[sundials] 45/76: New upstream version 2.7.0+dfsg

Andreas Tille tille at debian.org
Sun Feb 5 18:44:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository sundials.

commit a6cbcafcb2fd04a2bfc9d61cb4d24df36316576e
Author: Andreas Tille <tille at debian.org>
Date:   Sun Feb 5 15:15:42 2017 +0100

    New upstream version 2.7.0+dfsg
---
 CMakeLists.txt                                     |   565 +-
 INSTALL_NOTES                                      |   559 -
 LICENSE                                            |    65 +-
 Makefile.in                                        |   139 -
 README                                             |    57 +-
 acinclude.m4                                       |  3213 ---
 bin/fortran-update.in                              |   490 -
 bin/makefile-update.in                             |    32 -
 bin/sundials-config.in                             |   136 -
 config.hin                                         |    97 -
 config/CheckFortranFunctionExists.cmake            |    49 -
 config/FindBLAS.cmake                              |   186 -
 config/FindHypre.cmake                             |    47 +
 config/FindKLU.cmake                               |    73 +
 config/FindLAPACK.cmake                            |    96 -
 config/FindPETSc.cmake                             |    48 +
 config/FindSUPERLUMT.cmake                         |    85 +
 config/SundialsAddTest.cmake                       |    93 +
 config/SundialsCXX.cmake                           |    61 +
 config/SundialsFortran.cmake                       |     7 +-
 config/SundialsFortran90.cmake                     |    72 +
 config/SundialsHypre.cmake                         |    79 +
 config/SundialsKLU.cmake                           |    73 +
 config/SundialsLapack.cmake                        |    12 +-
 config/SundialsMPIC.cmake                          |    15 +-
 config/SundialsMPICXX.cmake                        |   120 +
 config/SundialsMPIF.cmake                          |     6 +-
 config/SundialsMPIF90.cmake                        |   105 +
 config/SundialsPETSc.cmake                         |    75 +
 config/SundialsSuperLUMT.cmake                     |    71 +
 config/config.guess                                |  1471 -
 config/config.sub                                  |  1599 --
 config/cust_general.m4                             |    94 -
 config/install-sh                                  |   251 -
 config/ltmain.sh                                   |  6868 -----
 config/mkinstalldirs                               |   137 -
 config/mod_c.m4                                    |    62 -
 config/mod_fortran.m4                              |   117 -
 config/rminstalldirs                               |    20 -
 configure                                          | 28297 -------------------
 configure.ac                                       |   157 -
 examples/arkode/CXX_parallel/CMakeLists.txt        |   141 +
 examples/arkode/CXX_parallel/README                |    55 +
 examples/arkode/CXX_parallel/ark_heat2D.cpp        |   813 +
 examples/arkode/CXX_parallel/ark_heat2D.out        |    49 +
 examples/arkode/CXX_parallel/plot_heat2D.py        |   142 +
 examples/arkode/CXX_serial/CMakeLists.txt          |   149 +
 examples/arkode/CXX_serial/README                  |    49 +
 examples/arkode/CXX_serial/ark_analytic_sys.cpp    |   352 +
 examples/arkode/CXX_serial/ark_analytic_sys.out    |    30 +
 examples/arkode/CXX_serial/plot_sol.py             |    62 +
 examples/arkode/C_openmp/CMakeLists.txt            |   133 +
 examples/arkode/C_openmp/README                    |    55 +
 examples/arkode/C_openmp/ark_brusselator1D_omp.c   |   514 +
 examples/arkode/C_openmp/ark_brusselator1D_omp.out |   122 +
 examples/arkode/C_openmp/plot_brusselator1D.py     |    73 +
 examples/arkode/C_parallel/CMakeLists.txt          |   144 +
 examples/arkode/C_parallel/README                  |    52 +
 examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c |   843 +
 .../arkode/C_parallel/ark_diurnal_kry_bbd_p.out    |   140 +
 examples/arkode/C_parallel/ark_diurnal_kry_p.c     |   956 +
 examples/arkode/C_parallel/ark_diurnal_kry_p.out   |    63 +
 examples/arkode/C_parhyp/CMakeLists.txt            |   146 +
 examples/arkode/C_parhyp/README                    |    50 +
 examples/arkode/C_parhyp/ark_diurnal_kry_ph.c      |  1009 +
 examples/arkode/C_parhyp/ark_diurnal_kry_ph.out    |    63 +
 examples/arkode/C_serial/CMakeLists.txt            |   218 +
 examples/arkode/C_serial/README                    |    62 +
 examples/arkode/C_serial/ark_KrylovDemo_prec.c     |  1155 +
 examples/arkode/C_serial/ark_KrylovDemo_prec.out   |   649 +
 examples/arkode/C_serial/ark_analytic.c            |   249 +
 examples/arkode/C_serial/ark_analytic.out          |    30 +
 examples/arkode/C_serial/ark_analytic_nonlin.c     |   190 +
 examples/arkode/C_serial/ark_analytic_nonlin.out   |    24 +
 examples/arkode/C_serial/ark_brusselator.c         |   322 +
 examples/arkode/C_serial/ark_brusselator.out       |    30 +
 examples/arkode/C_serial/ark_brusselator1D.c       |   478 +
 examples/arkode/C_serial/ark_brusselator1D.out     |   121 +
 .../arkode/C_serial/ark_brusselator1D_FEM_slu.c    |  1352 +
 .../arkode/C_serial/ark_brusselator1D_FEM_slu.out  |   121 +
 examples/arkode/C_serial/ark_brusselator1D_klu.c   |   630 +
 examples/arkode/C_serial/ark_brusselator1D_klu.out |    29 +
 examples/arkode/C_serial/ark_brusselator_fp.c      |   294 +
 examples/arkode/C_serial/ark_brusselator_fp.out    |    27 +
 examples/arkode/C_serial/ark_heat1D.c              |   320 +
 examples/arkode/C_serial/ark_heat1D.out            |    29 +
 examples/arkode/C_serial/ark_heat1D_adapt.c        |   514 +
 examples/arkode/C_serial/ark_heat1D_adapt.out      |   107 +
 examples/arkode/C_serial/ark_robertson.c           |   280 +
 examples/arkode/C_serial/ark_robertson.out         |   117 +
 examples/arkode/C_serial/ark_robertson_root.c      |   319 +
 examples/arkode/C_serial/ark_robertson_root.out    |    32 +
 examples/arkode/C_serial/bruss_plots.m             |    75 +
 examples/arkode/C_serial/plot_brusselator1D.py     |    73 +
 examples/arkode/C_serial/plot_brusselator1D_FEM.py |    80 +
 examples/arkode/C_serial/plot_heat1D.py            |    61 +
 examples/arkode/C_serial/plot_heat1D_adapt.py      |    88 +
 examples/arkode/C_serial/plot_sol.py               |    62 +
 examples/arkode/C_serial/plot_sol_log.py           |    62 +
 examples/arkode/F77_parallel/CMakeLists.txt        |   154 +
 examples/arkode/F77_parallel/README                |    50 +
 examples/arkode/F77_parallel/fark_diag_kry_bbd_p.f |   358 +
 .../arkode/F77_parallel/fark_diag_kry_bbd_p.out    |    87 +
 examples/arkode/F77_parallel/fark_diag_non_p.f     |   238 +
 examples/arkode/F77_parallel/fark_diag_non_p.out   |    34 +
 examples/arkode/F77_serial/CMakeLists.txt          |   157 +
 examples/arkode/F77_serial/README                  |    50 +
 examples/arkode/F77_serial/fark_diurnal_kry_bp.f   |   403 +
 examples/arkode/F77_serial/fark_diurnal_kry_bp.out |    73 +
 examples/arkode/F77_serial/fark_roberts_dnsL.f     |   307 +
 examples/arkode/F77_serial/fark_roberts_dnsL.out   |    34 +
 examples/arkode/F90_parallel/CMakeLists.txt        |   149 +
 examples/arkode/F90_parallel/README                |    55 +
 examples/arkode/F90_parallel/fark_heat2D.f90       |   879 +
 examples/arkode/F90_parallel/fark_heat2D.out       |    49 +
 examples/arkode/F90_parallel/plot_heat2D.py        |   141 +
 examples/arkode/F90_serial/CMakeLists.txt          |   185 +
 examples/arkode/F90_serial/README                  |    51 +
 examples/arkode/F90_serial/ark_bruss.f90           |   299 +
 examples/arkode/F90_serial/ark_bruss.out           |    25 +
 examples/arkode/F90_serial/ark_bruss1D_FEM_klu.f90 |  1134 +
 examples/arkode/F90_serial/ark_bruss1D_FEM_klu.out |    56 +
 .../arkode/F90_serial/plot_brusselator1D_FEM.py    |    80 +
 examples/arkode/F90_serial/plot_sol.py             |    62 +
 examples/cvode/C_openmp/CMakeLists.txt             |   128 +
 examples/cvode/C_openmp/README                     |    49 +
 examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c        |   458 +
 examples/cvode/C_openmp/cvAdvDiff_bnd_omp.out      |    23 +
 examples/cvode/fcmix_parallel/CMakeLists.txt       |    49 +-
 examples/cvode/fcmix_parallel/Makefile.in          |   116 -
 examples/cvode/fcmix_parallel/README               |    50 +-
 examples/cvode/fcmix_parallel/fcvDiag_kry_bbd_p.f  |    27 +-
 examples/cvode/fcmix_parallel/fcvDiag_kry_p.f      |    29 +-
 examples/cvode/fcmix_parallel/fcvDiag_non_p.f      |    17 +-
 examples/cvode/fcmix_serial/CMakeLists.txt         |    76 +-
 examples/cvode/fcmix_serial/Makefile.in            |   137 -
 examples/cvode/fcmix_serial/README                 |    49 +-
 examples/cvode/fcmix_serial/fcvAdvDiff_bnd.f       |    44 +-
 examples/cvode/fcmix_serial/fcvDiurnal_kry.f       |    65 +-
 examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.f    |    37 +-
 examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.out  |    66 +-
 examples/cvode/fcmix_serial/fcvRoberts_dns.f       |    22 +-
 examples/cvode/fcmix_serial/fcvRoberts_dnsL.f      |    28 +-
 examples/cvode/fcmix_serial/fcvRoberts_klu.f       |   324 +
 examples/cvode/fcmix_serial/fcvRoberts_klu.out     |    32 +
 examples/cvode/fcmix_serial/fcvRoberts_sps.f       |   306 +
 examples/cvode/fcmix_serial/fcvRoberts_sps.out     |    32 +
 examples/cvode/parallel/CMakeLists.txt             |    50 +-
 examples/cvode/parallel/Makefile.in                |   113 -
 examples/cvode/parallel/README                     |    51 +-
 examples/cvode/parallel/cvAdvDiff_diag_p.c         |   367 +
 examples/cvode/parallel/cvAdvDiff_diag_p.out       |    23 +
 examples/cvode/parallel/cvAdvDiff_non_p.c          |    22 +-
 examples/cvode/parallel/cvDiurnal_kry_bbd_p.c      |    46 +-
 examples/cvode/parallel/cvDiurnal_kry_p.c          |    56 +-
 examples/cvode/parhyp/CMakeLists.txt               |   140 +
 examples/cvode/parhyp/README                       |    52 +
 examples/cvode/parhyp/cvAdvDiff_non_ph.c           |   396 +
 examples/cvode/parhyp/cvAdvDiff_non_ph.out         |    21 +
 examples/cvode/serial/CMakeLists.txt               |    79 +-
 examples/cvode/serial/Makefile.in                  |   139 -
 examples/cvode/serial/README                       |    52 +-
 examples/cvode/serial/cvAdvDiff_bnd.c              |    24 +-
 examples/cvode/serial/cvAdvDiff_bndL.c             |    18 +-
 examples/cvode/serial/cvDirectDemo_ls.c            |    62 +-
 examples/cvode/serial/cvDirectDemo_ls.out          |     4 +-
 examples/cvode/serial/cvDiurnal_kry.c              |   100 +-
 examples/cvode/serial/cvDiurnal_kry_bp.c           |    55 +-
 examples/cvode/serial/cvDiurnal_kry_bp.out         |    92 +-
 examples/cvode/serial/cvKrylovDemo_ls.c            |    60 +-
 examples/cvode/serial/cvKrylovDemo_prec.c          |    70 +-
 examples/cvode/serial/cvRoberts_dns.c              |    10 +-
 examples/cvode/serial/cvRoberts_dnsL.c             |    11 +-
 examples/cvode/serial/cvRoberts_dns_uw.c           |    12 +-
 examples/cvode/serial/cvRoberts_klu.c              |   382 +
 examples/cvode/serial/cvRoberts_klu.out            |    24 +
 examples/cvode/serial/cvRoberts_sps.c              |   378 +
 examples/cvode/serial/cvRoberts_sps.out            |    24 +
 examples/cvodes/C_openmp/CMakeLists.txt            |   128 +
 examples/cvodes/C_openmp/README                    |    49 +
 examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c      |   458 +
 examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.out    |    23 +
 examples/cvodes/parallel/CMakeLists.txt            |    80 +-
 examples/cvodes/parallel/Makefile.in               |   116 -
 examples/cvodes/parallel/README                    |    50 +-
 examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c   |    48 +-
 examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c    |    28 +-
 examples/cvodes/parallel/cvsAdvDiff_non_p.c        |    22 +-
 .../cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c    |   236 +-
 .../cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.out  |    37 +-
 examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c    |    64 +-
 examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c    |    46 +-
 examples/cvodes/parallel/cvsDiurnal_kry_p.c        |    56 +-
 examples/cvodes/serial/CMakeLists.txt              |   192 +-
 examples/cvodes/serial/Makefile.in                 |   146 -
 examples/cvodes/serial/README                      |    53 +-
 examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c       |    28 +-
 examples/cvodes/serial/cvsAdvDiff_FSA_non.c        |    25 +-
 examples/cvodes/serial/cvsAdvDiff_bnd.c            |    24 +-
 examples/cvodes/serial/cvsAdvDiff_bndL.c           |    18 +-
 examples/cvodes/serial/cvsDirectDemo_ls.c          |    61 +-
 examples/cvodes/serial/cvsDiurnal_FSA_kry.c        |    68 +-
 examples/cvodes/serial/cvsDiurnal_kry.c            |   100 +-
 examples/cvodes/serial/cvsDiurnal_kry_bp.c         |    48 +-
 examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c       |    80 +-
 examples/cvodes/serial/cvsFoodWeb_ASAi_kry.out     |     2 +-
 examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c       |    74 +-
 examples/cvodes/serial/cvsHessian_ASA_FSA.c        |    61 +-
 examples/cvodes/serial/cvsHessian_ASA_FSA.out      |    46 +-
 examples/cvodes/serial/cvsKrylovDemo_ls.c          |    63 +-
 examples/cvodes/serial/cvsKrylovDemo_prec.c        |    70 +-
 examples/cvodes/serial/cvsRoberts_ASAi_dns.c       |   150 +-
 examples/cvodes/serial/cvsRoberts_ASAi_dns.out     |    37 +-
 examples/cvodes/serial/cvsRoberts_ASAi_klu.c       |   825 +
 examples/cvodes/serial/cvsRoberts_ASAi_klu.out     |    60 +
 examples/cvodes/serial/cvsRoberts_ASAi_sps.c       |   826 +
 examples/cvodes/serial/cvsRoberts_ASAi_sps.out     |    60 +
 examples/cvodes/serial/cvsRoberts_FSA_dns.c        |    28 +-
 examples/cvodes/serial/cvsRoberts_FSA_klu.c        |   672 +
 examples/cvodes/serial/cvsRoberts_FSA_klu.out      |    93 +
 examples/cvodes/serial/cvsRoberts_FSA_sps.c        |   673 +
 examples/cvodes/serial/cvsRoberts_FSA_sps.out      |    93 +
 examples/cvodes/serial/cvsRoberts_dns.c            |    10 +-
 examples/cvodes/serial/cvsRoberts_dnsL.c           |     8 +-
 examples/cvodes/serial/cvsRoberts_dns_uw.c         |    12 +-
 examples/cvodes/serial/cvsRoberts_klu.c            |   382 +
 examples/cvodes/serial/cvsRoberts_klu.out          |    24 +
 examples/cvodes/serial/cvsRoberts_sps.c            |   378 +
 examples/cvodes/serial/cvsRoberts_sps.out          |    24 +
 examples/ida/C_openmp/CMakeLists.txt               |   143 +
 examples/ida/C_openmp/README                       |    50 +
 examples/ida/C_openmp/idaFoodWeb_bnd_omp.c         |   705 +
 examples/ida/C_openmp/idaFoodWeb_bnd_omp.out       |    44 +
 examples/ida/C_openmp/idaFoodWeb_kry_omp.c         |   841 +
 examples/ida/C_openmp/idaFoodWeb_kry_omp.out       |    44 +
 examples/ida/fcmix_openmp/CMakeLists.txt           |   150 +
 examples/ida/fcmix_openmp/README                   |    49 +
 examples/ida/fcmix_openmp/fidaRoberts_dns_openmp.f |   271 +
 .../ida/fcmix_openmp/fidaRoberts_dns_openmp.out    |    34 +
 examples/ida/fcmix_parallel/CMakeLists.txt         |    43 +-
 examples/ida/fcmix_parallel/Makefile.in            |   114 -
 examples/ida/fcmix_parallel/README                 |    50 +-
 examples/ida/fcmix_parallel/fidaHeat2D_kry_bbd_p.f |   175 +-
 examples/ida/fcmix_pthreads/CMakeLists.txt         |   146 +
 examples/ida/fcmix_pthreads/README                 |    50 +
 .../ida/fcmix_pthreads/fidaRoberts_dns_pthreads.f  |   271 +
 .../fcmix_pthreads/fidaRoberts_dns_pthreads.out    |    34 +
 examples/ida/fcmix_serial/CMakeLists.txt           |    30 +-
 examples/ida/fcmix_serial/Makefile.in              |   134 -
 examples/ida/fcmix_serial/README                   |    49 +-
 examples/ida/fcmix_serial/fidaRoberts_dns.f        |    29 +-
 examples/ida/parallel/CMakeLists.txt               |    52 +-
 examples/ida/parallel/Makefile.in                  |   113 -
 examples/ida/parallel/README                       |    50 +-
 examples/ida/parallel/idaFoodWeb_kry_bbd_p.c       |    24 +-
 examples/ida/parallel/idaFoodWeb_kry_p.c           |    26 +-
 examples/ida/parallel/idaHeat2D_kry_bbd_p.c        |    26 +-
 examples/ida/parallel/idaHeat2D_kry_p.c            |    26 +-
 examples/ida/petsc/CMakeLists.txt                  |   134 +
 examples/ida/petsc/README                          |    50 +
 examples/ida/petsc/idaHeat2D_kry_petsc.c           |   730 +
 examples/ida/petsc/idaHeat2D_kry_petsc.out         |    33 +
 examples/ida/serial/CMakeLists.txt                 |    84 +-
 examples/ida/serial/Makefile.in                    |   134 -
 examples/ida/serial/README                         |    52 +-
 examples/ida/serial/idaFoodWeb_bnd.c               |    37 +-
 examples/ida/serial/idaFoodWeb_bnd.out             |    14 +-
 examples/ida/serial/idaFoodWeb_kry.c               |   808 +
 examples/ida/serial/idaFoodWeb_kry.out             |    42 +
 examples/ida/serial/idaHeat2D_bnd.c                |    22 +-
 examples/ida/serial/idaHeat2D_klu.c                |   747 +
 examples/ida/serial/idaHeat2D_klu.out              |    30 +
 examples/ida/serial/idaHeat2D_kry.c                |    24 +-
 examples/ida/serial/idaKrylovDemo_ls.c             |    24 +-
 examples/ida/serial/idaRoberts_dns.c               |    40 +-
 examples/ida/serial/idaRoberts_klu.c               |   488 +
 examples/ida/serial/idaRoberts_klu.out             |    38 +
 examples/ida/serial/idaRoberts_sps.c               |   421 +
 examples/ida/serial/idaRoberts_sps.out             |    38 +
 examples/ida/serial/idaSlCrank_dns.c               |    19 +-
 examples/idas/C_openmp/CMakeLists.txt              |   129 +
 examples/idas/C_openmp/README                      |    50 +
 examples/idas/C_openmp/idasFoodWeb_bnd_omp.c       |   705 +
 examples/idas/C_openmp/idasFoodWeb_bnd_omp.out     |    44 +
 examples/idas/C_openmp/idasFoodWeb_kry_omp.c       |   841 +
 examples/idas/C_openmp/idasFoodWeb_kry_omp.out     |    44 +
 examples/idas/parallel/CMakeLists.txt              |    75 +-
 examples/idas/parallel/Makefile.in                 |   117 -
 examples/idas/parallel/README                      |    50 +-
 examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c  |    26 +-
 examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c   |    22 +-
 examples/idas/parallel/idasBruss_kry_bbd_p.c       |    18 +-
 examples/idas/parallel/idasFoodWeb_kry_bbd_p.c     |    20 +-
 examples/idas/parallel/idasFoodWeb_kry_p.c         |    26 +-
 examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c  |    26 +-
 examples/idas/parallel/idasHeat2D_kry_bbd_p.c      |    26 +-
 examples/idas/parallel/idasHeat2D_kry_p.c          |    26 +-
 examples/idas/serial/CMakeLists.txt                |   117 +-
 examples/idas/serial/Makefile.in                   |   142 -
 examples/idas/serial/README                        |    53 +-
 examples/idas/serial/idasAkzoNob_ASAi_dns.c        |    35 +-
 examples/idas/serial/idasAkzoNob_dns.c             |    43 +-
 examples/idas/serial/idasFoodWeb_bnd.c             |    30 +-
 examples/idas/serial/idasFoodWeb_bnd.out           |    14 +-
 examples/idas/serial/idasHeat2D_bnd.c              |    22 +-
 examples/idas/serial/idasHeat2D_kry.c              |    24 +-
 examples/idas/serial/idasHessian_ASA_FSA.c         |    53 +-
 examples/idas/serial/idasKrylovDemo_ls.c           |    24 +-
 examples/idas/serial/idasRoberts_ASAi_dns.c        |    67 +-
 examples/idas/serial/idasRoberts_ASAi_klu.c        |   768 +
 examples/idas/serial/idasRoberts_ASAi_klu.out      |    37 +
 examples/idas/serial/idasRoberts_ASAi_sps.c        |   769 +
 examples/idas/serial/idasRoberts_ASAi_sps.out      |    37 +
 examples/idas/serial/idasRoberts_FSA_dns.c         |    61 +-
 examples/idas/serial/idasRoberts_FSA_klu.c         |   830 +
 examples/idas/serial/idasRoberts_FSA_klu.out       |   113 +
 examples/idas/serial/idasRoberts_FSA_sps.c         |   831 +
 examples/idas/serial/idasRoberts_FSA_sps.out       |   113 +
 examples/idas/serial/idasRoberts_dns.c             |    40 +-
 examples/idas/serial/idasRoberts_klu.c             |   427 +
 examples/idas/serial/idasRoberts_klu.out           |    38 +
 examples/idas/serial/idasRoberts_sps.c             |   421 +
 examples/idas/serial/idasRoberts_sps.out           |    38 +
 examples/idas/serial/idasSlCrank_FSA_dns.c         |    32 +-
 examples/idas/serial/idasSlCrank_dns.c             |    22 +-
 examples/kinsol/C_openmp/CMakeLists.txt            |   128 +
 examples/kinsol/C_openmp/README                    |    49 +
 examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c      |   824 +
 examples/kinsol/C_openmp/kinFoodWeb_kry_omp.out    |    30 +
 examples/kinsol/fcmix_parallel/CMakeLists.txt      |    39 +-
 examples/kinsol/fcmix_parallel/Makefile.in         |   114 -
 examples/kinsol/fcmix_parallel/README              |    50 +-
 examples/kinsol/fcmix_parallel/fkinDiagon_kry_p.f  |    68 +-
 examples/kinsol/fcmix_serial/CMakeLists.txt        |    26 +-
 examples/kinsol/fcmix_serial/Makefile.in           |   134 -
 examples/kinsol/fcmix_serial/README                |    49 +-
 examples/kinsol/fcmix_serial/fkinDiagon_kry.f      |    81 +-
 examples/kinsol/parallel/CMakeLists.txt            |    43 +-
 examples/kinsol/parallel/Makefile.in               |   111 -
 examples/kinsol/parallel/README                    |    50 +-
 examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c    |    26 +-
 examples/kinsol/parallel/kinFoodWeb_kry_p.c        |    28 +-
 examples/kinsol/serial/CMakeLists.txt              |    78 +-
 examples/kinsol/serial/Makefile.in                 |   133 -
 examples/kinsol/serial/README                      |    62 +-
 examples/kinsol/serial/kinFerTron_dns.c            |    31 +-
 examples/kinsol/serial/kinFerTron_klu.c            |   623 +
 examples/kinsol/serial/kinFerTron_klu.out          |    71 +
 examples/kinsol/serial/kinFoodWeb_kry.c            |    22 +-
 examples/kinsol/serial/kinKrylovDemo_ls.c          |   111 +-
 examples/kinsol/serial/kinKrylovDemo_ls.out        |    53 +-
 examples/kinsol/serial/kinLaplace_bnd.c            |    28 +-
 examples/kinsol/serial/kinLaplace_picard_bnd.c     |   432 +
 examples/kinsol/serial/kinLaplace_picard_bnd.out   |    30 +
 examples/kinsol/serial/kinRoberts_fp.c             |   299 +
 examples/kinsol/serial/kinRoberts_fp.out           |    17 +
 examples/kinsol/serial/kinRoboKin_dns.c            |    20 +-
 examples/kinsol/serial/kinRoboKin_slu.c            |   614 +
 examples/kinsol/serial/kinRoboKin_slu.out          |    32 +
 examples/nvector/C_openmp/CMakeLists.txt           |   120 +
 examples/nvector/C_openmp/test_nvector_openmp.c    |   160 +
 examples/nvector/parallel/CMakeLists.txt           |   131 +
 examples/nvector/parallel/test_nvector_mpi.c       |   153 +
 examples/nvector/parhyp/CMakeLists.txt             |   136 +
 examples/nvector/parhyp/test_nvector_parhyp.c      |   315 +
 examples/nvector/petsc/CMakeLists.txt              |   133 +
 examples/nvector/petsc/test_nvector_petsc.c        |   239 +
 examples/nvector/pthreads/CMakeLists.txt           |   124 +
 examples/nvector/pthreads/test_nvector_pthreads.c  |   161 +
 examples/nvector/serial/CMakeLists.txt             |   117 +
 examples/nvector/serial/test_nvector_serial.c      |   153 +
 examples/nvector/test_nvector.c                    |  1842 ++
 examples/nvector/test_nvector.h                    |    87 +
 examples/templates/cmakelists_openmp_C_ex.in       |   111 +
 examples/templates/cmakelists_openmp_F77_ex.in     |   107 +
 examples/templates/cmakelists_parallel_CXX_ex.in   |   100 +
 examples/templates/cmakelists_parallel_C_ex.in     |    31 +-
 examples/templates/cmakelists_parallel_F77_ex.in   |    27 +-
 examples/templates/cmakelists_parallel_F90_ex.in   |    97 +
 examples/templates/cmakelists_parhyp_C_ex.in       |   110 +
 examples/templates/cmakelists_petsc_C_ex.in        |   109 +
 examples/templates/cmakelists_pthreads_C_ex.in     |    85 +
 examples/templates/cmakelists_pthreads_F77_ex.in   |   100 +
 examples/templates/cmakelists_serial_CXX_ex.in     |    93 +
 examples/templates/cmakelists_serial_C_ex.in       |    31 +-
 examples/templates/cmakelists_serial_F77_ex.in     |    26 +-
 examples/templates/cmakelists_serial_F90_ex.in     |    93 +
 examples/templates/makefile_openmp_C_ex.in         |    83 +
 examples/templates/makefile_openmp_F77_ex.in       |    76 +
 examples/templates/makefile_parallel_CXX_ex.in     |    82 +
 examples/templates/makefile_parallel_C_ex.in       |    17 +-
 examples/templates/makefile_parallel_F77_ex.in     |    13 +-
 examples/templates/makefile_parallel_F90_ex.in     |    80 +
 examples/templates/makefile_parhyp_C_ex.in         |    90 +
 examples/templates/makefile_petsc_C_ex.in          |    89 +
 examples/templates/makefile_pthreads_C_ex.in       |    81 +
 examples/templates/makefile_pthreads_F77_ex.in     |    76 +
 examples/templates/makefile_serial_CXX_ex.in       |    77 +
 examples/templates/makefile_serial_C_ex.in         |    18 +-
 examples/templates/makefile_serial_F77_ex.in       |    13 +-
 examples/templates/makefile_serial_F90_ex.in       |    74 +
 include/arkode/arkode.h                            |  1380 +
 include/arkode/arkode_band.h                       |    94 +
 include/arkode/arkode_bandpre.h                    |   149 +
 include/arkode/arkode_bbdpre.h                     |   271 +
 include/arkode/arkode_dense.h                      |    77 +
 include/arkode/arkode_direct.h                     |   373 +
 include/arkode/arkode_klu.h                        |   195 +
 include/arkode/arkode_lapack.h                     |   134 +
 include/arkode/arkode_pcg.h                        |   116 +
 include/arkode/arkode_sparse.h                     |   216 +
 include/arkode/arkode_spbcgs.h                     |   106 +
 include/arkode/arkode_spfgmr.h                     |   115 +
 include/arkode/arkode_spgmr.h                      |   109 +
 include/arkode/arkode_spils.h                      |   529 +
 include/arkode/arkode_sptfqmr.h                    |   104 +
 include/arkode/arkode_superlumt.h                  |   138 +
 include/cvode/cvode.h                              |    18 +-
 include/cvode/cvode_band.h                         |    17 +-
 include/cvode/cvode_bandpre.h                      |    19 +-
 include/cvode/cvode_bbdpre.h                       |    17 +-
 include/cvode/cvode_dense.h                        |    17 +-
 include/cvode/cvode_diag.h                         |    15 +-
 include/cvode/cvode_direct.h                       |    17 +-
 include/cvode/cvode_klu.h                          |   111 +
 include/cvode/cvode_lapack.h                       |    17 +-
 include/cvode/cvode_sparse.h                       |   182 +
 include/cvode/cvode_spbcgs.h                       |    17 +-
 include/cvode/cvode_spgmr.h                        |    17 +-
 include/cvode/cvode_spils.h                        |    17 +-
 include/cvode/cvode_sptfqmr.h                      |    17 +-
 include/cvode/cvode_superlumt.h                    |    84 +
 include/cvodes/cvodes.h                            |    18 +-
 include/cvodes/cvodes_band.h                       |    18 +-
 include/cvodes/cvodes_bandpre.h                    |    20 +-
 include/cvodes/cvodes_bbdpre.h                     |    18 +-
 include/cvodes/cvodes_dense.h                      |    18 +-
 include/cvodes/cvodes_diag.h                       |    16 +-
 include/cvodes/cvodes_direct.h                     |    66 +-
 include/cvodes/cvodes_klu.h                        |   156 +
 include/cvodes/cvodes_lapack.h                     |    19 +-
 include/cvodes/cvodes_sparse.h                     |   255 +
 include/cvodes/cvodes_spbcgs.h                     |    27 +-
 include/cvodes/cvodes_spgmr.h                      |    27 +-
 include/cvodes/cvodes_spils.h                      |   106 +-
 include/cvodes/cvodes_sptfqmr.h                    |    27 +-
 include/cvodes/cvodes_superlumt.h                  |   111 +
 include/ida/ida.h                                  |    34 +-
 include/ida/ida_band.h                             |    17 +-
 include/ida/ida_bbdpre.h                           |    17 +-
 include/ida/ida_dense.h                            |    17 +-
 include/ida/ida_direct.h                           |    47 +-
 include/ida/ida_klu.h                              |   122 +
 include/ida/ida_lapack.h                           |    17 +-
 include/ida/ida_sparse.h                           |   268 +
 include/ida/ida_spbcgs.h                           |    17 +-
 include/ida/ida_spgmr.h                            |    23 +-
 include/ida/ida_spils.h                            |    23 +-
 include/ida/ida_sptfqmr.h                          |    17 +-
 include/ida/ida_superlumt.h                        |    99 +
 include/idas/idas.h                                |    29 +-
 include/idas/idas_band.h                           |    18 +-
 include/idas/idas_bbdpre.h                         |    16 +-
 include/idas/idas_dense.h                          |    18 +-
 include/idas/idas_direct.h                         |    74 +-
 include/idas/idas_klu.h                            |   157 +
 include/idas/idas_lapack.h                         |    23 +-
 include/idas/idas_sparse.h                         |   269 +
 include/idas/idas_spbcgs.h                         |    27 +-
 include/idas/idas_spgmr.h                          |    33 +-
 include/idas/idas_spils.h                          |    92 +-
 include/idas/idas_sptfqmr.h                        |    28 +-
 include/idas/idas_superlumt.h                      |   112 +
 include/kinsol/kinsol.h                            |    24 +-
 include/kinsol/kinsol_band.h                       |    17 +-
 include/kinsol/kinsol_bbdpre.h                     |    15 +-
 include/kinsol/kinsol_dense.h                      |    17 +-
 include/kinsol/kinsol_direct.h                     |    17 +-
 include/kinsol/kinsol_klu.h                        |   111 +
 include/kinsol/kinsol_lapack.h                     |    17 +-
 include/kinsol/kinsol_sparse.h                     |   165 +
 include/kinsol/kinsol_spbcgs.h                     |    17 +-
 include/kinsol/kinsol_spfgmr.h                     |    90 +
 include/kinsol/kinsol_spgmr.h                      |    17 +-
 include/kinsol/kinsol_spils.h                      |    18 +-
 include/kinsol/kinsol_sptfqmr.h                    |    17 +-
 include/kinsol/kinsol_superlumt.h                  |    87 +
 include/nvector/nvector_openmp.h                   |   289 +
 include/nvector/nvector_parallel.h                 |    57 +-
 include/nvector/nvector_parhyp.h                   |   237 +
 include/nvector/nvector_petsc.h                    |   240 +
 include/nvector/nvector_pthreads.h                 |   310 +
 include/nvector/nvector_serial.h                   |    27 +-
 include/sundials/sundials_band.h                   |    50 +-
 include/sundials/sundials_config.in                |    30 +-
 include/sundials/sundials_dense.h                  |    50 +-
 include/sundials/sundials_direct.h                 |    25 +-
 include/sundials/sundials_fnvector.h               |    20 +-
 include/sundials/sundials_iterative.h              |    17 +-
 include/sundials/sundials_klu_impl.h               |    57 +
 include/sundials/sundials_lapack.h                 |    11 +-
 include/sundials/sundials_math.h                   |    82 +-
 include/sundials/sundials_nvector.h                |    40 +-
 include/sundials/sundials_pcg.h                    |   156 +
 include/sundials/sundials_sparse.h                 |   237 +
 include/sundials/sundials_spbcgs.h                 |    15 +-
 include/sundials/sundials_spfgmr.h                 |   284 +
 include/sundials/sundials_spgmr.h                  |    15 +-
 include/sundials/sundials_sptfqmr.h                |    15 +-
 include/sundials/sundials_superlumt_impl.h         |    61 +
 include/sundials/sundials_types.h                  |    12 +-
 src/arkode/CMakeLists.txt                          |   161 +
 src/arkode/LICENSE                                 |    32 +
 src/arkode/README                                  |    72 +
 src/arkode/arkode.c                                |  6396 +++++
 src/arkode/arkode_band.c                           |   637 +
 src/arkode/arkode_bandpre.c                        |   465 +
 src/arkode/arkode_bandpre_impl.h                   |    72 +
 src/arkode/arkode_bbdpre.c                         |   547 +
 src/arkode/arkode_bbdpre_impl.h                    |    77 +
 src/arkode/arkode_butcher.c                        |  1038 +
 src/arkode/arkode_dense.c                          |   613 +
 src/arkode/arkode_direct.c                         |   617 +
 src/arkode/arkode_direct_impl.h                    |   141 +
 src/arkode/arkode_impl.h                           |   805 +
 src/arkode/arkode_io.c                             |  2944 ++
 src/arkode/arkode_klu.c                            |  1275 +
 src/arkode/arkode_lapack.c                         |  1270 +
 src/arkode/arkode_pcg.c                            |   772 +
 src/arkode/arkode_sparse.c                         |   268 +
 src/arkode/arkode_sparse_impl.h                    |   127 +
 src/arkode/arkode_spbcgs.c                         |   766 +
 src/arkode/arkode_spfgmr.c                         |   777 +
 src/arkode/arkode_spgmr.c                          |   779 +
 src/arkode/arkode_spils.c                          |  1191 +
 src/arkode/arkode_spils_impl.h                     |   192 +
 src/arkode/arkode_sptfqmr.c                        |   767 +
 src/arkode/arkode_superlumt.c                      |  1097 +
 src/arkode/fcmix/CMakeLists.txt                    |    76 +
 src/arkode/fcmix/farkadapt.c                       |    82 +
 src/arkode/fcmix/farkband.c                        |    97 +
 src/arkode/fcmix/farkbandmass.c                    |    84 +
 src/arkode/fcmix/farkbbd.c                         |   129 +
 src/arkode/fcmix/farkbbd.h                         |   645 +
 src/arkode/fcmix/farkbp.c                          |    55 +
 src/arkode/fcmix/farkbp.h                          |   491 +
 src/arkode/fcmix/farkdense.c                       |    90 +
 src/arkode/fcmix/farkdensemass.c                   |    78 +
 src/arkode/fcmix/farkewt.c                         |    76 +
 src/arkode/fcmix/farkexpstab.c                     |    77 +
 src/arkode/fcmix/farkjtimes.c                      |    90 +
 src/arkode/fcmix/farkklu.c                         |    66 +
 src/arkode/fcmix/farklapack.c                      |    71 +
 src/arkode/fcmix/farklapband.c                     |   103 +
 src/arkode/fcmix/farklapbandmass.c                 |    84 +
 src/arkode/fcmix/farklapdense.c                    |    93 +
 src/arkode/fcmix/farklapdensemass.c                |    80 +
 src/arkode/fcmix/farkmasspreco.c                   |   110 +
 src/arkode/fcmix/farkmtimes.c                      |    77 +
 src/arkode/fcmix/farkode.c                         |  1189 +
 src/arkode/fcmix/farkode.h                         |  2308 ++
 src/arkode/fcmix/farkpreco.c                       |   124 +
 src/arkode/fcmix/farkroot.c                        |   100 +
 src/arkode/fcmix/farkroot.h                        |   153 +
 src/arkode/fcmix/farksparse.c                      |    86 +
 src/arkode/fcmix/farksparsemass.c                  |    79 +
 src/arkode/fcmix/farksuperlumt.c                   |    53 +
 src/cvode/CMakeLists.txt                           |    46 +-
 src/cvode/LICENSE                                  |    57 +-
 src/cvode/Makefile.in                              |   175 -
 src/cvode/README                                   |   403 +-
 src/cvode/cvode.c                                  |  1166 +-
 src/cvode/cvode_band.c                             |    43 +-
 src/cvode/cvode_bandpre.c                          |    78 +-
 src/cvode/cvode_bandpre_impl.h                     |    19 +-
 src/cvode/cvode_bbdpre.c                           |    92 +-
 src/cvode/cvode_bbdpre_impl.h                      |    17 +-
 src/cvode/cvode_dense.c                            |    43 +-
 src/cvode/cvode_diag.c                             |    41 +-
 src/cvode/cvode_diag_impl.h                        |    15 +-
 src/cvode/cvode_direct.c                           |    62 +-
 src/cvode/cvode_direct_impl.h                      |    29 +-
 src/cvode/cvode_impl.h                             |    33 +-
 src/cvode/cvode_io.c                               |   109 +-
 src/cvode/cvode_klu.c                              |   612 +
 src/cvode/cvode_lapack.c                           |    69 +-
 src/cvode/cvode_sparse.c                           |   175 +
 src/cvode/cvode_sparse_impl.h                      |   109 +
 src/cvode/cvode_spbcgs.c                           |    48 +-
 src/cvode/cvode_spgmr.c                            |    48 +-
 src/cvode/cvode_spils.c                            |    90 +-
 src/cvode/cvode_spils_impl.h                       |    23 +-
 src/cvode/cvode_sptfqmr.c                          |    54 +-
 src/cvode/cvode_superlumt.c                        |   554 +
 src/cvode/fcmix/CMakeLists.txt                     |    20 +-
 src/cvode/fcmix/Makefile.in                        |   125 -
 src/cvode/fcmix/fcvband.c                          |    14 +-
 src/cvode/fcmix/fcvbbd.c                           |    11 +-
 src/cvode/fcmix/fcvbbd.h                           |    32 +-
 src/cvode/fcmix/fcvbp.c                            |    11 +-
 src/cvode/fcmix/fcvbp.h                            |    38 +-
 src/cvode/fcmix/fcvdense.c                         |    14 +-
 src/cvode/fcmix/fcvewt.c                           |    14 +-
 src/cvode/fcmix/fcvjtimes.c                        |    14 +-
 src/cvode/fcmix/fcvklu.c                           |    52 +
 src/cvode/fcmix/fcvlapack.c                        |    11 +-
 src/cvode/fcmix/fcvlapband.c                       |    19 +-
 src/cvode/fcmix/fcvlapdense.c                      |    14 +-
 src/cvode/fcmix/fcvode.c                           |    55 +-
 src/cvode/fcmix/fcvode.h                           |   255 +-
 src/cvode/fcmix/fcvpreco.c                         |    14 +-
 src/cvode/fcmix/fcvroot.c                          |    14 +-
 src/cvode/fcmix/fcvroot.h                          |    20 +-
 src/cvode/fcmix/fcvsparse.c                        |    81 +
 src/cvode/fcmix/fcvsuperlumt.c                     |    42 +
 src/cvodes/CMakeLists.txt                          |    30 +-
 src/cvodes/LICENSE                                 |    57 +-
 src/cvodes/Makefile.in                             |   180 -
 src/cvodes/README                                  |   411 +-
 src/cvodes/cvodea.c                                |    41 +-
 src/cvodes/cvodea_io.c                             |    11 +-
 src/cvodes/cvodes.c                                |   574 +-
 src/cvodes/cvodes_band.c                           |    33 +-
 src/cvodes/cvodes_bandpre.c                        |    50 +-
 src/cvodes/cvodes_bandpre_impl.h                   |    19 +-
 src/cvodes/cvodes_bbdpre.c                         |    63 +-
 src/cvodes/cvodes_bbdpre_impl.h                    |    17 +-
 src/cvodes/cvodes_dense.c                          |    39 +-
 src/cvodes/cvodes_diag.c                           |    17 +-
 src/cvodes/cvodes_diag_impl.h                      |    15 +-
 src/cvodes/cvodes_direct.c                         |   253 +-
 src/cvodes/cvodes_direct_impl.h                    |    32 +-
 src/cvodes/cvodes_impl.h                           |    32 +-
 src/cvodes/cvodes_io.c                             |    19 +-
 src/cvodes/cvodes_klu.c                            |   818 +
 src/cvodes/cvodes_lapack.c                         |    55 +-
 src/cvodes/cvodes_sparse.c                         |   407 +
 src/cvodes/cvodes_sparse_impl.h                    |   137 +
 src/cvodes/cvodes_spbcgs.c                         |    32 +-
 src/cvodes/cvodes_spgmr.c                          |    32 +-
 src/cvodes/cvodes_spils.c                          |   322 +-
 src/cvodes/cvodes_spils_impl.h                     |    31 +-
 src/cvodes/cvodes_sptfqmr.c                        |    38 +-
 src/cvodes/cvodes_superlumt.c                      |   705 +
 src/ida/CMakeLists.txt                             |    39 +-
 src/ida/LICENSE                                    |     2 +-
 src/ida/Makefile.in                                |   169 -
 src/ida/README                                     |   331 +-
 src/ida/fcmix/CMakeLists.txt                       |    20 +-
 src/ida/fcmix/Makefile.in                          |   123 -
 src/ida/fcmix/fida.c                               |    79 +-
 src/ida/fcmix/fida.h                               |   250 +-
 src/ida/fcmix/fidaband.c                           |    11 +-
 src/ida/fcmix/fidabbd.c                            |    11 +-
 src/ida/fcmix/fidabbd.h                            |    22 +-
 src/ida/fcmix/fidadense.c                          |    11 +-
 src/ida/fcmix/fidaewt.c                            |    11 +-
 src/ida/fcmix/fidajtimes.c                         |    11 +-
 src/ida/fcmix/fidaklu.c                            |    52 +
 src/ida/fcmix/fidalapack.c                         |    11 +-
 src/ida/fcmix/fidalapband.c                        |    11 +-
 src/ida/fcmix/fidalapdense.c                       |    11 +-
 src/ida/fcmix/fidapreco.c                          |    11 +-
 src/ida/fcmix/fidaroot.c                           |    11 +-
 src/ida/fcmix/fidaroot.h                           |    20 +-
 src/ida/fcmix/fidasparse.c                         |    82 +
 src/ida/fcmix/fidasuperlumt.c                      |    42 +
 src/ida/ida.c                                      |   214 +-
 src/ida/ida_band.c                                 |    27 +-
 src/ida/ida_bbdpre.c                               |    64 +-
 src/ida/ida_bbdpre_impl.h                          |    17 +-
 src/ida/ida_dense.c                                |    24 +-
 src/ida/ida_direct.c                               |    46 +-
 src/ida/ida_direct_impl.h                          |    34 +-
 src/ida/ida_ic.c                                   |    44 +-
 src/ida/ida_impl.h                                 |    46 +-
 src/ida/ida_io.c                                   |    44 +-
 src/ida/ida_klu.c                                  |   564 +
 src/ida/ida_lapack.c                               |    24 +-
 src/ida/ida_sparse.c                               |   175 +
 src/ida/ida_sparse_impl.h                          |   127 +
 src/ida/ida_spbcgs.c                               |    23 +-
 src/ida/ida_spgmr.c                                |    30 +-
 src/ida/ida_spils.c                                |    31 +-
 src/ida/ida_spils_impl.h                           |    22 +-
 src/ida/ida_sptfqmr.c                              |    23 +-
 src/ida/ida_superlumt.c                            |   522 +
 src/idas/CMakeLists.txt                            |    45 +-
 src/idas/LICENSE                                   |     4 +-
 src/idas/Makefile.in                               |   173 -
 src/idas/README                                    |    66 +-
 src/idas/idaa.c                                    |    46 +-
 src/idas/idaa_io.c                                 |    19 +-
 src/idas/idas.c                                    |   267 +-
 src/idas/idas_band.c                               |    29 +-
 src/idas/idas_bbdpre.c                             |    69 +-
 src/idas/idas_bbdpre_impl.h                        |    17 +-
 src/idas/idas_dense.c                              |    30 +-
 src/idas/idas_direct.c                             |   283 +-
 src/idas/idas_direct_impl.h                        |    38 +-
 src/idas/idas_ic.c                                 |    66 +-
 src/idas/idas_impl.h                               |    27 +-
 src/idas/idas_io.c                                 |    47 +-
 src/idas/idas_klu.c                                |   780 +
 src/idas/idas_lapack.c                             |   212 +-
 src/idas/idas_sparse.c                             |   429 +
 src/idas/idas_sparse_impl.h                        |   127 +
 src/idas/idas_spbcgs.c                             |    31 +-
 src/idas/idas_spgmr.c                              |    37 +-
 src/idas/idas_spils.c                              |   381 +-
 src/idas/idas_spils_impl.h                         |    24 +-
 src/idas/idas_sptfqmr.c                            |    37 +-
 src/idas/idas_superlumt.c                          |   679 +
 src/kinsol/CMakeLists.txt                          |    56 +-
 src/kinsol/LICENSE                                 |     4 +-
 src/kinsol/Makefile.in                             |   167 -
 src/kinsol/README                                  |   341 +-
 src/kinsol/fcmix/CMakeLists.txt                    |    20 +-
 src/kinsol/fcmix/Makefile.in                       |   119 -
 src/kinsol/fcmix/fkinband.c                        |    11 +-
 src/kinsol/fcmix/fkinbbd.c                         |    11 +-
 src/kinsol/fcmix/fkinbbd.h                         |    27 +-
 src/kinsol/fcmix/fkindense.c                       |    11 +-
 src/kinsol/fcmix/fkinjtimes.c                      |    11 +-
 src/kinsol/fcmix/fkinklu.c                         |    52 +
 src/kinsol/fcmix/fkinlapack.c                      |    11 +-
 src/kinsol/fcmix/fkinlapband.c                     |    11 +-
 src/kinsol/fcmix/fkinlapdense.c                    |    11 +-
 src/kinsol/fcmix/fkinpreco.c                       |    11 +-
 src/kinsol/fcmix/fkinsol.c                         |   134 +-
 src/kinsol/fcmix/fkinsol.h                         |   289 +-
 src/kinsol/fcmix/fkinsparse.c                      |    71 +
 src/kinsol/fcmix/fkinsuperlumt.c                   |    42 +
 src/kinsol/kinsol.c                                |   822 +-
 src/kinsol/kinsol_band.c                           |    63 +-
 src/kinsol/kinsol_bbdpre.c                         |    45 +-
 src/kinsol/kinsol_bbdpre_impl.h                    |    19 +-
 src/kinsol/kinsol_dense.c                          |    54 +-
 src/kinsol/kinsol_direct.c                         |    32 +-
 src/kinsol/kinsol_direct_impl.h                    |    30 +-
 src/kinsol/kinsol_impl.h                           |    73 +-
 src/kinsol/kinsol_io.c                             |    80 +-
 src/kinsol/kinsol_klu.c                            |   575 +
 src/kinsol/kinsol_lapack.c                         |    93 +-
 src/kinsol/kinsol_sparse.c                         |   178 +
 src/kinsol/kinsol_sparse_impl.h                    |    92 +
 src/kinsol/kinsol_spbcgs.c                         |   118 +-
 src/kinsol/kinsol_spfgmr.c                         |   451 +
 src/kinsol/kinsol_spgmr.c                          |   122 +-
 src/kinsol/kinsol_spils.c                          |    24 +-
 src/kinsol/kinsol_spils_impl.h                     |    49 +-
 src/kinsol/kinsol_sptfqmr.c                        |   122 +-
 src/kinsol/kinsol_superlumt.c                      |   506 +
 src/nvec_openmp/CMakeLists.txt                     |    94 +
 src/nvec_openmp/README                             |    46 +
 src/nvec_openmp/fnvector_openmp.c                  |   159 +
 src/nvec_openmp/fnvector_openmp.h                  |    95 +
 src/nvec_openmp/nvector_openmp.c                   |  1332 +
 src/nvec_par/CMakeLists.txt                        |    15 +-
 src/nvec_par/Makefile.in                           |   128 -
 src/nvec_par/README                                |   106 +-
 src/nvec_par/fnvector_parallel.c                   |    18 +-
 src/nvec_par/fnvector_parallel.h                   |    19 +-
 src/nvec_par/nvector_parallel.c                    |    65 +-
 src/nvec_parhyp/CMakeLists.txt                     |    77 +
 src/nvec_parhyp/README                             |    46 +
 src/nvec_parhyp/nvector_parhyp.c                   |  1160 +
 src/nvec_petsc/CMakeLists.txt                      |    77 +
 src/nvec_petsc/README                              |    45 +
 src/nvec_petsc/nvector_petsc.c                     |   900 +
 src/nvec_pthreads/CMakeLists.txt                   |    87 +
 src/nvec_pthreads/README                           |    47 +
 src/nvec_pthreads/fnvector_pthreads.c              |   159 +
 src/nvec_pthreads/fnvector_pthreads.h              |    95 +
 src/nvec_pthreads/nvector_pthreads.c               |  3204 +++
 src/nvec_ser/CMakeLists.txt                        |    11 +-
 src/nvec_ser/Makefile.in                           |   125 -
 src/nvec_ser/README                                |   100 +-
 src/nvec_ser/fnvector_serial.c                     |    18 +-
 src/nvec_ser/fnvector_serial.h                     |    19 +-
 src/nvec_ser/nvector_serial.c                      |    67 +-
 src/sundials/CMakeLists.txt                        |    14 +-
 src/sundials/LICENSE                               |    67 +
 src/sundials/Makefile.in                           |   137 -
 src/sundials/README                                |   188 +-
 src/sundials/sundials_band.c                       |    55 +-
 src/sundials/sundials_dense.c                      |    39 +-
 src/sundials/sundials_direct.c                     |    19 +-
 src/sundials/sundials_iterative.c                  |    43 +-
 src/sundials/sundials_math.c                       |    21 +-
 src/sundials/sundials_nvector.c                    |    18 +-
 src/sundials/sundials_pcg.c                        |   213 +
 src/sundials/sundials_sparse.c                     |   870 +
 src/sundials/sundials_spbcgs.c                     |    17 +-
 src/sundials/sundials_spfgmr.c                     |   364 +
 src/sundials/sundials_spgmr.c                      |    29 +-
 src/sundials/sundials_sptfqmr.c                    |    31 +-
 sundialsTB/Contents.m                              |     6 -
 sundialsTB/LICENSE                                 |    60 -
 sundialsTB/README                                  |   219 -
 sundialsTB/cvodes/CVode.m                          |    55 -
 sundialsTB/cvodes/CVodeAdjInit.m                   |    23 -
 sundialsTB/cvodes/CVodeAdjReInit.m                 |    13 -
 sundialsTB/cvodes/CVodeB.m                         |    49 -
 sundialsTB/cvodes/CVodeFree.m                      |    11 -
 sundialsTB/cvodes/CVodeGet.m                       |    36 -
 sundialsTB/cvodes/CVodeGetStats.m                  |    86 -
 sundialsTB/cvodes/CVodeGetStatsB.m                 |    76 -
 sundialsTB/cvodes/CVodeInit.m                      |    42 -
 sundialsTB/cvodes/CVodeInitB.m                     |    37 -
 sundialsTB/cvodes/CVodeMonitor.m                   |   796 -
 sundialsTB/cvodes/CVodeMonitorB.m                  |   697 -
 sundialsTB/cvodes/CVodeMonitorB_octave.m           |   545 -
 sundialsTB/cvodes/CVodeMonitor_octave.m            |   637 -
 sundialsTB/cvodes/CVodeQuadInit.m                  |    28 -
 sundialsTB/cvodes/CVodeQuadInitB.m                 |    32 -
 sundialsTB/cvodes/CVodeQuadReInit.m                |    28 -
 sundialsTB/cvodes/CVodeQuadReInitB.m               |    30 -
 sundialsTB/cvodes/CVodeQuadSetOptions.m            |    64 -
 sundialsTB/cvodes/CVodeReInit.m                    |    32 -
 sundialsTB/cvodes/CVodeReInitB.m                   |    36 -
 sundialsTB/cvodes/CVodeSensInit.m                  |    33 -
 sundialsTB/cvodes/CVodeSensReInit.m                |    32 -
 sundialsTB/cvodes/CVodeSensSetOptions.m            |   112 -
 sundialsTB/cvodes/CVodeSensToggleOff.m             |    16 -
 sundialsTB/cvodes/CVodeSet.m                       |    52 -
 sundialsTB/cvodes/CVodeSetB.m                      |    48 -
 sundialsTB/cvodes/CVodeSetOptions.m                |   300 -
 sundialsTB/cvodes/Contents.m                       |   115 -
 sundialsTB/cvodes/cvm/Contents.m                   |     3 -
 sundialsTB/cvodes/cvm/cvm_bjac.m                   |    12 -
 sundialsTB/cvodes/cvm/cvm_bjacB.m                  |    12 -
 sundialsTB/cvodes/cvm/cvm_djac.m                   |    13 -
 sundialsTB/cvodes/cvm/cvm_djacB.m                  |    12 -
 sundialsTB/cvodes/cvm/cvm_gcom.m                   |    12 -
 sundialsTB/cvodes/cvm/cvm_gcomB.m                  |    12 -
 sundialsTB/cvodes/cvm/cvm_gloc.m                   |    12 -
 sundialsTB/cvodes/cvm/cvm_glocB.m                  |    12 -
 sundialsTB/cvodes/cvm/cvm_jtv.m                    |    12 -
 sundialsTB/cvodes/cvm/cvm_jtvB.m                   |    12 -
 sundialsTB/cvodes/cvm/cvm_monitor.m                |    17 -
 sundialsTB/cvodes/cvm/cvm_monitorB.m               |    15 -
 sundialsTB/cvodes/cvm/cvm_options.m                |    66 -
 sundialsTB/cvodes/cvm/cvm_pset.m                   |    12 -
 sundialsTB/cvodes/cvm/cvm_psetB.m                  |    12 -
 sundialsTB/cvodes/cvm/cvm_psol.m                   |    12 -
 sundialsTB/cvodes/cvm/cvm_psolB.m                  |    12 -
 sundialsTB/cvodes/cvm/cvm_rhs.m                    |    13 -
 sundialsTB/cvodes/cvm/cvm_rhsB.m                   |    48 -
 sundialsTB/cvodes/cvm/cvm_rhsQ.m                   |    13 -
 sundialsTB/cvodes/cvm/cvm_rhsQB.m                  |    49 -
 sundialsTB/cvodes/cvm/cvm_rhsS.m                   |    17 -
 sundialsTB/cvodes/cvm/cvm_root.m                   |    13 -
 sundialsTB/cvodes/cvm/src/cvm.c                    |  3662 ---
 sundialsTB/cvodes/cvm/src/cvm.h                    |   281 -
 sundialsTB/cvodes/cvm/src/cvmOpts.c                |   850 -
 sundialsTB/cvodes/cvm/src/cvmWrap.c                |  1225 -
 .../cvodes/examples_par/mcvsAdvDiff_FSA_non_p.m    |   206 -
 .../cvodes/examples_par/mcvsAtmDisp_kry_bbd_p.m    |   521 -
 sundialsTB/cvodes/examples_par/mcvsDecoupl_non_p.m |    91 -
 sundialsTB/cvodes/examples_ser/mcvsAdvDiff_bnd.m   |   243 -
 sundialsTB/cvodes/examples_ser/mcvsDiscRHS_dns.m   |   150 -
 sundialsTB/cvodes/examples_ser/mcvsDiscSOL_dns.m   |    77 -
 sundialsTB/cvodes/examples_ser/mcvsDiurnal_kry.m   |   388 -
 .../cvodes/examples_ser/mcvsHessian_FSA_ASA.m      |   349 -
 sundialsTB/cvodes/examples_ser/mcvsOzone_FSA_dns.m |   143 -
 sundialsTB/cvodes/examples_ser/mcvsPleiades_non.m  |   149 -
 .../cvodes/examples_ser/mcvsPollut_FSA_dns.m       |   417 -
 .../cvodes/examples_ser/mcvsRoberts_ASAi_dns.m     |   286 -
 .../cvodes/examples_ser/mcvsRoberts_FSA_dns.m      |   197 -
 sundialsTB/cvodes/examples_ser/mcvsRoberts_dns.m   |   132 -
 sundialsTB/cvodes/examples_ser/mcvsVanDPol_dns.m   |    64 -
 sundialsTB/cvodes/function_types/CVBandJacFn.m     |    31 -
 sundialsTB/cvodes/function_types/CVBandJacFnB.m    |    27 -
 sundialsTB/cvodes/function_types/CVDenseJacFn.m    |    27 -
 sundialsTB/cvodes/function_types/CVDenseJacFnB.m   |    24 -
 sundialsTB/cvodes/function_types/CVGcommFn.m       |    34 -
 sundialsTB/cvodes/function_types/CVGcommFnB.m      |    28 -
 sundialsTB/cvodes/function_types/CVGlocalFn.m      |    28 -
 sundialsTB/cvodes/function_types/CVGlocalFnB.m     |    22 -
 sundialsTB/cvodes/function_types/CVJacTimesVecFn.m |    28 -
 .../cvodes/function_types/CVJacTimesVecFnB.m       |    23 -
 sundialsTB/cvodes/function_types/CVMonitorFn.m     |    37 -
 sundialsTB/cvodes/function_types/CVMonitorFnB.m    |    37 -
 sundialsTB/cvodes/function_types/CVPrecSetupFn.m   |    68 -
 sundialsTB/cvodes/function_types/CVPrecSetupFnB.m  |    53 -
 sundialsTB/cvodes/function_types/CVPrecSolveFn.m   |    35 -
 sundialsTB/cvodes/function_types/CVPrecSolveFnB.m  |    25 -
 sundialsTB/cvodes/function_types/CVQuadRhsFn.m     |    24 -
 sundialsTB/cvodes/function_types/CVQuadRhsFnB.m    |    20 -
 sundialsTB/cvodes/function_types/CVRhsFn.m         |    24 -
 sundialsTB/cvodes/function_types/CVRhsFnB.m        |    20 -
 sundialsTB/cvodes/function_types/CVRootFn.m        |    26 -
 sundialsTB/cvodes/function_types/CVSensRhsFn.m     |    26 -
 sundialsTB/idas/Contents.m                         |   113 -
 sundialsTB/idas/IDAAdjInit.m                       |    23 -
 sundialsTB/idas/IDAAdjReInit.m                     |    13 -
 sundialsTB/idas/IDACalcIC.m                        |    73 -
 sundialsTB/idas/IDACalcICB.m                       |    23 -
 sundialsTB/idas/IDAFree.m                          |    11 -
 sundialsTB/idas/IDAGet.m                           |    36 -
 sundialsTB/idas/IDAGetStats.m                      |    80 -
 sundialsTB/idas/IDAGetStatsB.m                     |    66 -
 sundialsTB/idas/IDAInit.m                          |    31 -
 sundialsTB/idas/IDAInitB.m                         |    37 -
 sundialsTB/idas/IDAMonitor.m                       |   796 -
 sundialsTB/idas/IDAMonitorB.m                      |   697 -
 sundialsTB/idas/IDAMonitorB_octave.m               |   545 -
 sundialsTB/idas/IDAMonitor_octave.m                |   637 -
 sundialsTB/idas/IDAQuadInit.m                      |    28 -
 sundialsTB/idas/IDAQuadInitB.m                     |    32 -
 sundialsTB/idas/IDAQuadReInit.m                    |    28 -
 sundialsTB/idas/IDAQuadReInitB.m                   |    30 -
 sundialsTB/idas/IDAQuadSetOptions.m                |    63 -
 sundialsTB/idas/IDAReInit.m                        |    33 -
 sundialsTB/idas/IDAReInitB.m                       |    37 -
 sundialsTB/idas/IDASensInit.m                      |    32 -
 sundialsTB/idas/IDASensReInit.m                    |    32 -
 sundialsTB/idas/IDASensSetOptions.m                |   112 -
 sundialsTB/idas/IDASensToggleOff.m                 |    16 -
 sundialsTB/idas/IDASet.m                           |    52 -
 sundialsTB/idas/IDASetB.m                          |    48 -
 sundialsTB/idas/IDASetOptions.m                    |   263 -
 sundialsTB/idas/IDASolve.m                         |    56 -
 sundialsTB/idas/IDASolveB.m                        |    50 -
 sundialsTB/idas/examples_ser/midasBruss_ASA_dns.m  |   446 -
 sundialsTB/idas/examples_ser/midasBruss_dns.m      |   301 -
 sundialsTB/idas/examples_ser/midasHeat2D_bnd.m     |   175 -
 sundialsTB/idas/examples_ser/midasPendI1_dns.m     |   183 -
 sundialsTB/idas/examples_ser/midasPendI2_dns.m     |   158 -
 sundialsTB/idas/examples_ser/midasReInit_dns.m     |   108 -
 .../idas/examples_ser/midasRoberts_ASAi_dns.m      |   209 -
 sundialsTB/idas/examples_ser/midasRoberts_dns.m    |   120 -
 .../idas/examples_ser/midasSlCrank_FSA_dns.m       |   238 -
 sundialsTB/idas/examples_ser/midasSlCrank_dns.m    |   481 -
 sundialsTB/idas/function_types/IDABandJacFn.m      |    32 -
 sundialsTB/idas/function_types/IDABandJacFnB.m     |    27 -
 sundialsTB/idas/function_types/IDADenseJacFn.m     |    29 -
 sundialsTB/idas/function_types/IDADenseJacFnB.m    |    24 -
 sundialsTB/idas/function_types/IDAGcommFn.m        |    34 -
 sundialsTB/idas/function_types/IDAGcommFnB.m       |    28 -
 sundialsTB/idas/function_types/IDAGlocalFn.m       |    29 -
 sundialsTB/idas/function_types/IDAGlocalFnB.m      |    23 -
 sundialsTB/idas/function_types/IDAJacTimesVecFn.m  |    28 -
 sundialsTB/idas/function_types/IDAJacTimesVecFnB.m |    23 -
 sundialsTB/idas/function_types/IDAMonitorFn.m      |    67 -
 sundialsTB/idas/function_types/IDAMonitorFnB.m     |    37 -
 sundialsTB/idas/function_types/IDAPrecSetupFn.m    |    53 -
 sundialsTB/idas/function_types/IDAPrecSetupFnB.m   |    18 -
 sundialsTB/idas/function_types/IDAPrecSolveFn.m    |    33 -
 sundialsTB/idas/function_types/IDAPrecSolveFnB.m   |    23 -
 sundialsTB/idas/function_types/IDAQuadRhsFn.m      |    24 -
 sundialsTB/idas/function_types/IDAQuadRhsFnB.m     |    20 -
 sundialsTB/idas/function_types/IDAResFn.m          |    23 -
 sundialsTB/idas/function_types/IDAResFnB.m         |    19 -
 sundialsTB/idas/function_types/IDARootFn.m         |    26 -
 sundialsTB/idas/function_types/IDASensResFn.m      |    26 -
 sundialsTB/idas/idm/Contents.m                     |     3 -
 sundialsTB/idas/idm/idm_bjac.m                     |    13 -
 sundialsTB/idas/idm/idm_bjacB.m                    |    13 -
 sundialsTB/idas/idm/idm_djac.m                     |    13 -
 sundialsTB/idas/idm/idm_djacB.m                    |    12 -
 sundialsTB/idas/idm/idm_gcom.m                     |    12 -
 sundialsTB/idas/idm/idm_gcomB.m                    |    12 -
 sundialsTB/idas/idm/idm_gloc.m                     |    13 -
 sundialsTB/idas/idm/idm_glocB.m                    |    13 -
 sundialsTB/idas/idm/idm_jtv.m                      |    12 -
 sundialsTB/idas/idm/idm_jtvB.m                     |    12 -
 sundialsTB/idas/idm/idm_monitor.m                  |    16 -
 sundialsTB/idas/idm/idm_monitorB.m                 |    15 -
 sundialsTB/idas/idm/idm_options.m                  |    66 -
 sundialsTB/idas/idm/idm_pset.m                     |    12 -
 sundialsTB/idas/idm/idm_psetB.m                    |    13 -
 sundialsTB/idas/idm/idm_psol.m                     |    13 -
 sundialsTB/idas/idm/idm_psolB.m                    |    13 -
 sundialsTB/idas/idm/idm_res.m                      |    12 -
 sundialsTB/idas/idm/idm_resB.m                     |    54 -
 sundialsTB/idas/idm/idm_resS.m                     |    18 -
 sundialsTB/idas/idm/idm_rhsQ.m                     |    12 -
 sundialsTB/idas/idm/idm_rhsQB.m                    |    55 -
 sundialsTB/idas/idm/idm_root.m                     |    13 -
 sundialsTB/idas/idm/src/idm.c                      |  3513 ---
 sundialsTB/idas/idm/src/idm.h                      |   319 -
 sundialsTB/idas/idm/src/idmOpts.c                  |   875 -
 sundialsTB/idas/idm/src/idmWrap.c                  |  1378 -
 sundialsTB/install_STB.m                           |  1025 -
 sundialsTB/kinsol/Contents.m                       |    28 -
 sundialsTB/kinsol/KINFree.m                        |    11 -
 sundialsTB/kinsol/KINGetStats.m                    |    44 -
 sundialsTB/kinsol/KINInit.m                        |    29 -
 sundialsTB/kinsol/KINSetOptions.m                  |   336 -
 sundialsTB/kinsol/KINSol.m                         |    47 -
 sundialsTB/kinsol/examples_par/mkinDiagon_kry_p.m  |   128 -
 sundialsTB/kinsol/examples_ser/mkinDiagon_kry.m    |   104 -
 sundialsTB/kinsol/examples_ser/mkinFerTron_dns.m   |   182 -
 sundialsTB/kinsol/examples_ser/mkinRoboKin_dns.m   |   248 -
 sundialsTB/kinsol/examples_ser/mkinTest_dns.m      |    59 -
 sundialsTB/kinsol/function_types/KINBandJacFn.m    |    27 -
 sundialsTB/kinsol/function_types/KINDenseJacFn.m   |    27 -
 sundialsTB/kinsol/function_types/KINGcommFn.m      |    33 -
 sundialsTB/kinsol/function_types/KINGlocalFn.m     |    28 -
 .../kinsol/function_types/KINJacTimesVecFn.m       |    29 -
 sundialsTB/kinsol/function_types/KINPrecSetupFn.m  |    48 -
 sundialsTB/kinsol/function_types/KINPrecSolveFn.m  |    35 -
 sundialsTB/kinsol/function_types/KINSysFn.m        |    25 -
 sundialsTB/kinsol/kim/Contents.m                   |     3 -
 sundialsTB/kinsol/kim/kim_bjac.m                   |    12 -
 sundialsTB/kinsol/kim/kim_djac.m                   |    12 -
 sundialsTB/kinsol/kim/kim_gcom.m                   |    13 -
 sundialsTB/kinsol/kim/kim_gloc.m                   |    12 -
 sundialsTB/kinsol/kim/kim_info.m                   |    81 -
 sundialsTB/kinsol/kim/kim_jtv.m                    |    12 -
 sundialsTB/kinsol/kim/kim_pset.m                   |    12 -
 sundialsTB/kinsol/kim/kim_psol.m                   |    11 -
 sundialsTB/kinsol/kim/kim_sys.m                    |    13 -
 sundialsTB/kinsol/kim/src/kim.c                    |   811 -
 sundialsTB/kinsol/kim/src/kim.h                    |   166 -
 sundialsTB/kinsol/kim/src/kimOpts.c                |   431 -
 sundialsTB/kinsol/kim/src/kimWrap.c                |   388 -
 sundialsTB/nvector/Contents.m                      |    17 -
 sundialsTB/nvector/N_VDotProd.m                    |    26 -
 sundialsTB/nvector/N_VL1Norm.m                     |    25 -
 sundialsTB/nvector/N_VMax.m                        |    25 -
 sundialsTB/nvector/N_VMaxNorm.m                    |    25 -
 sundialsTB/nvector/N_VMin.m                        |    24 -
 sundialsTB/nvector/N_VWL2Norm.m                    |    29 -
 sundialsTB/nvector/N_VWrmsNorm.m                   |    34 -
 sundialsTB/nvector/src/nvm.h                       |    43 -
 sundialsTB/nvector/src/nvm_ops.c                   |    43 -
 sundialsTB/nvector/src/nvm_parallel.c              |    79 -
 sundialsTB/nvector/src/nvm_serial.c                |    29 -
 sundialsTB/putils/Contents.m                       |     9 -
 sundialsTB/putils/mpirun.m                         |    67 -
 sundialsTB/putils/mpiruns.m                        |    50 -
 sundialsTB/putils/mpistart.m                       |   324 -
 sundialsTB/startup_STB.in                          |    65 -
 1036 files changed, 120569 insertions(+), 89591 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a0491b5..08b6203 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.10 $
-# $Date: 2010/12/15 22:28:16 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # Top level CMakeLists.txt for SUNDIALS (for cmake build system)
 
@@ -18,7 +23,12 @@
 
 # Require a fairly recent cmake version
 
-CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
+
+# Set CMake policy to allow examples to build
+if(COMMAND cmake_policy)
+  cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
 
 # Project SUNDIALS (initially only C supported)
 
@@ -26,11 +36,14 @@ PROJECT(sundials C)
 
 # Set some variables with info on the SUNDIALS project
 
-SET(PACKAGE_BUGREPORT "radu at llnl.gov")
+SET(PACKAGE_BUGREPORT "woodward6 at llnl.gov")
 SET(PACKAGE_NAME "SUNDIALS")
-SET(PACKAGE_STRING "SUNDIALS 2.4.0")
+SET(PACKAGE_STRING "SUNDIALS 2.7.0")
 SET(PACKAGE_TARNAME "sundials")
-SET(PACKAGE_VERSION "2.4.0")
+SET(PACKAGE_VERSION "2.7.0")
+
+# 
+SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
 
 # Prohibit in-source build
 
@@ -51,26 +64,29 @@ MARK_AS_ADVANCED(CLEAR
 
 # Specify the VERSION and SOVERSION for shared libraries
 
-SET(cvodelib_VERSION "1.0.0")
-SET(cvodelib_SOVERSION "1")
+SET(arkodelib_VERSION "1.1.0")
+SET(arkodelib_SOVERSION "1")
 
-SET(cvodeslib_VERSION "2.0.0")
+SET(cvodelib_VERSION "2.9.0")
+SET(cvodelib_SOVERSION "2")
+
+SET(cvodeslib_VERSION "2.9.0")
 SET(cvodeslib_SOVERSION "2")
 
-SET(idalib_VERSION "2.0.0")
+SET(idalib_VERSION "2.9.0")
 SET(idalib_SOVERSION "2")
 
-SET(idaslib_VERSION "0.0.0")
-SET(idaslib_SOVERSION "0")
+SET(idaslib_VERSION "1.3.0")
+SET(idaslib_SOVERSION "1")
 
-SET(kinsollib_VERSION "1.0.0")
-SET(kinsollib_SOVERSION "1")
+SET(kinsollib_VERSION "2.9.0")
+SET(kinsollib_SOVERSION "2")
 
 SET(cpodeslib_VERSION "0.0.0")
 SET(cpodeslib_SOVERSION "0")
 
-SET(nveclib_VERSION "0.0.2")
-SET(nveclib_SOVERSION "0")
+SET(nveclib_VERSION "2.7.0")
+SET(nveclib_SOVERSION "2")
 
 # Specify the location of additional CMAKE modules
 
@@ -143,6 +159,12 @@ ENDMACRO(LIST2STRING)
 # For each SUNDIALS solver available (i.e. for which we have the
 # sources), give the user the option of enabling/disabling it.
 
+IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/arkode")
+  OPTION(BUILD_ARKODE  "Build the ARKODE library"  ON)
+ELSE(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/arkode")
+  SET(BUILD_ARKODE OFF)
+ENDIF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/arkode")
+
 IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvode")
   OPTION(BUILD_CVODE  "Build the CVODE library"  ON)
 ELSE(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cvode")
@@ -173,11 +195,12 @@ ELSE(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/kinsol")
   SET(BUILD_KINSOL OFF)
 ENDIF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/kinsol")
 
-IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes")
-  OPTION(BUILD_CPODES  "Build the CPODES library"  ON)
-ELSE(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes")
-  SET(BUILD_CPODES OFF)
-ENDIF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes")
+# CPODES is always OFF for now.  (commented out for Release); ToDo: better way to do this?
+#IF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes")
+#  OPTION(BUILD_CPODES  "Build the CPODES library"  OFF)
+#ELSE(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes")
+#  SET(BUILD_CPODES OFF)
+#ENDIF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes")
 
 # -------------------------------------------------------------
 # Other configuration options
@@ -187,7 +210,7 @@ ENDIF(IS_DIRECTORY "${sundials_SOURCE_DIR}/src/cpodes")
 # ----------------------------------------------------------------
 
 OPTION(BUILD_STATIC_LIBS "Build static libraries" ON)
-OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF)
+OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON)
 
 # Prepare substitution variable SUNDIALS_EXPORT for sundials_config.h
 # When building shared SUNDIALS libraries under Windows, use
@@ -232,11 +255,27 @@ IF(UNIX)
   IF(USE_GENERIC_MATH)
     # executables will be linked against -lm 
     SET(EXTRA_LINK_LIBS -lm)
-    # prepare substitution variable GENERIC_MATH_LIB for sundials_config.h
-    SET(GENERIC_MATH_LIB "#define SUNDIALS_USE_GENERIC_MATH")
+    # prepare substitution variable for sundials_config.h
+    SET(SUNDIALS_USE_GENERIC_MATH TRUE)
   ENDIF(USE_GENERIC_MATH)
 ENDIF(UNIX)
 
+## clock-monotonic, see if we need to link with rt
+include(CheckSymbolExists)
+set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
+set(CMAKE_REQUIRED_LIBRARIES rt)
+CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" SUNDIALS_POSIX_TIMERS)
+set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
+if(SUNDIALS_POSIX_TIMERS)
+  find_library(SUNDIALS_RT_LIBRARY NAMES rt)
+  mark_as_advanced(SUNDIALS_RT_LIBRARY)
+  if(SUNDIALS_RT_LIBRARY)
+    # sundials_config.h symbol
+    SET(SUNDIALS_HAVE_POSIX_TIMERS TRUE)
+    set(EXTRA_LINK_LIBS ${EXTRA_LINK_LIBS} ${SUNDIALS_RT_LIBRARY})
+  endif()
+endif()
+
 # -------------------------------------------------------------
 # Enable Fortran support?
 # -------------------------------------------------------------
@@ -244,11 +283,40 @@ ENDIF(UNIX)
 # FCMIX support is an option only if at least one solver that 
 # provides such an interface is built.
 
-IF(BUILD_CVODE OR BUILD_IDA OR BUILD_KINSOL)
+IF(BUILD_ARKODE OR BUILD_CVODE OR BUILD_IDA OR BUILD_KINSOL)
   SHOW_VARIABLE(FCMIX_ENABLE BOOL "Enable Fortran-C support" OFF)
-ELSE(BUILD_CVODE OR BUILD_IDA OR BUILD_KINSOL)
+ELSE(BUILD_ARKODE OR BUILD_CVODE OR BUILD_IDA OR BUILD_KINSOL)
   HIDE_VARIABLE(FCMIX_ENABLE)
-ENDIF(BUILD_CVODE OR BUILD_IDA OR BUILD_KINSOL)
+ENDIF(BUILD_ARKODE OR BUILD_CVODE OR BUILD_IDA OR BUILD_KINSOL)
+
+# -------------------------------------------------------------
+# Enable Fortran90 support?
+# -------------------------------------------------------------
+
+# F90 support is an option only if ARKode is built and 
+# examples are enabled
+
+IF(BUILD_ARKODE AND EXAMPLES_ENABLE AND FCMIX_ENABLE)
+  SHOW_VARIABLE(F90_ENABLE BOOL "Enable Fortran90 ARKode examples" OFF)
+ELSE(BUILD_ARKODE AND EXAMPLES_ENABLE AND FCMIX_ENABLE)
+  # # set back to OFF (in case was ON)
+  # SET(F90_ENABLE OFF)
+  # HIDE_VARIABLE(F90_ENABLE AND FCMIX_ENABLE)
+  HIDE_VARIABLE(F90_ENABLE)
+ENDIF(BUILD_ARKODE AND EXAMPLES_ENABLE AND FCMIX_ENABLE)
+
+# -------------------------------------------------------------
+# Enable C++ support?
+# -------------------------------------------------------------
+
+# C++ support is an option only if ARKode is built and 
+# examples are enabled
+
+IF(BUILD_ARKODE AND EXAMPLES_ENABLE)
+  SHOW_VARIABLE(CXX_ENABLE BOOL "Enable C++ ARKode examples" OFF)
+ELSE(BUILD_ARKODE AND EXAMPLES_ENABLE)
+  HIDE_VARIABLE(CXX_ENABLE)
+ENDIF(BUILD_ARKODE AND EXAMPLES_ENABLE)
 
 # -------------------------------------------------------------
 # Enable BLAS/LAPACK support?
@@ -263,6 +331,31 @@ IF(NOT LAPACK_ENABLE)
 ENDIF(NOT LAPACK_ENABLE)
 
 # -------------------------------------------------------------
+# Enable SUPERLUMT support?
+# -------------------------------------------------------------
+
+OPTION(SUPERLUMT_ENABLE "Enable SUPERLUMT support" OFF)
+
+IF(NOT SUPERLUMT_ENABLE)
+  HIDE_VARIABLE(SUPERLUMT_THREAD_TYPE)
+  HIDE_VARIABLE(SUPERLUMT_LIBRARY_DIR)
+  HIDE_VARIABLE(SUPERLUMT_INCLUDE_DIR)
+  SET (SUPERLUMT_DISABLED TRUE CACHE INTERNAL "GUI - return when first set")
+ENDIF(NOT SUPERLUMT_ENABLE)
+
+# -------------------------------------------------------------
+# Enable KLU support?
+# -------------------------------------------------------------
+
+OPTION(KLU_ENABLE "Enable KLU support" OFF)
+
+IF(NOT KLU_ENABLE)
+  HIDE_VARIABLE(KLU_LIBRARY_DIR)
+  HIDE_VARIABLE(KLU_INCLUDE_DIR)
+  SET (KLU_DISABLED TRUE CACHE INTERNAL "GUI - return when first set")
+ENDIF(NOT KLU_ENABLE)
+
+# -------------------------------------------------------------
 # Enable MPI support?
 # -------------------------------------------------------------
 
@@ -273,14 +366,69 @@ IF(NOT MPI_ENABLE)
   HIDE_VARIABLE(MPI_LIBRARIES)
   HIDE_VARIABLE(MPI_EXTRA_LIBRARIES)
   HIDE_VARIABLE(MPI_MPICC)
+  HIDE_VARIABLE(MPI_MPICXX)
   HIDE_VARIABLE(MPI_MPIF77)
+  HIDE_VARIABLE(MPI_MPIF90)
+ENDIF(NOT MPI_ENABLE)
+
+# -------------------------------------------------------------
+# Enable HYPRE Vector support?
+# -------------------------------------------------------------
+
+OPTION(HYPRE_ENABLE "Enable Hypre support" OFF)
+IF(NOT MPI_ENABLE)
+  HIDE_VARIABLE(HYPRE_INCLUDE_DIR)
+  HIDE_VARIABLE(HYPRE_LIBRARY_DIR)
+  SET (HYPRE_DISABLED TRUE CACHE INTERNAL "GUI - return when first set")
 ENDIF(NOT MPI_ENABLE)
 
 # -------------------------------------------------------------
+# Enable OpenMP support?
+# -------------------------------------------------------------
+
+OPTION(OPENMP_ENABLE "Enable OpenMP support" OFF)
+
+IF(OPENMP_ENABLE)
+  FIND_PACKAGE(OpenMP)
+  IF(NOT OPENMP_FOUND)
+    message(STATUS "Disabling OpenMP support, could not determine compiler flags")
+  ENDIF(NOT OPENMP_FOUND)
+ENDIF(OPENMP_ENABLE)
+
+# -------------------------------------------------------------
+# Enable Pthread support?
+# -------------------------------------------------------------
+
+OPTION(PTHREAD_ENABLE "Enable Pthreads support" OFF)
+
+IF(PTHREAD_ENABLE)
+  FIND_PACKAGE(Threads)
+  IF(CMAKE_USE_PTHREADS_INIT)
+    message(STATUS "Using Pthreads")
+    SET(PTHREADS_FOUND TRUE)
+    # SGS    
+  ELSE()
+    message(STATUS "Disabling Pthreads support, could not determine compiler flags")
+  endif()
+ENDIF(PTHREAD_ENABLE)
+
+# -------------------------------------------------------------
+# Enable PETSc support?
+# -------------------------------------------------------------
+
+OPTION(PETSC_ENABLE "Enable PETSC support" OFF)
+
+IF(NOT PETSC_ENABLE)
+  HIDE_VARIABLE(PETSC_LIBRARY_DIR)
+  HIDE_VARIABLE(PETSC_INCLUDE_DIR)
+  SET (PETSC_DISABLED TRUE CACHE INTERNAL "GUI - return when first set")
+ENDIF(NOT PETSC_ENABLE)
+
+# -------------------------------------------------------------
 # Enable examples?
 # -------------------------------------------------------------
 
-OPTION(EXAMPLES_ENABLE "Build the SUNDIALS examples" OFF)
+OPTION(EXAMPLES_ENABLE "Build the SUNDIALS examples" ON)
 
 IF(EXAMPLES_ENABLE)
 
@@ -300,7 +448,7 @@ IF(EXAMPLES_ENABLE)
   # If examples are to be exported, check where we should install them.
   IF(EXAMPLES_INSTALL)
 
-    SHOW_VARIABLE(EXAMPLES_INSTALL_PATH STRING
+    SHOW_VARIABLE(EXAMPLES_INSTALL_PATH PATH
       "Output directory for installing example files" "${CMAKE_INSTALL_PREFIX}/examples")
     
     IF(NOT EXAMPLES_INSTALL_PATH)
@@ -337,6 +485,10 @@ IF(WIN32)
   ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
 ENDIF(WIN32)
 
+IF(APPLE)
+  SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup")
+ENDIF(APPLE)
+
 # -------------------------------------------------------------
 # A Fortran compiler is needed if:
 # (a) FCMIX is enabled
@@ -352,6 +504,34 @@ IF(FCMIX_ENABLE OR LAPACK_ENABLE)
 ENDIF(FCMIX_ENABLE OR LAPACK_ENABLE)
 
 # -------------------------------------------------------------
+# A Fortran90 compiler is needed if:
+# (a) F90 is enabled, and
+# (b) ARKODE examples are enabled
+# -------------------------------------------------------------
+
+IF(F90_ENABLE AND BUILD_ARKODE)
+  INCLUDE(SundialsFortran90)
+  IF(NOT F90_FOUND AND F90_ENABLE)
+    PRINT_WARNING("Fortran90 compiler not functional"
+      "F90 support will not be provided")
+  ENDIF(NOT F90_FOUND AND F90_ENABLE)
+ENDIF(F90_ENABLE AND BUILD_ARKODE)
+
+# -------------------------------------------------------------
+# A C++ compiler is needed if:
+# (a) C++ is enabled, and
+# (b) ARKODE examples are enabled
+# -------------------------------------------------------------
+
+IF(CXX_ENABLE AND BUILD_ARKODE)
+  INCLUDE(SundialsCXX)
+  IF(NOT CXX_FOUND AND CXX_ENABLE)
+    PRINT_WARNING("C++ compiler not functional"
+      "C++ support will not be provided")
+  ENDIF(NOT CXX_FOUND AND CXX_ENABLE)
+ENDIF(CXX_ENABLE AND BUILD_ARKODE)
+
+# -------------------------------------------------------------
 # Check if we need an alternate way of specifying the Fortran
 # name-mangling scheme if we were unable to infer it using a
 # compiler. 
@@ -459,37 +639,101 @@ ENDIF(F77SCHEME_FOUND)
 # If LAPACK is needed, first try to find the appropriate
 # libraries and linker flags needed to link against them.
 
-# Macro to be inserted in sundials_config.h
-SET(BLAS_LAPACK_MACRO "#define SUNDIALS_BLAS_LAPACK 0")
-
 IF(LAPACK_ENABLE)
 
+  # find BLAS and LAPACK Libraries
   INCLUDE(SundialsLapack)
 
-  IF(LAPACK_FOUND)
-    SET(BLAS_LAPACK_MACRO "#define SUNDIALS_BLAS_LAPACK 1")
-  ELSE(LAPACK_FOUND)
-    SHOW_VARIABLE(LAPACK_LIBRARIES STRING "Lapack libraries" "${LAPACK_LIBRARIES}")
-    SHOW_VARIABLE(LAPACK_LINKER_FLAGS STRING "Lapack required linker flags" "${LAPACK_LINKER_FLAGS}")
-  ENDIF(LAPACK_FOUND)
+  SHOW_VARIABLE(LAPACK_LIBRARIES STRING "Blas and Lapack libraries" "${LAPACK_LIBRARIES}")
 
   IF(LAPACK_LIBRARIES AND NOT LAPACK_FOUND)
     PRINT_WARNING("LAPACK not functional"
       "Blas/Lapack support will not be provided")
+  ELSE(LAPACK_LIBRARIES AND NOT LAPACK_FOUND)
+    #set sundials_config.h symbol via sundials_config.in
+    SET(SUNDIALS_BLAS_LAPACK TRUE)
   ENDIF(LAPACK_LIBRARIES AND NOT LAPACK_FOUND)
+  
 
 ELSE(LAPACK_ENABLE)
 
   HIDE_VARIABLE(LAPACK_LIBRARIES)
-  HIDE_VARIABLE(LAPACK_LINKER_FLAGS)
 
 ENDIF(LAPACK_ENABLE)
 
 # -------------------------------------------------------------
+# Find (and test) the SUPERLUMT libraries
+# -------------------------------------------------------------
+
+# If SUPERLUMT is needed, first try to find the appropriate
+# libraries to link against them.
+
+IF(SUPERLUMT_ENABLE)
+
+  # get thread type for SUPERLUMT (OpenMP or Pthreads(default))
+  SET(SUPERLUMT_THREAD_TYPE "Pthread" CACHE STRING "OpenMP or Pthread")
+  SHOW_VARIABLE(SUPERLUMT_THREAD_TYPE STRING "SUPERLUMT threading type: OpenMP or Pthread" "${SUPERLUMT_THREAD_TYPE}")
+  SHOW_VARIABLE(SUPERLUMT_INCLUDE_DIR PATH "SUPERLUMT include directory" "${SUPERLUMT_INCLUDE_DIR}")
+  SHOW_VARIABLE(SUPERLUMT_LIBRARY_DIR PATH "SUPERLUMT library directory" "${SUPERLUMT_LIBRARY_DIR}")
+
+  INCLUDE(SundialsSuperLUMT)
+
+  IF(SUPERLUMT_FOUND)
+    # sundials_config.h symbols
+    SET(SUNDIALS_SUPERLUMT TRUE)
+    SET(SUNDIALS_SUPERLUMT_THREAD_TYPE ${SUPERLUMT_THREAD_TYPE})
+  ENDIF(SUPERLUMT_FOUND)
+
+  IF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND)
+    PRINT_WARNING("SUPERLUMT not functional - support will not be provided"
+      "Double check spelling specified libraries (search is case sensitive)")
+  ENDIF(SUPERLUMT_LIBRARIES AND NOT SUPERLUMT_FOUND)
+
+ELSE(SUPERLUMT_ENABLE)
+
+  HIDE_VARIABLE(SUPERLUMT_THREAD_TYPE)
+  HIDE_VARIABLE(SUPERLUMT_INCLUDE_DIR)
+  HIDE_VARIABLE(SUPERLUMT_LIBRARY_DIR)
+
+ENDIF(SUPERLUMT_ENABLE)
+
+# -------------------------------------------------------------
+# Find (and test) the KLU libraries
+# -------------------------------------------------------------
+
+# If KLU is requested, first try to find the appropriate libraries to
+# link against them.
+
+IF(KLU_ENABLE)
+
+  SHOW_VARIABLE(KLU_INCLUDE_DIR PATH "KLU include directory"
+    "${KLU_INCLUDE_DIR}") 
+  SHOW_VARIABLE(KLU_LIBRARY_DIR PATH
+    "Klu library directory" "${KLU_LIBRARY_DIR}")
+
+  INCLUDE(SundialsKLU)
+
+  IF(KLU_FOUND) 
+    # sundials_config.h symbol
+    SET(SUNDIALS_KLU TRUE)
+    INCLUDE_DIRECTORIES(${KLU_INCLUDE_DIR})
+  ENDIF(KLU_FOUND)
+
+  IF(KLU_LIBRARIES AND NOT KLU_FOUND) 
+    PRINT_WARNING("KLU not functional - support will not be provided" 
+      "Double check spelling of include path and specified libraries (search is case sensitive)")
+  ENDIF(KLU_LIBRARIES AND NOT KLU_FOUND)
+
+ENDIF(KLU_ENABLE)
+
+# -------------------------------------------------------------
 # Decide how to compile MPI codes.
 # -------------------------------------------------------------
 
 IF(MPI_ENABLE)
+  # get run command for mpi (openmpi or OpenMP or Pthreads(default))
+  SET(MPI_RUN_COMMAND "mpirun" CACHE STRING "mpirun or srun")
+  SHOW_VARIABLE(MPI_RUN_COMMAND STRING "MPI run command: mpirun or srun" "${MPI_RUN_COMMAND}")
   INCLUDE(SundialsMPIC)
   IF(NOT MPIC_FOUND)
     PRINT_WARNING("MPI not functional"
@@ -503,8 +747,81 @@ IF(MPI_ENABLE)
   IF(MPIC_FOUND AND FCMIX_ENABLE)
     INCLUDE(SundialsMPIF)
   ENDIF(MPIC_FOUND AND FCMIX_ENABLE)
+  IF(MPIC_FOUND AND CXX_ENABLE)
+    INCLUDE(SundialsMPICXX)
+  ENDIF(MPIC_FOUND AND CXX_ENABLE)
+  IF(MPIC_FOUND AND F90_ENABLE)
+    INCLUDE(SundialsMPIF90)
+  ENDIF(MPIC_FOUND AND F90_ENABLE)
 ENDIF(MPI_ENABLE)
 
+#-------------------------------------------------------------
+# Find the Hypre libraries
+#-------------------------------------------------------------
+IF(HYPRE_ENABLE AND NOT MPI_ENABLE)
+    PRINT_WARNING("MPI not enabled - HYPRE support will not be provided" 
+      "Set MPI_ENABLE to ON to use parhyp")
+ENDIF(HYPRE_ENABLE AND NOT MPI_ENABLE)
+
+IF(HYPRE_ENABLE AND MPI_ENABLE)
+  SHOW_VARIABLE(HYPRE_INCLUDE_DIR PATH "HYPRE include directory"
+    "${HYPRE_INCLUDE_DIR}") 
+  SHOW_VARIABLE(HYPRE_LIBRARY_DIR PATH
+    "HYPRE library directory" "${HYPRE_LIBRARY_DIR}")
+
+  INCLUDE(SundialsHypre)
+
+  IF(HYPRE_FOUND) 
+    # sundials_config.h symbol
+    SET(SUNDIALS_HYPRE TRUE)
+    INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR})
+  ENDIF(HYPRE_FOUND)
+
+  IF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND) 
+    PRINT_WARNING("HYPRE not functional - support will not be provided" 
+      "Found hypre library, test code does not work")
+  ENDIF(HYPRE_LIBRARIES AND NOT HYPRE_FOUND)
+  
+ENDIF(HYPRE_ENABLE AND MPI_ENABLE)
+
+# -------------------------------------------------------------
+# Find (and test) the PETSc libraries
+# -------------------------------------------------------------
+IF(PETSC_ENABLE AND NOT MPI_ENABLE)
+    PRINT_WARNING("MPI not enabled - PETSc support will not be provided" 
+      "Set MPI_ENABLE to ON to use PETSc.")
+ENDIF(PETSC_ENABLE AND NOT MPI_ENABLE)
+
+IF(PETSC_ENABLE AND MPI_ENABLE)
+  SHOW_VARIABLE(PETSC_INCLUDE_DIR PATH "PETSc include directory"
+    "${PETSC_INCLUDE_DIR}") 
+  SHOW_VARIABLE(PETSC_LIBRARY_DIR PATH
+    "PETSc library directory" "${PETSC_LIBRARY_DIR}")
+
+  INCLUDE(SundialsPETSc)
+
+  IF(PETSC_FOUND) 
+    # sundials_config.h symbol
+    SET(SUNDIALS_PETSC TRUE)
+    INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIR})
+  ENDIF(PETSC_FOUND)
+
+  IF(PETSC_LIBRARIES AND NOT PETSC_FOUND) 
+    PRINT_WARNING("PETSC not functional - support will not be provided" 
+      "Double check spelling specified libraries (search is case sensitive)")
+  ENDIF(PETSC_LIBRARIES AND NOT PETSC_FOUND)
+
+ENDIF(PETSC_ENABLE AND MPI_ENABLE)
+
+
+# -------------------------------------------------------------
+# If using MPI with C++, disable C++ extensions (for known wrappers)
+# -------------------------------------------------------------
+
+# IF(MPICXX_FOUND)
+#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX -DLAM_BUILDING")
+# ENDIF(MPICXX_FOUND)
+
 # -------------------------------------------------------------
 # Configure the header file sundials_config.h
 # -------------------------------------------------------------
@@ -518,7 +835,11 @@ CONFIGURE_FILE(
 
 # Add the include directory in the source tree and the one in
 # the binary tree (for the header file sundials_config.h)
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include)
+IF(SUPERLUMT_FOUND)
+  INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${SUPERLUMT_INCLUDE_DIR})
+ELSE(SUPERLUMT_FOUND)
+  INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include)
+ENDIF(SUPERLUMT_FOUND)
 
 # -------------------------------------------------------------
 # Add selected modules to the build system
@@ -532,6 +853,31 @@ IF(MPIC_FOUND)
   ADD_SUBDIRECTORY(src/nvec_par)
 ENDIF(MPIC_FOUND)
 
+IF(SUNDIALS_HYPRE)
+  ADD_SUBDIRECTORY(src/nvec_parhyp)
+ENDIF(SUNDIALS_HYPRE)
+
+IF(OPENMP_FOUND)
+  ADD_SUBDIRECTORY(src/nvec_openmp)	
+ENDIF(OPENMP_FOUND)
+
+IF(PTHREADS_FOUND)
+  ADD_SUBDIRECTORY(src/nvec_pthreads)   
+ENDIF(PTHREADS_FOUND)
+
+IF(PETSC_FOUND)
+  ADD_SUBDIRECTORY(src/nvec_petsc)   
+ENDIF(PETSC_FOUND)
+
+# ARKODE library
+
+IF(BUILD_ARKODE)	
+  ADD_SUBDIRECTORY(src/arkode)
+  IF(FCMIX_ENABLE AND F77_FOUND)
+    ADD_SUBDIRECTORY(src/arkode/fcmix)
+  ENDIF(FCMIX_ENABLE AND F77_FOUND)
+ENDIF(BUILD_ARKODE)
+
 # CVODE library
 
 IF(BUILD_CVODE)	
@@ -586,7 +932,18 @@ ENDIF(BUILD_CPODES)
 # Also, if we will generate exported example Makefiles, set 
 # variables needed in generating them from templates.
 
+# For now, TestRunner is not being distributed.
+# So:
+#  - Don't show TESTRUNNER variable
+#  - Don't enable testing if TestRunner if not found.
+#  - There will be no 'make test' target
+
+INCLUDE(SundialsAddTest)
+HIDE_VARIABLE(TESTRUNNER)
 IF(EXAMPLES_ENABLE)
+  IF(TESTRUNNER)
+    ENABLE_TESTING()
+  ENDIF(TESTRUNNER)
 
   IF(EXAMPLES_INSTALL)
     SET(SHELL "sh")
@@ -600,6 +957,13 @@ IF(EXAMPLES_ENABLE)
     SET(CFLAGS "${CMAKE_C_FLAGS_RELEASE}")
     SET(LDFLAGS "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
     LIST2STRING(EXTRA_LINK_LIBS LIBS)
+    IF(CXX_FOUND)
+      SET(CXX "${CMAKE_CXX_COMPILER}")
+      SET(CXX_LNKR "${CMAKE_CXX_COMPILER}")
+      SET(CXXFLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
+      SET(CXX_LDFLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
+      LIST2STRING(EXTRA_LINK_LIBS CXX_LIBS)
+    ENDIF(CXX_FOUND)
     IF(F77_FOUND)
       SET(F77 "${CMAKE_Fortran_COMPILER}")
       SET(F77_LNKR "${CMAKE_Fortran_COMPILER}")
@@ -607,9 +971,23 @@ IF(EXAMPLES_ENABLE)
       SET(F77_LDFLAGS "${CMAKE_Fortran_FLAGS_RELEASE}")
       LIST2STRING(EXTRA_LINK_LIBS F77_LIBS)
     ENDIF(F77_FOUND)
+    IF(F90_FOUND)
+      SET(F90 "${CMAKE_Fortran_COMPILER}")
+      SET(F90_LNKR "${CMAKE_Fortran_COMPILER}")
+      SET(F90FLAGS "${CMAKE_Fortran_FLAGS_RELEASE}")
+      SET(F90_LDFLAGS "${CMAKE_Fortran_FLAGS_RELEASE}")
+      LIST2STRING(EXTRA_LINK_LIBS F90_LIBS)
+    ENDIF(F90_FOUND)
+    IF(SUPERLUMT_FOUND)
+      LIST2STRING(SUPERLUMT_LIBRARIES SUPERLUMT_LIBS)
+      SET(SUPERLUMT_LIBS "${SUPERLUMT_LINKER_FLAGS} ${SUPERLUMT_LIBS}")
+    ENDIF(SUPERLUMT_FOUND)
+    IF(KLU_FOUND)
+      LIST2STRING(KLU_LIBRARIES KLU_LIBS)
+      SET(KLU_LIBS "${KLU_LINKER_FLAGS} ${KLU_LIBS}")
+    ENDIF(KLU_FOUND)
     IF(LAPACK_FOUND)
       LIST2STRING(LAPACK_LIBRARIES BLAS_LAPACK_LIBS)
-      SET(BLAS_LAPACK_LIBS "${LAPACK_LINKER_FLAGS} ${BLAS_LAPACK_LIBS}")
     ENDIF(LAPACK_FOUND)
     IF(MPIC_FOUND)
       IF(MPI_MPICC)
@@ -624,7 +1002,18 @@ IF(EXAMPLES_ENABLE)
         SET(MPI_LIB_DIR ".")
         LIST2STRING(MPI_LIBRARIES MPI_LIBS)
       ENDIF(MPI_MPICC)
+      SET(HYPRE_INC_DIR "${HYPRE_INCLUDE_DIR}")
+      SET(HYPRE_LIB_DIR "${HYPRE_LIBRARY_DIR}")
+      SET(HYPRE_LIBS "${HYPRE_LIBRARIES}")
     ENDIF(MPIC_FOUND)
+    IF(MPICXX_FOUND)
+      IF(MPI_MPICXX)
+        SET(MPICXX "${MPI_MPICXX}")
+      ELSE(MPI_MPICXX)
+        SET(MPICXX "${CMAKE_CXX_COMPILER}")
+        LIST2STRING(MPI_LIBRARIES MPI_LIBS)
+      ENDIF(MPI_MPICXX)
+    ENDIF(MPICXX_FOUND)
     IF(MPIF_FOUND)
       IF(MPI_MPIF77)
         SET(MPIF77 "${MPI_MPIF77}")
@@ -637,8 +1026,50 @@ IF(EXAMPLES_ENABLE)
         LIST2STRING(MPI_LIBRARIES MPI_LIBS)
       ENDIF(MPI_MPIF77)
     ENDIF(MPIF_FOUND)
+    IF(MPIF90_FOUND)
+      IF(MPI_MPIF90)
+        SET(MPIF90 "${MPI_MPIF90}")
+        SET(MPIF90_LNKR "${MPI_MPIF90}")
+      ELSE(MPI_MPIF90)
+        SET(MPIF90 "${CMAKE_Fortran_COMPILER}")
+        SET(MPIF90_LNKR "${CMAKE_Fortran_COMPILER}")
+        LIST2STRING(MPI_LIBRARIES MPI_LIBS)
+      ENDIF(MPI_MPIF90)
+    ENDIF(MPIF90_FOUND)
   ENDIF(EXAMPLES_INSTALL)
 
+  IF(BUILD_ARKODE)
+    ADD_SUBDIRECTORY(examples/arkode/C_serial)
+    IF(OPENMP_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/C_openmp)
+    ENDIF(OPENMP_FOUND)
+    IF(CXX_ENABLE AND CXX_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/CXX_serial)
+    ENDIF(CXX_ENABLE AND CXX_FOUND)
+    IF(FCMIX_ENABLE AND F77_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/F77_serial)
+    ENDIF(FCMIX_ENABLE AND F77_FOUND)
+    IF(F90_ENABLE AND F90_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/F90_serial)
+    ENDIF(F90_ENABLE AND F90_FOUND)
+    IF(MPIC_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/C_parallel)
+    ENDIF(MPIC_FOUND)
+    IF(MPICXX_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/CXX_parallel)
+    ENDIF(MPICXX_FOUND)
+    IF(MPIF_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/F77_parallel)
+    ENDIF(MPIF_FOUND)
+    IF(MPIF90_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/F90_parallel)
+    ENDIF(MPIF90_FOUND)
+    IF(HYPRE_ENABLE AND HYPRE_FOUND)
+      ADD_SUBDIRECTORY(examples/arkode/C_parhyp)
+    ENDIF(HYPRE_ENABLE AND HYPRE_FOUND)
+    
+  ENDIF(BUILD_ARKODE)
+  
   IF(BUILD_CVODE)
     ADD_SUBDIRECTORY(examples/cvode/serial)
     IF(FCMIX_ENABLE AND F77_FOUND)
@@ -650,6 +1081,12 @@ IF(EXAMPLES_ENABLE)
     IF(MPIF_FOUND)
       ADD_SUBDIRECTORY(examples/cvode/fcmix_parallel)
     ENDIF(MPIF_FOUND)
+    IF(OPENMP_FOUND)
+      ADD_SUBDIRECTORY(examples/cvode/C_openmp)
+    ENDIF(OPENMP_FOUND)
+    IF(HYPRE_ENABLE AND HYPRE_FOUND)
+      ADD_SUBDIRECTORY(examples/cvode/parhyp)
+    ENDIF(HYPRE_ENABLE AND HYPRE_FOUND)
   ENDIF(BUILD_CVODE)
   
   IF(BUILD_CVODES)	
@@ -657,16 +1094,31 @@ IF(EXAMPLES_ENABLE)
     IF(MPIC_FOUND)
       ADD_SUBDIRECTORY(examples/cvodes/parallel)
     ENDIF(MPIC_FOUND)
+    IF(OPENMP_FOUND)
+      ADD_SUBDIRECTORY(examples/cvodes/C_openmp)
+    ENDIF(OPENMP_FOUND)
   ENDIF(BUILD_CVODES)
   
   IF(BUILD_IDA)
     ADD_SUBDIRECTORY(examples/ida/serial)
     IF(FCMIX_ENABLE AND F77_FOUND)
       ADD_SUBDIRECTORY(examples/ida/fcmix_serial)
+      IF(OPENMP_FOUND)
+        ADD_SUBDIRECTORY(examples/ida/fcmix_openmp)
+      ENDIF(OPENMP_FOUND)
+      IF(PTHREADS_FOUND)
+	ADD_SUBDIRECTORY(examples/ida/fcmix_pthreads)
+      ENDIF(PTHREADS_FOUND)
     ENDIF(FCMIX_ENABLE AND F77_FOUND)
+    IF(OPENMP_FOUND)
+      ADD_SUBDIRECTORY(examples/ida/C_openmp)
+    ENDIF(OPENMP_FOUND)
     IF(MPIC_FOUND)
       ADD_SUBDIRECTORY(examples/ida/parallel)
     ENDIF(MPIC_FOUND)
+    IF(PETSC_FOUND)
+      ADD_SUBDIRECTORY(examples/ida/petsc)
+    ENDIF(PETSC_FOUND)
     IF(MPIF_FOUND)
       ADD_SUBDIRECTORY(examples/ida/fcmix_parallel)
     ENDIF(MPIF_FOUND)
@@ -674,6 +1126,9 @@ IF(EXAMPLES_ENABLE)
   
   IF(BUILD_IDAS)	
     ADD_SUBDIRECTORY(examples/idas/serial)
+    IF(OPENMP_FOUND)
+      ADD_SUBDIRECTORY(examples/idas/C_openmp)
+    ENDIF(OPENMP_FOUND)
     IF(MPIC_FOUND)
       ADD_SUBDIRECTORY(examples/idas/parallel)
     ENDIF(MPIC_FOUND)
@@ -681,6 +1136,9 @@ IF(EXAMPLES_ENABLE)
 
   IF(BUILD_KINSOL)	
     ADD_SUBDIRECTORY(examples/kinsol/serial)
+    IF(OPENMP_FOUND)
+      ADD_SUBDIRECTORY(examples/kinsol/C_openmp) # the only example here need special handling from testrunner (not yet implemented)
+    ENDIF(OPENMP_FOUND)
     IF(FCMIX_ENABLE AND F77_FOUND)
       ADD_SUBDIRECTORY(examples/kinsol/fcmix_serial)
     ENDIF(FCMIX_ENABLE AND F77_FOUND)
@@ -698,6 +1156,29 @@ IF(EXAMPLES_ENABLE)
       ADD_SUBDIRECTORY(examples/cpodes/parallel)
     ENDIF(MPIC_FOUND)
   ENDIF(BUILD_CPODES)
+
+  # Always add the nvector serial examples
+  ADD_SUBDIRECTORY(examples/nvector/serial)
+
+  IF(MPIC_FOUND)
+      ADD_SUBDIRECTORY(examples/nvector/parallel)
+  ENDIF(MPIC_FOUND)
+  
+  IF(SUNDIALS_HYPRE)
+      ADD_SUBDIRECTORY(examples/nvector/parhyp)
+  ENDIF(SUNDIALS_HYPRE)
+
+  IF(PTHREADS_FOUND)
+      ADD_SUBDIRECTORY(examples/nvector/pthreads)
+  ENDIF(PTHREADS_FOUND)
+
+  IF(OPENMP_FOUND)
+      ADD_SUBDIRECTORY(examples/nvector/C_openmp)
+  ENDIF(OPENMP_FOUND)
+  
+  IF(PETSC_FOUND)
+      ADD_SUBDIRECTORY(examples/nvector/petsc)
+  ENDIF(PETSC_FOUND)
   
 ENDIF(EXAMPLES_ENABLE)
 
diff --git a/INSTALL_NOTES b/INSTALL_NOTES
deleted file mode 100644
index 3d9870a..0000000
--- a/INSTALL_NOTES
+++ /dev/null
@@ -1,559 +0,0 @@
-                     SUNDIALS Installation Instructions
-                        Release 2.7.0, March 2011  
-
-
-These are generic installation instructions. For complete installation instructions, 
-consult the user guide for any of the SUNDIALS solvers.
-
-Contents:
-
-[A] Preliminaries
-    A.1. Libraries and exported headers
-[B] autotools-based installation
-    B.1. Basic Installation
-    B.2. Installation names
-    B.3. Compilers and Options
-       B.3.1. General options
-       B.3.2. Options for Fortran support
-       B.3.3. Options for Blas/Lapack support
-       B.3.4. Options for MPI support
-       B.3.5. Options for library support
-       B.3.6. Environment variables
-    B.4. Configuration examples
-[C] CMake-based installation
-    C.1. Prerequisites
-    C.2. Configuration and build
-
-================
-A. Preliminaries
-================
-
-The SUNDIALS suite (or an individual solver) is distributed as a compressed archive
-(.tar.gz). The name of the distribution archive is of the form 'solver'-x.y.z.tar.gz,
-where 'solver' is one of: 'sundials', 'cvode', 'cvodes', 'ida', 'idas', or 'kinsol',
-and x.y.z represents the version number (of the SUNDIALS suite or of the individual 
-solver).
-
-To begin the installation, first uncompress and expand the sources, by issuing
-
-   % tar xzf solver-x.y.z.tar.gz
-
-This will extract source files under a directory 'solver'-x.y.z.
-
-In the remainder of this chapter, we make the following distinctions:
-
-'srcdir' 
-
-  is the directory 'solver'-x.y.z created above; i.e., the 
-  directory containing the SUNDIALS sources.
-
-'builddir'
-
-  is the directory under which SUNDIALS is built; i.e., the directory from within 
-  which the configure or ccmake command is issued. 
-
-  NOTE: When using the autoconf configure script, this directory can be the same 
-  as 'srcdir'. However, when using ccmake, insource builds are prohibited.
-
-'instdir'
-
-  is the directory under which the SUNDIALS exported header files and libraries will 
-  be installed. Typically, header files are exported under a directory 'instdir'/include 
-  while libraries are installed under 'instdir'/lib, with 'instdir' specified with the 
-  --prefix flag to configure. See below for more details on the installation directories, 
-  including the special cases of the SUNDIALS examples.
-
-  NOTE: The installation directory 'instdir' should NOT be the same as the source 
-        directory 'srcdir'.
-
-
-SUNDIALS provides two build alternatives:
-1) autotools-based build system. This options, suitable for *nix systems 
-   (Linux, Unix, Mac OS X, cygwin, mingw, etc.) is based on running a 'configure'
-   shell script which generates all required makefiles. 
-2) CMake-based build system. This option is available on a variety of platforms 
-   (*nix, Windows, Mac OS, etc) but relies on additional software (freely
-   available CMake).
-
-
------------------------------------
-A.1. Libraries and exported headers
------------------------------------
-
-By default, 'make install' will install the SUNDIALS libraries under 'libdir' and the public 
-header files under 'includedir'. The default values for these directories are 'instdir'/lib 
-and 'instdir'/include, respectively, but can be changed at the configuration stage.
-
-The SUNDIALS libraries and header files are summarized below (names are relative to 'libdir' 
-for libraries and to 'includedir' for header files)
-
-SHARED module
-  header files: sundials/sundials_types.h      sundials/sundials_math.h
-                sundials/sundials_config.h     sundias/sundials_nvector.h
-                sundials/sundials_smalldense.h sundials/sundials_dense.h
-                sundials/sundials_iterative.h  sundials/sundials_band.h
-                sundials/sundials_spbcgs.h     sundials/sundials_sptfqmr.h
-                sundials/sundials_spgmr.h      sundials/sundials_lapack.h
-                sundials/sundials_fnvector.h
-
-
-NVECTOR_SERIAL module
-  libraries:    libsundials_nvecserial.{a,so} libsundials_fnvecserial.a
-  header files: nvector/nvector_serial.h
-
-
-NVECTOR_PARALLEL module
-  libraries:    libsundials_nvecparallel.{a,so} libsundials_fnvecparallel.a
-  header files: nvector/nvector_parallel.h
-
-
-CVODE module
-  libraries:    libsundials_cvode.{a,so} libsundials_fcvode.a
-  header files: cvode/cvode.h          cvode/cvode_direct.h
-                cvode/cvode_dense.h    cvode/cvode_band.h
-                cvode/cvode_diag.h     cvode/cvode_spils.h
-                cvode/cvode_bandpre.h  cvode/cvode_bbdpre.h
-                cvode/cvode_spgmr.h    cvode/cvode_spbcgs.h
-                cvode/cvode_sptfqmr.h  cvode/cvode_impl.h
-                cvode/cvode_lapack.h
-
-
-CVODES module
-  library:      libsundials_cvodes.{a,so}
-  header files: cvodes/cvodes.h           cvodes/cvodes_direct.h
-                cvodes/cvodes_dense.h     cvodes/cvodes_band.h
-                cvodes/cvodes_diag.h      cvodes/cvodes_spils.h
-                cvodes/cvodes_bandpre.h   cvodes/cvodes_bbdpre.h
-                cvodes/cvodes_spgmr.h     cvodes/cvodes_spbcgs.h
-                cvodes/cvodes_sptfqmr.h   cvodes/cvodes_impl.h
-                cvodes/cvodes_lapack.h
-
-
-IDA module
-  library:      libsundials_ida.{a,so}
-  header files: ida/ida.h          ida/ida_direct.h
-                ida/ida_dense.h    ida/ida_band.h
-                ida/ida_spils.h    ida/ida_spgmr.h
-                ida/ida_spbcgs.h   ida/ida_sptfqmr.h
-                ida/ida_bbdpre.h   ida/ida_impl.h
-                ida/dia_lapack.h
-
-
-IDAS module
-  library:      libsundials_idas.{a,so}
-  header files: idas/idas.h          idas/idas_direct.h
-                idas/idas_dense.h    idas/idas_band.h
-                idas/idas_spils.h    idas/idas_spgmr.h
-                idas/idas_spbcgs.h   idas/idas_sptfqmr.h
-                idas/idas_bbdpre.h   idas/idas_impl.h
-                idas/dia_lapack.h
-
-
-KINSOL module
-  libraries:    libsundials_kinsol.{a,so} libsundials_fkinsol.a
-  header files: kinsol/kinsol.h
-                kinsol/kinsol_dense.h   kinsol/kinsol_band.h
-                kinsol/kinsol_spils.h   kinsol/kinsol_spgmr.h
-                kinsol/kinsol_spbcgs.h  kinsol/kinsol_sptfqmr.h
-                kinsol/kinsol_bbdpre.h  kinsol/kinsol_impl.h
-
-
-
-===============================
-B. autotools-based installation
-===============================
-
------------------------
-B.1. Basic Installation
------------------------
-
-The installation procedure outlined below will work on commodity Linux/Unix 
-systems without modification. However, users are still encouraged to carefully read 
-the entire chapter before attempting to install the SUNDIALS suite, in case
-non-default choices are desired for compilers, compilation options, or the like.
-Instead of reading the option list below, the user may invoke the configuration
-script with the help flag to view a complete listing of available options, which
-may be done by issuing 
-
-   % ./configure --help 
-
-from within the 'srcdir' directory created above.
-
-
-The installation steps for SUNDIALS can be as simple as 
-
-   % tar xzf solver-x.y.z.tar.gz
-   % cd solver-x.y.z
-   % ./configure
-   % make
-   % make install
-
-in which case the SUNDIALS header files and libraries are installed under /usr/local/include
-and /usr/local/lib, respectively. Note that, by default, the example programs are not built 
-and installed.
-
-If disk space is a priority, then to delete all temporary files created by building SUNDIALS, issue
-
-   % make clean
-
-To prepare the SUNDIALS distribution for a new install (using, for example, different options and/or
-installation destinations), issue
-
-   % make distclean
-
-
------------------------
-B.2. Installation names
------------------------
-
-By default, 'make install' will install the SUNDIALS libraries under 'libdir' and the public 
-header files under 'includedir'. The default values for these directories are 'instdir'/lib 
-and 'instdir'/include, respectively, but can be changed using the configure script options
---prefix, --exec-prefix, --includedir, and --libdir (see below). For example, a global 
-installation of SUNDIALS on a *NIX system could be accomplished using
-
-   % ./configure --prefix=/opt/sundials-2.3.0
-
-Although all installed libraries reside under 'libdir', the public header files are further 
-organized into subdirectories under 'includedir'.
-
-The installed libraries and exported header files are listed for reference in Section A.1.
-
-A typical user program need not explicitly include any of the shared SUNDIALS header files 
-from under the 'includedir'/sundials directory since they are explicitly included by the 
-appropriate solver header files (e.g., cvode_dense.h includes sundials_dense.h). 
-However, it is both legal and safe to do so (e.g., the functions declared in 
-sundials_smalldense.h could be used in building a preconditioner.
-
-
---------------------------
-B.3. Compilers and Options
---------------------------
-
-Some systems require unusual options for compilation or linking that the `configure' 
-script does not know about.  Run `./configure --help' for details on some of the 
-pertinent environment variables.
-
-You can give `configure' initial values for these variables by setting them in the 
-environment.  You can do that on the command line like this:
-
-     % ./configure CC=gcc CFLAGS=-O2 F77=g77 FFLAGS=-O
-
-Here is a detailed description of the configure options that are pertinent to SUNDIALS. 
-In what follows, 'build_tree' is the directory from where 'configure' was invoked.
-
-
-----------------------
-B.3.1. General options
-----------------------
-
---help
--h
-
-  print a summary of the options to `configure', and exit.
-
---quiet
---silent
--q
-
-  do not print messages saying which checks are being made.  To
-  suppress all normal output, redirect it to `/dev/null' (any error
-  messages will still be shown).
-
-
---prefix=PREFIX
-
-  Location for architecture-independent files.
-  Default: PREFIX=/usr/local
-
---exec-prefix=EPREFIX
-
-  Location for architecture-dependent files.
-  Default: EPREFIX=/usr/local
-  
---includedir=DIR
-
-  Alternate location for header files.
-  Default: DIR=PREFIX/include
-  
---libdir=DIR
-
-  Alternate location for libraries.
-  Default: DIR=EPREFIX/lib
-
---disable-solver
-
-  Although each existing solver module is built by default, support for a
-  given solver can be explicitly disabled using this option. 
-  The valid values for solver are: cvode, cvodes, 
-  ida, and kinsol.
-
---enable-examples
-
-  Available example programs are not built by default. Use this option
-  to enable compilation of all pertinent example programs. Upon completion of 
-  the 'make' command, the example executables will be created under solver-specific
-  subdirectories of 'builddir'/examples:
-
-    'builddir'/examples/'solver'/serial :         serial C examples
-    'builddir'/examples/'solver'/parallel :       parallel C examples
-    'builddir'/examples/'solver'/fcmix_serial :   serial Fortran examples
-    'builddir'/examples/'solver'/fcmix_parallel : parallel Fortran examples
-
-  Note: Some of these subdirectories may not exist depending upon the
-  solver and/or the configuration options given.
-
---with-exinstdir=DIR
-
-  Alternate location for example sources and sample output files (valid only if
-  examples are enabled). Note that installtion of example files can be completely
-  disabled by issuing DIR=no (in case building the examples is desired only as a
-  test of the SUNDIALS libraries).
-
-  Default: DIR=EPREFIX/examples
-
---with-cppflags=ARG
-
-  Specify C preprocessor flags (overrides the environment variable CPPFLAGS)
-  (e.g., ARG=-I<include_dir> if necessary header files are located in nonstandard locations).
-
---with-cflags=ARG
-
-  Specify C compilation flags (overrides the environment variable CFLAGS)
-
---with-ldflags=ARG
-
-  Specify linker flags (overrides the environment variable LDFLAGS)
-  (e.g., ARG=-L<lib_dir> if required libraries are located in nonstandard locations).
-
---with-libs=ARG
-
-  Specify additional libraries to be used 
-  (e.g., ARG=-l<foo> to link with the library named libfoo.a or libfoo.so).
-
---with-precision=ARG
-
-  By default, sundials will define a real number (internally referred to as
-  realtype) to be a double-precision floating-point numeric data type (double
-  C-type); however, this option may be used to build sundials with realtype
-  alternatively defined as a single-precision floating-point numeric data type
-  (float C-type) if ARG=single, or as a long double C-type if ARG=extended.
-
-  Default: ARG=double
-
-----------------------------------
-B.3.2. Options for Fortran support
-----------------------------------
-
---disable-fcmix
-
-  Using this option will disable all F77 support. The fcvode, fida, fkinsol and
-  fnvector modules will not be built regardless of availability.
-
---with-fflags=ARG
-
-  Specify F77 compilation flags (overrides the environment variable FFLAGS)
-
---------------------------------------
-B.3.3. Options for Blas/Lapack support
---------------------------------------
-
---disable-lapack
-
-  Disable support for the linear solver module based on Blas/Lapack.
-
---with-blas=ARG
-
-  Specifies the BLAS library to be used
-
---with-lapack=ARG
-
-  Specifies the LAPACK library to be used
-
-------------------------------
-B.3.4. Options for MPI support
-------------------------------
-
-The following configuration options are only applicable to the parallel sundials packages:
-
-  
---disable-mpi
-
-  Using this option will completely disable MPI support.
-
---with-mpicc=ARG
---with-mpif77=ARG
-
-  By default, the configuration utility script will use the MPI compiler
-  scripts named mpicc and mpif77 to compile the parallelized
-  sundials subroutines; however, for reasons of compatibility, different
-  executable names may be specified via the above options. Also, ARG=no
-  can be used to disable the use of MPI compiler scripts, thus causing
-  the serial C and F compilers to be used to compile the parallelized
-  sundials functions and examples.
-
---with-mpi-root=MPIDIR
-
-  This option may be used to specify which MPI implementation should be used.
-  The sundials configuration script will automatically check under the
-  subdirectories MPIDIR/include and MPIDIR/lib for the necessary
-  header files and libraries. The subdirectory MPIDIR/bin will also be
-  searched for the C and F MPI compiler scripts, unless the user uses
-  --with-mpicc=no or --with-mpif77=no.
-
---with-mpi-incdir=INCDIR
---with-mpi-libdir=LIBDIR
---with-mpi-libs=LIBS
-
-  These options may be used if the user would prefer not to use a preexisting
-  MPI compiler script, but instead would rather use a serial complier and
-  provide the flags necessary to compile the MPI-aware subroutines in
-  sundials.
-
-  Often an MPI implementation will have unique library names and so it may
-  be necessary to specify the appropriate libraries to use (e.g., LIBS=-lmpich).
-
-  Default: INCDIR=MPIDIR/include, LIBDIR=MPIDIR/lib and LIBS=-lmpi
-
---with-mpi-flags=ARG
-
-  Specify additional MPI-specific flags.
-
-----------------------------------
-B.3.5. Options for library support
-----------------------------------
-
-By default, only static libraries are built, but the following option
-may be used to build shared libraries on supported platforms.
-
---enable-shared
-
-  Using this particular option will result in both static and shared versions
-  of the available sundials libraries being built if the systsupports
-  shared libraries. To build only shared libraries also specify --disable-static.
-
-  Note: The fcvode and fkinsol libraries can only be built as static
-  libraries because they contain references to externally defined symbols, namely
-  user-supplied F77 subroutines.  Although the F77 interfaces to the serial and
-  parallel implementations of the supplied nvector module do not contain any
-  unresolvable external symbols, the libraries are still built as static libraries
-  for the purpose of consistency.
-
-----------------------------
-B.3.6. Environment variables
-----------------------------
-
-The following environment variables can be locally (re)defined for use during the 
-configuration of sundials. See the next section for illustrations of these.
-
-CC
-
-F77
-
-  Since the configuration script uses the first C and F77 compilers found in
-  the current executable search path, then each relevant shell variable (CC
-  and F77) must be locally (re)defined in order to use a different compiler. 
-  For example, to use xcc (executable name of chosen compiler) as the C
-  language compiler, use CC=xcc in the configure step.
-
-CFLAGS
-
-FFLAGS
-
-  Use these environment variables to override the default C and F77 compilation flags.
-
-
----------------------------
-B.4. Configuration examples
----------------------------
-
-The following examples are meant to help demonstrate proper usage of the configure options.
-
-To build SUNDIALS using the default C and Fortran compilers, and default mpicc and mpif77 
-parallel compilers, enable compilation of examples, and install them under the default
-directory /home/myname/sundials/examples, use
-
-   % ./configure --prefix=/home/myname/sundials --enable-examples
-
-To disable installation of the examples, use:
-   % ./configure --prefix=/home/myname/sundials \
-                 --enable-examples --with-examples-instdir=no
-
-The following example builds SUNDIALS using gcc as the serial C compiler, g77 as the serial 
-Fortran compiler, mpicc as the parallel C compiler, mpif77 as the parallel Fortran compiler, 
-and uses the -g3 C compilation flag:
-
-   % ./configure CC=gcc F77=g77 --with-cflags=-g3 --with-fflags=-g3 \
-                 --with-mpicc=/usr/apps/mpich/1.2.4/bin/mpicc \ 
-                 --with-mpif77=/usr/apps/mpich/1.2.4/bin/mpif77
-
-The next example again builds SUNDIALS using gcc as the serial C compiler, but the 
---with-mpicc=no option explicitly disables the use of the corresponding MPI compiler 
-script. In addition, since the  --with-mpi-root option is given, the compilation flags
--I/usr/apps/mpich/1.2.4/include and -L/usr/apps/mpich/1.2.4/lib are passed to gcc when 
-compiling the MPI-enabled functions. 
-The --disable-examples option explicitly disables the examples.
-The --with-mpi-libs option is required so that the configure script can check if gcc 
-can link with the appropriate MPI library.
-
-   % ./configure CC=gcc --disable-examples --with-mpicc=no \
-                 --with-mpi-root=/usr/apps/mpich/1.2.4 \
-                 --with-mpi-libs=-lmpich
-
-
-
-===========================
-C. CMake-based installation
-===========================
-
-Using CMake as a build system for the SUNDIALS libraries has the advantage 
-that GUI based build configuration is possible. Also build files for Windows 
-development environments can be easily generated. On the Windows platform 
-compilers such as the Borland C++ compiler or Visual C++ compiler are natively 
-supported. 
-
-The installation options are very similar to the options mentioned above. 
-Note, however, that CMake may not support all features and plattforms that 
-are supported by the autotools build system.
-
-------------------
-C.1. Prerequisites
-------------------
-
-You may need to get CMake if it isn't available on your system already. 
-In order to use the CMake build system, you need a fairly recent CMake version. 
-You can download it from http://www.cmake.org www.cmake.org. 
-
-----------------------------
-C.2. Configuration and build
-----------------------------
-
-We assume here a *nix system. For other systems, the required steps are very 
-similar and are explained in more detail in the SUNDIALS user guides.
-The installation steps are as follows:
-
-- uncompress solver-x.y.z.tar.gz to obtain 'srcdir'
-- create the directories 'builddir' and 'instdir'
-- change directory to 'builddir'
-- run ccmake with 'srcdir' as an argument
-
-You should now see the ccmake curses interface. Press 'c' to configure your build 
-with the default options. (If you don't have curses on your system and cannot use 
-ccmake, you can configure cmake with command line options very similar to ./configure 
-of the autotools. You can read about this on the cmake webpage.)
-
-In the dialog you can adjust the build options. For details see the options above
-in the autotools section. To adjust advanced options press 't' to show all the options
-and settings CMake offers. 
-
-After adjusting some options, for instance enabling the examples by turning 
-ENABLE_EXAMPLES to ON, you need to press 'c' again. Depending on the options, 
-you will see new options at the top of the list, marked with a star. After 
-adjusting the new options, press 'c' again. Once all options have been set, 
-you can press 'g' to generate the make files.
-
-Now you can build and install the sundials library:
-   % make
-   % make install
-
-
diff --git a/LICENSE b/LICENSE
index 73faf96..5675f1d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,15 +1,17 @@
-Copyright (c) 2002, The Regents of the University of California. 
+Copyright (c) 2002-2016, Lawrence Livermore National Security. 
 Produced at the Lawrence Livermore National Laboratory.
-Written by S.D. Cohen, A.C. Hindmarsh, R. Serban, 
-           D. Shumaker, and A.G. Taylor.
+Written by A.C. Hindmarsh, D.R. Reynolds, R. Serban, C.S. Woodward,
+S.D. Cohen, A.G. Taylor, S. Peles, L.E. Banks, and D. Shumaker.
+LLNL-CODE-667205    (ARKODE)
 UCRL-CODE-155951    (CVODE)
 UCRL-CODE-155950    (CVODES)
 UCRL-CODE-155952    (IDA)
 UCRL-CODE-237203    (IDAS)
-UCRL-CODE-155953    (KINSOL)
+LLNL-CODE-665877    (KINSOL)
 All rights reserved. 
 
-This file is part of SUNDIALS.
+This file is part of SUNDIALS.  For details, 
+see http://computation.llnl.gov/projects/sundials
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
@@ -23,42 +25,43 @@ notice, this list of conditions and the disclaimer (as noted below)
 in the documentation and/or other materials provided with the
 distribution.
 
-3. Neither the name of the UC/LLNL nor the names of its contributors
+3. Neither the name of the LLNS/LLNL nor the names of its contributors
 may be used to endorse or promote products derived from this software
 without specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
+LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF 
+ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 Additional BSD Notice
 ---------------------
 1. This notice is required to be provided under our contract with
-the U.S. Department of Energy (DOE). This work was produced at the
-University of California, Lawrence Livermore National Laboratory
-under Contract No. W-7405-ENG-48 with the DOE.
+the U.S. Department of Energy (DOE). This work was produced at
+Lawrence Livermore National Laboratory under Contract 
+No. DE-AC52-07NA27344 with the DOE.
 
-2. Neither the United States Government nor the University of
-California nor any of their employees, makes any warranty, express
-or implied, or assumes any liability or responsibility for the
+2. Neither the United States Government nor Lawrence Livermore 
+National Security, LLC nor any of their employees, makes any warranty, 
+express or implied, or assumes any liability or responsibility for the
 accuracy, completeness, or usefulness of any information, apparatus,
 product, or process disclosed, or represents that its use would not
 infringe privately-owned rights.
 
-3. Also, reference herein to any specific commercial products,
-process, or services by trade name, trademark, manufacturer or
-otherwise does not necessarily constitute or imply its endorsement,
-recommendation, or favoring by the United States Government or the
-University of California. The views and opinions of authors expressed
-herein do not necessarily state or reflect those of the United States
-Government or the University of California, and shall not be used for
-advertising or product endorsement purposes.
+3. Also, reference herein to any specific commercial products, process, 
+or services by trade name, trademark, manufacturer or otherwise does 
+not necessarily constitute or imply its endorsement, recommendation, 
+or favoring by the United States Government or Lawrence Livermore 
+National Security, LLC. The views and opinions of authors expressed 
+herein do not necessarily state or reflect those of the United States 
+Government or Lawrence Livermore National Security, LLC, and shall 
+not be used for advertising or product endorsement purposes.
+
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index c520e8e..0000000
--- a/Makefile.in
+++ /dev/null
@@ -1,139 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.17 $
-# $Date: 2012/04/06 22:24:37 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Main Makefile for SUNDIALS suite
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-bindir       = @bindir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-
-SLV_MODULES  = @SLV_MODULES@
-EXS_MODULES  = @EXS_MODULES@
-
-ALL_MODULES  = @SLV_MODULES@ @EXS_MODULES@
-
-EXS_INSTDIR  = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-
-# -----------------------------------------------------------------
-
-all:
-	@for i in ${ALL_MODULES} ; do       \
-	   if test -d $${i} ; then          \
-	     echo "----------------------"; \
-	     echo "Make $${i}..." ;         \
-	     echo "----------------------"; \
-	     cd $${i} ;                     \
-	     ${MAKE} ;                      \
-	     cd ${abs_builddir} ;           \
-	     echo "" ;                      \
-	   fi ;                             \
-	 done
-
-install:
-	$(mkinstalldirs) $(bindir)
-	$(INSTALL_PROG)  $(top_builddir)/bin/sundials-config    $(bindir)/
-	@if test -f $(top_builddir)/bin/fortran-update.sh ; then              \
-	  $(INSTALL_PROG)  $(top_builddir)/bin/fortran-update.sh  $(bindir)/ ;\
-	fi
-	@for i in ${SLV_MODULES} ; do                                         \
-	   if test -d $${i} ; then                                            \
-	     echo "----------------------";                                   \
-	     echo "Install $${i}..." ;                                        \
-	     echo "----------------------";                                   \
-	     cd $${i} ;                                                       \
-	     ${MAKE} install ;                                                \
-	     cd ${abs_builddir} ;                                             \
-	     echo "" ;                                                        \
-	   fi ;                                                               \
-	 done
-	@if test "X${EXS_MODULES}" = "X" ; then                               \
-	   : ;                                                                \
-	 else                                                                 \
-	   if test "X${EXS_INSTDIR}" = "Xno"; then                            \
-	     echo "" ;                                                        \
-	     echo "" ;                                                        \
-	     echo "Examples were built but installation was disabled." ;      \
-	     echo "" ;                                                        \
-	     echo "" ;                                                        \
-	   else                                                               \
-	     for i in ${EXS_MODULES} ; do                                     \
-	       echo "----------------------";                                 \
-	       echo "Install $${i}..." ;                                      \
-	       echo "----------------------";                                 \
-	       cd $${i} ;                                                     \
-	       ${MAKE} install ;                                              \
-	       cd ${abs_builddir} ;                                           \
-	       echo "" ;                                                      \
-	     done ;                                                           \
-	   fi ;                                                               \
-	 fi
-
-clean:
-	@for i in ${ALL_MODULES} ; do \
-	   if test -d $${i} ; then    \
-	     cd $${i} ;               \
-	     ${MAKE} clean ;          \
-	     cd ${abs_builddir} ;     \
-	   fi ;                       \
-	 done
-
-uninstall:
-	rm -f $(bindir)/sundials-config
-	rm -f $(bindir)/fortran-update.sh
-	@for i in ${ALL_MODULES} ; do       \
-	   if test -d $${i} ; then          \
-	     echo "----------------------"; \
-	     echo "Uninstall $${i}..." ;    \
-	     echo "----------------------"; \
-	     cd $${i} ;                     \
-	     ${MAKE} uninstall ;            \
-	     cd ${abs_builddir} ;           \
-	   fi ;                             \
-	 done
-
-# ---------------------------------------------------------------------
-
-distclean:
-	@for i in ${ALL_MODULES} ; do  \
-	   if test -d $${i} ; then     \
-	     cd $${i};                 \
-	     ${MAKE} distclean;        \
-	     cd ${abs_builddir} ;      \
-	   fi ;                        \
-	 done
-	rm -f $(top_builddir)/config.log
-	rm -f $(top_builddir)/config.status
-	rm -f $(top_builddir)/config.cache
-	rm -f $(top_builddir)/config.h
-	rm -f $(top_builddir)/libtool
-	rm -f $(top_builddir)/bin/sundials-config
-	rm -f $(top_builddir)/bin/fortran-update.sh
-	rm -f Makefile
diff --git a/README b/README
index 2e4d7e8..dd71714 100644
--- a/README
+++ b/README
@@ -1,11 +1,13 @@
                             SUNDIALS 
     SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
-                   Release 2.5.0, March 2012
-            Alan Hindmarsh, Radu Serban, Carol Woodward
+                   Release 2.6.2, August 2015
+      Alan Hindmarsh, Daniel Reynolds, Radu Serban, Carol Woodward
            Center for Applied Scientific Computing, LLNL
 
-
 The family of solvers referred to as SUNDIALS consists of the following solvers:
+ ARKODE - for integration of ordinary differential equation systems (ODEs)
+          ARKODE treats stiff, nonstiff and multi-rate ODE systems of the form
+          y' = fe(t,y) + fi(t,y), y(t0) = y0
  CVODE  - for integration of ordinary differential equation systems (ODEs)
           CVODE treats stiff and nonstiff ODE systems of the form
           y' = f(t,y), y(t0) = y0
@@ -28,30 +30,31 @@ that exploits that sharing. Each individual solver includes documentation
 on installation, along with full usage documentation.
 
 Warning to users who receive more than one of these individual solvers
-at different times: The mixing of old and new versions SUNDIALS may fail.  
+at different times: The mixing of old and new versions of SUNDIALS may fail.  
 To avoid such failures, obtain all desired solvers at the same time.
 
-For installation directions see the file INSTALL_NOTES.
-
-For additional information on a particular solver, see the README file
-in the solver directory (e.g. src/cvode/README).
-
-
-Release history
+For installation directions see the file INSTALL_GUIDE.pdf.
+
+Release history:
+
++----------+----------------------------------------------------------------------------+
+|          | SUNDIALS |                             Solver version                      |
+|   Date   |          +----------+----------+----------+----------+---------------------+
+|          | release  |  ARKODE  |   CVODE  | CVODES   |   IDA    |   IDAS   |  KINSOL  |
++----------+----------+----------+----------+----------+----------+---------------------+
+| Sep 2016 |   2.7.0  |  1.1.0   |  2.9.0   |  2.9.0   |  2.9.0   |  1.3.0   |  2.9.0   |
+| Aug 2015 |   2.6.2  |  1.0.2   |  2.8.2   |  2.8.2   |  2.8.2   |  1.2.2   |  2.8.2   |
+| Mar 2015 |   2.6.1  |  1.0.1   |  2.8.1   |  2.8.1   |  2.8.1   |  1.2.1   |  2.8.1   |
+| Mar 2015 |   2.6.0  |  1.0.0   |  2.8.0   |  2.8.0   |  2.8.0   |  1.2.0   |  2.8.0   |
+| Mar 2012 |   2.5.0  |          |  2.7.0   |  2.7.0   |  2.7.0   |  1.1.0   |  2.7.0   |
+| May 2009 |   2.4.0  |          |  2.6.0   |  2.6.0   |  2.6.0   |  1.0.0   |  2.6.0   |
+| Nov 2006 |   2.3.0  |          |  2.5.0   |  2.5.0   |  2.5.0   |          |  2.5.0   |
+| Mar 2006 |   2.2.0  |          |  2.4.0   |  2.4.0   |  2.4.0   |          |  2.4.0   |
+| May 2005 |   2.1.1  |          |  2.3.0   |  2.3.0   |  2.3.0   |          |  2.3.0   |
+| Apr 2005 |   2.1.0  |          |  2.3.0   |  2.2.0   |  2.3.0   |          |  2.3.0   |
+| Mar 2005 |   2.0.2  |          |  2.2.2   |  2.1.2   |  2.2.2   |          |  2.2.2   |
+| Jan 2005 |   2.0.1  |          |  2.2.1   |  2.1.1   |  2.2.1   |          |  2.2.1   |
+| Dec 2004 |   2.0    |          |  2.2.0   |  2.1.0   |  2.2.0   |          |  2.2.0   |
+| Jul 2002 |   1.0    |          |    2.0   |    1.0   |    2.0   |          |    2.0   |
++----------+----------+----------+----------+----------+----------+---------------------+
 
-+----------+-----------------------------------------------------------------+
-|          | SUNDIALS |                        Solver version                |
-|   Date   |          +----------+----------+----------+---------------------+
-|          | release  |   CVODE  | CVODES   |   IDA    |   IDAS   |  KINSOL  |
-+----------+----------+----------+----------+----------+---------------------+
-| Jul 2002 |   1.0    |    2.0   |    1.0   |    2.0   |          |    2.0   |
-| Dec 2004 |   2.0    |  2.2.0   |  2.1.0   |  2.2.0   |          |  2.2.0   |
-| Jan 2005 |   2.0.1  |  2.2.1   |  2.1.1   |  2.2.1   |          |  2.2.1   |
-| Mar 2005 |   2.0.2  |  2.2.2   |  2.1.2   |  2.2.2   |          |  2.2.2   |
-| Apr 2005 |   2.1.0  |  2.3.0   |  2.2.0   |  2.3.0   |          |  2.3.0   |
-| May 2005 |   2.1.1  |  2.3.0   |  2.3.0   |  2.3.0   |          |  2.3.0   |
-| Mar 2006 |   2.2.0  |  2.4.0   |  2.4.0   |  2.4.0   |          |  2.4.0   |
-| Nov 2006 |   2.3.0  |  2.5.0   |  2.5.0   |  2.5.0   |          |  2.5.0   |
-| May 2009 |   2.4.0  |  2.6.0   |  2.6.0   |  2.6.0   |  1.0.0   |  2.6.0   |
-| Mar 2012 |   2.5.0  |  2.7.0   |  2.7.0   |  2.7.0   |  1.1.0   |  2.7.0   |
-+----------+----------+----------+----------+----------+---------------------+
diff --git a/acinclude.m4 b/acinclude.m4
deleted file mode 100644
index 7825698..0000000
--- a/acinclude.m4
+++ /dev/null
@@ -1,3213 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.58 $
-# $Date: 2010/12/15 22:28:17 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-#
-# SUNDIALS autoconf macros
-#
-# The functions defined here fall into the following categories:
-#
-# (1) Initializations:
-#     SUNDIALS_GREETING
-#     SUNDIALS_INITIALIZE
-#     SUNDIALS_ENABLES
-#
-# (2) C compiler tests
-#     SUNDIALS_SET_CC
-#     SUNDIALS_CC_CHECK
-#     SUNDIALS_CPLUSPLUS_CHECK
-#
-# (3) Fortran support
-#     SUNDIALS_F77_SUPPORT
-#     SUNDIALS_F77_CHECK
-#     SUNDIALS_F77_LNKR_CHECK
-#     SUNDIALS_F77_NAME_MANGLING
-#     SUNDIALS_F77_LAPACK_SET
-#
-# (4) Parallel support
-#     SUNDIALS_SET_MPICC
-#     SUNDIALS_CHECK_MPICC
-#     SUNDIALS_CC_WITH_MPI_CHECK
-#     SUNDIALS_SET_MPIF77
-#     SUNDIALS_CHECK_MPIF77
-#     SUNDIALS_MPIF77_LNKR_CHECK
-#     SUNDIALS_F77_WITH_MPI_CHECK
-#     SUNDIALS_CHECK_MPI2
-#
-# (5) Finalizations:
-#     SUNDIALS_MORE_HELP
-#     SUNDIALS_SET_EXAMPLES
-#     SUNDIALS_BUILD_MODULES_LIST
-#     SUNDIALS_POST_PROCESSING
-#     SUNDIALS_REPORT
-#
-# -----------------------------------------------------------------
-
-
-#=================================================================#
-#                                                                 #
-#                                                                 #
-#               I N I T I A L I Z A T I O N S                     #
-#                                                                 #
-#                                                                 #
-#==================================================================
-
-#------------------------------------------------------------------
-# GREETING
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_GREETING],
-[
-
-# Say Hi!
-echo "
----------------------------------
-Running SUNDIALS Configure Script
----------------------------------
-"
-
-]) dnl END SUNDIALS_GREETING
-
-#------------------------------------------------------------------
-# PERFORM INITIALIZATIONS
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_INITIALIZE],
-[
-
-# Reference custom macros
-m4_include([config/mod_fortran.m4])
-m4_include([config/mod_c.m4])
-m4_include([config/cust_general.m4])
-
-# Make input filename DOS compatible (change config.h.in to config.hin)
-AC_CONFIG_HEADERS([config.h:config.hin])
-
-# Make user aware of copyright notice (input COPYRIGHT information)
-AC_COPYRIGHT(
-[
-Copyright (c) 2002, The Regents of the University of California.
-Produced at the Lawrence Livermore National Laboratory.
-All rights reserved.
-For details, see the LICENSE file.
-])
-
-# Specify root of source tree
-# Given file is guaranteed to exist in all SUNDIALS packages
-AC_CONFIG_SRCDIR([/src/sundials/sundials_nvector.c])
-
-# Get host information
-# AC_CANONICAL_BUILD defines the following variables: build, build_cpu,
-# build_vendor, and build_os
-AC_CANONICAL_BUILD
-# AC_CANONICAL_HOST defines the following variables: host, host_cpu,
-# host_vendor, and host_os
-AC_CANONICAL_HOST
-
-# Set MAKE if necessary
-# Must include @SET_MAKE@ in each Makefile.in file
-# AC_SUBST is called automatically for SET_MAKE
-AC_PROG_MAKE_SET
-
-# Defines INSTALL (sets to path of "install" program)
-# Also sets INSTALL_PROGRAM and INSTALL_SCRIPT
-AC_PROG_INSTALL
-
-# Set defaults for config/sundials_config.in file
-F77_MANGLE_MACRO1=""
-F77_MANGLE_MACRO2=""
-PRECISION_LEVEL=""
-GENERIC_MATH_LIB=""
-BLAS_LAPACK_MACRO=""
-F77_MPI_COMM_F2C=""
-SUNDIALS_EXPORT="#define SUNDIALS_EXPORT"
-
-# Initialize enable status of various modules, options, and features
-# to their default values
-#
-# NOTE: when CPODES is released, change its default to enabled.
-#
-CVODE_ENABLED="yes"
-CVODES_ENABLED="yes"
-IDA_ENABLED="yes"
-IDAS_ENABLED="yes"
-KINSOL_ENABLED="yes"
-LAPACK_ENABLED="yes"
-FCMIX_ENABLED="yes"
-MPI_ENABLED="yes"
-#
-CPODES_ENABLED="no"
-#
-EXAMPLES_ENABLED="no"
-F77_EXAMPLES_ENABLED="no"
-
-# Initialize variables that may NOT necessarily be initialized
-# during normal execution. Should NOT use uninitialized variables
-F77_OK="no"
-LAPACK_OK="no"
-MPI_C_COMP_OK="no"
-MPI_F77_COMP_OK="no"
-
-# This variable is set to "yes" if an AC_MSG_WARN statement
-# was executed
-SUNDIALS_WARN_FLAG="no"
-
-]) dnl END SUNDIALS_INITIALIZE
-
-#------------------------------------------------------------------
-# TEST ENABLES
-#
-# The following variables may be changed here (default value in []):
-#
-#   CVODE_ENABLED    - enable CVODE module [yes]
-#   CVODES_ENABLED   - enable CVODES module [yes]
-#   IDA_ENABLED      - enable IDA module [yes]
-#   IDAS_ENABLED     - enable IDAS module [yes]
-#   KINSOL_ENABLED   - enable KINSOL module [yes]
-#   FCMIX_ENABLED    - enable Fortran-C interfaces [yes]
-#   LAPACK_ENABLED   - enable Lapack support [yes]
-#   MPI_ENABLED      - enable parallel support [yes]
-#   EXAMPLES_ENABLED - enable example programs [no]
-#   F77_EXAMPLES_ENABLED - enable Fortran example programs [no]
-#  
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_ENABLES],
-[
-
-# Check if user wants to disable CVODE module
-# If not, then make certain source directory actually exists
-AC_ARG_ENABLE(cvode,
-[AC_HELP_STRING([--disable-cvode],[disable configuration of CVODE])],
-[
-if test "X${enableval}" = "Xno"; then
-  CVODE_ENABLED="no"
-fi
-],
-[
-if test -d ${srcdir}/src/cvode ; then
-  CVODE_ENABLED="yes"
-else
-  CVODE_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable CVODES module
-# If not, then make certain source directory actually exists
-AC_ARG_ENABLE(cvodes,
-[AC_HELP_STRING([--disable-cvodes],[disable configuration of CVODES])],
-[
-if test "X${enableval}" = "Xno"; then
-  CVODES_ENABLED="no"
-fi
-],
-[
-if test -d ${srcdir}/src/cvodes ; then
-  CVODES_ENABLED="yes"
-else
-  CVODES_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable IDA module
-# If not, then make certain source directory actually exists
-AC_ARG_ENABLE(ida,
-[AC_HELP_STRING([--disable-ida],[disable configuration of IDA])],
-[
-if test "X${enableval}" = "Xno"; then
-  IDA_ENABLED="no"
-fi
-],
-[
-if test -d ${srcdir}/src/ida  ; then
-  IDA_ENABLED="yes"
-else
-  IDA_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable IDAS module
-# If not, then make certain source directory actually exists
-AC_ARG_ENABLE(idas,
-[AC_HELP_STRING([--disable-idas],[disable configuration of IDAS])],
-[
-if test "X${enableval}" = "Xno"; then
-  IDAS_ENABLED="no"
-fi
-],
-[
-if test -d ${srcdir}/src/idas  ; then
-  IDAS_ENABLED="yes"
-else
-  IDAS_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable KINSOL MODULE
-# If not, then make certain source directory actually exists
-AC_ARG_ENABLE(kinsol,
-[AC_HELP_STRING([--disable-kinsol],[disable configuration of KINSOL])],
-[
-if test "X${enableval}" = "Xno"; then
-  KINSOL_ENABLED="no"
-fi
-],
-[
-if test -d ${srcdir}/src/kinsol ; then
-  KINSOL_ENABLED="yes"
-else
-  KINSOL_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable CPODES module
-# If not, then make certain source directory actually exists
-AC_ARG_ENABLE(cpodes,
-[AC_HELP_STRING([--disable-cpodes],[disable configuration of CPODES])],
-[
-if test "X${enableval}" = "Xno"; then
-  CPODES_ENABLED="no"
-fi
-],
-[
-if test -d ${srcdir}/src/cpodes ; then
-  CPODES_ENABLED="yes"
-else
-  CPODES_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable Fortran support (FCMIX components).
-AC_ARG_ENABLE([fcmix],
-[AC_HELP_STRING([--disable-fcmix], [disable Fortran-C support])],
-[
-if test "X${enableval}" = "Xno"; then
-  FCMIX_ENABLED="no"
-fi
-],
-[
-if test "X${CVODE_ENABLED}" = "Xno" && test "X${KINSOL_ENABLED}" = "Xno" && test "X${IDA_ENABLED}" = "Xno"; then
-  FCMIX_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable Lapack support.
-AC_ARG_ENABLE([lapack],
-[AC_HELP_STRING([--disable-lapack], [disable Lapack support])],
-[
-if test "X${enableval}" = "Xno"; then
-  LAPACK_ENABLED="no"
-fi
-])
-
-# Check if user wants to disable support for MPI.
-# If not, set the default based on whetehr certain source directories exist
-AC_ARG_ENABLE([mpi],
-[AC_HELP_STRING([--disable-mpi],[disable MPI support])],
-[
-if test "X${enableval}" = "Xno"; then
-  MPI_ENABLED="no"
-fi
-],
-[
-if test -d ${srcdir}/src/nvec_par || test -d ${srcdir}/src/nvec_spcpar; then
-  MPI_ENABLED="yes"
-else
-  MPI_ENABLED="no"
-fi
-])
-
-# Check if user wants to enable all examples.
-# Examples are NOT built by default
-AC_ARG_ENABLE(examples,
-[AC_HELP_STRING([--enable-examples],[enable configuration of examples])],
-[
-if test "X${enableval}" = "Xno"; then
-  EXAMPLES_ENABLED="no"
-else
-  EXAMPLES_ENABLED="yes"
-fi
-])
-
-# Fortran examples are enabled only if both FCMIX and EXAMPLES are enabled
-if test "X${FCMIX_ENABLED}" = "Xyes" && test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-  F77_EXAMPLES_ENABLED="yes"
-fi
-
-]) dnl END SUNDIALS_ENABLES
-
-
-#=================================================================#
-#                                                                 #
-#                                                                 #
-#              C    C O M P I L E R     T E S T S                 #
-#                                                                 #
-#                                                                 #
-#==================================================================
-
-
-#------------------------------------------------------------------
-# CHECK C COMPILER
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_SET_CC],
-[
-
-
-if test "X${CC}" = "X"; then
-
-  echo ""
-  echo "   Unable to find a working C compiler"
-  echo ""
-  echo "   Try using CC to explicitly specify a C compiler"
-  echo ""
-
-  AC_MSG_ERROR([cannot find a C compiler])
-
-else
-
-  SUNDIALS_CC_CHECK
-
-fi
-
-]) dnl END SUNDIALS_SET_CC
- 
-
-AC_DEFUN([SUNDIALS_CC_CHECK],
-[
-
-# Default is C programming language (initialize language stack)
-AC_LANG([C])
-
-AC_ARG_WITH([],[],[])
-
-# Set floating-point precision: single   [C type 'float']
-#                               double   [C type 'double'] (default)
-#                               extended [C type 'long double']
-# Provide variable description templates for config.hin and config.h files
-# Required by autoheader utility
-AH_TEMPLATE([SUNDIALS_SINGLE_PRECISION],
-            [Define SUNDIALS data type 'realtype' as 'float'])
-AH_TEMPLATE([SUNDIALS_DOUBLE_PRECISION],
-            [Define SUNDIALS data type 'realtype' as 'double'])
-AH_TEMPLATE([SUNDIALS_EXTENDED_PRECISION],
-            [Define SUNDIALS data type 'realtype' as 'long double'])
-
-AC_MSG_CHECKING([floating-point data type to use])
-AC_ARG_WITH(precision,
-[AC_HELP_STRING([--with-precision=ARG],
-[specify floating-point precision (single/double/extended) [double]])],
-[
-if test "X${withval}" = "Xsingle"; then
-  AC_MSG_RESULT([float])
-  AC_DEFINE([SUNDIALS_SINGLE_PRECISION],[1],[])
-  FLOAT_TYPE="single"
-  PRECISION_LEVEL="#define SUNDIALS_SINGLE_PRECISION 1"
-elif test "X${withval}" = "Xdouble"; then
-  AC_MSG_RESULT([double])
-  AC_DEFINE([SUNDIALS_DOUBLE_PRECISION],[1],[])
-  FLOAT_TYPE="double"
-  PRECISION_LEVEL="#define SUNDIALS_DOUBLE_PRECISION 1"
-elif test "X${withval}" = "Xextended"; then
-  AC_MSG_RESULT([long double])
-  AC_DEFINE([SUNDIALS_EXTENDED_PRECISION],[1],[])
-  FLOAT_TYPE="extended"
-  PRECISION_LEVEL="#define SUNDIALS_EXTENDED_PRECISION 1"
-else
-  AC_MSG_ERROR([invalid input])
-fi
-],
-[
-# Use 'double' by default
-AC_MSG_RESULT([double])
-AC_DEFINE([SUNDIALS_DOUBLE_PRECISION],[1],[])
-FLOAT_TYPE="double"
-PRECISION_LEVEL="#define SUNDIALS_DOUBLE_PRECISION 1"
-])
-
-AC_ARG_WITH([],[ ],[])
-
-# Overwrite CFLAGS
-AC_MSG_CHECKING([for C compiler flags])
-AC_ARG_WITH(cflags,
-[AC_HELP_STRING([--with-cflags=ARG],[specify C compiler flags (CFLAGS will be overridden)])],
-[
-AC_MSG_RESULT([${withval}])
-CFLAGS="${withval}"
-],
-[
-AC_MSG_RESULT([none])
-])
-
-# Set CPP to command that runs C preprocessor
-AC_PROG_CPP
-
-# Overwrite CPPFLAGS
-AC_MSG_CHECKING([for C/C++ preprocessor flags])
-AC_ARG_WITH(cppflags,
-[AC_HELP_STRING([--with-cppflags=ARG],[specify C/C++ preprocessor flags (CPPFLAGS will be overridden)])],
-[
-AC_MSG_RESULT([${withval}])
-CPPFLAGS="${withval}"
-],
-[
-AC_MSG_RESULT([none])
-])
-
-# Overwrite LDFLAGS
-AC_MSG_CHECKING([for linker flags])
-AC_ARG_WITH(ldflags,
-[AC_HELP_STRING([--with-ldflags=ARG],[specify linker flags (LDFLAGS will be overridden)])],
-[
-AC_MSG_RESULT([${withval}])
-LDFLAGS="${withval}"
-],
-[
-AC_MSG_RESULT([none])
-])
-
-# Add any additional libraries
-AC_MSG_CHECKING([for extra libraries])
-AC_ARG_WITH(libs,
-[AC_HELP_STRING([--with-libs=ARG],[add extra libraries])],
-[
-AC_MSG_RESULT([${withval}])
-if test "X${LIBS}" = "X"; then
-  LIBS="${withval}"
-else
-  LIBS="${LIBS} ${withval}"
-fi
-],
-[
-AC_MSG_RESULT([none])
-])
-
-# Defines STDC_HEADERS if the following header files are found: stdlib.h,
-# stdarg.h, string.h, and float.h
-# We really only need stdlib.h and float.h
-AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h float.h math.h])
-
-# Set flag indicating if generic function names should be used
-# Provide variable description template for config.hin and config.h files
-# Required by autoheader utility
-AH_TEMPLATE([SUNDIALS_USE_GENERIC_MATH],
-            [Use generic math functions])
-
-# Check if math library contains abs(), fabs(), pow(), and sqrt() functions (required)
-# May update LIBS (meaning add additional library, namely libm)
-MATH_FABS_OK="yes"
-MATH_POW_OK="yes"
-MATH_SQRT_OK="yes"
-# Save copy of LIBS variable and unset LIBS
-SAVED_LIBS="${LIBS}"
-LIBS=""
-# The abs routine is defined for an integer argument, so check for it regardless of
-# the level of precision chosen
-AC_CHECK_LIB([m],abs,[],[AC_MSG_ERROR([cannot find abs function])])
-TEMP_MATH_LIB="${LIBS}"
-LIBS=""
-# Check for single-precision math routines
-if test "X${FLOAT_TYPE}" = "Xsingle"; then
-  AC_CHECK_LIB([m],fabsf,[],[MATH_FABS_OK="no"])
-  AC_CHECK_LIB([m],powf,[],[MATH_POW_OK="no"])
-  AC_CHECK_LIB([m],sqrtf,[],[MATH_SQRT_OK="no"])
-# Check for extended-precision math routines
-elif test "X${FLOAT_TYPE}" = "Xextended"; then
-  AC_CHECK_LIB([m],fabsl,[],[MATH_FABS_OK="no"])
-  AC_CHECK_LIB([m],powl,[],[MATH_POW_OK="no"])
-  AC_CHECK_LIB([m],sqrtl,[],[MATH_SQRT_OK="no"])
-# Check for (generic) double-precision math routines
-elif test "X${FLOAT_TYPE}" = "Xdouble"; then
-  AC_CHECK_LIB([m],fabs,[],[AC_MSG_ERROR([cannot find fabs function])])
-  AC_CHECK_LIB([m],pow,[],[AC_MSG_ERROR([cannot find pow function])])
-  AC_CHECK_LIB([m],sqrt,[],[AC_MSG_ERROR([cannot find sqrt function])])
-fi
-# If cannot find precision-specific implementations, then check for generic versions
-if test "X${MATH_FABS_OK}" = "Xno" || test "X${MATH_POW_OK}" = "Xno" || test "X${MATH_SQRT_OK}" = "Xno"; then
-  AC_CHECK_LIB([m],fabs,[],[AC_MSG_ERROR([cannot find fabs function])])
-  AC_CHECK_LIB([m],pow,[],[AC_MSG_ERROR([cannot find pow function])])
-  AC_CHECK_LIB([m],sqrt,[],[AC_MSG_ERROR([cannot find sqrt function])])
-  # If all generic math routines are available, then set SUNDIALS_USE_GENERIC_MATH flag
-  # for use by sundials_math.c file (preprocessor macros)
-  AC_DEFINE([SUNDIALS_USE_GENERIC_MATH],[1],[])
-  GENERIC_MATH_LIB="#define SUNDIALS_USE_GENERIC_MATH"
-# If found all precision-specific routines, then set SUNDIALS_USE_GENERIC_MATH only if
-# building SUNDIALS libraries with double-precision
-else
-  if test "X${FLOAT_TYPE}" = "Xdouble"; then
-    AC_DEFINE([SUNDIALS_USE_GENERIC_MATH],[1],[])
-    GENERIC_MATH_LIB="#define SUNDIALS_USE_GENERIC_MATH"
-  else
-    AC_DEFINE([SUNDIALS_USE_GENERIC_MATH],[0],[])
-  fi
-fi
-
-# Add math library to LIBS environment variable
-LIBS="${TEMP_MATH_LIB}"
-AC_MSG_CHECKING([for additional required C libraries])
-if test "X${LIBS}" = "X"; then
-  if test "X${SAVED_LIBS}" = "X"; then
-    LIBS=""
-  else
-    LIBS="${SAVED_LIBS}"
-  fi
-  AC_MSG_RESULT([none])
-else
-  AC_MSG_RESULT([${LIBS}])
-  if test "X${SAVED_LIBS}" = "X"; then
-    LIBS="${LIBS}"
-  else
-    LIBS="${LIBS} ${SAVED_LIBS}"
-  fi
-fi
-
-# Check sizeof(int) - used to modify Fortran examples
-AC_CHECK_SIZEOF(int)
-
-# Check sizeof(long int) - used to modify Fortran examples
-AC_CHECK_SIZEOF(long int)
-
-# Check sizeof(realtype), where realtype is either float, double
-# or long double - used to modify Fortran examples
-if test "X${FLOAT_TYPE}" = "Xsingle"; then
-  AC_CHECK_SIZEOF(float)
-elif test "X${FLOAT_TYPE}" = "Xdouble"; then
-  AC_CHECK_SIZEOF(double)
-elif test "X${FLOAT_TYPE}" = "Xextended"; then
-  AC_CHECK_SIZEOF(long double)
-fi
-
-# Defines EGREP and exports via AC_SUBST - used by FCMIX Makefile's
-AC_PROG_EGREP
-
-# Defines FGREP and exports via AC_SUBST - used by FCMIX Makefile's
-AC_PROG_FGREP
-
-# Check if CC is a C++ compiler
-# Note: If CC is a C++ compiler and MPI is enabled, then we will
-# check for "mpiCC" instead of "mpicc" if an MPI compiler was NOT specified
-SUNDIALS_CPLUSPLUS_CHECK([${CC}])
-
-]) dnl END SUNDIALS_SET_CC
-
-#------------------------------------------------------------------
-# CHECK IF COMPILER IS A C++ COMPILER
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_CPLUSPLUS_CHECK],
-[
-
-# Rename argument
-COMP_NAME="$1"
-
-# Update the language stack
-AC_LANG_PUSH([C])
-
-# Check if using a C++ compiler
-AC_MSG_CHECKING([if ${COMP_NAME} is a C++ compiler])
-AC_RUN_IFELSE(
-[AC_LANG_PROGRAM([[]],
-[[
-#ifdef __cplusplus
-  return(0);
-#else
-  return(1);
-#endif
-]])],
-[
-AC_MSG_RESULT([yes])
-# COMP_NAME is a C++ compiler
-USING_CPLUSPLUS_COMP="yes"
-],
-[
-AC_MSG_RESULT([no])
-# COMP_NAMPE is NOT a C++ compiler
-USING_CPLUSPLUS_COMP="no"
-])
-
-# Revert back to previous language
-AC_LANG_POP([C])
-
-]) dnl END SUNDIALS_CPLUSPLUS_CHECK
-
-
-
-
-#=================================================================#
-#                                                                 #
-#                                                                 #
-#             F O R T R A N     S U P P O R T                     #
-#                                                                 #
-#                                                                 #
-#==================================================================
-
-
-
-#------------------------------------------------------------------
-# FORTRAN SUPPORT
-#
-# Fortran support is required if FCMIX is enabled OR if LAPACK
-# is enabled. In either case, we need a working F77 compiler in
-# order to determine the Fortran name-mangling scheme.
-#
-# If we do need Fortran support, we first find and test a F77
-# compiler, determine the mangling scheme, then we find the 
-# libraries required to link C and Fortran.
-#
-# Throughout this function we use the control variable F77_OK
-# which was initialized to "no".
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_F77_SUPPORT],
-[
-
-F77_OK="yes"
-
-# Look for a F77 compiler
-# If unsuccessful, disable all Fortran support
-
-AC_PROG_F77(f77 g77)
-
-if test "X${F77}" = "X"; then
-
-  F77_OK="no"
-  SUNDIALS_WARN_FLAG="yes"
-
-  echo ""
-  echo "   Unable to find a working Fortran compiler"
-  echo ""
-  echo "   Try using F77 to explicitly specify a C compiler"
-  echo ""
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    echo "   Disabling compilation of Fortran-C interfaces..."
-  fi
-  if test "X${LAPACK_ENABLED}" = "Xyes"; then
-    echo "   Disabling compilation of Blas/Lapack interfaces..."
-  fi
-  echo ""
-
-  FCMIX_ENABLED="no"
-  LAPACK_ENABLED="no"
-  F77_EXAMPLES_ENABLED="no"
-
-fi
-
-# Check Fortran compiler
-# If unsuccessful, disable all Fortran support
-
-if test "X${F77_OK}" = "Xyes"; then
-
-  SUNDIALS_F77_CHECK
-
-  if test "X${F77_OK}" = "Xno"; then
-
-    SUNDIALS_WARN_FLAG="yes"
-
-    echo ""
-    echo "   Unable to compile test program using given Fortran compiler."
-    echo ""
-    if test "X${FCMIX_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Fortran-C interfaces..."
-    fi
-    if test "X${LAPACK_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Blas/Lapack interfaces..."
-    fi
-    echo ""
-
-    FCMIX_ENABLED="no"
-    LAPACK_ENABLED="no"
-    F77_EXAMPLES_ENABLED="no"
-    
-  fi
-
-fi
-
-
-# Determine the Fortran name-mangling scheme
-# If successfull, provide variable description templates for config.hin 
-# and config.h files required by autoheader utility
-# Otherwise, disable all Fortran support.
-
-if test "X${F77_OK}" = "Xyes"; then
-
-  SUNDIALS_F77_NAME_MANGLING
-
-  AH_TEMPLATE([SUNDIALS_F77_FUNC], [FCMIX: Define name-mangling macro for C identifiers])
-  AH_TEMPLATE([SUNDIALS_F77_FUNC_], [FCMIX: Define name-mangling macro for C identifiers with underscores])
-
-  if test "X${F77_OK}" = "Xno"; then
-
-    SUNDIALS_WARN_FLAG="yes"
-
-    echo ""
-    echo "   Unable to determine Fortran name-mangling scheme."
-    echo ""
-    if test "X${FCMIX_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Fortran-C interfaces..."
-    fi
-    if test "X${LAPACK_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Blas/Lapack interfaces..."
-    fi
-    echo ""
-
-    F77_EXAMPLES_ENABLED="no"
-    FCMIX_ENABLED="no"
-    LAPACK_ENABLED="no"
-
-  fi
-
-fi
-
-
-# If LAPACK is enabled, determine the proper library linkage
-# If successful, set the libaries
-# Otherwise, disable all Blas/Lapack support.
-
-if test "X${LAPACK_ENABLED}" = "Xyes" && test "X${F77_OK}" = "Xyes"; then
-
-
-  SUNDIALS_F77_LAPACK_SET
-
-  if test "X${LAPACK_OK}" = "Xyes"; then
-
-    AC_MSG_CHECKING([for Blas/Lapack library linkage])
-    BLAS_LAPACK_LIBS="${LAPACK_LIBS} ${BLAS_LIBS} ${LIBS} ${FLIBS}"
-    AC_MSG_RESULT([${LAPACK_LIBS} ${BLAS_LIBS}])
-
-  else
-
-    SUNDIALS_WARN_FLAG="yes"
-    AC_MSG_CHECKING([for Blas/Lapack library linkage])
-    AC_MSG_RESULT("no")
-    echo ""
-    echo "   Unable to determine Blas/Lapack library linkage."
-    echo ""
-    echo "   Try using --with-blas and --with-lapack."
-    echo ""
-    echo "   Disabling compilation of Blas/Lapack interfaces..."
-
-    LAPACK_ENABLED="no"
-
-  fi
-
-fi
-
-
-# Set the macro BLAS_LAPACK_MACRO for expansion in sundials_config.h
-
-AH_TEMPLATE([SUNDIALS_BLAS_LAPACK], [Availability of Blas/Lapack libraries])
-
-if test "X${LAPACK_ENABLED}" = "Xyes"; then
-  AC_DEFINE([SUNDIALS_BLAS_LAPACK],[1],[])
-  BLAS_LAPACK_MACRO="#define SUNDIALS_BLAS_LAPACK 1"
-else
-  AC_DEFINE([SUNDIALS_BLAS_LAPACK],[0],[])
-  BLAS_LAPACK_MACRO="#define SUNDIALS_BLAS_LAPACK 0"
-fi
-
-]) dnl SUNDIALS_F77_SUPPORT
-
-#------------------------------------------------------------------
-# CHECK FORTRAN COMPILER
-#
-# Test the Fortran compiler by attempting to compile and link a 
-# simple Fortran program. If the test succeeds, set F77_OK=yes.
-# If the test fails, set F77_OK="no"
-#
-# Finally, check if we must use a Fortran compiler to link the
-# Fortran codes (default is to use CC).
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_F77_CHECK],
-[
-
-AC_LANG_PUSH([Fortran 77])
-
-# Add any additional FFLAGS
-AC_MSG_CHECKING([for extra Fortran compiler flags])
-AC_ARG_WITH(fflags,
-[AC_HELP_STRING([--with-fflags=ARG],[add extra Fortran compiler flags])],
-[
-AC_MSG_RESULT([${withval}])
-FFLAGS="${FFLAGS} ${withval}"
-],
-[
-AC_MSG_RESULT([none])
-])
-  
-# Add any required linker flags to FLIBS
-# Note: if FLIBS is defined, it is left unchanged
-AC_F77_LIBRARY_LDFLAGS
-
-# Try to compile a simple Fortran program (no linking)
-AC_COMPILE_IFELSE(
-[AC_LANG_SOURCE(
-[[
-	SUBROUTINE SUNDIALS()
-	RETURN
-	END
-]])],
-[F77_OK="yes"],
-[F77_OK="no"])
-
-# If CC is a C++ compiler (decided in SUNDIALS_CPLUSPLUS_CHECK), we must use 
-# it to link the Fortran examples. In this case, test if that is successful.
-# Otherwise, simply use F77 as the linker
-
-if test "X${F77_OK}" = "Xyes"; then
-  AC_MSG_CHECKING([which linker to use])
-  if test "X${USING_CPLUSPLUS_COMP}" = "Xyes"; then
-    SUNDIALS_F77_LNKR_CHECK
-  else
-    F77_LNKR="${F77}"
-  fi
-  AC_MSG_RESULT([${F77_LNKR}])
-fi
-
-# Reset language (remove 'Fortran 77' from stack)
-AC_LANG_POP([Fortran 77])
-
-]) dnl END SUNDIALS_SET_F77
-
-
-#------------------------------------------------------------------
-# F77 LINKER CHECK
-# Check if the C++ compiler CC can be used to link a Fortran program.
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_F77_LNKR_CHECK],
-[
-
-F77_LNKR_CHECK_OK="no"
-
-# Compile simple Fortran example, but do NOT link
-# Note: result stored as conftest.${ac_objext}
-AC_COMPILE_IFELSE(
-[AC_LANG_SOURCE(
-[[
-	PROGRAM SUNDIALS
-	WRITE(*,*)'TEST'
-	END
-]])],
-[
-
-# Temporarily reset LIBS environment variable to perform test
-SAVED_LIBS="${LIBS}"
-LIBS="${LIBS} ${FLIBS}"
-
-# Switch working language to C for next test
-AC_LANG_PUSH([C])
-
-# Check if CC can link Fortran example
-# Note: AC_LINKONLY_IFELSE is a custom macro (modifications made to
-# general.m4 and c.m4) (see config/cust_general.m4 and config/mod_c.m4)
-AC_LINKONLY_IFELSE([],[F77_LNKR_CHECK_OK="yes"],[F77_LNKR_CHECK_OK="no"])
-
-# Revert back to previous language (Fortran 77)
-AC_LANG_POP([C])
-
-# Set LIBS environment variable back to original value
-LIBS="${SAVED_LIBS}"
-
-])
-
-# If either the compilation or the linking failed, we should
-# disable building the Fortran examples
-# For now, use F77 as the linker...
-if test "X${F77_LNKR_CHECK_OK}" = "Xyes"; then
-  F77_LNKR="${CC}"
-else
-  F77_LNKR="${F77}"
-fi
-
-]) dnl SUNDIALS_F77_LNKR_CHECK
-
-
-#------------------------------------------------------------------
-# DETERMINE FORTRAN NAME-MANGLING SCHEME
-#
-# Compiling a simple Fortran example and link it using a C compiler.
-# Interpret results to infer name-mangling scheme.
-#------------------------------------------------------------------
-
-
-AC_DEFUN([SUNDIALS_F77_NAME_MANGLING],
-[
-
-AC_LANG_PUSH([Fortran 77])
-
-# (1) Compile a dummy Fortran subroutine named SUNDIALS
-
-FNAME_STATUS="none"
-
-AC_COMPILE_IFELSE(
-  [AC_LANG_SOURCE(
-  [[
-	SUBROUTINE SUNDIALS()
-	RETURN
-	END
-  ]])],
-  [
-
-  mv conftest.${ac_objext} f77_wrapper_check.${ac_objext}
-
-  # Temporarily reset LIBS environment variable to perform test
-  SAVED_LIBS="${LIBS}"
-  LIBS="f77_wrapper_check.${ac_objext} ${LIBS} ${FLIBS}"
-
-  AC_LANG_PUSH([C])
-
-  for i in "sundials" "SUNDIALS"
-  do
-    for j in "" "_" "__"
-    do
-      F77_MANGLED_NAME="${i}${j}"
-      AC_LINK_IFELSE([AC_LANG_CALL([],[${F77_MANGLED_NAME}])],[FNAME_STATUS="set" ; break 2])
-    done
-  done
-
-  AC_LANG_POP([C])
-
-  # If test succeeded, then set the F77_MANGLE_MACRO1 macro
-
-  if test "X${FNAME_STATUS}" = "Xset"; then
-
-    if test "X${i}" = "Xsundials"; then
-
-      FNAME_MSG="lower case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name],[])
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name"
-        dgemm="dgemm"
-        dgetrf="dgetrf"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name ## _],[])
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name ## _"
-        dgemm="dgemm_"
-        dgetrf="dgetrf_"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name ## __],[])
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name ## __"
-        dgemm="dgemm__"
-        dgetrf="dgetrf__"
-      fi
-
-    else
-
-      FNAME_MSG="upper case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name],[])
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) NAME"
-        dgemm="DGEMM"
-        dgetrf="DGETRF"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name ## _],[])
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) NAME ## _"
-        dgemm="DGEMM_"
-        dgetrf="DGETRF_"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        AC_DEFINE([SUNDIALS_F77_FUNC(name,NAME)],[name ## __],[])
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) NAME ## __"
-        dgemm="DGEMM__"
-        dgetrf="DGETRF__"
-      fi
-
-    fi
-
-    AC_MSG_CHECKING([for Fortran name-mangling scheme of C identifiers])
-    AC_MSG_RESULT([${FNAME_MSG}])
-
-  else
-
-    F77_OK="no"
-
-  fi
-
-  # Set LIBS environment variable back to original value
-  LIBS="${SAVED_LIBS}"
-
-  ])
-
-# Remove temporary file
-rm -f f77_wrapper_check.${ac_objext}
-
-
-# (2) Compile a dummy Fortran subroutine named SUN_DIALS
-
-FNAME_STATUS="none"
-
-AC_COMPILE_IFELSE(
-  [AC_LANG_SOURCE(
-  [[
-	SUBROUTINE SUN_DIALS()
-	RETURN
-	END
-  ]])],
-  [
-
-  mv conftest.${ac_objext} f77_wrapper_check.${ac_objext}
-
-  # Temporarily reset LIBS environment variable to perform test
-  SAVED_LIBS="${LIBS}"
-  LIBS="f77_wrapper_check.${ac_objext} ${LIBS} ${FLIBS}"
-
-  AC_LANG_PUSH([C])
-
-  for i in "sun_dials" "SUN_DIALS"
-  do
-    for j in "" "_" "__"
-    do
-      F77_MANGLED_NAME="${i}${j}"
-      AC_LINK_IFELSE([AC_LANG_CALL([],[${F77_MANGLED_NAME}])],[FNAME_STATUS="set" ; break 2])
-    done
-  done
-
-  AC_LANG_POP([C])
-
-  # If test succeeded, then set the F77_MANGLE_MACRO2 macro
-
-  if test "X${FNAME_STATUS}" = "Xset"; then
-
-    if test "X${i}" = "Xsun_dials"; then
-
-      FNAME_MSG="lower case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC_(name,NAME)],[name],[])
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) name"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC_(name,NAME)],[name ## _],[])
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) name ## _"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        AC_DEFINE([SUNDIALS_F77_FUNC_(name,NAME)],[name ## __],[])
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) name ## __"
-      fi
-
-    else
-
-      FNAME_MSG="upper case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC_(name,NAME)],[name],[])
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) NAME"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        AC_DEFINE([SUNDIALS_F77_FUNC_(name,NAME)],[name ## _],[])
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## _"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        AC_DEFINE([SUNDIALS_F77_FUNC_(name,NAME)],[name ## __],[])
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## __"
-      fi
-
-    fi
-
-    AC_MSG_CHECKING([for Fortran name-mangling scheme of C identifiers with underscores])
-    AC_MSG_RESULT([${FNAME_MSG}])
-
-  else
-
-    F77_OK="no"
-
-  fi
-
-  # Set LIBS environment variable back to original value
-  LIBS="${SAVED_LIBS}"
-
-  ])
-
-# Remove temporary file
-rm -f f77_wrapper_check.${ac_objext}
-
-
-AC_LANG_POP([Fortran 77])
-
-]) dnl END SUNDIALS_SET_FNAME
-
-
-#------------------------------------------------------------------
-# DETERMINE BLAS/LAPACK LIBRARY LINKAGE SCHEME
-#
-# If successful, this function sets LAPACK_OK="yes".
-# Otherwise, it sets LAPACK_OK="no" 
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_F77_LAPACK_SET],
-[
-
-# Check if the user specifies Blas libraries
-AC_ARG_WITH(blas,
-[AC_HELP_STRING([--with-blas=ARG],[specify Blas library])],
-[
-  case $withval in
-    -* | */* | *.a | *.so | *.so.* | *.o) 
-        BLAS_LIBS="$withval" 
-        ;;
-    *) 
-        BLAS_LIBS="-l$withval" 
-        ;;
-  esac
-])
-
-# Check if the user specifies Lapack libraries
-AC_ARG_WITH(lapack,
-[AC_HELP_STRING([--with-lapack=ARG],[specify Lapack library])],
-[
-  case $withval in
-    -* | */* | *.a | *.so | *.so.* | *.o) 
-        LAPACK_LIBS="$withval" 
-        ;;
-    *) 
-        LAPACK_LIBS="-l$withval" 
-        ;;
-  esac
-])
-
-acx_blas_ok=no
-acx_lapack_ok=no
-
-# BLAS_LIBS
-# ---------
-
-acx_blas_save_LIBS="$LIBS"
-LIBS="$LIBS $FLIBS"
-
-# First, check BLAS_LIBS environment variable
-if test "x$BLAS_LIBS" != x; then
-  save_LIBS="$LIBS"
-  LIBS="$BLAS_LIBS $LIBS"
-  AC_MSG_CHECKING([aha for $dgemm in $BLAS_LIBS])
-  AC_TRY_LINK_FUNC($dgemm, [acx_blas_ok=yes], [BLAS_LIBS=""])
-  AC_MSG_RESULT($acx_blas_ok)
-  LIBS="$save_LIBS"
-fi
-
-# BLAS linked to by default?  (happens on some supercomputers)
-if test $acx_blas_ok = no; then
-  save_LIBS="$LIBS"; LIBS="$LIBS"
-  AC_CHECK_FUNC($dgemm, [acx_blas_ok=yes])
-  LIBS="$save_LIBS"
-fi
-
-# BLAS in Alpha CXML library?
-if test $acx_blas_ok = no; then
-  AC_CHECK_LIB(cxml, $dgemm, [acx_blas_ok=yes;BLAS_LIBS="-lcxml"])
-fi
-
-# BLAS in Alpha DXML library? (now called CXML, see above)
-if test $acx_blas_ok = no; then
-  AC_CHECK_LIB(dxml, $dgemm, [acx_blas_ok=yes;BLAS_LIBS="-ldxml"])
-fi
-
-# BLAS in Sun Performance library?
-if test $acx_blas_ok = no; then
-  if test "x$GCC" != xyes; then # only works with Sun CC
-    AC_CHECK_LIB(sunmath, acosp,
-                 [AC_CHECK_LIB(sunperf, $dgemm,
-                               [BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
-                                acx_blas_ok=yes],[],[-lsunmath])])
-  fi
-fi
-
-# BLAS in SCSL library?  (SGI/Cray Scientific Library)
-if test $acx_blas_ok = no; then
-  AC_CHECK_LIB(scs, $dgemm, [acx_blas_ok=yes; BLAS_LIBS="-lscs"])
-fi
-
-# BLAS in SGIMATH library?
-if test $acx_blas_ok = no; then
-  AC_CHECK_LIB(complib.sgimath, $dgemm,
-               [acx_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
-fi
-
-# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
-if test $acx_blas_ok = no; then
- AC_CHECK_LIB(blas, $dgemm,
-              [AC_CHECK_LIB(essl, $dgemm,
-                        [acx_blas_ok=yes; BLAS_LIBS="-lessl -lblas"],
-                        [], [-lblas $FLIBS])])
-fi
-
-# Generic BLAS library?
-if test $acx_blas_ok = no; then
-  AC_CHECK_LIB(blas, $dgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas"])
-fi
-
-LIBS="$acx_blas_save_LIBS"
-
-# LAPACK
-# ------
-
-# If we didn't find a Blas implementation, disable tests for Lapack
-if test $acx_blas_ok = no; then
-  acx_lapack_ok=disabled
-fi
-
-# Check LAPACK_LIBS environment variable
-if test $acx_lapack_ok = no; then
-if test "x$LAPACK_LIBS" != x; then
-  save_LIBS="$LIBS"; 
-  LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
-  AC_MSG_CHECKING([for $dgetrf in $LAPACK_LIBS])
-  AC_TRY_LINK_FUNC($dgetrf, [acx_lapack_ok=yes], [LAPACK_LIBS=""])
-  AC_MSG_RESULT($acx_lapack_ok)
-  LIBS="$save_LIBS"
-  if test acx_lapack_ok = no; then
-     LAPACK_LIBS=""
-  fi
-fi
-fi
-
-# LAPACK linked to by default?  (is sometimes included in BLAS lib)
-if test $acx_lapack_ok = no; then
-  save_LIBS="$LIBS"
-  LIBS="$LIBS $BLAS_LIBS $FLIBS"
-  AC_CHECK_FUNC($dgetrf, [acx_lapack_ok=yes])
-  LIBS="$save_LIBS"
-fi
-
-# Generic LAPACK library?
-for lapack in lapack lapack_rs6k; do
-  if test $acx_lapack_ok = no; then
-    save_LIBS="$LIBS"
-      LIBS="$BLAS_LIBS $LIBS"
-      AC_CHECK_LIB($lapack, $dgetrf,
-                   [acx_lapack_ok=yes; LAPACK_LIBS="-l$lapack"], [], [$FLIBS])
-      LIBS="$save_LIBS"
-  fi
-done
-
-# If we have both libraries, set LAPACK_OK to yes
-# -----------------------------------------------------
-
-if test $acx_blas_ok = yes && test $acx_lapack_ok = yes; then
-  LAPACK_OK="yes"
-else
-  LAPACK_OK="no"
-fi
-
-]) dnl SUNDIALS_F77_LAPACK_SET
-
-
-
-
-
-#=================================================================#
-#                                                                 #
-#                                                                 #
-#           P A R A L L E L     S U P P O R T                     #
-#                                                                 #
-#                                                                 #
-#==================================================================
-
-
-#------------------------------------------------------------------
-# CHECK MPI-C COMPILER
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_SET_MPICC],
-[
-
-AC_ARG_WITH([],[    ],[])
-
-# MPI root directory
-AC_ARG_WITH(mpi-root,
-[AC_HELP_STRING([--with-mpi-root=MPIROOT],[use MPI root directory])],
-[
-MPI_ROOT_DIR="${withval}"
-],
-[
-MPI_ROOT_DIR=""
-])
-
-# MPI include directory
-AC_ARG_WITH(mpi-incdir,
-[AC_HELP_STRING([--with-mpi-incdir=DIR],[MPI include directory @<:@MPIROOT/include@:>@])],
-[
-MPI_INC_DIR="${withval}"
-],
-[
-MPI_INC_DIR=""
-])
-
-# MPI library directory
-AC_ARG_WITH(mpi-libdir,
-[AC_HELP_STRING([--with-mpi-libdir=DIR],[MPI library directory @<:@MPIROOT/lib@:>@])],
-[
-MPI_LIB_DIR="${withval}"
-],
-[
-MPI_LIB_DIR=""
-])
-
-# MPI libraries
-AC_ARG_WITH(mpi-libs,
-[AC_HELP_STRING([--with-mpi-libs=ARG],[MPI libraries])],
-[
-MPI_LIBS="${withval}"
-],
-[
-MPI_LIBS=""
-])
-
-# MPI flags
-AC_ARG_WITH(mpi-flags,
-[AC_HELP_STRING([--with-mpi-flags=ARG],[MPI-specific flags])],
-[
-MPI_FLAGS="${withval}"
-MPI_FLAGS_OK="yes"
-],
-[
-MPI_FLAGS=""
-MPI_FLAGS_OK="no"
-])
-
-# MPI-C compiler
-MPICC_COMP_GIVEN="yes"
-AC_MSG_CHECKING([if using MPI-C script])
-AC_ARG_WITH(mpicc,
-[AC_HELP_STRING([--with-mpicc[[[[=ARG]]]]],[specify MPI-C compiler to use @<:@mpicc@:>@])],
-[
-if test "X${withval}" = "Xno"; then
-  USE_MPICC_SCRIPT="no"
-else
-  USE_MPICC_SCRIPT="yes"
-  MPICC_COMP="${withval}"
-fi
-],
-[
-  USE_MPICC_SCRIPT="yes"
-  MPICC_COMP="mpicc"
-  MPICC_COMP_GIVEN="no"
-])
-AC_MSG_RESULT([${USE_MPICC_SCRIPT}])
-
-# If CC is a C++ compiler, then we certainly do NOT want to use an MPI-C script
-# Note: USING_CPLUSPLUS_COMP was defined by a call to SUNDIALS_CPLUSPLUS_CHECK
-# in SUNDIALS_SET_CC
-# Note: If the user specified an MPI-C script, then we will NOT do anything for now
-if test "X${MPICC_COMP_GIVEN}" = "Xno" && test "X${USING_CPLUSPLUS_COMP}" = "Xyes"; then
-  MPICC_COMP="mpiCC"
-fi
-
-# Check MPI-C compiler (either MPI compiler script or regular C compiler)
-if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-  SUNDIALS_CHECK_MPICC
-else
-  MPICC_COMP="${CC}"
-  MPICC="${CC}"
-  SUNDIALS_CC_WITH_MPI_CHECK
-fi
-
-]) dnl END SUNDIALS_SET_MPICC
-
-#------------------------------------------------------------------
-# TEST MPI-C COMPILER
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_CHECK_MPICC],
-[
-
-# Test MPI-C compiler (meaning test MPICC_COMP)
-# Check if MPI-C compiler can be found
-
-AC_MSG_CHECKING([if absolute path to ${MPICC_COMP} was given])
-
-# CASE 1: MPICC_COMP was found (cannot check if executable because the
-# "-x" flag is NOT portable)
-if test -f ${MPICC_COMP} ; then
-
-  AC_MSG_RESULT([yes])
-  MPICC_COMP_EXISTS="yes"
-  # Determine MPI_INC_DIR and MPI_LIB_DIR for use by Makefile
-  MPI_BASE_DIR=`AS_DIRNAME(["${MPICC_COMP}"])`
-  TMP_MPI_INC_DIR="${MPI_BASE_DIR}/../include"
-  TMP_MPI_LIB_DIR="${MPI_BASE_DIR}/../lib"
-
-# CASE 2: MPICC_COMP could NOT be found and MPI_ROOT_DIR was NOT specified,
-# so search in PATH
-else
-
-  AC_MSG_RESULT([no])
-
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    # Try to find location of executable (perhaps directory was entered
-    # incorrectly)
-    TEMP_MPICC_COMP=`basename "${MPICC_COMP}"`
-    AC_PATH_PROG([MPICC_COMP],[${TEMP_MPICC_COMP}],[none])
-    # Cannot find executable in PATH
-    if test "X${MPICC_COMP}" = "Xnone"; then
-      MPICC_COMP_EXISTS="no"
-      MPICC_COMP=""
-    # Found executable and set MPICC_COMP to absolute pathname
-    else
-      MPICC_COMP_EXISTS="yes"
-      MPI_BASE_DIR=`AS_DIRNAME(["${MPICC_COMP}"])`
-      TMP_MPI_INC_DIR="${MPI_BASE_DIR}/../include"
-      TMP_MPI_LIB_DIR="${MPI_BASE_DIR}/../lib"
-    fi
-
-  # CASE 3: MPICC_COMP could NOT be found, but MPI_ROOT_DIR was specified
-  else
-
-    AC_MSG_CHECKING([if ${MPICC_COMP} exists in ${MPI_ROOT_DIR}/bin])
-    # MPICC_COMP should really only contain an executable name
-    # Found location of MPICC_COMP
-    if test -f ${MPI_ROOT_DIR}/bin/${MPICC_COMP} ; then
-      AC_MSG_RESULT([yes])
-      MPICC_COMP_EXISTS="yes"
-      MPICC_COMP="${MPI_ROOT_DIR}/bin/${MPICC_COMP}"
-      TMP_MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-      TMP_MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    # Could NOT find MPICC_COMP anywhere
-    else
-      AC_MSG_RESULT([no])
-      MPICC_COMP_EXISTS="no"
-      MPICC_COMP=""
-    fi
-
-  fi
-
-fi
-
-# If MPICC_COMP exists, set MPICC and (conditionally) set MPI_INC_DIR
-# and MPI_LIB_DIR so that we do not end up with empty -I options.
-# Otherwise, issue warning message
-if test "X${MPICC_COMP_EXISTS}" = "Xyes"; then
-
-  MPICC="${MPICC_COMP}"
-  MPI_C_COMP_OK="yes"
-
-  # If MPI_INC_DIR is empty, set it to TMP_MPI_INC_DIR
-  if test "X${MPI_INC_DIR}" = "X"; then
-    MPI_INC_DIR="$TMP_MPI_INC_DIR"
-  fi
-
-  # If MPI_LIB_DIR is empty, set it to TMP_MPI_LIB_DIR
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="$TMP_MPI_LIB_DIR"
-  fi
-
-else
-
-  AC_MSG_WARN([cannot find MPI-C compiler])
-  echo ""
-  echo "   Unable to find a functional MPI-C compiler."
-  echo ""
-  echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-  echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-  echo "   to specify the locations of all relevant MPI files, or"
-  echo "   --with-mpi-root to specify the base installation directory"
-  echo "   of the MPI implementation to be used."
-  echo ""
-  echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-  echo ""
-  MPICC=""
-  MPI_C_COMP_OK="no"
-  SUNDIALS_WARN_FLAG="yes"
-
-fi
-
-]) dnl END SUNDIALS_CHECK_MPICC
-
-#------------------------------------------------------------------
-# TEST C COMPILER WITH MPI
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_CC_WITH_MPI_CHECK],
-[
-
-# Test if we can compile MPI programs using the CC compiler
-# and current MPI settings
-
-AC_MSG_NOTICE([Testing CC with MPI settings])
-
-# Save copies of CPPFLAGS, LDFLAGS and LIBS (preserve information)
-# Temporarily overwritten so we can test MPI implementation
-SAVED_CPPFLAGS="${CPPFLAGS}"
-SAVED_LDFLAGS="${LDFLAGS}"
-SAVED_LIBS="${LIBS}"
-
-# Determine location of MPI header files (find MPI include directory)
-MPI_EXISTS="yes"
-
-AC_MSG_CHECKING([for location of MPI implementation])
-
-# If MPI include directory was NOT explicitly specified, check if MPI root
-# directory was given by user
-if test "X${MPI_INC_DIR}" = "X"; then
-  # If MPI root directory was NOT given so issue a warning message
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    AC_MSG_RESULT([not found])
-    MPI_EXISTS="no"
-    AC_MSG_WARN([cannot find MPI implementation files])
-    echo ""
-    echo "   Unable to find MPI implementation files."
-    echo ""
-    echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-    echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-    echo "   to specify the locations of all relevant MPI files, or"
-    echo "   --with-mpi-root to specify the base installation directory"
-    echo "   of the MPI implementation to be used."
-    echo ""
-    echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-    echo ""
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI root directory was given so set MPI_INC_DIR accordingly
-  # Update CPPFLAGS
-  else
-    MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-    AC_MSG_RESULT([${MPI_INC_DIR}])
-    if test "X${CPPFLAGS}" = "X"; then
-      CPPFLAGS="-I${MPI_INC_DIR}"
-    else
-      CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-    fi
-    # Add MPI_FLAGS if non-empty
-    if test "X${MPI_FLAGS}" = "X"; then
-      CPPFLAGS="${CPPFLAGS}"
-    else
-      CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-    fi
-  fi
-# MPI include directory was specified so update CPPFLAGS
-else
-  AC_MSG_RESULT([${MPI_INC_DIR}])
-  if test "X${CPPFLAGS}" = "X"; then
-    CPPFLAGS="-I${MPI_INC_DIR}"
-  else
-    CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-  fi
-  # Add MPI_FLAGS if non-empty
-  if test "X${MPI_FLAGS}" = "X"; then
-    CPPFLAGS="${CPPFLAGS}"
-  else
-    CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-  fi
-fi
-
-# Only continue if found an MPI implementation
-if test "X${MPI_EXISTS}" = "Xyes"; then
-
-  AC_MSG_CHECKING([for location of MPI libraries])
-
-  # Determine location of MPI libraries
-  # MPI library directory was NOT specified by user so set based upon MPI_ROOT_DIR
-  # Update LDFLAGS
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    AC_MSG_RESULT([${MPI_LIB_DIR}])
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  # MPI library directory was specified so update LDFLAGS
-  else
-    AC_MSG_RESULT([${MPI_LIB_DIR}])
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  fi
-
-  # Check if user specified which MPI libraries must be included
-  # If no libraries are given, then issue a warning message
-  AC_MSG_CHECKING([for MPI libraries])
-  if test "X${MPI_LIBS}" = "X"; then
-    AC_MSG_RESULT([none])
-    AC_MSG_WARN([no MPI libraries were given])
-    echo ""
-    echo "   Unable to compile MPI program using C compiler because"
-    echo "   MPI libraries were not specified."
-    echo ""
-    echo "   Try using --with-mpi-libdir and --with-mpi-libs to"
-    echo "   specify the location and names of the MPI libraries."
-    echo ""
-    echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-    echo ""
-    MPI_C_COMP_OK="no"
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI libraries were specified so update LIBS
-  else
-    AC_MSG_RESULT([${MPI_LIBS}])
-    if test "X${LIBS}" = "X"; then
-      LIBS="${MPI_LIBS}"
-    else
-      LIBS="${LIBS} ${MPI_LIBS}"
-    fi
-    # Set the MPI_C_COMP_OK variable to NULL so we can conditionally execute
-    # the next test
-    MPI_C_COMP_OK=""
-  fi
-
-  if test "X${MPI_C_COMP_OK}" = "X"; then
-    AC_MSG_CHECKING([if C compiler can compile MPI programs])
-    AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM([[#include "mpi.h"]],[[int c; char **v; MPI_Init(&c,&v);]])],
-    [AC_MSG_RESULT([yes])
-     MPI_C_COMP_OK="yes"],
-    [AC_MSG_RESULT([no])
-     AC_MSG_WARN([C compiler cannot compile MPI programs])
-     echo ""
-     echo "   Unable to compile MPI program using C compiler."
-     echo ""
-     echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-     echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-     echo "   to specify the locations of all relevant MPI files, or"
-     echo "   --with-mpi-root to specify the base installation directory"
-     echo "   of the MPI implementation to be used."
-     echo ""
-     echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-     echo ""
-     MPI_C_COMP_OK="no"
-     SUNDIALS_WARN_FLAG="yes"])
-  fi
-else
-  MPI_C_COMP_OK="no"
-fi
-  
-# Restore CPPFLAGS, LDFLAGS and LIBS
-CPPFLAGS="${SAVED_CPPFLAGS}"
-LDFLAGS="${SAVED_LDFLAGS}"
-LIBS="${SAVED_LIBS}"
-
-]) dnl END SUNDIALS_CC_WITH_MPI_CHECK
-
-#------------------------------------------------------------------
-# SET MPI-F77 COMPILER
-#
-# These tests are done only if all of the following are still true:
-#  - MPI is enabled
-#  - F77 examples are enabled
-#  - F77 works
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_SET_MPIF77],
-[
-
-AC_MSG_CHECKING([if using MPI-Fortran script])
-AC_ARG_WITH(mpif77,
-[AC_HELP_STRING([--with-mpif77[[[[=ARG]]]]],[specify MPI-Fortran compiler to use @<:@mpif77@:>@])],
-[
-if test "X${withval}" = "Xno"; then
-  USE_MPIF77_SCRIPT="no"
-else
-  USE_MPIF77_SCRIPT="yes"
-  MPIF77_COMP="${withval}"
-fi
-],
-[
-USE_MPIF77_SCRIPT="yes"
-MPIF77_COMP="mpif77"
-])
-AC_MSG_RESULT([${USE_MPIF77_SCRIPT}])
-
-# Check MPI-Fortran compiler (either MPI compiler script or regular Fortran compiler)
-if test "X${USE_MPIF77_SCRIPT}" = "Xyes"; then
-  SUNDIALS_CHECK_MPIF77
-else
-  MPIF77_COMP="${F77}"
-  MPIF77="${F77}"
-  SUNDIALS_F77_WITH_MPI_CHECK
-fi
-
-]) dnl END SUNDIALS_SET_MPIF77
-
-#------------------------------------------------------------------
-# TEST MPIF77 COMPILER SCRIPT
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_CHECK_MPIF77],
-[
-
-# Test the MPI-Fortran compiler (meaning test MPIF77_COMP)
-# Check if MPI-Fortran compiler can be found
-
-AC_MSG_CHECKING([if absolute path to ${MPIF77_COMP} was given])
-
-# CASE 1: MPIF77_COMP was found (cannot check if executable because the
-# "-x" flag is NOT portable)
-if test -f ${MPIF77_COMP} ; then
-
-  AC_MSG_RESULT([yes])
-  MPIF77_COMP_EXISTS="yes"
-  # Determine MPI_INC_DIR and MPI_LIB_DIR for use by Makefile
-  MPI_BASE_DIR=`AS_DIRNAME(["${MPIF77_COMP}"])`
-
-# CASE 2: MPIF77_COMP could NOT be found and MPI_ROOT_DIR was NOT specified,
-# so search in PATH
-else
-
-  AC_MSG_RESULT([no])
-
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-
-    # Try to find location of executable (perhaps directory was entered incorrectly)
-    TEMP_MPIF77_COMP=`basename "${MPIF77_COMP}"`
-    AC_PATH_PROG([MPIF77_COMP],[${TEMP_MPIF77_COMP}],[none])
-    # Cannot find executable in PATH
-    if test "X${MPIF77_COMP}" = "Xnone"; then
-      MPIF77_COMP_EXISTS="no"
-      MPIF77_COMP=""
-    # Found executable and set MPIF77_COMP to absolute pathname
-    else
-      MPIF77_COMP_EXISTS="yes"
-      MPI_BASE_DIR=`AS_DIRNAME(["${MPIF77_COMP}"])`
-    fi
-
-  # CASE 3: MPIF77_COMP could NOT be found, but MPI_ROOT_DIR was specified
-  else
-
-    AC_MSG_CHECKING([if ${MPIF77_COMP} exists in ${MPI_ROOT_DIR}/bin])
-    # MPIF77_COMP should really only contain an executable name
-    # Found location of MPIF77_COMP
-    if test -f ${MPI_ROOT_DIR}/bin/${MPIF77_COMP} ; then
-      AC_MSG_RESULT([yes])
-      MPIF77_COMP_EXISTS="yes"
-      MPIF77_COMP="${MPI_ROOT_DIR}/bin/${MPIF77_COMP}"
-    # Could NOT find MPIF77_COMP anywhere
-    else
-      AC_MSG_RESULT([no])
-      MPIF77_COMP_EXISTS="no"
-      MPIF77_COMP=""
-    fi
-
-  fi
-
-fi
-
-# Issue warning message if MPIF77_COMP does NOT exist, else set MPIF77
-if test "X${MPIF77_COMP_EXISTS}" = "Xyes"; then
-
-  MPIF77="${MPIF77_COMP}"
-  MPI_F77_COMP_OK="yes"
-
-  # Note that we do not have to worry about empty MPI_INC_DIR and MPI_LIB_DIR
-  # here as they were set in SUNDIALS_CHECK_MPICC
-
-  # Check if we must use the MPI-Fortran compiler script (MPIF77) to link
-  # the Fortran examples (default is to use MPICC)
-  SUNDIALS_MPIF77_LNKR_CHECK
-
-else
-
-  AC_MSG_WARN([cannot find MPI-Fortran compiler])
-  echo ""
-  echo "   Unable to find a functional MPI-Fortran compiler."
-  echo ""
-  echo "   Try using --with-mpif77 to specify a MPI-Fortran compiler script,"
-  echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-  echo "   to specify the locations of all relevant MPI files, or"
-  echo "   --with-mpi-root to specify the base installation directory"
-  echo "   of the MPI implementation to be used."
-  echo ""
-  echo "   Disabling parallel Fortran examples...."
-  echo ""
-  MPIF77=""
-  MPI_F77_COMP_OK="no"
-  SUNDIALS_WARN_FLAG="yes"
-
-fi
-
-]) dnl END SUNDIALS_CHECK_MPIF77
-
-#------------------------------------------------------------------
-# DETERMINE MPI-FORTRAN LINKER IF USING MPIF77 SCRIPT
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_MPIF77_LNKR_CHECK],
-[
-
-# If we are NOT using an MPI script, then MPICC_COMP == CC and we do NOT need
-# to check again if CC is a C++ compiler as we already know the answer
-if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-
-  # Check if using a C++ compiler (meaning MPI-C++ script)
-  # Save result from CC check
-  SAVED_USING_CPLUSPLUS_COMP="${USING_CPLUSPLUS_COMP}"
-  SUNDIALS_CPLUSPLUS_CHECK([${MPICC_COMP}])
-  # MPICC uses a C++ compiler so run the next test
-  if test "X${USING_CPLUSPLUS_COMP}" = "Xyes" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xyes"; then
-    RUN_MPIF77_LNKR_CHECK="yes"
-  # ERROR
-  elif test "X${USING_CPLUSPLUS_COMP}" = "Xyes" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xno"; then
-    AC_MSG_ERROR([${MPICC_COMP} is a C++ compiler but ${CC} is a C compiler])
-  # MPICC uses a C compiler so skip the next test
-  elif test "X${USING_CPLUSPLUS_COMP}" = "Xno" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xno" ; then
-    RUN_MPIF77_LNKR_CHECK="no"
-  # ERROR
-  elif test "X${USING_CPLUSPLUS_COMP}" = "Xno" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xyes" ; then
-    AC_MSG_ERROR([${MPICC_COMP} is a C compiler but ${CC} is a C++ compiler])
-  fi
-  # Restore result from CC check
-  USING_CPLUSPLUS_COMP="${SAVED_USING_CPLUSPLUS_COMP}"
-
-else
-
-  AC_MSG_CHECKING([if ${MPICC_COMP} is a C++ compiler])
-  if test "X${USING_CPLUSPLUS_COMP}" = "Xyes"; then
-    AC_MSG_RESULT([yes])
-  else
-    AC_MSG_RESULT([no])
-  fi
-
-fi
-
-AC_MSG_CHECKING([which linker to use])
-# Perform the next test only if using a C++ compiler to build NVECTOR_PARALLEL
-if test "X${RUN_MPIF77_LNKR_CHECK}" = "Xyes"; then
-
-  MPIF77_LNKR_CHECK_OK="no"
-
-  # Switch language to "Fortran 77"
-  AC_LANG_PUSH([Fortran 77])
-
-  # Temporarily reset F77 environment variable to perform test
-  SAVED_F77="${F77}"
-  F77="${MPIF77_COMP}"
-
-  # Compile simple Fortran example, but do NOT link
-  # Note: result stored as conftest.${ac_objext}
-  AC_COMPILE_IFELSE(
-  [AC_LANG_SOURCE(
-  [[
-	PROGRAM SUNDIALS
-	INTEGER IER
-	CALL MPI_INIT(IER)
-	END
-  ]])],
-  [
-
-  # Reset F77 to original value
-  F77="${SAVED_F77}"
-
-  # Revert to previous language
-  AC_LANG_POP([Fortran 77])
-
-  # Temporarily reset LIBS environment variable to perform test
-  SAVED_LIBS="${LIBS}"
-  LIBS="${LIBS} ${FLIBS}"
-
-  # Switch working language to C for next test
-  AC_LANG_PUSH([C])
-
-  # Temporarily reset CC environment variable to perform next test
-  SAVED_CC="${CC}"
-  CC="${MPICC_COMP}"
-
-  # Check if MPICC_COMP can link Fortran example
-  # Note: AC_LINKONLY_IFELSE is a custom macro (modifications made to
-  # general.m4 and c.m4)
-  AC_LINKONLY_IFELSE([],[MPIF77_LNKR_CHECK_OK="yes"],[MPIF77_LNKR_CHECK_OK="no"])
-
-  # Reset CC to original value
-  CC="${SAVED_CC}"
-
-  # Revert back to previous language (Fortran 77)
-  AC_LANG_POP([C])
-
-  # Set LIBS environment variable back to original value
-  LIBS="${SAVED_LIBS}"
-
-  ])
-
-  # If either the compilation or the linking failed, we should
-  # disable building the parallel Fortran examples
-  # For now, use MPIF77 as the linker...
-
-  if test "X${MPIF77_LNKR_CHECK_OK}" = "Xyes"; then
-    MPIF77_LNKR="${MPICC}"
-  else
-    MPIF77_LNKR="${MPIF77}"
-  fi
-
-else
-
-  # Using a C compiler so use MPIF77 to link parallel Fortran examples
-  MPIF77_LNKR="${MPIF77}"
-
-fi
-AC_MSG_RESULT([${MPIF77_LNKR}])
-
-
-]) dnl SUNDIALS_MPIF77_LNKR_CHECK
-
-#------------------------------------------------------------------
-# TEST FORTRAN COMPILER WITH MPI
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_F77_WITH_MPI_CHECK],
-[
-
-# Test if we can compile MPI programs using the F77 compiler
-# and current MPI settings
-
-AC_MSG_NOTICE([Testing F77 with MPI settings])
-
-AC_LANG_PUSH([Fortran 77])
-
-# Save copies of FFLAGS, LDFLAGS and LIBS (preserve information)
-# Temporarily overwritten so we can test MPI implementation
-SAVED_FFLAGS="${FFLAGS}"
-SAVED_LDFLAGS="${LDFLAGS}"
-SAVED_LIBS="${LIBS}"
-
-# This may seem redundant, but we are not guaranteed that
-# SUNDIALS_CC_WITH_MPI_CHECK has been executed
-# Determine location of MPI header files (find MPI include directory)
-MPI_EXISTS="yes"
-
-AC_MSG_CHECKING([for location of MPI implementation])
-
-# If MPI include directory was NOT explicitly specified so check if MPI root
-# directory was given by user
-if test "X${MPI_INC_DIR}" = "X"; then
-  # If MPI root directory was NOT given so issue a warning message
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    AC_MSG_RESULT([not found])
-    MPI_EXISTS="no"
-    AC_MSG_WARN([cannot find MPI implementation files])
-    echo ""
-    echo "   Unable to find MPI implementation files."
-    echo ""
-    echo "   Try using --with-mpif77 to specify a MPI-Fortran compiler script,"
-    echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-    echo "   to specify the locations of all relevant MPI files, or"
-    echo "   --with-mpi-root to specify the base installation directory"
-    echo "   of the MPI implementation to be used."
-    echo ""
-    echo "   Disabling all parallel Fortran examples..."
-    echo ""
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI root directory was given so set MPI_INC_DIR accordingly
-  # Update FFLAGS
-  else
-    MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-    AC_MSG_RESULT([${MPI_INC_DIR}])
-    if test "X${FFLAGS}" = "X"; then
-      FFLAGS="-I${MPI_INC_DIR}"
-    else
-      FFLAGS="${FFLAGS} -I${MPI_INC_DIR}"
-    fi
-  fi
-# MPI include directory was specified so update FFLAGS
-else
-  AC_MSG_RESULT([${MPI_INC_DIR}])
-  if test "X${FFLAGS}" = "X"; then
-    FFLAGS="-I${MPI_INC_DIR}"
-  else
-    FFLAGS="${FFLAGS} -I${MPI_INC_DIR}"
-  fi
-fi
-
-# Only continue if found an MPI implementation
-if test "X${MPI_EXISTS}" = "Xyes"; then
-
-  AC_MSG_CHECKING([for location of MPI libraries])
-
-  # Determine location of MPI libraries
-  # MPI library directory was NOT specified by user so set based upon MPI_ROOT_DIR
-  # Update LDFLAGS
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    AC_MSG_RESULT([${MPI_LIB_DIR}])
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  # MPI library directory was specified so update LDFLAGS
-  else
-    AC_MSG_RESULT([${MPI_LIB_DIR}])
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  fi
-
-  # Check if user specified which MPI libraries must be included
-  # If no libraries are given, then issue a warning message
-  AC_MSG_CHECKING([for MPI libraries])
-  if test "X${MPI_LIBS}" = "X"; then
-    AC_MSG_RESULT([none])
-    echo ""
-    echo "   Unable to compile MPI program using Fortran compiler because"
-    echo "   MPI libraries were not specified."
-    echo ""
-    echo "   Try using --with-mpi-libdir and --with-mpi-libs to"
-    echo "   specify the location and names of the MPI libraries."
-    echo ""
-    echo "   Disabling all parallel Fortran examples..."
-    echo ""
-    MPI_F77_COMP_OK="no"
-  # MPI libraries were specified so update LIBS
-  else
-    AC_MSG_RESULT([${MPI_LIBS}])
-    if test "X${LIBS}" = "X"; then
-      LIBS="${MPI_LIBS}"
-    else
-      LIBS="${LIBS} ${MPI_LIBS}"
-    fi
-    # Set the MPI_F77_COMP_OK variable to NULL so we can conditionally execute
-    # the next test
-    MPI_F77_COMP_OK=""
-  fi
-
-  if test "X${MPI_F77_COMP_OK}" = "X"; then
-    AC_MSG_CHECKING([if Fortran compiler can compile MPI programs])
-    AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM([],
-    [      
-        INCLUDE "mpif.h"
-        CALL MPI_INIT(IER)
-    ])],
-    [AC_MSG_RESULT([yes])
-     MPI_F77_COMP_OK="yes"],
-    [AC_MSG_RESULT([no])
-     AC_MSG_WARN([Fortran compiler cannot compile MPI programs])
-     echo ""
-     echo "   Unable to compile MPI program using Fortran compiler."
-     echo ""
-     echo "   Try using --with-mpif77 to specify a MPI-Fortran compiler script,"
-     echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-     echo "   to specify the locations of all relevant MPI files, or"
-     echo "   --with-mpi-root to specify the base installation directory"
-     echo "   of the MPI implementation to be used."
-     echo ""
-     echo "   Disabling all parallel Fortran examples..."
-     echo ""
-     MPI_F77_COMP_OK="no"
-     SUNDIALS_WARN_FLAG="yes"])
-
-    # Set MPIF77_LNKR based on value of F77_LNKR
-    # Note: setting MPIF77_LNKR is trivial if NOT using the MPI compiler script
-    # since the SUNDIALS_F77_LNKR_CHECK macro already checked if CC or F77
-    # should be used
-    AC_MSG_CHECKING([which linker to use])
-    if test "X${F77_LNKR}" = "X${CC}"; then
-      MPIF77_LNKR="${MPICC}"
-    elif test "X${F77_LNKR}" = "X${F77}"; then
-      MPIF77_LNKR="${MPIF77}"
-    fi
-    AC_MSG_RESULT([${MPIF77_LNKR}])
-  fi
-
-else
-  MPI_F77_COMP_OK="no"
-fi
-
-# Restore FFLAGS, LDFLAGS and LIBS
-FFLAGS="${SAVED_FFLAGS}"
-LDFLAGS="${SAVED_LDFLAGS}"
-LIBS="${SAVED_LIBS}"
-
-AC_LANG_POP([Fortran 77])
-
-]) dnl END SUNDIALS_F77_WITH_MPI_CHECK
-
-#------------------------------------------------------------------
-# TEST MPI-2 FUNCTIONALITY
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_CHECK_MPI2],
-[
-
-# Determine if MPI implementation used to build SUNDIALS provides
-# MPI-2 functionality.
-#
-# Test for MPI_Comm_f2c() function:
-#   (1) NO  : FNVECTOR_PARALLEL module will NOT allow user to specify
-#             an MPI communicator and MPI_COMM_WORLD will be used
-#   (2) YES : FNVECTOR_PARALLEL module will allow user to specify
-#             an MPI communicator
-#
- 
-# Provide variable description templates for config.hin and config.h files
-# Required by autoheader utility
-AH_TEMPLATE([SUNDIALS_MPI_COMM_F2C],
-            [FNVECTOR: Allow user to specify different MPI communicator])
-
-# Save copies of CPPFLAGS, LDFLAGS and LIBS (preserve information)
-# Temporarily overwritten so we can test MPI implementation
-SAVED_CPPFLAGS="${CPPFLAGS}"
-SAVED_LDFLAGS="${LDFLAGS}"
-SAVED_LIBS="${LIBS}"
-
-# Determine location of MPI header files (find MPI include directory)
-MPI_EXISTS="yes"
-
-# MPI include directory was NOT explicitly specified so check if MPI root
-# directory was given by user
-if test "X${MPI_INC_DIR}" = "X"; then
-  # MPI root directory was NOT given so issue a warning message
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    MPI_EXISTS="no"
-    AC_MSG_WARN([cannot find MPI implementation files])
-    echo ""
-    echo "   Unable to find MPI implementation files."
-    echo ""
-    echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-    echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-    echo "   to specify the locations of all relevant MPI files, or"
-    echo "   --with-mpi-root to specify the base installation directory"
-    echo "   of the MPI implementation to be used."
-    echo ""
-    echo "   Disabling FNVECTOR_PARALLEL support for user-specified"
-    echo "   MPI communicator..."
-    echo ""
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI root directory was given so set MPI_INC_DIR accordingly
-  # Update CPPFLAGS
-  else
-    MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-    if test "X${CPPFLAGS}" = "X"; then
-      CPPFLAGS="-I${MPI_INC_DIR}"
-    else
-      CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-    fi
-    # Add MPI_FLAGS if non-empty
-    if test "X${MPI_FLAGS}" = "X"; then
-      CPPFLAGS="${CPPFLAGS}"
-    else
-      CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-    fi
-  fi
-# MPI include directory was specified so update CPPFLAGS
-else
-  if test "X${CPPFLAGS}" = "X"; then
-    CPPFLAGS="-I${MPI_INC_DIR}"
-  else
-    CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-  fi
-  # Add MPI_FLAGS if non-empty
-  if test "X${MPI_FLAGS}" = "X"; then
-    CPPFLAGS="${CPPFLAGS}"
-  else
-    CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-  fi
-fi
-
-# Only continue if found an MPI implementation
-if test "X${MPI_EXISTS}" = "Xyes"; then
-
-  # Determine location of MPI libraries
-  # MPI library directory was NOT specified by user so set based upon MPI_ROOT_DIR
-  # Update LDFLAGS
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  # MPI library directory was specified so update LDFLAGS
-  else
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  fi
-
-  # Check if user specified which MPI libraries linker should be use
-  if test "X${MPI_LIBS}" = "X"; then
-    :
-  # MPI libraries were specified so update LIBS
-  else
-    if test "X${LIBS}" = "X"; then
-      LIBS="${MPI_LIBS}"
-    else
-      LIBS="${LIBS} ${MPI_LIBS}"
-    fi
-  fi
-
-  # Since AC_LINK_IFELSE uses CC, set CC = MPICC if using
-  # an MPI compiler script
-  if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-    SAVED_CC="${CC}"
-    CC="${MPICC_COMP}"
-  fi
-
-  # Check if MPI implementation supports MPI_Comm_f2c() from
-  # MPI-2 specification
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    AC_MSG_CHECKING([for MPI_Comm_f2c() from MPI-2 specification])
-    AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM([[#include "mpi.h"]],
-    [[
-        int c;
-        char **v;
-        MPI_Comm C_comm;
-        MPI_Init(&c, &v);
-        C_comm = MPI_Comm_f2c((MPI_Fint) 1);
-        MPI_Finalize();
-    ]])],
-    [AC_MSG_RESULT([yes])
-     AC_DEFINE([SUNDIALS_MPI_COMM_F2C],[1],[])
-     F77_MPI_COMM_F2C="#define SUNDIALS_MPI_COMM_F2C 1"],
-    [AC_MSG_RESULT([no])
-     AC_DEFINE([SUNDIALS_MPI_COMM_F2C],[0],[])
-     F77_MPI_COMM_F2C="#define SUNDIALS_MPI_COMM_F2C 0"])
-  fi
-
-  # Reset CC if necessary
-  if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-    CC="${SAVED_CC}"
-  fi
-
-else
-  AC_DEFINE([SUNDIALS_MPI_COMM_F2C],[0],[])
-  F77_MPI_COMM_F2C="#define SUNDIALS_MPI_COMM_F2C 0"
-fi
-
-# Restore CPPFLAGS, LDFLAGS and LIBS
-CPPFLAGS="${SAVED_CPPFLAGS}"
-LDFLAGS="${SAVED_LDFLAGS}"
-LIBS="${SAVED_LIBS}"
-
-]) dnl END SUNDIALS_CHECK_MPI2
-
-
-
-
-#=================================================================#
-#                                                                 #
-#                                                                 #
-#                   F I N A L I Z A T I O N S                     #
-#                                                                 #
-#                                                                 #
-#==================================================================
-
-
-#------------------------------------------------------------------
-# ADD SOME MORE STUFF TO configure --help
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_MORE_HELP],
-[
-
-AC_ARG_WITH([],[          ],[])
-AC_ARG_WITH([],[NOTES],[])
-AC_ARG_WITH([],[  It is legal to set --with-exinstdir to "no", in which case the examples],[])
-AC_ARG_WITH([],[  are built but not installed.],[])
-AC_ARG_WITH([],[  Enabling the compilation of the examples (--enable-examples) but disabling their],[])
-AC_ARG_WITH([],[  installation (--with-exinstdir=no) can be used to test the SUNDIALS libraries.],[])
-
-]) dnl END SUNDIALS_MORE_HELP
-
-#------------------------------------------------------------------
-# SET EXAMPLES
-#
-# Decide which examples can be built
-#
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_SET_EXAMPLES],
-[
-
-# Set proper object file extension
-# Must export OBJ_EXT via AC_SUBST
-OBJEXT=".lo"
-
-# Check if serial C examples can actually be built
-SERIAL_C_EXAMPLES="yes"
-
-# Check if parallel C examples can actually be built
-if test "X${MPI_ENABLED}" = "Xyes"; then
-  if test "X${MPI_C_COMP_OK}" = "Xyes"; then
-    PARALLEL_C_EXAMPLES="yes"
-  else
-    PARALLEL_C_EXAMPLES="no"
-  fi
-else
-  PARALLEL_C_EXAMPLES="disabled"
-fi
-
-# Check if serial F77 examples can actually be built
-if test "X${FCMIX_ENABLED}" = "Xyes"; then
-  if test "X${F77_OK}" = "Xyes"; then
-    SERIAL_F77_EXAMPLES="yes"
-  else
-    SERIAL_F77_EXAMPLES="no"
-  fi
-else
-  SERIAL_F77_EXAMPLES="disabled"
-fi
-
-# Check if parallel F77 examples can actually be built
-if test "X${FCMIX_ENABLED}" = "Xyes" &&  test "X${MPI_ENABLED}" = "Xyes"; then
-  if test "X${MPI_F77_COMP_OK}" = "Xyes"; then
-    PARALLEL_F77_EXAMPLES="yes"
-  else
-    PARALLEL_F77_EXAMPLES="no"
-  fi
-else
-  PARALLEL_F77_EXAMPLES="disabled"
-fi
-
-# Notify user
-AC_MSG_CHECKING([if we can build serial C examples])
-AC_MSG_RESULT([${SERIAL_C_EXAMPLES}])
-AC_MSG_CHECKING([if we can build parallel C examples])
-AC_MSG_RESULT([${PARALLEL_C_EXAMPLES}])
-AC_MSG_CHECKING([if we can build serial Fortran examples])
-AC_MSG_RESULT([${SERIAL_F77_EXAMPLES}])
-AC_MSG_CHECKING([if we can build parallel Fortran examples])
-AC_MSG_RESULT([${PARALLEL_F77_EXAMPLES}])
-
-# Check if the Fortran update script (bin/fortran-update.in) is needed
-if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" || test "X${PARALLEL_F77_EXAMPLES}" = "Xyes"; then
-  BUILD_F77_UPDATE_SCRIPT="yes";
-else
-  BUILD_F77_UPDATE_SCRIPT="no"
-fi
-
-# Where should we install the examples?
-# Note: setting this to "no" will disable example installation!
-AC_MSG_CHECKING([where to install the SUNDIALS examples])
-AC_ARG_WITH([],[   ],[])
-AC_ARG_WITH([exinstdir],
-[AC_HELP_STRING([--with-exinstdir=DIR], [install SUNDIALS examples in DIR @<:@EPREFIX/examples@:>@])],
-[
-  EXS_INSTDIR="${withval}"
-],
-[
-  if test "X${exec_prefix}" = "XNONE"; then
-    if test "X${prefix}" = "XNONE"; then
-      EXS_INSTDIR="\${exec_prefix}/examples"
-    else
-      EXS_INSTDIR="${prefix}/examples"
-    fi
-  else
-    EXS_INSTDIR="${exec_prefix}/examples"
-  fi
-])
-AC_MSG_RESULT([${EXS_INSTDIR}])
-
-# Prepare substitution variables to create the exported example Makefiles
-
-F77_LIBS="${FLIBS} ${LIBS}"
-if test "X${F77_LNKR}" = "X${F77}"; then
-  F77_LDFLAGS="${FFLAGS} ${LDFLAGS}"
-else
-  F77_LDFLAGS="${CFLAGS} ${LDFLAGS}"
-fi
-
-]) dnl END SUNDIALS_SET_EXAMPLES
-
-#------------------------------------------------------------------
-# BUILD MODULES LIST
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_BUILD_MODULES_LIST],
-[
-
-# Initialize the list of Makefiles to be created
-SUNDIALS_MAKEFILES="Makefile"
-
-# Initialize list of additional configure files to be created
-SUNDIALS_CONFIGFILES="include/sundials/sundials_config.h:include/sundials/sundials_config.in"
-SUNDIALS_CONFIGFILES="${SUNDIALS_CONFIGFILES} bin/sundials-config:bin/sundials-config.in"
-
-# Initialize lists of solver modules and example modules
-SLV_MODULES="src/sundials"
-SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/sundials/Makefile"
-
-EXS_MODULES=""
-
-# NVECTOR modules
-if test -d ${srcdir}/src/nvec_ser ; then
-  SLV_MODULES="${SLV_MODULES} src/nvec_ser"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/nvec_ser/Makefile"
-fi
-
-if test -d ${srcdir}/src/nvec_par && test "X${MPI_C_COMP_OK}" = "Xyes"; then
-  SLV_MODULES="${SLV_MODULES} src/nvec_par"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/nvec_par/Makefile"
-fi
-
-if test -d ${srcdir}/src/nvec_spcpar && test "X${MPI_C_COMP_OK}" = "Xyes"; then
-  SLV_MODULES="${SLV_MODULES} src/nvec_spcpar"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/nvec_spcpar/Makefile"
-fi
-
-# CVODE module
-if test "X${CVODE_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/cvode"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cvode/Makefile"
-
-  if test "X${FCMIX_ENABLED}" = "Xyes" && test -d ${srcdir}/src/cvode/fcmix ; then
-    SLV_MODULES="${SLV_MODULES} src/cvode/fcmix"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cvode/fcmix/Makefile"
-  fi
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/fcmix_serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_serial/Makefile_ex:examples/templates/makefile_serial_F77_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/fcmix_parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_parallel/Makefile_ex:examples/templates/makefile_parallel_F77_ex.in"
-  fi
-
-fi
-
-# CVODES module
-if test "X${CVODES_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/cvodes"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cvodes/Makefile"
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvodes/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvodes/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-fi
-
-# IDA module
-if test "X${IDA_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/ida"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/ida/Makefile"
-
-  if test "X${FCMIX_ENABLED}" = "Xyes" && test -d ${srcdir}/src/ida/fcmix ; then
-    SLV_MODULES="${SLV_MODULES} src/ida/fcmix"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/ida/fcmix/Makefile"
-  fi
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/fcmix_serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_serial/Makefile_ex:examples/templates/makefile_serial_F77_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/fcmix_parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_parallel/Makefile_ex:examples/templates/makefile_parallel_F77_ex.in"
-  fi
-
-fi
-
-# IDAS module
-if test "X${IDAS_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/idas"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/idas/Makefile"
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/idas/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/idas/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-fi
-
-# KINSOL module
-if test "X${KINSOL_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/kinsol"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/kinsol/Makefile"
-
-  if test "X${FCMIX_ENABLED}" = "Xyes" && test -d ${srcdir}/src/kinsol/fcmix ; then
-    SLV_MODULES="${SLV_MODULES} src/kinsol/fcmix"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/kinsol/fcmix/Makefile"
-  fi
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/fcmix_serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_serial/Makefile_ex:examples/templates/makefile_serial_F77_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/fcmix_parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_parallel/Makefile_ex:examples/templates/makefile_parallel_F77_ex.in"
-  fi
-
-fi
-
-# CPODES module
-if test "X${CPODES_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/cpodes"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cpodes/Makefile"
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cpodes/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cpodes/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-fi
-
-# Add Fortran update script to the list of additional files to be generated
-if test "X${BUILD_F77_UPDATE_SCRIPT}" = "Xyes"; then
-  SUNDIALS_CONFIGFILES="${SUNDIALS_CONFIGFILES} bin/fortran-update.sh:bin/fortran-update.in"
-fi
-
-# If needed, add Makefile update script to the list of additional files to be generated
-if test "X${EXAMPLES_ENABLED}" = "Xyes" && test "X${EXS_INSTDIR}" != "Xno"; then
-  SUNDIALS_CONFIGFILES="${SUNDIALS_CONFIGFILES} bin/makefile-update.sh:bin/makefile-update.in"
-fi
-
-]) dnl END SUNDIALS_BUILD_MODULES_LIST
-
-#------------------------------------------------------------------
-# POST PROCESSING OF EXAMPLE Makefiles for export
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_POST_PROCESSING],
-[
-
-# If installing examples, the Makefiles that will be exported must
-# be post-processed to complete the substitution of all variables. 
-# After config.status runs, each example subdirectory contains an 
-# export makefile, named Makefile_ex, which was created from the 
-# common template in examples/templates.
-#
-# The following variables are still to be substituted at this point:
-#   SOLVER
-#   EXAMPLES
-#   EXAMPLES_BL
-#   SOLVER_LIB SOLVER_FLIB
-#   NVEC_LIB NVEC_FLIB
-# 
-# This function is called ONLY if examples are enabled AND examples will 
-# be installed. If so, it sets up commands to be called after config.status
-# has generated a first version of the Makefiles for export:
-# 
-# (1) For each solver, proceed ONLY if the solver is enabled.
-# (2) For each type of examples, proceed ONLY if they can be compiled AND
-#     the example directory exists.
-
-# CVODE module
-if test "X${CVODE_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([cvode_ser_ex_bl],
-       [   
-       IN_FILE="examples/cvode/serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB=""
-       EXAMPLES="cvAdvDiff_bnd cvDirectDemo_ls cvDiurnal_kry_bp cvDiurnal_kry cvKrylovDemo_ls cvKrylovDemo_prec cvRoberts_dns cvRoberts_dns_uw"
-       EXAMPLES_BL="cvAdvDiff_bndL cvRoberts_dnsL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([cvode_ser_ex],
-       [   
-       IN_FILE="examples/cvode/serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB=""
-       EXAMPLES="cvAdvDiff_bnd cvDirectDemo_ls cvDiurnal_kry_bp cvDiurnal_kry cvKrylovDemo_ls cvKrylovDemo_prec cvRoberts_dns cvRoberts_dns_uw"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([cvode_fser_ex_bl],
-       [
-       IN_FILE="examples/cvode/fcmix_serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB="sundials_fcvode"
-       EXAMPLES="fcvAdvDiff_bnd fcvDiurnal_kry_bp fcvDiurnal_kry fcvRoberts_dns"
-       EXAMPLES_BL="fcvRoberts_dnsL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([cvode_fser_ex],
-       [
-       IN_FILE="examples/cvode/fcmix_serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB="sundials_fcvode"
-       EXAMPLES="fcvAdvDiff_bnd fcvDiurnal_kry_bp fcvDiurnal_kry fcvRoberts_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/parallel ; then
-     AC_CONFIG_COMMANDS([cvode_par_ex],
-     [
-     IN_FILE="examples/cvode/parallel/Makefile_ex"
-     SOLVER="CVODE"
-     SOLVER_LIB="sundials_cvode"
-     SOLVER_FLIB=""
-     EXAMPLES="cvAdvDiff_non_p cvDiurnal_kry_bbd_p cvDiurnal_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_parallel ; then
-     AC_CONFIG_COMMANDS([cvode_fpar_ex],
-     [
-     IN_FILE="examples/cvode/fcmix_parallel/Makefile_ex"
-     SOLVER="CVODE"
-     SOLVER_LIB="sundials_cvode"
-     SOLVER_FLIB="sundials_fcvode"
-     EXAMPLES="fcvDiag_non_p fcvDiag_kry_bbd_p fcvDiag_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-fi
-
-
-# CVODES module
-if test "X${CVODES_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([cvodes_ser_ex_bl],
-       [
-       IN_FILE="examples/cvodes/serial/Makefile_ex"
-       SOLVER="CVODES"
-       SOLVER_LIB="sundials_cvodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cvsAdvDiff_ASAi_bnd cvsAdvDiff_FSA_non cvsDiurnal_kry_bp cvsFoodWeb_ASAp_kry cvsKrylovDemo_prec cvsAdvDiff_bnd cvsDirectDemo_ls cvsDiurnal_kry cvsHessian_ASA_FSA cvsRoberts_ASAi_dns cvsRoberts_dns_uw  cvsDiurnal_FSA_kry cvsFoodWeb_ASAi_kry cvsKrylovDemo_ls cvsRoberts_dns cvsRoberts_FSA_dns"
-       EXAMPLES_BL="cvsRoberts_dnsL cvsAdvDiff_bndL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([cvodes_ser_ex],
-       [
-       IN_FILE="examples/cvodes/serial/Makefile_ex"
-       SOLVER="CVODES"
-       SOLVER_LIB="sundials_cvodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cvsAdvDiff_ASAi_bnd cvsAdvDiff_FSA_non cvsDiurnal_kry_bp cvsFoodWeb_ASAp_kry cvsKrylovDemo_prec cvsAdvDiff_bnd cvsDirectDemo_ls cvsDiurnal_kry cvsHessian_ASA_FSA cvsRoberts_ASAi_dns cvsRoberts_dns_uw  cvsDiurnal_FSA_kry cvsFoodWeb_ASAi_kry cvsKrylovDemo_ls cvsRoberts_dns cvsRoberts_FSA_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/parallel ; then
-     AC_CONFIG_COMMANDS([cvodes_par_ex],
-     [
-     IN_FILE="examples/cvodes/parallel/Makefile_ex"
-     SOLVER="CVODES"
-     SOLVER_LIB="sundials_cvodes"
-     SOLVER_FLIB=""
-     EXAMPLES="cvsAdvDiff_ASAp_non_p cvsAdvDiff_non_p cvsDiurnal_FSA_kry_p cvsDiurnal_kry_p cvsAdvDiff_FSA_non_p cvsAtmDisp_ASAi_kry_bbd_p cvsDiurnal_kry_bbd_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-fi
-
-
-# IDA module
-if test "X${IDA_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([ida_ser_ex_bl],
-       [
-       IN_FILE="examples/ida/serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB=""
-       EXAMPLES="idaFoodWeb_bnd idaHeat2D_bnd idaHeat2D_kry idaKrylovDemo_ls idaRoberts_dns idaSlCrank_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([ida_ser_ex],
-       [
-       IN_FILE="examples/ida/serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB=""
-       EXAMPLES="idaFoodWeb_bnd idaHeat2D_bnd idaHeat2D_kry idaKrylovDemo_ls idaRoberts_dns idaSlCrank_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([ida_fser_ex_bl],
-       [
-       IN_FILE="examples/ida/fcmix_serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB="sundials_fida"
-       EXAMPLES="fidaRoberts_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([ida_fser_ex],
-       [
-       IN_FILE="examples/ida/fcmix_serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB="sundials_fida"
-       EXAMPLES="fidaRoberts_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/parallel ; then
-     AC_CONFIG_COMMANDS([ida_par_ex],
-     [
-     IN_FILE="examples/ida/parallel/Makefile_ex"
-     SOLVER="IDA"
-     SOLVER_LIB="sundials_ida"
-     SOLVER_FLIB=""
-     EXAMPLES="idaFoodWeb_kry_bbd_p idaFoodWeb_kry_p idaHeat2D_kry_bbd_p idaHeat2D_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_parallel ; then
-     AC_CONFIG_COMMANDS([ida_fpar_ex],
-     [
-     IN_FILE="examples/ida/fcmix_parallel/Makefile_ex"
-     SOLVER="IDA"
-     SOLVER_LIB="sundials_ida"
-     SOLVER_FLIB="sundials_fida"
-     EXAMPLES="fidaHeat2D_kry_bbd_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-fi
-
-
-# IDAS module
-if test "X${IDAS_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([idas_ser_ex_bl],
-       [
-       IN_FILE="examples/idas/serial/Makefile_ex"
-       SOLVER="IDAS"
-       SOLVER_LIB="sundials_idas"
-       SOLVER_FLIB=""
-       EXAMPLES="idasAkzoNob_ASAi_dns idasFoodWeb_bnd idasHeat2D_kry idasKrylovDemo_ls idasRoberts_dns idasSlCrank_dns idasAkzoNob_dns idasHeat2D_bnd idasHessian_ASA_FSA idasRoberts_ASAi_dns idasRoberts_FSA_dns idasSlCrank_FSA_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([idas_ser_ex],
-       [
-       IN_FILE="examples/idas/serial/Makefile_ex"
-       SOLVER="IDAS"
-       SOLVER_LIB="sundials_idas"
-       SOLVER_FLIB=""
-       EXAMPLES="idasAkzoNob_ASAi_dns idasFoodWeb_bnd idasHeat2D_kry idasKrylovDemo_ls idasRoberts_dns idasSlCrank_dns idasAkzoNob_dns idasHeat2D_bnd idasHessian_ASA_FSA idasRoberts_ASAi_dns idasRoberts_FSA_dns idasSlCrank_FSA_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/parallel ; then
-     AC_CONFIG_COMMANDS([idas_par_ex],
-     [
-     IN_FILE="examples/idas/parallel/Makefile_ex"
-     SOLVER="IDAS"
-     SOLVER_LIB="sundials_idas"
-     SOLVER_FLIB=""
-     EXAMPLES="idasBruss_ASAp_kry_bbd_p idasBruss_kry_bbd_p idasFoodWeb_kry_p idasHeat2D_kry_bbd_p idasBruss_FSA_kry_bbd_p idasFoodWeb_kry_bbd_p idasHeat2D_FSA_kry_bbd_p idasHeat2D_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-fi
-
-
-# KINSOL module
-if test "X${KINSOL_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([kinsol_ser_ex_bl],
-       [
-       IN_FILE="examples/kinsol/serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB=""
-       EXAMPLES="kinFerTron_dns kinFoodWeb_kry kinKrylovDemo_ls kinLaplace_bnd kinRoboKin_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([kinsol_ser_ex],
-       [
-       IN_FILE="examples/kinsol/serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB=""
-       EXAMPLES="kinFerTron_dns kinFoodWeb_kry kinKrylovDemo_ls kinLaplace_bnd kinRoboKin_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([kinsol_fser_ex_bl],
-       [
-       IN_FILE="examples/kinsol/fcmix_serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB="sundials_fkinsol"
-       EXAMPLES="fkinDiagon_kry"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([kinsol_fser_ex],
-       [
-       IN_FILE="examples/kinsol/fcmix_serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB="sundials_fkinsol"
-       EXAMPLES="fkinDiagon_kry"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/parallel ; then
-     AC_CONFIG_COMMANDS([kinsol_par_ex],
-     [
-     IN_FILE="examples/kinsol/parallel/Makefile_ex"
-     SOLVER="KINSOL"
-     SOLVER_LIB="sundials_kinsol"
-     SOLVER_FLIB=""
-     EXAMPLES="kinFoodWeb_kry_bbd_p kinFoodWeb_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_parallel ; then
-     AC_CONFIG_COMMANDS([kinsol_fpar_ex],
-     [
-     IN_FILE="examples/kinsol/fcmix_parallel/Makefile_ex"
-     SOLVER="KINSOL"
-     SOLVER_LIB="sundials_kinsol"
-     SOLVER_FLIB="sundials_fkinsol"
-     EXAMPLES="fkinDiagon_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-fi
-
-
-# CPODES module
-if test "X${CPODES_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-       AC_CONFIG_COMMANDS([cpodes_ser_ex_bl],
-       [
-       IN_FILE="examples/cpodes/serial/Makefile_ex"
-       SOLVER="CPODES"
-       SOLVER_LIB="sundials_cpodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cpsAdvDiff_bnd cpsAdvDiff_non cpsNewtCrd_dns cpsPend_dns cpsRoberts_dns cpsVanDPol_non"
-       EXAMPLES_BL="cpsAdvDiff_bndL cpsPend_dnsL cpsRoberts_dnsL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     else
-       AC_CONFIG_COMMANDS([cpodes_ser_ex],
-       [
-       IN_FILE="examples/cpodes/serial/Makefile_ex"
-       SOLVER="CPODES"
-       SOLVER_LIB="sundials_cpodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cpsAdvDiff_bnd cpsAdvDiff_non cpsNewtCrd_dns cpsPend_dns cpsRoberts_dns cpsVanDPol_non"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-       ])
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/parallel ; then
-     AC_CONFIG_COMMANDS([cpodes_par_ex],
-     [
-     IN_FILE="examples/cpodes/parallel/Makefile_ex"
-     SOLVER="CPODES"
-     SOLVER_LIB="sundials_cpodes"
-     SOLVER_FLIB=""
-     EXAMPLES="cpsHeat2D_kry_bbd_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-     ])
-  fi
-
-fi
-
-]) dnl END SUNDIALS_POST_PROCESSING
-
-#------------------------------------------------------------------
-# PRINT STATUS REPORT
-#------------------------------------------------------------------
-
-AC_DEFUN([SUNDIALS_REPORT],
-[
-
-if test "X${SUNDIALS_WARN_FLAG}" = "Xyes"; then
-echo "
-***************
-*   WARNING   *
-***************
-
-At least one warning was issued. Some features were disabled.
-
-Review the configure output and/or the contents of config.log 
-before proceeding with the build.
-"
-fi
-
-echo "
-------------------------------
-SUNDIALS Configuration Summary
-------------------------------"
-
-echo "
-Configuration
--------------
-
-  Host System:               ${host}
-  Build System:              ${build}
-
-  C Preprocessor:            ${CPP} 
-  C Preprocessor Flags:      ${CPPFLAGS}
-  C Compiler:	             ${CC}
-  C Compiler Flags           ${CFLAGS}
-  C Linker:                  ${CC}
-  Linker Flags:              ${LDFLAGS}
-  Libraries:                 ${LIBS}"
-
-if test "X${F77_OK}" = "Xyes"; then
-echo "
-  Fortran Compiler:          ${F77}
-  Fortran Compiler Flags:    ${FFLAGS}
-  Fortran Linker:            ${F77_LNKR}
-  Extra Fortran Libraries:   ${FLIBS}"
-fi
-
-if test "X${MPI_ENABLED}" = "Xyes" && test "X${MPI_C_COMP_OK}" = "Xyes"; then
-echo "
-  MPI Root Directory:        ${MPI_ROOT_DIR}
-  MPI Include Directory:     ${MPI_INC_DIR}
-  MPI Library Directory:     ${MPI_LIB_DIR}
-  MPI Flags:                 ${MPI_FLAGS}
-  Extra MPI Libraries:       ${MPI_LIBS}
-
-  Using MPI-C script?        ${USE_MPICC_SCRIPT}
-  MPI-C:                     ${MPICC}"
-fi
-
-if test "X${MPI_ENABLED}" = "Xyes" && test "X${F77_EXAMPLES_ENABLED}" = "Xyes" && test "X${MPI_F77_COMP_OK}" = "Xyes"; then
-echo "
-  Using MPI-Fortran script?  ${USE_MPIF77_SCRIPT}
-  MPI-Fortran:               ${MPIF77}
-  MPI-Fortran Linker:        ${MPIF77_LNKR}"
-fi
-
-# Determine SOURCE, BUILD, and EXEC_PREFIX directories
-cv_srcdir=`( cd ${srcdir} ; pwd )`
-cv_builddir=`pwd`
-if test "X${exec_prefix}" = "XNONE"; then
-  cv_exec_prefix="${prefix}"
-else
-  cv_exec_prefix="${exec_prefix}"
-fi
-
-echo "
-  srcdir:                    ${cv_srcdir}
-  builddir:                  ${cv_builddir}
-  prefix:                    ${prefix}
-  exec_prefix:               ${cv_exec_prefix}
-  includedir:                ${includedir}
-  libdir:                    ${libdir}"
-
-if test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-echo "  examples installed in:     ${EXS_INSTDIR}"
-fi
-
-echo "
-Modules
--------
-"
-
-if test "X${CVODE_ENABLED}" = "Xyes"; then
-  THIS_LINE="CVODE"
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    THIS_LINE="${THIS_LINE}  FCVODE"
-  fi
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${CVODES_ENABLED}" = "Xyes"; then
-  THIS_LINE="CVODES"
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${IDA_ENABLED}" = "Xyes"; then
-  THIS_LINE="IDA"
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    THIS_LINE="${THIS_LINE}    FIDA"
-  fi
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${IDAS_ENABLED}" = "Xyes"; then
-  THIS_LINE="IDAS"
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${KINSOL_ENABLED}" = "Xyes"; then
-  THIS_LINE="KINSOL"
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    THIS_LINE="${THIS_LINE} FKINSOL"
-  fi
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${CPODES_ENABLED}" = "Xyes"; then
-  THIS_LINE="CPODES"
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-echo "
-Examples
---------
-"
-
-echo "  Serial C examples:         ${SERIAL_C_EXAMPLES}"
-echo "  Parallel C examples:       ${PARALLEL_C_EXAMPLES}"
-echo "  Serial Fortran examples:   ${SERIAL_F77_EXAMPLES}"
-echo "  Parallel Fortran examples: ${PARALLEL_F77_EXAMPLES}"
-
-fi
-
-
-echo "  
-  Type 'make' and then 'make install' to build and install ${PACKAGE_STRING}."
-
-
-
-echo "
-----------------------------------
-Finished SUNDIALS Configure Script
-----------------------------------
-"
-
-]) dnl END SUNDIALS_REPORT
diff --git a/bin/fortran-update.in b/bin/fortran-update.in
deleted file mode 100644
index 744372d..0000000
--- a/bin/fortran-update.in
+++ /dev/null
@@ -1,490 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.1 $
-# $Date: 2007/01/30 15:23:24 $
-# -----------------------------------------------------------------
-# Programmer(s): Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# This script updates Fortran source code according to the level
-# of precision specified using the --with-precision option. It also
-# updates variable type specifiers according to the sizes of the
-# C types 'long int' and 'int' and the SUNDIALS-specific type
-# 'realtype'.
-# -----------------------------------------------------------------
-# Notes:
-#
-#  (1) The environment variable F77_KEYWORD_LIST should contain
-#      a list of all intrinsic functions/procedures used in the
-#      Fortran examples (defined under 'update' target).
-#
-#  (2) F77_MPI_REAL_* is set to MPI_REAL#, where # is the number
-#      of bytes in realtype (SUNDIALS-specific data type). However,
-#      if MPI_REAL# is NOT defined in the header file 'mpif.h',
-#      then MPI_REAL is used instead. Also, if the file 'mpif.h'
-#      does NOT exist under the directory MPI_INC_DIR, then
-#      MPI_REAL# is still used, but there is NO guarantee that
-#      it is actually defined. Of course, the problem can easily
-#      be avoided by adding -I<mpi_inc_dir> to FFLAGS or
-#      --with-fflags.
-# -----------------------------------------------------------------
-
-SAVED_LC_ALL="${LC_ALL}"
-LC_ALL="C"
-
-abs_top_builddir="@abs_top_builddir@"
-prefix="@prefix@"
-includedir="@includedir@"
-
-FLOAT_TYPE="@FLOAT_TYPE@"
-
-MPI_INC_DIR="@MPI_INC_DIR@"
-
-EGREP="@EGREP@"
-FGREP="@FGREP@"
-
-MPI_COMM_F2C="@F77_MPI_COMM_F2C@"
-TEMP_A=`echo "${MPI_COMM_F2C}" | ${FGREP} "#define SUNDIALS_MPI_COMM_F2C 1"`
-if test "X${TEMP_A}" = "X"; then
-  USE_MPI_COMM_F2C_EXT="no"
-else
-  USE_MPI_COMM_F2C_EXT="yes"
-fi
-
-INSTALL="@INSTALL@"
-TEMP_INSTALL=`echo "${INSTALL}" | cut -d' ' -f1`
-if test -f ${TEMP_INSTALL} ; then
-  :
-else
-  INSTALL="${abs_top_builddir}/config/${INSTALL}"
-fi
-CP_FILE="@INSTALL_DATA@"
-
-srcdir="${1}"
-SOURCE_FILE="${2}"
-
-builddir="."
-
-F77_KEYWORD_LIST="FLOAT/DBLE/QFLOAT,float/dble/qfloat SIN/DSIN/QSIN,sin/dsin/qsin"
-F77_KEYWORD_LIST="${F77_KEYWORD_LIST} EXP/DEXP/QEXP,exp/dexp/qexp"
-F77_KEYWORD_LIST="${F77_KEYWORD_LIST} ABS/DABS/QABS,abs/dabs/qabs"
-F77_KEYWORD_LIST="${F77_KEYWORD_LIST} AMAX1/DMAX1/QMAX1,amax1/dmax1/qmax1"
-
-TEMP_A=`${FGREP} "#define SIZEOF_INT 4" ${abs_top_builddir}/config.h`
-if test "X${TEMP_A}" = "X"; then
-  TEMP_A=`${FGREP} "#define SIZEOF_INT 8" ${abs_top_builddir}/config.h`
-  if test "X${TEMP_A}" = "X"; then
-    INT_BYTES="4"
-  else
-    INT_BYTES="8"
-  fi
-else
-  INT_BYTES="4"
-fi
-F77_INT_UPPER="INTEGER\*${INT_BYTES}"
-F77_INT_LOWER="integer\*${INT_BYTES}"
-TEMP_A=`${FGREP} "#define SIZEOF_LONG_INT 4" ${abs_top_builddir}/config.h`
-if test "X${TEMP_A}" = "X"; then
-  TEMP_A=`${FGREP} "#define SIZEOF_LONG_INT 8" ${abs_top_builddir}/config.h`
-  if test "X${TEMP_A}" = "X"; then
-    LONG_INT_BYTES="4"
-  else
-    LONG_INT_BYTES="8"
-  fi
-else
-  LONG_INT_BYTES="4"
-fi
-F77_LONG_INT_UPPER="INTEGER\*${LONG_INT_BYTES}"
-F77_LONG_INT_LOWER="integer\*${LONG_INT_BYTES}"
-if test "X${FLOAT_TYPE}" = "Xsingle"; then
-  TEMP_A=`${FGREP} "#define SIZEOF_FLOAT 4" ${abs_top_builddir}/config.h`
-  if test "X${TEMP_A}" = "X"; then
-    TEMP_A=`${FGREP} "#define SIZEOF_FLOAT 8" ${abs_top_builddir}/config.h`
-    if test "X${TEMP_A}" = "X"; then
-      TEMP_A=`${FGREP} "#define SIZEOF_FLOAT 16" ${abs_top_builddir}/config.h`
-      if test "X${TEMP_A}" = "X"; then
-        FLOAT_BYTES=""
-      else
-        FLOAT_BYTES="16"
-      fi
-    else
-      FLOAT_BYTES="8"
-    fi
-  else
-    FLOAT_BYTES="4"
-  fi
-elif test "X${FLOAT_TYPE}" = "Xdouble"; then
-  TEMP_A=`${FGREP} "#define SIZEOF_DOUBLE 4" ${abs_top_builddir}/config.h`
-  if test "X${TEMP_A}" = "X"; then
-    TEMP_A=`${FGREP} "#define SIZEOF_DOUBLE 8" ${abs_top_builddir}/config.h`
-    if test "X${TEMP_A}" = "X"; then
-      TEMP_A=`${FGREP} "#define SIZEOF_DOUBLE 16" ${abs_top_builddir}/config.h`
-      if test "X${TEMP_A}" = "X"; then
-        FLOAT_BYTES=""
-      else
-        FLOAT_BYTES="16"
-      fi
-    else
-      FLOAT_BYTES="8"
-    fi
-  else
-    FLOAT_BYTES="4"
-  fi
-elif test "X${FLOAT_TYPE}" = "Xextended"; then
-  TEMP_A=`${FGREP} "#define SIZEOF_LONG_DOUBLE 4" ${abs_top_builddir}/config.h`
-  if test "X${TEMP_A}" = "X"; then
-    TEMP_A=`${FGREP} "#define SIZEOF_LONG_DOUBLE 8" ${abs_top_builddir}/config.h`
-    if test "X${TEMP_A}" = "X"; then
-      TEMP_A=`${FGREP} "#define SIZEOF_LONG_DOUBLE 16" ${abs_top_builddir}/config.h`
-      if test "X${TEMP_A}" = "X"; then
-        FLOAT_BYTES=""
-      else
-        FLOAT_BYTES="16"
-      fi
-    else
-      FLOAT_BYTES="8"
-    fi
-  else
-    FLOAT_BYTES="4"
-  fi
-fi
-if test "X${FLOAT_BYTES}" = "X" || test "X${FLOAT_TYPE}" = "Xdouble"; then
-  F77_FLOAT_UPPER=""
-  F77_FLOAT_LOWER=""
-elif test "X${FLOAT_TYPE}" = "Xsingle" || test "X${FLOAT_TYPE}" = "Xextended"; then
-  F77_FLOAT_UPPER="REAL\*${FLOAT_BYTES}"
-  F77_FLOAT_LOWER="real\*${FLOAT_BYTES}"
-fi
-if test "X${FLOAT_TYPE}" = "Xsingle"; then
-  C_FLOAT_TYPE="float"
-elif test "X${FLOAT_TYPE}" = "Xdouble"; then
-  C_FLOAT_TYPE="double"
-elif test "X${FLOAT_TYPE}" = "Xextended"; then
-  C_FLOAT_TYPE="long double"
-fi
-TEMP_A=`echo "${srcdir}" | ${FGREP} "examples_par"`
-if test "X${TEMP_A}" = "X"; then
-  :
-else
-  if test -f ${MPI_INC_DIR}/mpif.h ; then
-    TEMP_A=`${FGREP} "MPI_REAL${FLOAT_BYTES}" ${MPI_INC_DIR}/mpif.h`
-    if test "X${TEMP_A}" = "X"; then
-      TEMP_A=`${FGREP} "mpi_real${FLOAT_BYTES}" ${MPI_INC_DIR}/mpif.h`
-    fi
-    if test "X${TEMP_A}" = "X"; then
-      F77_MPI_REAL_UPPER="MPI_REAL"
-      F77_MPI_REAL_LOWER="mpi_real"
-    else
-      F77_MPI_REAL_UPPER="MPI_REAL${FLOAT_BYTES}"
-      F77_MPI_REAL_LOWER="mpi_real${FLOAT_BYTES}"
-    fi
-  else
-    echo ""
-    echo "WARNING: using MPI_REAL${FLOAT_BYTES} since unable to find mpif.h"
-    echo ""
-    F77_MPI_REAL_UPPER="MPI_REAL${FLOAT_BYTES}"
-    F77_MPI_REAL_LOWER="mpi_real${FLOAT_BYTES}"
-  fi
-fi
-if test "X${FLOAT_BYTES}" = "X"; then
-  echo ""
-  echo "WARNING: ${C_FLOAT_TYPE} floating-point data type has NO Fortran equivalent"
-  echo ""
-fi
-if test -f ${srcdir}/${SOURCE_FILE} ; then
-  echo "Updating ${SOURCE_FILE}..."
-  ${CP_FILE} ${srcdir}/${SOURCE_FILE} ${builddir}/temp1.f
-  TEMP_A=`${FGREP} "INTEGER*4" ${builddir}/temp1.f`
-  TEMP_B=`${FGREP} "integer*4" ${builddir}/temp1.f`
-  TEMP_A="${TEMP_A} ${TEMP_B}"
-  for j in ${TEMP_A} ; do
-    TEMP_B=`echo "${j}" | ${FGREP} "INTEGER*4"`
-    F77_CASE="upper"
-    if test "X${TEMP_B}" = "X"; then
-      TEMP_B=`echo "${j}" | ${FGREP} "integer*4"`
-      F77_CASE="lower"
-    fi
-    if test "X${TEMP_B}" = "X"; then
-      :
-    else
-      TEMP1=`echo "${j}" | cut -d'*' -f1`
-      TEMP2=`echo "${j}" | cut -d'*' -f2`
-      j="${TEMP1}\*${TEMP2}"
-      if test "X${F77_CASE}" = "Xupper"; then
-        sed "s,${j},${F77_LONG_INT_UPPER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-      else
-        sed "s,${j},${F77_LONG_INT_LOWER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-      fi
-      ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-    fi
-  done
-  TEMP_A=`${FGREP} "INTEGER " ${builddir}/temp1.f`
-  TEMP_B=`${FGREP} "integer " ${builddir}/temp1.f`
-  TEMP_A="${TEMP_A} ${TEMP_B}"
-  for j in ${TEMP_A} ; do
-    TEMP_B=`echo "${j}" | ${FGREP} "INTEGER"`
-    F77_CASE="upper"
-    if test "X${TEMP_B}" = "X"; then
-      TEMP_B=`echo "${j}" | ${FGREP} "integer"`
-      F77_CASE="lower"
-    fi
-    if test "X${TEMP_B}" = "X"; then
-      :
-    else
-      if test "X${F77_CASE}" = "Xupper"; then
-        sed "s,${j} ,${F77_INT_UPPER} ," ${builddir}/temp1.f > ${builddir}/temp2.f
-      else
-        sed "s,${j} ,${F77_INT_LOWER} ," ${builddir}/temp1.f > ${builddir}/temp2.f
-      fi
-      ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-    fi
-  done
-  if test "X${FLOAT_TYPE}" = "Xdouble" || test "X${FLOAT_BYTES}" = "X"; then
-    :
-  elif test "X${FLOAT_TYPE}" = "Xsingle"; then
-    CONTINUE="yes"
-    while test "X${CONTINUE}" = "Xyes" ; do
-      TEMP_A=`${FGREP} "DOUBLE PRECISION" ${builddir}/temp1.f`
-      F77_CASE="upper"
-      if test "X${TEMP_A}" = "X"; then
-        TEMP_A=`${FGREP} "double precision" ${builddir}/temp1.f`
-        F77_CASE="lower"
-      fi
-      if test "X${TEMP_A}" = "X"; then
-        CONTINUE="no"
-      else
-        if test "X${F77_CASE}" = "Xupper"; then
-          sed "s,DOUBLE PRECISION,${F77_FLOAT_UPPER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        else
-          sed "s,double precision,${F77_FLOAT_LOWER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        fi
-        ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-      fi
-    done
-    CONTINUE="yes"
-    while test "X${CONTINUE}" = "Xyes" ; do
-      TEMP_A=`${FGREP} "MPI_DOUBLE_PRECISION" ${builddir}/temp1.f`
-      F77_CASE="upper"
-      if test "X${TEMP_A}" = "X"; then
-        TEMP_A=`${FGREP} "mpi_double_precision" ${builddir}/temp1.f`
-        F77_CASE="lower"
-      fi
-      if test "X${TEMP_A}" = "X"; then
-        CONTINUE="no"
-      else
-        if test "X${F77_CASE}" = "Xupper"; then
-          sed "s,MPI_DOUBLE_PRECISION,${F77_MPI_REAL_UPPER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        else
-          sed "s,mpi_double_precision,${F77_MPI_REAL_LOWER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        fi
-        ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-      fi
-    done
-    TEMP_A=`${EGREP} "[/]?[[:digit:]]+[.]{1}[[:digit:]]*[dD]{1}[+-]?[[:digit:]]+[/]?" ${builddir}/temp1.f`
-    CONTINUE="yes"
-    while test "X${CONTINUE}" = "Xyes" ; do
-      TEMP_B=`echo "${TEMP_A}" | ${FGREP} ","`
-      if test "X${TEMP_B}" = "X"; then
-        CONTINUE="no"
-      else
-        TEMP_A=`echo "${TEMP_A}" | sed "s,\,, ,"`
-      fi
-    done
-    CONTINUE="yes"
-    while test "X${CONTINUE}" = "Xyes" ; do
-      TEMP_B=`echo "${TEMP_A}" | ${FGREP} "("`
-      if test "X${TEMP_B}" = "X"; then
-        CONTINUE="no"
-      else
-        TEMP_A=`echo "${TEMP_A}" | sed "s,(, ,"`
-      fi
-    done
-    for j in ${TEMP_A} ; do
-      TEMP_B=`echo "${j}" | ${EGREP} "[/]?[[:digit:]]+[.]{1}[[:digit:]]*[dD]{1}[+-]?[[:digit:]]+[/]?"`
-      if test "X${TEMP_B}" = "X"; then
-        :
-      else
-        TEMP_B=`echo "${j}" | ${FGREP} "/"`
-        if test "X${TEMP_B}" = "X"; then
-          TEMP_B=`echo "${j}" | sed "s,D,E,"`
-          TEMP_B=`echo "${TEMP_B}" | sed "s,d,e,"`
-          sed "s,${j},${TEMP_B}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        else
-          TEMP_B=`echo "${j}" | cut -d'/' -f2`
-          TEMP_C=`echo "${TEMP_B}" | sed "s,D,E,"`
-          TEMP_C=`echo "${TEMP_C}" | sed "s,d,e,"`
-          TEMP_C=`echo "${j}" | sed "s,${TEMP_B},${TEMP_C},"`
-          sed "s,${j},${TEMP_C}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        fi
-        ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-      fi
-    done
-    for k in ${F77_KEYWORD_LIST} ; do
-      F77_LIST_UPPER=`echo "${k}" | cut -d',' -f1`
-      F77_LIST_LOWER=`echo "${k}" | cut -d',' -f2`
-      DEFAULT_KEYWORD_UPPER=`echo "${F77_LIST_UPPER}" | cut -d'/' -f2`
-      DEFAULT_KEYWORD_LOWER=`echo "${F77_LIST_LOWER}" | cut -d'/' -f2`
-      TEMP_A=`${FGREP} "${DEFAULT_KEYWORD_UPPER}(" ${builddir}/temp1.f`
-      TEMP_B=`${FGREP} "${DEFAULT_KEYWORD_LOWER}(" ${builddir}/temp1.f`
-      TEMP_A="${TEMP_A} ${TEMP_B}"
-      CONTINUE="yes"
-      while test "X${CONTINUE}" = "Xyes" ; do
-        TEMP_B=`echo "${TEMP_A}" | ${FGREP} ","`
-        if test "X${TEMP_B}" = "X"; then
-          CONTINUE="no"
-        else
-          TEMP_A=`echo "${TEMP_A}" | sed "s,\,, ,"`
-        fi
-      done
-      for j in ${TEMP_A} ; do
-        TEMP_B=`echo "${j}" | ${FGREP} "${DEFAULT_KEYWORD_UPPER}("`
-        F77_CASE="upper"
-        if test "X${TEMP_B}" = "X"; then
-          TEMP_B=`echo "${j}" | ${FGREP} "${DEFAULT_KEYWORD_LOWER}("`
-          F77_CASE="lower"
-        fi
-        if test "X${TEMP_B}" = "X"; then
-          :
-        else
-          if test "X${F77_CASE}" = "Xupper"; then
-            TEMP_C=`echo "${F77_LIST_UPPER}" | cut -d'/' -f1`
-            TEMP_B=`echo "${j}" | sed "s,${DEFAULT_KEYWORD_UPPER}(,${TEMP_C}(,"`
-          else
-            TEMP_C=`echo "${F77_LIST_LOWER}" | cut -d'/' -f1`
-            TEMP_B=`echo "${j}" | sed "s,${DEFAULT_KEYWORD_LOWER}(,${TEMP_C}(,"`
-          fi
-          sed "s,${j},${TEMP_B}," ${builddir}/temp1.f > ${builddir}/temp2.f
-          ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-        fi
-      done
-    done
-  elif test "X${FLOAT_TYPE}" = "Xextended"; then
-    CONTINUE="yes"
-    while test "X${CONTINUE}" = "Xyes" ; do
-      TEMP_A=`${FGREP} "DOUBLE PRECISION" ${builddir}/temp1.f`
-      F77_CASE="upper"
-      if test "X${TEMP_A}" = "X"; then
-        TEMP_A=`${FGREP} "double precision" ${builddir}/temp1.f`
-        F77_CASE="lower"
-      fi
-      if test "X${TEMP_A}" = "X"; then
-        CONTINUE="no"
-      else
-        if test "X${F77_CASE}" = "Xupper"; then
-          sed "s,DOUBLE PRECISION,${F77_FLOAT_UPPER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        else
-          sed "s,double precision,${F77_FLOAT_LOWER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        fi
-        ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-      fi
-    done
-    CONTINUE="yes"
-    while test "X${CONTINUE}" = "Xyes" ; do
-      TEMP_A=`${FGREP} "MPI_DOUBLE_PRECISION" ${builddir}/temp1.f`
-      F77_CASE="upper"
-      if test "X${TEMP_A}" = "X"; then
-        TEMP_A=`${FGREP} "mpi_double_precision" ${builddir}/temp1.f`
-        F77_CASE="lower"
-      fi
-      if test "X${TEMP_A}" = "X"; then
-        CONTINUE="no"
-      else
-        if test "X${F77_CASE}" = "Xupper"; then
-          sed "s,MPI_DOUBLE_PRECISION,${F77_MPI_REAL_UPPER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        else
-          sed "s,mpi_double_precision,${F77_MPI_REAL_LOWER}," ${builddir}/temp1.f > ${builddir}/temp2.f
-        fi
-        ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-      fi
-    done
-    if test "X${FLOAT_BYTES}" = "X16"; then
-      for k in ${F77_KEYWORD_LIST} ; do
-        F77_LIST_UPPER=`echo "${k}" | cut -d',' -f1`
-        F77_LIST_LOWER=`echo "${k}" | cut -d',' -f2`
-        DEFAULT_KEYWORD_UPPER=`echo "${F77_LIST_UPPER}" | cut -d'/' -f2`
-        DEFAULT_KEYWORD_LOWER=`echo "${F77_LIST_LOWER}" | cut -d'/' -f2`
-        TEMP_A=`${FGREP} "${DEFAULT_KEYWORD_UPPER}(" ${builddir}/temp1.f`
-        TEMP_B=`${FGREP} "${DEFAULT_KEYWORD_LOWER}(" ${builddir}/temp1.f`
-        TEMP_A="${TEMP_A} ${TEMP_B}"
-        CONTINUE="yes"
-        while test "X${CONTINUE}" = "Xyes" ; do
-          TEMP_B=`echo "${TEMP_A}" | ${FGREP} ","`
-          if test "X${TEMP_B}" = "X"; then
-            CONTINUE="no"
-          else
-            TEMP_A=`echo "${TEMP_A}" | sed "s,\,, ,"`
-          fi
-        done
-        for j in ${TEMP_A} ; do
-          TEMP_B=`echo "${j}" | ${FGREP} "${DEFAULT_KEYWORD_UPPER}("`
-          F77_CASE="upper"
-          if test "X${TEMP_B}" = "X"; then
-            TEMP_B=`echo "${j}" | ${FGREP} "${DEFAULT_KEYWORD_LOWER}("`
-            F77_CASE="lower"
-          fi
-          if test "X${TEMP_B}" = "X"; then
-            :
-          else
-            if test "X${F77_CASE}" = "Xupper"; then
-              TEMP_C=`echo "${F77_LIST_UPPER}" | cut -d'/' -f3`
-              TEMP_B=`echo "${j}" | sed "s,${DEFAULT_KEYWORD_UPPER}(,${TEMP_C}(,"`
-            else
-              TEMP_C=`echo "${F77_LIST_LOWER}" | cut -d'/' -f3`
-              TEMP_B=`echo "${j}" | sed "s,${DEFAULT_KEYWORD_LOWER}(,${TEMP_C}(,"`
-            fi
-            sed "s,${j},${TEMP_B}," ${builddir}/temp1.f > ${builddir}/temp2.f
-            ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-          fi
-        done
-      done
-    fi
-  fi
-
-  F77_MPI_KEYWORD_LIST="FNVINITP,fnvinitp FNVINITPQ,fnvinitpq FNVINITPS,fnvinitps"
-  F77_MPI_KEYWORD_LIST="${F77_MPI_KEYWORD_LIST} FNVINITPB,fnvinitpb FNVINITPQB,fnvinitpqb"
-
-  if test "X${USE_MPI_COMM_F2C_EXT}" = "Xno"; then
-    F77_MPI_KEYWORD=""
-    for z in ${F77_MPI_KEYWORD_LIST} ; do
-      F77_MPI_A=`echo "${z}" | cut -d',' -f1`
-      F77_MPI_B=`echo "${z}" | cut -d',' -f2`
-      TEMP_A=`${FGREP} "${F77_MPI_A}(" ${builddir}/temp1.f`
-      if test "X${TEMP_A}" = "X"; then
-        TEMP_A=`${FGREP} "${F77_MPI_B}(" ${builddir}/temp1.f`
-        if test "X${TEMP_A}" = "X"; then
-          F77_SKIP_MPI_UPDATE="yes"
-        else
-          F77_MPI_KEYWORD="${F77_MPI_B}"
-          F77_MPI_CASE="lower"
-          F77_SKIP_MPI_UPDATE="no"
-        fi
-      else
-        F77_MPI_KEYWORD="${F77_MPI_A}"
-        F77_MPI_CASE="upper"
-        F77_SKIP_MPI_UPDATE="no"
-      fi
-      if test "X${F77_SKIP_MPI_UPDATE}" = "Xno"; then
-        break
-      fi
-    done
-    if test "X${F77_SKIP_MPI_UPDATE}" = "Xno"; then
-      if test "X${F77_MPI_CASE}" = "Xupper"; then
-        sed "s,${F77_MPI_KEYWORD}(MPI\_COMM\_WORLD\, ,${F77_MPI_KEYWORD}(0\, ," ${builddir}/temp1.f > ${builddir}/temp2.f
-        ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-      else
-        sed "s,${F77_MPI_KEYWORD}(mpi\_comm\_world\, ,${F77_MPI_KEYWORD}(0\, ," ${builddir}/temp1.f > ${builddir}/temp2.f
-        ${CP_FILE} ${builddir}/temp2.f ${builddir}/temp1.f
-      fi
-    fi
-  fi
-
-  SOURCE_FILE=`echo "${SOURCE_FILE}" | cut -d'.' -f1`
-  SOURCE_FILE="${SOURCE_FILE}-updated.f"
-  ${CP_FILE} ${builddir}/temp1.f ${builddir}/${SOURCE_FILE}
-  rm -f ${builddir}/temp1.f ${builddir}/temp2.f
-fi
-
-LC_ALL="${SAVED_LC_ALL}"
diff --git a/bin/makefile-update.in b/bin/makefile-update.in
deleted file mode 100644
index bd7c4b0..0000000
--- a/bin/makefile-update.in
+++ /dev/null
@@ -1,32 +0,0 @@
-#! @SHELL@
-# -----------------------------------------------------------------------------------
-# $Revision: 1.2 $
-# $Date: 2007/12/19 20:33:59 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# This script updates example Makefiles before export.
-# It is called by the configure script, after an initial export
-# Makefile_ex has been created by config.status.
-# -----------------------------------------------------------------
-
-infile="${1}"
-solver="${2}"
-examples="${3}"
-examples_bl="${4}"
-solver_lib="${5}"
-solver_flib="${6}"
-
-sed "s/@SOLVER@/${solver}/" ${infile}       | \
-sed "s/@EXAMPLES@/${examples}/"             | \
-sed "s/@EXAMPLES_BL@/${examples_bl}/"       | \
-sed "s/@SOLVER_LIB@/${solver_lib}/"         | \
-sed "s/@SOLVER_FLIB@/${solver_flib}/"       > foo_makefile
-
-mv foo_makefile ${infile}
-
diff --git a/bin/sundials-config.in b/bin/sundials-config.in
deleted file mode 100644
index 11ff711..0000000
--- a/bin/sundials-config.in
+++ /dev/null
@@ -1,136 +0,0 @@
-#! @SHELL@
-# -----------------------------------------------------------------------------------
-
-    NAME_="sundials-config"
- PURPOSE_="returns required flags for linking to SUNDIALS libraries"
-SYNOPSIS_="$NAME_ -m cvode|cvodes|ida|idas|kinsol -t s|p -l c|f [-s libs|cppflags -hv]"
-REQUIRES_="standard GNU commands"
- VERSION_="0.1"
-    DATE_="2006-07-25"
-  AUTHOR_="Radu Serban <radu at llnl.gov>"
-
-# -----------------------------------------------------------------------------------
-
-usage () {
-
-echo >&2 "$NAME_ $VERSION_ - $PURPOSE_
-Usage: $SYNOPSIS_
-Requires: $REQUIRES_
-Options:
-    -m cvode|cvodes|ida|idas|kinsol  SUNDIALS module
-    -t s|p                           use serial or parallel vectors
-    -l c|f                           use C or Fortran
-    -s libs|cppflags                 show linking flags or C preprocessor flags. 
-                                     (show both if option not given.)
-    -h                               usage and options (this help)
-    -v                               view this script
-Notes:
-    '-l f' is not valid for '-m cvodes' or '-m idas'
-    '-s cppflags' returns an empty string for '-l f'" 
-    exit 1
-}
-
-
-# args check
-[ $# -eq 0 ] && { echo >&2 missing argument, type $NAME_ -h for help; exit 1; }
-
-# process args
-while getopts hvm:t:l:s: options
-do
-    case $options in
-        m) module=$OPTARG ;;
-        t) vector=$OPTARG ;;
-        l) lang=$OPTARG ;;
-        s) show=$OPTARG ;;
-        h) usage ;;
-        v) more $0; exit 1 ;;
-       \?) echo invalid argument, type $NAME_ -h for help; exit 1 ;;
-    esac
-done
-shift $(( $OPTIND - 1 ))
-
-# args check
-[[ $module ]] || { echo >&2 the -m option and argument must be specified; exit 1; }
-[[ $vector ]] || { echo >&2 the -t option and argument must be specified; exit 1; }
-[[ $lang ]]   || { echo >&2 the -l option and argument must be specified; exit 1; }
-[[ $show ]]   || { show=both; }
-
-# main
-
-prefix=@prefix@;
-exec_prefix=@exec_prefix@;
-includedir=@includedir@;
-libdir=@libdir@;
-
-abs_includedir=`cd "${includedir}" > /dev/null 2>&1 && pwd`;
-abs_libdir=`cd "${libdir}" > /dev/null 2>&1 && pwd`;
-
-if test $abs_includedir != /usr/include ; then
-    includes=-I$abs_includedir
-fi
-
-libdirs=-L$abs_libdir
-
-case $module in
-    cvode) 
-        sun_lib="-lsundials_cvode";
-        sun_flib="-lsundials_fcvode";
-        ;;
-    cvodes)
-        sun_lib="-lsundials_cvodes";
-        sun_flib=;
-        ;;
-    ida) 
-        sun_lib="-lsundials_ida";
-        sun_flib="-lsundials_fida";
-        ;;
-    idas) 
-        sun_lib="-lsundials_idas";
-        sun_flib=;
-        ;;
-    kinsol) 
-        sun_lib="-lsundials_kinsol";
-        sun_flib="-lsundials_fkinsol";
-        ;;  
-esac
-
-case $vector in
-    s)
-        nvec_lib="-lsundials_nvecserial";
-        nvec_flib="-lsundials_fnvecserial";
-        ;;
-    p)
-        nvec_lib="-lsundials_nvecparallel";
-        nvec_flib="-lsundials_fnvecparallel";
-        ;;
-esac
-
-case $lang in
-    c)
-        cppflags=$includes;
-        libs="$libdirs $sun_lib $nvec_lib @LIBS@";
-        ;;
-    f)
-        cppflags=;
-        if test $module = cvodes ; then
-            libs="Fortran interface not available for CVODES";
-        else
-            libs="$libdirs $sun_flib $sun_lib $nvec_flib $nvec_lib @LIBS@ @FLIBS@";
-        fi
-        ;;
-esac
-
-case $show in
-    cppflags)
-        echo $cppflags
-        ;;
-    libs)
-        echo $libs
-        ;;
-    both)
-        echo $cppflags
-        echo $libs
-        ;;
-esac
-
-# end script
diff --git a/config.hin b/config.hin
deleted file mode 100644
index 4a7e8d2..0000000
--- a/config.hin
+++ /dev/null
@@ -1,97 +0,0 @@
-/* config.hin.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <float.h> header file. */
-#undef HAVE_FLOAT_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
-
-/* Define to 1 if you have the <math.h> header file. */
-#undef HAVE_MATH_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* The size of a `double', as computed by sizeof. */
-#undef SIZEOF_DOUBLE
-
-/* The size of a `float', as computed by sizeof. */
-#undef SIZEOF_FLOAT
-
-/* The size of a `int', as computed by sizeof. */
-#undef SIZEOF_INT
-
-/* The size of a `long double', as computed by sizeof. */
-#undef SIZEOF_LONG_DOUBLE
-
-/* The size of a `long int', as computed by sizeof. */
-#undef SIZEOF_LONG_INT
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Availability of Blas/Lapack libraries */
-#undef SUNDIALS_BLAS_LAPACK
-
-/* Define SUNDIALS data type 'realtype' as 'double' */
-#undef SUNDIALS_DOUBLE_PRECISION
-
-/* Define SUNDIALS data type 'realtype' as 'long double' */
-#undef SUNDIALS_EXTENDED_PRECISION
-
-/* FCMIX: Define name-mangling macro for C identifiers */
-#undef SUNDIALS_F77_FUNC
-
-/* FCMIX: Define name-mangling macro for C identifiers with underscores */
-#undef SUNDIALS_F77_FUNC_
-
-/* FNVECTOR: Allow user to specify different MPI communicator */
-#undef SUNDIALS_MPI_COMM_F2C
-
-/* Define SUNDIALS data type 'realtype' as 'float' */
-#undef SUNDIALS_SINGLE_PRECISION
-
-/* Use generic math functions */
-#undef SUNDIALS_USE_GENERIC_MATH
diff --git a/config/CheckFortranFunctionExists.cmake b/config/CheckFortranFunctionExists.cmake
deleted file mode 100644
index b6b9444..0000000
--- a/config/CheckFortranFunctionExists.cmake
+++ /dev/null
@@ -1,49 +0,0 @@
-# - Check if the Fortran function exists.
-# CHECK_FORTRAN_FUNCTION_EXISTS(FUNCTION VARIABLE)
-# - macro which checks if the Fortran function exists
-#  FUNCTION - the name of the Fortran function
-#  VARIABLE - variable to store the result
-#
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
-#
-#  CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-
-macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
-  if(NOT DEFINED ${VARIABLE})
-    message(STATUS "Looking for Fortran ${FUNCTION}")
-    if(CMAKE_REQUIRED_LIBRARIES)
-      set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
-    else(CMAKE_REQUIRED_LIBRARIES)
-      set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
-    endif(CMAKE_REQUIRED_LIBRARIES)
-    FILE(WRITE
-    ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
-    "
-      program TESTFortran
-      external ${FUNCTION}
-      end
-    "
-    )
-    try_compile(${VARIABLE}
-    ${CMAKE_BINARY_DIR}
-    ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
-    CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}"
-    OUTPUT_VARIABLE OUTPUT
-    )
-    if(${VARIABLE})
-      set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}")
-      message(STATUS "Looking for Fortran ${FUNCTION} - found")
-      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
-        "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n"
-        "${OUTPUT}\n\n")
-    else(${VARIABLE})
-      message(STATUS "Looking for Fortran ${FUNCTION} - not found")
-      set(${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}")
-      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
-        "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n"
-        "${OUTPUT}\n\n")
-    endif(${VARIABLE})
-  endif(NOT DEFINED ${VARIABLE})
-endmacro(CHECK_FORTRAN_FUNCTION_EXISTS)
diff --git a/config/FindBLAS.cmake b/config/FindBLAS.cmake
deleted file mode 100644
index 52f445b..0000000
--- a/config/FindBLAS.cmake
+++ /dev/null
@@ -1,186 +0,0 @@
-# - Find BLAS library
-# This module finds an installed fortran library that implements the BLAS 
-# linear-algebra interface (see http://www.netlib.org/blas/).  
-# The list of libraries searched for is taken
-# from the autoconf macro file, acx_blas.m4 (distributed at
-# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
-#
-# This module sets the following variables:
-#  BLAS_FOUND - set to true if a library implementing the BLAS interface
-#    is found
-#  BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
-#    and -L).
-#  BLAS_LIBRARIES - uncached list of libraries (using full path name) to 
-#    link against to use BLAS
-#
-
-include(CheckFortranFunctionExists)
-
-macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list)
-# This macro checks for the existence of the combination of fortran libraries
-# given by _list.  If the combination is found, this macro checks (using the 
-# Check_Fortran_Function_Exists macro) whether can link against that library
-# combination using the name of a routine given by _name using the linker
-# flags given by _flags.  If the combination of libraries is found and passes
-# the link test, LIBRARIES is set to the list of complete library paths that
-# have been found.  Otherwise, LIBRARIES is set to FALSE.
- 
-# N.B. _prefix is the prefix applied to the names of all cached variables that
-# are generated internally and marked advanced by this macro.
-
-set(_libraries_work TRUE)
-set(${LIBRARIES})
-set(_combined_name)
-foreach(_library ${_list})
-  set(_combined_name ${_combined_name}_${_library})
-  if(_libraries_work)
-    find_library(${_prefix}_${_library}_LIBRARY
-    NAMES ${_library}
-    PATHS /usr/local/lib /usr/lib
-    )
-    mark_as_advanced(${_prefix}_${_library}_LIBRARY)
-    set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
-    set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
-  endif(_libraries_work)
-endforeach(_library ${_list})
-if(_libraries_work)
-  # Test this combination of libraries.
-  set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}})
-  #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
-  check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
-  set(CMAKE_REQUIRED_LIBRARIES)
-  mark_as_advanced(${_prefix}${_combined_name}_WORKS)
-  set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
-endif(_libraries_work)
-if(NOT _libraries_work)
-  set(${LIBRARIES} FALSE)
-endif(NOT _libraries_work)
-#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
-endmacro(Check_Fortran_Libraries)
-
-set(BLAS_LINKER_FLAGS)
-set(BLAS_LIBRARIES)
-if(NOT BLAS_LIBRARIES)
-  # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  cblas_dgemm
-  ""
-  "cblas;f77blas;atlas"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  ""
-  "sgemm;dgemm;blas"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-# BLAS in Alpha CXML library?
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  ""
-  "cxml"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-# BLAS in Alpha DXML library? (now called CXML, see above)
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  ""
-  "dxml"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-# BLAS in Sun Performance library?
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  "-xlic_lib=sunperf"
-  "sunperf;sunmath"
-  )
-  if(BLAS_LIBRARIES)
-    set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
-  endif(BLAS_LIBRARIES)
-  
-endif(NOT BLAS_LIBRARIES)
-
-# BLAS in SCSL library?  (SGI/Cray Scientific Library)
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  ""
-  "scsl"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-# BLAS in SGIMATH library?
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  ""
-  "complib.sgimath"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  ""
-  "essl;blas"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-# Generic BLAS library?
-if(NOT BLAS_LIBRARIES)
-  check_fortran_libraries(
-  BLAS_LIBRARIES
-  BLAS
-  sgemm
-  ""
-  "blas"
-  )
-endif(NOT BLAS_LIBRARIES)
-
-if(BLAS_LIBRARIES)
-  set(BLAS_FOUND TRUE)
-else(BLAS_LIBRARIES)
-  set(BLAS_FOUND FALSE)
-endif(BLAS_LIBRARIES)
-
-if(NOT BLAS_FIND_QUIETLY)
-  if(BLAS_FOUND)
-    message(STATUS "A library with BLAS API found.")
-  else(BLAS_FOUND)
-    if(BLAS_FIND_REQUIRED)
-      message(FATAL_ERROR 
-      "A library with BLAS API not found. Please specify library location."
-      )
-    else(BLAS_FIND_REQUIRED)
-      message(STATUS
-      "A library with BLAS API not found. Please specify library location."
-      )
-    endif(BLAS_FIND_REQUIRED)
-  endif(BLAS_FOUND)
-endif(NOT BLAS_FIND_QUIETLY)
diff --git a/config/FindHypre.cmake b/config/FindHypre.cmake
new file mode 100644
index 0000000..3116792
--- /dev/null
+++ b/config/FindHypre.cmake
@@ -0,0 +1,47 @@
+# ---------------------------------------------------------------
+# $Revision: 4713 $
+# $Date: 2016-03-28 07:20:43 -0700 (Mon, 28 Mar 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Slaven Peles @ LLNL, Jean Sexton @ SMU,
+#              Eddy Banks @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# - Find hypre
+
+#  HYPRE_INCLUDE_DIR = cached location of HYPRE.h
+#  HYPRE_LIBRARY    = cached list of HYPRE library to link in
+
+### Find include dir
+find_path(temp_HYPRE_INCLUDE_DIR hypre.h ${HYPRE_INCLUDE_DIR})
+if (temp_HYPRE_INCLUDE_DIR)
+    set(HYPRE_INCLUDE_DIR ${temp_HYPRE_INCLUDE_DIR})
+endif()
+unset(temp_HYPRE_INCLUDE_DIR CACHE)
+    
+if (HYPRE_LIBRARY)
+    # We have (or were given) HYPRE_LIBRARY - get path to use for any related libs
+    get_filename_component(HYPRE_LIBRARY_DIR ${HYPRE_LIBRARY} PATH)
+
+    # force CACHE update to show user DIR that will be used
+    set(HYPRE_LIBRARY_DIR ${HYPRE_LIBRARY_DIR} CACHE PATH "" FORCE)
+    
+else ()
+    # find library with user provided directory path
+    set(HYPRE_LIBRARY_NAMES hypre HYPRE)
+    find_library(HYPRE_LIBRARY 
+      NAMES ${HYPRE_LIBRARY_NAMES}
+      PATHS ${HYPRE_LIBRARY_DIR} NO_DEFAULT_PATH
+      )
+endif ()
+mark_as_advanced(HYPRE_LIBRARY)
+
+set(HYPRE_LIBRARIES ${HYPRE_LIBRARY})
diff --git a/config/FindKLU.cmake b/config/FindKLU.cmake
new file mode 100644
index 0000000..d80bb6e
--- /dev/null
+++ b/config/FindKLU.cmake
@@ -0,0 +1,73 @@
+# ---------------------------------------------------------------
+# $Revision: 4957 $
+# $Date: 2016-09-23 12:21:47 -0700 (Fri, 23 Sep 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# Find KLU library.
+# 
+# Set library prefixes for Windows
+IF(WIN32)
+  set(CMAKE_FIND_LIBRARY_PREFIXES lib ${CMAKE_FIND_LIBRARY_PREFIXES})
+endif()
+
+### Find include dir
+find_path(temp_KLU_INCLUDE_DIR klu.h ${KLU_INCLUDE_DIR})
+if (temp_KLU_INCLUDE_DIR)
+    set(KLU_INCLUDE_DIR ${temp_KLU_INCLUDE_DIR})
+endif()
+unset(temp_KLU_INCLUDE_DIR CACHE)
+    
+if (KLU_LIBRARY)
+    # We have (or were given) KLU_LIBRARY - get path to use for other Suitesparse libs
+    get_filename_component(KLU_LIBRARY_DIR ${KLU_LIBRARY} PATH)
+
+    # force CACHE update to show user DIR that will be used
+    set(KLU_LIBRARY_DIR ${KLU_LIBRARY_DIR} CACHE PATH "" FORCE)
+    
+else ()
+    # find library with user provided directory path
+    set(KLU_LIBRARY_NAME klu)
+    find_library(KLU_LIBRARY ${KLU_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH)
+endif ()
+mark_as_advanced(KLU_LIBRARY)
+
+if (NOT AMD_LIBRARY)
+    set(AMD_LIBRARY_NAME amd)
+    FIND_LIBRARY(AMD_LIBRARY ${AMD_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH)
+    mark_as_advanced(AMD_LIBRARY)
+endif ()
+
+if (NOT COLAMD_LIBRARY)
+    set(COLAMD_LIBRARY_NAME colamd)
+    FIND_LIBRARY(COLAMD_LIBRARY ${COLAMD_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH)
+    mark_as_advanced(COLAMD_LIBRARY)
+endif ()
+
+if (NOT BTF_LIBRARY)
+    set(BTF_LIBRARY_NAME btf)
+    FIND_LIBRARY( BTF_LIBRARY ${BTF_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH)
+    mark_as_advanced(BTF_LIBRARY)
+endif ()
+
+if (NOT SUITESPARSECONFIG_LIBRARY)
+    set(SUITESPARSECONFIG_LIBRARY_NAME suitesparseconfig)
+    # NOTE: no prefix for this library on windows
+    if (WIN32)
+        set(CMAKE_FIND_LIBRARY_PREFIXES "")
+    endif()
+    FIND_LIBRARY( SUITESPARSECONFIG_LIBRARY ${SUITESPARSECONFIG_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH)
+    mark_as_advanced(SUITESPARSECONFIG_LIBRARY)
+endif ()
+
+set(KLU_LIBRARIES ${KLU_LIBRARY} ${AMD_LIBRARY} ${COLAMD_LIBRARY} ${BTF_LIBRARY} ${SUITESPARSECONFIG_LIBRARY})
diff --git a/config/FindLAPACK.cmake b/config/FindLAPACK.cmake
deleted file mode 100644
index 8c2ca6e..0000000
--- a/config/FindLAPACK.cmake
+++ /dev/null
@@ -1,96 +0,0 @@
-# - Find LAPACK library
-# This module finds an installed fortran library that implements the LAPACK
-# linear-algebra interface (see http://www.netlib.org/lapack/).
-#
-# The approach follows that taken for the autoconf macro file, acx_lapack.m4
-# (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
-#
-# This module sets the following variables:
-#  LAPACK_FOUND - set to true if a library implementing the LAPACK interface
-#    is found
-#  LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
-#    and -L).
-#  LAPACK_LIBRARIES - uncached list of libraries (using full path name) to 
-#    link against to use LAPACK
-#
-
-include(CheckFortranFunctionExists)
-set(LAPACK_FOUND FALSE)
-
-if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-  find_package(BLAS)
-else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-  find_package(BLAS REQUIRED)
-endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-
-if(BLAS_FOUND)
-  set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
-  # LAPACK linked to by default?  (is sometimes included in BLAS lib)
-  set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LINKER_FLAGS} ${BLAS_LIBRARIES})
-  check_fortran_function_exists(cheev LAPACK_BLAS_WORKS)
-  mark_as_advanced(LAPACK_BLAS_WORKS)
-  if(LAPACK_BLAS_WORKS)
-    set(LAPACK_FOUND TRUE)
-    set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
-  endif(LAPACK_BLAS_WORKS)
-  # Generic LAPACK library?
-  if(NOT LAPACK_FOUND)
-    find_library(LAPACK_LAPACK_LIBRARY
-    NAMES lapack
-    PATHS /usr/local/lib /usr/lib
-    )
-    mark_as_advanced(LAPACK_LAPACK_LIBRARY)
-    if(LAPACK_LAPACK_LIBRARY)
-      set(LAPACK_LIBRARIES ${LAPACK_LAPACK_LIBRARY} ${BLAS_LIBRARIES})
-      # Test this combination of libraries.
-      set(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LINKER_FLAGS} ${LAPACK_LIBRARIES})
-      check_fortran_function_exists(cheev LAPACK_LAPACK_WORKS)
-      mark_as_advanced(LAPACK_LAPACK_WORKS)
-      set(CMAKE_REQUIRED_LIBRARIES)
-      if(LAPACK_LAPACK_WORKS)
-        set(LAPACK_FOUND TRUE)
-      else(LAPACK_LAPACK_WORKS)
-        set(LAPACK_LIBRARIES)
-      endif(LAPACK_LAPACK_WORKS)
-    endif(LAPACK_LAPACK_LIBRARY)
-  endif(NOT LAPACK_FOUND)
-  # Generic LAPACK rs6k library?
-  if(NOT LAPACK_FOUND)
-    find_library(LAPACK_RS6K_LIBRARY
-    NAMES lapack_rs6k
-    PATHS /usr/local/lib /usr/lib
-    )
-    mark_as_advanced(LAPACK_RS6K_LIBRARY)
-    if(LAPACK_RS6K_LIBRARY)
-      set(LAPACK_LIBRARIES ${LAPACK_RS6K_LIBRARY} ${BLAS_LIBRARIES})
-      # Test this combination of libraries.
-      set(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LINKER_FLAGS} ${LAPACK_LIBRARIES})
-      check_fortran_function_exists(cheev LAPACK_RS6K_WORKS)
-      mark_as_advanced(LAPACK_RS6K_WORKS)
-      set(CMAKE_REQUIRED_LIBRARIES)
-      if(LAPACK_RS6K_WORKS)
-        set(LAPACK_FOUND TRUE)
-      else(LAPACK_RS6K_WORKS)
-        set(LAPACK_LIBRARIES)
-      endif(LAPACK_RS6K_WORKS)
-    endif(LAPACK_RS6K_LIBRARY)
-  endif(NOT LAPACK_FOUND)
-else(BLAS_FOUND)
-  message(STATUS "LAPACK requires BLAS")
-endif(BLAS_FOUND)
-
-if(NOT LAPACK_FIND_QUIETLY)
-  if(LAPACK_FOUND)
-    message(STATUS "A library with LAPACK API found.")
-  else(LAPACK_FOUND)
-    if(LAPACK_FIND_REQUIRED)
-      message(FATAL_ERROR 
-      "A library with LAPACK API not found. Please specify library location."
-      )
-    else(LAPACK_FIND_REQUIRED)
-      message(STATUS
-      "A library with LAPACK API not found. Please specify library location."
-      )
-    endif(LAPACK_FIND_REQUIRED)
-  endif(LAPACK_FOUND)
-endif(NOT LAPACK_FIND_QUIETLY)
diff --git a/config/FindPETSc.cmake b/config/FindPETSc.cmake
new file mode 100644
index 0000000..7c1f736
--- /dev/null
+++ b/config/FindPETSc.cmake
@@ -0,0 +1,48 @@
+# ---------------------------------------------------------------
+# $Revision:  $
+# $Date:  $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# Find PETSC library.
+# 
+
+IF(WIN32)
+  set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
+endif(WIN32)
+
+### Find include dir
+find_path(temp_PETSC_INCLUDE_DIR petsc.h ${PETSC_INCLUDE_DIR})
+if (temp_PETSC_INCLUDE_DIR)
+    set(PETSC_INCLUDE_DIR ${temp_PETSC_INCLUDE_DIR})
+endif()
+unset(temp_PETSC_INCLUDE_DIR CACHE)
+
+if (PETSC_LIBRARY)
+    # We have (or were given) PETSC_LIBRARY - get path to use for any related libs
+    get_filename_component(PETSC_LIBRARY_DIR ${PETSC_LIBRARY} PATH)
+    
+    # force CACHE update to show user DIR that will be used
+    set(PETSC_LIBRARY_DIR ${PETSC_LIBRARY_DIR} CACHE PATH "" FORCE)
+    
+else ()
+    # find library with user provided directory path
+    set(PETSC_LIBRARY_NAMES petsc PETSC)
+    find_library(PETSC_LIBRARY 
+      NAMES ${PETSC_LIBRARY_NAMES}
+      PATHS ${PETSC_LIBRARY_DIR} NO_DEFAULT_PATH
+      )
+endif ()
+mark_as_advanced(PETSC_LIBRARY)
+
+set(PETSC_LIBRARIES ${PETSC_LIBRARY})
diff --git a/config/FindSUPERLUMT.cmake b/config/FindSUPERLUMT.cmake
new file mode 100644
index 0000000..25c4c3f
--- /dev/null
+++ b/config/FindSUPERLUMT.cmake
@@ -0,0 +1,85 @@
+# ---------------------------------------------------------------
+# $Revision: 4957 $
+# $Date: 2016-09-23 12:21:47 -0700 (Fri, 23 Sep 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Eddy Banks @ LLNL
+# ---------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# SUPERLUMT tests for SUNDIALS CMake-based configuration.
+# 
+
+# make sure valid thread type - if not, then warn and return
+STRING(TOUPPER "${SUPERLUMT_THREAD_TYPE}" SUPERLUMT_THREAD_TYPE_UPPER)
+If(SUPERLUMT_THREAD_TYPE AND NOT SUPERLUMT_THREAD_TYPE_UPPER STREQUAL "OPENMP" AND NOT SUPERLUMT_THREAD_TYPE_UPPER STREQUAL "PTHREAD")
+    PRINT_WARNING("Unknown thread type: ${SUPERLUMT_THREAD_TYPE}" "Please enter Pthread or OpenMP")
+ENDIF(SUPERLUMT_THREAD_TYPE AND NOT SUPERLUMT_THREAD_TYPE_UPPER STREQUAL "OPENMP" AND NOT SUPERLUMT_THREAD_TYPE_UPPER STREQUAL "PTHREAD")
+
+# find the SUPERLUMT include directory path
+IF(SUPERLUMT_THREAD_TYPE)
+    # if have user input for thread type - set postfix of library name
+    set(POST ${SUPERLUMT_THREAD_TYPE_UPPER})
+
+    ### Find include dir
+    find_path(temp_SUPERLUMT_INCLUDE_DIR slu_mt_ddefs.h ${SUPERLUMT_INCLUDE_DIR})
+    if (temp_SUPERLUMT_INCLUDE_DIR)
+        set(SUPERLUMT_INCLUDE_DIR ${temp_SUPERLUMT_INCLUDE_DIR})
+    endif()
+    unset(temp_SUPERLUMT_INCLUDE_DIR CACHE)
+    
+ENDIF(SUPERLUMT_THREAD_TYPE)
+
+IF(MSVC)
+  SET(CMAKE_FIND_LIBRARY_PREFIXES lib ${CMAKE_FIND_LIBRARY_PREFIXES})
+ENDIF()
+
+if(SUPERLUMT_LIBRARY)
+    get_filename_component(SUPERLUMT_LIBRARY_DIR ${SUPERLUMT_LIBRARY} PATH)
+    set(SUPERLUMT_LIBRARY_DIR ${SUPERLUMT_LIBRARY_DIR} CACHE PATH "" FORCE)
+    
+else()
+    # find library with user provided directory path
+    set(SUPERLUMT_LIBRARY_NAME superlu_mt_${POST})
+    find_library(SUPERLUMT_LIBRARY ${SUPERLUMT_LIBRARY_NAME} ${SUPERLUMT_LIBRARY_DIR} NO_DEFAULT_PATH)
+endif()
+mark_as_advanced(SUPERLUMT_LIBRARY)
+    
+# add threading library (pthread or openmp)
+If(SUPERLUMT_THREAD_TYPE_UPPER STREQUAL "PTHREAD")
+  # add pthread to libraries
+  find_library(SUPERLUMT_THREAD_LIBRARY
+      NAMES pthread
+      PATHS /usr/lib /usr/local/lib
+      "$ENV{ProgramFiles}/SUPERLUMT/Lib"
+      )
+ELSE(SUPERLUMT_THREAD_TYPE_UPPER STREQUAL "OPENMP")
+  # add openmp to libraries
+  find_package( OpenMP REQUIRED)
+  if(OPENMP_FOUND)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+    #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
+  endif()  
+ENDIF()
+mark_as_advanced(SUPERLUMT_THREAD_LIBRARY)
+
+# add to SUPERLUMT_LIBRARIES (Note: will be 'not found' if either are not found 
+set(SUPERLUMT_LIBRARIES ${SUPERLUMT_LIBRARY} ${SUPERLUMT_THREAD_LIBRARY})
+
+# If LAPACK/BLAS not enabled - find BLAS with SUPERLUMT
+if(NOT LAPACK_ENABLE)
+    set(SUPERLUMT_BLAS_LIBRARY_NAME blas_${POST})
+    
+    #unset(SUPERLUMT_BLAS_LIBRARIES CACHE)
+    FIND_LIBRARY(SUPERLUMT_BLAS_LIBRARIES ${SUPERLUMT_BLAS_LIBRARY_NAME} ${SUPERLUMT_LIBRARY_DIR} NO_DEFAULT_PATH)
+    
+    if (NOT SUPERLUMT_BLAS_LIBRARIES)
+      PRINT_WARNING("Can't find SUPERLUMT_BLAS_LIBRARY" "Try setting LAPACK_ENABLE to ON")
+    else ()
+      set(SUPERLUMT_LIBRARIES ${SUPERLUMT_LIBRARIES} ${SUPERLUMT_BLAS_LIBRARIES})
+    endif ()
+    mark_as_advanced(SUPERLUMT_BLAS_LIBRARIES)
+endif(NOT LAPACK_ENABLE)
diff --git a/config/SundialsAddTest.cmake b/config/SundialsAddTest.cmake
new file mode 100644
index 0000000..3ce3bf8
--- /dev/null
+++ b/config/SundialsAddTest.cmake
@@ -0,0 +1,93 @@
+# ---------------------------------------------------------------
+# Author:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2013, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+#
+# SUNDIALS_ADD_TEST(<test name> <executable> )
+# 
+# Add Sundials regression test.
+
+# Executable is run and output is compared with output in the
+# test/answers directory.  If output differs significantly then test
+# fails.  Default signicance is 4 decimal points for floating values
+# and 10% for integer values.
+
+IF(EXAMPLES_ENABLE)
+
+  find_package(PythonInterp)
+  IF(${PYTHON_VERSION_MAJOR} LESS 3)
+      IF(${PYTHON_VERSION_MINOR} LESS 7)
+	message( WARNING "***************************************************************************\nWARNING\nPython version must be 2.7.x or greater in order to run regression tests.\nExamples will build but 'make test' will fail.\n***************************************************************************")
+      ENDIF()
+  ENDIF()
+
+  FIND_PROGRAM(TESTRUNNER testRunner PATHS test)
+ENDIF(EXAMPLES_ENABLE)
+
+macro(SUNDIALS_ADD_TEST NAME EXECUTABLE)
+
+  set(options "")
+  set(oneValueArgs "MPI_NPROCS" "ANSWER_FILE" "FLOAT_PRECISION" "INTEGER_PERCENTAGE")
+  set(multiValueArgs "TEST_ARGS")
+
+  CMAKE_PARSE_ARGUMENTS(SUNDIALS_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+  # SGS add check to make sure parallel is integer
+  # SGS add check for float and integer precision
+
+  set(TEST_ARGS  "-v" "--testname=${NAME}" 
+    "--executablename=$<TARGET_FILE:${EXECUTABLE}>"
+    "--answersdir=${CMAKE_SOURCE_DIR}/test/answers"
+    "--outputdir=${CMAKE_BINARY_DIR}/Testing/output"
+    )
+
+  IF("${SUNDIALS_ADD_TEST_MPI_NPROCS}" STREQUAL "")
+  ELSE()
+
+    IF(MPI_ENABLE)
+      IF(MPI_RUN_COMMAND MATCHES "srun")
+	set(RUN_COMMAND "srun -N1 -n${SUNDIALS_ADD_TEST_MPI_NPROCS} -ppdebug")
+      ELSE(MPI_RUN_COMMAND MATCHES "srun")
+	set(RUN_COMMAND "mpirun -n ${SUNDIALS_ADD_TEST_MPI_NPROCS}")
+      ENDIF(MPI_RUN_COMMAND MATCHES "srun")
+      
+      LIST(APPEND TEST_ARGS "--runcommand=\"${RUN_COMMAND}\"")
+
+    ENDIF(MPI_ENABLE)
+
+  ENDIF()
+  
+  IF("${SUNDIALS_ADD_TEST_TEST_ARGS}" STREQUAL "")
+  ELSE()
+    string (REPLACE ";" " " USER_ARGS "${SUNDIALS_ADD_TEST_TEST_ARGS}")
+    LIST(APPEND TEST_ARGS "--runargs=\"${USER_ARGS}\"")
+  ENDIF()
+
+  IF("${SUNDIALS_ADD_TEST_ANSWER_FILE}" STREQUAL "")
+  ELSE()
+    LIST(APPEND TEST_ARGS "--answerfile=${SUNDIALS_ADD_TEST_ANSWER_FILE}")
+  ENDIF()
+
+  IF("${SUNDIALS_ADD_TEST_FLOAT_PRECISION}" STREQUAL "")
+  ELSE()
+    LIST(APPEND TEST_ARGS "--floatprecision=${SUNDIALS_ADD_TEST_FLOAT_PRECISION}")
+  ENDIF()
+
+  IF("${SUNDIALS_ADD_TEST_INTEGER_PERCENTAGE}" STREQUAL "")
+  ELSE()
+    LIST(APPEND TEST_ARGS "--integerpercentage=${SUNDIALS_ADD_TEST_INTEGER_PERCENTAGE}")
+  ENDIF()
+
+  ADD_TEST(NAME ${NAME}
+    COMMAND ${PYTHON_EXECUTABLE} ${TESTRUNNER} ${TEST_ARGS})
+
+endmacro()
diff --git a/config/SundialsCXX.cmake b/config/SundialsCXX.cmake
new file mode 100644
index 0000000..14a757a
--- /dev/null
+++ b/config/SundialsCXX.cmake
@@ -0,0 +1,61 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# C++-related tests for SUNDIALS CMake-based configuration.
+
+set(CXX_FOUND FALSE)
+
+include(CMakeDetermineCXXCompiler)
+
+if(CMAKE_CXX_COMPILER)
+  message(STATUS "Searching for a C++ compiler... ${CMAKE_CXX_COMPILER}")
+  # Enable the language for next steps
+  enable_language(CXX)
+  mark_as_advanced(CLEAR 
+    CMAKE_CXX_COMPILER
+    CMAKE_CXX_FLAGS
+    CMAKE_CXX_FLAGS_DEBUG
+    CMAKE_CXX_FLAGS_MINSIZEREL
+    CMAKE_CXX_FLAGS_RELEASE
+    CMAKE_CXX_FLAGS_RELWITHDEB)
+  # Create the CXXTest directory
+  set(CXXTest_DIR ${PROJECT_BINARY_DIR}/CXXTest)
+  file(MAKE_DIRECTORY ${CXXTest_DIR})
+  # Create a CMakeLists.txt file which will generate the executable "cxxtest"
+  file(WRITE ${CXXTest_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+    "PROJECT(cxxtest CXX)\n"
+    "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+    "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+    "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\")\n"
+    "SET(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE}\")\n"
+    "SET(CMAKE_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG}\")\n"
+    "SET(CMAKE_CXX_FLAGS_RELWITHDEBUGINFO \"${CMAKE_CXX_FLAGS_RELWITHDEBUGINFO}\")\n"
+    "SET(CMAKE_CXX_FLAGS_MINSIZE \"${CMAKE_CXX_FLAGS_MINSIZE}\")\n"
+    "ADD_EXECUTABLE(cxxtest cxxtest.cpp)\n")
+  # Create the C++ source cxxtest.cpp which does some simple calls
+  file(WRITE ${CXXTest_DIR}/cxxtest.cpp
+    "#include <string>\n"
+    "int main(){\n"
+    "std::string c;\n"
+    "return(0);\n"
+    "}\n")
+  # Use TRY_COMPILE to make the target "cxxtest"
+  try_compile(CXXTEST_OK ${CXXTest_DIR} ${CXXTest_DIR}
+    ftest OUTPUT_VARIABLE MY_OUTPUT)
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${CXXTest_DIR}/CMakeFiles)
+  # Proceed based on test results
+  if(CXXTEST_OK)
+    message(STATUS "Trying to compile and link a simple C++ program... OK")
+    set(CXX_FOUND TRUE)
+  endif(CXXTEST_OK)
+else(CMAKE_CXX_COMPILER)
+  message(STATUS "Searching for a C++ compiler... FAILED")
+endif(CMAKE_CXX_COMPILER)
+
diff --git a/config/SundialsFortran.cmake b/config/SundialsFortran.cmake
index 39addcf..4fe16e7 100644
--- a/config/SundialsFortran.cmake
+++ b/config/SundialsFortran.cmake
@@ -1,6 +1,6 @@
 # ---------------------------------------------------------------
-# $Revision: 1.1 $
-# $Date: 2009/02/17 02:58:46 $
+# $Revision: 4511 $
+# $Date: 2015-06-29 16:48:09 -0700 (Mon, 29 Jun 2015) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
@@ -51,6 +51,7 @@ if(CMAKE_Fortran_COMPILER)
   # Create a CMakeLists.txt file which will generate the "flib" library
   # and an executable "ftest"
   file(WRITE ${FortranTest_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
     "PROJECT(ftest Fortran)\n"
     "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
     "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
@@ -89,6 +90,7 @@ if(CMAKE_Fortran_COMPILER)
     # Infer Fortran name-mangling scheme for symbols WITHOUT underscores.
     # Overwrite CMakeLists.txt with one which will generate the "ctest1" executable
     file(WRITE ${FortranTest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(ctest1 C)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
@@ -133,6 +135,7 @@ if(CMAKE_Fortran_COMPILER)
     # Infer Fortran name-mangling scheme for symbols WITH underscores.
     # Practically a duplicate of the previous steps.
     file(WRITE ${FortranTest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(ctest2 C)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
diff --git a/config/SundialsFortran90.cmake b/config/SundialsFortran90.cmake
new file mode 100644
index 0000000..efc9fe1
--- /dev/null
+++ b/config/SundialsFortran90.cmake
@@ -0,0 +1,72 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# Fortran90-related tests for SUNDIALS CMake-based configuration.
+
+set(F90_FOUND FALSE)
+include(CMakeDetermineFortranCompiler)
+
+if(CMAKE_Fortran_COMPILER)
+  message(STATUS "Searching for a Fortran compiler... ${CMAKE_Fortran_COMPILER}")
+  # Enable the language for next steps
+  enable_language(Fortran)
+  mark_as_advanced(CLEAR 
+    CMAKE_Fortran_COMPILER
+    CMAKE_Fortran_FLAGS
+    CMAKE_Fortran_FLAGS_DEBUG
+    CMAKE_Fortran_FLAGS_MINSIZEREL
+    CMAKE_Fortran_FLAGS_RELEASE
+    CMAKE_Fortran_FLAGS_RELWITHDEB)
+  # Create the Fortran90Test directory
+  set(Fortran90Test_DIR ${PROJECT_BINARY_DIR}/Fortran90Test)
+  file(MAKE_DIRECTORY ${Fortran90Test_DIR})
+  # Create a CMakeLists.txt file which will generate the "f90lib" library
+  # and an executable "f90test"
+  file(WRITE ${Fortran90Test_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+    "PROJECT(f90test Fortran)\n"
+    "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+    "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+    "SET(CMAKE_Fortran_FLAGS \"${CMAKE_Fortran_FLAGS}\")\n"
+    "SET(CMAKE_Fortran_FLAGS_RELEASE \"${CMAKE_Fortran_FLAGS_RELEASE}\")\n"
+    "SET(CMAKE_Fortran_FLAGS_DEBUG \"${CMAKE_Fortran_FLAGS_DEBUG}\")\n"
+    "SET(CMAKE_Fortran_FLAGS_RELWITHDEBUGINFO \"${CMAKE_Fortran_FLAGS_RELWITHDEBUGINFO}\")\n"
+    "SET(CMAKE_Fortran_FLAGS_MINSIZE \"${CMAKE_Fortran_FLAGS_MINSIZE}\")\n"
+    "ADD_LIBRARY(f90lib f90lib.f90)\n"
+    "ADD_EXECUTABLE(f90test f90test.f90)\n"
+    "TARGET_LINK_LIBRARIES(f90test f90lib)\n")
+  # Create the Fortran source f90lib.f90 which defines two subroutines, "mysub" and "my_sub"
+  file(WRITE ${Fortran90Test_DIR}/f90lib.f90
+    "subroutine mysub\n"
+    "  return\n"
+    "end\n"
+    "subroutine my_sub\n"
+    "  return\n"
+    "end\n")
+  # Create the Fortran source f90test.f90 which calls "mysub" and "my_sub"
+  file(WRITE ${Fortran90Test_DIR}/f90test.f90
+    "program f90test\n"
+    "  call mysub()\n"
+    "  call my_sub()\n"
+    "end\n")
+  # Use TRY_COMPILE to make the targets "f90lib" and "f90test"
+  try_compile(F90TEST_OK ${Fortran90Test_DIR} ${Fortran90Test_DIR}
+    f90test OUTPUT_VARIABLE MY_OUTPUT)
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${Fortran90Test_DIR}/CMakeFiles)
+  # Proceed based on test results
+  if(F90TEST_OK)
+    message(STATUS "Trying to compile and link a simple Fortran90 program... OK")
+    set(F90_FOUND TRUE)
+  else(F90TEST_OK)
+    message(STATUS "Trying to compile and link a simple Fortran90 program... FAILED")
+  endif(F90TEST_OK)
+else(CMAKE_Fortran_COMPILER)
+  message(STATUS "Searching for a Fortran compiler... FAILED")
+endif(CMAKE_Fortran_COMPILER)
+
diff --git a/config/SundialsHypre.cmake b/config/SundialsHypre.cmake
new file mode 100644
index 0000000..a065c6d
--- /dev/null
+++ b/config/SundialsHypre.cmake
@@ -0,0 +1,79 @@
+# ---------------------------------------------------------------
+# $Revision: 4713 $
+# $Date: 2016-03-28 07:20:43 -0700 (Mon, 28 Mar 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Slaven Peles @ LLNL, Jean Sexton @ SMU
+#              Eddy Banks @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# Hypre tests for SUNDIALS CMake-based configuration.
+# 
+### This is only set if running GUI - simply return first time enabled
+IF(HYPRE_DISABLED)
+  SET(HYPRE_DISABLED FALSE CACHE INTERNAL "GUI - now enabled" FORCE)
+  RETURN()
+ENDIF()
+
+set(HYPRE_FOUND FALSE)
+
+include(FindHypre)
+
+if(UNIX)
+  set(LINK_MATH_LIB "-lm")
+endif()
+
+if(HYPRE_LIBRARIES)
+  message(STATUS "Looking for HYPRE LIBRARIES...")
+  # Create the HYPRETest directory
+  set(HYPRETest_DIR ${PROJECT_BINARY_DIR}/HYPRETest)
+  file(MAKE_DIRECTORY ${HYPRETest_DIR})
+  # Create a CMakeLists.txt file 
+  file(WRITE ${HYPRETest_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.2)\n"
+    "PROJECT(ltest C)\n"
+    "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+    "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+    "SET(CMAKE_C_COMPILER ${MPI_MPICC})\n"
+    "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n"
+    "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n"
+    "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n"
+    "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n"
+    "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n"
+    "SET(CMAKE_EXE_LINKER_FLAGS \"${LINK_MATH_LIB}\")\n"
+    "INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR})\n"
+    "ADD_EXECUTABLE(ltest ltest.c)\n"
+    "TARGET_LINK_LIBRARIES(ltest ${HYPRE_LIBRARIES})\n")    
+  # Create a C source file which calls a hypre function
+  file(WRITE ${HYPRETest_DIR}/ltest.c
+    "\#include \"HYPRE_parcsr_ls.h\"\n"
+    "int main(){\n"
+    "HYPRE_ParVector par_b;\n"
+    "HYPRE_IJVector b;\n"
+    "return(0);\n"
+    "}\n")
+  # Attempt to link the "ltest" executable
+  try_compile(LTEST_OK ${HYPRETest_DIR} ${HYPRETest_DIR} ltest OUTPUT_VARIABLE MY_OUTPUT)
+      
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${HYPRETest_DIR}/CMakeFiles)
+  # Process test result
+  if(LTEST_OK)
+    message(STATUS "Checking if HYPRE works... OK")
+    set(HYPRE_FOUND TRUE)
+  else(LTEST_OK)
+    message(STATUS "Checking if HYPRE works... FAILED")
+  endif(LTEST_OK)
+else(HYPRE_LIBRARIES)
+  PRINT_WARNING("HYPRE LIBRARIES NOT Found. Please check library path" "${HYPRE_LIBRARY_DIR} ")
+  message(STATUS "Looking for HYPRE LIBRARY... FAILED")
+endif(HYPRE_LIBRARIES)
diff --git a/config/SundialsKLU.cmake b/config/SundialsKLU.cmake
new file mode 100644
index 0000000..9118314
--- /dev/null
+++ b/config/SundialsKLU.cmake
@@ -0,0 +1,73 @@
+# ---------------------------------------------------------------
+# $Revision: 4955 $
+# $Date: 2016-09-23 10:01:28 -0700 (Fri, 23 Sep 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# KLU tests for SUNDIALS CMake-based configuration.
+#    - loosely based on SundialsLapack.cmake
+#
+
+### This is only set if running GUI - simply return first time enabled
+IF(KLU_DISABLED)
+  SET(KLU_DISABLED FALSE CACHE INTERNAL "GUI - KLU now enabled" FORCE)
+  RETURN()
+ENDIF()
+
+SET(KLU_FOUND FALSE)
+
+# set KLU_LIBRARIES
+include(FindKLU)
+# If we have the KLU libraries, test them
+if(KLU_LIBRARIES)
+  message(STATUS "Looking for KLU libraries...")
+  # Create the KLUTest directory
+  set(KLUTest_DIR ${PROJECT_BINARY_DIR}/KLUTest)
+  file(MAKE_DIRECTORY ${KLUTest_DIR})
+  # Create a CMakeLists.txt file 
+  file(WRITE ${KLUTest_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+    "PROJECT(ltest C)\n"
+    "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+    "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+    "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n"
+    "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n"
+    "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n"
+    "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n"
+    "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n"
+    "INCLUDE_DIRECTORIES(${KLU_INCLUDE_DIR})\n"
+    "ADD_EXECUTABLE(ltest ltest.c)\n"
+    "TARGET_LINK_LIBRARIES(ltest ${KLU_LIBRARIES})\n")    
+# Create a C source file which calls a KLU function
+# SGS TODO what is a simple KLU method to invoke?
+  file(WRITE ${KLUTest_DIR}/ltest.c
+    "\#include \"klu.h\"\n"
+    "int main(){\n"
+    "klu_common Common;\n"
+    "klu_defaults (&Common);\n" 
+    "return(0);\n"
+    "}\n")
+  # Attempt to link the "ltest" executable
+  try_compile(LTEST_OK ${KLUTest_DIR} ${KLUTest_DIR} ltest OUTPUT_VARIABLE MY_OUTPUT)
+      
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${KLUTest_DIR}/CMakeFiles)
+  # Process test result
+  if(LTEST_OK)
+    message(STATUS "Checking if KLU works... OK")
+    set(KLU_FOUND TRUE)
+  else(LTEST_OK)
+    message(STATUS "Checking if KLU works... FAILED")
+  endif(LTEST_OK)
+else(KLU_LIBRARIES)
+  PRINT_WARNING("KLU LIBRARIES NOT Found. Please check library path" "${KLU_LIBRARY_DIR} ")
+  message(STATUS "Looking for KLU libraries... FAILED")
+endif(KLU_LIBRARIES)
+ 
+  
diff --git a/config/SundialsLapack.cmake b/config/SundialsLapack.cmake
index aa7a9e4..aa2f60d 100644
--- a/config/SundialsLapack.cmake
+++ b/config/SundialsLapack.cmake
@@ -1,6 +1,6 @@
 # ---------------------------------------------------------------
-# $Revision: 1.1 $
-# $Date: 2009/02/17 02:58:46 $
+# $Revision: 4511 $
+# $Date: 2015-06-29 16:48:09 -0700 (Mon, 29 Jun 2015) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
@@ -29,11 +29,7 @@ if(NOT LAPACK_LIBRARIES)
       )
   endif(F77_FOUND)
 endif(NOT LAPACK_LIBRARIES)
-# If using a GNU C compiler, it is quite likely we'll want LAPACK_LINKER_FLAGS
-# to include -lg2c (if not already present)
-if(CMAKE_COMPILER_IS_GNUCC AND NOT LAPACK_LINKER_FLAGS MATCHES "g2c")
-  set(LAPACK_LINKER_FLAGS "${LAPACK_LINKER_FLAGS} -lg2c")
-endif(CMAKE_COMPILER_IS_GNUCC AND NOT LAPACK_LINKER_FLAGS MATCHES "g2c")
+
 # If we have the LAPACK libraries, test them
 if(LAPACK_LIBRARIES)
   message(STATUS "Looking for LAPACK libraries... OK")
@@ -42,6 +38,7 @@ if(LAPACK_LIBRARIES)
   file(MAKE_DIRECTORY ${LapackTest_DIR})
   # Create a CMakeLists.txt file 
   file(WRITE ${LapackTest_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
     "PROJECT(ltest C)\n"
     "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
     "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
@@ -50,7 +47,6 @@ if(LAPACK_LIBRARIES)
     "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n"
     "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n"
     "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n"
-    "SET(CMAKE_EXE_LINKER_FLAGS \"\${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}\")\n"
     "ADD_EXECUTABLE(ltest ltest.c)\n"
     "TARGET_LINK_LIBRARIES(ltest ${LAPACK_LIBRARIES})\n")    
   # Create a C source file which calls a Blas function (dcopy) and an Lapack function (dgetrf)
diff --git a/config/SundialsMPIC.cmake b/config/SundialsMPIC.cmake
index c708e68..062fa69 100644
--- a/config/SundialsMPIC.cmake
+++ b/config/SundialsMPIC.cmake
@@ -1,6 +1,6 @@
 # ---------------------------------------------------------------
-# $Revision: 1.1 $
-# $Date: 2009/02/17 02:58:46 $
+# $Revision: 4511 $
+# $Date: 2015-06-29 16:48:09 -0700 (Mon, 29 Jun 2015) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
@@ -13,6 +13,11 @@
 #
 # 
 
+# make sure valid mpi_run_command. If not, then warn and return
+If(MPI_RUN_COMMAND AND NOT MPI_RUN_COMMAND STREQUAL "mpirun" AND NOT MPI_RUN_COMMAND STREQUAL "srun")
+    PRINT_WARNING("Unknown mpi run command: ${MPI_RUN_COMMAND}" "Please enter mpirun or srun")
+ENDIF(MPI_RUN_COMMAND AND NOT MPI_RUN_COMMAND STREQUAL "mpirun" AND NOT MPI_RUN_COMMAND STREQUAL "srun")
+
 set(MPIC_FOUND FALSE)
 set(MPIC_MPI2 FALSE)
 
@@ -74,6 +79,7 @@ if(MPIC_PERFORM_TEST)
   # Create a CMakeLists.txt file which will generate the "mpictest" executable
   if(MPI_MPICC)
     file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(mpictest C)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_C_COMPILER ${MPI_MPICC})\n"
@@ -86,6 +92,7 @@ if(MPIC_PERFORM_TEST)
       "ADD_EXECUTABLE(mpictest mpictest.c)\n")
   else(MPI_MPICC)
     file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(mpictest C)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
@@ -110,7 +117,7 @@ if(MPIC_PERFORM_TEST)
     "}\n")
   # Use TRY_COMPILE to make the target "mpictest"
   try_compile(MPITEST_OK ${MPITest_DIR} ${MPITest_DIR}
-    mpitest OUTPUT_VARIABLE MY_OUTPUT)
+    mpictest OUTPUT_VARIABLE MY_OUTPUT)
   # To ensure we do not use stuff from the previous attempts, 
   # we must remove the CMakeFiles directory.
   file(REMOVE_RECURSE ${MPITest_DIR}/CMakeFiles)
@@ -128,6 +135,7 @@ if(MPIC_FOUND)
   # Create a CMakeLists.txt file which will generate the "mpi2test" executable
   if(MPI_MPICC)
     file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(mpi2test C)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_C_COMPILER ${MPI_MPICC})\n"
@@ -140,6 +148,7 @@ if(MPIC_FOUND)
       "ADD_EXECUTABLE(mpi2test mpi2test.c)\n")
   else(MPI_MPICC)
     file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(mpi2test C)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
diff --git a/config/SundialsMPICXX.cmake b/config/SundialsMPICXX.cmake
new file mode 100644
index 0000000..481615c
--- /dev/null
+++ b/config/SundialsMPICXX.cmake
@@ -0,0 +1,120 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# MPI-C++ tests for SUNDIALS CMake-based configuration.
+
+set(MPICXX_FOUND FALSE)
+
+# Local variable indicating whether to test MPI
+set(MPICXX_PERFORM_TEST FALSE)
+# By default, we try to use the MPI compiler script
+# Search for the MPICXX compiler script
+find_program(MPI_MPICXX NAMES mpicxx DOC "mpicxx program")
+if(MPI_MPICXX)
+  message(STATUS "Looking for MPI C++ compiler script... ${MPI_MPICXX}")
+  # Test the MPI compiler script
+  set(MPICXX_PERFORM_TEST TRUE)
+else(MPI_MPICXX)
+  message(STATUS "Looking for MPI C++ compiler script... FAILED")
+  # If not already available, search for MPI headers and libraries.
+  # Define the following values
+  #  MPI_INCLUDE_PATH = cached location of mpi.h
+  #  MPI_LIBRARIES    = cached list of libraries to link in (mpi mpich etc)
+  if(NOT MPI_LIBRARIES)
+    find_path(MPI_INCLUDE_PATH mpi.h
+      PATHS /usr/local/include 
+      /usr/include 
+      /usr/include/mpi
+      /usr/local/mpi/include
+      "$ENV{ProgramFiles}/MPICH/SDK/Include"
+      "$ENV{ProgramFiles}/MPICH2/include"
+      "C:/Program Files/MPICH/SDK/Include"
+      )
+    find_library(MPI_LIBRARIES
+      NAMES mpich2 mpi mpich 
+      PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib
+      "$ENV{ProgramFiles}/MPICH/SDK/Lib"
+      "$ENV{ProgramFiles}/MPICH2/Lib"
+      "C:/Program Files/MPICH/SDK/Lib" 
+      )
+    find_library(MPI_EXTRA_LIBRARIES 
+      NAMES mpi++
+      PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib 
+      "$ENV{ProgramFiles}/MPICH/SDK/Lib"
+      "C:/Program Files/MPICH/SDK/Lib" 
+      DOC "If a second mpi library is necessary, specify it here.")
+    if(MPI_EXTRA_LIBRARIES)
+      set(MPI_LIBRARIES ${MPI_LIBRARIES} ${MPI_EXTRA_LIBRARIES})
+    endif(MPI_EXTRA_LIBRARIES)
+  endif(NOT MPI_LIBRARIES)
+  if(MPI_LIBRARIES)
+    message(STATUS "Looking for MPI libraries... ${MPI_LIBRARIES}")
+    # Test the MPI libraries
+    set(MPICXX_PERFORM_TEST TRUE)
+  else(MPI_LIBRARIES)
+    message(STATUS "Looking for MPI libraries... FAILED")
+  endif(MPI_LIBRARIES)
+endif(MPI_MPICXX)  
+# If we have what to test, do it now
+if(MPICXX_PERFORM_TEST)
+  # Create the MPITest directory
+  set(MPITest_DIR ${PROJECT_BINARY_DIR}/MPITest)
+  file(MAKE_DIRECTORY ${MPITest_DIR})
+  # Create a CMakeLists.txt file which will generate the "mpicxxtest" executable
+  if(MPI_MPICXX)
+    file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+      "PROJECT(mpicxxtest CXX)\n"
+      "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+      "SET(CMAKE_CXX_COMPILER ${MPI_MPICXX})\n"
+      "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+      "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\")\n"
+      "SET(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE}\")\n"
+      "SET(CMAKE_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG}\")\n"
+      "SET(CMAKE_CXX_FLAGS_RELWITHDEBUGINFO \"${CMAKE_CXX_FLAGS_RELWITHDEBUGINFO}\")\n"
+      "SET(CMAKE_CXX_FLAGS_MINSIZE \"${CMAKE_CXX_FLAGS_MINSIZE}\")\n"
+      "ADD_EXECUTABLE(mpicxxtest mpicxxtest.cpp)\n")
+  else(MPI_MPICXX)
+    file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+      "PROJECT(mpicxxtest CXX)\n"
+      "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+      "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+      "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\")\n"
+      "SET(CMAKE_CXX_FLAGS_RELEASE \"${CMAKE_CXX_FLAGS_RELEASE}\")\n"
+      "SET(CMAKE_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG}\")\n"
+      "SET(CMAKE_CXX_FLAGS_RELWITHDEBUGINFO \"${CMAKE_CXX_FLAGS_RELWITHDEBUGINFO}\")\n"
+      "SET(CMAKE_CXX_FLAGS_MINSIZE \"${CMAKE_CXX_FLAGS_MINSIZE}\")\n"
+      "INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})\n"
+      "ADD_EXECUTABLE(mpicxxtest mpictest.cpp)\n"
+      "TARGET_LINK_LIBRARIES(mpicxxtest ${MPI_LIBRARIES})\n")
+  endif(MPI_MPICXX)
+  # Create a simple C++ source which only calls the MPI_Init and MPI_Finalize functions
+  file(WRITE ${MPITest_DIR}/mpicxxtest.cpp
+    "#include <mpi.h>\n"
+    "int main(){\n"
+    "int c;\n"
+    "char **v;\n"
+    "MPI_Init(&c, &v);\n"
+    "MPI_Finalize();\n"
+    "return(0);\n"
+    "}\n")
+  # Use TRY_COMPILE to make the target "mpictest"
+  try_compile(MPITEST_OK ${MPITest_DIR} ${MPITest_DIR}
+    mpictest OUTPUT_VARIABLE MY_OUTPUT)
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${MPITest_DIR}/CMakeFiles)
+  # Process test result
+  if(MPITEST_OK)
+    message(STATUS "Trying to compile and link a simple MPI C++ program... OK")
+    set(MPICXX_FOUND TRUE)
+  else(MPITEST_OK)
+    message(STATUS "Trying to compile and link a simple MPI C++ program... FAILED")
+  endif(MPITEST_OK)
+endif(MPICXX_PERFORM_TEST)
+
diff --git a/config/SundialsMPIF.cmake b/config/SundialsMPIF.cmake
index c0a5a43..73affac 100644
--- a/config/SundialsMPIF.cmake
+++ b/config/SundialsMPIF.cmake
@@ -1,6 +1,6 @@
 # ---------------------------------------------------------------
-# $Revision: 1.1 $
-# $Date: 2009/02/17 02:58:46 $
+# $Revision: 4511 $
+# $Date: 2015-06-29 16:48:09 -0700 (Mon, 29 Jun 2015) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
@@ -70,6 +70,7 @@ if(MPIF_PERFORM_TEST)
   # Create a CMakeLists.txt file which will generate the "mpiftest" executable
   if(MPI_MPIF77)
     file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(mpiftest Fortran)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_Fortran_COMPILER ${MPI_MPIF77})\n"
@@ -77,6 +78,7 @@ if(MPIF_PERFORM_TEST)
       "ADD_EXECUTABLE(mpiftest mpiftest.f)\n")
   else(MPI_MPIF77)
     file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
       "PROJECT(mpiftest Fortran)\n"
       "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
       "SET(CMAKE_Fortran_FLAGS \"${TMP_Fortran_FLAGS}\")\n"
diff --git a/config/SundialsMPIF90.cmake b/config/SundialsMPIF90.cmake
new file mode 100644
index 0000000..104dd9d
--- /dev/null
+++ b/config/SundialsMPIF90.cmake
@@ -0,0 +1,105 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# MPI-Fortran90 tests for SUNDIALS CMake-based configuration.
+
+set(MPIF90_FOUND FALSE)
+
+# Local variable indicating whether to test MPI
+set(MPIF90_PERFORM_TEST FALSE)
+# By default, we try to use the MPI compiler script
+# Search for the MPIF90 compiler script
+find_program(MPI_MPIF90 NAMES mpif90 DOC "mpif90 program")
+if(MPI_MPIF90)
+  message(STATUS "Looking for MPI Fortran90 compiler script... ${MPI_MPIF90}")
+  # Test the MPI compiler script
+  set(MPIF90_PERFORM_TEST TRUE)
+else(MPI_MPIF90)
+  message(STATUS "Looking for MPI Fortran90 compiler script... FAILED")
+  # If not already available, search for MPI headers and libraries.
+  if(NOT MPI_LIBRARIES)
+    find_path(MPI_INCLUDE_PATH mpi.h
+      PATHS /usr/local/include 
+      /usr/include 
+      /usr/include/mpi
+      /usr/local/mpi/include
+      "$ENV{ProgramFiles}/MPICH/SDK/Include"
+      "$ENV{ProgramFiles}/MPICH2/include"
+      "C:/Program Files/MPICH/SDK/Include"
+      )
+    find_library(MPI_LIBRARIES
+      NAMES mpich2 mpi mpich 
+      PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib
+      "$ENV{ProgramFiles}/MPICH/SDK/Lib"
+      "$ENV{ProgramFiles}/MPICH2/Lib"
+      "C:/Program Files/MPICH/SDK/Lib" 
+      )
+    find_library(MPI_EXTRA_LIBRARIES 
+      NAMES mpi++
+      PATHS /usr/lib /usr/local/lib /usr/local/mpi/lib 
+      "$ENV{ProgramFiles}/MPICH/SDK/Lib"
+      "C:/Program Files/MPICH/SDK/Lib" 
+      DOC "If a second mpi library is necessary, specify it here.")
+    if(MPI_EXTRA_LIBRARIES)
+      set(MPI_LIBRARIES ${MPI_LIBRARIES} ${MPI_EXTRA_LIBRARIES})
+    endif(MPI_EXTRA_LIBRARIES)
+  endif(NOT MPI_LIBRARIES)
+  if(MPI_LIBRARIES)
+    message(STATUS "Looking for MPI libraries... ${MPI_LIBRARIES}")
+    # Test the MPI libraries
+    set(MPIF90_PERFORM_TEST TRUE)
+  else(MPI_LIBRARIES)
+    message(STATUS "Looking for MPI libraries... FAILED")
+  endif(MPI_LIBRARIES)
+endif(MPI_MPIF90)
+# If we have what to test, do it now
+if(MPIF90_PERFORM_TEST)
+  # Create the MPITest directory
+  set(MPITest_DIR ${PROJECT_BINARY_DIR}/MPITest)
+  file(MAKE_DIRECTORY ${MPITest_DIR})
+  # Create a CMakeLists.txt file which will generate the "mpif90test" executable
+  if(MPI_MPIF90)
+    file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+      "PROJECT(mpif90test Fortran)\n"
+      "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+      "SET(CMAKE_Fortran_COMPILER ${MPI_MPIF90})\n"
+      "SET(CMAKE_Fortran_FLAGS \"${TMP_Fortran_FLAGS}\")\n"
+      "ADD_EXECUTABLE(mpif90test mpif90test.f90)\n")
+  else(MPI_MPIF90)
+    file(WRITE ${MPITest_DIR}/CMakeLists.txt
+      "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+      "PROJECT(mpif90test Fortran)\n"
+      "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+      "SET(CMAKE_Fortran_FLAGS \"${TMP_Fortran_FLAGS}\")\n"
+      "INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})\n"
+      "ADD_EXECUTABLE(mpif90test mpif90test.f90)\n"
+      "TARGET_LINK_LIBRARIES(mpif90test ${MPI_LIBRARIES})\n")
+  endif(MPI_MPIF90)
+  # Create a simple F90 source which only calls the MPI_Init and MPI_Finalize functions
+  file(WRITE ${MPITest_DIR}/mpif90test.f90
+    "program test\n"
+    "include \"mpif.h\"\n"
+    "integer :: ier\n" 
+    "call MPI_Init(ier)\n"
+    "call MPI_Finalize(ier)\n"
+    "stop\n"
+    "end program\n")
+  # Use TRY_COMPILE to make the target "mpif90test"
+  try_compile(MPITEST_OK ${MPITest_DIR} ${MPITest_DIR}
+    mpif90test OUTPUT_VARIABLE MY_OUTPUT)
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${MPITest_DIR}/CMakeFiles)
+  # Process test result
+  if(MPITEST_OK)
+    message(STATUS "Trying to compile and link a simple MPI Fortran90 program... OK")
+    set(MPIF90_FOUND TRUE)
+  else(MPITEST_OK)
+    message(STATUS "Trying to compile and link a simple MPI Fortran90 program... FAILED")
+  endif(MPITEST_OK)
+endif(MPIF90_PERFORM_TEST)
\ No newline at end of file
diff --git a/config/SundialsPETSc.cmake b/config/SundialsPETSc.cmake
new file mode 100644
index 0000000..4ab8f49
--- /dev/null
+++ b/config/SundialsPETSc.cmake
@@ -0,0 +1,75 @@
+# ---------------------------------------------------------------
+# $Revision:  $
+# $Date:  $
+# ---------------------------------------------------------------
+# Programmer:  Eddy Banks @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# PETSc tests for SUNDIALS CMake-based configuration.
+# 
+### This is only set if running GUI - simply return first time enabled
+IF(PETSC_DISABLED)
+  SET(PETSC_DISABLED FALSE CACHE INTERNAL "GUI - now enabled" FORCE)
+  RETURN()
+ENDIF()
+
+SET(PETSC_FOUND FALSE)
+
+# set PETSC_LIBRARIES
+include(FindPETSc)
+
+# If we have the PETSC libraries, test them
+if(PETSC_LIBRARIES)
+  message(STATUS "Looking for PETSc libraries...")
+  # Create the PETSCTest directory
+  set(PETSCTest_DIR ${PROJECT_BINARY_DIR}/PETSCTest)
+  file(MAKE_DIRECTORY ${PETSCTest_DIR})
+  # Create a CMakeLists.txt file 
+  file(WRITE ${PETSCTest_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+    "PROJECT(ltest C)\n"
+    "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+    "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+    "SET(CMAKE_C_COMPILER ${MPI_MPICC})\n"
+    "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n"
+    "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n"
+    "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n"
+    "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n"
+    "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n"
+    "INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIR})\n"
+    "ADD_EXECUTABLE(ltest ltest.c)\n"
+    "TARGET_LINK_LIBRARIES(ltest ${PETSC_LIBRARIES})\n")    
+  # Create a C source file which calls a PETSC function
+  file(WRITE ${PETSCTest_DIR}/ltest.c
+    "\#include \"petscvec.h\"\n"
+    "int main(){\n"
+    "Vec x;\n"
+    "VecCreate(PETSC_COMM_WORLD, &x);\n" 
+    "return(0);\n"
+    "}\n")
+  # Attempt to link the "ltest" executable
+  try_compile(LTEST_OK ${PETSCTest_DIR} ${PETSCTest_DIR} ltest OUTPUT_VARIABLE MY_OUTPUT)
+      
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${PETSCTest_DIR}/CMakeFiles)
+  # Process test result
+  if(LTEST_OK)
+    message(STATUS "Checking if PETSc works... OK")
+    set(PETSC_FOUND TRUE)
+  else(LTEST_OK)
+    message(STATUS "Checking if PETSc works... FAILED")
+  endif(LTEST_OK)
+else(PETSC_LIBRARIES)
+  PRINT_WARNING("PETSC LIBRARIES NOT Found. Please check library path" "${PETSC_LIBRARY_DIR} ")
+  message(STATUS "Looking for PETSc libraries... FAILED")
+endif(PETSC_LIBRARIES)
diff --git a/config/SundialsSuperLUMT.cmake b/config/SundialsSuperLUMT.cmake
new file mode 100644
index 0000000..662e3af
--- /dev/null
+++ b/config/SundialsSuperLUMT.cmake
@@ -0,0 +1,71 @@
+# ---------------------------------------------------------------
+# $Revision: 4955 $
+# $Date: 2016-09-23 10:01:28 -0700 (Fri, 23 Sep 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Eddy Banks @ LLNL
+# ---------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# SUPERLUMT tests for SUNDIALS CMake-based configuration.
+#    - loosely based on SundialsLapack.cmake
+# 
+### This is only set if running GUI - simply return first time enabled
+IF(SUPERLUMT_DISABLED)
+  SET(SUPERLUMT_DISABLED FALSE CACHE INTERNAL "GUI - SUPERLUMT now enabled" FORCE)
+  RETURN()
+ENDIF()
+
+SET(SUPERLUMT_FOUND FALSE)
+
+# set SUPERLUMT_LIBRARIES
+include(FindSUPERLUMT)
+# If we have the SUPERLUMT libraries, test them
+if(SUPERLUMT_LIBRARY AND SUPERLUMT_LIBRARIES)
+  message(STATUS "Looking for SUPERLUMT libraries... OK")
+  # Create the SUPERLUMT_TEST directory
+  set(SUPERLUMT_TEST_DIR ${PROJECT_BINARY_DIR}/SUPERLUMT_TEST)
+  file(MAKE_DIRECTORY ${SUPERLUMT_TEST_DIR})
+  # Create a CMakeLists.txt file 
+  file(WRITE ${SUPERLUMT_TEST_DIR}/CMakeLists.txt
+    "CMAKE_MINIMUM_REQUIRED(VERSION 2.4)\n"
+    "PROJECT(ltest C)\n"
+    "SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
+    "SET(CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\")\n"
+    "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}\")\n"
+    "SET(CMAKE_C_FLAGS_RELEASE \"${CMAKE_C_FLAGS_RELEASE}\")\n"
+    "SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n"
+    "SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n"
+    "SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n"
+    "INCLUDE_DIRECTORIES(${SUPERLUMT_INCLUDE_DIR})\n"
+    "ADD_EXECUTABLE(ltest ltest.c)\n"
+    "TARGET_LINK_LIBRARIES(ltest ${SUPERLUMT_LIBRARIES})\n")    
+# Create a C source file which calls a SUPERLUMT function
+  file(WRITE ${SUPERLUMT_TEST_DIR}/ltest.c
+    "\#include \"slu_mt_ddefs.h\"\n"
+#    "\#include \"pdsp_defs.h\"\n"
+    "int main(){\n"
+    "SuperMatrix A;\n"
+    "NCformat *Astore;\n" 
+    "return(0);\n"
+    "}\n")
+  # Attempt to link the "ltest" executable
+  try_compile(LTEST_OK ${SUPERLUMT_TEST_DIR} ${SUPERLUMT_TEST_DIR} ltest OUTPUT_VARIABLE MY_OUTPUT)
+      
+  # To ensure we do not use stuff from the previous attempts, 
+  # we must remove the CMakeFiles directory.
+  file(REMOVE_RECURSE ${SUPERLUMT_TEST_DIR}/CMakeFiles)
+  # Process test result
+  if(LTEST_OK)
+    message(STATUS "Checking if SUPERLUMT works... OK")
+    set(SUPERLUMT_FOUND TRUE)
+  else(LTEST_OK)
+    message(STATUS "Checking if SUPERLUMT works... FAILED")
+  endif(LTEST_OK)
+
+else()
+  PRINT_WARNING("SUPERLUMT LIBRARIES NOT Found. Please check library path" "${SUPERLUMT_LIBRARY_DIR} ")
+  message(STATUS "Looking for SUPERLUMT libraries... FAILED")
+endif()
diff --git a/config/config.guess b/config/config.guess
deleted file mode 100755
index e3ef63f..0000000
--- a/config/config.guess
+++ /dev/null
@@ -1,1471 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-12-13'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per at bothner.com>.
-# Please send patches to <config-patches at gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub.  If it succeeds, it prints the system name on stdout, and
-# exits with 0.  Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches at gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )	# Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help" >&2
-       exit 1 ;;
-    * )
-       break ;;
-  esac
-done
-
-if test $# != 0; then
-  echo "$me: too many arguments$help" >&2
-  exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int x;" > $dummy.c ;
-	for c in cc gcc c89 c99 ; do
-	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
-	     CC_FOR_BUILD="$c"; break ;
-	  fi ;
-	done ;
-	if test x"$CC_FOR_BUILD" = x ; then
-	  CC_FOR_BUILD=no_compiler_found ;
-	fi
-	;;
- ,,*)   CC_FOR_BUILD=$CC ;;
- ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi at noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
-	PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
-    *:NetBSD:*:*)
-	# NetBSD (nbsd) targets should (where applicable) match one or
-	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
-	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
-	# switched to ELF, *-*-netbsd* would select the old
-	# object file format.  This provides both forward
-	# compatibility and a consistent mechanism for selecting the
-	# object file format.
-	#
-	# Note: NetBSD doesn't particularly care about the vendor
-	# portion of the name.  We always set it to "unknown".
-	sysctl="sysctl -n hw.machine_arch"
-	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
-	case "${UNAME_MACHINE_ARCH}" in
-	    armeb) machine=armeb-unknown ;;
-	    arm*) machine=arm-unknown ;;
-	    sh3el) machine=shl-unknown ;;
-	    sh3eb) machine=sh-unknown ;;
-	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
-	esac
-	# The Operating System including object format, if it has switched
-	# to ELF recently, or will in the future.
-	case "${UNAME_MACHINE_ARCH}" in
-	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
-		eval $set_cc_for_build
-		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
-			| grep __ELF__ >/dev/null
-		then
-		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
-		    # Return netbsd for either.  FIX?
-		    os=netbsd
-		else
-		    os=netbsdelf
-		fi
-		;;
-	    *)
-	        os=netbsd
-		;;
-	esac
-	# The OS release
-	# Debian GNU/NetBSD machines have a different userland, and
-	# thus, need a distinct triplet. However, they do not need
-	# kernel version information, so it can be replaced with a
-	# suitable tag, in the style of linux-gnu.
-	case "${UNAME_VERSION}" in
-	    Debian*)
-		release='-gnu'
-		;;
-	    *)
-		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-		;;
-	esac
-	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
-	# contains redundant information, the shorter form:
-	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-	echo "${machine}-${os}${release}"
-	exit ;;
-    *:OpenBSD:*:*)
-	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-	echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
-	exit ;;
-    *:ekkoBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
-	exit ;;
-    macppc:MirBSD:*:*)
-	echo powerppc-unknown-mirbsd${UNAME_RELEASE}
-	exit ;;
-    *:MirBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
-	exit ;;
-    alpha:OSF1:*:*)
-	case $UNAME_RELEASE in
-	*4.0)
-		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-		;;
-	*5.*)
-	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
-		;;
-	esac
-	# According to Compaq, /usr/sbin/psrinfo has been available on
-	# OSF/1 and Tru64 systems produced since 1995.  I hope that
-	# covers most systems running today.  This code pipes the CPU
-	# types through head -n 1, so we only detect the type of CPU 0.
-	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
-	case "$ALPHA_CPU_TYPE" in
-	    "EV4 (21064)")
-		UNAME_MACHINE="alpha" ;;
-	    "EV4.5 (21064)")
-		UNAME_MACHINE="alpha" ;;
-	    "LCA4 (21066/21068)")
-		UNAME_MACHINE="alpha" ;;
-	    "EV5 (21164)")
-		UNAME_MACHINE="alphaev5" ;;
-	    "EV5.6 (21164A)")
-		UNAME_MACHINE="alphaev56" ;;
-	    "EV5.6 (21164PC)")
-		UNAME_MACHINE="alphapca56" ;;
-	    "EV5.7 (21164PC)")
-		UNAME_MACHINE="alphapca57" ;;
-	    "EV6 (21264)")
-		UNAME_MACHINE="alphaev6" ;;
-	    "EV6.7 (21264A)")
-		UNAME_MACHINE="alphaev67" ;;
-	    "EV6.8CB (21264C)")
-		UNAME_MACHINE="alphaev68" ;;
-	    "EV6.8AL (21264B)")
-		UNAME_MACHINE="alphaev68" ;;
-	    "EV6.8CX (21264D)")
-		UNAME_MACHINE="alphaev68" ;;
-	    "EV6.9A (21264/EV69A)")
-		UNAME_MACHINE="alphaev69" ;;
-	    "EV7 (21364)")
-		UNAME_MACHINE="alphaev7" ;;
-	    "EV7.9 (21364A)")
-		UNAME_MACHINE="alphaev79" ;;
-	esac
-	# A Pn.n version is a patched version.
-	# A Vn.n version is a released version.
-	# A Tn.n version is a released field test version.
-	# A Xn.n version is an unreleased experimental baselevel.
-	# 1.2 uses "1.2" for uname -r.
-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	exit ;;
-    Alpha\ *:Windows_NT*:*)
-	# How do we know it's Interix rather than the generic POSIX subsystem?
-	# Should we change UNAME_MACHINE based on the output of uname instead
-	# of the specific Alpha model?
-	echo alpha-pc-interix
-	exit ;;
-    21064:Windows_NT:50:3)
-	echo alpha-dec-winnt3.5
-	exit ;;
-    Amiga*:UNIX_System_V:4.0:*)
-	echo m68k-unknown-sysv4
-	exit ;;
-    *:[Aa]miga[Oo][Ss]:*:*)
-	echo ${UNAME_MACHINE}-unknown-amigaos
-	exit ;;
-    *:[Mm]orph[Oo][Ss]:*:*)
-	echo ${UNAME_MACHINE}-unknown-morphos
-	exit ;;
-    *:OS/390:*:*)
-	echo i370-ibm-openedition
-	exit ;;
-    *:z/VM:*:*)
-	echo s390-ibm-zvmoe
-	exit ;;
-    *:OS400:*:*)
-        echo powerpc-ibm-os400
-	exit ;;
-    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-	echo arm-acorn-riscix${UNAME_RELEASE}
-	exit ;;
-    arm:riscos:*:*|arm:RISCOS:*:*)
-	echo arm-unknown-riscos
-	exit ;;
-    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
-	echo hppa1.1-hitachi-hiuxmpp
-	exit ;;
-    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
-	# akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
-	if test "`(/bin/universe) 2>/dev/null`" = att ; then
-		echo pyramid-pyramid-sysv3
-	else
-		echo pyramid-pyramid-bsd
-	fi
-	exit ;;
-    NILE*:*:*:dcosx)
-	echo pyramid-pyramid-svr4
-	exit ;;
-    DRS?6000:unix:4.0:6*)
-	echo sparc-icl-nx6
-	exit ;;
-    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
-	case `/usr/bin/uname -p` in
-	    sparc) echo sparc-icl-nx7; exit ;;
-	esac ;;
-    sun4H:SunOS:5.*:*)
-	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    i86pc:SunOS:5.*:*)
-	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    sun4*:SunOS:6*:*)
-	# According to config.sub, this is the proper way to canonicalize
-	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
-	# it's likely to be more like Solaris than SunOS4.
-	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    sun4*:SunOS:*:*)
-	case "`/usr/bin/arch -k`" in
-	    Series*|S4*)
-		UNAME_RELEASE=`uname -v`
-		;;
-	esac
-	# Japanese Language versions have a version number like `4.1.3-JL'.
-	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
-	exit ;;
-    sun3*:SunOS:*:*)
-	echo m68k-sun-sunos${UNAME_RELEASE}
-	exit ;;
-    sun*:*:4.2BSD:*)
-	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
-	case "`/bin/arch`" in
-	    sun3)
-		echo m68k-sun-sunos${UNAME_RELEASE}
-		;;
-	    sun4)
-		echo sparc-sun-sunos${UNAME_RELEASE}
-		;;
-	esac
-	exit ;;
-    aushp:SunOS:*:*)
-	echo sparc-auspex-sunos${UNAME_RELEASE}
-	exit ;;
-    # The situation for MiNT is a little confusing.  The machine name
-    # can be virtually everything (everything which is not
-    # "atarist" or "atariste" at least should have a processor
-    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
-    # to the lowercase version "mint" (or "freemint").  Finally
-    # the system name "TOS" denotes a system which is actually not
-    # MiNT.  But MiNT is downward compatible to TOS, so this should
-    # be no problem.
-    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-	exit ;;
-    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-	echo m68k-atari-mint${UNAME_RELEASE}
-        exit ;;
-    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
-	exit ;;
-    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
-    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
-    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
-    m68k:machten:*:*)
-	echo m68k-apple-machten${UNAME_RELEASE}
-	exit ;;
-    powerpc:machten:*:*)
-	echo powerpc-apple-machten${UNAME_RELEASE}
-	exit ;;
-    RISC*:Mach:*:*)
-	echo mips-dec-mach_bsd4.3
-	exit ;;
-    RISC*:ULTRIX:*:*)
-	echo mips-dec-ultrix${UNAME_RELEASE}
-	exit ;;
-    VAX*:ULTRIX*:*:*)
-	echo vax-dec-ultrix${UNAME_RELEASE}
-	exit ;;
-    2020:CLIX:*:* | 2430:CLIX:*:*)
-	echo clipper-intergraph-clix${UNAME_RELEASE}
-	exit ;;
-    mips:*:*:UMIPS | mips:*:*:RISCos)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h>  /* for printf() prototype */
-	int main (int argc, char *argv[]) {
-#else
-	int main (argc, argv) int argc; char *argv[]; {
-#endif
-	#if defined (host_mips) && defined (MIPSEB)
-	#if defined (SYSTYPE_SYSV)
-	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
-	#endif
-	#if defined (SYSTYPE_SVR4)
-	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
-	#endif
-	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
-	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
-	#endif
-	#endif
-	  exit (-1);
-	}
-EOF
-	$CC_FOR_BUILD -o $dummy $dummy.c &&
-	  dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
-	  SYSTEM_NAME=`$dummy $dummyarg` &&
-	    { echo "$SYSTEM_NAME"; exit; }
-	echo mips-mips-riscos${UNAME_RELEASE}
-	exit ;;
-    Motorola:PowerMAX_OS:*:*)
-	echo powerpc-motorola-powermax
-	exit ;;
-    Motorola:*:4.3:PL8-*)
-	echo powerpc-harris-powermax
-	exit ;;
-    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
-	echo powerpc-harris-powermax
-	exit ;;
-    Night_Hawk:Power_UNIX:*:*)
-	echo powerpc-harris-powerunix
-	exit ;;
-    m88k:CX/UX:7*:*)
-	echo m88k-harris-cxux7
-	exit ;;
-    m88k:*:4*:R4*)
-	echo m88k-motorola-sysv4
-	exit ;;
-    m88k:*:3*:R3*)
-	echo m88k-motorola-sysv3
-	exit ;;
-    AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
-	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
-	then
-	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
-	       [ ${TARGET_BINARY_INTERFACE}x = x ]
-	    then
-		echo m88k-dg-dgux${UNAME_RELEASE}
-	    else
-		echo m88k-dg-dguxbcs${UNAME_RELEASE}
-	    fi
-	else
-	    echo i586-dg-dgux${UNAME_RELEASE}
-	fi
- 	exit ;;
-    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
-	echo m88k-dolphin-sysv3
-	exit ;;
-    M88*:*:R3*:*)
-	# Delta 88k system running SVR3
-	echo m88k-motorola-sysv3
-	exit ;;
-    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
-	echo m88k-tektronix-sysv3
-	exit ;;
-    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
-	echo m68k-tektronix-bsd
-	exit ;;
-    *:IRIX*:*:*)
-	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
-	exit ;;
-    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
-	echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
-	exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
-    i*86:AIX:*:*)
-	echo i386-ibm-aix
-	exit ;;
-    ia64:AIX:*:*)
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
-	else
-		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-	fi
-	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
-	exit ;;
-    *:AIX:2:3)
-	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-		eval $set_cc_for_build
-		sed 's/^		//' << EOF >$dummy.c
-		#include <sys/systemcfg.h>
-
-		main()
-			{
-			if (!__power_pc())
-				exit(1);
-			puts("powerpc-ibm-aix3.2.5");
-			exit(0);
-			}
-EOF
-		if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
-		then
-			echo "$SYSTEM_NAME"
-		else
-			echo rs6000-ibm-aix3.2.5
-		fi
-	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
-		echo rs6000-ibm-aix3.2.4
-	else
-		echo rs6000-ibm-aix3.2
-	fi
-	exit ;;
-    *:AIX:*:[45])
-	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
-	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
-		IBM_ARCH=rs6000
-	else
-		IBM_ARCH=powerpc
-	fi
-	if [ -x /usr/bin/oslevel ] ; then
-		IBM_REV=`/usr/bin/oslevel`
-	else
-		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
-	fi
-	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
-	exit ;;
-    *:AIX:*:*)
-	echo rs6000-ibm-aix
-	exit ;;
-    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
-	echo romp-ibm-bsd4.4
-	exit ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
-	exit ;;                             # report: romp-ibm BSD 4.3
-    *:BOSX:*:*)
-	echo rs6000-bull-bosx
-	exit ;;
-    DPX/2?00:B.O.S.:*:*)
-	echo m68k-bull-sysv3
-	exit ;;
-    9000/[34]??:4.3bsd:1.*:*)
-	echo m68k-hp-bsd
-	exit ;;
-    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
-	echo m68k-hp-bsd4.4
-	exit ;;
-    9000/[34678]??:HP-UX:*:*)
-	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-	case "${UNAME_MACHINE}" in
-	    9000/31? )            HP_ARCH=m68000 ;;
-	    9000/[34]?? )         HP_ARCH=m68k ;;
-	    9000/[678][0-9][0-9])
-		if [ -x /usr/bin/getconf ]; then
-		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
-			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
-		fi
-		if [ "${HP_ARCH}" = "" ]; then
-		    eval $set_cc_for_build
-		    sed 's/^              //' << EOF >$dummy.c
-
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
-
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
-
-                  switch (cpu)
-              	{
-              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-              	case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-              	    switch (bits)
-              		{
-              		case 64: puts ("hppa2.0w"); break;
-              		case 32: puts ("hppa2.0n"); break;
-              		default: puts ("hppa2.0"); break;
-              		} break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-              	    puts ("hppa2.0"); break;
-              #endif
-              	default: puts ("hppa1.0"); break;
-              	}
-                  exit (0);
-              }
-EOF
-		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
-		    test -z "$HP_ARCH" && HP_ARCH=hppa
-		fi ;;
-	esac
-	if [ ${HP_ARCH} = "hppa2.0w" ]
-	then
-	    eval $set_cc_for_build
-
-	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
-	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
-	    # generating 64-bit code.  GNU and HP use different nomenclature:
-	    #
-	    # $ CC_FOR_BUILD=cc ./config.guess
-	    # => hppa2.0w-hp-hpux11.23
-	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
-	    # => hppa64-hp-hpux11.23
-
-	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
-		grep __LP64__ >/dev/null
-	    then
-		HP_ARCH="hppa2.0w"
-	    else
-		HP_ARCH="hppa64"
-	    fi
-	fi
-	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
-	exit ;;
-    ia64:HP-UX:*:*)
-	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-	echo ia64-hp-hpux${HPUX_REV}
-	exit ;;
-    3050*:HI-UX:*:*)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#include <unistd.h>
-	int
-	main ()
-	{
-	  long cpu = sysconf (_SC_CPU_VERSION);
-	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
-	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
-	     results, however.  */
-	  if (CPU_IS_PA_RISC (cpu))
-	    {
-	      switch (cpu)
-		{
-		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
-		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
-		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
-		  default: puts ("hppa-hitachi-hiuxwe2"); break;
-		}
-	    }
-	  else if (CPU_IS_HP_MC68K (cpu))
-	    puts ("m68k-hitachi-hiuxwe2");
-	  else puts ("unknown-hitachi-hiuxwe2");
-	  exit (0);
-	}
-EOF
-	$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
-		{ echo "$SYSTEM_NAME"; exit; }
-	echo unknown-hitachi-hiuxwe2
-	exit ;;
-    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
-	echo hppa1.1-hp-bsd
-	exit ;;
-    9000/8??:4.3bsd:*:*)
-	echo hppa1.0-hp-bsd
-	exit ;;
-    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
-	echo hppa1.0-hp-mpeix
-	exit ;;
-    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
-	echo hppa1.1-hp-osf
-	exit ;;
-    hp8??:OSF1:*:*)
-	echo hppa1.0-hp-osf
-	exit ;;
-    i*86:OSF1:*:*)
-	if [ -x /usr/sbin/sysversion ] ; then
-	    echo ${UNAME_MACHINE}-unknown-osf1mk
-	else
-	    echo ${UNAME_MACHINE}-unknown-osf1
-	fi
-	exit ;;
-    parisc*:Lites*:*:*)
-	echo hppa1.1-hp-lites
-	exit ;;
-    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
-	echo c1-convex-bsd
-        exit ;;
-    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-        exit ;;
-    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
-	echo c34-convex-bsd
-        exit ;;
-    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
-	echo c38-convex-bsd
-        exit ;;
-    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
-	echo c4-convex-bsd
-        exit ;;
-    CRAY*Y-MP:*:*:*)
-	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*[A-Z]90:*:*:*)
-	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
-	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-	      -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*TS:*:*:*)
-	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*T3E:*:*:*)
-	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    CRAY*SV1:*:*:*)
-	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    *:UNICOS/mp:*:*)
-	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
-	exit ;;
-    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit ;;
-    5000:UNIX_System_V:4.*:*)
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-	exit ;;
-    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
-	exit ;;
-    sparc*:BSD/OS:*:*)
-	echo sparc-unknown-bsdi${UNAME_RELEASE}
-	exit ;;
-    *:BSD/OS:*:*)
-	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
-	exit ;;
-    *:FreeBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
-	exit ;;
-    i*:CYGWIN*:*)
-	echo ${UNAME_MACHINE}-pc-cygwin
-	exit ;;
-    i*:MINGW*:*)
-	echo ${UNAME_MACHINE}-pc-mingw32
-	exit ;;
-    i*:windows32*:*)
-    	# uname -m includes "-pc" on this system.
-    	echo ${UNAME_MACHINE}-mingw32
-	exit ;;
-    i*:PW*:*)
-	echo ${UNAME_MACHINE}-pc-pw32
-	exit ;;
-    x86:Interix*:[345]*)
-	echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
-	exit ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-	echo i${UNAME_MACHINE}-pc-mks
-	exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-	# How do we know it's Interix rather than the generic POSIX subsystem?
-	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-	# UNAME_MACHINE based on the output of uname instead of i386?
-	echo i586-pc-interix
-	exit ;;
-    i*:UWIN*:*)
-	echo ${UNAME_MACHINE}-pc-uwin
-	exit ;;
-    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-	echo x86_64-unknown-cygwin
-	exit ;;
-    p*:CYGWIN*:*)
-	echo powerpcle-unknown-cygwin
-	exit ;;
-    prep*:SunOS:5.*:*)
-	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
-	exit ;;
-    *:GNU:*:*)
-	# the GNU system
-	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
-	exit ;;
-    *:GNU/*:*:*)
-	# other systems with GNU libc and userland
-	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
-	exit ;;
-    i*86:Minix:*:*)
-	echo ${UNAME_MACHINE}-pc-minix
-	exit ;;
-    arm*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    cris:Linux:*:*)
-	echo cris-axis-linux-gnu
-	exit ;;
-    crisv32:Linux:*:*)
-	echo crisv32-axis-linux-gnu
-	exit ;;
-    frv:Linux:*:*)
-    	echo frv-unknown-linux-gnu
-	exit ;;
-    ia64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    m32r*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    m68*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    mips:Linux:*:*)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#undef CPU
-	#undef mips
-	#undef mipsel
-	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=mipsel
-	#else
-	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=mips
-	#else
-	CPU=
-	#endif
-	#endif
-EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '/^CPU/{s: ::g;p;}'`"
-	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-	;;
-    mips64:Linux:*:*)
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#undef CPU
-	#undef mips64
-	#undef mips64el
-	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
-	CPU=mips64el
-	#else
-	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
-	CPU=mips64
-	#else
-	CPU=
-	#endif
-	#endif
-EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '/^CPU/{s: ::g;p;}'`"
-	test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
-	;;
-    or32:Linux:*:*)
-	echo or32-unknown-linux-gnu
-	exit ;;
-    ppc:Linux:*:*)
-	echo powerpc-unknown-linux-gnu
-	exit ;;
-    ppc64:Linux:*:*)
-	echo powerpc64-unknown-linux-gnu
-	exit ;;
-    alpha:Linux:*:*)
-	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
-	  EV5)   UNAME_MACHINE=alphaev5 ;;
-	  EV56)  UNAME_MACHINE=alphaev56 ;;
-	  PCA56) UNAME_MACHINE=alphapca56 ;;
-	  PCA57) UNAME_MACHINE=alphapca56 ;;
-	  EV6)   UNAME_MACHINE=alphaev6 ;;
-	  EV67)  UNAME_MACHINE=alphaev67 ;;
-	  EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
-	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
-	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
-	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
-	exit ;;
-    parisc:Linux:*:* | hppa:Linux:*:*)
-	# Look for CPU level
-	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
-	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
-	  *)    echo hppa-unknown-linux-gnu ;;
-	esac
-	exit ;;
-    parisc64:Linux:*:* | hppa64:Linux:*:*)
-	echo hppa64-unknown-linux-gnu
-	exit ;;
-    s390:Linux:*:* | s390x:Linux:*:*)
-	echo ${UNAME_MACHINE}-ibm-linux
-	exit ;;
-    sh64*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    sh*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    sparc:Linux:*:* | sparc64:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
-	exit ;;
-    vax:Linux:*:*)
-	echo ${UNAME_MACHINE}-dec-linux-gnu
-	exit ;;
-    x86_64:Linux:*:*)
-	echo x86_64-unknown-linux-gnu
-	exit ;;
-    i*86:Linux:*:*)
-	# The BFD linker knows what the default object file format is, so
-	# first see if it will tell us. cd to the root directory to prevent
-	# problems with other programs or directories called `ld' in the path.
-	# Set LC_ALL=C to ensure ld outputs messages in English.
-	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
-			 | sed -ne '/supported targets:/!d
-				    s/[ 	][ 	]*/ /g
-				    s/.*supported targets: *//
-				    s/ .*//
-				    p'`
-        case "$ld_supported_targets" in
-	  elf32-i386)
-		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
-		;;
-	  a.out-i386-linux)
-		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
-		exit ;;
-	  coff-i386)
-		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
-		exit ;;
-	  "")
-		# Either a pre-BFD a.out linker (linux-gnuoldld) or
-		# one that does not give us useful --help.
-		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
-		exit ;;
-	esac
-	# Determine whether the default compiler is a.out or elf
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#include <features.h>
-	#ifdef __ELF__
-	# ifdef __GLIBC__
-	#  if __GLIBC__ >= 2
-	LIBC=gnu
-	#  else
-	LIBC=gnulibc1
-	#  endif
-	# else
-	LIBC=gnulibc1
-	# endif
-	#else
-	#if defined(__INTEL_COMPILER) || defined(__PGI)
-	LIBC=gnu
-	#else
-	LIBC=gnuaout
-	#endif
-	#endif
-	#ifdef __dietlibc__
-	LIBC=dietlibc
-	#endif
-EOF
-	eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '/^LIBC/{s: ::g;p;}'`"
-	test x"${LIBC}" != x && {
-		echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
-		exit
-	}
-	test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
-	;;
-    i*86:DYNIX/ptx:4*:*)
-	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
-	# earlier versions are messed up and put the nodename in both
-	# sysname and nodename.
-	echo i386-sequent-sysv4
-	exit ;;
-    i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
-	# I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
-	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
-	exit ;;
-    i*86:OS/2:*:*)
-	# If we were able to find `uname', then EMX Unix compatibility
-	# is probably installed.
-	echo ${UNAME_MACHINE}-pc-os2-emx
-	exit ;;
-    i*86:XTS-300:*:STOP)
-	echo ${UNAME_MACHINE}-unknown-stop
-	exit ;;
-    i*86:atheos:*:*)
-	echo ${UNAME_MACHINE}-unknown-atheos
-	exit ;;
-    i*86:syllable:*:*)
-	echo ${UNAME_MACHINE}-pc-syllable
-	exit ;;
-    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
-	echo i386-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    i*86:*DOS:*:*)
-	echo ${UNAME_MACHINE}-pc-msdosdjgpp
-	exit ;;
-    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
-	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
-	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
-	else
-		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
-	fi
-	exit ;;
-    i*86:*:5:[678]*)
-    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
-	case `/bin/uname -X | grep "^Machine"` in
-	    *486*)	     UNAME_MACHINE=i486 ;;
-	    *Pentium)	     UNAME_MACHINE=i586 ;;
-	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
-	esac
-	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
-	exit ;;
-    i*86:*:3.2:*)
-	if test -f /usr/options/cb.name; then
-		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
-	elif /bin/uname -X 2>/dev/null >/dev/null ; then
-		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
-		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
-		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
-			&& UNAME_MACHINE=i586
-		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
-			&& UNAME_MACHINE=i686
-		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
-			&& UNAME_MACHINE=i686
-		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
-	else
-		echo ${UNAME_MACHINE}-pc-sysv32
-	fi
-	exit ;;
-    pc:*:*:*)
-	# Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i386.
-	echo i386-pc-msdosdjgpp
-        exit ;;
-    Intel:Mach:3*:*)
-	echo i386-pc-mach3
-	exit ;;
-    paragon:*:*:*)
-	echo i860-intel-osf1
-	exit ;;
-    i860:*:4.*:*) # i860-SVR4
-	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
-	else # Add other i860-SVR4 vendors below as they are discovered.
-	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
-	fi
-	exit ;;
-    mini*:CTIX:SYS*5:*)
-	# "miniframe"
-	echo m68010-convergent-sysv
-	exit ;;
-    mc68k:UNIX:SYSTEM5:3.51m)
-	echo m68k-convergent-sysv
-	exit ;;
-    M680?0:D-NIX:5.3:*)
-	echo m68k-diab-dnix
-	exit ;;
-    M68*:*:R3V[5678]*:*)
-	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
-    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
-	OS_REL=''
-	test -r /etc/.relid \
-	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
-	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-	  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
-	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
-    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && { echo i486-ncr-sysv4; exit; } ;;
-    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-	echo m68k-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    mc68030:UNIX_System_V:4.*:*)
-	echo m68k-atari-sysv4
-	exit ;;
-    TSUNAMI:LynxOS:2.*:*)
-	echo sparc-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    rs6000:LynxOS:2.*:*)
-	echo rs6000-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
-	echo powerpc-unknown-lynxos${UNAME_RELEASE}
-	exit ;;
-    SM[BE]S:UNIX_SV:*:*)
-	echo mips-dde-sysv${UNAME_RELEASE}
-	exit ;;
-    RM*:ReliantUNIX-*:*:*)
-	echo mips-sni-sysv4
-	exit ;;
-    RM*:SINIX-*:*:*)
-	echo mips-sni-sysv4
-	exit ;;
-    *:SINIX-*:*:*)
-	if uname -p 2>/dev/null >/dev/null ; then
-		UNAME_MACHINE=`(uname -p) 2>/dev/null`
-		echo ${UNAME_MACHINE}-sni-sysv4
-	else
-		echo ns32k-sni-sysv
-	fi
-	exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel at ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
-    *:UNIX_System_V:4*:FTX*)
-	# From Gerald Hewes <hewes at openmarket.com>.
-	# How about differentiating between stratus architectures? -djm
-	echo hppa1.1-stratus-sysv4
-	exit ;;
-    *:*:*:FTX*)
-	# From seanf at swdc.stratus.com.
-	echo i860-stratus-sysv4
-	exit ;;
-    i*86:VOS:*:*)
-	# From Paul.Green at stratus.com.
-	echo ${UNAME_MACHINE}-stratus-vos
-	exit ;;
-    *:VOS:*:*)
-	# From Paul.Green at stratus.com.
-	echo hppa1.1-stratus-vos
-	exit ;;
-    mc68*:A/UX:*:*)
-	echo m68k-apple-aux${UNAME_RELEASE}
-	exit ;;
-    news*:NEWS-OS:6*:*)
-	echo mips-sony-newsos6
-	exit ;;
-    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
-	if [ -d /usr/nec ]; then
-	        echo mips-nec-sysv${UNAME_RELEASE}
-	else
-	        echo mips-unknown-sysv${UNAME_RELEASE}
-	fi
-        exit ;;
-    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
-	echo powerpc-be-beos
-	exit ;;
-    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
-	echo powerpc-apple-beos
-	exit ;;
-    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
-	echo i586-pc-beos
-	exit ;;
-    SX-4:SUPER-UX:*:*)
-	echo sx4-nec-superux${UNAME_RELEASE}
-	exit ;;
-    SX-5:SUPER-UX:*:*)
-	echo sx5-nec-superux${UNAME_RELEASE}
-	exit ;;
-    SX-6:SUPER-UX:*:*)
-	echo sx6-nec-superux${UNAME_RELEASE}
-	exit ;;
-    Power*:Rhapsody:*:*)
-	echo powerpc-apple-rhapsody${UNAME_RELEASE}
-	exit ;;
-    *:Rhapsody:*:*)
-	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
-	exit ;;
-    *:Darwin:*:*)
-	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-	case $UNAME_PROCESSOR in
-	    unknown) UNAME_PROCESSOR=powerpc ;;
-	esac
-	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
-	exit ;;
-    *:procnto*:*:* | *:QNX:[0123456789]*:*)
-	UNAME_PROCESSOR=`uname -p`
-	if test "$UNAME_PROCESSOR" = "x86"; then
-		UNAME_PROCESSOR=i386
-		UNAME_MACHINE=pc
-	fi
-	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
-	exit ;;
-    *:QNX:*:4*)
-	echo i386-pc-qnx
-	exit ;;
-    NSE-?:NONSTOP_KERNEL:*:*)
-	echo nse-tandem-nsk${UNAME_RELEASE}
-	exit ;;
-    NSR-?:NONSTOP_KERNEL:*:*)
-	echo nsr-tandem-nsk${UNAME_RELEASE}
-	exit ;;
-    *:NonStop-UX:*:*)
-	echo mips-compaq-nonstopux
-	exit ;;
-    BS2000:POSIX*:*:*)
-	echo bs2000-siemens-sysv
-	exit ;;
-    DS/*:UNIX_System_V:*:*)
-	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
-	exit ;;
-    *:Plan9:*:*)
-	# "uname -m" is not consistent, so use $cputype instead. 386
-	# is converted to i386 for consistency with other x86
-	# operating systems.
-	if test "$cputype" = "386"; then
-	    UNAME_MACHINE=i386
-	else
-	    UNAME_MACHINE="$cputype"
-	fi
-	echo ${UNAME_MACHINE}-unknown-plan9
-	exit ;;
-    *:TOPS-10:*:*)
-	echo pdp10-unknown-tops10
-	exit ;;
-    *:TENEX:*:*)
-	echo pdp10-unknown-tenex
-	exit ;;
-    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
-	echo pdp10-dec-tops20
-	exit ;;
-    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
-	echo pdp10-xkl-tops20
-	exit ;;
-    *:TOPS-20:*:*)
-	echo pdp10-unknown-tops20
-	exit ;;
-    *:ITS:*:*)
-	echo pdp10-unknown-its
-	exit ;;
-    SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
-	exit ;;
-    *:DragonFly:*:*)
-	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
-	exit ;;
-    *:*VMS:*:*)
-    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
-	case "${UNAME_MACHINE}" in
-	    A*) echo alpha-dec-vms ; exit ;;
-	    I*) echo ia64-dec-vms ; exit ;;
-	    V*) echo vax-dec-vms ; exit ;;
-	esac ;;
-    *:XENIX:*:SysV)
-	echo i386-pc-xenix
-	exit ;;
-    i*86:skyos:*:*)
-	echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
-	exit ;;
-    i*86:rdos:*:*)
-	echo ${UNAME_MACHINE}-pc-rdos
-	exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
-  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
-     I don't know....  */
-  printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
-  printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
-          "4"
-#else
-	  ""
-#endif
-         ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
-  printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
-  printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
-  int version;
-  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
-  if (version < 4)
-    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
-  else
-    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
-  exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
-  printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
-  printf ("ns32k-encore-mach\n"); exit (0);
-#else
-  printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
-  printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
-  printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
-  printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
-    struct utsname un;
-
-    uname(&un);
-
-    if (strncmp(un.version, "V2", 2) == 0) {
-	printf ("i386-sequent-ptx2\n"); exit (0);
-    }
-    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
-	printf ("i386-sequent-ptx1\n"); exit (0);
-    }
-    printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-#  include <sys/param.h>
-#  if defined (BSD)
-#   if BSD == 43
-      printf ("vax-dec-bsd4.3\n"); exit (0);
-#   else
-#    if BSD == 199006
-      printf ("vax-dec-bsd4.3reno\n"); exit (0);
-#    else
-      printf ("vax-dec-bsd\n"); exit (0);
-#    endif
-#   endif
-#  else
-    printf ("vax-dec-bsd\n"); exit (0);
-#  endif
-# else
-    printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
-  printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
-  exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
-	{ echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
-    case `getsysinfo -f cpu_type` in
-    c1*)
-	echo c1-convex-bsd
-	exit ;;
-    c2*)
-	if getsysinfo -f scalar_acc
-	then echo c32-convex-bsd
-	else echo c2-convex-bsd
-	fi
-	exit ;;
-    c34*)
-	echo c34-convex-bsd
-	exit ;;
-    c38*)
-	echo c38-convex-bsd
-	exit ;;
-    c4*)
-	echo c4-convex-bsd
-	exit ;;
-    esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
-  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches at gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo               = `(hostinfo) 2>/dev/null`
-/bin/universe          = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch              = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM  = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/config/config.sub b/config/config.sub
deleted file mode 100755
index 2851647..0000000
--- a/config/config.sub
+++ /dev/null
@@ -1,1599 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-12-11'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine.  It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches at gnu.org>.  Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support.  The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
-       $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
-  -h, --help         print this help, then exit
-  -t, --time-stamp   print date of last modification, then exit
-  -v, --version      print version number, then exit
-
-Report bugs and patches to <config-patches at gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions.  There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
-  case $1 in
-    --time-stamp | --time* | -t )
-       echo "$timestamp" ; exit ;;
-    --version | -v )
-       echo "$version" ; exit ;;
-    --help | --h* | -h )
-       echo "$usage"; exit ;;
-    -- )     # Stop option processing
-       shift; break ;;
-    - )	# Use stdin as input.
-       break ;;
-    -* )
-       echo "$me: invalid option $1$help"
-       exit 1 ;;
-
-    *local*)
-       # First pass through any local machine types.
-       echo $1
-       exit ;;
-
-    * )
-       break ;;
-  esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
-    exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
-    exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
-    os=-$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-    ;;
-  *)
-    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-    if [ $basic_machine != $1 ]
-    then os=`echo $1 | sed 's/.*-/-/'`
-    else os=; fi
-    ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work.  We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
-	-sun*os*)
-		# Prevent following clause from handling this invalid input.
-		;;
-	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis | -knuth | -cray)
-		os=
-		basic_machine=$1
-		;;
-	-sim | -cisco | -oki | -wec | -winbond)
-		os=
-		basic_machine=$1
-		;;
-	-scout)
-		;;
-	-wrs)
-		os=-vxworks
-		basic_machine=$1
-		;;
-	-chorusos*)
-		os=-chorusos
-		basic_machine=$1
-		;;
- 	-chorusrdb)
- 		os=-chorusrdb
-		basic_machine=$1
- 		;;
-	-hiux*)
-		os=-hiuxwe2
-		;;
-	-sco6)
-		os=-sco5v6
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco5)
-		os=-sco3.2v5
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco4)
-		os=-sco3.2v4
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco3.2.[4-9]*)
-		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco3.2v[4-9]*)
-		# Don't forget version if it is 3.2v4 or newer.
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco5v6*)
-		# Don't forget version if it is 3.2v4 or newer.
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-sco*)
-		os=-sco3.2v2
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-udk*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-isc)
-		os=-isc2.2
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-clix*)
-		basic_machine=clipper-intergraph
-		;;
-	-isc*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-		;;
-	-lynx*)
-		os=-lynxos
-		;;
-	-ptx*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
-		;;
-	-windowsnt*)
-		os=`echo $os | sed -e 's/windowsnt/winnt/'`
-		;;
-	-psos*)
-		os=-psos
-		;;
-	-mint | -mint[0-9]*)
-		basic_machine=m68k-atari
-		os=-mint
-		;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
-	# Recognize the basic CPU types without company name.
-	# Some are omitted here because they have special meanings below.
-	1750a | 580 \
-	| a29k \
-	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
-	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
-	| am33_2.0 \
-	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
-	| bfin \
-	| c4x | clipper \
-	| d10v | d30v | dlx | dsp16xx \
-	| fr30 | frv \
-	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-	| i370 | i860 | i960 | ia64 \
-	| ip2k | iq2000 \
-	| m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
-	| mips | mipsbe | mipseb | mipsel | mipsle \
-	| mips16 \
-	| mips64 | mips64el \
-	| mips64vr | mips64vrel \
-	| mips64orion | mips64orionel \
-	| mips64vr4100 | mips64vr4100el \
-	| mips64vr4300 | mips64vr4300el \
-	| mips64vr5000 | mips64vr5000el \
-	| mips64vr5900 | mips64vr5900el \
-	| mipsisa32 | mipsisa32el \
-	| mipsisa32r2 | mipsisa32r2el \
-	| mipsisa64 | mipsisa64el \
-	| mipsisa64r2 | mipsisa64r2el \
-	| mipsisa64sb1 | mipsisa64sb1el \
-	| mipsisa64sr71k | mipsisa64sr71kel \
-	| mipstx39 | mipstx39el \
-	| mn10200 | mn10300 \
-	| mt \
-	| msp430 \
-	| ns16k | ns32k \
-	| or32 \
-	| pdp10 | pdp11 | pj | pjl \
-	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
-	| pyramid \
-	| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
-	| sh64 | sh64le \
-	| sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
-	| sparcv8 | sparcv9 | sparcv9b \
-	| strongarm \
-	| tahoe | thumb | tic4x | tic80 | tron \
-	| v850 | v850e \
-	| we32k \
-	| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
-	| z8k)
-		basic_machine=$basic_machine-unknown
-		;;
-	m32c)
-		basic_machine=$basic_machine-unknown
-		;;
-	m6811 | m68hc11 | m6812 | m68hc12)
-		# Motorola 68HC11/12.
-		basic_machine=$basic_machine-unknown
-		os=-none
-		;;
-	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
-		;;
-	ms1)
-		basic_machine=mt-unknown
-		;;
-
-	# We use `pc' rather than `unknown'
-	# because (1) that's what they normally are, and
-	# (2) the word "unknown" tends to confuse beginning users.
-	i*86 | x86_64)
-	  basic_machine=$basic_machine-pc
-	  ;;
-	# Object if more than one company name word.
-	*-*-*)
-		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-		exit 1
-		;;
-	# Recognize the basic CPU types with company name.
-	580-* \
-	| a29k-* \
-	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
-	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
-	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
-	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
-	| avr-* \
-	| bfin-* | bs2000-* \
-	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-	| clipper-* | craynv-* | cydra-* \
-	| d10v-* | d30v-* | dlx-* \
-	| elxsi-* \
-	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
-	| h8300-* | h8500-* \
-	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
-	| i*86-* | i860-* | i960-* | ia64-* \
-	| ip2k-* | iq2000-* \
-	| m32r-* | m32rle-* \
-	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | maxq-* | mcore-* \
-	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
-	| mips16-* \
-	| mips64-* | mips64el-* \
-	| mips64vr-* | mips64vrel-* \
-	| mips64orion-* | mips64orionel-* \
-	| mips64vr4100-* | mips64vr4100el-* \
-	| mips64vr4300-* | mips64vr4300el-* \
-	| mips64vr5000-* | mips64vr5000el-* \
-	| mips64vr5900-* | mips64vr5900el-* \
-	| mipsisa32-* | mipsisa32el-* \
-	| mipsisa32r2-* | mipsisa32r2el-* \
-	| mipsisa64-* | mipsisa64el-* \
-	| mipsisa64r2-* | mipsisa64r2el-* \
-	| mipsisa64sb1-* | mipsisa64sb1el-* \
-	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
-	| mipstx39-* | mipstx39el-* \
-	| mmix-* \
-	| mt-* \
-	| msp430-* \
-	| none-* | np1-* | ns16k-* | ns32k-* \
-	| orion-* \
-	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
-	| pyramid-* \
-	| romp-* | rs6000-* \
-	| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
-	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-	| sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
-	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
-	| tahoe-* | thumb-* \
-	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
-	| tron-* \
-	| v850-* | v850e-* | vax-* \
-	| we32k-* \
-	| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
-	| xstormy16-* | xtensa-* \
-	| ymp-* \
-	| z8k-*)
-		;;
-	m32c-*)
-		;;
-	# Recognize the various machine names and aliases which stand
-	# for a CPU type and a company and sometimes even an OS.
-	386bsd)
-		basic_machine=i386-unknown
-		os=-bsd
-		;;
-	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
-		basic_machine=m68000-att
-		;;
-	3b*)
-		basic_machine=we32k-att
-		;;
-	a29khif)
-		basic_machine=a29k-amd
-		os=-udi
-		;;
-    	abacus)
-		basic_machine=abacus-unknown
-		;;
-	adobe68k)
-		basic_machine=m68010-adobe
-		os=-scout
-		;;
-	alliant | fx80)
-		basic_machine=fx80-alliant
-		;;
-	altos | altos3068)
-		basic_machine=m68k-altos
-		;;
-	am29k)
-		basic_machine=a29k-none
-		os=-bsd
-		;;
-	amd64)
-		basic_machine=x86_64-pc
-		;;
-	amd64-*)
-		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	amdahl)
-		basic_machine=580-amdahl
-		os=-sysv
-		;;
-	amiga | amiga-*)
-		basic_machine=m68k-unknown
-		;;
-	amigaos | amigados)
-		basic_machine=m68k-unknown
-		os=-amigaos
-		;;
-	amigaunix | amix)
-		basic_machine=m68k-unknown
-		os=-sysv4
-		;;
-	apollo68)
-		basic_machine=m68k-apollo
-		os=-sysv
-		;;
-	apollo68bsd)
-		basic_machine=m68k-apollo
-		os=-bsd
-		;;
-	aux)
-		basic_machine=m68k-apple
-		os=-aux
-		;;
-	balance)
-		basic_machine=ns32k-sequent
-		os=-dynix
-		;;
-	c90)
-		basic_machine=c90-cray
-		os=-unicos
-		;;
-	convex-c1)
-		basic_machine=c1-convex
-		os=-bsd
-		;;
-	convex-c2)
-		basic_machine=c2-convex
-		os=-bsd
-		;;
-	convex-c32)
-		basic_machine=c32-convex
-		os=-bsd
-		;;
-	convex-c34)
-		basic_machine=c34-convex
-		os=-bsd
-		;;
-	convex-c38)
-		basic_machine=c38-convex
-		os=-bsd
-		;;
-	cray | j90)
-		basic_machine=j90-cray
-		os=-unicos
-		;;
-	craynv)
-		basic_machine=craynv-cray
-		os=-unicosmp
-		;;
-	cr16c)
-		basic_machine=cr16c-unknown
-		os=-elf
-		;;
-	crds | unos)
-		basic_machine=m68k-crds
-		;;
-	crisv32 | crisv32-* | etraxfs*)
-		basic_machine=crisv32-axis
-		;;
-	cris | cris-* | etrax*)
-		basic_machine=cris-axis
-		;;
-	crx)
-		basic_machine=crx-unknown
-		os=-elf
-		;;
-	da30 | da30-*)
-		basic_machine=m68k-da30
-		;;
-	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
-		basic_machine=mips-dec
-		;;
-	decsystem10* | dec10*)
-		basic_machine=pdp10-dec
-		os=-tops10
-		;;
-	decsystem20* | dec20*)
-		basic_machine=pdp10-dec
-		os=-tops20
-		;;
-	delta | 3300 | motorola-3300 | motorola-delta \
-	      | 3300-motorola | delta-motorola)
-		basic_machine=m68k-motorola
-		;;
-	delta88)
-		basic_machine=m88k-motorola
-		os=-sysv3
-		;;
-	djgpp)
-		basic_machine=i586-pc
-		os=-msdosdjgpp
-		;;
-	dpx20 | dpx20-*)
-		basic_machine=rs6000-bull
-		os=-bosx
-		;;
-	dpx2* | dpx2*-bull)
-		basic_machine=m68k-bull
-		os=-sysv3
-		;;
-	ebmon29k)
-		basic_machine=a29k-amd
-		os=-ebmon
-		;;
-	elxsi)
-		basic_machine=elxsi-elxsi
-		os=-bsd
-		;;
-	encore | umax | mmax)
-		basic_machine=ns32k-encore
-		;;
-	es1800 | OSE68k | ose68k | ose | OSE)
-		basic_machine=m68k-ericsson
-		os=-ose
-		;;
-	fx2800)
-		basic_machine=i860-alliant
-		;;
-	genix)
-		basic_machine=ns32k-ns
-		;;
-	gmicro)
-		basic_machine=tron-gmicro
-		os=-sysv
-		;;
-	go32)
-		basic_machine=i386-pc
-		os=-go32
-		;;
-	h3050r* | hiux*)
-		basic_machine=hppa1.1-hitachi
-		os=-hiuxwe2
-		;;
-	h8300hms)
-		basic_machine=h8300-hitachi
-		os=-hms
-		;;
-	h8300xray)
-		basic_machine=h8300-hitachi
-		os=-xray
-		;;
-	h8500hms)
-		basic_machine=h8500-hitachi
-		os=-hms
-		;;
-	harris)
-		basic_machine=m88k-harris
-		os=-sysv3
-		;;
-	hp300-*)
-		basic_machine=m68k-hp
-		;;
-	hp300bsd)
-		basic_machine=m68k-hp
-		os=-bsd
-		;;
-	hp300hpux)
-		basic_machine=m68k-hp
-		os=-hpux
-		;;
-	hp3k9[0-9][0-9] | hp9[0-9][0-9])
-		basic_machine=hppa1.0-hp
-		;;
-	hp9k2[0-9][0-9] | hp9k31[0-9])
-		basic_machine=m68000-hp
-		;;
-	hp9k3[2-9][0-9])
-		basic_machine=m68k-hp
-		;;
-	hp9k6[0-9][0-9] | hp6[0-9][0-9])
-		basic_machine=hppa1.0-hp
-		;;
-	hp9k7[0-79][0-9] | hp7[0-79][0-9])
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k78[0-9] | hp78[0-9])
-		# FIXME: really hppa2.0-hp
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
-		# FIXME: really hppa2.0-hp
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k8[0-9][13679] | hp8[0-9][13679])
-		basic_machine=hppa1.1-hp
-		;;
-	hp9k8[0-9][0-9] | hp8[0-9][0-9])
-		basic_machine=hppa1.0-hp
-		;;
-	hppa-next)
-		os=-nextstep3
-		;;
-	hppaosf)
-		basic_machine=hppa1.1-hp
-		os=-osf
-		;;
-	hppro)
-		basic_machine=hppa1.1-hp
-		os=-proelf
-		;;
-	i370-ibm* | ibm*)
-		basic_machine=i370-ibm
-		;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
-	i*86v32)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-sysv32
-		;;
-	i*86v4*)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-sysv4
-		;;
-	i*86v)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-sysv
-		;;
-	i*86sol2)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-		os=-solaris2
-		;;
-	i386mach)
-		basic_machine=i386-mach
-		os=-mach
-		;;
-	i386-vsta | vsta)
-		basic_machine=i386-unknown
-		os=-vsta
-		;;
-	iris | iris4d)
-		basic_machine=mips-sgi
-		case $os in
-		    -irix*)
-			;;
-		    *)
-			os=-irix4
-			;;
-		esac
-		;;
-	isi68 | isi)
-		basic_machine=m68k-isi
-		os=-sysv
-		;;
-	m88k-omron*)
-		basic_machine=m88k-omron
-		;;
-	magnum | m3230)
-		basic_machine=mips-mips
-		os=-sysv
-		;;
-	merlin)
-		basic_machine=ns32k-utek
-		os=-sysv
-		;;
-	mingw32)
-		basic_machine=i386-pc
-		os=-mingw32
-		;;
-	miniframe)
-		basic_machine=m68000-convergent
-		;;
-	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
-		basic_machine=m68k-atari
-		os=-mint
-		;;
-	mips3*-*)
-		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
-		;;
-	mips3*)
-		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
-		;;
-	monitor)
-		basic_machine=m68k-rom68k
-		os=-coff
-		;;
-	morphos)
-		basic_machine=powerpc-unknown
-		os=-morphos
-		;;
-	msdos)
-		basic_machine=i386-pc
-		os=-msdos
-		;;
-	ms1-*)
-		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
-		;;
-	mvs)
-		basic_machine=i370-ibm
-		os=-mvs
-		;;
-	ncr3000)
-		basic_machine=i486-ncr
-		os=-sysv4
-		;;
-	netbsd386)
-		basic_machine=i386-unknown
-		os=-netbsd
-		;;
-	netwinder)
-		basic_machine=armv4l-rebel
-		os=-linux
-		;;
-	news | news700 | news800 | news900)
-		basic_machine=m68k-sony
-		os=-newsos
-		;;
-	news1000)
-		basic_machine=m68030-sony
-		os=-newsos
-		;;
-	news-3600 | risc-news)
-		basic_machine=mips-sony
-		os=-newsos
-		;;
-	necv70)
-		basic_machine=v70-nec
-		os=-sysv
-		;;
-	next | m*-next )
-		basic_machine=m68k-next
-		case $os in
-		    -nextstep* )
-			;;
-		    -ns2*)
-		      os=-nextstep2
-			;;
-		    *)
-		      os=-nextstep3
-			;;
-		esac
-		;;
-	nh3000)
-		basic_machine=m68k-harris
-		os=-cxux
-		;;
-	nh[45]000)
-		basic_machine=m88k-harris
-		os=-cxux
-		;;
-	nindy960)
-		basic_machine=i960-intel
-		os=-nindy
-		;;
-	mon960)
-		basic_machine=i960-intel
-		os=-mon960
-		;;
-	nonstopux)
-		basic_machine=mips-compaq
-		os=-nonstopux
-		;;
-	np1)
-		basic_machine=np1-gould
-		;;
-	nsr-tandem)
-		basic_machine=nsr-tandem
-		;;
-	op50n-* | op60c-*)
-		basic_machine=hppa1.1-oki
-		os=-proelf
-		;;
-	openrisc | openrisc-*)
-		basic_machine=or32-unknown
-		;;
-	os400)
-		basic_machine=powerpc-ibm
-		os=-os400
-		;;
-	OSE68000 | ose68000)
-		basic_machine=m68000-ericsson
-		os=-ose
-		;;
-	os68k)
-		basic_machine=m68k-none
-		os=-os68k
-		;;
-	pa-hitachi)
-		basic_machine=hppa1.1-hitachi
-		os=-hiuxwe2
-		;;
-	paragon)
-		basic_machine=i860-intel
-		os=-osf
-		;;
-	pbd)
-		basic_machine=sparc-tti
-		;;
-	pbb)
-		basic_machine=m68k-tti
-		;;
-	pc532 | pc532-*)
-		basic_machine=ns32k-pc532
-		;;
-	pentium | p5 | k5 | k6 | nexgen | viac3)
-		basic_machine=i586-pc
-		;;
-	pentiumpro | p6 | 6x86 | athlon | athlon_*)
-		basic_machine=i686-pc
-		;;
-	pentiumii | pentium2 | pentiumiii | pentium3)
-		basic_machine=i686-pc
-		;;
-	pentium4)
-		basic_machine=i786-pc
-		;;
-	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pentiumpro-* | p6-* | 6x86-* | athlon-*)
-		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pentium4-*)
-		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	pn)
-		basic_machine=pn-gould
-		;;
-	power)	basic_machine=power-ibm
-		;;
-	ppc)	basic_machine=powerpc-unknown
-		;;
-	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ppcle | powerpclittle | ppc-le | powerpc-little)
-		basic_machine=powerpcle-unknown
-		;;
-	ppcle-* | powerpclittle-*)
-		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ppc64)	basic_machine=powerpc64-unknown
-		;;
-	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
-		basic_machine=powerpc64le-unknown
-		;;
-	ppc64le-* | powerpc64little-*)
-		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
-		;;
-	ps2)
-		basic_machine=i386-ibm
-		;;
-	pw32)
-		basic_machine=i586-unknown
-		os=-pw32
-		;;
-	rdos)
-		basic_machine=i386-pc
-		os=-rdos
-		;;
-	rom68k)
-		basic_machine=m68k-rom68k
-		os=-coff
-		;;
-	rm[46]00)
-		basic_machine=mips-siemens
-		;;
-	rtpc | rtpc-*)
-		basic_machine=romp-ibm
-		;;
-	s390 | s390-*)
-		basic_machine=s390-ibm
-		;;
-	s390x | s390x-*)
-		basic_machine=s390x-ibm
-		;;
-	sa29200)
-		basic_machine=a29k-amd
-		os=-udi
-		;;
-	sb1)
-		basic_machine=mipsisa64sb1-unknown
-		;;
-	sb1el)
-		basic_machine=mipsisa64sb1el-unknown
-		;;
-	sei)
-		basic_machine=mips-sei
-		os=-seiux
-		;;
-	sequent)
-		basic_machine=i386-sequent
-		;;
-	sh)
-		basic_machine=sh-hitachi
-		os=-hms
-		;;
-	sh64)
-		basic_machine=sh64-unknown
-		;;
-	sparclite-wrs | simso-wrs)
-		basic_machine=sparclite-wrs
-		os=-vxworks
-		;;
-	sps7)
-		basic_machine=m68k-bull
-		os=-sysv2
-		;;
-	spur)
-		basic_machine=spur-unknown
-		;;
-	st2000)
-		basic_machine=m68k-tandem
-		;;
-	stratus)
-		basic_machine=i860-stratus
-		os=-sysv4
-		;;
-	sun2)
-		basic_machine=m68000-sun
-		;;
-	sun2os3)
-		basic_machine=m68000-sun
-		os=-sunos3
-		;;
-	sun2os4)
-		basic_machine=m68000-sun
-		os=-sunos4
-		;;
-	sun3os3)
-		basic_machine=m68k-sun
-		os=-sunos3
-		;;
-	sun3os4)
-		basic_machine=m68k-sun
-		os=-sunos4
-		;;
-	sun4os3)
-		basic_machine=sparc-sun
-		os=-sunos3
-		;;
-	sun4os4)
-		basic_machine=sparc-sun
-		os=-sunos4
-		;;
-	sun4sol2)
-		basic_machine=sparc-sun
-		os=-solaris2
-		;;
-	sun3 | sun3-*)
-		basic_machine=m68k-sun
-		;;
-	sun4)
-		basic_machine=sparc-sun
-		;;
-	sun386 | sun386i | roadrunner)
-		basic_machine=i386-sun
-		;;
-	sv1)
-		basic_machine=sv1-cray
-		os=-unicos
-		;;
-	symmetry)
-		basic_machine=i386-sequent
-		os=-dynix
-		;;
-	t3e)
-		basic_machine=alphaev5-cray
-		os=-unicos
-		;;
-	t90)
-		basic_machine=t90-cray
-		os=-unicos
-		;;
-	tic54x | c54x*)
-		basic_machine=tic54x-unknown
-		os=-coff
-		;;
-	tic55x | c55x*)
-		basic_machine=tic55x-unknown
-		os=-coff
-		;;
-	tic6x | c6x*)
-		basic_machine=tic6x-unknown
-		os=-coff
-		;;
-	tx39)
-		basic_machine=mipstx39-unknown
-		;;
-	tx39el)
-		basic_machine=mipstx39el-unknown
-		;;
-	toad1)
-		basic_machine=pdp10-xkl
-		os=-tops20
-		;;
-	tower | tower-32)
-		basic_machine=m68k-ncr
-		;;
-	tpf)
-		basic_machine=s390x-ibm
-		os=-tpf
-		;;
-	udi29k)
-		basic_machine=a29k-amd
-		os=-udi
-		;;
-	ultra3)
-		basic_machine=a29k-nyu
-		os=-sym1
-		;;
-	v810 | necv810)
-		basic_machine=v810-nec
-		os=-none
-		;;
-	vaxv)
-		basic_machine=vax-dec
-		os=-sysv
-		;;
-	vms)
-		basic_machine=vax-dec
-		os=-vms
-		;;
-	vpp*|vx|vx-*)
-		basic_machine=f301-fujitsu
-		;;
-	vxworks960)
-		basic_machine=i960-wrs
-		os=-vxworks
-		;;
-	vxworks68)
-		basic_machine=m68k-wrs
-		os=-vxworks
-		;;
-	vxworks29k)
-		basic_machine=a29k-wrs
-		os=-vxworks
-		;;
-	w65*)
-		basic_machine=w65-wdc
-		os=-none
-		;;
-	w89k-*)
-		basic_machine=hppa1.1-winbond
-		os=-proelf
-		;;
-	xbox)
-		basic_machine=i686-pc
-		os=-mingw32
-		;;
-	xps | xps100)
-		basic_machine=xps100-honeywell
-		;;
-	ymp)
-		basic_machine=ymp-cray
-		os=-unicos
-		;;
-	z8k-*-coff)
-		basic_machine=z8k-unknown
-		os=-sim
-		;;
-	none)
-		basic_machine=none-none
-		os=-none
-		;;
-
-# Here we handle the default manufacturer of certain CPU types.  It is in
-# some cases the only manufacturer, in others, it is the most popular.
-	w89k)
-		basic_machine=hppa1.1-winbond
-		;;
-	op50n)
-		basic_machine=hppa1.1-oki
-		;;
-	op60c)
-		basic_machine=hppa1.1-oki
-		;;
-	romp)
-		basic_machine=romp-ibm
-		;;
-	mmix)
-		basic_machine=mmix-knuth
-		;;
-	rs6000)
-		basic_machine=rs6000-ibm
-		;;
-	vax)
-		basic_machine=vax-dec
-		;;
-	pdp10)
-		# there are many clones, so DEC is not a safe bet
-		basic_machine=pdp10-unknown
-		;;
-	pdp11)
-		basic_machine=pdp11-dec
-		;;
-	we32k)
-		basic_machine=we32k-att
-		;;
-	sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
-		basic_machine=sh-unknown
-		;;
-	sparc | sparcv8 | sparcv9 | sparcv9b)
-		basic_machine=sparc-sun
-		;;
-	cydra)
-		basic_machine=cydra-cydrome
-		;;
-	orion)
-		basic_machine=orion-highlevel
-		;;
-	orion105)
-		basic_machine=clipper-highlevel
-		;;
-	mac | mpw | mac-mpw)
-		basic_machine=m68k-apple
-		;;
-	pmac | pmac-mpw)
-		basic_machine=powerpc-apple
-		;;
-	*-unknown)
-		# Make sure to match an already-canonicalized machine name.
-		;;
-	*)
-		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-		exit 1
-		;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
-	*-digital*)
-		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
-		;;
-	*-commodore*)
-		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
-		;;
-	*)
-		;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
-	# -solaris* is a basic system type, with this one exception.
-	-solaris1 | -solaris1.*)
-		os=`echo $os | sed -e 's|solaris1|sunos4|'`
-		;;
-	-solaris)
-		os=-solaris2
-		;;
-	-svr4*)
-		os=-sysv4
-		;;
-	-unixware*)
-		os=-sysv4.2uw
-		;;
-	-gnu/linux*)
-		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
-		;;
-	# First accept the basic system types.
-	# The portable systems comes first.
-	# Each alternative MUST END IN A *, to match a version number.
-	# -sysv* is not here because it comes later, after sysvr4.
-	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
-	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
-	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
-	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-	      | -aos* \
-	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
-	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
-	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
-	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
-	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
-	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-	      | -chorusos* | -chorusrdb* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
-	      | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
-	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos*)
-	# Remember, each alternative MUST END IN *, to match a version number.
-		;;
-	-qnx*)
-		case $basic_machine in
-		    x86-* | i*86-*)
-			;;
-		    *)
-			os=-nto$os
-			;;
-		esac
-		;;
-	-nto-qnx*)
-		;;
-	-nto*)
-		os=`echo $os | sed -e 's|nto|nto-qnx|'`
-		;;
-	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
-	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
-		;;
-	-mac*)
-		os=`echo $os | sed -e 's|mac|macos|'`
-		;;
-	-linux-dietlibc)
-		os=-linux-dietlibc
-		;;
-	-linux*)
-		os=`echo $os | sed -e 's|linux|linux-gnu|'`
-		;;
-	-sunos5*)
-		os=`echo $os | sed -e 's|sunos5|solaris2|'`
-		;;
-	-sunos6*)
-		os=`echo $os | sed -e 's|sunos6|solaris3|'`
-		;;
-	-opened*)
-		os=-openedition
-		;;
-        -os400*)
-		os=-os400
-		;;
-	-wince*)
-		os=-wince
-		;;
-	-osfrose*)
-		os=-osfrose
-		;;
-	-osf*)
-		os=-osf
-		;;
-	-utek*)
-		os=-bsd
-		;;
-	-dynix*)
-		os=-bsd
-		;;
-	-acis*)
-		os=-aos
-		;;
-	-atheos*)
-		os=-atheos
-		;;
-	-syllable*)
-		os=-syllable
-		;;
-	-386bsd)
-		os=-bsd
-		;;
-	-ctix* | -uts*)
-		os=-sysv
-		;;
-	-nova*)
-		os=-rtmk-nova
-		;;
-	-ns2 )
-		os=-nextstep2
-		;;
-	-nsk*)
-		os=-nsk
-		;;
-	# Preserve the version number of sinix5.
-	-sinix5.*)
-		os=`echo $os | sed -e 's|sinix|sysv|'`
-		;;
-	-sinix*)
-		os=-sysv4
-		;;
-        -tpf*)
-		os=-tpf
-		;;
-	-triton*)
-		os=-sysv3
-		;;
-	-oss*)
-		os=-sysv3
-		;;
-	-svr4)
-		os=-sysv4
-		;;
-	-svr3)
-		os=-sysv3
-		;;
-	-sysvr4)
-		os=-sysv4
-		;;
-	# This must come after -sysvr4.
-	-sysv*)
-		;;
-	-ose*)
-		os=-ose
-		;;
-	-es1800*)
-		os=-ose
-		;;
-	-xenix)
-		os=-xenix
-		;;
-	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-		os=-mint
-		;;
-	-aros*)
-		os=-aros
-		;;
-	-kaos*)
-		os=-kaos
-		;;
-	-zvmoe)
-		os=-zvmoe
-		;;
-	-none)
-		;;
-	*)
-		# Get rid of the `-' at the beginning of $os.
-		os=`echo $os | sed 's/[^-]*-//'`
-		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
-		exit 1
-		;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system.  Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
-	*-acorn)
-		os=-riscix1.2
-		;;
-	arm*-rebel)
-		os=-linux
-		;;
-	arm*-semi)
-		os=-aout
-		;;
-    c4x-* | tic4x-*)
-        os=-coff
-        ;;
-	# This must come before the *-dec entry.
-	pdp10-*)
-		os=-tops20
-		;;
-	pdp11-*)
-		os=-none
-		;;
-	*-dec | vax-*)
-		os=-ultrix4.2
-		;;
-	m68*-apollo)
-		os=-domain
-		;;
-	i386-sun)
-		os=-sunos4.0.2
-		;;
-	m68000-sun)
-		os=-sunos3
-		# This also exists in the configure program, but was not the
-		# default.
-		# os=-sunos4
-		;;
-	m68*-cisco)
-		os=-aout
-		;;
-	mips*-cisco)
-		os=-elf
-		;;
-	mips*-*)
-		os=-elf
-		;;
-	or32-*)
-		os=-coff
-		;;
-	*-tti)	# must be before sparc entry or we get the wrong os.
-		os=-sysv3
-		;;
-	sparc-* | *-sun)
-		os=-sunos4.1.1
-		;;
-	*-be)
-		os=-beos
-		;;
-	*-haiku)
-		os=-haiku
-		;;
-	*-ibm)
-		os=-aix
-		;;
-    	*-knuth)
-		os=-mmixware
-		;;
-	*-wec)
-		os=-proelf
-		;;
-	*-winbond)
-		os=-proelf
-		;;
-	*-oki)
-		os=-proelf
-		;;
-	*-hp)
-		os=-hpux
-		;;
-	*-hitachi)
-		os=-hiux
-		;;
-	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
-		os=-sysv
-		;;
-	*-cbm)
-		os=-amigaos
-		;;
-	*-dg)
-		os=-dgux
-		;;
-	*-dolphin)
-		os=-sysv3
-		;;
-	m68k-ccur)
-		os=-rtu
-		;;
-	m88k-omron*)
-		os=-luna
-		;;
-	*-next )
-		os=-nextstep
-		;;
-	*-sequent)
-		os=-ptx
-		;;
-	*-crds)
-		os=-unos
-		;;
-	*-ns)
-		os=-genix
-		;;
-	i370-*)
-		os=-mvs
-		;;
-	*-next)
-		os=-nextstep3
-		;;
-	*-gould)
-		os=-sysv
-		;;
-	*-highlevel)
-		os=-bsd
-		;;
-	*-encore)
-		os=-bsd
-		;;
-	*-sgi)
-		os=-irix
-		;;
-	*-siemens)
-		os=-sysv4
-		;;
-	*-masscomp)
-		os=-rtu
-		;;
-	f30[01]-fujitsu | f700-fujitsu)
-		os=-uxpv
-		;;
-	*-rom68k)
-		os=-coff
-		;;
-	*-*bug)
-		os=-coff
-		;;
-	*-apple)
-		os=-macos
-		;;
-	*-atari*)
-		os=-mint
-		;;
-	*)
-		os=-none
-		;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer.  We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
-	*-unknown)
-		case $os in
-			-riscix*)
-				vendor=acorn
-				;;
-			-sunos*)
-				vendor=sun
-				;;
-			-aix*)
-				vendor=ibm
-				;;
-			-beos*)
-				vendor=be
-				;;
-			-hpux*)
-				vendor=hp
-				;;
-			-mpeix*)
-				vendor=hp
-				;;
-			-hiux*)
-				vendor=hitachi
-				;;
-			-unos*)
-				vendor=crds
-				;;
-			-dgux*)
-				vendor=dg
-				;;
-			-luna*)
-				vendor=omron
-				;;
-			-genix*)
-				vendor=ns
-				;;
-			-mvs* | -opened*)
-				vendor=ibm
-				;;
-			-os400*)
-				vendor=ibm
-				;;
-			-ptx*)
-				vendor=sequent
-				;;
-			-tpf*)
-				vendor=ibm
-				;;
-			-vxsim* | -vxworks* | -windiss*)
-				vendor=wrs
-				;;
-			-aux*)
-				vendor=apple
-				;;
-			-hms*)
-				vendor=hitachi
-				;;
-			-mpw* | -macos*)
-				vendor=apple
-				;;
-			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-				vendor=atari
-				;;
-			-vos*)
-				vendor=stratus
-				;;
-		esac
-		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
-		;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/config/cust_general.m4 b/config/cust_general.m4
deleted file mode 100644
index 73c0f7c..0000000
--- a/config/cust_general.m4
+++ /dev/null
@@ -1,94 +0,0 @@
-# This file is part of Autoconf.                       -*- Autoconf -*-
-# Parameterized macros.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# As a special exception, the Free Software Foundation gives unlimited
-# permission to copy, distribute and modify the configure scripts that
-# are the output of Autoconf.  You need not follow the terms of the GNU
-# General Public License when using or distributing such scripts, even
-# though portions of the text of Autoconf appear in them.  The GNU
-# General Public License (GPL) does govern all other use of the material
-# that constitutes the Autoconf program.
-#
-# Certain portions of the Autoconf source text are designed to be copied
-# (in certain cases, depending on the input) into the output of
-# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
-# source text consists of comments plus executable code that decides which
-# of the data portions to output in any given case.  We call these
-# comments and executable code the "non-data" portions.  Autoconf never
-# copies any of the non-data portions into its output.
-#
-# This special exception to the GPL applies to versions of Autoconf
-# released by the Free Software Foundation.  When you make and
-# distribute a modified version of Autoconf, you may extend this special
-# exception to the GPL to apply to your modified version as well, *unless*
-# your modified version has the potential to copy into its output some
-# of the text that was the non-data portion of the version that you started
-# with.  (In other words, unless your change moves or copies text from
-# the non-data portions to the data portions.)  If your modification has
-# such potential, you must delete any notice of this special exception
-# to the GPL from your modified version.
-#
-# Written by David MacKenzie, with help from
-# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
-# Roland McGrath, Noah Friedman, david d zuhn, and many others.
-
-
-# _AC_MSG_LOG_CONFTEST_GENERAL
-# ----------------------------
-m4_define([_AC_MSG_LOG_CONFTEST_GENERAL],
-[echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
-if test -f conftest.c ; then
-  sed 's/^/| /' conftest.c >&AS_MESSAGE_LOG_FD
-elif test -f conftest.cc ; then
-  sed 's/^/| /' conftest.cc >&AS_MESSAGE_LOG_FD
-elif test -f conftest.f ; then
-  sed 's/^/| /' conftest.f >&AS_MESSAGE_LOG_FD
-elif test -f conftest.${FC_SRCEXT-f} ; then
-  sed 's/^/| /' conftest.${FC_SRCEXT-f} >&AS_MESSAGE_LOG_FD
-fi
-])
-
-
-# _AC_LINKONLY_IFELSE(PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# ------------------------------------------------------------------
-# Try to link PROGRAM (empty).
-# This macro can be used during the selection of a compiler.
-m4_define([_AC_LINKONLY_IFELSE],
-[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
-AS_IF([_AC_EVAL_STDERR($ac_linkonly) &&
-	 AC_TRY_COMMAND([test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag"
-			 || test ! -s conftest.err]) &&
-	 AC_TRY_COMMAND([test -s conftest$ac_exeext])],
-      [$2],
-      [_AC_MSG_LOG_CONFTEST_GENERAL
-m4_ifvaln([$3], [$3])dnl])[]dnl
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
-])# _AC_LINKONLY_IFELSE
-
-
-# AC_LINKONLY_IFELSE(PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# -----------------------------------------------------------------
-# Try to link PROGRAM.  Requires that the compiler for the current
-# language was checked for, hence do not use this macro in macros looking
-# for a compiler.
-AC_DEFUN([AC_LINKONLY_IFELSE],
-[AC_LANG_COMPILER_REQUIRE()dnl
-_AC_LINKONLY_IFELSE($@)])
diff --git a/config/install-sh b/config/install-sh
deleted file mode 100755
index e9de238..0000000
--- a/config/install-sh
+++ /dev/null
@@ -1,251 +0,0 @@
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5 (mit/util/scripts/install.sh).
-#
-# Copyright 1991 by the Massachusetts Institute of Technology
-#
-# Permission to use, copy, modify, distribute, and sell this software and its
-# documentation for any purpose is hereby granted without fee, provided that
-# the above copyright notice appear in all copies and that both that
-# copyright notice and this permission notice appear in supporting
-# documentation, and that the name of M.I.T. not be used in advertising or
-# publicity pertaining to distribution of the software without specific,
-# written prior permission.  M.I.T. makes no representations about the
-# suitability of this software for any purpose.  It is provided "as is"
-# without express or implied warranty.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.  It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
-    case $1 in
-	-c) instcmd="$cpprog"
-	    shift
-	    continue;;
-
-	-d) dir_arg=true
-	    shift
-	    continue;;
-
-	-m) chmodcmd="$chmodprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-o) chowncmd="$chownprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-g) chgrpcmd="$chgrpprog $2"
-	    shift
-	    shift
-	    continue;;
-
-	-s) stripcmd="$stripprog"
-	    shift
-	    continue;;
-
-	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
-	    shift
-	    continue;;
-
-	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
-	    shift
-	    continue;;
-
-	*)  if [ x"$src" = x ]
-	    then
-		src=$1
-	    else
-		# this colon is to work around a 386BSD /bin/sh bug
-		:
-		dst=$1
-	    fi
-	    shift
-	    continue;;
-    esac
-done
-
-if [ x"$src" = x ]
-then
-	echo "install:	no input file specified"
-	exit 1
-else
-	true
-fi
-
-if [ x"$dir_arg" != x ]; then
-	dst=$src
-	src=""
-	
-	if [ -d $dst ]; then
-		instcmd=:
-		chmodcmd=""
-	else
-		instcmd=mkdir
-	fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad 
-# if $src (and thus $dsttmp) contains '*'.
-
-	if [ -f $src -o -d $src ]
-	then
-		true
-	else
-		echo "install:  $src does not exist"
-		exit 1
-	fi
-	
-	if [ x"$dst" = x ]
-	then
-		echo "install:	no destination specified"
-		exit 1
-	else
-		true
-	fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
-	if [ -d $dst ]
-	then
-		dst="$dst"/`basename $src`
-	else
-		true
-	fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-#  this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='	
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
-	pathcomp="${pathcomp}${1}"
-	shift
-
-	if [ ! -d "${pathcomp}" ] ;
-        then
-		$mkdirprog "${pathcomp}"
-	else
-		true
-	fi
-
-	pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
-	$doit $instcmd $dst &&
-
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
-	if [ x"$transformarg" = x ] 
-	then
-		dstfile=`basename $dst`
-	else
-		dstfile=`basename $dst $transformbasename | 
-			sed $transformarg`$transformbasename
-	fi
-
-# don't allow the sed command to completely eliminate the filename
-
-	if [ x"$dstfile" = x ] 
-	then
-		dstfile=`basename $dst`
-	else
-		true
-	fi
-
-# Make a temp file name in the proper directory.
-
-	dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
-	$doit $instcmd $src $dsttmp &&
-
-	trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing.  If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
-	$doit $rmcmd -f $dstdir/$dstfile &&
-	$doit $mvcmd $dsttmp $dstdir/$dstfile 
-
-fi &&
-
-
-exit 0
diff --git a/config/ltmain.sh b/config/ltmain.sh
deleted file mode 100644
index ce4a877..0000000
--- a/config/ltmain.sh
+++ /dev/null
@@ -1,6868 +0,0 @@
-# ltmain.sh - Provide generalized library-building support services.
-# NOTE: Changing this file will not affect anything until you rerun configure.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-basename="s,^.*/,,g"
-
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
-
-# The name of this program:
-progname=`echo "$progpath" | $SED $basename`
-modename="$progname"
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-
-PROGRAM=ltmain.sh
-PACKAGE=libtool
-VERSION=1.5.22
-TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
-
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes.
-if test -n "${ZSH_VERSION+set}" ; then
-  setopt NO_GLOB_SUBST
-fi
-
-# Check that we have a working $echo.
-if test "X$1" = X--no-reexec; then
-  # Discard the --no-reexec flag, and continue.
-  shift
-elif test "X$1" = X--fallback-echo; then
-  # Avoid inline document here, it may be left over
-  :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
-  # Yippee, $echo works!
-  :
-else
-  # Restart under the correct shell, and then maybe $echo will work.
-  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
-  # used as fallback echo
-  shift
-  cat <<EOF
-$*
-EOF
-  exit $EXIT_SUCCESS
-fi
-
-default_mode=
-help="Try \`$progname --help' for more information."
-magic="%%%MAGIC variable%%%"
-mkdir="mkdir"
-mv="mv -f"
-rm="rm -f"
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  SP2NL='tr \040 \012'
-  NL2SP='tr \015\012 \040\040'
-  ;;
- *) # EBCDIC based system
-  SP2NL='tr \100 \n'
-  NL2SP='tr \r\n \100\100'
-  ;;
-esac
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-# We save the old values to restore during execute mode.
-if test "${LC_ALL+set}" = set; then
-  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
-fi
-if test "${LANG+set}" = set; then
-  save_LANG="$LANG"; LANG=C; export LANG
-fi
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" 	$lt_nl"
-
-if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
-  $echo "$modename: not configured to build any kind of library" 1>&2
-  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
-  exit $EXIT_FAILURE
-fi
-
-# Global variables.
-mode=$default_mode
-nonopt=
-prev=
-prevopt=
-run=
-show="$echo"
-show_help=
-execute_dlfiles=
-duplicate_deps=no
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-
-#####################################
-# Shell function definitions:
-# This seems to be the best place for them
-
-# func_mktempdir [string]
-# Make a temporary directory that won't clash with other running
-# libtool processes, and avoids race conditions if possible.  If
-# given, STRING is the basename for that directory.
-func_mktempdir ()
-{
-    my_template="${TMPDIR-/tmp}/${1-$progname}"
-
-    if test "$run" = ":"; then
-      # Return a directory name, but don't create it in dry-run mode
-      my_tmpdir="${my_template}-$$"
-    else
-
-      # If mktemp works, use that first and foremost
-      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
-
-      if test ! -d "$my_tmpdir"; then
-	# Failing that, at least try and use $RANDOM to avoid a race
-	my_tmpdir="${my_template}-${RANDOM-0}$$"
-
-	save_mktempdir_umask=`umask`
-	umask 0077
-	$mkdir "$my_tmpdir"
-	umask $save_mktempdir_umask
-      fi
-
-      # If we're not in dry-run mode, bomb out on failure
-      test -d "$my_tmpdir" || {
-        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
-	exit $EXIT_FAILURE
-      }
-    fi
-
-    $echo "X$my_tmpdir" | $Xsed
-}
-
-
-# func_win32_libid arg
-# return the library type of file 'arg'
-#
-# Need a lot of goo to handle *both* DLLs and import libs
-# Has to be a shell function in order to 'eat' the argument
-# that is supplied when $file_magic_command is called.
-func_win32_libid ()
-{
-  win32_libid_type="unknown"
-  win32_fileres=`file -L $1 2>/dev/null`
-  case $win32_fileres in
-  *ar\ archive\ import\ library*) # definitely import
-    win32_libid_type="x86 archive import"
-    ;;
-  *ar\ archive*) # could be an import, or static
-    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
-      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
-      win32_nmres=`eval $NM -f posix -A $1 | \
-	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
-      case $win32_nmres in
-      import*)  win32_libid_type="x86 archive import";;
-      *)        win32_libid_type="x86 archive static";;
-      esac
-    fi
-    ;;
-  *DLL*)
-    win32_libid_type="x86 DLL"
-    ;;
-  *executable*) # but shell scripts are "executable" too...
-    case $win32_fileres in
-    *MS\ Windows\ PE\ Intel*)
-      win32_libid_type="x86 DLL"
-      ;;
-    esac
-    ;;
-  esac
-  $echo $win32_libid_type
-}
-
-
-# func_infer_tag arg
-# Infer tagged configuration to use if any are available and
-# if one wasn't chosen via the "--tag" command line option.
-# Only attempt this if the compiler in the base compile
-# command doesn't match the default compiler.
-# arg is usually of the form 'gcc ...'
-func_infer_tag ()
-{
-    if test -n "$available_tags" && test -z "$tagname"; then
-      CC_quoted=
-      for arg in $CC; do
-	case $arg in
-	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	  arg="\"$arg\""
-	  ;;
-	esac
-	CC_quoted="$CC_quoted $arg"
-      done
-      case $@ in
-      # Blanks in the command may have been stripped by the calling shell,
-      # but not from the CC environment variable when configure was run.
-      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
-      # Blanks at the start of $base_compile will cause this to fail
-      # if we don't check for them as well.
-      *)
-	for z in $available_tags; do
-	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
-	    # Evaluate the configuration.
-	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
-	    CC_quoted=
-	    for arg in $CC; do
-	    # Double-quote args containing other shell metacharacters.
-	    case $arg in
-	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	      arg="\"$arg\""
-	      ;;
-	    esac
-	    CC_quoted="$CC_quoted $arg"
-	  done
-	    case "$@ " in
-	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
-	      # The compiler in the base compile command matches
-	      # the one in the tagged configuration.
-	      # Assume this is the tagged configuration we want.
-	      tagname=$z
-	      break
-	      ;;
-	    esac
-	  fi
-	done
-	# If $tagname still isn't set, then no tagged configuration
-	# was found and let the user know that the "--tag" command
-	# line option must be used.
-        #
-        #
-        # Modified by R.Serban (Nov. 28, 2006) to use the default
-        # CC tag if unable to infer one
-	if test -z "$tagname"; then
-          tagname=CC
-#	  $echo "$modename: unable to infer tagged configuration"
-#	  $echo "$modename: specify a tag with \`--tag'" 1>&2
-#	  exit $EXIT_FAILURE
-#        else
-#          $echo "$modename: using $tagname tagged configuration"
-	fi
-	;;
-      esac
-    fi
-}
-
-
-# func_extract_an_archive dir oldlib
-func_extract_an_archive ()
-{
-    f_ex_an_ar_dir="$1"; shift
-    f_ex_an_ar_oldlib="$1"
-
-    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
-    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
-    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
-     :
-    else
-      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
-      exit $EXIT_FAILURE
-    fi
-}
-
-# func_extract_archives gentop oldlib ...
-func_extract_archives ()
-{
-    my_gentop="$1"; shift
-    my_oldlibs=${1+"$@"}
-    my_oldobjs=""
-    my_xlib=""
-    my_xabs=""
-    my_xdir=""
-    my_status=""
-
-    $show "${rm}r $my_gentop"
-    $run ${rm}r "$my_gentop"
-    $show "$mkdir $my_gentop"
-    $run $mkdir "$my_gentop"
-    my_status=$?
-    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
-      exit $my_status
-    fi
-
-    for my_xlib in $my_oldlibs; do
-      # Extract the objects.
-      case $my_xlib in
-	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
-	*) my_xabs=`pwd`"/$my_xlib" ;;
-      esac
-      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
-      my_xdir="$my_gentop/$my_xlib"
-
-      $show "${rm}r $my_xdir"
-      $run ${rm}r "$my_xdir"
-      $show "$mkdir $my_xdir"
-      $run $mkdir "$my_xdir"
-      exit_status=$?
-      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
-	exit $exit_status
-      fi
-      case $host in
-      *-darwin*)
-	$show "Extracting $my_xabs"
-	# Do not bother doing anything if just a dry run
-	if test -z "$run"; then
-	  darwin_orig_dir=`pwd`
-	  cd $my_xdir || exit $?
-	  darwin_archive=$my_xabs
-	  darwin_curdir=`pwd`
-	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
-	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
-	  if test -n "$darwin_arches"; then 
-	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
-	    darwin_arch=
-	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
-	    for darwin_arch in  $darwin_arches ; do
-	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
-	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
-	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
-	      cd "$darwin_curdir"
-	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
-	    done # $darwin_arches
-      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
-	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
-	    darwin_file=
-	    darwin_files=
-	    for darwin_file in $darwin_filelist; do
-	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
-	      lipo -create -output "$darwin_file" $darwin_files
-	    done # $darwin_filelist
-	    ${rm}r unfat-$$
-	    cd "$darwin_orig_dir"
-	  else
-	    cd "$darwin_orig_dir"
- 	    func_extract_an_archive "$my_xdir" "$my_xabs"
-	  fi # $darwin_arches
-	fi # $run
-	;;
-      *)
-        func_extract_an_archive "$my_xdir" "$my_xabs"
-        ;;
-      esac
-      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
-    done
-    func_extract_archives_result="$my_oldobjs"
-}
-# End of Shell function definitions
-#####################################
-
-# Darwin sucks
-eval std_shrext=\"$shrext_cmds\"
-
-disable_libs=no
-
-# Parse our command line options once, thoroughly.
-while test "$#" -gt 0
-do
-  arg="$1"
-  shift
-
-  case $arg in
-  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
-  *) optarg= ;;
-  esac
-
-  # If the previous option needs an argument, assign it.
-  if test -n "$prev"; then
-    case $prev in
-    execute_dlfiles)
-      execute_dlfiles="$execute_dlfiles $arg"
-      ;;
-    tag)
-      tagname="$arg"
-      preserve_args="${preserve_args}=$arg"
-
-      # Check whether tagname contains only valid characters
-      case $tagname in
-      *[!-_A-Za-z0-9,/]*)
-	$echo "$progname: invalid tag name: $tagname" 1>&2
-	exit $EXIT_FAILURE
-	;;
-      esac
-
-      case $tagname in
-      CC)
-	# Don't test for the "default" C tag, as we know, it's there, but
-	# not specially marked.
-	;;
-      *)
-	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
-	  taglist="$taglist $tagname"
-	  # Evaluate the configuration.
-	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
-	else
-	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
-	fi
-	;;
-      esac
-      ;;
-    *)
-      eval "$prev=\$arg"
-      ;;
-    esac
-
-    prev=
-    prevopt=
-    continue
-  fi
-
-  # Have we seen a non-optional argument yet?
-  case $arg in
-  --help)
-    show_help=yes
-    ;;
-
-  --version)
-    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
-    $echo
-    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
-    $echo "This is free software; see the source for copying conditions.  There is NO"
-    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-    exit $?
-    ;;
-
-  --config)
-    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
-    # Now print the configurations for the tags.
-    for tagname in $taglist; do
-      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
-    done
-    exit $?
-    ;;
-
-  --debug)
-    $echo "$progname: enabling shell trace mode"
-    set -x
-    preserve_args="$preserve_args $arg"
-    ;;
-
-  --dry-run | -n)
-    run=:
-    ;;
-
-  --features)
-    $echo "host: $host"
-    if test "$build_libtool_libs" = yes; then
-      $echo "enable shared libraries"
-    else
-      $echo "disable shared libraries"
-    fi
-    if test "$build_old_libs" = yes; then
-      $echo "enable static libraries"
-    else
-      $echo "disable static libraries"
-    fi
-    exit $?
-    ;;
-
-  --finish) mode="finish" ;;
-
-  --mode) prevopt="--mode" prev=mode ;;
-  --mode=*) mode="$optarg" ;;
-
-  --preserve-dup-deps) duplicate_deps="yes" ;;
-
-  --quiet | --silent)
-    show=:
-    preserve_args="$preserve_args $arg"
-    ;;
-
-  --tag)
-    prevopt="--tag"
-    prev=tag
-    preserve_args="$preserve_args --tag"
-    ;;
-  --tag=*)
-    set tag "$optarg" ${1+"$@"}
-    shift
-    prev=tag
-    preserve_args="$preserve_args --tag"
-    ;;
-
-  -dlopen)
-    prevopt="-dlopen"
-    prev=execute_dlfiles
-    ;;
-
-  -*)
-    $echo "$modename: unrecognized option \`$arg'" 1>&2
-    $echo "$help" 1>&2
-    exit $EXIT_FAILURE
-    ;;
-
-  *)
-    nonopt="$arg"
-    break
-    ;;
-  esac
-done
-
-if test -n "$prevopt"; then
-  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
-  $echo "$help" 1>&2
-  exit $EXIT_FAILURE
-fi
-
-case $disable_libs in
-no) 
-  ;;
-shared)
-  build_libtool_libs=no
-  build_old_libs=yes
-  ;;
-static)
-  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
-  ;;
-esac
-
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end.  This prevents here-documents from being
-# left over by shells.
-exec_cmd=
-
-if test -z "$show_help"; then
-
-  # Infer the operation mode.
-  if test -z "$mode"; then
-    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
-    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
-    case $nonopt in
-    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
-      mode=link
-      for arg
-      do
-	case $arg in
-	-c)
-	   mode=compile
-	   break
-	   ;;
-	esac
-      done
-      ;;
-    *db | *dbx | *strace | *truss)
-      mode=execute
-      ;;
-    *install*|cp|mv)
-      mode=install
-      ;;
-    *rm)
-      mode=uninstall
-      ;;
-    *)
-      # If we have no mode, but dlfiles were specified, then do execute mode.
-      test -n "$execute_dlfiles" && mode=execute
-
-      # Just use the default operation mode.
-      if test -z "$mode"; then
-	if test -n "$nonopt"; then
-	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
-	else
-	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
-	fi
-      fi
-      ;;
-    esac
-  fi
-
-  # Only execute mode is allowed to have -dlopen flags.
-  if test -n "$execute_dlfiles" && test "$mode" != execute; then
-    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
-    $echo "$help" 1>&2
-    exit $EXIT_FAILURE
-  fi
-
-  # Change the help message to a mode-specific one.
-  generic_help="$help"
-  help="Try \`$modename --help --mode=$mode' for more information."
-
-  # These modes are in order of execution frequency so that they run quickly.
-  case $mode in
-  # libtool compile mode
-  compile)
-    modename="$modename: compile"
-    # Get the compilation command and the source file.
-    base_compile=
-    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
-    suppress_opt=yes
-    suppress_output=
-    arg_mode=normal
-    libobj=
-    later=
-
-    for arg
-    do
-      case $arg_mode in
-      arg  )
-	# do not "continue".  Instead, add this to base_compile
-	lastarg="$arg"
-	arg_mode=normal
-	;;
-
-      target )
-	libobj="$arg"
-	arg_mode=normal
-	continue
-	;;
-
-      normal )
-	# Accept any command-line options.
-	case $arg in
-	-o)
-	  if test -n "$libobj" ; then
-	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-	  arg_mode=target
-	  continue
-	  ;;
-
-	-static | -prefer-pic | -prefer-non-pic)
-	  later="$later $arg"
-	  continue
-	  ;;
-
-	-no-suppress)
-	  suppress_opt=no
-	  continue
-	  ;;
-
-	-Xcompiler)
-	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
-	  continue      #  The current "srcfile" will either be retained or
-	  ;;            #  replaced later.  I would guess that would be a bug.
-
-	-Wc,*)
-	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
-	  lastarg=
-	  save_ifs="$IFS"; IFS=','
- 	  for arg in $args; do
-	    IFS="$save_ifs"
-
-	    # Double-quote args containing other shell metacharacters.
-	    # Many Bourne shells cannot handle close brackets correctly
-	    # in scan sets, so we specify it separately.
-	    case $arg in
-	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	      arg="\"$arg\""
-	      ;;
-	    esac
-	    lastarg="$lastarg $arg"
-	  done
-	  IFS="$save_ifs"
-	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
-
-	  # Add the arguments to base_compile.
-	  base_compile="$base_compile $lastarg"
-	  continue
-	  ;;
-
-	* )
-	  # Accept the current argument as the source file.
-	  # The previous "srcfile" becomes the current argument.
-	  #
-	  lastarg="$srcfile"
-	  srcfile="$arg"
-	  ;;
-	esac  #  case $arg
-	;;
-      esac    #  case $arg_mode
-
-      # Aesthetically quote the previous argument.
-      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
-
-      case $lastarg in
-      # Double-quote args containing other shell metacharacters.
-      # Many Bourne shells cannot handle close brackets correctly
-      # in scan sets, and some SunOS ksh mistreat backslash-escaping
-      # in scan sets (worked around with variable expansion),
-      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
-      # at all, so we specify them separately.
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	lastarg="\"$lastarg\""
-	;;
-      esac
-
-      base_compile="$base_compile $lastarg"
-    done # for arg
-
-    case $arg_mode in
-    arg)
-      $echo "$modename: you must specify an argument for -Xcompile"
-      exit $EXIT_FAILURE
-      ;;
-    target)
-      $echo "$modename: you must specify a target with \`-o'" 1>&2
-      exit $EXIT_FAILURE
-      ;;
-    *)
-      # Get the name of the library object.
-      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
-      ;;
-    esac
-
-    # Recognize several different file suffixes.
-    # If the user specifies -o file.o, it is replaced with file.lo
-    xform='[cCFSifmso]'
-    case $libobj in
-    *.ada) xform=ada ;;
-    *.adb) xform=adb ;;
-    *.ads) xform=ads ;;
-    *.asm) xform=asm ;;
-    *.c++) xform=c++ ;;
-    *.cc) xform=cc ;;
-    *.ii) xform=ii ;;
-    *.class) xform=class ;;
-    *.cpp) xform=cpp ;;
-    *.cxx) xform=cxx ;;
-    *.f90) xform=f90 ;;
-    *.for) xform=for ;;
-    *.java) xform=java ;;
-    esac
-
-    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
-
-    case $libobj in
-    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
-    *)
-      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
-      exit $EXIT_FAILURE
-      ;;
-    esac
-
-    func_infer_tag $base_compile
-
-    for arg in $later; do
-      case $arg in
-      -static)
-	build_old_libs=yes
-	continue
-	;;
-
-      -prefer-pic)
-	pic_mode=yes
-	continue
-	;;
-
-      -prefer-non-pic)
-	pic_mode=no
-	continue
-	;;
-      esac
-    done
-
-    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
-    case $qlibobj in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	qlibobj="\"$qlibobj\"" ;;
-    esac
-    test "X$libobj" != "X$qlibobj" \
-	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
-	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
-    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
-    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
-    if test "X$xdir" = "X$obj"; then
-      xdir=
-    else
-      xdir=$xdir/
-    fi
-    lobj=${xdir}$objdir/$objname
-
-    if test -z "$base_compile"; then
-      $echo "$modename: you must specify a compilation command" 1>&2
-      $echo "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
-
-    # Delete any leftover library objects.
-    if test "$build_old_libs" = yes; then
-      removelist="$obj $lobj $libobj ${libobj}T"
-    else
-      removelist="$lobj $libobj ${libobj}T"
-    fi
-
-    $run $rm $removelist
-    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
-
-    # On Cygwin there's no "real" PIC flag so we must build both object types
-    case $host_os in
-    cygwin* | mingw* | pw32* | os2*)
-      pic_mode=default
-      ;;
-    esac
-    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
-      # non-PIC code in shared libraries is not supported
-      pic_mode=default
-    fi
-
-    # Calculate the filename of the output object if compiler does
-    # not support -o with -c
-    if test "$compiler_c_o" = no; then
-      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
-      lockfile="$output_obj.lock"
-      removelist="$removelist $output_obj $lockfile"
-      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
-    else
-      output_obj=
-      need_locks=no
-      lockfile=
-    fi
-
-    # Lock this critical section if it is needed
-    # We use this script file to make the link, it avoids creating a new file
-    if test "$need_locks" = yes; then
-      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
-	$show "Waiting for $lockfile to be removed"
-	sleep 2
-      done
-    elif test "$need_locks" = warn; then
-      if test -f "$lockfile"; then
-	$echo "\
-*** ERROR, $lockfile exists and contains:
-`cat $lockfile 2>/dev/null`
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
-	$run $rm $removelist
-	exit $EXIT_FAILURE
-      fi
-      $echo "$srcfile" > "$lockfile"
-    fi
-
-    if test -n "$fix_srcfile_path"; then
-      eval srcfile=\"$fix_srcfile_path\"
-    fi
-    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
-    case $qsrcfile in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-      qsrcfile="\"$qsrcfile\"" ;;
-    esac
-
-    $run $rm "$libobj" "${libobj}T"
-
-    # Create a libtool object file (analogous to a ".la" file),
-    # but don't create it if we're doing a dry run.
-    test -z "$run" && cat > ${libobj}T <<EOF
-# $libobj - a libtool object file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# Name of the PIC object.
-EOF
-
-    # Only build a PIC object if we are building libtool libraries.
-    if test "$build_libtool_libs" = yes; then
-      # Without this assignment, base_compile gets emptied.
-      fbsd_hideous_sh_bug=$base_compile
-
-      if test "$pic_mode" != no; then
-	command="$base_compile $qsrcfile $pic_flag"
-      else
-	# Don't build PIC code
-	command="$base_compile $qsrcfile"
-      fi
-
-      if test ! -d "${xdir}$objdir"; then
-	$show "$mkdir ${xdir}$objdir"
-	$run $mkdir ${xdir}$objdir
-	exit_status=$?
-	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
-	  exit $exit_status
-	fi
-      fi
-
-      if test -z "$output_obj"; then
-	# Place PIC objects in $objdir
-	command="$command -o $lobj"
-      fi
-
-      $run $rm "$lobj" "$output_obj"
-
-      $show "$command"
-      if $run eval "$command"; then :
-      else
-	test -n "$output_obj" && $run $rm $removelist
-	exit $EXIT_FAILURE
-      fi
-
-      if test "$need_locks" = warn &&
-	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
-	$echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
-	$run $rm $removelist
-	exit $EXIT_FAILURE
-      fi
-
-      # Just move the object if needed, then go on to compile the next one
-      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
-	$show "$mv $output_obj $lobj"
-	if $run $mv $output_obj $lobj; then :
-	else
-	  error=$?
-	  $run $rm $removelist
-	  exit $error
-	fi
-      fi
-
-      # Append the name of the PIC object to the libtool object file.
-      test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object='$objdir/$objname'
-
-EOF
-
-      # Allow error messages only from the first compilation.
-      if test "$suppress_opt" = yes; then
-        suppress_output=' >/dev/null 2>&1'
-      fi
-    else
-      # No PIC object so indicate it doesn't exist in the libtool
-      # object file.
-      test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object=none
-
-EOF
-    fi
-
-    # Only build a position-dependent object if we build old libraries.
-    if test "$build_old_libs" = yes; then
-      if test "$pic_mode" != yes; then
-	# Don't build PIC code
-	command="$base_compile $qsrcfile"
-      else
-	command="$base_compile $qsrcfile $pic_flag"
-      fi
-      if test "$compiler_c_o" = yes; then
-	command="$command -o $obj"
-      fi
-
-      # Suppress compiler output if we already did a PIC compilation.
-      command="$command$suppress_output"
-      $run $rm "$obj" "$output_obj"
-      $show "$command"
-      if $run eval "$command"; then :
-      else
-	$run $rm $removelist
-	exit $EXIT_FAILURE
-      fi
-
-      if test "$need_locks" = warn &&
-	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
-	$echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together.  If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
-	$run $rm $removelist
-	exit $EXIT_FAILURE
-      fi
-
-      # Just move the object if needed
-      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
-	$show "$mv $output_obj $obj"
-	if $run $mv $output_obj $obj; then :
-	else
-	  error=$?
-	  $run $rm $removelist
-	  exit $error
-	fi
-      fi
-
-      # Append the name of the non-PIC object the libtool object file.
-      # Only append if the libtool object file exists.
-      test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object='$objname'
-
-EOF
-    else
-      # Append the name of the non-PIC object the libtool object file.
-      # Only append if the libtool object file exists.
-      test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object=none
-
-EOF
-    fi
-
-    $run $mv "${libobj}T" "${libobj}"
-
-    # Unlock the critical section if it was locked
-    if test "$need_locks" != no; then
-      $run $rm "$lockfile"
-    fi
-
-    exit $EXIT_SUCCESS
-    ;;
-
-  # libtool link mode
-  link | relink)
-    modename="$modename: link"
-    case $host in
-    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-      # It is impossible to link a dll without this setting, and
-      # we shouldn't force the makefile maintainer to figure out
-      # which system we are compiling for in order to pass an extra
-      # flag for every libtool invocation.
-      # allow_undefined=no
-
-      # FIXME: Unfortunately, there are problems with the above when trying
-      # to make a dll which has undefined symbols, in which case not
-      # even a static library is built.  For now, we need to specify
-      # -no-undefined on the libtool link line when we can be certain
-      # that all symbols are satisfied, otherwise we get a static library.
-      allow_undefined=yes
-      ;;
-    *)
-      allow_undefined=yes
-      ;;
-    esac
-    libtool_args="$nonopt"
-    base_compile="$nonopt $@"
-    compile_command="$nonopt"
-    finalize_command="$nonopt"
-
-    compile_rpath=
-    finalize_rpath=
-    compile_shlibpath=
-    finalize_shlibpath=
-    convenience=
-    old_convenience=
-    deplibs=
-    old_deplibs=
-    compiler_flags=
-    linker_flags=
-    dllsearchpath=
-    lib_search_path=`pwd`
-    inst_prefix_dir=
-
-    avoid_version=no
-    dlfiles=
-    dlprefiles=
-    dlself=no
-    export_dynamic=no
-    export_symbols=
-    export_symbols_regex=
-    generated=
-    libobjs=
-    ltlibs=
-    module=no
-    no_install=no
-    objs=
-    non_pic_objects=
-    notinst_path= # paths that contain not-installed libtool libraries
-    precious_files_regex=
-    prefer_static_libs=no
-    preload=no
-    prev=
-    prevarg=
-    release=
-    rpath=
-    xrpath=
-    perm_rpath=
-    temp_rpath=
-    thread_safe=no
-    vinfo=
-    vinfo_number=no
-
-    func_infer_tag $base_compile
-
-    # We need to know -static, to get the right output filenames.
-    for arg
-    do
-      case $arg in
-      -all-static | -static)
-	if test "X$arg" = "X-all-static"; then
-	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
-	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
-	  fi
-	  if test -n "$link_static_flag"; then
-	    dlopen_self=$dlopen_self_static
-	  fi
-	  prefer_static_libs=yes
-	else
-	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
-	    dlopen_self=$dlopen_self_static
-	  fi
-	  prefer_static_libs=built
-	fi
-	build_libtool_libs=no
-	build_old_libs=yes
-	break
-	;;
-      esac
-    done
-
-    # See if our shared archives depend on static archives.
-    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
-
-    # Go through the arguments, transforming them on the way.
-    while test "$#" -gt 0; do
-      arg="$1"
-      shift
-      case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
-	;;
-      *) qarg=$arg ;;
-      esac
-      libtool_args="$libtool_args $qarg"
-
-      # If the previous option needs an argument, assign it.
-      if test -n "$prev"; then
-	case $prev in
-	output)
-	  compile_command="$compile_command @OUTPUT@"
-	  finalize_command="$finalize_command @OUTPUT@"
-	  ;;
-	esac
-
-	case $prev in
-	dlfiles|dlprefiles)
-	  if test "$preload" = no; then
-	    # Add the symbol object into the linking commands.
-	    compile_command="$compile_command @SYMFILE@"
-	    finalize_command="$finalize_command @SYMFILE@"
-	    preload=yes
-	  fi
-	  case $arg in
-	  *.la | *.lo) ;;  # We handle these cases below.
-	  force)
-	    if test "$dlself" = no; then
-	      dlself=needless
-	      export_dynamic=yes
-	    fi
-	    prev=
-	    continue
-	    ;;
-	  self)
-	    if test "$prev" = dlprefiles; then
-	      dlself=yes
-	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
-	      dlself=yes
-	    else
-	      dlself=needless
-	      export_dynamic=yes
-	    fi
-	    prev=
-	    continue
-	    ;;
-	  *)
-	    if test "$prev" = dlfiles; then
-	      dlfiles="$dlfiles $arg"
-	    else
-	      dlprefiles="$dlprefiles $arg"
-	    fi
-	    prev=
-	    continue
-	    ;;
-	  esac
-	  ;;
-	expsyms)
-	  export_symbols="$arg"
-	  if test ! -f "$arg"; then
-	    $echo "$modename: symbol file \`$arg' does not exist"
-	    exit $EXIT_FAILURE
-	  fi
-	  prev=
-	  continue
-	  ;;
-	expsyms_regex)
-	  export_symbols_regex="$arg"
-	  prev=
-	  continue
-	  ;;
-	inst_prefix)
-	  inst_prefix_dir="$arg"
-	  prev=
-	  continue
-	  ;;
-	precious_regex)
-	  precious_files_regex="$arg"
-	  prev=
-	  continue
-	  ;;
-	release)
-	  release="-$arg"
-	  prev=
-	  continue
-	  ;;
-	objectlist)
-	  if test -f "$arg"; then
-	    save_arg=$arg
-	    moreargs=
-	    for fil in `cat $save_arg`
-	    do
-#	      moreargs="$moreargs $fil"
-	      arg=$fil
-	      # A libtool-controlled object.
-
-	      # Check to see that this really is a libtool object.
-	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-		pic_object=
-		non_pic_object=
-
-		# Read the .lo file
-		# If there is no directory component, then add one.
-		case $arg in
-		*/* | *\\*) . $arg ;;
-		*) . ./$arg ;;
-		esac
-
-		if test -z "$pic_object" || \
-		   test -z "$non_pic_object" ||
-		   test "$pic_object" = none && \
-		   test "$non_pic_object" = none; then
-		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
-		  exit $EXIT_FAILURE
-		fi
-
-		# Extract subdirectory from the argument.
-		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
-		if test "X$xdir" = "X$arg"; then
-		  xdir=
-		else
-		  xdir="$xdir/"
-		fi
-
-		if test "$pic_object" != none; then
-		  # Prepend the subdirectory the object is found in.
-		  pic_object="$xdir$pic_object"
-
-		  if test "$prev" = dlfiles; then
-		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
-		      dlfiles="$dlfiles $pic_object"
-		      prev=
-		      continue
-		    else
-		      # If libtool objects are unsupported, then we need to preload.
-		      prev=dlprefiles
-		    fi
-		  fi
-
-		  # CHECK ME:  I think I busted this.  -Ossama
-		  if test "$prev" = dlprefiles; then
-		    # Preload the old-style object.
-		    dlprefiles="$dlprefiles $pic_object"
-		    prev=
-		  fi
-
-		  # A PIC object.
-		  libobjs="$libobjs $pic_object"
-		  arg="$pic_object"
-		fi
-
-		# Non-PIC object.
-		if test "$non_pic_object" != none; then
-		  # Prepend the subdirectory the object is found in.
-		  non_pic_object="$xdir$non_pic_object"
-
-		  # A standard non-PIC object
-		  non_pic_objects="$non_pic_objects $non_pic_object"
-		  if test -z "$pic_object" || test "$pic_object" = none ; then
-		    arg="$non_pic_object"
-		  fi
-		else
-		  # If the PIC object exists, use it instead.
-		  # $xdir was prepended to $pic_object above.
-		  non_pic_object="$pic_object"
-		  non_pic_objects="$non_pic_objects $non_pic_object"
-		fi
-	      else
-		# Only an error if not doing a dry-run.
-		if test -z "$run"; then
-		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
-		  exit $EXIT_FAILURE
-		else
-		  # Dry-run case.
-
-		  # Extract subdirectory from the argument.
-		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
-		  if test "X$xdir" = "X$arg"; then
-		    xdir=
-		  else
-		    xdir="$xdir/"
-		  fi
-
-		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
-		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
-		  libobjs="$libobjs $pic_object"
-		  non_pic_objects="$non_pic_objects $non_pic_object"
-		fi
-	      fi
-	    done
-	  else
-	    $echo "$modename: link input file \`$save_arg' does not exist"
-	    exit $EXIT_FAILURE
-	  fi
-	  arg=$save_arg
-	  prev=
-	  continue
-	  ;;
-	rpath | xrpath)
-	  # We need an absolute path.
-	  case $arg in
-	  [\\/]* | [A-Za-z]:[\\/]*) ;;
-	  *)
-	    $echo "$modename: only absolute run-paths are allowed" 1>&2
-	    exit $EXIT_FAILURE
-	    ;;
-	  esac
-	  if test "$prev" = rpath; then
-	    case "$rpath " in
-	    *" $arg "*) ;;
-	    *) rpath="$rpath $arg" ;;
-	    esac
-	  else
-	    case "$xrpath " in
-	    *" $arg "*) ;;
-	    *) xrpath="$xrpath $arg" ;;
-	    esac
-	  fi
-	  prev=
-	  continue
-	  ;;
-	xcompiler)
-	  compiler_flags="$compiler_flags $qarg"
-	  prev=
-	  compile_command="$compile_command $qarg"
-	  finalize_command="$finalize_command $qarg"
-	  continue
-	  ;;
-	xlinker)
-	  linker_flags="$linker_flags $qarg"
-	  compiler_flags="$compiler_flags $wl$qarg"
-	  prev=
-	  compile_command="$compile_command $wl$qarg"
-	  finalize_command="$finalize_command $wl$qarg"
-	  continue
-	  ;;
-	xcclinker)
-	  linker_flags="$linker_flags $qarg"
-	  compiler_flags="$compiler_flags $qarg"
-	  prev=
-	  compile_command="$compile_command $qarg"
-	  finalize_command="$finalize_command $qarg"
-	  continue
-	  ;;
-	shrext)
-  	  shrext_cmds="$arg"
-	  prev=
-	  continue
-	  ;;
-	darwin_framework|darwin_framework_skip)
-	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
-	  compile_command="$compile_command $arg"
-	  finalize_command="$finalize_command $arg"
-	  prev=
-	  continue
-	  ;;
-	*)
-	  eval "$prev=\"\$arg\""
-	  prev=
-	  continue
-	  ;;
-	esac
-      fi # test -n "$prev"
-
-      prevarg="$arg"
-
-      case $arg in
-      -all-static)
-	if test -n "$link_static_flag"; then
-	  compile_command="$compile_command $link_static_flag"
-	  finalize_command="$finalize_command $link_static_flag"
-	fi
-	continue
-	;;
-
-      -allow-undefined)
-	# FIXME: remove this flag sometime in the future.
-	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
-	continue
-	;;
-
-      -avoid-version)
-	avoid_version=yes
-	continue
-	;;
-
-      -dlopen)
-	prev=dlfiles
-	continue
-	;;
-
-      -dlpreopen)
-	prev=dlprefiles
-	continue
-	;;
-
-      -export-dynamic)
-	export_dynamic=yes
-	continue
-	;;
-
-      -export-symbols | -export-symbols-regex)
-	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
-	  $echo "$modename: more than one -exported-symbols argument is not allowed"
-	  exit $EXIT_FAILURE
-	fi
-	if test "X$arg" = "X-export-symbols"; then
-	  prev=expsyms
-	else
-	  prev=expsyms_regex
-	fi
-	continue
-	;;
-
-      -framework|-arch|-isysroot)
-	case " $CC " in
-	  *" ${arg} ${1} "* | *" ${arg}	${1} "*) 
-		prev=darwin_framework_skip ;;
-	  *) compiler_flags="$compiler_flags $arg"
-	     prev=darwin_framework ;;
-	esac
-	compile_command="$compile_command $arg"
-	finalize_command="$finalize_command $arg"
-	continue
-	;;
-
-      -inst-prefix-dir)
-	prev=inst_prefix
-	continue
-	;;
-
-      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
-      # so, if we see these flags be careful not to treat them like -L
-      -L[A-Z][A-Z]*:*)
-	case $with_gcc/$host in
-	no/*-*-irix* | /*-*-irix*)
-	  compile_command="$compile_command $arg"
-	  finalize_command="$finalize_command $arg"
-	  ;;
-	esac
-	continue
-	;;
-
-      -L*)
-	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
-	# We need an absolute path.
-	case $dir in
-	[\\/]* | [A-Za-z]:[\\/]*) ;;
-	*)
-	  absdir=`cd "$dir" && pwd`
-	  if test -z "$absdir"; then
-	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
-	    absdir="$dir"
-	    notinst_path="$notinst_path $dir"
-	  fi
-	  dir="$absdir"
-	  ;;
-	esac
-	case "$deplibs " in
-	*" -L$dir "*) ;;
-	*)
-	  deplibs="$deplibs -L$dir"
-	  lib_search_path="$lib_search_path $dir"
-	  ;;
-	esac
-	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
-	  case :$dllsearchpath: in
-	  *":$dir:"*) ;;
-	  *) dllsearchpath="$dllsearchpath:$dir";;
-	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  *) dllsearchpath="$dllsearchpath:$testbindir";;
-	  esac
-	  ;;
-	esac
-	continue
-	;;
-
-      -l*)
-	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
-	  case $host in
-	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
-	    # These systems don't actually have a C or math library (as such)
-	    continue
-	    ;;
-	  *-*-os2*)
-	    # These systems don't actually have a C library (as such)
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
-	    # Do not include libc due to us having libc/libc_r.
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  *-*-rhapsody* | *-*-darwin1.[012])
-	    # Rhapsody C and math libraries are in the System framework
-	    deplibs="$deplibs -framework System"
-	    continue
-	    ;;
-	  *-*-sco3.2v5* | *-*-sco5v6*)
-	    # Causes problems with __ctype
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-	    # Compiler inserts libc in the correct place for threads to work
-	    test "X$arg" = "X-lc" && continue
-	    ;;
-	  esac
-	elif test "X$arg" = "X-lc_r"; then
-	 case $host in
-	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
-	   # Do not include libc_r directly, use -pthread flag.
-	   continue
-	   ;;
-	 esac
-	fi
-	deplibs="$deplibs $arg"
-	continue
-	;;
-
-      # Tru64 UNIX uses -model [arg] to determine the layout of C++
-      # classes, name mangling, and exception handling.
-      -model)
-	compile_command="$compile_command $arg"
-	compiler_flags="$compiler_flags $arg"
-	finalize_command="$finalize_command $arg"
-	prev=xcompiler
-	continue
-	;;
-
-     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
-	compiler_flags="$compiler_flags $arg"
-	compile_command="$compile_command $arg"
-	finalize_command="$finalize_command $arg"
-	continue
-	;;
-
-      -module)
-	module=yes
-	continue
-	;;
-
-      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
-      # -r[0-9][0-9]* specifies the processor on the SGI compiler
-      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
-      # +DA*, +DD* enable 64-bit mode on the HP compiler
-      # -q* pass through compiler args for the IBM compiler
-      # -m* pass through architecture-specific compiler args for GCC
-      # -m*, -t[45]*, -txscale* pass through architecture-specific
-      # compiler args for GCC
-      # -pg pass through profiling flag for GCC
-      # @file GCC response files
-      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
-      -t[45]*|-txscale*|@*)
-
-	# Unknown arguments in both finalize_command and compile_command need
-	# to be aesthetically quoted because they are evaled later.
-	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-	case $arg in
-	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	  arg="\"$arg\""
-	  ;;
-	esac
-        compile_command="$compile_command $arg"
-        finalize_command="$finalize_command $arg"
-        compiler_flags="$compiler_flags $arg"
-        continue
-        ;;
-
-      -shrext)
-	prev=shrext
-	continue
-	;;
-
-      -no-fast-install)
-	fast_install=no
-	continue
-	;;
-
-      -no-install)
-	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-	  # The PATH hackery in wrapper scripts is required on Windows
-	  # in order for the loader to find any dlls it needs.
-	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
-	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
-	  fast_install=no
-	  ;;
-	*) no_install=yes ;;
-	esac
-	continue
-	;;
-
-      -no-undefined)
-	allow_undefined=no
-	continue
-	;;
-
-      -objectlist)
-	prev=objectlist
-	continue
-	;;
-
-      -o) prev=output ;;
-
-      -precious-files-regex)
-	prev=precious_regex
-	continue
-	;;
-
-      -release)
-	prev=release
-	continue
-	;;
-
-      -rpath)
-	prev=rpath
-	continue
-	;;
-
-      -R)
-	prev=xrpath
-	continue
-	;;
-
-      -R*)
-	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
-	# We need an absolute path.
-	case $dir in
-	[\\/]* | [A-Za-z]:[\\/]*) ;;
-	*)
-	  $echo "$modename: only absolute run-paths are allowed" 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-	case "$xrpath " in
-	*" $dir "*) ;;
-	*) xrpath="$xrpath $dir" ;;
-	esac
-	continue
-	;;
-
-      -static)
-	# The effects of -static are defined in a previous loop.
-	# We used to do the same as -all-static on platforms that
-	# didn't have a PIC flag, but the assumption that the effects
-	# would be equivalent was wrong.  It would break on at least
-	# Digital Unix and AIX.
-	continue
-	;;
-
-      -thread-safe)
-	thread_safe=yes
-	continue
-	;;
-
-      -version-info)
-	prev=vinfo
-	continue
-	;;
-      -version-number)
-	prev=vinfo
-	vinfo_number=yes
-	continue
-	;;
-
-      -Wc,*)
-	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
-	arg=
-	save_ifs="$IFS"; IFS=','
-	for flag in $args; do
-	  IFS="$save_ifs"
-	  case $flag in
-	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	    flag="\"$flag\""
-	    ;;
-	  esac
-	  arg="$arg $wl$flag"
-	  compiler_flags="$compiler_flags $flag"
-	done
-	IFS="$save_ifs"
-	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
-	;;
-
-      -Wl,*)
-	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
-	arg=
-	save_ifs="$IFS"; IFS=','
-	for flag in $args; do
-	  IFS="$save_ifs"
-	  case $flag in
-	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	    flag="\"$flag\""
-	    ;;
-	  esac
-	  arg="$arg $wl$flag"
-	  compiler_flags="$compiler_flags $wl$flag"
-	  linker_flags="$linker_flags $flag"
-	done
-	IFS="$save_ifs"
-	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
-	;;
-
-      -Xcompiler)
-	prev=xcompiler
-	continue
-	;;
-
-      -Xlinker)
-	prev=xlinker
-	continue
-	;;
-
-      -XCClinker)
-	prev=xcclinker
-	continue
-	;;
-
-      # Some other compiler flag.
-      -* | +*)
-	# Unknown arguments in both finalize_command and compile_command need
-	# to be aesthetically quoted because they are evaled later.
-	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-	case $arg in
-	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	  arg="\"$arg\""
-	  ;;
-	esac
-	;;
-
-      *.$objext)
-	# A standard object.
-	objs="$objs $arg"
-	;;
-
-      *.lo)
-	# A libtool-controlled object.
-
-	# Check to see that this really is a libtool object.
-	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-	  pic_object=
-	  non_pic_object=
-
-	  # Read the .lo file
-	  # If there is no directory component, then add one.
-	  case $arg in
-	  */* | *\\*) . $arg ;;
-	  *) . ./$arg ;;
-	  esac
-
-	  if test -z "$pic_object" || \
-	     test -z "$non_pic_object" ||
-	     test "$pic_object" = none && \
-	     test "$non_pic_object" = none; then
-	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-
-	  # Extract subdirectory from the argument.
-	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
-	  if test "X$xdir" = "X$arg"; then
-	    xdir=
- 	  else
-	    xdir="$xdir/"
-	  fi
-
-	  if test "$pic_object" != none; then
-	    # Prepend the subdirectory the object is found in.
-	    pic_object="$xdir$pic_object"
-
-	    if test "$prev" = dlfiles; then
-	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
-		dlfiles="$dlfiles $pic_object"
-		prev=
-		continue
-	      else
-		# If libtool objects are unsupported, then we need to preload.
-		prev=dlprefiles
-	      fi
-	    fi
-
-	    # CHECK ME:  I think I busted this.  -Ossama
-	    if test "$prev" = dlprefiles; then
-	      # Preload the old-style object.
-	      dlprefiles="$dlprefiles $pic_object"
-	      prev=
-	    fi
-
-	    # A PIC object.
-	    libobjs="$libobjs $pic_object"
-	    arg="$pic_object"
-	  fi
-
-	  # Non-PIC object.
-	  if test "$non_pic_object" != none; then
-	    # Prepend the subdirectory the object is found in.
-	    non_pic_object="$xdir$non_pic_object"
-
-	    # A standard non-PIC object
-	    non_pic_objects="$non_pic_objects $non_pic_object"
-	    if test -z "$pic_object" || test "$pic_object" = none ; then
-	      arg="$non_pic_object"
-	    fi
-	  else
-	    # If the PIC object exists, use it instead.
-	    # $xdir was prepended to $pic_object above.
-	    non_pic_object="$pic_object"
-	    non_pic_objects="$non_pic_objects $non_pic_object"
-	  fi
-	else
-	  # Only an error if not doing a dry-run.
-	  if test -z "$run"; then
-	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
-	    exit $EXIT_FAILURE
-	  else
-	    # Dry-run case.
-
-	    # Extract subdirectory from the argument.
-	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
-	    if test "X$xdir" = "X$arg"; then
-	      xdir=
-	    else
-	      xdir="$xdir/"
-	    fi
-
-	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
-	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
-	    libobjs="$libobjs $pic_object"
-	    non_pic_objects="$non_pic_objects $non_pic_object"
-	  fi
-	fi
-	;;
-
-      *.$libext)
-	# An archive.
-	deplibs="$deplibs $arg"
-	old_deplibs="$old_deplibs $arg"
-	continue
-	;;
-
-      *.la)
-	# A libtool-controlled library.
-
-	if test "$prev" = dlfiles; then
-	  # This library was specified with -dlopen.
-	  dlfiles="$dlfiles $arg"
-	  prev=
-	elif test "$prev" = dlprefiles; then
-	  # The library was specified with -dlpreopen.
-	  dlprefiles="$dlprefiles $arg"
-	  prev=
-	else
-	  deplibs="$deplibs $arg"
-	fi
-	continue
-	;;
-
-      # Some other compiler argument.
-      *)
-	# Unknown arguments in both finalize_command and compile_command need
-	# to be aesthetically quoted because they are evaled later.
-	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-	case $arg in
-	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	  arg="\"$arg\""
-	  ;;
-	esac
-	;;
-      esac # arg
-
-      # Now actually substitute the argument into the commands.
-      if test -n "$arg"; then
-	compile_command="$compile_command $arg"
-	finalize_command="$finalize_command $arg"
-      fi
-    done # argument parsing loop
-
-    if test -n "$prev"; then
-      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
-      $echo "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
-
-    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
-      eval arg=\"$export_dynamic_flag_spec\"
-      compile_command="$compile_command $arg"
-      finalize_command="$finalize_command $arg"
-    fi
-
-    oldlibs=
-    # calculate the name of the file, without its directory
-    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
-    libobjs_save="$libobjs"
-
-    if test -n "$shlibpath_var"; then
-      # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
-    else
-      shlib_search_path=
-    fi
-    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
-    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
-
-    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
-    if test "X$output_objdir" = "X$output"; then
-      output_objdir="$objdir"
-    else
-      output_objdir="$output_objdir/$objdir"
-    fi
-    # Create the object directory.
-    if test ! -d "$output_objdir"; then
-      $show "$mkdir $output_objdir"
-      $run $mkdir $output_objdir
-      exit_status=$?
-      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
-	exit $exit_status
-      fi
-    fi
-
-    # Determine the type of output
-    case $output in
-    "")
-      $echo "$modename: you must specify an output file" 1>&2
-      $echo "$help" 1>&2
-      exit $EXIT_FAILURE
-      ;;
-    *.$libext) linkmode=oldlib ;;
-    *.lo | *.$objext) linkmode=obj ;;
-    *.la) linkmode=lib ;;
-    *) linkmode=prog ;; # Anything else should be a program.
-    esac
-
-    case $host in
-    *cygwin* | *mingw* | *pw32*)
-      # don't eliminate duplications in $postdeps and $predeps
-      duplicate_compiler_generated_deps=yes
-      ;;
-    *)
-      duplicate_compiler_generated_deps=$duplicate_deps
-      ;;
-    esac
-    specialdeplibs=
-
-    libs=
-    # Find all interdependent deplibs by searching for libraries
-    # that are linked more than once (e.g. -la -lb -la)
-    for deplib in $deplibs; do
-      if test "X$duplicate_deps" = "Xyes" ; then
-	case "$libs " in
-	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	esac
-      fi
-      libs="$libs $deplib"
-    done
-
-    if test "$linkmode" = lib; then
-      libs="$predeps $libs $compiler_lib_search_path $postdeps"
-
-      # Compute libraries that are listed more than once in $predeps
-      # $postdeps and mark them as special (i.e., whose duplicates are
-      # not to be eliminated).
-      pre_post_deps=
-      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
-	for pre_post_dep in $predeps $postdeps; do
-	  case "$pre_post_deps " in
-	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
-	  esac
-	  pre_post_deps="$pre_post_deps $pre_post_dep"
-	done
-      fi
-      pre_post_deps=
-    fi
-
-    deplibs=
-    newdependency_libs=
-    newlib_search_path=
-    need_relink=no # whether we're linking any uninstalled libtool libraries
-    notinst_deplibs= # not-installed libtool libraries
-    case $linkmode in
-    lib)
-	passes="conv link"
-	for file in $dlfiles $dlprefiles; do
-	  case $file in
-	  *.la) ;;
-	  *)
-	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
-	    exit $EXIT_FAILURE
-	    ;;
-	  esac
-	done
-	;;
-    prog)
-	compile_deplibs=
-	finalize_deplibs=
-	alldeplibs=no
-	newdlfiles=
-	newdlprefiles=
-	passes="conv scan dlopen dlpreopen link"
-	;;
-    *)  passes="conv"
-	;;
-    esac
-    for pass in $passes; do
-      if test "$linkmode,$pass" = "lib,link" ||
-	 test "$linkmode,$pass" = "prog,scan"; then
-	libs="$deplibs"
-	deplibs=
-      fi
-      if test "$linkmode" = prog; then
-	case $pass in
-	dlopen) libs="$dlfiles" ;;
-	dlpreopen) libs="$dlprefiles" ;;
-	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
-	esac
-      fi
-      if test "$pass" = dlopen; then
-	# Collect dlpreopened libraries
-	save_deplibs="$deplibs"
-	deplibs=
-      fi
-      for deplib in $libs; do
-	lib=
-	found=no
-	case $deplib in
-	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
-	  if test "$linkmode,$pass" = "prog,link"; then
-	    compile_deplibs="$deplib $compile_deplibs"
-	    finalize_deplibs="$deplib $finalize_deplibs"
-	  else
-	    compiler_flags="$compiler_flags $deplib"
-	  fi
-	  continue
-	  ;;
-	-l*)
-	  if test "$linkmode" != lib && test "$linkmode" != prog; then
-	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
-	    continue
-	  fi
-	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
-	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
-	    for search_ext in .la $std_shrext .so .a; do
-	      # Search the libtool library
-	      lib="$searchdir/lib${name}${search_ext}"
-	      if test -f "$lib"; then
-		if test "$search_ext" = ".la"; then
-		  found=yes
-		else
-		  found=no
-		fi
-		break 2
-	      fi
-	    done
-	  done
-	  if test "$found" != yes; then
-	    # deplib doesn't seem to be a libtool library
-	    if test "$linkmode,$pass" = "prog,link"; then
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      deplibs="$deplib $deplibs"
-	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    continue
-	  else # deplib is a libtool library
-	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
-	    # We need to do some special things here, and not later.
-	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	      case " $predeps $postdeps " in
-	      *" $deplib "*)
-		if (${SED} -e '2q' $lib |
-                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-		  library_names=
-		  old_library=
-		  case $lib in
-		  */* | *\\*) . $lib ;;
-		  *) . ./$lib ;;
-		  esac
-		  for l in $old_library $library_names; do
-		    ll="$l"
-		  done
-		  if test "X$ll" = "X$old_library" ; then # only static version available
-		    found=no
-		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
-		    test "X$ladir" = "X$lib" && ladir="."
-		    lib=$ladir/$old_library
-		    if test "$linkmode,$pass" = "prog,link"; then
-		      compile_deplibs="$deplib $compile_deplibs"
-		      finalize_deplibs="$deplib $finalize_deplibs"
-		    else
-		      deplibs="$deplib $deplibs"
-		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
-		    fi
-		    continue
-		  fi
-		fi
-	        ;;
-	      *) ;;
-	      esac
-	    fi
-	  fi
-	  ;; # -l
-	-L*)
-	  case $linkmode in
-	  lib)
-	    deplibs="$deplib $deplibs"
-	    test "$pass" = conv && continue
-	    newdependency_libs="$deplib $newdependency_libs"
-	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
-	    ;;
-	  prog)
-	    if test "$pass" = conv; then
-	      deplibs="$deplib $deplibs"
-	      continue
-	    fi
-	    if test "$pass" = scan; then
-	      deplibs="$deplib $deplibs"
-	    else
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    fi
-	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
-	    ;;
-	  *)
-	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
-	    ;;
-	  esac # linkmode
-	  continue
-	  ;; # -L
-	-R*)
-	  if test "$pass" = link; then
-	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
-	    # Make sure the xrpath contains only unique directories.
-	    case "$xrpath " in
-	    *" $dir "*) ;;
-	    *) xrpath="$xrpath $dir" ;;
-	    esac
-	  fi
-	  deplibs="$deplib $deplibs"
-	  continue
-	  ;;
-	*.la) lib="$deplib" ;;
-	*.$libext)
-	  if test "$pass" = conv; then
-	    deplibs="$deplib $deplibs"
-	    continue
-	  fi
-	  case $linkmode in
-	  lib)
-	    valid_a_lib=no
-	    case $deplibs_check_method in
-	      match_pattern*)
-		set dummy $deplibs_check_method
-	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
-		if eval $echo \"$deplib\" 2>/dev/null \
-		    | $SED 10q \
-		    | $EGREP "$match_pattern_regex" > /dev/null; then
-		  valid_a_lib=yes
-		fi
-		;;
-	      pass_all)
-		valid_a_lib=yes
-		;;
-            esac
-	    if test "$valid_a_lib" != yes; then
-	      $echo
-	      $echo "*** Warning: Trying to link with static lib archive $deplib."
-	      $echo "*** I have the capability to make that library automatically link in when"
-	      $echo "*** you link to this library.  But I can only do this if you have a"
-	      $echo "*** shared version of the library, which you do not appear to have"
-	      $echo "*** because the file extensions .$libext of this argument makes me believe"
-	      $echo "*** that it is just a static archive that I should not used here."
-	    else
-	      $echo
-	      $echo "*** Warning: Linking the shared library $output against the"
-	      $echo "*** static library $deplib is not portable!"
-	      deplibs="$deplib $deplibs"
-	    fi
-	    continue
-	    ;;
-	  prog)
-	    if test "$pass" != link; then
-	      deplibs="$deplib $deplibs"
-	    else
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    fi
-	    continue
-	    ;;
-	  esac # linkmode
-	  ;; # *.$libext
-	*.lo | *.$objext)
-	  if test "$pass" = conv; then
-	    deplibs="$deplib $deplibs"
-	  elif test "$linkmode" = prog; then
-	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
-	      # If there is no dlopen support or we're linking statically,
-	      # we need to preload.
-	      newdlprefiles="$newdlprefiles $deplib"
-	      compile_deplibs="$deplib $compile_deplibs"
-	      finalize_deplibs="$deplib $finalize_deplibs"
-	    else
-	      newdlfiles="$newdlfiles $deplib"
-	    fi
-	  fi
-	  continue
-	  ;;
-	%DEPLIBS%)
-	  alldeplibs=yes
-	  continue
-	  ;;
-	esac # case $deplib
-	if test "$found" = yes || test -f "$lib"; then :
-	else
-	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-
-	# Check to see that this really is a libtool archive.
-	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
-	else
-	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-
-	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
-	test "X$ladir" = "X$lib" && ladir="."
-
-	dlname=
-	dlopen=
-	dlpreopen=
-	libdir=
-	library_names=
-	old_library=
-	# If the library was installed with an old release of libtool,
-	# it will not redefine variables installed, or shouldnotlink
-	installed=yes
-	shouldnotlink=no
-	avoidtemprpath=
-
-
-	# Read the .la file
-	case $lib in
-	*/* | *\\*) . $lib ;;
-	*) . ./$lib ;;
-	esac
-
-	if test "$linkmode,$pass" = "lib,link" ||
-	   test "$linkmode,$pass" = "prog,scan" ||
-	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
-	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
-	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
-	fi
-
-	if test "$pass" = conv; then
-	  # Only check for convenience libraries
-	  deplibs="$lib $deplibs"
-	  if test -z "$libdir"; then
-	    if test -z "$old_library"; then
-	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
-	      exit $EXIT_FAILURE
-	    fi
-	    # It is a libtool convenience library, so add in its objects.
-	    convenience="$convenience $ladir/$objdir/$old_library"
-	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
-	    tmp_libs=
-	    for deplib in $dependency_libs; do
-	      deplibs="$deplib $deplibs"
-              if test "X$duplicate_deps" = "Xyes" ; then
-	        case "$tmp_libs " in
-	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	        esac
-              fi
-	      tmp_libs="$tmp_libs $deplib"
-	    done
-	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
-	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-	  continue
-	fi # $pass = conv
-
-
-	# Get the name of the library we link against.
-	linklib=
-	for l in $old_library $library_names; do
-	  linklib="$l"
-	done
-	if test -z "$linklib"; then
-	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-
-	# This library was specified with -dlopen.
-	if test "$pass" = dlopen; then
-	  if test -z "$libdir"; then
-	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-	  if test -z "$dlname" ||
-	     test "$dlopen_support" != yes ||
-	     test "$build_libtool_libs" = no; then
-	    # If there is no dlname, no dlopen support or we're linking
-	    # statically, we need to preload.  We also need to preload any
-	    # dependent libraries so libltdl's deplib preloader doesn't
-	    # bomb out in the load deplibs phase.
-	    dlprefiles="$dlprefiles $lib $dependency_libs"
-	  else
-	    newdlfiles="$newdlfiles $lib"
-	  fi
-	  continue
-	fi # $pass = dlopen
-
-	# We need an absolute path.
-	case $ladir in
-	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
-	*)
-	  abs_ladir=`cd "$ladir" && pwd`
-	  if test -z "$abs_ladir"; then
-	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
-	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
-	    abs_ladir="$ladir"
-	  fi
-	  ;;
-	esac
-	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-
-	# Find the relevant object directory and library name.
-	if test "X$installed" = Xyes; then
-	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    libdir="$abs_ladir"
-	  else
-	    dir="$libdir"
-	    absdir="$libdir"
-	  fi
-	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
-	else
-	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
-	    dir="$ladir"
-	    absdir="$abs_ladir"
-	    # Remove this search path later
-	    notinst_path="$notinst_path $abs_ladir"
-	  else
-	    dir="$ladir/$objdir"
-	    absdir="$abs_ladir/$objdir"
-	    # Remove this search path later
-	    notinst_path="$notinst_path $abs_ladir"
-	  fi
-	fi # $installed = yes
-	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
-
-	# This library was specified with -dlpreopen.
-	if test "$pass" = dlpreopen; then
-	  if test -z "$libdir"; then
-	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-	  # Prefer using a static library (so that no silly _DYNAMIC symbols
-	  # are required to link).
-	  if test -n "$old_library"; then
-	    newdlprefiles="$newdlprefiles $dir/$old_library"
-	  # Otherwise, use the dlname, so that lt_dlopen finds it.
-	  elif test -n "$dlname"; then
-	    newdlprefiles="$newdlprefiles $dir/$dlname"
-	  else
-	    newdlprefiles="$newdlprefiles $dir/$linklib"
-	  fi
-	fi # $pass = dlpreopen
-
-	if test -z "$libdir"; then
-	  # Link the convenience library
-	  if test "$linkmode" = lib; then
-	    deplibs="$dir/$old_library $deplibs"
-	  elif test "$linkmode,$pass" = "prog,link"; then
-	    compile_deplibs="$dir/$old_library $compile_deplibs"
-	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
-	  else
-	    deplibs="$lib $deplibs" # used for prog,scan pass
-	  fi
-	  continue
-	fi
-
-
-	if test "$linkmode" = prog && test "$pass" != link; then
-	  newlib_search_path="$newlib_search_path $ladir"
-	  deplibs="$lib $deplibs"
-
-	  linkalldeplibs=no
-	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
-	     test "$build_libtool_libs" = no; then
-	    linkalldeplibs=yes
-	  fi
-
-	  tmp_libs=
-	  for deplib in $dependency_libs; do
-	    case $deplib in
-	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
-	    esac
-	    # Need to link against all dependency_libs?
-	    if test "$linkalldeplibs" = yes; then
-	      deplibs="$deplib $deplibs"
-	    else
-	      # Need to hardcode shared library paths
-	      # or/and link against static libraries
-	      newdependency_libs="$deplib $newdependency_libs"
-	    fi
-	    if test "X$duplicate_deps" = "Xyes" ; then
-	      case "$tmp_libs " in
-	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	      esac
-	    fi
-	    tmp_libs="$tmp_libs $deplib"
-	  done # for deplib
-	  continue
-	fi # $linkmode = prog...
-
-	if test "$linkmode,$pass" = "prog,link"; then
-	  if test -n "$library_names" &&
-	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
-	    # We need to hardcode the library path
-	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
-	      # Make sure the rpath contains only unique directories.
-	      case "$temp_rpath " in
-	      *" $dir "*) ;;
-	      *" $absdir "*) ;;
-	      *) temp_rpath="$temp_rpath $absdir" ;;
-	      esac
-	    fi
-
-	    # Hardcode the library path.
-	    # Skip directories that are in the system default run-time
-	    # search path.
-	    case " $sys_lib_dlsearch_path " in
-	    *" $absdir "*) ;;
-	    *)
-	      case "$compile_rpath " in
-	      *" $absdir "*) ;;
-	      *) compile_rpath="$compile_rpath $absdir"
-	      esac
-	      ;;
-	    esac
-	    case " $sys_lib_dlsearch_path " in
-	    *" $libdir "*) ;;
-	    *)
-	      case "$finalize_rpath " in
-	      *" $libdir "*) ;;
-	      *) finalize_rpath="$finalize_rpath $libdir"
-	      esac
-	      ;;
-	    esac
-	  fi # $linkmode,$pass = prog,link...
-
-	  if test "$alldeplibs" = yes &&
-	     { test "$deplibs_check_method" = pass_all ||
-	       { test "$build_libtool_libs" = yes &&
-		 test -n "$library_names"; }; }; then
-	    # We only need to search for static libraries
-	    continue
-	  fi
-	fi
-
-	link_static=no # Whether the deplib will be linked statically
-	use_static_libs=$prefer_static_libs
-	if test "$use_static_libs" = built && test "$installed" = yes ; then
-	  use_static_libs=no
-	fi
-	if test -n "$library_names" &&
-	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
-	  if test "$installed" = no; then
-	    notinst_deplibs="$notinst_deplibs $lib"
-	    need_relink=yes
-	  fi
-	  # This is a shared library
-
-	  # Warn about portability, can't link against -module's on
-	  # some systems (darwin)
-	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
-	    $echo
-	    if test "$linkmode" = prog; then
-	      $echo "*** Warning: Linking the executable $output against the loadable module"
-	    else
-	      $echo "*** Warning: Linking the shared library $output against the loadable module"
-	    fi
-	    $echo "*** $linklib is not portable!"
-	  fi
-	  if test "$linkmode" = lib &&
-	     test "$hardcode_into_libs" = yes; then
-	    # Hardcode the library path.
-	    # Skip directories that are in the system default run-time
-	    # search path.
-	    case " $sys_lib_dlsearch_path " in
-	    *" $absdir "*) ;;
-	    *)
-	      case "$compile_rpath " in
-	      *" $absdir "*) ;;
-	      *) compile_rpath="$compile_rpath $absdir"
-	      esac
-	      ;;
-	    esac
-	    case " $sys_lib_dlsearch_path " in
-	    *" $libdir "*) ;;
-	    *)
-	      case "$finalize_rpath " in
-	      *" $libdir "*) ;;
-	      *) finalize_rpath="$finalize_rpath $libdir"
-	      esac
-	      ;;
-	    esac
-	  fi
-
-	  if test -n "$old_archive_from_expsyms_cmds"; then
-	    # figure out the soname
-	    set dummy $library_names
-	    realname="$2"
-	    shift; shift
-	    libname=`eval \\$echo \"$libname_spec\"`
-	    # use dlname if we got it. it's perfectly good, no?
-	    if test -n "$dlname"; then
-	      soname="$dlname"
-	    elif test -n "$soname_spec"; then
-	      # bleh windows
-	      case $host in
-	      *cygwin* | mingw*)
-		major=`expr $current - $age`
-		versuffix="-$major"
-		;;
-	      esac
-	      eval soname=\"$soname_spec\"
-	    else
-	      soname="$realname"
-	    fi
-
-	    # Make a new name for the extract_expsyms_cmds to use
-	    soroot="$soname"
-	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
-	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
-
-	    # If the library has no export list, then create one now
-	    if test -f "$output_objdir/$soname-def"; then :
-	    else
-	      $show "extracting exported symbol list from \`$soname'"
-	      save_ifs="$IFS"; IFS='~'
-	      cmds=$extract_expsyms_cmds
-	      for cmd in $cmds; do
-		IFS="$save_ifs"
-		eval cmd=\"$cmd\"
-		$show "$cmd"
-		$run eval "$cmd" || exit $?
-	      done
-	      IFS="$save_ifs"
-	    fi
-
-	    # Create $newlib
-	    if test -f "$output_objdir/$newlib"; then :; else
-	      $show "generating import library for \`$soname'"
-	      save_ifs="$IFS"; IFS='~'
-	      cmds=$old_archive_from_expsyms_cmds
-	      for cmd in $cmds; do
-		IFS="$save_ifs"
-		eval cmd=\"$cmd\"
-		$show "$cmd"
-		$run eval "$cmd" || exit $?
-	      done
-	      IFS="$save_ifs"
-	    fi
-	    # make sure the library variables are pointing to the new library
-	    dir=$output_objdir
-	    linklib=$newlib
-	  fi # test -n "$old_archive_from_expsyms_cmds"
-
-	  if test "$linkmode" = prog || test "$mode" != relink; then
-	    add_shlibpath=
-	    add_dir=
-	    add=
-	    lib_linked=yes
-	    case $hardcode_action in
-	    immediate | unsupported)
-	      if test "$hardcode_direct" = no; then
-		add="$dir/$linklib"
-		case $host in
-		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
-		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
-		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
-		    *-*-unixware7*) add_dir="-L$dir" ;;
-		  *-*-darwin* )
-		    # if the lib is a module then we can not link against
-		    # it, someone is ignoring the new warnings I added
-		    if /usr/bin/file -L $add 2> /dev/null |
-                      $EGREP ": [^:]* bundle" >/dev/null ; then
-		      $echo "** Warning, lib $linklib is a module, not a shared library"
-		      if test -z "$old_library" ; then
-		        $echo
-		        $echo "** And there doesn't seem to be a static archive available"
-		        $echo "** The link will probably fail, sorry"
-		      else
-		        add="$dir/$old_library"
-		      fi
-		    fi
-		esac
-	      elif test "$hardcode_minus_L" = no; then
-		case $host in
-		*-*-sunos*) add_shlibpath="$dir" ;;
-		esac
-		add_dir="-L$dir"
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = no; then
-		add_shlibpath="$dir"
-		add="-l$name"
-	      else
-		lib_linked=no
-	      fi
-	      ;;
-	    relink)
-	      if test "$hardcode_direct" = yes; then
-		add="$dir/$linklib"
-	      elif test "$hardcode_minus_L" = yes; then
-		add_dir="-L$dir"
-		# Try looking first in the location we're being installed to.
-		if test -n "$inst_prefix_dir"; then
-		  case $libdir in
-		    [\\/]*)
-		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
-		      ;;
-		  esac
-		fi
-		add="-l$name"
-	      elif test "$hardcode_shlibpath_var" = yes; then
-		add_shlibpath="$dir"
-		add="-l$name"
-	      else
-		lib_linked=no
-	      fi
-	      ;;
-	    *) lib_linked=no ;;
-	    esac
-
-	    if test "$lib_linked" != yes; then
-	      $echo "$modename: configuration error: unsupported hardcode properties"
-	      exit $EXIT_FAILURE
-	    fi
-
-	    if test -n "$add_shlibpath"; then
-	      case :$compile_shlibpath: in
-	      *":$add_shlibpath:"*) ;;
-	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
-	      esac
-	    fi
-	    if test "$linkmode" = prog; then
-	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
-	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
-	    else
-	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
-	      test -n "$add" && deplibs="$add $deplibs"
-	      if test "$hardcode_direct" != yes && \
-		 test "$hardcode_minus_L" != yes && \
-		 test "$hardcode_shlibpath_var" = yes; then
-		case :$finalize_shlibpath: in
-		*":$libdir:"*) ;;
-		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
-		esac
-	      fi
-	    fi
-	  fi
-
-	  if test "$linkmode" = prog || test "$mode" = relink; then
-	    add_shlibpath=
-	    add_dir=
-	    add=
-	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes; then
-	      add="$libdir/$linklib"
-	    elif test "$hardcode_minus_L" = yes; then
-	      add_dir="-L$libdir"
-	      add="-l$name"
-	    elif test "$hardcode_shlibpath_var" = yes; then
-	      case :$finalize_shlibpath: in
-	      *":$libdir:"*) ;;
-	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
-	      esac
-	      add="-l$name"
-	    elif test "$hardcode_automatic" = yes; then
-	      if test -n "$inst_prefix_dir" &&
-		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
-	        add="$inst_prefix_dir$libdir/$linklib"
-	      else
-	        add="$libdir/$linklib"
-	      fi
-	    else
-	      # We cannot seem to hardcode it, guess we'll fake it.
-	      add_dir="-L$libdir"
-	      # Try looking first in the location we're being installed to.
-	      if test -n "$inst_prefix_dir"; then
-		case $libdir in
-		  [\\/]*)
-		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
-		    ;;
-		esac
-	      fi
-	      add="-l$name"
-	    fi
-
-	    if test "$linkmode" = prog; then
-	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
-	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
-	    else
-	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
-	      test -n "$add" && deplibs="$add $deplibs"
-	    fi
-	  fi
-	elif test "$linkmode" = prog; then
-	  # Here we assume that one of hardcode_direct or hardcode_minus_L
-	  # is not unsupported.  This is valid on all known static and
-	  # shared platforms.
-	  if test "$hardcode_direct" != unsupported; then
-	    test -n "$old_library" && linklib="$old_library"
-	    compile_deplibs="$dir/$linklib $compile_deplibs"
-	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
-	  else
-	    compile_deplibs="-l$name -L$dir $compile_deplibs"
-	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
-	  fi
-	elif test "$build_libtool_libs" = yes; then
-	  # Not a shared library
-	  if test "$deplibs_check_method" != pass_all; then
-	    # We're trying link a shared library against a static one
-	    # but the system doesn't support it.
-
-	    # Just print a warning and add the library to dependency_libs so
-	    # that the program can be linked against the static library.
-	    $echo
-	    $echo "*** Warning: This system can not link to static lib archive $lib."
-	    $echo "*** I have the capability to make that library automatically link in when"
-	    $echo "*** you link to this library.  But I can only do this if you have a"
-	    $echo "*** shared version of the library, which you do not appear to have."
-	    if test "$module" = yes; then
-	      $echo "*** But as you try to build a module library, libtool will still create "
-	      $echo "*** a static module, that should work as long as the dlopening application"
-	      $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
-	      if test -z "$global_symbol_pipe"; then
-		$echo
-		$echo "*** However, this would only work if libtool was able to extract symbol"
-		$echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
-		$echo "*** not find such a program.  So, this module is probably useless."
-		$echo "*** \`nm' from GNU binutils and a full rebuild may help."
-	      fi
-	      if test "$build_old_libs" = no; then
-		build_libtool_libs=module
-		build_old_libs=yes
-	      else
-		build_libtool_libs=no
-	      fi
-	    fi
-	  else
-	    deplibs="$dir/$old_library $deplibs"
-	    link_static=yes
-	  fi
-	fi # link shared/static library?
-
-	if test "$linkmode" = lib; then
-	  if test -n "$dependency_libs" &&
-	     { test "$hardcode_into_libs" != yes ||
-	       test "$build_old_libs" = yes ||
-	       test "$link_static" = yes; }; then
-	    # Extract -R from dependency_libs
-	    temp_deplibs=
-	    for libdir in $dependency_libs; do
-	      case $libdir in
-	      -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
-		   case " $xrpath " in
-		   *" $temp_xrpath "*) ;;
-		   *) xrpath="$xrpath $temp_xrpath";;
-		   esac;;
-	      *) temp_deplibs="$temp_deplibs $libdir";;
-	      esac
-	    done
-	    dependency_libs="$temp_deplibs"
-	  fi
-
-	  newlib_search_path="$newlib_search_path $absdir"
-	  # Link against this library
-	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
-	  # ... and its dependency_libs
-	  tmp_libs=
-	  for deplib in $dependency_libs; do
-	    newdependency_libs="$deplib $newdependency_libs"
-	    if test "X$duplicate_deps" = "Xyes" ; then
-	      case "$tmp_libs " in
-	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
-	      esac
-	    fi
-	    tmp_libs="$tmp_libs $deplib"
-	  done
-
-	  if test "$link_all_deplibs" != no; then
-	    # Add the search paths of all dependency libraries
-	    for deplib in $dependency_libs; do
-	      case $deplib in
-	      -L*) path="$deplib" ;;
-	      *.la)
-		dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
-		test "X$dir" = "X$deplib" && dir="."
-		# We need an absolute path.
-		case $dir in
-		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
-		*)
-		  absdir=`cd "$dir" && pwd`
-		  if test -z "$absdir"; then
-		    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
-		    absdir="$dir"
-		  fi
-		  ;;
-		esac
-		if grep "^installed=no" $deplib > /dev/null; then
-		  path="$absdir/$objdir"
-		else
-		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
-		  if test -z "$libdir"; then
-		    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
-		    exit $EXIT_FAILURE
-		  fi
-		  if test "$absdir" != "$libdir"; then
-		    $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
-		  fi
-		  path="$absdir"
-		fi
-		depdepl=
-		case $host in
-		*-*-darwin*)
-		  # we do not want to link against static libs,
-		  # but need to link against shared
-		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
-		  if test -n "$deplibrary_names" ; then
-		    for tmp in $deplibrary_names ; do
-		      depdepl=$tmp
-		    done
-		    if test -f "$path/$depdepl" ; then
-		      depdepl="$path/$depdepl"
-		    fi
-		    # do not add paths which are already there
-		    case " $newlib_search_path " in
-		    *" $path "*) ;;
-		    *) newlib_search_path="$newlib_search_path $path";;
-		    esac
-		  fi
-		  path=""
-		  ;;
-		*)
-		  path="-L$path"
-		  ;;
-		esac
-		;;
-	      -l*)
-		case $host in
-		*-*-darwin*)
-		  # Again, we only want to link against shared libraries
-		  eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
-		  for tmp in $newlib_search_path ; do
-		    if test -f "$tmp/lib$tmp_libs.dylib" ; then
-		      eval depdepl="$tmp/lib$tmp_libs.dylib"
-		      break
-		    fi
-		  done
-		  path=""
-		  ;;
-		*) continue ;;
-		esac
-		;;
-	      *) continue ;;
-	      esac
-	      case " $deplibs " in
-	      *" $path "*) ;;
-	      *) deplibs="$path $deplibs" ;;
-	      esac
-	      case " $deplibs " in
-	      *" $depdepl "*) ;;
-	      *) deplibs="$depdepl $deplibs" ;;
-	      esac
-	    done
-	  fi # link_all_deplibs != no
-	fi # linkmode = lib
-      done # for deplib in $libs
-      dependency_libs="$newdependency_libs"
-      if test "$pass" = dlpreopen; then
-	# Link the dlpreopened libraries before other libraries
-	for deplib in $save_deplibs; do
-	  deplibs="$deplib $deplibs"
-	done
-      fi
-      if test "$pass" != dlopen; then
-	if test "$pass" != conv; then
-	  # Make sure lib_search_path contains only unique directories.
-	  lib_search_path=
-	  for dir in $newlib_search_path; do
-	    case "$lib_search_path " in
-	    *" $dir "*) ;;
-	    *) lib_search_path="$lib_search_path $dir" ;;
-	    esac
-	  done
-	  newlib_search_path=
-	fi
-
-	if test "$linkmode,$pass" != "prog,link"; then
-	  vars="deplibs"
-	else
-	  vars="compile_deplibs finalize_deplibs"
-	fi
-	for var in $vars dependency_libs; do
-	  # Add libraries to $var in reverse order
-	  eval tmp_libs=\"\$$var\"
-	  new_libs=
-	  for deplib in $tmp_libs; do
-	    # FIXME: Pedantically, this is the right thing to do, so
-	    #        that some nasty dependency loop isn't accidentally
-	    #        broken:
-	    #new_libs="$deplib $new_libs"
-	    # Pragmatically, this seems to cause very few problems in
-	    # practice:
-	    case $deplib in
-	    -L*) new_libs="$deplib $new_libs" ;;
-	    -R*) ;;
-	    *)
-	      # And here is the reason: when a library appears more
-	      # than once as an explicit dependence of a library, or
-	      # is implicitly linked in more than once by the
-	      # compiler, it is considered special, and multiple
-	      # occurrences thereof are not removed.  Compare this
-	      # with having the same library being listed as a
-	      # dependency of multiple other libraries: in this case,
-	      # we know (pedantically, we assume) the library does not
-	      # need to be listed more than once, so we keep only the
-	      # last copy.  This is not always right, but it is rare
-	      # enough that we require users that really mean to play
-	      # such unportable linking tricks to link the library
-	      # using -Wl,-lname, so that libtool does not consider it
-	      # for duplicate removal.
-	      case " $specialdeplibs " in
-	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
-	      *)
-		case " $new_libs " in
-		*" $deplib "*) ;;
-		*) new_libs="$deplib $new_libs" ;;
-		esac
-		;;
-	      esac
-	      ;;
-	    esac
-	  done
-	  tmp_libs=
-	  for deplib in $new_libs; do
-	    case $deplib in
-	    -L*)
-	      case " $tmp_libs " in
-	      *" $deplib "*) ;;
-	      *) tmp_libs="$tmp_libs $deplib" ;;
-	      esac
-	      ;;
-	    *) tmp_libs="$tmp_libs $deplib" ;;
-	    esac
-	  done
-	  eval $var=\"$tmp_libs\"
-	done # for var
-      fi
-      # Last step: remove runtime libs from dependency_libs
-      # (they stay in deplibs)
-      tmp_libs=
-      for i in $dependency_libs ; do
-	case " $predeps $postdeps $compiler_lib_search_path " in
-	*" $i "*)
-	  i=""
-	  ;;
-	esac
-	if test -n "$i" ; then
-	  tmp_libs="$tmp_libs $i"
-	fi
-      done
-      dependency_libs=$tmp_libs
-    done # for pass
-    if test "$linkmode" = prog; then
-      dlfiles="$newdlfiles"
-      dlprefiles="$newdlprefiles"
-    fi
-
-    case $linkmode in
-    oldlib)
-      if test -n "$deplibs"; then
-	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
-      fi
-
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
-      fi
-
-      if test -n "$rpath"; then
-	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
-      fi
-
-      if test -n "$xrpath"; then
-	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
-      fi
-
-      if test -n "$vinfo"; then
-	$echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
-      fi
-
-      if test -n "$release"; then
-	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
-      fi
-
-      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
-	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
-      fi
-
-      # Now set the variables for building old libraries.
-      build_libtool_libs=no
-      oldlibs="$output"
-      objs="$objs$old_deplibs"
-      ;;
-
-    lib)
-      # Make sure we only generate libraries of the form `libNAME.la'.
-      case $outputname in
-      lib*)
-	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
-	eval shared_ext=\"$shrext_cmds\"
-	eval libname=\"$libname_spec\"
-	;;
-      *)
-	if test "$module" = no; then
-	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
-	  $echo "$help" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-	if test "$need_lib_prefix" != no; then
-	  # Add the "lib" prefix for modules if required
-	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
-	  eval shared_ext=\"$shrext_cmds\"
-	  eval libname=\"$libname_spec\"
-	else
-	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
-	fi
-	;;
-      esac
-
-      if test -n "$objs"; then
-	if test "$deplibs_check_method" != pass_all; then
-	  $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
-	  exit $EXIT_FAILURE
-	else
-	  $echo
-	  $echo "*** Warning: Linking the shared library $output against the non-libtool"
-	  $echo "*** objects $objs is not portable!"
-	  libobjs="$libobjs $objs"
-	fi
-      fi
-
-      if test "$dlself" != no; then
-	$echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
-      fi
-
-      set dummy $rpath
-      if test "$#" -gt 2; then
-	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
-      fi
-      install_libdir="$2"
-
-      oldlibs=
-      if test -z "$rpath"; then
-	if test "$build_libtool_libs" = yes; then
-	  # Building a libtool convenience library.
-	  # Some compilers have problems with a `.al' extension so
-	  # convenience libraries should have the same extension an
-	  # archive normally would.
-	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
-	  build_libtool_libs=convenience
-	  build_old_libs=yes
-	fi
-
-	if test -n "$vinfo"; then
-	  $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
-	fi
-
-	if test -n "$release"; then
-	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
-	fi
-      else
-
-	# Parse the version information argument.
-	save_ifs="$IFS"; IFS=':'
-	set dummy $vinfo 0 0 0
-	IFS="$save_ifs"
-
-	if test -n "$8"; then
-	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
-	  $echo "$help" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-
-	# convert absolute version numbers to libtool ages
-	# this retains compatibility with .la files and attempts
-	# to make the code below a bit more comprehensible
-
-	case $vinfo_number in
-	yes)
-	  number_major="$2"
-	  number_minor="$3"
-	  number_revision="$4"
-	  #
-	  # There are really only two kinds -- those that
-	  # use the current revision as the major version
-	  # and those that subtract age and use age as
-	  # a minor version.  But, then there is irix
-	  # which has an extra 1 added just for fun
-	  #
-	  case $version_type in
-	  darwin|linux|osf|windows)
-	    current=`expr $number_major + $number_minor`
-	    age="$number_minor"
-	    revision="$number_revision"
-	    ;;
-	  freebsd-aout|freebsd-elf|sunos)
-	    current="$number_major"
-	    revision="$number_minor"
-	    age="0"
-	    ;;
-	  irix|nonstopux)
-	    current=`expr $number_major + $number_minor - 1`
-	    age="$number_minor"
-	    revision="$number_minor"
-	    ;;
-	  esac
-	  ;;
-	no)
-	  current="$2"
-	  revision="$3"
-	  age="$4"
-	  ;;
-	esac
-
-	# Check that each of the things are valid numbers.
-	case $current in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
-	*)
-	  $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
-	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-
-	case $revision in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
-	*)
-	  $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
-	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-
-	case $age in
-	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
-	*)
-	  $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
-	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-
-	if test "$age" -gt "$current"; then
-	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
-	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-
-	# Calculate the version variables.
-	major=
-	versuffix=
-	verstring=
-	case $version_type in
-	none) ;;
-
-	darwin)
-	  # Like Linux, but with the current version available in
-	  # verstring for coding it into the library header
-	  major=.`expr $current - $age`
-	  versuffix="$major.$age.$revision"
-	  # Darwin ld doesn't like 0 for these options...
-	  minor_current=`expr $current + 1`
-	  verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
-	  ;;
-
-	freebsd-aout)
-	  major=".$current"
-	  versuffix=".$current.$revision";
-	  ;;
-
-	freebsd-elf)
-	  major=".$current"
-	  versuffix=".$current";
-	  ;;
-
-	irix | nonstopux)
-	  major=`expr $current - $age + 1`
-
-	  case $version_type in
-	    nonstopux) verstring_prefix=nonstopux ;;
-	    *)         verstring_prefix=sgi ;;
-	  esac
-	  verstring="$verstring_prefix$major.$revision"
-
-	  # Add in all the interfaces that we are compatible with.
-	  loop=$revision
-	  while test "$loop" -ne 0; do
-	    iface=`expr $revision - $loop`
-	    loop=`expr $loop - 1`
-	    verstring="$verstring_prefix$major.$iface:$verstring"
-	  done
-
-	  # Before this point, $major must not contain `.'.
-	  major=.$major
-	  versuffix="$major.$revision"
-	  ;;
-
-	linux)
-	  major=.`expr $current - $age`
-	  versuffix="$major.$age.$revision"
-	  ;;
-
-	osf)
-	  major=.`expr $current - $age`
-	  versuffix=".$current.$age.$revision"
-	  verstring="$current.$age.$revision"
-
-	  # Add in all the interfaces that we are compatible with.
-	  loop=$age
-	  while test "$loop" -ne 0; do
-	    iface=`expr $current - $loop`
-	    loop=`expr $loop - 1`
-	    verstring="$verstring:${iface}.0"
-	  done
-
-	  # Make executables depend on our current version.
-	  verstring="$verstring:${current}.0"
-	  ;;
-
-	sunos)
-	  major=".$current"
-	  versuffix=".$current.$revision"
-	  ;;
-
-	windows)
-	  # Use '-' rather than '.', since we only want one
-	  # extension on DOS 8.3 filesystems.
-	  major=`expr $current - $age`
-	  versuffix="-$major"
-	  ;;
-
-	*)
-	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
-	  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-
-	# Clear the version info if we defaulted, and they specified a release.
-	if test -z "$vinfo" && test -n "$release"; then
-	  major=
-	  case $version_type in
-	  darwin)
-	    # we can't check for "0.0" in archive_cmds due to quoting
-	    # problems, so we reset it completely
-	    verstring=
-	    ;;
-	  *)
-	    verstring="0.0"
-	    ;;
-	  esac
-	  if test "$need_version" = no; then
-	    versuffix=
-	  else
-	    versuffix=".0.0"
-	  fi
-	fi
-
-	# Remove version info from name if versioning should be avoided
-	if test "$avoid_version" = yes && test "$need_version" = no; then
-	  major=
-	  versuffix=
-	  verstring=""
-	fi
-
-	# Check to see if the archive will have undefined symbols.
-	if test "$allow_undefined" = yes; then
-	  if test "$allow_undefined_flag" = unsupported; then
-	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
-	    build_libtool_libs=no
-	    build_old_libs=yes
-	  fi
-	else
-	  # Don't allow undefined symbols.
-	  allow_undefined_flag="$no_undefined_flag"
-	fi
-      fi
-
-      if test "$mode" != relink; then
-	# Remove our outputs, but don't remove object files since they
-	# may have been created when compiling PIC objects.
-	removelist=
-	tempremovelist=`$echo "$output_objdir/*"`
-	for p in $tempremovelist; do
-	  case $p in
-	    *.$objext)
-	       ;;
-	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
-	       if test "X$precious_files_regex" != "X"; then
-	         if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
-	         then
-		   continue
-		 fi
-	       fi
-	       removelist="$removelist $p"
-	       ;;
-	    *) ;;
-	  esac
-	done
-	if test -n "$removelist"; then
-	  $show "${rm}r $removelist"
-	  $run ${rm}r $removelist
-	fi
-      fi
-
-      # Now set the variables for building old libraries.
-      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
-	oldlibs="$oldlibs $output_objdir/$libname.$libext"
-
-	# Transform .lo files to .o files.
-	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
-      fi
-
-      # Eliminate all temporary directories.
-      for path in $notinst_path; do
-	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
-	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
-	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
-      done
-
-      if test -n "$xrpath"; then
-	# If the user specified any rpath flags, then add them.
-	temp_xrpath=
-	for libdir in $xrpath; do
-	  temp_xrpath="$temp_xrpath -R$libdir"
-	  case "$finalize_rpath " in
-	  *" $libdir "*) ;;
-	  *) finalize_rpath="$finalize_rpath $libdir" ;;
-	  esac
-	done
-	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
-	  dependency_libs="$temp_xrpath $dependency_libs"
-	fi
-      fi
-
-      # Make sure dlfiles contains only unique files that won't be dlpreopened
-      old_dlfiles="$dlfiles"
-      dlfiles=
-      for lib in $old_dlfiles; do
-	case " $dlprefiles $dlfiles " in
-	*" $lib "*) ;;
-	*) dlfiles="$dlfiles $lib" ;;
-	esac
-      done
-
-      # Make sure dlprefiles contains only unique files
-      old_dlprefiles="$dlprefiles"
-      dlprefiles=
-      for lib in $old_dlprefiles; do
-	case "$dlprefiles " in
-	*" $lib "*) ;;
-	*) dlprefiles="$dlprefiles $lib" ;;
-	esac
-      done
-
-      if test "$build_libtool_libs" = yes; then
-	if test -n "$rpath"; then
-	  case $host in
-	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
-	    # these systems don't actually have a c library (as such)!
-	    ;;
-	  *-*-rhapsody* | *-*-darwin1.[012])
-	    # Rhapsody C library is in the System framework
-	    deplibs="$deplibs -framework System"
-	    ;;
-	  *-*-netbsd*)
-	    # Don't link with libc until the a.out ld.so is fixed.
-	    ;;
-	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
-	    # Do not include libc due to us having libc/libc_r.
-	    ;;
-	  *-*-sco3.2v5* | *-*-sco5v6*)
-	    # Causes problems with __ctype
-	    ;;
-	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
-	    # Compiler inserts libc in the correct place for threads to work
-	    ;;
- 	  *)
-	    # Add libc to deplibs on all other systems if necessary.
-	    if test "$build_libtool_need_lc" = "yes"; then
-	      deplibs="$deplibs -lc"
-	    fi
-	    ;;
-	  esac
-	fi
-
-	# Transform deplibs into only deplibs that can be linked in shared.
-	name_save=$name
-	libname_save=$libname
-	release_save=$release
-	versuffix_save=$versuffix
-	major_save=$major
-	# I'm not sure if I'm treating the release correctly.  I think
-	# release should show up in the -l (ie -lgmp5) so we don't want to
-	# add it in twice.  Is that correct?
-	release=""
-	versuffix=""
-	major=""
-	newdeplibs=
-	droppeddeps=no
-	case $deplibs_check_method in
-	pass_all)
-	  # Don't check for shared/static.  Everything works.
-	  # This might be a little naive.  We might want to check
-	  # whether the library exists or not.  But this is on
-	  # osf3 & osf4 and I'm not really sure... Just
-	  # implementing what was already the behavior.
-	  newdeplibs=$deplibs
-	  ;;
-	test_compile)
-	  # This code stresses the "libraries are programs" paradigm to its
-	  # limits. Maybe even breaks it.  We compile a program, linking it
-	  # against the deplibs as a proxy for the library.  Then we can check
-	  # whether they linked in statically or dynamically with ldd.
-	  $rm conftest.c
-	  cat > conftest.c <<EOF
-	  int main() { return 0; }
-EOF
-	  $rm conftest
-	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
-	  if test "$?" -eq 0 ; then
-	    ldd_output=`ldd conftest`
-	    for i in $deplibs; do
-	      name=`expr $i : '-l\(.*\)'`
-	      # If $name is empty we are operating on a -L argument.
-              if test "$name" != "" && test "$name" -ne "0"; then
-		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		  case " $predeps $postdeps " in
-		  *" $i "*)
-		    newdeplibs="$newdeplibs $i"
-		    i=""
-		    ;;
-		  esac
-	        fi
-		if test -n "$i" ; then
-		  libname=`eval \\$echo \"$libname_spec\"`
-		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
-		  set dummy $deplib_matches
-		  deplib_match=$2
-		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
-		    newdeplibs="$newdeplibs $i"
-		  else
-		    droppeddeps=yes
-		    $echo
-		    $echo "*** Warning: dynamic linker does not accept needed library $i."
-		    $echo "*** I have the capability to make that library automatically link in when"
-		    $echo "*** you link to this library.  But I can only do this if you have a"
-		    $echo "*** shared version of the library, which I believe you do not have"
-		    $echo "*** because a test_compile did reveal that the linker did not use it for"
-		    $echo "*** its dynamic dependency list that programs get resolved with at runtime."
-		  fi
-		fi
-	      else
-		newdeplibs="$newdeplibs $i"
-	      fi
-	    done
-	  else
-	    # Error occurred in the first compile.  Let's try to salvage
-	    # the situation: Compile a separate program for each library.
-	    for i in $deplibs; do
-	      name=`expr $i : '-l\(.*\)'`
-	      # If $name is empty we are operating on a -L argument.
-              if test "$name" != "" && test "$name" != "0"; then
-		$rm conftest
-		$LTCC $LTCFLAGS -o conftest conftest.c $i
-		# Did it work?
-		if test "$?" -eq 0 ; then
-		  ldd_output=`ldd conftest`
-		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		    case " $predeps $postdeps " in
-		    *" $i "*)
-		      newdeplibs="$newdeplibs $i"
-		      i=""
-		      ;;
-		    esac
-		  fi
-		  if test -n "$i" ; then
-		    libname=`eval \\$echo \"$libname_spec\"`
-		    deplib_matches=`eval \\$echo \"$library_names_spec\"`
-		    set dummy $deplib_matches
-		    deplib_match=$2
-		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
-		      newdeplibs="$newdeplibs $i"
-		    else
-		      droppeddeps=yes
-		      $echo
-		      $echo "*** Warning: dynamic linker does not accept needed library $i."
-		      $echo "*** I have the capability to make that library automatically link in when"
-		      $echo "*** you link to this library.  But I can only do this if you have a"
-		      $echo "*** shared version of the library, which you do not appear to have"
-		      $echo "*** because a test_compile did reveal that the linker did not use this one"
-		      $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
-		    fi
-		  fi
-		else
-		  droppeddeps=yes
-		  $echo
-		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
-		  $echo "***  make it link in!  You will probably need to install it or some"
-		  $echo "*** library that it depends on before this library will be fully"
-		  $echo "*** functional.  Installing it before continuing would be even better."
-		fi
-	      else
-		newdeplibs="$newdeplibs $i"
-	      fi
-	    done
-	  fi
-	  ;;
-	file_magic*)
-	  set dummy $deplibs_check_method
-	  file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
-	  for a_deplib in $deplibs; do
-	    name=`expr $a_deplib : '-l\(.*\)'`
-	    # If $name is empty we are operating on a -L argument.
-            if test "$name" != "" && test  "$name" != "0"; then
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		case " $predeps $postdeps " in
-		*" $a_deplib "*)
-		  newdeplibs="$newdeplibs $a_deplib"
-		  a_deplib=""
-		  ;;
-		esac
-	      fi
-	      if test -n "$a_deplib" ; then
-		libname=`eval \\$echo \"$libname_spec\"`
-		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
-		  for potent_lib in $potential_libs; do
-		      # Follow soft links.
-		      if ls -lLd "$potent_lib" 2>/dev/null \
-			 | grep " -> " >/dev/null; then
-			continue
-		      fi
-		      # The statement above tries to avoid entering an
-		      # endless loop below, in case of cyclic links.
-		      # We might still enter an endless loop, since a link
-		      # loop can be closed while we follow links,
-		      # but so what?
-		      potlib="$potent_lib"
-		      while test -h "$potlib" 2>/dev/null; do
-			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
-			case $potliblink in
-			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
-			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
-			esac
-		      done
-		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
-			 | ${SED} 10q \
-			 | $EGREP "$file_magic_regex" > /dev/null; then
-			newdeplibs="$newdeplibs $a_deplib"
-			a_deplib=""
-			break 2
-		      fi
-		  done
-		done
-	      fi
-	      if test -n "$a_deplib" ; then
-		droppeddeps=yes
-		$echo
-		$echo "*** Warning: linker path does not have real file for library $a_deplib."
-		$echo "*** I have the capability to make that library automatically link in when"
-		$echo "*** you link to this library.  But I can only do this if you have a"
-		$echo "*** shared version of the library, which you do not appear to have"
-		$echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
-		  $echo "*** with $libname but no candidates were found. (...for file magic test)"
-		else
-		  $echo "*** with $libname and none of the candidates passed a file format test"
-		  $echo "*** using a file magic. Last file checked: $potlib"
-		fi
-	      fi
-	    else
-	      # Add a -L argument.
-	      newdeplibs="$newdeplibs $a_deplib"
-	    fi
-	  done # Gone through all deplibs.
-	  ;;
-	match_pattern*)
-	  set dummy $deplibs_check_method
-	  match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
-	  for a_deplib in $deplibs; do
-	    name=`expr $a_deplib : '-l\(.*\)'`
-	    # If $name is empty we are operating on a -L argument.
-	    if test -n "$name" && test "$name" != "0"; then
-	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-		case " $predeps $postdeps " in
-		*" $a_deplib "*)
-		  newdeplibs="$newdeplibs $a_deplib"
-		  a_deplib=""
-		  ;;
-		esac
-	      fi
-	      if test -n "$a_deplib" ; then
-		libname=`eval \\$echo \"$libname_spec\"`
-		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
-		  for potent_lib in $potential_libs; do
-		    potlib="$potent_lib" # see symlink-check above in file_magic test
-		    if eval $echo \"$potent_lib\" 2>/dev/null \
-		        | ${SED} 10q \
-		        | $EGREP "$match_pattern_regex" > /dev/null; then
-		      newdeplibs="$newdeplibs $a_deplib"
-		      a_deplib=""
-		      break 2
-		    fi
-		  done
-		done
-	      fi
-	      if test -n "$a_deplib" ; then
-		droppeddeps=yes
-		$echo
-		$echo "*** Warning: linker path does not have real file for library $a_deplib."
-		$echo "*** I have the capability to make that library automatically link in when"
-		$echo "*** you link to this library.  But I can only do this if you have a"
-		$echo "*** shared version of the library, which you do not appear to have"
-		$echo "*** because I did check the linker path looking for a file starting"
-		if test -z "$potlib" ; then
-		  $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
-		else
-		  $echo "*** with $libname and none of the candidates passed a file format test"
-		  $echo "*** using a regex pattern. Last file checked: $potlib"
-		fi
-	      fi
-	    else
-	      # Add a -L argument.
-	      newdeplibs="$newdeplibs $a_deplib"
-	    fi
-	  done # Gone through all deplibs.
-	  ;;
-	none | unknown | *)
-	  newdeplibs=""
-	  tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
-	    -e 's/ -[LR][^ ]*//g'`
-	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
-	    for i in $predeps $postdeps ; do
-	      # can't use Xsed below, because $i might contain '/'
-	      tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
-	    done
-	  fi
-	  if $echo "X $tmp_deplibs" | $Xsed -e 's/[ 	]//g' \
-	    | grep . >/dev/null; then
-	    $echo
-	    if test "X$deplibs_check_method" = "Xnone"; then
-	      $echo "*** Warning: inter-library dependencies are not supported in this platform."
-	    else
-	      $echo "*** Warning: inter-library dependencies are not known to be supported."
-	    fi
-	    $echo "*** All declared inter-library dependencies are being dropped."
-	    droppeddeps=yes
-	  fi
-	  ;;
-	esac
-	versuffix=$versuffix_save
-	major=$major_save
-	release=$release_save
-	libname=$libname_save
-	name=$name_save
-
-	case $host in
-	*-*-rhapsody* | *-*-darwin1.[012])
-	  # On Rhapsody replace the C library is the System framework
-	  newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
-	  ;;
-	esac
-
-	if test "$droppeddeps" = yes; then
-	  if test "$module" = yes; then
-	    $echo
-	    $echo "*** Warning: libtool could not satisfy all declared inter-library"
-	    $echo "*** dependencies of module $libname.  Therefore, libtool will create"
-	    $echo "*** a static module, that should work as long as the dlopening"
-	    $echo "*** application is linked with the -dlopen flag."
-	    if test -z "$global_symbol_pipe"; then
-	      $echo
-	      $echo "*** However, this would only work if libtool was able to extract symbol"
-	      $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
-	      $echo "*** not find such a program.  So, this module is probably useless."
-	      $echo "*** \`nm' from GNU binutils and a full rebuild may help."
-	    fi
-	    if test "$build_old_libs" = no; then
-	      oldlibs="$output_objdir/$libname.$libext"
-	      build_libtool_libs=module
-	      build_old_libs=yes
-	    else
-	      build_libtool_libs=no
-	    fi
-	  else
-	    $echo "*** The inter-library dependencies that have been dropped here will be"
-	    $echo "*** automatically added whenever a program is linked with this library"
-	    $echo "*** or is declared to -dlopen it."
-
-	    if test "$allow_undefined" = no; then
-	      $echo
-	      $echo "*** Since this library must not contain undefined symbols,"
-	      $echo "*** because either the platform does not support them or"
-	      $echo "*** it was explicitly requested with -no-undefined,"
-	      $echo "*** libtool will only create a static version of it."
-	      if test "$build_old_libs" = no; then
-		oldlibs="$output_objdir/$libname.$libext"
-		build_libtool_libs=module
-		build_old_libs=yes
-	      else
-		build_libtool_libs=no
-	      fi
-	    fi
-	  fi
-	fi
-	# Done checking deplibs!
-	deplibs=$newdeplibs
-      fi
-
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-	case " $new_libs " in
-	*" -L$path/$objdir "*) ;;
-	*)
-	  case " $deplibs " in
-	  *" -L$path/$objdir "*)
-	    new_libs="$new_libs -L$path/$objdir" ;;
-	  esac
-	  ;;
-	esac
-      done
-      for deplib in $deplibs; do
-	case $deplib in
-	-L*)
-	  case " $new_libs " in
-	  *" $deplib "*) ;;
-	  *) new_libs="$new_libs $deplib" ;;
-	  esac
-	  ;;
-	*) new_libs="$new_libs $deplib" ;;
-	esac
-      done
-      deplibs="$new_libs"
-
-
-      # All the library-specific variables (install_libdir is set above).
-      library_names=
-      old_library=
-      dlname=
-
-      # Test again, we may have decided not to build it any more
-      if test "$build_libtool_libs" = yes; then
-	if test "$hardcode_into_libs" = yes; then
-	  # Hardcode the library paths
-	  hardcode_libdirs=
-	  dep_rpath=
-	  rpath="$finalize_rpath"
-	  test "$mode" != relink && rpath="$compile_rpath$rpath"
-	  for libdir in $rpath; do
-	    if test -n "$hardcode_libdir_flag_spec"; then
-	      if test -n "$hardcode_libdir_separator"; then
-		if test -z "$hardcode_libdirs"; then
-		  hardcode_libdirs="$libdir"
-		else
-		  # Just accumulate the unique libdirs.
-		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
-		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
-		    ;;
-		  *)
-		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
-		    ;;
-		  esac
-		fi
-	      else
-		eval flag=\"$hardcode_libdir_flag_spec\"
-		dep_rpath="$dep_rpath $flag"
-	      fi
-	    elif test -n "$runpath_var"; then
-	      case "$perm_rpath " in
-	      *" $libdir "*) ;;
-	      *) perm_rpath="$perm_rpath $libdir" ;;
-	      esac
-	    fi
-	  done
-	  # Substitute the hardcoded libdirs into the rpath.
-	  if test -n "$hardcode_libdir_separator" &&
-	     test -n "$hardcode_libdirs"; then
-	    libdir="$hardcode_libdirs"
-	    if test -n "$hardcode_libdir_flag_spec_ld"; then
-	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
-	    else
-	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
-	    fi
-	  fi
-	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
-	    # We should set the runpath_var.
-	    rpath=
-	    for dir in $perm_rpath; do
-	      rpath="$rpath$dir:"
-	    done
-	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
-	  fi
-	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
-	fi
-
-	shlibpath="$finalize_shlibpath"
-	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
-	if test -n "$shlibpath"; then
-	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
-	fi
-
-	# Get the real and link names of the library.
-	eval shared_ext=\"$shrext_cmds\"
-	eval library_names=\"$library_names_spec\"
-	set dummy $library_names
-	realname="$2"
-	shift; shift
-
-	if test -n "$soname_spec"; then
-	  eval soname=\"$soname_spec\"
-	else
-	  soname="$realname"
-	fi
-	if test -z "$dlname"; then
-	  dlname=$soname
-	fi
-
-	lib="$output_objdir/$realname"
-	linknames=
-	for link
-	do
-	  linknames="$linknames $link"
-	done
-
-	# Use standard objects if they are pic
-	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
-
-	# Prepare the list of exported symbols
-	if test -z "$export_symbols"; then
-	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
-	    $show "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
-	    $run $rm $export_symbols
-	    cmds=$export_symbols_cmds
-	    save_ifs="$IFS"; IFS='~'
-	    for cmd in $cmds; do
-	      IFS="$save_ifs"
-	      eval cmd=\"$cmd\"
-	      if len=`expr "X$cmd" : ".*"` &&
-	       test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
-	        $show "$cmd"
-	        $run eval "$cmd" || exit $?
-	        skipped_export=false
-	      else
-	        # The command line is too long to execute in one step.
-	        $show "using reloadable object file for export list..."
-	        skipped_export=:
-		# Break out early, otherwise skipped_export may be
-		# set to false by a later but shorter cmd.
-		break
-	      fi
-	    done
-	    IFS="$save_ifs"
-	    if test -n "$export_symbols_regex"; then
-	      $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
-	      $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
-	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
-	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
-	    fi
-	  fi
-	fi
-
-	if test -n "$export_symbols" && test -n "$include_expsyms"; then
-	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
-	fi
-
-	tmp_deplibs=
-	for test_deplib in $deplibs; do
-		case " $convenience " in
-		*" $test_deplib "*) ;;
-		*)
-			tmp_deplibs="$tmp_deplibs $test_deplib"
-			;;
-		esac
-	done
-	deplibs="$tmp_deplibs"
-
-	if test -n "$convenience"; then
-	  if test -n "$whole_archive_flag_spec"; then
-	    save_libobjs=$libobjs
-	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
-	  else
-	    gentop="$output_objdir/${outputname}x"
-	    generated="$generated $gentop"
-
-	    func_extract_archives $gentop $convenience
-	    libobjs="$libobjs $func_extract_archives_result"
-	  fi
-	fi
-	
-	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
-	  eval flag=\"$thread_safe_flag_spec\"
-	  linker_flags="$linker_flags $flag"
-	fi
-
-	# Make a backup of the uninstalled library when relinking
-	if test "$mode" = relink; then
-	  $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
-	fi
-
-	# Do each of the archive commands.
-	if test "$module" = yes && test -n "$module_cmds" ; then
-	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
-	    eval test_cmds=\"$module_expsym_cmds\"
-	    cmds=$module_expsym_cmds
-	  else
-	    eval test_cmds=\"$module_cmds\"
-	    cmds=$module_cmds
-	  fi
-	else
-	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-	  eval test_cmds=\"$archive_expsym_cmds\"
-	  cmds=$archive_expsym_cmds
-	else
-	  eval test_cmds=\"$archive_cmds\"
-	  cmds=$archive_cmds
-	  fi
-	fi
-
-	if test "X$skipped_export" != "X:" &&
-	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
-	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
-	  :
-	else
-	  # The command line is too long to link in one step, link piecewise.
-	  $echo "creating reloadable object files..."
-
-	  # Save the value of $output and $libobjs because we want to
-	  # use them later.  If we have whole_archive_flag_spec, we
-	  # want to use save_libobjs as it was before
-	  # whole_archive_flag_spec was expanded, because we can't
-	  # assume the linker understands whole_archive_flag_spec.
-	  # This may have to be revisited, in case too many
-	  # convenience libraries get linked in and end up exceeding
-	  # the spec.
-	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
-	    save_libobjs=$libobjs
-	  fi
-	  save_output=$output
-	  output_la=`$echo "X$output" | $Xsed -e "$basename"`
-
-	  # Clear the reloadable object creation command queue and
-	  # initialize k to one.
-	  test_cmds=
-	  concat_cmds=
-	  objlist=
-	  delfiles=
-	  last_robj=
-	  k=1
-	  output=$output_objdir/$output_la-${k}.$objext
-	  # Loop over the list of objects to be linked.
-	  for obj in $save_libobjs
-	  do
-	    eval test_cmds=\"$reload_cmds $objlist $last_robj\"
-	    if test "X$objlist" = X ||
-	       { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
-		 test "$len" -le "$max_cmd_len"; }; then
-	      objlist="$objlist $obj"
-	    else
-	      # The command $test_cmds is almost too long, add a
-	      # command to the queue.
-	      if test "$k" -eq 1 ; then
-		# The first file doesn't have a previous command to add.
-		eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
-	      else
-		# All subsequent reloadable object files will link in
-		# the last one created.
-		eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
-	      fi
-	      last_robj=$output_objdir/$output_la-${k}.$objext
-	      k=`expr $k + 1`
-	      output=$output_objdir/$output_la-${k}.$objext
-	      objlist=$obj
-	      len=1
-	    fi
-	  done
-	  # Handle the remaining objects by creating one last
-	  # reloadable object file.  All subsequent reloadable object
-	  # files will link in the last one created.
-	  test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	  eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
-
-	  if ${skipped_export-false}; then
-	    $show "generating symbol list for \`$libname.la'"
-	    export_symbols="$output_objdir/$libname.exp"
-	    $run $rm $export_symbols
-	    libobjs=$output
-	    # Append the command to create the export file.
-	    eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
-          fi
-
-	  # Set up a command to remove the reloadable object files
-	  # after they are used.
-	  i=0
-	  while test "$i" -lt "$k"
-	  do
-	    i=`expr $i + 1`
-	    delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
-	  done
-
-	  $echo "creating a temporary reloadable object file: $output"
-
-	  # Loop through the commands generated above and execute them.
-	  save_ifs="$IFS"; IFS='~'
-	  for cmd in $concat_cmds; do
-	    IFS="$save_ifs"
-	    $show "$cmd"
-	    $run eval "$cmd" || exit $?
-	  done
-	  IFS="$save_ifs"
-
-	  libobjs=$output
-	  # Restore the value of output.
-	  output=$save_output
-
-	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
-	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
-	  fi
-	  # Expand the library linking commands again to reset the
-	  # value of $libobjs for piecewise linking.
-
-	  # Do each of the archive commands.
-	  if test "$module" = yes && test -n "$module_cmds" ; then
-	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
-	      cmds=$module_expsym_cmds
-	    else
-	      cmds=$module_cmds
-	    fi
-	  else
-	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-	    cmds=$archive_expsym_cmds
-	  else
-	    cmds=$archive_cmds
-	    fi
-	  fi
-
-	  # Append the command to remove the reloadable object files
-	  # to the just-reset $cmds.
-	  eval cmds=\"\$cmds~\$rm $delfiles\"
-	fi
-	save_ifs="$IFS"; IFS='~'
-	for cmd in $cmds; do
-	  IFS="$save_ifs"
-	  eval cmd=\"$cmd\"
-	  $show "$cmd"
-	  $run eval "$cmd" || {
-	    lt_exit=$?
-
-	    # Restore the uninstalled library and exit
-	    if test "$mode" = relink; then
-	      $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
-	    fi
-
-	    exit $lt_exit
-	  }
-	done
-	IFS="$save_ifs"
-
-	# Restore the uninstalled library and exit
-	if test "$mode" = relink; then
-	  $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
-
-	  if test -n "$convenience"; then
-	    if test -z "$whole_archive_flag_spec"; then
-	      $show "${rm}r $gentop"
-	      $run ${rm}r "$gentop"
-	    fi
-	  fi
-
-	  exit $EXIT_SUCCESS
-	fi
-
-	# Create links to the real library.
-	for linkname in $linknames; do
-	  if test "$realname" != "$linkname"; then
-	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
-	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
-	  fi
-	done
-
-	# If -module or -export-dynamic was specified, set the dlname.
-	if test "$module" = yes || test "$export_dynamic" = yes; then
-	  # On all known operating systems, these are identical.
-	  dlname="$soname"
-	fi
-      fi
-      ;;
-
-    obj)
-      if test -n "$deplibs"; then
-	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
-      fi
-
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
-      fi
-
-      if test -n "$rpath"; then
-	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
-      fi
-
-      if test -n "$xrpath"; then
-	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
-      fi
-
-      if test -n "$vinfo"; then
-	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
-      fi
-
-      if test -n "$release"; then
-	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
-      fi
-
-      case $output in
-      *.lo)
-	if test -n "$objs$old_deplibs"; then
-	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-	libobj="$output"
-	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
-	;;
-      *)
-	libobj=
-	obj="$output"
-	;;
-      esac
-
-      # Delete the old objects.
-      $run $rm $obj $libobj
-
-      # Objects from convenience libraries.  This assumes
-      # single-version convenience libraries.  Whenever we create
-      # different ones for PIC/non-PIC, this we'll have to duplicate
-      # the extraction.
-      reload_conv_objs=
-      gentop=
-      # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec
-      wl=
-
-      if test -n "$convenience"; then
-	if test -n "$whole_archive_flag_spec"; then
-	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
-	else
-	  gentop="$output_objdir/${obj}x"
-	  generated="$generated $gentop"
-
-	  func_extract_archives $gentop $convenience
-	  reload_conv_objs="$reload_objs $func_extract_archives_result"
-	fi
-      fi
-
-      # Create the old-style object.
-      reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
-
-      output="$obj"
-      cmds=$reload_cmds
-      save_ifs="$IFS"; IFS='~'
-      for cmd in $cmds; do
-	IFS="$save_ifs"
-	eval cmd=\"$cmd\"
-	$show "$cmd"
-	$run eval "$cmd" || exit $?
-      done
-      IFS="$save_ifs"
-
-      # Exit if we aren't doing a library object file.
-      if test -z "$libobj"; then
-	if test -n "$gentop"; then
-	  $show "${rm}r $gentop"
-	  $run ${rm}r $gentop
-	fi
-
-	exit $EXIT_SUCCESS
-      fi
-
-      if test "$build_libtool_libs" != yes; then
-	if test -n "$gentop"; then
-	  $show "${rm}r $gentop"
-	  $run ${rm}r $gentop
-	fi
-
-	# Create an invalid libtool object if no PIC, so that we don't
-	# accidentally link it into a program.
-	# $show "echo timestamp > $libobj"
-	# $run eval "echo timestamp > $libobj" || exit $?
-	exit $EXIT_SUCCESS
-      fi
-
-      if test -n "$pic_flag" || test "$pic_mode" != default; then
-	# Only do commands if we really have different PIC objects.
-	reload_objs="$libobjs $reload_conv_objs"
-	output="$libobj"
-	cmds=$reload_cmds
-	save_ifs="$IFS"; IFS='~'
-	for cmd in $cmds; do
-	  IFS="$save_ifs"
-	  eval cmd=\"$cmd\"
-	  $show "$cmd"
-	  $run eval "$cmd" || exit $?
-	done
-	IFS="$save_ifs"
-      fi
-
-      if test -n "$gentop"; then
-	$show "${rm}r $gentop"
-	$run ${rm}r $gentop
-      fi
-
-      exit $EXIT_SUCCESS
-      ;;
-
-    prog)
-      case $host in
-	*cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
-      esac
-      if test -n "$vinfo"; then
-	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
-      fi
-
-      if test -n "$release"; then
-	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
-      fi
-
-      if test "$preload" = yes; then
-	if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
-	   test "$dlopen_self_static" = unknown; then
-	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
-	fi
-      fi
-
-      case $host in
-      *-*-rhapsody* | *-*-darwin1.[012])
-	# On Rhapsody replace the C library is the System framework
-	compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
-	finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
-	;;
-      esac
-
-      case $host in
-      *darwin*)
-        # Don't allow lazy linking, it breaks C++ global constructors
-        if test "$tagname" = CXX ; then
-        compile_command="$compile_command ${wl}-bind_at_load"
-        finalize_command="$finalize_command ${wl}-bind_at_load"
-        fi
-        ;;
-      esac
-
-
-      # move library search paths that coincide with paths to not yet
-      # installed libraries to the beginning of the library search list
-      new_libs=
-      for path in $notinst_path; do
-	case " $new_libs " in
-	*" -L$path/$objdir "*) ;;
-	*)
-	  case " $compile_deplibs " in
-	  *" -L$path/$objdir "*)
-	    new_libs="$new_libs -L$path/$objdir" ;;
-	  esac
-	  ;;
-	esac
-      done
-      for deplib in $compile_deplibs; do
-	case $deplib in
-	-L*)
-	  case " $new_libs " in
-	  *" $deplib "*) ;;
-	  *) new_libs="$new_libs $deplib" ;;
-	  esac
-	  ;;
-	*) new_libs="$new_libs $deplib" ;;
-	esac
-      done
-      compile_deplibs="$new_libs"
-
-
-      compile_command="$compile_command $compile_deplibs"
-      finalize_command="$finalize_command $finalize_deplibs"
-
-      if test -n "$rpath$xrpath"; then
-	# If the user specified any rpath flags, then add them.
-	for libdir in $rpath $xrpath; do
-	  # This is the magic to use -rpath.
-	  case "$finalize_rpath " in
-	  *" $libdir "*) ;;
-	  *) finalize_rpath="$finalize_rpath $libdir" ;;
-	  esac
-	done
-      fi
-
-      # Now hardcode the library paths
-      rpath=
-      hardcode_libdirs=
-      for libdir in $compile_rpath $finalize_rpath; do
-	if test -n "$hardcode_libdir_flag_spec"; then
-	  if test -n "$hardcode_libdir_separator"; then
-	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
-	    else
-	      # Just accumulate the unique libdirs.
-	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
-	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
-		;;
-	      *)
-		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
-		;;
-	      esac
-	    fi
-	  else
-	    eval flag=\"$hardcode_libdir_flag_spec\"
-	    rpath="$rpath $flag"
-	  fi
-	elif test -n "$runpath_var"; then
-	  case "$perm_rpath " in
-	  *" $libdir "*) ;;
-	  *) perm_rpath="$perm_rpath $libdir" ;;
-	  esac
-	fi
-	case $host in
-	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
-	  testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
-	  case :$dllsearchpath: in
-	  *":$libdir:"*) ;;
-	  *) dllsearchpath="$dllsearchpath:$libdir";;
-	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  *) dllsearchpath="$dllsearchpath:$testbindir";;
-	  esac
-	  ;;
-	esac
-      done
-      # Substitute the hardcoded libdirs into the rpath.
-      if test -n "$hardcode_libdir_separator" &&
-	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
-	eval rpath=\" $hardcode_libdir_flag_spec\"
-      fi
-      compile_rpath="$rpath"
-
-      rpath=
-      hardcode_libdirs=
-      for libdir in $finalize_rpath; do
-	if test -n "$hardcode_libdir_flag_spec"; then
-	  if test -n "$hardcode_libdir_separator"; then
-	    if test -z "$hardcode_libdirs"; then
-	      hardcode_libdirs="$libdir"
-	    else
-	      # Just accumulate the unique libdirs.
-	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
-	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
-		;;
-	      *)
-		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
-		;;
-	      esac
-	    fi
-	  else
-	    eval flag=\"$hardcode_libdir_flag_spec\"
-	    rpath="$rpath $flag"
-	  fi
-	elif test -n "$runpath_var"; then
-	  case "$finalize_perm_rpath " in
-	  *" $libdir "*) ;;
-	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
-	  esac
-	fi
-      done
-      # Substitute the hardcoded libdirs into the rpath.
-      if test -n "$hardcode_libdir_separator" &&
-	 test -n "$hardcode_libdirs"; then
-	libdir="$hardcode_libdirs"
-	eval rpath=\" $hardcode_libdir_flag_spec\"
-      fi
-      finalize_rpath="$rpath"
-
-      if test -n "$libobjs" && test "$build_old_libs" = yes; then
-	# Transform all the library objects into standard objects.
-	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
-	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
-      fi
-
-      dlsyms=
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-	if test -n "$NM" && test -n "$global_symbol_pipe"; then
-	  dlsyms="${outputname}S.c"
-	else
-	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
-	fi
-      fi
-
-      if test -n "$dlsyms"; then
-	case $dlsyms in
-	"") ;;
-	*.c)
-	  # Discover the nlist of each of the dlfiles.
-	  nlist="$output_objdir/${outputname}.nm"
-
-	  $show "$rm $nlist ${nlist}S ${nlist}T"
-	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
-
-	  # Parse the name list into a source file.
-	  $show "creating $output_objdir/$dlsyms"
-
-	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
-/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
-/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
-
-#ifdef __cplusplus
-extern \"C\" {
-#endif
-
-/* Prevent the only kind of declaration conflicts we can make. */
-#define lt_preloaded_symbols some_other_symbol
-
-/* External symbol declarations for the compiler. */\
-"
-
-	  if test "$dlself" = yes; then
-	    $show "generating symbol list for \`$output'"
-
-	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
-
-	    # Add our own program objects to the symbol list.
-	    progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
-	    for arg in $progfiles; do
-	      $show "extracting global C symbols from \`$arg'"
-	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
-	    done
-
-	    if test -n "$exclude_expsyms"; then
-	      $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
-	      $run eval '$mv "$nlist"T "$nlist"'
-	    fi
-
-	    if test -n "$export_symbols_regex"; then
-	      $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
-	      $run eval '$mv "$nlist"T "$nlist"'
-	    fi
-
-	    # Prepare the list of exported symbols
-	    if test -z "$export_symbols"; then
-	      export_symbols="$output_objdir/$outputname.exp"
-	      $run $rm $export_symbols
-	      $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
-              case $host in
-              *cygwin* | *mingw* )
-	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-		$run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
-                ;;
-              esac
-	    else
-	      $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
-	      $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
-	      $run eval 'mv "$nlist"T "$nlist"'
-              case $host in
-              *cygwin* | *mingw* )
-	        $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
-		$run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
-                ;;
-              esac
-	    fi
-	  fi
-
-	  for arg in $dlprefiles; do
-	    $show "extracting global C symbols from \`$arg'"
-	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
-	    $run eval '$echo ": $name " >> "$nlist"'
-	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
-	  done
-
-	  if test -z "$run"; then
-	    # Make sure we have at least an empty file.
-	    test -f "$nlist" || : > "$nlist"
-
-	    if test -n "$exclude_expsyms"; then
-	      $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
-	      $mv "$nlist"T "$nlist"
-	    fi
-
-	    # Try sorting and uniquifying the output.
-	    if grep -v "^: " < "$nlist" |
-		if sort -k 3 </dev/null >/dev/null 2>&1; then
-		  sort -k 3
-		else
-		  sort +2
-		fi |
-		uniq > "$nlist"S; then
-	      :
-	    else
-	      grep -v "^: " < "$nlist" > "$nlist"S
-	    fi
-
-	    if test -f "$nlist"S; then
-	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
-	    else
-	      $echo '/* NONE */' >> "$output_objdir/$dlsyms"
-	    fi
-
-	    $echo >> "$output_objdir/$dlsyms" "\
-
-#undef lt_preloaded_symbols
-
-#if defined (__STDC__) && __STDC__
-# define lt_ptr void *
-#else
-# define lt_ptr char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-"
-
-	    case $host in
-	    *cygwin* | *mingw* )
-	  $echo >> "$output_objdir/$dlsyms" "\
-/* DATA imports from DLLs on WIN32 can't be const, because
-   runtime relocations are performed -- see ld's documentation
-   on pseudo-relocs */
-struct {
-"
-	      ;;
-	    * )
-	  $echo >> "$output_objdir/$dlsyms" "\
-const struct {
-"
-	      ;;
-	    esac
-
-
-	  $echo >> "$output_objdir/$dlsyms" "\
-  const char *name;
-  lt_ptr address;
-}
-lt_preloaded_symbols[] =
-{\
-"
-
-	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
-
-	    $echo >> "$output_objdir/$dlsyms" "\
-  {0, (lt_ptr) 0}
-};
-
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
-  return lt_preloaded_symbols;
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif\
-"
-	  fi
-
-	  pic_flag_for_symtable=
-	  case $host in
-	  # compiling the symbol table file with pic_flag works around
-	  # a FreeBSD bug that causes programs to crash when -lm is
-	  # linked before any other PIC object.  But we must not use
-	  # pic_flag when linking with -static.  The problem exists in
-	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
-	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
-	    case "$compile_command " in
-	    *" -static "*) ;;
-	    *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
-	    esac;;
-	  *-*-hpux*)
-	    case "$compile_command " in
-	    *" -static "*) ;;
-	    *) pic_flag_for_symtable=" $pic_flag";;
-	    esac
-	  esac
-
-	  # Now compile the dynamic symbol file.
-	  $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
-	  $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
-
-	  # Clean up the generated files.
-	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
-	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
-
-	  # Transform the symbol file into the correct name.
-          case $host in
-          *cygwin* | *mingw* )
-            if test -f "$output_objdir/${outputname}.def" ; then
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
-            else
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-             fi
-            ;;
-          * )
-            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-            ;;
-          esac
-	  ;;
-	*)
-	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-      else
-	# We keep going just in case the user didn't refer to
-	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
-	# really was required.
-
-	# Nullify the symbol file.
-	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
-	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
-      fi
-
-      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
-	# Replace the output file specification.
-	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
-	link_command="$compile_command$compile_rpath"
-
-	# We have no uninstalled library dependencies, so finalize right now.
-	$show "$link_command"
-	$run eval "$link_command"
-	exit_status=$?
-
-	# Delete the generated files.
-	if test -n "$dlsyms"; then
-	  $show "$rm $output_objdir/${outputname}S.${objext}"
-	  $run $rm "$output_objdir/${outputname}S.${objext}"
-	fi
-
-	exit $exit_status
-      fi
-
-      if test -n "$shlibpath_var"; then
-	# We should set the shlibpath_var
-	rpath=
-	for dir in $temp_rpath; do
-	  case $dir in
-	  [\\/]* | [A-Za-z]:[\\/]*)
-	    # Absolute path.
-	    rpath="$rpath$dir:"
-	    ;;
-	  *)
-	    # Relative path: add a thisdir entry.
-	    rpath="$rpath\$thisdir/$dir:"
-	    ;;
-	  esac
-	done
-	temp_rpath="$rpath"
-      fi
-
-      if test -n "$compile_shlibpath$finalize_shlibpath"; then
-	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
-      fi
-      if test -n "$finalize_shlibpath"; then
-	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
-      fi
-
-      compile_var=
-      finalize_var=
-      if test -n "$runpath_var"; then
-	if test -n "$perm_rpath"; then
-	  # We should set the runpath_var.
-	  rpath=
-	  for dir in $perm_rpath; do
-	    rpath="$rpath$dir:"
-	  done
-	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
-	fi
-	if test -n "$finalize_perm_rpath"; then
-	  # We should set the runpath_var.
-	  rpath=
-	  for dir in $finalize_perm_rpath; do
-	    rpath="$rpath$dir:"
-	  done
-	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
-	fi
-      fi
-
-      if test "$no_install" = yes; then
-	# We don't need to create a wrapper script.
-	link_command="$compile_var$compile_command$compile_rpath"
-	# Replace the output file specification.
-	link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
-	# Delete the old output file.
-	$run $rm $output
-	# Link the executable and exit
-	$show "$link_command"
-	$run eval "$link_command" || exit $?
-	exit $EXIT_SUCCESS
-      fi
-
-      if test "$hardcode_action" = relink; then
-	# Fast installation is not supported
-	link_command="$compile_var$compile_command$compile_rpath"
-	relink_command="$finalize_var$finalize_command$finalize_rpath"
-
-	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
-	$echo "$modename: \`$output' will be relinked during installation" 1>&2
-      else
-	if test "$fast_install" != no; then
-	  link_command="$finalize_var$compile_command$finalize_rpath"
-	  if test "$fast_install" = yes; then
-	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
-	  else
-	    # fast_install is set to needless
-	    relink_command=
-	  fi
-	else
-	  link_command="$compile_var$compile_command$compile_rpath"
-	  relink_command="$finalize_var$finalize_command$finalize_rpath"
-	fi
-      fi
-
-      # Replace the output file specification.
-      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
-
-      # Delete the old output files.
-      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
-
-      $show "$link_command"
-      $run eval "$link_command" || exit $?
-
-      # Now create the wrapper script.
-      $show "creating $output"
-
-      # Quote the relink command for shipping.
-      if test -n "$relink_command"; then
-	# Preserve any variables that may affect compiler behavior
-	for var in $variables_saved_for_relink; do
-	  if eval test -z \"\${$var+set}\"; then
-	    relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
-	  elif eval var_value=\$$var; test -z "$var_value"; then
-	    relink_command="$var=; export $var; $relink_command"
-	  else
-	    var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
-	    relink_command="$var=\"$var_value\"; export $var; $relink_command"
-	  fi
-	done
-	relink_command="(cd `pwd`; $relink_command)"
-	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
-      fi
-
-      # Quote $echo for shipping.
-      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
-	case $progpath in
-	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
-	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
-	esac
-	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
-      else
-	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
-      fi
-
-      # Only actually do things if our run command is non-null.
-      if test -z "$run"; then
-	# win32 will think the script is a binary if it has
-	# a .exe suffix, so we strip it off here.
-	case $output in
-	  *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
-	esac
-	# test for cygwin because mv fails w/o .exe extensions
-	case $host in
-	  *cygwin*)
-	    exeext=.exe
-	    outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
-	  *) exeext= ;;
-	esac
-	case $host in
-	  *cygwin* | *mingw* )
-            output_name=`basename $output`
-            output_path=`dirname $output`
-            cwrappersource="$output_path/$objdir/lt-$output_name.c"
-            cwrapper="$output_path/$output_name.exe"
-            $rm $cwrappersource $cwrapper
-            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
-
-	    cat > $cwrappersource <<EOF
-
-/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
-   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-
-   The $output program cannot be directly executed until all the libtool
-   libraries that it depends on are installed.
-
-   This wrapper executable should never be moved out of the build directory.
-   If it is, it will not operate correctly.
-
-   Currently, it simply execs the wrapper *script* "/bin/sh $output",
-   but could eventually absorb all of the scripts functionality and
-   exec $objdir/$outputname directly.
-*/
-EOF
-	    cat >> $cwrappersource<<"EOF"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <malloc.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/stat.h>
-
-#if defined(PATH_MAX)
-# define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
-# define LT_PATHMAX MAXPATHLEN
-#else
-# define LT_PATHMAX 1024
-#endif
-
-#ifndef DIR_SEPARATOR
-# define DIR_SEPARATOR '/'
-# define PATH_SEPARATOR ':'
-#endif
-
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
-# define HAVE_DOS_BASED_FILE_SYSTEM
-# ifndef DIR_SEPARATOR_2
-#  define DIR_SEPARATOR_2 '\\'
-# endif
-# ifndef PATH_SEPARATOR_2
-#  define PATH_SEPARATOR_2 ';'
-# endif
-#endif
-
-#ifndef DIR_SEPARATOR_2
-# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
-#else /* DIR_SEPARATOR_2 */
-# define IS_DIR_SEPARATOR(ch) \
-        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
-#endif /* DIR_SEPARATOR_2 */
-
-#ifndef PATH_SEPARATOR_2
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
-#else /* PATH_SEPARATOR_2 */
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
-#endif /* PATH_SEPARATOR_2 */
-
-#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
-#define XFREE(stale) do { \
-  if (stale) { free ((void *) stale); stale = 0; } \
-} while (0)
-
-/* -DDEBUG is fairly common in CFLAGS.  */
-#undef DEBUG
-#if defined DEBUGWRAPPER
-# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
-#else
-# define DEBUG(format, ...)
-#endif
-
-const char *program_name = NULL;
-
-void * xmalloc (size_t num);
-char * xstrdup (const char *string);
-const char * base_name (const char *name);
-char * find_executable(const char *wrapper);
-int    check_executable(const char *path);
-char * strendzap(char *str, const char *pat);
-void lt_fatal (const char *message, ...);
-
-int
-main (int argc, char *argv[])
-{
-  char **newargz;
-  int i;
-
-  program_name = (char *) xstrdup (base_name (argv[0]));
-  DEBUG("(main) argv[0]      : %s\n",argv[0]);
-  DEBUG("(main) program_name : %s\n",program_name);
-  newargz = XMALLOC(char *, argc+2);
-EOF
-
-            cat >> $cwrappersource <<EOF
-  newargz[0] = (char *) xstrdup("$SHELL");
-EOF
-
-            cat >> $cwrappersource <<"EOF"
-  newargz[1] = find_executable(argv[0]);
-  if (newargz[1] == NULL)
-    lt_fatal("Couldn't find %s", argv[0]);
-  DEBUG("(main) found exe at : %s\n",newargz[1]);
-  /* we know the script has the same name, without the .exe */
-  /* so make sure newargz[1] doesn't end in .exe */
-  strendzap(newargz[1],".exe");
-  for (i = 1; i < argc; i++)
-    newargz[i+1] = xstrdup(argv[i]);
-  newargz[argc+1] = NULL;
-
-  for (i=0; i<argc+1; i++)
-  {
-    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
-    ;
-  }
-
-EOF
-
-            case $host_os in
-              mingw*)
-                cat >> $cwrappersource <<EOF
-  execv("$SHELL",(char const **)newargz);
-EOF
-              ;;
-              *)
-                cat >> $cwrappersource <<EOF
-  execv("$SHELL",newargz);
-EOF
-              ;;
-            esac
-
-            cat >> $cwrappersource <<"EOF"
-  return 127;
-}
-
-void *
-xmalloc (size_t num)
-{
-  void * p = (void *) malloc (num);
-  if (!p)
-    lt_fatal ("Memory exhausted");
-
-  return p;
-}
-
-char *
-xstrdup (const char *string)
-{
-  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
-;
-}
-
-const char *
-base_name (const char *name)
-{
-  const char *base;
-
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  /* Skip over the disk name in MSDOS pathnames. */
-  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
-    name += 2;
-#endif
-
-  for (base = name; *name; name++)
-    if (IS_DIR_SEPARATOR (*name))
-      base = name + 1;
-  return base;
-}
-
-int
-check_executable(const char * path)
-{
-  struct stat st;
-
-  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
-  if ((!path) || (!*path))
-    return 0;
-
-  if ((stat (path, &st) >= 0) &&
-      (
-        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
-#if defined (S_IXOTH)
-       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
-#endif
-#if defined (S_IXGRP)
-       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
-#endif
-       ((st.st_mode & S_IXUSR) == S_IXUSR))
-      )
-    return 1;
-  else
-    return 0;
-}
-
-/* Searches for the full path of the wrapper.  Returns
-   newly allocated full path name if found, NULL otherwise */
-char *
-find_executable (const char* wrapper)
-{
-  int has_slash = 0;
-  const char* p;
-  const char* p_next;
-  /* static buffer for getcwd */
-  char tmp[LT_PATHMAX + 1];
-  int tmp_len;
-  char* concat_name;
-
-  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
-
-  if ((wrapper == NULL) || (*wrapper == '\0'))
-    return NULL;
-
-  /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
-  {
-    concat_name = xstrdup (wrapper);
-    if (check_executable(concat_name))
-      return concat_name;
-    XFREE(concat_name);
-  }
-  else
-  {
-#endif
-    if (IS_DIR_SEPARATOR (wrapper[0]))
-    {
-      concat_name = xstrdup (wrapper);
-      if (check_executable(concat_name))
-        return concat_name;
-      XFREE(concat_name);
-    }
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
-  }
-#endif
-
-  for (p = wrapper; *p; p++)
-    if (*p == '/')
-    {
-      has_slash = 1;
-      break;
-    }
-  if (!has_slash)
-  {
-    /* no slashes; search PATH */
-    const char* path = getenv ("PATH");
-    if (path != NULL)
-    {
-      for (p = path; *p; p = p_next)
-      {
-        const char* q;
-        size_t p_len;
-        for (q = p; *q; q++)
-          if (IS_PATH_SEPARATOR(*q))
-            break;
-        p_len = q - p;
-        p_next = (*q == '\0' ? q : q + 1);
-        if (p_len == 0)
-        {
-          /* empty path: current directory */
-          if (getcwd (tmp, LT_PATHMAX) == NULL)
-            lt_fatal ("getcwd failed");
-          tmp_len = strlen(tmp);
-          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
-          memcpy (concat_name, tmp, tmp_len);
-          concat_name[tmp_len] = '/';
-          strcpy (concat_name + tmp_len + 1, wrapper);
-        }
-        else
-        {
-          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
-          memcpy (concat_name, p, p_len);
-          concat_name[p_len] = '/';
-          strcpy (concat_name + p_len + 1, wrapper);
-        }
-        if (check_executable(concat_name))
-          return concat_name;
-        XFREE(concat_name);
-      }
-    }
-    /* not found in PATH; assume curdir */
-  }
-  /* Relative path | not found in path: prepend cwd */
-  if (getcwd (tmp, LT_PATHMAX) == NULL)
-    lt_fatal ("getcwd failed");
-  tmp_len = strlen(tmp);
-  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
-  memcpy (concat_name, tmp, tmp_len);
-  concat_name[tmp_len] = '/';
-  strcpy (concat_name + tmp_len + 1, wrapper);
-
-  if (check_executable(concat_name))
-    return concat_name;
-  XFREE(concat_name);
-  return NULL;
-}
-
-char *
-strendzap(char *str, const char *pat)
-{
-  size_t len, patlen;
-
-  assert(str != NULL);
-  assert(pat != NULL);
-
-  len = strlen(str);
-  patlen = strlen(pat);
-
-  if (patlen <= len)
-  {
-    str += len - patlen;
-    if (strcmp(str, pat) == 0)
-      *str = '\0';
-  }
-  return str;
-}
-
-static void
-lt_error_core (int exit_status, const char * mode,
-          const char * message, va_list ap)
-{
-  fprintf (stderr, "%s: %s: ", program_name, mode);
-  vfprintf (stderr, message, ap);
-  fprintf (stderr, ".\n");
-
-  if (exit_status >= 0)
-    exit (exit_status);
-}
-
-void
-lt_fatal (const char *message, ...)
-{
-  va_list ap;
-  va_start (ap, message);
-  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
-  va_end (ap);
-}
-EOF
-          # we should really use a build-platform specific compiler
-          # here, but OTOH, the wrappers (shell script and this C one)
-          # are only useful if you want to execute the "real" binary.
-          # Since the "real" binary is built for $host, then this
-          # wrapper might as well be built for $host, too.
-          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
-          ;;
-        esac
-        $rm $output
-        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
-
-	$echo > $output "\
-#! $SHELL
-
-# $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# The $output program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='${SED} -e 1s/^X//'
-sed_quote_subst='$sed_quote_subst'
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-relink_command=\"$relink_command\"
-
-# This environment variable determines our operation mode.
-if test \"\$libtool_install_magic\" = \"$magic\"; then
-  # install mode needs the following variable:
-  notinst_deplibs='$notinst_deplibs'
-else
-  # When we are sourced in execute mode, \$file and \$echo are already set.
-  if test \"\$libtool_execute_magic\" != \"$magic\"; then
-    echo=\"$qecho\"
-    file=\"\$0\"
-    # Make sure echo works.
-    if test \"X\$1\" = X--no-reexec; then
-      # Discard the --no-reexec flag, and continue.
-      shift
-    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
-      # Yippee, \$echo works!
-      :
-    else
-      # Restart under the correct shell, and then maybe \$echo will work.
-      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
-    fi
-  fi\
-"
-	$echo >> $output "\
-
-  # Find the directory that this script lives in.
-  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
-  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
-
-  # Follow symbolic links until we get to the real thisdir.
-  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
-  while test -n \"\$file\"; do
-    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
-
-    # If there was a directory component, then change thisdir.
-    if test \"x\$destdir\" != \"x\$file\"; then
-      case \"\$destdir\" in
-      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
-      *) thisdir=\"\$thisdir/\$destdir\" ;;
-      esac
-    fi
-
-    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
-    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
-  done
-
-  # Try to get the absolute directory name.
-  absdir=\`cd \"\$thisdir\" && pwd\`
-  test -n \"\$absdir\" && thisdir=\"\$absdir\"
-"
-
-	if test "$fast_install" = yes; then
-	  $echo >> $output "\
-  program=lt-'$outputname'$exeext
-  progdir=\"\$thisdir/$objdir\"
-
-  if test ! -f \"\$progdir/\$program\" || \\
-     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
-       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
-
-    file=\"\$\$-\$program\"
-
-    if test ! -d \"\$progdir\"; then
-      $mkdir \"\$progdir\"
-    else
-      $rm \"\$progdir/\$file\"
-    fi"
-
-	  $echo >> $output "\
-
-    # relink executable if necessary
-    if test -n \"\$relink_command\"; then
-      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
-      else
-	$echo \"\$relink_command_output\" >&2
-	$rm \"\$progdir/\$file\"
-	exit $EXIT_FAILURE
-      fi
-    fi
-
-    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
-    { $rm \"\$progdir/\$program\";
-      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
-    $rm \"\$progdir/\$file\"
-  fi"
-	else
-	  $echo >> $output "\
-  program='$outputname'
-  progdir=\"\$thisdir/$objdir\"
-"
-	fi
-
-	$echo >> $output "\
-
-  if test -f \"\$progdir/\$program\"; then"
-
-	# Export our shlibpath_var if we have one.
-	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
-	  $echo >> $output "\
-    # Add our own library path to $shlibpath_var
-    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
-
-    # Some systems cannot cope with colon-terminated $shlibpath_var
-    # The second colon is a workaround for a bug in BeOS R4 sed
-    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
-
-    export $shlibpath_var
-"
-	fi
-
-	# fixup the dll searchpath if we need to.
-	if test -n "$dllsearchpath"; then
-	  $echo >> $output "\
-    # Add the dll search path components to the executable PATH
-    PATH=$dllsearchpath:\$PATH
-"
-	fi
-
-	$echo >> $output "\
-    if test \"\$libtool_execute_magic\" != \"$magic\"; then
-      # Run the actual program with our arguments.
-"
-	case $host in
-	# Backslashes separate directories on plain windows
-	*-*-mingw | *-*-os2*)
-	  $echo >> $output "\
-      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
-"
-	  ;;
-
-	*)
-	  $echo >> $output "\
-      exec \"\$progdir/\$program\" \${1+\"\$@\"}
-"
-	  ;;
-	esac
-	$echo >> $output "\
-      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
-      exit $EXIT_FAILURE
-    fi
-  else
-    # The program doesn't exist.
-    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
-    \$echo \"This script is just a wrapper for \$program.\" 1>&2
-    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
-    exit $EXIT_FAILURE
-  fi
-fi\
-"
-	chmod +x $output
-      fi
-      exit $EXIT_SUCCESS
-      ;;
-    esac
-
-    # See if we need to build an old-fashioned archive.
-    for oldlib in $oldlibs; do
-
-      if test "$build_libtool_libs" = convenience; then
-	oldobjs="$libobjs_save"
-	addlibs="$convenience"
-	build_libtool_libs=no
-      else
-	if test "$build_libtool_libs" = module; then
-	  oldobjs="$libobjs_save"
-	  build_libtool_libs=no
-	else
-	  oldobjs="$old_deplibs $non_pic_objects"
-	fi
-	addlibs="$old_convenience"
-      fi
-
-      if test -n "$addlibs"; then
-	gentop="$output_objdir/${outputname}x"
-	generated="$generated $gentop"
-
-	func_extract_archives $gentop $addlibs
-	oldobjs="$oldobjs $func_extract_archives_result"
-      fi
-
-      # Do each command in the archive commands.
-      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
-       cmds=$old_archive_from_new_cmds
-      else
-	# POSIX demands no paths to be encoded in archives.  We have
-	# to avoid creating archives with duplicate basenames if we
-	# might have to extract them afterwards, e.g., when creating a
-	# static archive out of a convenience library, or when linking
-	# the entirety of a libtool archive into another (currently
-	# not supported by libtool).
-	if (for obj in $oldobjs
-	    do
-	      $echo "X$obj" | $Xsed -e 's%^.*/%%'
-	    done | sort | sort -uc >/dev/null 2>&1); then
-	  :
-	else
-	  $echo "copying selected object files to avoid basename conflicts..."
-
-	  if test -z "$gentop"; then
-	    gentop="$output_objdir/${outputname}x"
-	    generated="$generated $gentop"
-
-	    $show "${rm}r $gentop"
-	    $run ${rm}r "$gentop"
-	    $show "$mkdir $gentop"
-	    $run $mkdir "$gentop"
-	    exit_status=$?
-	    if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
-	      exit $exit_status
-	    fi
-	  fi
-
-	  save_oldobjs=$oldobjs
-	  oldobjs=
-	  counter=1
-	  for obj in $save_oldobjs
-	  do
-	    objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
-	    case " $oldobjs " in
-	    " ") oldobjs=$obj ;;
-	    *[\ /]"$objbase "*)
-	      while :; do
-		# Make sure we don't pick an alternate name that also
-		# overlaps.
-		newobj=lt$counter-$objbase
-		counter=`expr $counter + 1`
-		case " $oldobjs " in
-		*[\ /]"$newobj "*) ;;
-		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
-		esac
-	      done
-	      $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
-	      $run ln "$obj" "$gentop/$newobj" ||
-	      $run cp "$obj" "$gentop/$newobj"
-	      oldobjs="$oldobjs $gentop/$newobj"
-	      ;;
-	    *) oldobjs="$oldobjs $obj" ;;
-	    esac
-	  done
-	fi
-
-	eval cmds=\"$old_archive_cmds\"
-
-	if len=`expr "X$cmds" : ".*"` &&
-	     test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
-	  cmds=$old_archive_cmds
-	else
-	  # the command line is too long to link in one step, link in parts
-	  $echo "using piecewise archive linking..."
-	  save_RANLIB=$RANLIB
-	  RANLIB=:
-	  objlist=
-	  concat_cmds=
-	  save_oldobjs=$oldobjs
-
-	  # Is there a better way of finding the last object in the list?
-	  for obj in $save_oldobjs
-	  do
-	    last_oldobj=$obj
-	  done
-	  for obj in $save_oldobjs
-	  do
-	    oldobjs="$objlist $obj"
-	    objlist="$objlist $obj"
-	    eval test_cmds=\"$old_archive_cmds\"
-	    if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
-	       test "$len" -le "$max_cmd_len"; then
-	      :
-	    else
-	      # the above command should be used before it gets too long
-	      oldobjs=$objlist
-	      if test "$obj" = "$last_oldobj" ; then
-	        RANLIB=$save_RANLIB
-	      fi
-	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
-	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
-	      objlist=
-	    fi
-	  done
-	  RANLIB=$save_RANLIB
-	  oldobjs=$objlist
-	  if test "X$oldobjs" = "X" ; then
-	    eval cmds=\"\$concat_cmds\"
-	  else
-	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
-	  fi
-	fi
-      fi
-      save_ifs="$IFS"; IFS='~'
-      for cmd in $cmds; do
-        eval cmd=\"$cmd\"
-	IFS="$save_ifs"
-	$show "$cmd"
-	$run eval "$cmd" || exit $?
-      done
-      IFS="$save_ifs"
-    done
-
-    if test -n "$generated"; then
-      $show "${rm}r$generated"
-      $run ${rm}r$generated
-    fi
-
-    # Now create the libtool archive.
-    case $output in
-    *.la)
-      old_library=
-      test "$build_old_libs" = yes && old_library="$libname.$libext"
-      $show "creating $output"
-
-      # Preserve any variables that may affect compiler behavior
-      for var in $variables_saved_for_relink; do
-	if eval test -z \"\${$var+set}\"; then
-	  relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
-	elif eval var_value=\$$var; test -z "$var_value"; then
-	  relink_command="$var=; export $var; $relink_command"
-	else
-	  var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
-	  relink_command="$var=\"$var_value\"; export $var; $relink_command"
-	fi
-      done
-      # Quote the link command for shipping.
-      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
-      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
-      if test "$hardcode_automatic" = yes ; then
-	relink_command=
-      fi
-
-
-      # Only create the output if not a dry run.
-      if test -z "$run"; then
-	for installed in no yes; do
-	  if test "$installed" = yes; then
-	    if test -z "$install_libdir"; then
-	      break
-	    fi
-	    output="$output_objdir/$outputname"i
-	    # Replace all uninstalled libtool libraries with the installed ones
-	    newdependency_libs=
-	    for deplib in $dependency_libs; do
-	      case $deplib in
-	      *.la)
-		name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
-		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
-		if test -z "$libdir"; then
-		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
-		  exit $EXIT_FAILURE
-		fi
-		newdependency_libs="$newdependency_libs $libdir/$name"
-		;;
-	      *) newdependency_libs="$newdependency_libs $deplib" ;;
-	      esac
-	    done
-	    dependency_libs="$newdependency_libs"
-	    newdlfiles=
-	    for lib in $dlfiles; do
-	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
-	      if test -z "$libdir"; then
-		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
-		exit $EXIT_FAILURE
-	      fi
-	      newdlfiles="$newdlfiles $libdir/$name"
-	    done
-	    dlfiles="$newdlfiles"
-	    newdlprefiles=
-	    for lib in $dlprefiles; do
-	      name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-	      eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
-	      if test -z "$libdir"; then
-		$echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
-		exit $EXIT_FAILURE
-	      fi
-	      newdlprefiles="$newdlprefiles $libdir/$name"
-	    done
-	    dlprefiles="$newdlprefiles"
-	  else
-	    newdlfiles=
-	    for lib in $dlfiles; do
-	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
-		*) abs=`pwd`"/$lib" ;;
-	      esac
-	      newdlfiles="$newdlfiles $abs"
-	    done
-	    dlfiles="$newdlfiles"
-	    newdlprefiles=
-	    for lib in $dlprefiles; do
-	      case $lib in
-		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
-		*) abs=`pwd`"/$lib" ;;
-	      esac
-	      newdlprefiles="$newdlprefiles $abs"
-	    done
-	    dlprefiles="$newdlprefiles"
-	  fi
-	  $rm $output
-	  # place dlname in correct position for cygwin
-	  tdlname=$dlname
-	  case $host,$output,$installed,$module,$dlname in
-	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
-	  esac
-	  $echo > $output "\
-# $outputname - a libtool library file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# The name that we can dlopen(3).
-dlname='$tdlname'
-
-# Names of this library.
-library_names='$library_names'
-
-# The name of the static archive.
-old_library='$old_library'
-
-# Libraries that this one depends upon.
-dependency_libs='$dependency_libs'
-
-# Version information for $libname.
-current=$current
-age=$age
-revision=$revision
-
-# Is this an already installed library?
-installed=$installed
-
-# Should we warn about portability when linking against -modules?
-shouldnotlink=$module
-
-# Files to dlopen/dlpreopen
-dlopen='$dlfiles'
-dlpreopen='$dlprefiles'
-
-# Directory that this library needs to be installed in:
-libdir='$install_libdir'"
-	  if test "$installed" = no && test "$need_relink" = yes; then
-	    $echo >> $output "\
-relink_command=\"$relink_command\""
-	  fi
-	done
-      fi
-
-      # Do a symbolic link so that the libtool archive can be found in
-      # LD_LIBRARY_PATH before the program is installed.
-      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
-      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
-      ;;
-    esac
-    exit $EXIT_SUCCESS
-    ;;
-
-  # libtool install mode
-  install)
-    modename="$modename: install"
-
-    # There may be an optional sh(1) argument at the beginning of
-    # install_prog (especially on Windows NT).
-    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
-       # Allow the use of GNU shtool's install command.
-       $echo "X$nonopt" | grep shtool > /dev/null; then
-      # Aesthetically quote it.
-      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
-      case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	arg="\"$arg\""
-	;;
-      esac
-      install_prog="$arg "
-      arg="$1"
-      shift
-    else
-      install_prog=
-      arg=$nonopt
-    fi
-
-    # The real first argument should be the name of the installation program.
-    # Aesthetically quote it.
-    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-    case $arg in
-    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-      arg="\"$arg\""
-      ;;
-    esac
-    install_prog="$install_prog$arg"
-
-    # We need to accept at least all the BSD install flags.
-    dest=
-    files=
-    opts=
-    prev=
-    install_type=
-    isdir=no
-    stripme=
-    for arg
-    do
-      if test -n "$dest"; then
-	files="$files $dest"
-	dest=$arg
-	continue
-      fi
-
-      case $arg in
-      -d) isdir=yes ;;
-      -f) 
-      	case " $install_prog " in
-	*[\\\ /]cp\ *) ;;
-	*) prev=$arg ;;
-	esac
-	;;
-      -g | -m | -o) prev=$arg ;;
-      -s)
-	stripme=" -s"
-	continue
-	;;
-      -*)
-	;;
-      *)
-	# If the previous option needed an argument, then skip it.
-	if test -n "$prev"; then
-	  prev=
-	else
-	  dest=$arg
-	  continue
-	fi
-	;;
-      esac
-
-      # Aesthetically quote the argument.
-      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
-      case $arg in
-      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
-	arg="\"$arg\""
-	;;
-      esac
-      install_prog="$install_prog $arg"
-    done
-
-    if test -z "$install_prog"; then
-      $echo "$modename: you must specify an install program" 1>&2
-      $echo "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
-
-    if test -n "$prev"; then
-      $echo "$modename: the \`$prev' option requires an argument" 1>&2
-      $echo "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
-
-    if test -z "$files"; then
-      if test -z "$dest"; then
-	$echo "$modename: no file or destination specified" 1>&2
-      else
-	$echo "$modename: you must specify a destination" 1>&2
-      fi
-      $echo "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
-
-    # Strip any trailing slash from the destination.
-    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
-
-    # Check to see that the destination is a directory.
-    test -d "$dest" && isdir=yes
-    if test "$isdir" = yes; then
-      destdir="$dest"
-      destname=
-    else
-      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
-      test "X$destdir" = "X$dest" && destdir=.
-      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
-
-      # Not a directory, so check to see that there is only one file specified.
-      set dummy $files
-      if test "$#" -gt 2; then
-	$echo "$modename: \`$dest' is not a directory" 1>&2
-	$echo "$help" 1>&2
-	exit $EXIT_FAILURE
-      fi
-    fi
-    case $destdir in
-    [\\/]* | [A-Za-z]:[\\/]*) ;;
-    *)
-      for file in $files; do
-	case $file in
-	*.lo) ;;
-	*)
-	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
-	  $echo "$help" 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-      done
-      ;;
-    esac
-
-    # This variable tells wrapper scripts just to set variables rather
-    # than running their programs.
-    libtool_install_magic="$magic"
-
-    staticlibs=
-    future_libdirs=
-    current_libdirs=
-    for file in $files; do
-
-      # Do each installation.
-      case $file in
-      *.$libext)
-	# Do the static libraries later.
-	staticlibs="$staticlibs $file"
-	;;
-
-      *.la)
-	# Check to see that this really is a libtool archive.
-	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
-	else
-	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
-	  $echo "$help" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-
-	library_names=
-	old_library=
-	relink_command=
-	# If there is no directory component, then add one.
-	case $file in
-	*/* | *\\*) . $file ;;
-	*) . ./$file ;;
-	esac
-
-	# Add the libdir to current_libdirs if it is the destination.
-	if test "X$destdir" = "X$libdir"; then
-	  case "$current_libdirs " in
-	  *" $libdir "*) ;;
-	  *) current_libdirs="$current_libdirs $libdir" ;;
-	  esac
-	else
-	  # Note the libdir as a future libdir.
-	  case "$future_libdirs " in
-	  *" $libdir "*) ;;
-	  *) future_libdirs="$future_libdirs $libdir" ;;
-	  esac
-	fi
-
-	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
-	test "X$dir" = "X$file/" && dir=
-	dir="$dir$objdir"
-
-	if test -n "$relink_command"; then
-	  # Determine the prefix the user has applied to our future dir.
-	  inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
-
-	  # Don't allow the user to place us outside of our expected
-	  # location b/c this prevents finding dependent libraries that
-	  # are installed to the same prefix.
-	  # At present, this check doesn't affect windows .dll's that
-	  # are installed into $libdir/../bin (currently, that works fine)
-	  # but it's something to keep an eye on.
-	  if test "$inst_prefix_dir" = "$destdir"; then
-	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-
-	  if test -n "$inst_prefix_dir"; then
-	    # Stick the inst_prefix_dir data into the link command.
-	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
-	  else
-	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
-	  fi
-
-	  $echo "$modename: warning: relinking \`$file'" 1>&2
-	  $show "$relink_command"
-	  if $run eval "$relink_command"; then :
-	  else
-	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-	fi
-
-	# See the names of the shared library.
-	set dummy $library_names
-	if test -n "$2"; then
-	  realname="$2"
-	  shift
-	  shift
-
-	  srcname="$realname"
-	  test -n "$relink_command" && srcname="$realname"T
-
-	  # Install the shared library and build the symlinks.
-	  $show "$install_prog $dir/$srcname $destdir/$realname"
-	  $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
-	  if test -n "$stripme" && test -n "$striplib"; then
-	    $show "$striplib $destdir/$realname"
-	    $run eval "$striplib $destdir/$realname" || exit $?
-	  fi
-
-	  if test "$#" -gt 0; then
-	    # Delete the old symlinks, and create new ones.
-	    # Try `ln -sf' first, because the `ln' binary might depend on
-	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
-	    # so we also need to try rm && ln -s.
-	    for linkname
-	    do
-	      if test "$linkname" != "$realname"; then
-                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
-                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
-	      fi
-	    done
-	  fi
-
-	  # Do each command in the postinstall commands.
-	  lib="$destdir/$realname"
-	  cmds=$postinstall_cmds
-	  save_ifs="$IFS"; IFS='~'
-	  for cmd in $cmds; do
-	    IFS="$save_ifs"
-	    eval cmd=\"$cmd\"
-	    $show "$cmd"
-	    $run eval "$cmd" || {
-	      lt_exit=$?
-
-	      # Restore the uninstalled library and exit
-	      if test "$mode" = relink; then
-		$run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
-	      fi
-
-	      exit $lt_exit
-	    }
-	  done
-	  IFS="$save_ifs"
-	fi
-
-	# Install the pseudo-library for information purposes.
-	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-	instname="$dir/$name"i
-	$show "$install_prog $instname $destdir/$name"
-	$run eval "$install_prog $instname $destdir/$name" || exit $?
-
-	# Maybe install the static library, too.
-	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
-	;;
-
-      *.lo)
-	# Install (i.e. copy) a libtool object.
-
-	# Figure out destination file name, if it wasn't already specified.
-	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
-	else
-	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-	  destfile="$destdir/$destfile"
-	fi
-
-	# Deduce the name of the destination old-style object file.
-	case $destfile in
-	*.lo)
-	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
-	  ;;
-	*.$objext)
-	  staticdest="$destfile"
-	  destfile=
-	  ;;
-	*)
-	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
-	  $echo "$help" 1>&2
-	  exit $EXIT_FAILURE
-	  ;;
-	esac
-
-	# Install the libtool object if requested.
-	if test -n "$destfile"; then
-	  $show "$install_prog $file $destfile"
-	  $run eval "$install_prog $file $destfile" || exit $?
-	fi
-
-	# Install the old object if enabled.
-	if test "$build_old_libs" = yes; then
-	  # Deduce the name of the old-style object file.
-	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
-
-	  $show "$install_prog $staticobj $staticdest"
-	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
-	fi
-	exit $EXIT_SUCCESS
-	;;
-
-      *)
-	# Figure out destination file name, if it wasn't already specified.
-	if test -n "$destname"; then
-	  destfile="$destdir/$destname"
-	else
-	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-	  destfile="$destdir/$destfile"
-	fi
-
-	# If the file is missing, and there is a .exe on the end, strip it
-	# because it is most likely a libtool script we actually want to
-	# install
-	stripped_ext=""
-	case $file in
-	  *.exe)
-	    if test ! -f "$file"; then
-	      file=`$echo $file|${SED} 's,.exe$,,'`
-	      stripped_ext=".exe"
-	    fi
-	    ;;
-	esac
-
-	# Do a test to see if this is really a libtool program.
-	case $host in
-	*cygwin*|*mingw*)
-	    wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
-	    ;;
-	*)
-	    wrapper=$file
-	    ;;
-	esac
-	if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
-	  notinst_deplibs=
-	  relink_command=
-
-	  # Note that it is not necessary on cygwin/mingw to append a dot to
-	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
-	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-	  # `FILE.' does not work on cygwin managed mounts.
-	  #
-	  # If there is no directory component, then add one.
-	  case $wrapper in
-	  */* | *\\*) . ${wrapper} ;;
-	  *) . ./${wrapper} ;;
-	  esac
-
-	  # Check the variables that should have been set.
-	  if test -z "$notinst_deplibs"; then
-	    $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
-	    exit $EXIT_FAILURE
-	  fi
-
-	  finalize=yes
-	  for lib in $notinst_deplibs; do
-	    # Check to see that each library is installed.
-	    libdir=
-	    if test -f "$lib"; then
-	      # If there is no directory component, then add one.
-	      case $lib in
-	      */* | *\\*) . $lib ;;
-	      *) . ./$lib ;;
-	      esac
-	    fi
-	    libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
-	    if test -n "$libdir" && test ! -f "$libfile"; then
-	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
-	      finalize=no
-	    fi
-	  done
-
-	  relink_command=
-	  # Note that it is not necessary on cygwin/mingw to append a dot to
-	  # foo even if both foo and FILE.exe exist: automatic-append-.exe
-	  # behavior happens only for exec(3), not for open(2)!  Also, sourcing
-	  # `FILE.' does not work on cygwin managed mounts.
-	  #
-	  # If there is no directory component, then add one.
-	  case $wrapper in
-	  */* | *\\*) . ${wrapper} ;;
-	  *) . ./${wrapper} ;;
-	  esac
-
-	  outputname=
-	  if test "$fast_install" = no && test -n "$relink_command"; then
-	    if test "$finalize" = yes && test -z "$run"; then
-	      tmpdir=`func_mktempdir`
-	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
-	      outputname="$tmpdir/$file"
-	      # Replace the output file specification.
-	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
-
-	      $show "$relink_command"
-	      if $run eval "$relink_command"; then :
-	      else
-		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
-		${rm}r "$tmpdir"
-		continue
-	      fi
-	      file="$outputname"
-	    else
-	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
-	    fi
-	  else
-	    # Install the binary that we compiled earlier.
-	    file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
-	  fi
-	fi
-
-	# remove .exe since cygwin /usr/bin/install will append another
-	# one anyway 
-	case $install_prog,$host in
-	*/usr/bin/install*,*cygwin*)
-	  case $file:$destfile in
-	  *.exe:*.exe)
-	    # this is ok
-	    ;;
-	  *.exe:*)
-	    destfile=$destfile.exe
-	    ;;
-	  *:*.exe)
-	    destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
-	    ;;
-	  esac
-	  ;;
-	esac
-	$show "$install_prog$stripme $file $destfile"
-	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
-	test -n "$outputname" && ${rm}r "$tmpdir"
-	;;
-      esac
-    done
-
-    for file in $staticlibs; do
-      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-
-      # Set up the ranlib parameters.
-      oldlib="$destdir/$name"
-
-      $show "$install_prog $file $oldlib"
-      $run eval "$install_prog \$file \$oldlib" || exit $?
-
-      if test -n "$stripme" && test -n "$old_striplib"; then
-	$show "$old_striplib $oldlib"
-	$run eval "$old_striplib $oldlib" || exit $?
-      fi
-
-      # Do each command in the postinstall commands.
-      cmds=$old_postinstall_cmds
-      save_ifs="$IFS"; IFS='~'
-      for cmd in $cmds; do
-	IFS="$save_ifs"
-	eval cmd=\"$cmd\"
-	$show "$cmd"
-	$run eval "$cmd" || exit $?
-      done
-      IFS="$save_ifs"
-    done
-
-    if test -n "$future_libdirs"; then
-      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
-    fi
-
-    if test -n "$current_libdirs"; then
-      # Maybe just do a dry run.
-      test -n "$run" && current_libdirs=" -n$current_libdirs"
-      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
-    else
-      exit $EXIT_SUCCESS
-    fi
-    ;;
-
-  # libtool finish mode
-  finish)
-    modename="$modename: finish"
-    libdirs="$nonopt"
-    admincmds=
-
-    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
-      for dir
-      do
-	libdirs="$libdirs $dir"
-      done
-
-      for libdir in $libdirs; do
-	if test -n "$finish_cmds"; then
-	  # Do each command in the finish commands.
-	  cmds=$finish_cmds
-	  save_ifs="$IFS"; IFS='~'
-	  for cmd in $cmds; do
-	    IFS="$save_ifs"
-	    eval cmd=\"$cmd\"
-	    $show "$cmd"
-	    $run eval "$cmd" || admincmds="$admincmds
-       $cmd"
-	  done
-	  IFS="$save_ifs"
-	fi
-	if test -n "$finish_eval"; then
-	  # Do the single finish_eval.
-	  eval cmds=\"$finish_eval\"
-	  $run eval "$cmds" || admincmds="$admincmds
-       $cmds"
-	fi
-      done
-    fi
-
-    # Exit here if they wanted silent mode.
-    test "$show" = : && exit $EXIT_SUCCESS
-
-    $echo "X----------------------------------------------------------------------" | $Xsed
-    $echo "Libraries have been installed in:"
-    for libdir in $libdirs; do
-      $echo "   $libdir"
-    done
-    $echo
-    $echo "If you ever happen to want to link against installed libraries"
-    $echo "in a given directory, LIBDIR, you must either use libtool, and"
-    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
-    $echo "flag during linking and do at least one of the following:"
-    if test -n "$shlibpath_var"; then
-      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
-      $echo "     during execution"
-    fi
-    if test -n "$runpath_var"; then
-      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
-      $echo "     during linking"
-    fi
-    if test -n "$hardcode_libdir_flag_spec"; then
-      libdir=LIBDIR
-      eval flag=\"$hardcode_libdir_flag_spec\"
-
-      $echo "   - use the \`$flag' linker flag"
-    fi
-    if test -n "$admincmds"; then
-      $echo "   - have your system administrator run these commands:$admincmds"
-    fi
-    if test -f /etc/ld.so.conf; then
-      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
-    fi
-    $echo
-    $echo "See any operating system documentation about shared libraries for"
-    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
-    $echo "X----------------------------------------------------------------------" | $Xsed
-    exit $EXIT_SUCCESS
-    ;;
-
-  # libtool execute mode
-  execute)
-    modename="$modename: execute"
-
-    # The first argument is the command name.
-    cmd="$nonopt"
-    if test -z "$cmd"; then
-      $echo "$modename: you must specify a COMMAND" 1>&2
-      $echo "$help"
-      exit $EXIT_FAILURE
-    fi
-
-    # Handle -dlopen flags immediately.
-    for file in $execute_dlfiles; do
-      if test ! -f "$file"; then
-	$echo "$modename: \`$file' is not a file" 1>&2
-	$echo "$help" 1>&2
-	exit $EXIT_FAILURE
-      fi
-
-      dir=
-      case $file in
-      *.la)
-	# Check to see that this really is a libtool archive.
-	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
-	else
-	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
-	  $echo "$help" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-
-	# Read the libtool library.
-	dlname=
-	library_names=
-
-	# If there is no directory component, then add one.
-	case $file in
-	*/* | *\\*) . $file ;;
-	*) . ./$file ;;
-	esac
-
-	# Skip this library if it cannot be dlopened.
-	if test -z "$dlname"; then
-	  # Warn if it was a shared library.
-	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
-	  continue
-	fi
-
-	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
-	test "X$dir" = "X$file" && dir=.
-
-	if test -f "$dir/$objdir/$dlname"; then
-	  dir="$dir/$objdir"
-	else
-	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
-	  exit $EXIT_FAILURE
-	fi
-	;;
-
-      *.lo)
-	# Just add the directory containing the .lo file.
-	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
-	test "X$dir" = "X$file" && dir=.
-	;;
-
-      *)
-	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
-	continue
-	;;
-      esac
-
-      # Get the absolute pathname.
-      absdir=`cd "$dir" && pwd`
-      test -n "$absdir" && dir="$absdir"
-
-      # Now add the directory to shlibpath_var.
-      if eval "test -z \"\$$shlibpath_var\""; then
-	eval "$shlibpath_var=\"\$dir\""
-      else
-	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
-      fi
-    done
-
-    # This variable tells wrapper scripts just to set shlibpath_var
-    # rather than running their programs.
-    libtool_execute_magic="$magic"
-
-    # Check if any of the arguments is a wrapper script.
-    args=
-    for file
-    do
-      case $file in
-      -*) ;;
-      *)
-	# Do a test to see if this is really a libtool program.
-	if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-	  # If there is no directory component, then add one.
-	  case $file in
-	  */* | *\\*) . $file ;;
-	  *) . ./$file ;;
-	  esac
-
-	  # Transform arg to wrapped name.
-	  file="$progdir/$program"
-	fi
-	;;
-      esac
-      # Quote arguments (to preserve shell metacharacters).
-      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
-      args="$args \"$file\""
-    done
-
-    if test -z "$run"; then
-      if test -n "$shlibpath_var"; then
-	# Export the shlibpath_var.
-	eval "export $shlibpath_var"
-      fi
-
-      # Restore saved environment variables
-      if test "${save_LC_ALL+set}" = set; then
-	LC_ALL="$save_LC_ALL"; export LC_ALL
-      fi
-      if test "${save_LANG+set}" = set; then
-	LANG="$save_LANG"; export LANG
-      fi
-
-      # Now prepare to actually exec the command.
-      exec_cmd="\$cmd$args"
-    else
-      # Display what would be done.
-      if test -n "$shlibpath_var"; then
-	eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
-	$echo "export $shlibpath_var"
-      fi
-      $echo "$cmd$args"
-      exit $EXIT_SUCCESS
-    fi
-    ;;
-
-  # libtool clean and uninstall mode
-  clean | uninstall)
-    modename="$modename: $mode"
-    rm="$nonopt"
-    files=
-    rmforce=
-    exit_status=0
-
-    # This variable tells wrapper scripts just to set variables rather
-    # than running their programs.
-    libtool_install_magic="$magic"
-
-    for arg
-    do
-      case $arg in
-      -f) rm="$rm $arg"; rmforce=yes ;;
-      -*) rm="$rm $arg" ;;
-      *) files="$files $arg" ;;
-      esac
-    done
-
-    if test -z "$rm"; then
-      $echo "$modename: you must specify an RM program" 1>&2
-      $echo "$help" 1>&2
-      exit $EXIT_FAILURE
-    fi
-
-    rmdirs=
-
-    origobjdir="$objdir"
-    for file in $files; do
-      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
-      if test "X$dir" = "X$file"; then
-	dir=.
-	objdir="$origobjdir"
-      else
-	objdir="$dir/$origobjdir"
-      fi
-      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-      test "$mode" = uninstall && objdir="$dir"
-
-      # Remember objdir for removal later, being careful to avoid duplicates
-      if test "$mode" = clean; then
-	case " $rmdirs " in
-	  *" $objdir "*) ;;
-	  *) rmdirs="$rmdirs $objdir" ;;
-	esac
-      fi
-
-      # Don't error if the file doesn't exist and rm -f was used.
-      if (test -L "$file") >/dev/null 2>&1 \
-	|| (test -h "$file") >/dev/null 2>&1 \
-	|| test -f "$file"; then
-	:
-      elif test -d "$file"; then
-	exit_status=1
-	continue
-      elif test "$rmforce" = yes; then
-	continue
-      fi
-
-      rmfiles="$file"
-
-      case $name in
-      *.la)
-	# Possibly a libtool archive, so verify it.
-	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-	  . $dir/$name
-
-	  # Delete the libtool libraries and symlinks.
-	  for n in $library_names; do
-	    rmfiles="$rmfiles $objdir/$n"
-	  done
-	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
-
-	  case "$mode" in
-	  clean)
-	    case "  $library_names " in
-	    # "  " in the beginning catches empty $dlname
-	    *" $dlname "*) ;;
-	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
-	    esac
-	     test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
-	    ;;
-	  uninstall)
-	    if test -n "$library_names"; then
-	      # Do each command in the postuninstall commands.
-	      cmds=$postuninstall_cmds
-	      save_ifs="$IFS"; IFS='~'
-	      for cmd in $cmds; do
-		IFS="$save_ifs"
-		eval cmd=\"$cmd\"
-		$show "$cmd"
-		$run eval "$cmd"
-		if test "$?" -ne 0 && test "$rmforce" != yes; then
-		  exit_status=1
-		fi
-	      done
-	      IFS="$save_ifs"
-	    fi
-
-	    if test -n "$old_library"; then
-	      # Do each command in the old_postuninstall commands.
-	      cmds=$old_postuninstall_cmds
-	      save_ifs="$IFS"; IFS='~'
-	      for cmd in $cmds; do
-		IFS="$save_ifs"
-		eval cmd=\"$cmd\"
-		$show "$cmd"
-		$run eval "$cmd"
-		if test "$?" -ne 0 && test "$rmforce" != yes; then
-		  exit_status=1
-		fi
-	      done
-	      IFS="$save_ifs"
-	    fi
-	    # FIXME: should reinstall the best remaining shared library.
-	    ;;
-	  esac
-	fi
-	;;
-
-      *.lo)
-	# Possibly a libtool object, so verify it.
-	if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-
-	  # Read the .lo file
-	  . $dir/$name
-
-	  # Add PIC object to the list of files to remove.
-	  if test -n "$pic_object" \
-	     && test "$pic_object" != none; then
-	    rmfiles="$rmfiles $dir/$pic_object"
-	  fi
-
-	  # Add non-PIC object to the list of files to remove.
-	  if test -n "$non_pic_object" \
-	     && test "$non_pic_object" != none; then
-	    rmfiles="$rmfiles $dir/$non_pic_object"
-	  fi
-	fi
-	;;
-
-      *)
-	if test "$mode" = clean ; then
-	  noexename=$name
-	  case $file in
-	  *.exe)
-	    file=`$echo $file|${SED} 's,.exe$,,'`
-	    noexename=`$echo $name|${SED} 's,.exe$,,'`
-	    # $file with .exe has already been added to rmfiles,
-	    # add $file without .exe
-	    rmfiles="$rmfiles $file"
-	    ;;
-	  esac
-	  # Do a test to see if this is a libtool program.
-	  if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-	    relink_command=
-	    . $dir/$noexename
-
-	    # note $name still contains .exe if it was in $file originally
-	    # as does the version of $file that was added into $rmfiles
-	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
-	    if test "$fast_install" = yes && test -n "$relink_command"; then
-	      rmfiles="$rmfiles $objdir/lt-$name"
-	    fi
-	    if test "X$noexename" != "X$name" ; then
-	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
-	    fi
-	  fi
-	fi
-	;;
-      esac
-      $show "$rm $rmfiles"
-      $run $rm $rmfiles || exit_status=1
-    done
-    objdir="$origobjdir"
-
-    # Try to remove the ${objdir}s in the directories where we deleted files
-    for dir in $rmdirs; do
-      if test -d "$dir"; then
-	$show "rmdir $dir"
-	$run rmdir $dir >/dev/null 2>&1
-      fi
-    done
-
-    exit $exit_status
-    ;;
-
-  "")
-    $echo "$modename: you must specify a MODE" 1>&2
-    $echo "$generic_help" 1>&2
-    exit $EXIT_FAILURE
-    ;;
-  esac
-
-  if test -z "$exec_cmd"; then
-    $echo "$modename: invalid operation mode \`$mode'" 1>&2
-    $echo "$generic_help" 1>&2
-    exit $EXIT_FAILURE
-  fi
-fi # test -z "$show_help"
-
-if test -n "$exec_cmd"; then
-  eval exec $exec_cmd
-  exit $EXIT_FAILURE
-fi
-
-# We need to display help for each of the modes.
-case $mode in
-"") $echo \
-"Usage: $modename [OPTION]... [MODE-ARG]...
-
-Provide generalized library-building support services.
-
-    --config          show all configuration variables
-    --debug           enable verbose shell tracing
--n, --dry-run         display commands without modifying any files
-    --features        display basic configuration information and exit
-    --finish          same as \`--mode=finish'
-    --help            display this help message and exit
-    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
-    --quiet           same as \`--silent'
-    --silent          don't print informational messages
-    --tag=TAG         use configuration variables from tag TAG
-    --version         print version information
-
-MODE must be one of the following:
-
-      clean           remove files from the build directory
-      compile         compile a source file into a libtool object
-      execute         automatically set library path, then run a program
-      finish          complete the installation of libtool libraries
-      install         install libraries or executables
-      link            create a library or an executable
-      uninstall       remove libraries from an installed directory
-
-MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
-a more detailed description of MODE.
-
-Report bugs to <bug-libtool at gnu.org>."
-  exit $EXIT_SUCCESS
-  ;;
-
-clean)
-  $echo \
-"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
-
-Remove files from the build directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, object or program, all the files associated
-with it are deleted. Otherwise, only FILE itself is deleted using RM."
-  ;;
-
-compile)
-  $echo \
-"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
-
-Compile a source file into a libtool library object.
-
-This mode accepts the following additional options:
-
-  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
-  -prefer-pic       try to building PIC objects only
-  -prefer-non-pic   try to building non-PIC objects only
-  -static           always build a \`.o' file suitable for static linking
-
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
-from the given SOURCEFILE.
-
-The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
-  ;;
-
-execute)
-  $echo \
-"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
-
-Automatically set library path, then run a program.
-
-This mode accepts the following additional options:
-
-  -dlopen FILE      add the directory containing FILE to the library path
-
-This mode sets the library path environment variable according to \`-dlopen'
-flags.
-
-If any of the ARGS are libtool executable wrappers, then they are translated
-into their corresponding uninstalled binary, and any of their required library
-directories are added to the library path.
-
-Then, COMMAND is executed, with ARGS as arguments."
-  ;;
-
-finish)
-  $echo \
-"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
-
-Complete the installation of libtool libraries.
-
-Each LIBDIR is a directory that contains libtool libraries.
-
-The commands that this mode executes may require superuser privileges.  Use
-the \`--dry-run' option if you just want to see what would be executed."
-  ;;
-
-install)
-  $echo \
-"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
-
-Install executables or libraries.
-
-INSTALL-COMMAND is the installation command.  The first component should be
-either the \`install' or \`cp' program.
-
-The rest of the components are interpreted as arguments to that command (only
-BSD-compatible install options are recognized)."
-  ;;
-
-link)
-  $echo \
-"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
-
-Link object files or libraries together to form another library, or to
-create an executable program.
-
-LINK-COMMAND is a command using the C compiler that you would use to create
-a program from several object files.
-
-The following components of LINK-COMMAND are treated specially:
-
-  -all-static       do not do any dynamic linking at all
-  -avoid-version    do not add a version suffix if possible
-  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
-  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
-  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
-  -export-symbols SYMFILE
-		    try to export only the symbols listed in SYMFILE
-  -export-symbols-regex REGEX
-		    try to export only the symbols matching REGEX
-  -LLIBDIR          search LIBDIR for required installed libraries
-  -lNAME            OUTPUT-FILE requires the installed library libNAME
-  -module           build a library that can dlopened
-  -no-fast-install  disable the fast-install mode
-  -no-install       link a not-installable executable
-  -no-undefined     declare that a library does not refer to external symbols
-  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
-  -objectlist FILE  Use a list of object files found in FILE to specify objects
-  -precious-files-regex REGEX
-                    don't remove output files matching REGEX
-  -release RELEASE  specify package release information
-  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
-  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
-  -static           do not do any dynamic linking of libtool libraries
-  -version-info CURRENT[:REVISION[:AGE]]
-		    specify library version info [each variable defaults to 0]
-
-All other options (arguments beginning with \`-') are ignored.
-
-Every other argument is treated as a filename.  Files ending in \`.la' are
-treated as uninstalled libtool libraries, other files are standard or library
-object files.
-
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
-required, except when creating a convenience library.
-
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
-
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
-is created, otherwise an executable program is created."
-  ;;
-
-uninstall)
-  $echo \
-"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
-
-Remove libraries from an installation directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, all the files associated with it are deleted.
-Otherwise, only FILE itself is deleted using RM."
-  ;;
-
-*)
-  $echo "$modename: invalid operation mode \`$mode'" 1>&2
-  $echo "$help" 1>&2
-  exit $EXIT_FAILURE
-  ;;
-esac
-
-$echo
-$echo "Try \`$modename --help' for more information about other modes."
-
-exit $?
-
-# The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries.  Given conflicting
-# choices, we go for a static library, that is the most portable,
-# since we can't tell whether shared libraries were disabled because
-# the user asked for that or because the platform doesn't support
-# them.  This is particularly important on AIX, because we don't
-# support having both static and shared libraries enabled at the same
-# time on that platform, so we default to a shared-only configuration.
-# If a disable-shared tag is given, we'll fallback to a static-only
-# configuration.  But we'll never go from static-only to shared-only.
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-disable_libs=shared
-# ### END LIBTOOL TAG CONFIG: disable-shared
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-static
-disable_libs=static
-# ### END LIBTOOL TAG CONFIG: disable-static
-
-# Local Variables:
-# mode:shell-script
-# sh-indentation:2
-# End:
diff --git a/config/mkinstalldirs b/config/mkinstalldirs
deleted file mode 100755
index a55cff6..0000000
--- a/config/mkinstalldirs
+++ /dev/null
@@ -1,137 +0,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Original author: Noah Friedman <friedman at prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain.
-
-scriptversion=2003-09-26.19
-
-errstatus=0
-dirmode=""
-
-usage="\
-Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
-
-Create each directory DIR (with mode MODE, if specified), including all
-leading file name components.
-"
-
-# process command line arguments
-while test $# -gt 0 ; do
-  case $1 in
-    -h | --help | --h*)         # -h for help
-      echo "$usage"
-      exit 0
-      ;;
-    -m)                         # -m PERM arg
-      shift
-      test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
-      dirmode=$1
-      shift
-      ;;
-    --version)
-      echo "$0 $scriptversion"
-      exit 0
-      ;;
-    --)                         # stop option processing
-      shift
-      break
-      ;;
-    -*)                         # unknown option
-      echo "$usage" 1>&2
-      exit 1
-      ;;
-    *)                          # first non-opt arg
-      break
-      ;;
-  esac
-done
-
-for file
-do
-  if test -d "$file"; then
-    shift
-  else
-    break
-  fi
-done
-
-case $# in
-  0) exit 0 ;;
-esac
-
-case $dirmode in
-  '')
-    if mkdir -p -- . 2>/dev/null; then
-      echo "mkdir -p -- $*"
-      exec mkdir -p -- "$@"
-    else
-      # On NextStep and OpenStep, the `mkdir' command does not
-      # recognize any option.  It will interpret all options as
-      # directories to create, and then abort because `.' already
-      # exists.
-      test -d ./-p && rmdir ./-p
-      test -d ./-- && rmdir ./--
-    fi
-    ;;
-  *)
-    if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
-      echo "mkdir -m $dirmode -p -- $*"
-      exec mkdir -m "$dirmode" -p -- "$@"
-    else
-      # Clean up after NextStep and OpenStep mkdir.
-      for d in ./-m ./-p ./-- "./$dirmode";
-      do
-        test -d $d && rmdir $d
-      done
-    fi
-    ;;
-esac
-
-for file
-do
-  set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-  shift
-
-  pathcomp=
-  for d
-  do
-    pathcomp="$pathcomp$d"
-    case $pathcomp in
-      -*) pathcomp=./$pathcomp ;;
-    esac
-
-    if test ! -d "$pathcomp"; then
-      echo "mkdir $pathcomp"
-
-      mkdir "$pathcomp" || lasterr=$?
-
-      if test ! -d "$pathcomp"; then
-	errstatus=$lasterr
-      else
-	if test ! -z "$dirmode"; then
-	  echo "chmod $dirmode $pathcomp"
-	  lasterr=""
-	  chmod "$dirmode" "$pathcomp" || lasterr=$?
-
-	  if test ! -z "$lasterr"; then
-	    errstatus=$lasterr
-	  fi
-	fi
-      fi
-    fi
-
-    pathcomp="$pathcomp/"
-  done
-done
-
-exit $errstatus
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/config/mod_c.m4 b/config/mod_c.m4
deleted file mode 100644
index 8f95212..0000000
--- a/config/mod_c.m4
+++ /dev/null
@@ -1,62 +0,0 @@
-# This file is part of Autoconf.                       -*- Autoconf -*-
-# Programming languages support.
-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-#
-# As a special exception, the Free Software Foundation gives unlimited
-# permission to copy, distribute and modify the configure scripts that
-# are the output of Autoconf.  You need not follow the terms of the GNU
-# General Public License when using or distributing such scripts, even
-# though portions of the text of Autoconf appear in them.  The GNU
-# General Public License (GPL) does govern all other use of the material
-# that constitutes the Autoconf program.
-#
-# Certain portions of the Autoconf source text are designed to be copied
-# (in certain cases, depending on the input) into the output of
-# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
-# source text consists of comments plus executable code that decides which
-# of the data portions to output in any given case.  We call these
-# comments and executable code the "non-data" portions.  Autoconf never
-# copies any of the non-data portions into its output.
-#
-# This special exception to the GPL applies to versions of Autoconf
-# released by the Free Software Foundation.  When you make and
-# distribute a modified version of Autoconf, you may extend this special
-# exception to the GPL to apply to your modified version as well, *unless*
-# your modified version has the potential to copy into its output some
-# of the text that was the non-data portion of the version that you started
-# with.  (In other words, unless your change moves or copies text from
-# the non-data portions to the data portions.)  If your modification has
-# such potential, you must delete any notice of this special exception
-# to the GPL from your modified version.
-#
-# Written by David MacKenzie, with help from
-# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
-# Roland McGrath, Noah Friedman, david d zuhn, and many others.
-
-
-# AC_LANG(C)
-# ----------
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-m4_define([AC_LANG(C)],
-[ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-])
diff --git a/config/mod_fortran.m4 b/config/mod_fortran.m4
deleted file mode 100644
index 1f02709..0000000
--- a/config/mod_fortran.m4
+++ /dev/null
@@ -1,117 +0,0 @@
-# This file is part of Autoconf.                       -*- Autoconf -*-
-# Fortran languages support.
-# Copyright (C) 2001, 2003
-# Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-#
-# As a special exception, the Free Software Foundation gives unlimited
-# permission to copy, distribute and modify the configure scripts that
-# are the output of Autoconf.  You need not follow the terms of the GNU
-# General Public License when using or distributing such scripts, even
-# though portions of the text of Autoconf appear in them.  The GNU
-# General Public License (GPL) does govern all other use of the material
-# that constitutes the Autoconf program.
-#
-# Certain portions of the Autoconf source text are designed to be copied
-# (in certain cases, depending on the input) into the output of
-# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
-# source text consists of comments plus executable code that decides which
-# of the data portions to output in any given case.  We call these
-# comments and executable code the "non-data" portions.  Autoconf never
-# copies any of the non-data portions into its output.
-#
-# This special exception to the GPL applies to versions of Autoconf
-# released by the Free Software Foundation.  When you make and
-# distribute a modified version of Autoconf, you may extend this special
-# exception to the GPL to apply to your modified version as well, *unless*
-# your modified version has the potential to copy into its output some
-# of the text that was the non-data portion of the version that you started
-# with.  (In other words, unless your change moves or copies text from
-# the non-data portions to the data portions.)  If your modification has
-# such potential, you must delete any notice of this special exception
-# to the GPL from your modified version.
-#
-# Written by David MacKenzie, with help from
-# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
-# Roland McGrath, Noah Friedman, david d zuhn, and many others.
-
-# Fortran vs. Fortran 77:
-#   This file contains macros for both "Fortran 77" and "Fortran", where
-# the former is the "classic" autoconf Fortran interface and is intended
-# for legacy F77 codes, while the latter is intended to support newer Fortran
-# dialects.  Fortran 77 uses environment variables F77, FFLAGS, and FLIBS,
-# while Fortran uses FC, FCFLAGS, and FCLIBS.  For each user-callable AC_*
-# macro, there is generally both an F77 and an FC version, where both versions
-# share the same _AC_*_FC_* backend.  This backend macro requires that
-# the appropriate language be AC_LANG_PUSH'ed, and uses _AC_LANG_ABBREV and
-# _AC_LANG_PREFIX in order to name cache and environment variables, etc.
-
-
-# _AC_PROG_FC_V_OUTPUT([FLAG = $ac_cv_prog_{f77/fc}_v])
-# -------------------------------------------------
-# Link a trivial Fortran program, compiling with a verbose output FLAG
-# (whose default value, $ac_cv_prog_{f77/fc}_v, is computed by
-# _AC_PROG_FC_V), and return the output in $ac_{f77/fc}_v_output.  This
-# output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS,
-# so that any link flags that are echoed by the compiler appear as
-# space-separated items.
-AC_DEFUN([_AC_PROG_FC_V_OUTPUT],
-[_AC_FORTRAN_ASSERT()dnl
-AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
-
-# Compile and link our simple test program by passing a flag (argument
-# 1 to this macro) to the Fortran compiler in order to get
-# "verbose" output that we can then parse for the Fortran linker
-# flags.
-ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
-_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS m4_default([$1], [$ac_cv_prog_[]_AC_LANG_ABBREV[]_v])"
-(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD
-ac_[]_AC_LANG_ABBREV[]_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
-echo "$ac_[]_AC_LANG_ABBREV[]_v_output" >&AS_MESSAGE_LOG_FD
-_AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
-
-rm -f conftest*
-
-# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
-# /foo, /bar, and /baz are search directories for the Fortran linker.
-# Here, we change these into -L/foo -L/bar -L/baz (and put it first):
-ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
-	grep 'LPATH is:' |
-	sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_[]_AC_LANG_ABBREV[]_v_output"
-
-case $ac_[]_AC_LANG_ABBREV[]_v_output in
-  # If we are using xlf then replace all the commas with spaces.
-  *xlfentry*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/,/ /g'` ;;
-
-  # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
-  # $LIBS confuse us, and the libraries appear later in the output anyway).
-  *mGLOB_options_string*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/"-mGLOB[[^"]]*"/ /g'` ;;
-
-  # Portland Group compiler has quoted -cmdline argument
-  *-cmdline*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "s/-cmdline '[[^']]*'/ /g"`  ;;
-
-  # If we are using Cray Fortran then delete quotes.
-  # Use "\"" instead of '"' for font-lock-mode.
-  # FIXME: a more general fix for quoted arguments with spaces?
-  *cft90*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "s/\"//g"` ;;
-esac
-
-])# _AC_PROG_FC_V_OUTPUT
diff --git a/config/rminstalldirs b/config/rminstalldirs
deleted file mode 100755
index 7a3871c..0000000
--- a/config/rminstalldirs
+++ /dev/null
@@ -1,20 +0,0 @@
-#! /bin/sh
-# rminstalldirs -- remove directory if empty with checks 
-# Author: Radu Serban
-
-for arg in ${1+"$@"} ; do
-
-  path=`echo "$arg" | sed -e 's,/$,,' | tr -s '/'`
-
-  case "$path" in
-      -* ) path="./$path" ;;
-  esac
-
-  if test -d "$path" ; then
-    if test x"`ls -A "$path"`" = x ; then
-      echo "rmdir $path"
-      rmdir "$path" > /dev/null 2>&1 || errstatus=$?
-    fi
-  fi
-
-done
\ No newline at end of file
diff --git a/configure b/configure
deleted file mode 100755
index 1a4e6e3..0000000
--- a/configure
+++ /dev/null
@@ -1,28297 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for SUNDIALS 2.5.0.
-#
-# Report bugs to <radu at llnl.gov>.
-#
-# Copyright (C) 2003 Free Software Foundation, Inc.
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-#
-#
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-#
-## --------------------- ##
-## M4sh Initialization.  ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
-  set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  as_unset=unset
-else
-  as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
-  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-  LC_TELEPHONE LC_TIME
-do
-  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
-    eval $as_var=C; export $as_var
-  else
-    $as_unset $as_var
-  fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)$' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
-  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\/\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-    PATH_SEPARATOR=';'
-  else
-    PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
-fi
-
-
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
-  # Find who we are.  Look in the path if we contain no path at all
-  # relative or not.
-  case $0 in
-    *[\\/]* ) as_myself=$0 ;;
-    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
-       ;;
-  esac
-  # We did not find ourselves, most probably we were run as `sh COMMAND'
-  # in which case we are not to be found in the path.
-  if test "x$as_myself" = x; then
-    as_myself=$0
-  fi
-  if test ! -f "$as_myself"; then
-    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
-   { (exit 1); exit 1; }; }
-  fi
-  case $CONFIG_SHELL in
-  '')
-    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for as_base in sh bash ksh sh5; do
-	 case $as_dir in
-	 /*)
-	   if ("$as_dir/$as_base" -c '
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
-	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
-	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
-	     CONFIG_SHELL=$as_dir/$as_base
-	     export CONFIG_SHELL
-	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
-	   fi;;
-	 esac
-       done
-done
-;;
-  esac
-
-  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
-  # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line before each line; the second 'sed' does the real
-  # work.  The second script uses 'N' to pair each line-number line
-  # with the numbered line, and appends trailing '-' during
-  # substitution so that $LINENO is not a special case at line end.
-  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
-  sed '=' <$as_myself |
-    sed '
-      N
-      s,$,-,
-      : loop
-      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
-      t loop
-      s,-$,,
-      s,^['$as_cr_digits']*\n,,
-    ' >$as_me.lineno &&
-  chmod +x $as_me.lineno ||
-    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
-   { (exit 1); exit 1; }; }
-
-  # Don't try to exec as it changes $[0], causing all sort of problems
-  # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensible to this).
-  . ./$as_me.lineno
-  # Exit status is that of the last command.
-  exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
-  # We could just check for DJGPP; but this test a) works b) is more generic
-  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
-  if test -f conf$$.exe; then
-    # Don't use ln at all; we don't have any links
-    as_ln_s='cp -p'
-  else
-    as_ln_s='ln -s'
-  fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
-else
-  as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p=:
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" 	$as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-
-
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
-  # Remove one level of quotation (which was required for Make).
-  ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
-  ;;
-esac
-
-echo=${ECHO-echo}
-if test "X$1" = X--no-reexec; then
-  # Discard the --no-reexec flag, and continue.
-  shift
-elif test "X$1" = X--fallback-echo; then
-  # Avoid inline document here, it may be left over
-  :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
-  # Yippee, $echo works!
-  :
-else
-  # Restart under the correct shell.
-  exec $SHELL "$0" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
-  # used as fallback echo
-  shift
-  cat <<EOF
-$*
-EOF
-  exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
-  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
-    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
-    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
-       echo_test_string=`eval $cmd` &&
-       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
-    then
-      break
-    fi
-  done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
-   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
-   test "X$echo_testing_string" = "X$echo_test_string"; then
-  :
-else
-  # The Solaris, AIX, and Digital Unix default echo programs unquote
-  # backslashes.  This makes it impossible to quote backslashes using
-  #   echo "$something" | sed 's/\\/\\\\/g'
-  #
-  # So, first we look for a working echo in the user's PATH.
-
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for dir in $PATH /usr/ucb; do
-    IFS="$lt_save_ifs"
-    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
-       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
-       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
-       test "X$echo_testing_string" = "X$echo_test_string"; then
-      echo="$dir/echo"
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-
-  if test "X$echo" = Xecho; then
-    # We didn't find a better echo, so look for alternatives.
-    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
-       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
-       test "X$echo_testing_string" = "X$echo_test_string"; then
-      # This shell has a builtin print -r that does the trick.
-      echo='print -r'
-    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
-	 test "X$CONFIG_SHELL" != X/bin/ksh; then
-      # If we have ksh, try running configure again with it.
-      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
-      export ORIGINAL_CONFIG_SHELL
-      CONFIG_SHELL=/bin/ksh
-      export CONFIG_SHELL
-      exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
-    else
-      # Try using printf.
-      echo='printf %s\n'
-      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
-	 echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
-	 test "X$echo_testing_string" = "X$echo_test_string"; then
-	# Cool, printf works
-	:
-      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
-	   test "X$echo_testing_string" = 'X\t' &&
-	   echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
-	   test "X$echo_testing_string" = "X$echo_test_string"; then
-	CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
-	export CONFIG_SHELL
-	SHELL="$CONFIG_SHELL"
-	export SHELL
-	echo="$CONFIG_SHELL $0 --fallback-echo"
-      elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
-	   test "X$echo_testing_string" = 'X\t' &&
-	   echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
-	   test "X$echo_testing_string" = "X$echo_test_string"; then
-	echo="$CONFIG_SHELL $0 --fallback-echo"
-      else
-	# maybe with a smaller string...
-	prev=:
-
-	for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
-	  if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
-	  then
-	    break
-	  fi
-	  prev="$cmd"
-	done
-
-	if test "$prev" != 'sed 50q "$0"'; then
-	  echo_test_string=`eval $prev`
-	  export echo_test_string
-	  exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
-	else
-	  # Oops.  We lost completely, so just stick with echo.
-	  echo=echo
-	fi
-      fi
-    fi
-  fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
-   ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
-fi
-
-
-
-
-tagnames=${tagnames+${tagnames},}CXX
-
-tagnames=${tagnames+${tagnames},}F77
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-exec 6>&1
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_config_libobj_dir=.
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete.  It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
-# Identity of this package.
-PACKAGE_NAME='SUNDIALS'
-PACKAGE_TARNAME='sundials'
-PACKAGE_VERSION='2.5.0'
-PACKAGE_STRING='SUNDIALS 2.5.0'
-PACKAGE_BUGREPORT='radu at llnl.gov'
-
-ac_unique_file="/src/sundials/sundials_nvector.c"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-#  include <stdint.h>
-# endif
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFL [...]
-ac_subst_files=''
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-ac_prev=
-for ac_option
-do
-  # If the previous option needs an argument, assign it.
-  if test -n "$ac_prev"; then
-    eval "$ac_prev=\$ac_option"
-    ac_prev=
-    continue
-  fi
-
-  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
-
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
-  case $ac_option in
-
-  -bindir | --bindir | --bindi | --bind | --bin | --bi)
-    ac_prev=bindir ;;
-  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir=$ac_optarg ;;
-
-  -build | --build | --buil | --bui | --bu)
-    ac_prev=build_alias ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build_alias=$ac_optarg ;;
-
-  -cache-file | --cache-file | --cache-fil | --cache-fi \
-  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-    ac_prev=cache_file ;;
-  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file=$ac_optarg ;;
-
-  --config-cache | -C)
-    cache_file=config.cache ;;
-
-  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
-    ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
-  | --da=*)
-    datadir=$ac_optarg ;;
-
-  -disable-* | --disable-*)
-    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
-   { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
-    eval "enable_$ac_feature=no" ;;
-
-  -enable-* | --enable-*)
-    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
-   { (exit 1); exit 1; }; }
-    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
-    case $ac_option in
-      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
-      *) ac_optarg=yes ;;
-    esac
-    eval "enable_$ac_feature='$ac_optarg'" ;;
-
-  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
-  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
-  | --exec | --exe | --ex)
-    ac_prev=exec_prefix ;;
-  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
-  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
-  | --exec=* | --exe=* | --ex=*)
-    exec_prefix=$ac_optarg ;;
-
-  -gas | --gas | --ga | --g)
-    # Obsolete; use --with-gas.
-    with_gas=yes ;;
-
-  -help | --help | --hel | --he | -h)
-    ac_init_help=long ;;
-  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
-    ac_init_help=recursive ;;
-  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
-    ac_init_help=short ;;
-
-  -host | --host | --hos | --ho)
-    ac_prev=host_alias ;;
-  -host=* | --host=* | --hos=* | --ho=*)
-    host_alias=$ac_optarg ;;
-
-  -includedir | --includedir | --includedi | --included | --include \
-  | --includ | --inclu | --incl | --inc)
-    ac_prev=includedir ;;
-  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
-  | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir=$ac_optarg ;;
-
-  -infodir | --infodir | --infodi | --infod | --info | --inf)
-    ac_prev=infodir ;;
-  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir=$ac_optarg ;;
-
-  -libdir | --libdir | --libdi | --libd)
-    ac_prev=libdir ;;
-  -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir=$ac_optarg ;;
-
-  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
-  | --libexe | --libex | --libe)
-    ac_prev=libexecdir ;;
-  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
-  | --libexe=* | --libex=* | --libe=*)
-    libexecdir=$ac_optarg ;;
-
-  -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst \
-  | --locals | --local | --loca | --loc | --lo)
-    ac_prev=localstatedir ;;
-  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
-  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
-    localstatedir=$ac_optarg ;;
-
-  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
-    ac_prev=mandir ;;
-  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir=$ac_optarg ;;
-
-  -nfp | --nfp | --nf)
-    # Obsolete; use --without-fp.
-    with_fp=no ;;
-
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c | -n)
-    no_create=yes ;;
-
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
-    no_recursion=yes ;;
-
-  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
-  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
-  | --oldin | --oldi | --old | --ol | --o)
-    ac_prev=oldincludedir ;;
-  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
-  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
-  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir=$ac_optarg ;;
-
-  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-    ac_prev=prefix ;;
-  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix=$ac_optarg ;;
-
-  -program-prefix | --program-prefix | --program-prefi | --program-pref \
-  | --program-pre | --program-pr | --program-p)
-    ac_prev=program_prefix ;;
-  -program-prefix=* | --program-prefix=* | --program-prefi=* \
-  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix=$ac_optarg ;;
-
-  -program-suffix | --program-suffix | --program-suffi | --program-suff \
-  | --program-suf | --program-su | --program-s)
-    ac_prev=program_suffix ;;
-  -program-suffix=* | --program-suffix=* | --program-suffi=* \
-  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix=$ac_optarg ;;
-
-  -program-transform-name | --program-transform-name \
-  | --program-transform-nam | --program-transform-na \
-  | --program-transform-n | --program-transform- \
-  | --program-transform | --program-transfor \
-  | --program-transfo | --program-transf \
-  | --program-trans | --program-tran \
-  | --progr-tra | --program-tr | --program-t)
-    ac_prev=program_transform_name ;;
-  -program-transform-name=* | --program-transform-name=* \
-  | --program-transform-nam=* | --program-transform-na=* \
-  | --program-transform-n=* | --program-transform-=* \
-  | --program-transform=* | --program-transfor=* \
-  | --program-transfo=* | --program-transf=* \
-  | --program-trans=* | --program-tran=* \
-  | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name=$ac_optarg ;;
-
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil)
-    silent=yes ;;
-
-  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
-    ac_prev=sbindir ;;
-  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
-  | --sbi=* | --sb=*)
-    sbindir=$ac_optarg ;;
-
-  -sharedstatedir | --sharedstatedir | --sharedstatedi \
-  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
-  | --sharedst | --shareds | --shared | --share | --shar \
-  | --sha | --sh)
-    ac_prev=sharedstatedir ;;
-  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
-  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
-  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
-  | --sha=* | --sh=*)
-    sharedstatedir=$ac_optarg ;;
-
-  -site | --site | --sit)
-    ac_prev=site ;;
-  -site=* | --site=* | --sit=*)
-    site=$ac_optarg ;;
-
-  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-    ac_prev=srcdir ;;
-  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir=$ac_optarg ;;
-
-  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
-  | --syscon | --sysco | --sysc | --sys | --sy)
-    ac_prev=sysconfdir ;;
-  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
-  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir=$ac_optarg ;;
-
-  -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target_alias ;;
-  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target_alias=$ac_optarg ;;
-
-  -v | -verbose | --verbose | --verbos | --verbo | --verb)
-    verbose=yes ;;
-
-  -version | --version | --versio | --versi | --vers | -V)
-    ac_init_version=: ;;
-
-  -with-* | --with-*)
-    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid package name: $ac_package" >&2
-   { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package| sed 's/-/_/g'`
-    case $ac_option in
-      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
-      *) ac_optarg=yes ;;
-    esac
-    eval "with_$ac_package='$ac_optarg'" ;;
-
-  -without-* | --without-*)
-    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid package name: $ac_package" >&2
-   { (exit 1); exit 1; }; }
-    ac_package=`echo $ac_package | sed 's/-/_/g'`
-    eval "with_$ac_package=no" ;;
-
-  --x)
-    # Obsolete; use --with-x.
-    with_x=yes ;;
-
-  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
-  | --x-incl | --x-inc | --x-in | --x-i)
-    ac_prev=x_includes ;;
-  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
-  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes=$ac_optarg ;;
-
-  -x-libraries | --x-libraries | --x-librarie | --x-librari \
-  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
-    ac_prev=x_libraries ;;
-  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
-  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries=$ac_optarg ;;
-
-  -*) { echo "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
-   { (exit 1); exit 1; }; }
-    ;;
-
-  *=*)
-    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
-      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
-   { (exit 1); exit 1; }; }
-    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
-    eval "$ac_envvar='$ac_optarg'"
-    export $ac_envvar ;;
-
-  *)
-    # FIXME: should be removed in autoconf 3.0.
-    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
-    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
-    ;;
-
-  esac
-done
-
-if test -n "$ac_prev"; then
-  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  { echo "$as_me: error: missing argument to $ac_option" >&2
-   { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
-do
-  eval ac_val=$`echo $ac_var`
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
-    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-   { (exit 1); exit 1; }; };;
-  esac
-done
-
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
-	      localstatedir libdir includedir oldincludedir infodir mandir
-do
-  eval ac_val=$`echo $ac_var`
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* ) ;;
-    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-   { (exit 1); exit 1; }; };;
-  esac
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
-  if test "x$build_alias" = x; then
-    cross_compiling=maybe
-    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used." >&2
-  elif test "x$build_alias" != "x$host_alias"; then
-    cross_compiling=yes
-  fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
-  ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then its parent.
-  ac_confdir=`(dirname "$0") 2>/dev/null ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$0" : 'X\(//\)[^/]' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$0" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-  srcdir=$ac_confdir
-  if test ! -r $srcdir/$ac_unique_file; then
-    srcdir=..
-  fi
-else
-  ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
-  if test "$ac_srcdir_defaulted" = yes; then
-    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
-   { (exit 1); exit 1; }; }
-  else
-    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
-   { (exit 1); exit 1; }; }
-  fi
-fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
-  { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
-   { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
-ac_env_F77_set=${F77+set}
-ac_env_F77_value=$F77
-ac_cv_env_F77_set=${F77+set}
-ac_cv_env_F77_value=$F77
-ac_env_FFLAGS_set=${FFLAGS+set}
-ac_env_FFLAGS_value=$FFLAGS
-ac_cv_env_FFLAGS_set=${FFLAGS+set}
-ac_cv_env_FFLAGS_value=$FFLAGS
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-ac_env_CXXCPP_set=${CXXCPP+set}
-ac_env_CXXCPP_value=$CXXCPP
-ac_cv_env_CXXCPP_set=${CXXCPP+set}
-ac_cv_env_CXXCPP_value=$CXXCPP
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
-  # Omit some internal or obsolete options to make the list less imposing.
-  # This message is too long to be a string in the A/UX 3.1 sh.
-  cat <<_ACEOF
-\`configure' configures SUNDIALS 2.5.0 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE.  See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
-  -h, --help              display this help and exit
-      --help=short        display options specific to this package
-      --help=recursive    display the short help of all the included packages
-  -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking...' messages
-      --cache-file=FILE   cache test results in FILE [disabled]
-  -C, --config-cache      alias for \`--cache-file=config.cache'
-  -n, --no-create         do not create output files
-      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
-
-_ACEOF
-
-  cat <<_ACEOF
-Installation directories:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-			  [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-			  [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
-  --bindir=DIR           user executables [EPREFIX/bin]
-  --sbindir=DIR          system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR       program executables [EPREFIX/libexec]
-  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
-  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
-  --libdir=DIR           object code libraries [EPREFIX/lib]
-  --includedir=DIR       C header files [PREFIX/include]
-  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
-  --infodir=DIR          info documentation [PREFIX/info]
-  --mandir=DIR           man documentation [PREFIX/man]
-_ACEOF
-
-  cat <<\_ACEOF
-
-System types:
-  --build=BUILD     configure for building on BUILD [guessed]
-  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
-  case $ac_init_help in
-     short | recursive ) echo "Configuration of SUNDIALS 2.5.0:";;
-   esac
-  cat <<\_ACEOF
-
-Optional Features:
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --disable-cvode         disable configuration of CVODE
-  --disable-cvodes        disable configuration of CVODES
-  --disable-ida           disable configuration of IDA
-  --disable-idas          disable configuration of IDAS
-  --disable-kinsol        disable configuration of KINSOL
-  --disable-cpodes        disable configuration of CPODES
-  --disable-fcmix         disable Fortran-C support
-  --disable-lapack        disable Lapack support
-  --disable-mpi           disable MPI support
-  --enable-examples       enable configuration of examples
-  --enable-shared[=PKGS]
-                          build shared libraries [default=no]
-  --enable-static[=PKGS]
-                          build static libraries [default=yes]
-  --enable-fast-install[=PKGS]
-                          optimize for fast installation [default=yes]
-  --disable-libtool-lock  avoid locking (might break parallel builds)
-
-Optional Packages:
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-
-  --with-precision=ARG    specify floating-point precision
-                          (single/double/extended) [double]
-
-  --with-cflags=ARG       specify C compiler flags (CFLAGS will be overridden)
-  --with-cppflags=ARG     specify C/C++ preprocessor flags (CPPFLAGS will be
-                          overridden)
-  --with-ldflags=ARG      specify linker flags (LDFLAGS will be overridden)
-  --with-libs=ARG         add extra libraries
-  --with-fflags=ARG       add extra Fortran compiler flags
-  --with-blas=ARG         specify Blas library
-  --with-lapack=ARG       specify Lapack library
-
-  --with-mpi-root=MPIROOT use MPI root directory
-  --with-mpi-incdir=DIR   MPI include directory [MPIROOT/include]
-  --with-mpi-libdir=DIR   MPI library directory [MPIROOT/lib]
-  --with-mpi-libs=ARG     MPI libraries
-  --with-mpi-flags=ARG    MPI-specific flags
-  --with-mpicc[=ARG] specify MPI-C compiler to use [mpicc]
-  --with-mpif77[=ARG] specify MPI-Fortran compiler to use [mpif77]
-
-  --with-exinstdir=DIR    install SUNDIALS examples in DIR
-                          [EPREFIX/examples]
-  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
-  --with-pic              try to use only PIC/non-PIC objects [default=use
-                          both]
-  --with-tags[=TAGS]
-                          include additional configurations [automatic]
-
-NOTES
-  It is legal to set --with-exinstdir to "no", in which case the examples
-  are built but not installed.
-  Enabling the compilation of the examples (--enable-examples) but disabling their
-  installation (--with-exinstdir=no) can be used to test the SUNDIALS libraries.
-
-Some influential environment variables:
-  CC          C compiler command
-  CFLAGS      C compiler flags
-  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
-              nonstandard directory <lib dir>
-  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
-              headers in a nonstandard directory <include dir>
-  CPP         C preprocessor
-  F77         Fortran 77 compiler command
-  FFLAGS      Fortran 77 compiler flags
-  CXX         C++ compiler command
-  CXXFLAGS    C++ compiler flags
-  CXXCPP      C++ preprocessor
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to <radu at llnl.gov>.
-_ACEOF
-fi
-
-if test "$ac_init_help" = "recursive"; then
-  # If there are subdirs, report their specific --help.
-  ac_popdir=`pwd`
-  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d $ac_dir || continue
-    ac_builddir=.
-
-if test "$ac_dir" != .; then
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
-    ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
-
-    cd $ac_dir
-    # Check for guested configure; otherwise get Cygnus style configure.
-    if test -f $ac_srcdir/configure.gnu; then
-      echo
-      $SHELL $ac_srcdir/configure.gnu  --help=recursive
-    elif test -f $ac_srcdir/configure; then
-      echo
-      $SHELL $ac_srcdir/configure  --help=recursive
-    elif test -f $ac_srcdir/configure.ac ||
-	   test -f $ac_srcdir/configure.in; then
-      echo
-      $ac_configure --help
-    else
-      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
-    fi
-    cd $ac_popdir
-  done
-fi
-
-test -n "$ac_init_help" && exit 0
-if $ac_init_version; then
-  cat <<\_ACEOF
-SUNDIALS configure 2.5.0
-generated by GNU Autoconf 2.59
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-
-
-Copyright (c) 2002, The Regents of the University of California.
-Produced at the Lawrence Livermore National Laboratory.
-All rights reserved.
-For details, see the LICENSE file.
-
-_ACEOF
-  exit 0
-fi
-exec 5>config.log
-cat >&5 <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by SUNDIALS $as_me 2.5.0, which was
-generated by GNU Autoconf 2.59.  Invocation command line was
-
-  $ $0 $@
-
-_ACEOF
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
-
-/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
-/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
-/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  echo "PATH: $as_dir"
-done
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_sep=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
-  for ac_arg
-  do
-    case $ac_arg in
-    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-    | -silent | --silent | --silen | --sile | --sil)
-      continue ;;
-    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
-      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    case $ac_pass in
-    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
-    2)
-      ac_configure_args1="$ac_configure_args1 '$ac_arg'"
-      if test $ac_must_keep_next = true; then
-	ac_must_keep_next=false # Got value, back to normal.
-      else
-	case $ac_arg in
-	  *=* | --config-cache | -C | -disable-* | --disable-* \
-	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
-	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
-	  | -with-* | --with-* | -without-* | --without-* | --x)
-	    case "$ac_configure_args0 " in
-	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
-	    esac
-	    ;;
-	  -* ) ac_must_keep_next=true ;;
-	esac
-      fi
-      ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
-      # Get rid of the leading space.
-      ac_sep=" "
-      ;;
-    esac
-  done
-done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log.  We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
-trap 'exit_status=$?
-  # Save into config.log some information that might help in debugging.
-  {
-    echo
-
-    cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
-    echo
-    # The following way of writing the cache mishandles newlines in values,
-{
-  (set) 2>&1 |
-    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
-    *ac_space=\ *)
-      sed -n \
-	"s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
-      ;;
-    *)
-      sed -n \
-	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
-      ;;
-    esac;
-}
-    echo
-
-    cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
-    echo
-    for ac_var in $ac_subst_vars
-    do
-      eval ac_val=$`echo $ac_var`
-      echo "$ac_var='"'"'$ac_val'"'"'"
-    done | sort
-    echo
-
-    if test -n "$ac_subst_files"; then
-      cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
-_ASBOX
-      echo
-      for ac_var in $ac_subst_files
-      do
-	eval ac_val=$`echo $ac_var`
-	echo "$ac_var='"'"'$ac_val'"'"'"
-      done | sort
-      echo
-    fi
-
-    if test -s confdefs.h; then
-      cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
-      echo
-      sed "/^$/d" confdefs.h | sort
-      echo
-    fi
-    test "$ac_signal" != 0 &&
-      echo "$as_me: caught signal $ac_signal"
-    echo "$as_me: exit $exit_status"
-  } >&5
-  rm -f core *.core &&
-  rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
-    exit $exit_status
-     ' 0
-for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo >confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
-  if test "x$prefix" != xNONE; then
-    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
-  else
-    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
-  fi
-fi
-for ac_site_file in $CONFIG_SITE; do
-  if test -r "$ac_site_file"; then
-    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
-    sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file"
-  fi
-done
-
-if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special
-  # files actually), so we avoid doing that.
-  if test -f "$cache_file"; then
-    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
-    case $cache_file in
-      [\\/]* | ?:[\\/]* ) . $cache_file;;
-      *)                      . ./$cache_file;;
-    esac
-  fi
-else
-  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
-  >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
-	       sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
-  eval ac_old_set=\$ac_cv_env_${ac_var}_set
-  eval ac_new_set=\$ac_env_${ac_var}_set
-  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
-  eval ac_new_val="\$ac_env_${ac_var}_value"
-  case $ac_old_set,$ac_new_set in
-    set,)
-      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,set)
-      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,);;
-    *)
-      if test "x$ac_old_val" != "x$ac_new_val"; then
-	{ echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-	{ echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5
-echo "$as_me:   former value:  $ac_old_val" >&2;}
-	{ echo "$as_me:$LINENO:   current value: $ac_new_val" >&5
-echo "$as_me:   current value: $ac_new_val" >&2;}
-	ac_cache_corrupted=:
-      fi;;
-  esac
-  # Pass precious variables to config.status.
-  if test "$ac_new_set" = set; then
-    case $ac_new_val in
-    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
-      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
-    *) ac_arg=$ac_var=$ac_new_val ;;
-    esac
-    case " $ac_configure_args " in
-      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
-    esac
-  fi
-done
-if $ac_cache_corrupted; then
-  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Display greeting
-
-
-# Say Hi!
-echo "
----------------------------------
-Running SUNDIALS Configure Script
----------------------------------
-"
-
-
-
-# Specify directory containing auxillary build tools and M4 files
-ac_aux_dir=
-for ac_dir in config $srcdir/config; do
-  if test -f $ac_dir/install-sh; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f $ac_dir/install.sh; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f $ac_dir/shtool; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
-done
-if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in config $srcdir/config" >&5
-echo "$as_me: error: cannot find install-sh or install.sh in config $srcdir/config" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"
-ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
-
-
-# Miscellaneous SUNDIALS initializations
-echo "Initialization"
-echo "--------------"
-echo ""
-
-
-# Reference custom macros
-# This file is part of Autoconf.                       -*- Autoconf -*-
-# Fortran languages support.
-# Copyright (C) 2001, 2003
-# Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-#
-# As a special exception, the Free Software Foundation gives unlimited
-# permission to copy, distribute and modify the configure scripts that
-# are the output of Autoconf.  You need not follow the terms of the GNU
-# General Public License when using or distributing such scripts, even
-# though portions of the text of Autoconf appear in them.  The GNU
-# General Public License (GPL) does govern all other use of the material
-# that constitutes the Autoconf program.
-#
-# Certain portions of the Autoconf source text are designed to be copied
-# (in certain cases, depending on the input) into the output of
-# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
-# source text consists of comments plus executable code that decides which
-# of the data portions to output in any given case.  We call these
-# comments and executable code the "non-data" portions.  Autoconf never
-# copies any of the non-data portions into its output.
-#
-# This special exception to the GPL applies to versions of Autoconf
-# released by the Free Software Foundation.  When you make and
-# distribute a modified version of Autoconf, you may extend this special
-# exception to the GPL to apply to your modified version as well, *unless*
-# your modified version has the potential to copy into its output some
-# of the text that was the non-data portion of the version that you started
-# with.  (In other words, unless your change moves or copies text from
-# the non-data portions to the data portions.)  If your modification has
-# such potential, you must delete any notice of this special exception
-# to the GPL from your modified version.
-#
-# Written by David MacKenzie, with help from
-# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
-# Roland McGrath, Noah Friedman, david d zuhn, and many others.
-
-# Fortran vs. Fortran 77:
-#   This file contains macros for both "Fortran 77" and "Fortran", where
-# the former is the "classic" autoconf Fortran interface and is intended
-# for legacy F77 codes, while the latter is intended to support newer Fortran
-# dialects.  Fortran 77 uses environment variables F77, FFLAGS, and FLIBS,
-# while Fortran uses FC, FCFLAGS, and FCLIBS.  For each user-callable AC_*
-# macro, there is generally both an F77 and an FC version, where both versions
-# share the same _AC_*_FC_* backend.  This backend macro requires that
-# the appropriate language be AC_LANG_PUSH'ed, and uses _AC_LANG_ABBREV and
-# _AC_LANG_PREFIX in order to name cache and environment variables, etc.
-
-
-# _AC_PROG_FC_V_OUTPUT([FLAG = $ac_cv_prog_{f77/fc}_v])
-# -------------------------------------------------
-# Link a trivial Fortran program, compiling with a verbose output FLAG
-# (whose default value, $ac_cv_prog_{f77/fc}_v, is computed by
-# _AC_PROG_FC_V), and return the output in $ac_{f77/fc}_v_output.  This
-# output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS,
-# so that any link flags that are echoed by the compiler appear as
-# space-separated items.
-# _AC_PROG_FC_V_OUTPUT
-
-# This file is part of Autoconf.                       -*- Autoconf -*-
-# Programming languages support.
-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-#
-# As a special exception, the Free Software Foundation gives unlimited
-# permission to copy, distribute and modify the configure scripts that
-# are the output of Autoconf.  You need not follow the terms of the GNU
-# General Public License when using or distributing such scripts, even
-# though portions of the text of Autoconf appear in them.  The GNU
-# General Public License (GPL) does govern all other use of the material
-# that constitutes the Autoconf program.
-#
-# Certain portions of the Autoconf source text are designed to be copied
-# (in certain cases, depending on the input) into the output of
-# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
-# source text consists of comments plus executable code that decides which
-# of the data portions to output in any given case.  We call these
-# comments and executable code the "non-data" portions.  Autoconf never
-# copies any of the non-data portions into its output.
-#
-# This special exception to the GPL applies to versions of Autoconf
-# released by the Free Software Foundation.  When you make and
-# distribute a modified version of Autoconf, you may extend this special
-# exception to the GPL to apply to your modified version as well, *unless*
-# your modified version has the potential to copy into its output some
-# of the text that was the non-data portion of the version that you started
-# with.  (In other words, unless your change moves or copies text from
-# the non-data portions to the data portions.)  If your modification has
-# such potential, you must delete any notice of this special exception
-# to the GPL from your modified version.
-#
-# Written by David MacKenzie, with help from
-# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
-# Roland McGrath, Noah Friedman, david d zuhn, and many others.
-
-
-# AC_LANG(C)
-# ----------
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-
-
-# This file is part of Autoconf.                       -*- Autoconf -*-
-# Parameterized macros.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# As a special exception, the Free Software Foundation gives unlimited
-# permission to copy, distribute and modify the configure scripts that
-# are the output of Autoconf.  You need not follow the terms of the GNU
-# General Public License when using or distributing such scripts, even
-# though portions of the text of Autoconf appear in them.  The GNU
-# General Public License (GPL) does govern all other use of the material
-# that constitutes the Autoconf program.
-#
-# Certain portions of the Autoconf source text are designed to be copied
-# (in certain cases, depending on the input) into the output of
-# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
-# source text consists of comments plus executable code that decides which
-# of the data portions to output in any given case.  We call these
-# comments and executable code the "non-data" portions.  Autoconf never
-# copies any of the non-data portions into its output.
-#
-# This special exception to the GPL applies to versions of Autoconf
-# released by the Free Software Foundation.  When you make and
-# distribute a modified version of Autoconf, you may extend this special
-# exception to the GPL to apply to your modified version as well, *unless*
-# your modified version has the potential to copy into its output some
-# of the text that was the non-data portion of the version that you started
-# with.  (In other words, unless your change moves or copies text from
-# the non-data portions to the data portions.)  If your modification has
-# such potential, you must delete any notice of this special exception
-# to the GPL from your modified version.
-#
-# Written by David MacKenzie, with help from
-# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
-# Roland McGrath, Noah Friedman, david d zuhn, and many others.
-
-
-# _AC_MSG_LOG_CONFTEST_GENERAL
-# ----------------------------
-
-
-
-# _AC_LINKONLY_IFELSE(PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# ------------------------------------------------------------------
-# Try to link PROGRAM (empty).
-# This macro can be used during the selection of a compiler.
-# _AC_LINKONLY_IFELSE
-
-
-# AC_LINKONLY_IFELSE(PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# -----------------------------------------------------------------
-# Try to link PROGRAM.  Requires that the compiler for the current
-# language was checked for, hence do not use this macro in macros looking
-# for a compiler.
-
-
-
-# Make input filename DOS compatible (change config.h.in to config.hin)
-          ac_config_headers="$ac_config_headers config.h:config.hin"
-
-
-# Make user aware of copyright notice (input COPYRIGHT information)
-
-
-# Specify root of source tree
-# Given file is guaranteed to exist in all SUNDIALS packages
-
-
-# Get host information
-# AC_CANONICAL_BUILD defines the following variables: build, build_cpu,
-# build_vendor, and build_os
-# Make sure we can run config.sub.
-$ac_config_sub sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
-echo "$as_me: error: cannot run $ac_config_sub" >&2;}
-   { (exit 1); exit 1; }; }
-
-echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6
-if test "${ac_cv_build+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_build_alias=$build_alias
-test -z "$ac_cv_build_alias" &&
-  ac_cv_build_alias=`$ac_config_guess`
-test -z "$ac_cv_build_alias" &&
-  { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
-   { (exit 1); exit 1; }; }
-ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
-  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
-   { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6
-build=$ac_cv_build
-build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-# AC_CANONICAL_HOST defines the following variables: host, host_cpu,
-# host_vendor, and host_os
-echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6
-if test "${ac_cv_host+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_host_alias=$host_alias
-test -z "$ac_cv_host_alias" &&
-  ac_cv_host_alias=$ac_cv_build_alias
-ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
-  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
-   { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6
-host=$ac_cv_host
-host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-
-# Set MAKE if necessary
-# Must include @SET_MAKE@ in each Makefile.in file
-# AC_SUBST is called automatically for SET_MAKE
-echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.make <<\_ACEOF
-all:
-	@echo 'ac_maketemp="$(MAKE)"'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
-  eval ac_cv_prog_make_${ac_make}_set=yes
-else
-  eval ac_cv_prog_make_${ac_make}_set=no
-fi
-rm -f conftest.make
-fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-  SET_MAKE=
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-  SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-
-# Defines INSTALL (sets to path of "install" program)
-# Also sets INSTALL_PROGRAM and INSTALL_SCRIPT
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in
-  ./ | .// | /cC/* | \
-  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
-  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
-  /usr/ucb/* ) ;;
-  *)
-    # OSF1 and SCO ODT 3.0 have their own names for install.
-    # Don't use installbsd from OSF since it installs stuff as root
-    # by default.
-    for ac_prog in ginstall scoinst install; do
-      for ac_exec_ext in '' $ac_executable_extensions; do
-	if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
-	  if test $ac_prog = install &&
-	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-	    # AIX install.  It has an incompatible calling convention.
-	    :
-	  elif test $ac_prog = install &&
-	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-	    # program-specific install script used by HP pwplus--don't use.
-	    :
-	  else
-	    ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-	    break 3
-	  fi
-	fi
-      done
-    done
-    ;;
-esac
-done
-
-
-fi
-  if test "${ac_cv_path_install+set}" = set; then
-    INSTALL=$ac_cv_path_install
-  else
-    # As a last resort, use the slow shell script.  We don't cache a
-    # path for INSTALL within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the path is relative.
-    INSTALL=$ac_install_sh
-  fi
-fi
-echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-# Set defaults for config/sundials_config.in file
-F77_MANGLE_MACRO1=""
-F77_MANGLE_MACRO2=""
-PRECISION_LEVEL=""
-GENERIC_MATH_LIB=""
-BLAS_LAPACK_MACRO=""
-F77_MPI_COMM_F2C=""
-SUNDIALS_EXPORT="#define SUNDIALS_EXPORT"
-
-# Initialize enable status of various modules, options, and features
-# to their default values
-#
-# NOTE: when CPODES is released, change its default to enabled.
-#
-CVODE_ENABLED="yes"
-CVODES_ENABLED="yes"
-IDA_ENABLED="yes"
-IDAS_ENABLED="yes"
-KINSOL_ENABLED="yes"
-LAPACK_ENABLED="yes"
-FCMIX_ENABLED="yes"
-MPI_ENABLED="yes"
-#
-CPODES_ENABLED="no"
-#
-EXAMPLES_ENABLED="no"
-F77_EXAMPLES_ENABLED="no"
-
-# Initialize variables that may NOT necessarily be initialized
-# during normal execution. Should NOT use uninitialized variables
-F77_OK="no"
-LAPACK_OK="no"
-MPI_C_COMP_OK="no"
-MPI_F77_COMP_OK="no"
-
-# This variable is set to "yes" if an AC_MSG_WARN statement
-# was executed
-SUNDIALS_WARN_FLAG="no"
-
-
-
-# Test enable/disable features
-
-
-# Check if user wants to disable CVODE module
-# If not, then make certain source directory actually exists
-# Check whether --enable-cvode or --disable-cvode was given.
-if test "${enable_cvode+set}" = set; then
-  enableval="$enable_cvode"
-
-if test "X${enableval}" = "Xno"; then
-  CVODE_ENABLED="no"
-fi
-
-else
-
-if test -d ${srcdir}/src/cvode ; then
-  CVODE_ENABLED="yes"
-else
-  CVODE_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable CVODES module
-# If not, then make certain source directory actually exists
-# Check whether --enable-cvodes or --disable-cvodes was given.
-if test "${enable_cvodes+set}" = set; then
-  enableval="$enable_cvodes"
-
-if test "X${enableval}" = "Xno"; then
-  CVODES_ENABLED="no"
-fi
-
-else
-
-if test -d ${srcdir}/src/cvodes ; then
-  CVODES_ENABLED="yes"
-else
-  CVODES_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable IDA module
-# If not, then make certain source directory actually exists
-# Check whether --enable-ida or --disable-ida was given.
-if test "${enable_ida+set}" = set; then
-  enableval="$enable_ida"
-
-if test "X${enableval}" = "Xno"; then
-  IDA_ENABLED="no"
-fi
-
-else
-
-if test -d ${srcdir}/src/ida  ; then
-  IDA_ENABLED="yes"
-else
-  IDA_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable IDAS module
-# If not, then make certain source directory actually exists
-# Check whether --enable-idas or --disable-idas was given.
-if test "${enable_idas+set}" = set; then
-  enableval="$enable_idas"
-
-if test "X${enableval}" = "Xno"; then
-  IDAS_ENABLED="no"
-fi
-
-else
-
-if test -d ${srcdir}/src/idas  ; then
-  IDAS_ENABLED="yes"
-else
-  IDAS_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable KINSOL MODULE
-# If not, then make certain source directory actually exists
-# Check whether --enable-kinsol or --disable-kinsol was given.
-if test "${enable_kinsol+set}" = set; then
-  enableval="$enable_kinsol"
-
-if test "X${enableval}" = "Xno"; then
-  KINSOL_ENABLED="no"
-fi
-
-else
-
-if test -d ${srcdir}/src/kinsol ; then
-  KINSOL_ENABLED="yes"
-else
-  KINSOL_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable CPODES module
-# If not, then make certain source directory actually exists
-# Check whether --enable-cpodes or --disable-cpodes was given.
-if test "${enable_cpodes+set}" = set; then
-  enableval="$enable_cpodes"
-
-if test "X${enableval}" = "Xno"; then
-  CPODES_ENABLED="no"
-fi
-
-else
-
-if test -d ${srcdir}/src/cpodes ; then
-  CPODES_ENABLED="yes"
-else
-  CPODES_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable Fortran support (FCMIX components).
-# Check whether --enable-fcmix or --disable-fcmix was given.
-if test "${enable_fcmix+set}" = set; then
-  enableval="$enable_fcmix"
-
-if test "X${enableval}" = "Xno"; then
-  FCMIX_ENABLED="no"
-fi
-
-else
-
-if test "X${CVODE_ENABLED}" = "Xno" && test "X${KINSOL_ENABLED}" = "Xno" && test "X${IDA_ENABLED}" = "Xno"; then
-  FCMIX_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable Lapack support.
-# Check whether --enable-lapack or --disable-lapack was given.
-if test "${enable_lapack+set}" = set; then
-  enableval="$enable_lapack"
-
-if test "X${enableval}" = "Xno"; then
-  LAPACK_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to disable support for MPI.
-# If not, set the default based on whetehr certain source directories exist
-# Check whether --enable-mpi or --disable-mpi was given.
-if test "${enable_mpi+set}" = set; then
-  enableval="$enable_mpi"
-
-if test "X${enableval}" = "Xno"; then
-  MPI_ENABLED="no"
-fi
-
-else
-
-if test -d ${srcdir}/src/nvec_par || test -d ${srcdir}/src/nvec_spcpar; then
-  MPI_ENABLED="yes"
-else
-  MPI_ENABLED="no"
-fi
-
-fi;
-
-# Check if user wants to enable all examples.
-# Examples are NOT built by default
-# Check whether --enable-examples or --disable-examples was given.
-if test "${enable_examples+set}" = set; then
-  enableval="$enable_examples"
-
-if test "X${enableval}" = "Xno"; then
-  EXAMPLES_ENABLED="no"
-else
-  EXAMPLES_ENABLED="yes"
-fi
-
-fi;
-
-# Fortran examples are enabled only if both FCMIX and EXAMPLES are enabled
-if test "X${FCMIX_ENABLED}" = "Xyes" && test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-  F77_EXAMPLES_ENABLED="yes"
-fi
-
-
-
-# Set C compilation (Required)
-echo ""
-echo "C Compiler Settings"
-echo "-------------------"
-echo ""
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in cc gcc
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-    test -n "$CC" && break
-  done
-fi
-if test -z "$CC"; then
-  ac_ct_CC=$CC
-  for ac_prog in cc gcc
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  test -n "$ac_ct_CC" && break
-done
-
-  CC=$ac_ct_CC
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
-     "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
-  (eval $ac_link_default) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  # Find the output, starting from the most likely.  This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
-do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
-	;;
-    conftest.$ac_ext )
-	# This is the source file.
-	;;
-    [ab].out )
-	# We found the default executable, but exeext='' is most
-	# certainly right.
-	break;;
-    *.* )
-	ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	# FIXME: I believe we export ac_cv_exeext for Libtool,
-	# but it would be cool to find out if it's true.  Does anybody
-	# maintain Libtool? --akim.
-	export ac_cv_exeext
-	break;;
-    * )
-	break;;
-  esac
-done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
-See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
-fi
-
-ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
-
-# Check the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
-  if { ac_try='./$ac_file'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { echo "$as_me:$LINENO: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-    fi
-  fi
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
-
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
-    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	  export ac_cv_exeext
-	  break;;
-    * ) break;;
-  esac
-done
-else
-  { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
-if test "${ac_cv_objext+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
-    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
-       break;;
-  esac
-done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_compiler_gnu=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_cc_g=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
-else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
-  else
-    CFLAGS=
-  fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std1 is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std1.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX			-qlanglvl=ansi
-# Ultrix and OSF/1	-std1
-# HP-UX 10.20 and later	-Ae
-# HP-UX older versions	-Aa -D_HPUX_SOURCE
-# SVR4			-Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_cc_stdc=$ac_arg
-break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
-  x|xno)
-    echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
-  *)
-    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
-    CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C.  Since we use `exit',
-# in C++ we need to declare it.  In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
-  choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  for ac_declaration in \
-   '' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
-    then ac_cv_prog_egrep='grep -E'
-    else ac_cv_prog_egrep='egrep'
-    fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
-
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Header=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-
-
-if test "X${CC}" = "X"; then
-
-  echo ""
-  echo "   Unable to find a working C compiler"
-  echo ""
-  echo "   Try using CC to explicitly specify a C compiler"
-  echo ""
-
-  { { echo "$as_me:$LINENO: error: cannot find a C compiler" >&5
-echo "$as_me: error: cannot find a C compiler" >&2;}
-   { (exit 1); exit 1; }; }
-
-else
-
-
-
-# Default is C programming language (initialize language stack)
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Set floating-point precision: single   [C type 'float']
-#                               double   [C type 'double'] (default)
-#                               extended [C type 'long double']
-# Provide variable description templates for config.hin and config.h files
-# Required by autoheader utility
-
-
-
-
-
-
-
-echo "$as_me:$LINENO: checking floating-point data type to use" >&5
-echo $ECHO_N "checking floating-point data type to use... $ECHO_C" >&6
-
-# Check whether --with-precision or --without-precision was given.
-if test "${with_precision+set}" = set; then
-  withval="$with_precision"
-
-if test "X${withval}" = "Xsingle"; then
-  echo "$as_me:$LINENO: result: float" >&5
-echo "${ECHO_T}float" >&6
-  cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_SINGLE_PRECISION 1
-_ACEOF
-
-  FLOAT_TYPE="single"
-  PRECISION_LEVEL="#define SUNDIALS_SINGLE_PRECISION 1"
-elif test "X${withval}" = "Xdouble"; then
-  echo "$as_me:$LINENO: result: double" >&5
-echo "${ECHO_T}double" >&6
-  cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_DOUBLE_PRECISION 1
-_ACEOF
-
-  FLOAT_TYPE="double"
-  PRECISION_LEVEL="#define SUNDIALS_DOUBLE_PRECISION 1"
-elif test "X${withval}" = "Xextended"; then
-  echo "$as_me:$LINENO: result: long double" >&5
-echo "${ECHO_T}long double" >&6
-  cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_EXTENDED_PRECISION 1
-_ACEOF
-
-  FLOAT_TYPE="extended"
-  PRECISION_LEVEL="#define SUNDIALS_EXTENDED_PRECISION 1"
-else
-  { { echo "$as_me:$LINENO: error: invalid input" >&5
-echo "$as_me: error: invalid input" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-else
-
-# Use 'double' by default
-echo "$as_me:$LINENO: result: double" >&5
-echo "${ECHO_T}double" >&6
-cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_DOUBLE_PRECISION 1
-_ACEOF
-
-FLOAT_TYPE="double"
-PRECISION_LEVEL="#define SUNDIALS_DOUBLE_PRECISION 1"
-
-fi;
-
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Overwrite CFLAGS
-echo "$as_me:$LINENO: checking for C compiler flags" >&5
-echo $ECHO_N "checking for C compiler flags... $ECHO_C" >&6
-
-# Check whether --with-cflags or --without-cflags was given.
-if test "${with_cflags+set}" = set; then
-  withval="$with_cflags"
-
-echo "$as_me:$LINENO: result: ${withval}" >&5
-echo "${ECHO_T}${withval}" >&6
-CFLAGS="${withval}"
-
-else
-
-echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-
-fi;
-
-# Set CPP to command that runs C preprocessor
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether non-existent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  # Broken: success on invalid input.
-continue
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  break
-fi
-
-    done
-    ac_cv_prog_CPP=$CPP
-
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether non-existent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  # Broken: success on invalid input.
-continue
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  :
-else
-  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Overwrite CPPFLAGS
-echo "$as_me:$LINENO: checking for C/C++ preprocessor flags" >&5
-echo $ECHO_N "checking for C/C++ preprocessor flags... $ECHO_C" >&6
-
-# Check whether --with-cppflags or --without-cppflags was given.
-if test "${with_cppflags+set}" = set; then
-  withval="$with_cppflags"
-
-echo "$as_me:$LINENO: result: ${withval}" >&5
-echo "${ECHO_T}${withval}" >&6
-CPPFLAGS="${withval}"
-
-else
-
-echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-
-fi;
-
-# Overwrite LDFLAGS
-echo "$as_me:$LINENO: checking for linker flags" >&5
-echo $ECHO_N "checking for linker flags... $ECHO_C" >&6
-
-# Check whether --with-ldflags or --without-ldflags was given.
-if test "${with_ldflags+set}" = set; then
-  withval="$with_ldflags"
-
-echo "$as_me:$LINENO: result: ${withval}" >&5
-echo "${ECHO_T}${withval}" >&6
-LDFLAGS="${withval}"
-
-else
-
-echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-
-fi;
-
-# Add any additional libraries
-echo "$as_me:$LINENO: checking for extra libraries" >&5
-echo $ECHO_N "checking for extra libraries... $ECHO_C" >&6
-
-# Check whether --with-libs or --without-libs was given.
-if test "${with_libs+set}" = set; then
-  withval="$with_libs"
-
-echo "$as_me:$LINENO: result: ${withval}" >&5
-echo "${ECHO_T}${withval}" >&6
-if test "X${LIBS}" = "X"; then
-  LIBS="${withval}"
-else
-  LIBS="${LIBS} ${withval}"
-fi
-
-else
-
-echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-
-fi;
-
-# Defines STDC_HEADERS if the following header files are found: stdlib.h,
-# stdarg.h, string.h, and float.h
-# We really only need stdlib.h and float.h
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_header_stdc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then
-  :
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then
-  :
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      exit(2);
-  exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-
-
-
-for ac_header in stdlib.h float.h math.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
-  # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    (
-      cat <<\_ASBOX
-## ---------------------------- ##
-## Report this to radu at llnl.gov ##
-## ---------------------------- ##
-_ASBOX
-    ) |
-      sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-# Set flag indicating if generic function names should be used
-# Provide variable description template for config.hin and config.h files
-# Required by autoheader utility
-
-
-
-# Check if math library contains abs(), fabs(), pow(), and sqrt() functions (required)
-# May update LIBS (meaning add additional library, namely libm)
-MATH_FABS_OK="yes"
-MATH_POW_OK="yes"
-MATH_SQRT_OK="yes"
-# Save copy of LIBS variable and unset LIBS
-SAVED_LIBS="${LIBS}"
-LIBS=""
-# The abs routine is defined for an integer argument, so check for it regardless of
-# the level of precision chosen
-
-echo "$as_me:$LINENO: checking for abs in -lm" >&5
-echo $ECHO_N "checking for abs in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_abs+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char abs ();
-int
-main ()
-{
-abs ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_abs=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_abs=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_abs" >&5
-echo "${ECHO_T}$ac_cv_lib_m_abs" >&6
-if test $ac_cv_lib_m_abs = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  { { echo "$as_me:$LINENO: error: cannot find abs function" >&5
-echo "$as_me: error: cannot find abs function" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-TEMP_MATH_LIB="${LIBS}"
-LIBS=""
-# Check for single-precision math routines
-if test "X${FLOAT_TYPE}" = "Xsingle"; then
-
-echo "$as_me:$LINENO: checking for fabsf in -lm" >&5
-echo $ECHO_N "checking for fabsf in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_fabsf+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char fabsf ();
-int
-main ()
-{
-fabsf ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_fabsf=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_fabsf=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_fabsf" >&5
-echo "${ECHO_T}$ac_cv_lib_m_fabsf" >&6
-if test $ac_cv_lib_m_fabsf = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  MATH_FABS_OK="no"
-fi
-
-
-echo "$as_me:$LINENO: checking for powf in -lm" >&5
-echo $ECHO_N "checking for powf in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_powf+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char powf ();
-int
-main ()
-{
-powf ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_powf=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_powf=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_powf" >&5
-echo "${ECHO_T}$ac_cv_lib_m_powf" >&6
-if test $ac_cv_lib_m_powf = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  MATH_POW_OK="no"
-fi
-
-
-echo "$as_me:$LINENO: checking for sqrtf in -lm" >&5
-echo $ECHO_N "checking for sqrtf in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_sqrtf+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char sqrtf ();
-int
-main ()
-{
-sqrtf ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_sqrtf=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_sqrtf=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrtf" >&5
-echo "${ECHO_T}$ac_cv_lib_m_sqrtf" >&6
-if test $ac_cv_lib_m_sqrtf = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  MATH_SQRT_OK="no"
-fi
-
-# Check for extended-precision math routines
-elif test "X${FLOAT_TYPE}" = "Xextended"; then
-
-echo "$as_me:$LINENO: checking for fabsl in -lm" >&5
-echo $ECHO_N "checking for fabsl in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_fabsl+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char fabsl ();
-int
-main ()
-{
-fabsl ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_fabsl=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_fabsl=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_fabsl" >&5
-echo "${ECHO_T}$ac_cv_lib_m_fabsl" >&6
-if test $ac_cv_lib_m_fabsl = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  MATH_FABS_OK="no"
-fi
-
-
-echo "$as_me:$LINENO: checking for powl in -lm" >&5
-echo $ECHO_N "checking for powl in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_powl+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char powl ();
-int
-main ()
-{
-powl ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_powl=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_powl=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_powl" >&5
-echo "${ECHO_T}$ac_cv_lib_m_powl" >&6
-if test $ac_cv_lib_m_powl = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  MATH_POW_OK="no"
-fi
-
-
-echo "$as_me:$LINENO: checking for sqrtl in -lm" >&5
-echo $ECHO_N "checking for sqrtl in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_sqrtl+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char sqrtl ();
-int
-main ()
-{
-sqrtl ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_sqrtl=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_sqrtl=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrtl" >&5
-echo "${ECHO_T}$ac_cv_lib_m_sqrtl" >&6
-if test $ac_cv_lib_m_sqrtl = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  MATH_SQRT_OK="no"
-fi
-
-# Check for (generic) double-precision math routines
-elif test "X${FLOAT_TYPE}" = "Xdouble"; then
-
-echo "$as_me:$LINENO: checking for fabs in -lm" >&5
-echo $ECHO_N "checking for fabs in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_fabs+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char fabs ();
-int
-main ()
-{
-fabs ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_fabs=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_fabs=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_fabs" >&5
-echo "${ECHO_T}$ac_cv_lib_m_fabs" >&6
-if test $ac_cv_lib_m_fabs = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  { { echo "$as_me:$LINENO: error: cannot find fabs function" >&5
-echo "$as_me: error: cannot find fabs function" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-
-echo "$as_me:$LINENO: checking for pow in -lm" >&5
-echo $ECHO_N "checking for pow in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_pow+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char pow ();
-int
-main ()
-{
-pow ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_pow=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_pow=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_pow" >&5
-echo "${ECHO_T}$ac_cv_lib_m_pow" >&6
-if test $ac_cv_lib_m_pow = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  { { echo "$as_me:$LINENO: error: cannot find pow function" >&5
-echo "$as_me: error: cannot find pow function" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-
-echo "$as_me:$LINENO: checking for sqrt in -lm" >&5
-echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_sqrt+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char sqrt ();
-int
-main ()
-{
-sqrt ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_sqrt=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_sqrt=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5
-echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6
-if test $ac_cv_lib_m_sqrt = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  { { echo "$as_me:$LINENO: error: cannot find sqrt function" >&5
-echo "$as_me: error: cannot find sqrt function" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-fi
-# If cannot find precision-specific implementations, then check for generic versions
-if test "X${MATH_FABS_OK}" = "Xno" || test "X${MATH_POW_OK}" = "Xno" || test "X${MATH_SQRT_OK}" = "Xno"; then
-
-echo "$as_me:$LINENO: checking for fabs in -lm" >&5
-echo $ECHO_N "checking for fabs in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_fabs+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char fabs ();
-int
-main ()
-{
-fabs ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_fabs=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_fabs=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_fabs" >&5
-echo "${ECHO_T}$ac_cv_lib_m_fabs" >&6
-if test $ac_cv_lib_m_fabs = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  { { echo "$as_me:$LINENO: error: cannot find fabs function" >&5
-echo "$as_me: error: cannot find fabs function" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-
-echo "$as_me:$LINENO: checking for pow in -lm" >&5
-echo $ECHO_N "checking for pow in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_pow+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char pow ();
-int
-main ()
-{
-pow ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_pow=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_pow=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_pow" >&5
-echo "${ECHO_T}$ac_cv_lib_m_pow" >&6
-if test $ac_cv_lib_m_pow = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  { { echo "$as_me:$LINENO: error: cannot find pow function" >&5
-echo "$as_me: error: cannot find pow function" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-
-echo "$as_me:$LINENO: checking for sqrt in -lm" >&5
-echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6
-if test "${ac_cv_lib_m_sqrt+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lm  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char sqrt ();
-int
-main ()
-{
-sqrt ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_m_sqrt=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_m_sqrt=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5
-echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6
-if test $ac_cv_lib_m_sqrt = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBM 1
-_ACEOF
-
-  LIBS="-lm $LIBS"
-
-else
-  { { echo "$as_me:$LINENO: error: cannot find sqrt function" >&5
-echo "$as_me: error: cannot find sqrt function" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-  # If all generic math routines are available, then set SUNDIALS_USE_GENERIC_MATH flag
-  # for use by sundials_math.c file (preprocessor macros)
-  cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_USE_GENERIC_MATH 1
-_ACEOF
-
-  GENERIC_MATH_LIB="#define SUNDIALS_USE_GENERIC_MATH"
-# If found all precision-specific routines, then set SUNDIALS_USE_GENERIC_MATH only if
-# building SUNDIALS libraries with double-precision
-else
-  if test "X${FLOAT_TYPE}" = "Xdouble"; then
-    cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_USE_GENERIC_MATH 1
-_ACEOF
-
-    GENERIC_MATH_LIB="#define SUNDIALS_USE_GENERIC_MATH"
-  else
-    cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_USE_GENERIC_MATH 0
-_ACEOF
-
-  fi
-fi
-
-# Add math library to LIBS environment variable
-LIBS="${TEMP_MATH_LIB}"
-echo "$as_me:$LINENO: checking for additional required C libraries" >&5
-echo $ECHO_N "checking for additional required C libraries... $ECHO_C" >&6
-if test "X${LIBS}" = "X"; then
-  if test "X${SAVED_LIBS}" = "X"; then
-    LIBS=""
-  else
-    LIBS="${SAVED_LIBS}"
-  fi
-  echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-else
-  echo "$as_me:$LINENO: result: ${LIBS}" >&5
-echo "${ECHO_T}${LIBS}" >&6
-  if test "X${SAVED_LIBS}" = "X"; then
-    LIBS="${LIBS}"
-  else
-    LIBS="${LIBS} ${SAVED_LIBS}"
-  fi
-fi
-
-# Check sizeof(int) - used to modify Fortran examples
-echo "$as_me:$LINENO: checking for int" >&5
-echo $ECHO_N "checking for int... $ECHO_C" >&6
-if test "${ac_cv_type_int+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-if ((int *) 0)
-  return 0;
-if (sizeof (int))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_int=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_int=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5
-echo "${ECHO_T}$ac_cv_type_int" >&6
-
-echo "$as_me:$LINENO: checking size of int" >&5
-echo $ECHO_N "checking size of int... $ECHO_C" >&6
-if test "${ac_cv_sizeof_int+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$ac_cv_type_int" = yes; then
-  # The cast to unsigned long works around a bug in the HP C Compiler
-  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-  # This bug is HP SR number 8606223364.
-  if test "$cross_compiling" = yes; then
-  # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr $ac_mid + 1`
-		    if test $ac_lo -le $ac_mid; then
-		      ac_lo= ac_hi=
-		      break
-		    fi
-		    ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_hi=`expr '(' $ac_mid ')' - 1`
-		       if test $ac_mid -le $ac_hi; then
-			 ac_lo= ac_hi=
-			 break
-		       fi
-		       ac_mid=`expr 2 '*' $ac_mid`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo= ac_hi=
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_int=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (int), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; } ;;
-esac
-else
-  if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-long longval () { return (long) (sizeof (int)); }
-unsigned long ulongval () { return (long) (sizeof (int)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    exit (1);
-  if (((long) (sizeof (int))) < 0)
-    {
-      long i = longval ();
-      if (i != ((long) (sizeof (int))))
-	exit (1);
-      fprintf (f, "%ld\n", i);
-    }
-  else
-    {
-      unsigned long i = ulongval ();
-      if (i != ((long) (sizeof (int))))
-	exit (1);
-      fprintf (f, "%lu\n", i);
-    }
-  exit (ferror (f) || fclose (f) != 0);
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_int=`cat conftest.val`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (int), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-rm -f conftest.val
-else
-  ac_cv_sizeof_int=0
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5
-echo "${ECHO_T}$ac_cv_sizeof_int" >&6
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_INT $ac_cv_sizeof_int
-_ACEOF
-
-
-
-# Check sizeof(long int) - used to modify Fortran examples
-echo "$as_me:$LINENO: checking for long int" >&5
-echo $ECHO_N "checking for long int... $ECHO_C" >&6
-if test "${ac_cv_type_long_int+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-if ((long int *) 0)
-  return 0;
-if (sizeof (long int))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_long_int=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_long_int=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_long_int" >&5
-echo "${ECHO_T}$ac_cv_type_long_int" >&6
-
-echo "$as_me:$LINENO: checking size of long int" >&5
-echo $ECHO_N "checking size of long int... $ECHO_C" >&6
-if test "${ac_cv_sizeof_long_int+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$ac_cv_type_long_int" = yes; then
-  # The cast to unsigned long works around a bug in the HP C Compiler
-  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-  # This bug is HP SR number 8606223364.
-  if test "$cross_compiling" = yes; then
-  # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long int))) >= 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long int))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr $ac_mid + 1`
-		    if test $ac_lo -le $ac_mid; then
-		      ac_lo= ac_hi=
-		      break
-		    fi
-		    ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long int))) < 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long int))) >= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_hi=`expr '(' $ac_mid ')' - 1`
-		       if test $ac_mid -le $ac_hi; then
-			 ac_lo= ac_hi=
-			 break
-		       fi
-		       ac_mid=`expr 2 '*' $ac_mid`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo= ac_hi=
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long int))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_long_int=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long int), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long int), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; } ;;
-esac
-else
-  if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-long longval () { return (long) (sizeof (long int)); }
-unsigned long ulongval () { return (long) (sizeof (long int)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    exit (1);
-  if (((long) (sizeof (long int))) < 0)
-    {
-      long i = longval ();
-      if (i != ((long) (sizeof (long int))))
-	exit (1);
-      fprintf (f, "%ld\n", i);
-    }
-  else
-    {
-      unsigned long i = ulongval ();
-      if (i != ((long) (sizeof (long int))))
-	exit (1);
-      fprintf (f, "%lu\n", i);
-    }
-  exit (ferror (f) || fclose (f) != 0);
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_long_int=`cat conftest.val`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long int), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long int), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-rm -f conftest.val
-else
-  ac_cv_sizeof_long_int=0
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_int" >&5
-echo "${ECHO_T}$ac_cv_sizeof_long_int" >&6
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_LONG_INT $ac_cv_sizeof_long_int
-_ACEOF
-
-
-
-# Check sizeof(realtype), where realtype is either float, double
-# or long double - used to modify Fortran examples
-if test "X${FLOAT_TYPE}" = "Xsingle"; then
-  echo "$as_me:$LINENO: checking for float" >&5
-echo $ECHO_N "checking for float... $ECHO_C" >&6
-if test "${ac_cv_type_float+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-if ((float *) 0)
-  return 0;
-if (sizeof (float))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_float=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_float=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_float" >&5
-echo "${ECHO_T}$ac_cv_type_float" >&6
-
-echo "$as_me:$LINENO: checking size of float" >&5
-echo $ECHO_N "checking size of float... $ECHO_C" >&6
-if test "${ac_cv_sizeof_float+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$ac_cv_type_float" = yes; then
-  # The cast to unsigned long works around a bug in the HP C Compiler
-  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-  # This bug is HP SR number 8606223364.
-  if test "$cross_compiling" = yes; then
-  # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (float))) >= 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (float))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr $ac_mid + 1`
-		    if test $ac_lo -le $ac_mid; then
-		      ac_lo= ac_hi=
-		      break
-		    fi
-		    ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (float))) < 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (float))) >= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_hi=`expr '(' $ac_mid ')' - 1`
-		       if test $ac_mid -le $ac_hi; then
-			 ac_lo= ac_hi=
-			 break
-		       fi
-		       ac_mid=`expr 2 '*' $ac_mid`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo= ac_hi=
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (float))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_float=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (float), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (float), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; } ;;
-esac
-else
-  if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-long longval () { return (long) (sizeof (float)); }
-unsigned long ulongval () { return (long) (sizeof (float)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    exit (1);
-  if (((long) (sizeof (float))) < 0)
-    {
-      long i = longval ();
-      if (i != ((long) (sizeof (float))))
-	exit (1);
-      fprintf (f, "%ld\n", i);
-    }
-  else
-    {
-      unsigned long i = ulongval ();
-      if (i != ((long) (sizeof (float))))
-	exit (1);
-      fprintf (f, "%lu\n", i);
-    }
-  exit (ferror (f) || fclose (f) != 0);
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_float=`cat conftest.val`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (float), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (float), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-rm -f conftest.val
-else
-  ac_cv_sizeof_float=0
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5
-echo "${ECHO_T}$ac_cv_sizeof_float" >&6
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_FLOAT $ac_cv_sizeof_float
-_ACEOF
-
-
-elif test "X${FLOAT_TYPE}" = "Xdouble"; then
-  echo "$as_me:$LINENO: checking for double" >&5
-echo $ECHO_N "checking for double... $ECHO_C" >&6
-if test "${ac_cv_type_double+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-if ((double *) 0)
-  return 0;
-if (sizeof (double))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_double=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_double=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5
-echo "${ECHO_T}$ac_cv_type_double" >&6
-
-echo "$as_me:$LINENO: checking size of double" >&5
-echo $ECHO_N "checking size of double... $ECHO_C" >&6
-if test "${ac_cv_sizeof_double+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$ac_cv_type_double" = yes; then
-  # The cast to unsigned long works around a bug in the HP C Compiler
-  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-  # This bug is HP SR number 8606223364.
-  if test "$cross_compiling" = yes; then
-  # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (double))) >= 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (double))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr $ac_mid + 1`
-		    if test $ac_lo -le $ac_mid; then
-		      ac_lo= ac_hi=
-		      break
-		    fi
-		    ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (double))) < 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (double))) >= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_hi=`expr '(' $ac_mid ')' - 1`
-		       if test $ac_mid -le $ac_hi; then
-			 ac_lo= ac_hi=
-			 break
-		       fi
-		       ac_mid=`expr 2 '*' $ac_mid`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo= ac_hi=
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (double))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_double=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (double), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (double), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; } ;;
-esac
-else
-  if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-long longval () { return (long) (sizeof (double)); }
-unsigned long ulongval () { return (long) (sizeof (double)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    exit (1);
-  if (((long) (sizeof (double))) < 0)
-    {
-      long i = longval ();
-      if (i != ((long) (sizeof (double))))
-	exit (1);
-      fprintf (f, "%ld\n", i);
-    }
-  else
-    {
-      unsigned long i = ulongval ();
-      if (i != ((long) (sizeof (double))))
-	exit (1);
-      fprintf (f, "%lu\n", i);
-    }
-  exit (ferror (f) || fclose (f) != 0);
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_double=`cat conftest.val`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (double), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (double), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-rm -f conftest.val
-else
-  ac_cv_sizeof_double=0
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5
-echo "${ECHO_T}$ac_cv_sizeof_double" >&6
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_DOUBLE $ac_cv_sizeof_double
-_ACEOF
-
-
-elif test "X${FLOAT_TYPE}" = "Xextended"; then
-  echo "$as_me:$LINENO: checking for long double" >&5
-echo $ECHO_N "checking for long double... $ECHO_C" >&6
-if test "${ac_cv_type_long_double+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-if ((long double *) 0)
-  return 0;
-if (sizeof (long double))
-  return 0;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_type_long_double=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_long_double=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_long_double" >&5
-echo "${ECHO_T}$ac_cv_type_long_double" >&6
-
-echo "$as_me:$LINENO: checking size of long double" >&5
-echo $ECHO_N "checking size of long double... $ECHO_C" >&6
-if test "${ac_cv_sizeof_long_double+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "$ac_cv_type_long_double" = yes; then
-  # The cast to unsigned long works around a bug in the HP C Compiler
-  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-  # This bug is HP SR number 8606223364.
-  if test "$cross_compiling" = yes; then
-  # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long double))) >= 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long double))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr $ac_mid + 1`
-		    if test $ac_lo -le $ac_mid; then
-		      ac_lo= ac_hi=
-		      break
-		    fi
-		    ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long double))) < 0)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long double))) >= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_lo=$ac_mid; break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_hi=`expr '(' $ac_mid ')' - 1`
-		       if test $ac_mid -le $ac_hi; then
-			 ac_lo= ac_hi=
-			 break
-		       fi
-		       ac_mid=`expr 2 '*' $ac_mid`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo= ac_hi=
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long double))) <= $ac_mid)];
-test_array [0] = 0
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_hi=$ac_mid
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_long_double=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long double), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long double), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; } ;;
-esac
-else
-  if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-long longval () { return (long) (sizeof (long double)); }
-unsigned long ulongval () { return (long) (sizeof (long double)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    exit (1);
-  if (((long) (sizeof (long double))) < 0)
-    {
-      long i = longval ();
-      if (i != ((long) (sizeof (long double))))
-	exit (1);
-      fprintf (f, "%ld\n", i);
-    }
-  else
-    {
-      unsigned long i = ulongval ();
-      if (i != ((long) (sizeof (long double))))
-	exit (1);
-      fprintf (f, "%lu\n", i);
-    }
-  exit (ferror (f) || fclose (f) != 0);
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_sizeof_long_double=`cat conftest.val`
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long double), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long double), 77
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-rm -f conftest.val
-else
-  ac_cv_sizeof_long_double=0
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_double" >&5
-echo "${ECHO_T}$ac_cv_sizeof_long_double" >&6
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_LONG_DOUBLE $ac_cv_sizeof_long_double
-_ACEOF
-
-
-fi
-
-# Defines EGREP and exports via AC_SUBST - used by FCMIX Makefile's
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
-    then ac_cv_prog_egrep='grep -E'
-    else ac_cv_prog_egrep='egrep'
-    fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
-
-
-
-# Defines FGREP and exports via AC_SUBST - used by FCMIX Makefile's
-echo "$as_me:$LINENO: checking for fgrep" >&5
-echo $ECHO_N "checking for fgrep... $ECHO_C" >&6
-if test "${ac_cv_prog_fgrep+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if echo 'ab*c' | (grep -F 'ab*c') >/dev/null 2>&1
-    then ac_cv_prog_fgrep='grep -F'
-    else ac_cv_prog_fgrep='fgrep'
-    fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_fgrep" >&5
-echo "${ECHO_T}$ac_cv_prog_fgrep" >&6
- FGREP=$ac_cv_prog_fgrep
-
-
-
-# Check if CC is a C++ compiler
-# Note: If CC is a C++ compiler and MPI is enabled, then we will
-# check for "mpiCC" instead of "mpicc" if an MPI compiler was NOT specified
-
-
-# Rename argument
-COMP_NAME="${CC}"
-
-# Update the language stack
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Check if using a C++ compiler
-echo "$as_me:$LINENO: checking if ${COMP_NAME} is a C++ compiler" >&5
-echo $ECHO_N "checking if ${COMP_NAME} is a C++ compiler... $ECHO_C" >&6
-if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-#ifdef __cplusplus
-  return(0);
-#else
-  return(1);
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-# COMP_NAME is a C++ compiler
-USING_CPLUSPLUS_COMP="yes"
-
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-# COMP_NAMPE is NOT a C++ compiler
-USING_CPLUSPLUS_COMP="no"
-
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-# Revert back to previous language
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-fi
-
-
-
-# Set Fortran support
-if test "X${FCMIX_ENABLED}" = "Xyes" || test "X${LAPACK_ENABLED}" = "Xyes"; then
-  echo ""
-  echo "Fortran Settings"
-  echo "----------------"
-  echo ""
-
-
-
-F77_OK="yes"
-
-# Look for a F77 compiler
-# If unsuccessful, disable all Fortran support
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in f77 g77
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$F77"; then
-  ac_cv_prog_F77="$F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-F77=$ac_cv_prog_F77
-if test -n "$F77"; then
-  echo "$as_me:$LINENO: result: $F77" >&5
-echo "${ECHO_T}$F77" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-    test -n "$F77" && break
-  done
-fi
-if test -z "$F77"; then
-  ac_ct_F77=$F77
-  for ac_prog in f77 g77
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_F77"; then
-  ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_F77="$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-ac_ct_F77=$ac_cv_prog_ac_ct_F77
-if test -n "$ac_ct_F77"; then
-  echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
-echo "${ECHO_T}$ac_ct_F77" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  test -n "$ac_ct_F77" && break
-done
-
-  F77=$ac_ct_F77
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:7176:" \
-     "checking for Fortran 77 compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-rm -f a.out
-
-# If we don't use `.F' as extension, the preprocessor is not run on the
-# input file.  (Note that this only needs to work for GNU compilers.)
-ac_save_ext=$ac_ext
-ac_ext=F
-echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6
-if test "${ac_cv_f77_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-      program main
-#ifndef __GNUC__
-       choke me
-#endif
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_compiler_gnu=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_f77_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6
-ac_ext=$ac_save_ext
-ac_test_FFLAGS=${FFLAGS+set}
-ac_save_FFLAGS=$FFLAGS
-FFLAGS=
-echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
-echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_f77_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  FFLAGS=-g
-cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_f77_g=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_f77_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
-echo "${ECHO_T}$ac_cv_prog_f77_g" >&6
-if test "$ac_test_FFLAGS" = set; then
-  FFLAGS=$ac_save_FFLAGS
-elif test $ac_cv_prog_f77_g = yes; then
-  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
-    FFLAGS="-g -O2"
-  else
-    FFLAGS="-g"
-  fi
-else
-  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
-    FFLAGS="-O2"
-  else
-    FFLAGS=
-  fi
-fi
-
-G77=`test $ac_compiler_gnu = yes && echo yes`
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-if test "X${F77}" = "X"; then
-
-  F77_OK="no"
-  SUNDIALS_WARN_FLAG="yes"
-
-  echo ""
-  echo "   Unable to find a working Fortran compiler"
-  echo ""
-  echo "   Try using F77 to explicitly specify a C compiler"
-  echo ""
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    echo "   Disabling compilation of Fortran-C interfaces..."
-  fi
-  if test "X${LAPACK_ENABLED}" = "Xyes"; then
-    echo "   Disabling compilation of Blas/Lapack interfaces..."
-  fi
-  echo ""
-
-  FCMIX_ENABLED="no"
-  LAPACK_ENABLED="no"
-  F77_EXAMPLES_ENABLED="no"
-
-fi
-
-# Check Fortran compiler
-# If unsuccessful, disable all Fortran support
-
-if test "X${F77_OK}" = "Xyes"; then
-
-
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-# Add any additional FFLAGS
-echo "$as_me:$LINENO: checking for extra Fortran compiler flags" >&5
-echo $ECHO_N "checking for extra Fortran compiler flags... $ECHO_C" >&6
-
-# Check whether --with-fflags or --without-fflags was given.
-if test "${with_fflags+set}" = set; then
-  withval="$with_fflags"
-
-echo "$as_me:$LINENO: result: ${withval}" >&5
-echo "${ECHO_T}${withval}" >&6
-FFLAGS="${FFLAGS} ${withval}"
-
-else
-
-echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-
-fi;
-
-# Add any required linker flags to FLIBS
-# Note: if FLIBS is defined, it is left unchanged
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-echo "$as_me:$LINENO: checking how to get verbose linking output from $F77" >&5
-echo $ECHO_N "checking how to get verbose linking output from $F77... $ECHO_C" >&6
-if test "${ac_cv_prog_f77_v+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_f77_v=
-# Try some options frequently used verbose output
-for ac_verb in -v -verbose --verbose -V -\#\#\#; do
-  cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-
-# Compile and link our simple test program by passing a flag (argument
-# 1 to this macro) to the Fortran compiler in order to get
-# "verbose" output that we can then parse for the Fortran linker
-# flags.
-ac_save_FFLAGS=$FFLAGS
-FFLAGS="$FFLAGS $ac_verb"
-(eval echo $as_me:7431: \"$ac_link\") >&5
-ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'`
-echo "$ac_f77_v_output" >&5
-FFLAGS=$ac_save_FFLAGS
-
-rm -f conftest*
-
-# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
-# /foo, /bar, and /baz are search directories for the Fortran linker.
-# Here, we change these into -L/foo -L/bar -L/baz (and put it first):
-ac_f77_v_output="`echo $ac_f77_v_output |
-	grep 'LPATH is:' |
-	sed 's,.*LPATH is\(: *[^ ]*\).*,\1,;s,: */, -L/,g'` $ac_f77_v_output"
-
-case $ac_f77_v_output in
-  # If we are using xlf then replace all the commas with spaces.
-  *xlfentry*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/,/ /g'` ;;
-
-  # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
-  # $LIBS confuse us, and the libraries appear later in the output anyway).
-  *mGLOB_options_string*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/"-mGLOB[^"]*"/ /g'` ;;
-
-  # Portland Group compiler has quoted -cmdline argument
-  *-cmdline*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed "s/-cmdline '[^']*'/ /g"`  ;;
-
-  # If we are using Cray Fortran then delete quotes.
-  # Use "\"" instead of '"' for font-lock-mode.
-  # FIXME: a more general fix for quoted arguments with spaces?
-  *cft90*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed "s/\"//g"` ;;
-esac
-
-
-  # look for -l* and *.a constructs in the output
-  for ac_arg in $ac_f77_v_output; do
-     case $ac_arg in
-        [\\/]*.a | ?:[\\/]*.a | -[lLRu]*)
-          ac_cv_prog_f77_v=$ac_verb
-          break 2 ;;
-     esac
-  done
-done
-if test -z "$ac_cv_prog_f77_v"; then
-   { echo "$as_me:$LINENO: WARNING: cannot determine how to obtain linking information from $F77" >&5
-echo "$as_me: WARNING: cannot determine how to obtain linking information from $F77" >&2;}
-fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ echo "$as_me:$LINENO: WARNING: compilation failed" >&5
-echo "$as_me: WARNING: compilation failed" >&2;}
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_f77_v" >&5
-echo "${ECHO_T}$ac_cv_prog_f77_v" >&6
-echo "$as_me:$LINENO: checking for Fortran libraries of $F77" >&5
-echo $ECHO_N "checking for Fortran libraries of $F77... $ECHO_C" >&6
-if test "${ac_cv_f77_libs+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test "x$FLIBS" != "x"; then
-  ac_cv_f77_libs="$FLIBS" # Let the user override the test.
-else
-
-cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-
-# Compile and link our simple test program by passing a flag (argument
-# 1 to this macro) to the Fortran compiler in order to get
-# "verbose" output that we can then parse for the Fortran linker
-# flags.
-ac_save_FFLAGS=$FFLAGS
-FFLAGS="$FFLAGS $ac_cv_prog_f77_v"
-(eval echo $as_me:7513: \"$ac_link\") >&5
-ac_f77_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'`
-echo "$ac_f77_v_output" >&5
-FFLAGS=$ac_save_FFLAGS
-
-rm -f conftest*
-
-# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
-# /foo, /bar, and /baz are search directories for the Fortran linker.
-# Here, we change these into -L/foo -L/bar -L/baz (and put it first):
-ac_f77_v_output="`echo $ac_f77_v_output |
-	grep 'LPATH is:' |
-	sed 's,.*LPATH is\(: *[^ ]*\).*,\1,;s,: */, -L/,g'` $ac_f77_v_output"
-
-case $ac_f77_v_output in
-  # If we are using xlf then replace all the commas with spaces.
-  *xlfentry*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/,/ /g'` ;;
-
-  # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
-  # $LIBS confuse us, and the libraries appear later in the output anyway).
-  *mGLOB_options_string*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/"-mGLOB[^"]*"/ /g'` ;;
-
-  # Portland Group compiler has quoted -cmdline argument
-  *-cmdline*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed "s/-cmdline '[^']*'/ /g"`  ;;
-
-  # If we are using Cray Fortran then delete quotes.
-  # Use "\"" instead of '"' for font-lock-mode.
-  # FIXME: a more general fix for quoted arguments with spaces?
-  *cft90*)
-    ac_f77_v_output=`echo $ac_f77_v_output | sed "s/\"//g"` ;;
-esac
-
-
-
-ac_cv_f77_libs=
-
-# Save positional arguments (if any)
-ac_save_positional="$@"
-
-set X $ac_f77_v_output
-while test $# != 1; do
-  shift
-  ac_arg=$1
-  case $ac_arg in
-        [\\/]*.a | ?:[\\/]*.a)
-            ac_exists=false
-  for ac_i in $ac_cv_f77_libs; do
-    if test x"$ac_arg" = x"$ac_i"; then
-      ac_exists=true
-      break
-    fi
-  done
-
-  if test x"$ac_exists" = xtrue; then
-  :
-else
-  ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
-fi
-
-          ;;
-        -bI:*)
-            ac_exists=false
-  for ac_i in $ac_cv_f77_libs; do
-    if test x"$ac_arg" = x"$ac_i"; then
-      ac_exists=true
-      break
-    fi
-  done
-
-  if test x"$ac_exists" = xtrue; then
-  :
-else
-  if test "$ac_compiler_gnu" = yes; then
-  for ac_link_opt in $ac_arg; do
-    ac_cv_f77_libs="$ac_cv_f77_libs -Xlinker $ac_link_opt"
-  done
-else
-  ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
-fi
-fi
-
-          ;;
-          # Ignore these flags.
-        -lang* | -lcrt[01].o | -lcrtbegin.o | -lc | -lgcc | -libmil | -LANG:=*)
-          ;;
-        -lkernel32)
-          test x"$CYGWIN" != xyes && ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
-          ;;
-        -[LRuY])
-          # These flags, when seen by themselves, take an argument.
-          # We remove the space between option and argument and re-iterate
-          # unless we find an empty arg or a new option (starting with -)
-	  case $2 in
-	     "" | -*);;
-	     *)
-		ac_arg="$ac_arg$2"
-		shift; shift
-		set X $ac_arg "$@"
-		;;
-	  esac
-          ;;
-        -YP,*)
-          for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
-              ac_exists=false
-  for ac_i in $ac_cv_f77_libs; do
-    if test x"$ac_j" = x"$ac_i"; then
-      ac_exists=true
-      break
-    fi
-  done
-
-  if test x"$ac_exists" = xtrue; then
-  :
-else
-  ac_arg="$ac_arg $ac_j"
-                               ac_cv_f77_libs="$ac_cv_f77_libs $ac_j"
-fi
-
-          done
-          ;;
-        -[lLR]*)
-            ac_exists=false
-  for ac_i in $ac_cv_f77_libs; do
-    if test x"$ac_arg" = x"$ac_i"; then
-      ac_exists=true
-      break
-    fi
-  done
-
-  if test x"$ac_exists" = xtrue; then
-  :
-else
-  ac_cv_f77_libs="$ac_cv_f77_libs $ac_arg"
-fi
-
-          ;;
-          # Ignore everything else.
-  esac
-done
-# restore positional arguments
-set X $ac_save_positional; shift
-
-# We only consider "LD_RUN_PATH" on Solaris systems.  If this is seen,
-# then we insist that the "run path" must be an absolute path (i.e. it
-# must begin with a "/").
-case `(uname -sr) 2>/dev/null` in
-   "SunOS 5"*)
-      ac_ld_run_path=`echo $ac_f77_v_output |
-                        sed -n 's,^.*LD_RUN_PATH *= *\(/[^ ]*\).*$,-R\1,p'`
-      test "x$ac_ld_run_path" != x &&
-        if test "$ac_compiler_gnu" = yes; then
-  for ac_link_opt in $ac_ld_run_path; do
-    ac_cv_f77_libs="$ac_cv_f77_libs -Xlinker $ac_link_opt"
-  done
-else
-  ac_cv_f77_libs="$ac_cv_f77_libs $ac_ld_run_path"
-fi
-      ;;
-esac
-fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_f77_libs" >&5
-echo "${ECHO_T}$ac_cv_f77_libs" >&6
-FLIBS="$ac_cv_f77_libs"
-
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-# Try to compile a simple Fortran program (no linking)
-cat >conftest.$ac_ext <<_ACEOF
-
-	SUBROUTINE SUNDIALS()
-	RETURN
-	END
-
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  F77_OK="yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-F77_OK="no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-# If CC is a C++ compiler (decided in SUNDIALS_CPLUSPLUS_CHECK), we must use
-# it to link the Fortran examples. In this case, test if that is successful.
-# Otherwise, simply use F77 as the linker
-
-if test "X${F77_OK}" = "Xyes"; then
-  echo "$as_me:$LINENO: checking which linker to use" >&5
-echo $ECHO_N "checking which linker to use... $ECHO_C" >&6
-  if test "X${USING_CPLUSPLUS_COMP}" = "Xyes"; then
-
-
-F77_LNKR_CHECK_OK="no"
-
-# Compile simple Fortran example, but do NOT link
-# Note: result stored as conftest.${ac_objext}
-cat >conftest.$ac_ext <<_ACEOF
-
-	PROGRAM SUNDIALS
-	WRITE(*,*)'TEST'
-	END
-
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-
-# Temporarily reset LIBS environment variable to perform test
-SAVED_LIBS="${LIBS}"
-LIBS="${LIBS} ${FLIBS}"
-
-# Switch working language to C for next test
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Check if CC can link Fortran example
-# Note: AC_LINKONLY_IFELSE is a custom macro (modifications made to
-# general.m4 and c.m4) (see config/cust_general.m4 and config/mod_c.m4)
-if { (eval echo "$as_me:$LINENO: \"$ac_linkonly\"") >&5
-  (eval $ac_linkonly) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  F77_LNKR_CHECK_OK="yes"
-else
-  echo "$as_me: failed program was:" >&5
-if test -f conftest.c ; then
-  sed 's/^/| /' conftest.c >&5
-elif test -f conftest.cc ; then
-  sed 's/^/| /' conftest.cc >&5
-elif test -f conftest.f ; then
-  sed 's/^/| /' conftest.f >&5
-elif test -f conftest.${FC_SRCEXT-f} ; then
-  sed 's/^/| /' conftest.${FC_SRCEXT-f} >&5
-fi
-
-F77_LNKR_CHECK_OK="no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext
-
-# Revert back to previous language (Fortran 77)
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-# Set LIBS environment variable back to original value
-LIBS="${SAVED_LIBS}"
-
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-# If either the compilation or the linking failed, we should
-# disable building the Fortran examples
-# For now, use F77 as the linker...
-if test "X${F77_LNKR_CHECK_OK}" = "Xyes"; then
-  F77_LNKR="${CC}"
-else
-  F77_LNKR="${F77}"
-fi
-
-
-  else
-    F77_LNKR="${F77}"
-  fi
-  echo "$as_me:$LINENO: result: ${F77_LNKR}" >&5
-echo "${ECHO_T}${F77_LNKR}" >&6
-fi
-
-# Reset language (remove 'Fortran 77' from stack)
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-  if test "X${F77_OK}" = "Xno"; then
-
-    SUNDIALS_WARN_FLAG="yes"
-
-    echo ""
-    echo "   Unable to compile test program using given Fortran compiler."
-    echo ""
-    if test "X${FCMIX_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Fortran-C interfaces..."
-    fi
-    if test "X${LAPACK_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Blas/Lapack interfaces..."
-    fi
-    echo ""
-
-    FCMIX_ENABLED="no"
-    LAPACK_ENABLED="no"
-    F77_EXAMPLES_ENABLED="no"
-
-  fi
-
-fi
-
-
-# Determine the Fortran name-mangling scheme
-# If successfull, provide variable description templates for config.hin
-# and config.h files required by autoheader utility
-# Otherwise, disable all Fortran support.
-
-if test "X${F77_OK}" = "Xyes"; then
-
-
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-# (1) Compile a dummy Fortran subroutine named SUNDIALS
-
-FNAME_STATUS="none"
-
-cat >conftest.$ac_ext <<_ACEOF
-
-	SUBROUTINE SUNDIALS()
-	RETURN
-	END
-
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-
-  mv conftest.${ac_objext} f77_wrapper_check.${ac_objext}
-
-  # Temporarily reset LIBS environment variable to perform test
-  SAVED_LIBS="${LIBS}"
-  LIBS="f77_wrapper_check.${ac_objext} ${LIBS} ${FLIBS}"
-
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-  for i in "sundials" "SUNDIALS"
-  do
-    for j in "" "_" "__"
-    do
-      F77_MANGLED_NAME="${i}${j}"
-      cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char ${F77_MANGLED_NAME} ();
-int
-main ()
-{
-${F77_MANGLED_NAME} ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  FNAME_STATUS="set" ; break 2
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-    done
-  done
-
-  ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-  # If test succeeded, then set the F77_MANGLE_MACRO1 macro
-
-  if test "X${FNAME_STATUS}" = "Xset"; then
-
-    if test "X${i}" = "Xsundials"; then
-
-      FNAME_MSG="lower case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC(name,NAME) name
-_ACEOF
-
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name"
-        dgemm="dgemm"
-        dgetrf="dgetrf"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC(name,NAME) name ## _
-_ACEOF
-
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name ## _"
-        dgemm="dgemm_"
-        dgetrf="dgetrf_"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC(name,NAME) name ## __
-_ACEOF
-
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) name ## __"
-        dgemm="dgemm__"
-        dgetrf="dgetrf__"
-      fi
-
-    else
-
-      FNAME_MSG="upper case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC(name,NAME) name
-_ACEOF
-
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) NAME"
-        dgemm="DGEMM"
-        dgetrf="DGETRF"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC(name,NAME) name ## _
-_ACEOF
-
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) NAME ## _"
-        dgemm="DGEMM_"
-        dgetrf="DGETRF_"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC(name,NAME) name ## __
-_ACEOF
-
-        F77_MANGLE_MACRO1="#define SUNDIALS_F77_FUNC(name,NAME) NAME ## __"
-        dgemm="DGEMM__"
-        dgetrf="DGETRF__"
-      fi
-
-    fi
-
-    echo "$as_me:$LINENO: checking for Fortran name-mangling scheme of C identifiers" >&5
-echo $ECHO_N "checking for Fortran name-mangling scheme of C identifiers... $ECHO_C" >&6
-    echo "$as_me:$LINENO: result: ${FNAME_MSG}" >&5
-echo "${ECHO_T}${FNAME_MSG}" >&6
-
-  else
-
-    F77_OK="no"
-
-  fi
-
-  # Set LIBS environment variable back to original value
-  LIBS="${SAVED_LIBS}"
-
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-# Remove temporary file
-rm -f f77_wrapper_check.${ac_objext}
-
-
-# (2) Compile a dummy Fortran subroutine named SUN_DIALS
-
-FNAME_STATUS="none"
-
-cat >conftest.$ac_ext <<_ACEOF
-
-	SUBROUTINE SUN_DIALS()
-	RETURN
-	END
-
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-
-  mv conftest.${ac_objext} f77_wrapper_check.${ac_objext}
-
-  # Temporarily reset LIBS environment variable to perform test
-  SAVED_LIBS="${LIBS}"
-  LIBS="f77_wrapper_check.${ac_objext} ${LIBS} ${FLIBS}"
-
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-  for i in "sun_dials" "SUN_DIALS"
-  do
-    for j in "" "_" "__"
-    do
-      F77_MANGLED_NAME="${i}${j}"
-      cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char ${F77_MANGLED_NAME} ();
-int
-main ()
-{
-${F77_MANGLED_NAME} ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  FNAME_STATUS="set" ; break 2
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-    done
-  done
-
-  ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-  # If test succeeded, then set the F77_MANGLE_MACRO2 macro
-
-  if test "X${FNAME_STATUS}" = "Xset"; then
-
-    if test "X${i}" = "Xsun_dials"; then
-
-      FNAME_MSG="lower case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC_(name,NAME) name
-_ACEOF
-
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) name"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC_(name,NAME) name ## _
-_ACEOF
-
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) name ## _"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC_(name,NAME) name ## __
-_ACEOF
-
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) name ## __"
-      fi
-
-    else
-
-      FNAME_MSG="upper case "
-
-      if test "X${j}" = "X"; then
-        FNAME_MSG="${FNAME_MSG} + no underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC_(name,NAME) name
-_ACEOF
-
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) NAME"
-      elif test "X${j}" = "X_"; then
-        FNAME_MSG="${FNAME_MSG} + one underscore"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC_(name,NAME) name ## _
-_ACEOF
-
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## _"
-      else
-        FNAME_MSG="${FNAME_MSG} + two underscores"
-        cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_F77_FUNC_(name,NAME) name ## __
-_ACEOF
-
-        F77_MANGLE_MACRO2="#define SUNDIALS_F77_FUNC_(name,NAME) NAME ## __"
-      fi
-
-    fi
-
-    echo "$as_me:$LINENO: checking for Fortran name-mangling scheme of C identifiers with underscores" >&5
-echo $ECHO_N "checking for Fortran name-mangling scheme of C identifiers with underscores... $ECHO_C" >&6
-    echo "$as_me:$LINENO: result: ${FNAME_MSG}" >&5
-echo "${ECHO_T}${FNAME_MSG}" >&6
-
-  else
-
-    F77_OK="no"
-
-  fi
-
-  # Set LIBS environment variable back to original value
-  LIBS="${SAVED_LIBS}"
-
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-# Remove temporary file
-rm -f f77_wrapper_check.${ac_objext}
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-
-
-
-  if test "X${F77_OK}" = "Xno"; then
-
-    SUNDIALS_WARN_FLAG="yes"
-
-    echo ""
-    echo "   Unable to determine Fortran name-mangling scheme."
-    echo ""
-    if test "X${FCMIX_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Fortran-C interfaces..."
-    fi
-    if test "X${LAPACK_ENABLED}" = "Xyes"; then
-      echo "   Disabling compilation of Blas/Lapack interfaces..."
-    fi
-    echo ""
-
-    F77_EXAMPLES_ENABLED="no"
-    FCMIX_ENABLED="no"
-    LAPACK_ENABLED="no"
-
-  fi
-
-fi
-
-
-# If LAPACK is enabled, determine the proper library linkage
-# If successful, set the libaries
-# Otherwise, disable all Blas/Lapack support.
-
-if test "X${LAPACK_ENABLED}" = "Xyes" && test "X${F77_OK}" = "Xyes"; then
-
-
-
-
-# Check if the user specifies Blas libraries
-
-# Check whether --with-blas or --without-blas was given.
-if test "${with_blas+set}" = set; then
-  withval="$with_blas"
-
-  case $withval in
-    -* | */* | *.a | *.so | *.so.* | *.o)
-        BLAS_LIBS="$withval"
-        ;;
-    *)
-        BLAS_LIBS="-l$withval"
-        ;;
-  esac
-
-fi;
-
-# Check if the user specifies Lapack libraries
-
-# Check whether --with-lapack or --without-lapack was given.
-if test "${with_lapack+set}" = set; then
-  withval="$with_lapack"
-
-  case $withval in
-    -* | */* | *.a | *.so | *.so.* | *.o)
-        LAPACK_LIBS="$withval"
-        ;;
-    *)
-        LAPACK_LIBS="-l$withval"
-        ;;
-  esac
-
-fi;
-
-acx_blas_ok=no
-acx_lapack_ok=no
-
-# BLAS_LIBS
-# ---------
-
-acx_blas_save_LIBS="$LIBS"
-LIBS="$LIBS $FLIBS"
-
-# First, check BLAS_LIBS environment variable
-if test "x$BLAS_LIBS" != x; then
-  save_LIBS="$LIBS"
-  LIBS="$BLAS_LIBS $LIBS"
-  echo "$as_me:$LINENO: checking aha for $dgemm in $BLAS_LIBS" >&5
-echo $ECHO_N "checking aha for $dgemm in $BLAS_LIBS... $ECHO_C" >&6
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  acx_blas_ok=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-BLAS_LIBS=""
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-  echo "$as_me:$LINENO: result: $acx_blas_ok" >&5
-echo "${ECHO_T}$acx_blas_ok" >&6
-  LIBS="$save_LIBS"
-fi
-
-# BLAS linked to by default?  (happens on some supercomputers)
-if test $acx_blas_ok = no; then
-  save_LIBS="$LIBS"; LIBS="$LIBS"
-  as_ac_var=`echo "ac_cv_func_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm" >&5
-echo $ECHO_N "checking for $dgemm... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $dgemm to an innocuous variant, in case <limits.h> declares $dgemm.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $dgemm innocuous_$dgemm
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $dgemm (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $dgemm
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$dgemm) || defined (__stub___$dgemm)
-choke me
-#else
-char (*f) () = $dgemm;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $dgemm;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  acx_blas_ok=yes
-fi
-
-  LIBS="$save_LIBS"
-fi
-
-# BLAS in Alpha CXML library?
-if test $acx_blas_ok = no; then
-  as_ac_Lib=`echo "ac_cv_lib_cxml_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -lcxml" >&5
-echo $ECHO_N "checking for $dgemm in -lcxml... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcxml  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  acx_blas_ok=yes;BLAS_LIBS="-lcxml"
-fi
-
-fi
-
-# BLAS in Alpha DXML library? (now called CXML, see above)
-if test $acx_blas_ok = no; then
-  as_ac_Lib=`echo "ac_cv_lib_dxml_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -ldxml" >&5
-echo $ECHO_N "checking for $dgemm in -ldxml... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldxml  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  acx_blas_ok=yes;BLAS_LIBS="-ldxml"
-fi
-
-fi
-
-# BLAS in Sun Performance library?
-if test $acx_blas_ok = no; then
-  if test "x$GCC" != xyes; then # only works with Sun CC
-    echo "$as_me:$LINENO: checking for acosp in -lsunmath" >&5
-echo $ECHO_N "checking for acosp in -lsunmath... $ECHO_C" >&6
-if test "${ac_cv_lib_sunmath_acosp+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsunmath  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char acosp ();
-int
-main ()
-{
-acosp ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_sunmath_acosp=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_sunmath_acosp=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_sunmath_acosp" >&5
-echo "${ECHO_T}$ac_cv_lib_sunmath_acosp" >&6
-if test $ac_cv_lib_sunmath_acosp = yes; then
-  as_ac_Lib=`echo "ac_cv_lib_sunperf_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -lsunperf" >&5
-echo $ECHO_N "checking for $dgemm in -lsunperf... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsunperf -lsunmath $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  BLAS_LIBS="-xlic_lib=sunperf -lsunmath"
-                                acx_blas_ok=yes
-fi
-
-fi
-
-  fi
-fi
-
-# BLAS in SCSL library?  (SGI/Cray Scientific Library)
-if test $acx_blas_ok = no; then
-  as_ac_Lib=`echo "ac_cv_lib_scs_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -lscs" >&5
-echo $ECHO_N "checking for $dgemm in -lscs... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lscs  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  acx_blas_ok=yes; BLAS_LIBS="-lscs"
-fi
-
-fi
-
-# BLAS in SGIMATH library?
-if test $acx_blas_ok = no; then
-  as_ac_Lib=`echo "ac_cv_lib_complib.sgimath_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -lcomplib.sgimath" >&5
-echo $ECHO_N "checking for $dgemm in -lcomplib.sgimath... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lcomplib.sgimath  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  acx_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"
-fi
-
-fi
-
-# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
-if test $acx_blas_ok = no; then
- as_ac_Lib=`echo "ac_cv_lib_blas_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -lblas" >&5
-echo $ECHO_N "checking for $dgemm in -lblas... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lblas  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  as_ac_Lib=`echo "ac_cv_lib_essl_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -lessl" >&5
-echo $ECHO_N "checking for $dgemm in -lessl... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lessl -lblas $FLIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  acx_blas_ok=yes; BLAS_LIBS="-lessl -lblas"
-fi
-
-fi
-
-fi
-
-# Generic BLAS library?
-if test $acx_blas_ok = no; then
-  as_ac_Lib=`echo "ac_cv_lib_blas_$dgemm" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgemm in -lblas" >&5
-echo $ECHO_N "checking for $dgemm in -lblas... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lblas  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgemm ();
-int
-main ()
-{
-$dgemm ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  acx_blas_ok=yes; BLAS_LIBS="-lblas"
-fi
-
-fi
-
-LIBS="$acx_blas_save_LIBS"
-
-# LAPACK
-# ------
-
-# If we didn't find a Blas implementation, disable tests for Lapack
-if test $acx_blas_ok = no; then
-  acx_lapack_ok=disabled
-fi
-
-# Check LAPACK_LIBS environment variable
-if test $acx_lapack_ok = no; then
-if test "x$LAPACK_LIBS" != x; then
-  save_LIBS="$LIBS";
-  LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
-  echo "$as_me:$LINENO: checking for $dgetrf in $LAPACK_LIBS" >&5
-echo $ECHO_N "checking for $dgetrf in $LAPACK_LIBS... $ECHO_C" >&6
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgetrf ();
-int
-main ()
-{
-$dgetrf ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  acx_lapack_ok=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-LAPACK_LIBS=""
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-  echo "$as_me:$LINENO: result: $acx_lapack_ok" >&5
-echo "${ECHO_T}$acx_lapack_ok" >&6
-  LIBS="$save_LIBS"
-  if test acx_lapack_ok = no; then
-     LAPACK_LIBS=""
-  fi
-fi
-fi
-
-# LAPACK linked to by default?  (is sometimes included in BLAS lib)
-if test $acx_lapack_ok = no; then
-  save_LIBS="$LIBS"
-  LIBS="$LIBS $BLAS_LIBS $FLIBS"
-  as_ac_var=`echo "ac_cv_func_$dgetrf" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgetrf" >&5
-echo $ECHO_N "checking for $dgetrf... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $dgetrf to an innocuous variant, in case <limits.h> declares $dgetrf.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $dgetrf innocuous_$dgetrf
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $dgetrf (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $dgetrf
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgetrf ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$dgetrf) || defined (__stub___$dgetrf)
-choke me
-#else
-char (*f) () = $dgetrf;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $dgetrf;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  acx_lapack_ok=yes
-fi
-
-  LIBS="$save_LIBS"
-fi
-
-# Generic LAPACK library?
-for lapack in lapack lapack_rs6k; do
-  if test $acx_lapack_ok = no; then
-    save_LIBS="$LIBS"
-      LIBS="$BLAS_LIBS $LIBS"
-      as_ac_Lib=`echo "ac_cv_lib_$lapack''_$dgetrf" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $dgetrf in -l$lapack" >&5
-echo $ECHO_N "checking for $dgetrf in -l$lapack... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Lib+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$lapack $FLIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $dgetrf ();
-int
-main ()
-{
-$dgetrf ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_Lib=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Lib=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
-  acx_lapack_ok=yes; LAPACK_LIBS="-l$lapack"
-fi
-
-      LIBS="$save_LIBS"
-  fi
-done
-
-# If we have both libraries, set LAPACK_OK to yes
-# -----------------------------------------------------
-
-if test $acx_blas_ok = yes && test $acx_lapack_ok = yes; then
-  LAPACK_OK="yes"
-else
-  LAPACK_OK="no"
-fi
-
-
-
-  if test "X${LAPACK_OK}" = "Xyes"; then
-
-    echo "$as_me:$LINENO: checking for Blas/Lapack library linkage" >&5
-echo $ECHO_N "checking for Blas/Lapack library linkage... $ECHO_C" >&6
-    BLAS_LAPACK_LIBS="${LAPACK_LIBS} ${BLAS_LIBS} ${LIBS} ${FLIBS}"
-    echo "$as_me:$LINENO: result: ${LAPACK_LIBS} ${BLAS_LIBS}" >&5
-echo "${ECHO_T}${LAPACK_LIBS} ${BLAS_LIBS}" >&6
-
-  else
-
-    SUNDIALS_WARN_FLAG="yes"
-    echo "$as_me:$LINENO: checking for Blas/Lapack library linkage" >&5
-echo $ECHO_N "checking for Blas/Lapack library linkage... $ECHO_C" >&6
-    echo "$as_me:$LINENO: result: \"no\"" >&5
-echo "${ECHO_T}\"no\"" >&6
-    echo ""
-    echo "   Unable to determine Blas/Lapack library linkage."
-    echo ""
-    echo "   Try using --with-blas and --with-lapack."
-    echo ""
-    echo "   Disabling compilation of Blas/Lapack interfaces..."
-
-    LAPACK_ENABLED="no"
-
-  fi
-
-fi
-
-
-# Set the macro BLAS_LAPACK_MACRO for expansion in sundials_config.h
-
-
-
-
-if test "X${LAPACK_ENABLED}" = "Xyes"; then
-  cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_BLAS_LAPACK 1
-_ACEOF
-
-  BLAS_LAPACK_MACRO="#define SUNDIALS_BLAS_LAPACK 1"
-else
-  cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_BLAS_LAPACK 0
-_ACEOF
-
-  BLAS_LAPACK_MACRO="#define SUNDIALS_BLAS_LAPACK 0"
-fi
-
-
-fi
-
-# Set MPI support (Optional)
-if test "X${MPI_ENABLED}" = "Xyes"; then
-  echo ""
-  echo "MPI-C Settings"
-  echo "--------------"
-  echo ""
-
-
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# MPI root directory
-
-# Check whether --with-mpi-root or --without-mpi-root was given.
-if test "${with_mpi_root+set}" = set; then
-  withval="$with_mpi_root"
-
-MPI_ROOT_DIR="${withval}"
-
-else
-
-MPI_ROOT_DIR=""
-
-fi;
-
-# MPI include directory
-
-# Check whether --with-mpi-incdir or --without-mpi-incdir was given.
-if test "${with_mpi_incdir+set}" = set; then
-  withval="$with_mpi_incdir"
-
-MPI_INC_DIR="${withval}"
-
-else
-
-MPI_INC_DIR=""
-
-fi;
-
-# MPI library directory
-
-# Check whether --with-mpi-libdir or --without-mpi-libdir was given.
-if test "${with_mpi_libdir+set}" = set; then
-  withval="$with_mpi_libdir"
-
-MPI_LIB_DIR="${withval}"
-
-else
-
-MPI_LIB_DIR=""
-
-fi;
-
-# MPI libraries
-
-# Check whether --with-mpi-libs or --without-mpi-libs was given.
-if test "${with_mpi_libs+set}" = set; then
-  withval="$with_mpi_libs"
-
-MPI_LIBS="${withval}"
-
-else
-
-MPI_LIBS=""
-
-fi;
-
-# MPI flags
-
-# Check whether --with-mpi-flags or --without-mpi-flags was given.
-if test "${with_mpi_flags+set}" = set; then
-  withval="$with_mpi_flags"
-
-MPI_FLAGS="${withval}"
-MPI_FLAGS_OK="yes"
-
-else
-
-MPI_FLAGS=""
-MPI_FLAGS_OK="no"
-
-fi;
-
-# MPI-C compiler
-MPICC_COMP_GIVEN="yes"
-echo "$as_me:$LINENO: checking if using MPI-C script" >&5
-echo $ECHO_N "checking if using MPI-C script... $ECHO_C" >&6
-
-# Check whether --with-mpicc or --without-mpicc was given.
-if test "${with_mpicc+set}" = set; then
-  withval="$with_mpicc"
-
-if test "X${withval}" = "Xno"; then
-  USE_MPICC_SCRIPT="no"
-else
-  USE_MPICC_SCRIPT="yes"
-  MPICC_COMP="${withval}"
-fi
-
-else
-
-  USE_MPICC_SCRIPT="yes"
-  MPICC_COMP="mpicc"
-  MPICC_COMP_GIVEN="no"
-
-fi;
-echo "$as_me:$LINENO: result: ${USE_MPICC_SCRIPT}" >&5
-echo "${ECHO_T}${USE_MPICC_SCRIPT}" >&6
-
-# If CC is a C++ compiler, then we certainly do NOT want to use an MPI-C script
-# Note: USING_CPLUSPLUS_COMP was defined by a call to SUNDIALS_CPLUSPLUS_CHECK
-# in SUNDIALS_SET_CC
-# Note: If the user specified an MPI-C script, then we will NOT do anything for now
-if test "X${MPICC_COMP_GIVEN}" = "Xno" && test "X${USING_CPLUSPLUS_COMP}" = "Xyes"; then
-  MPICC_COMP="mpiCC"
-fi
-
-# Check MPI-C compiler (either MPI compiler script or regular C compiler)
-if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-
-
-# Test MPI-C compiler (meaning test MPICC_COMP)
-# Check if MPI-C compiler can be found
-
-echo "$as_me:$LINENO: checking if absolute path to ${MPICC_COMP} was given" >&5
-echo $ECHO_N "checking if absolute path to ${MPICC_COMP} was given... $ECHO_C" >&6
-
-# CASE 1: MPICC_COMP was found (cannot check if executable because the
-# "-x" flag is NOT portable)
-if test -f ${MPICC_COMP} ; then
-
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-  MPICC_COMP_EXISTS="yes"
-  # Determine MPI_INC_DIR and MPI_LIB_DIR for use by Makefile
-  MPI_BASE_DIR=`(dirname "${MPICC_COMP}") 2>/dev/null ||
-$as_expr X"${MPICC_COMP}" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"${MPICC_COMP}" : 'X\(//\)[^/]' \| \
-	 X"${MPICC_COMP}" : 'X\(//\)$' \| \
-	 X"${MPICC_COMP}" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"${MPICC_COMP}" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-  TMP_MPI_INC_DIR="${MPI_BASE_DIR}/../include"
-  TMP_MPI_LIB_DIR="${MPI_BASE_DIR}/../lib"
-
-# CASE 2: MPICC_COMP could NOT be found and MPI_ROOT_DIR was NOT specified,
-# so search in PATH
-else
-
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    # Try to find location of executable (perhaps directory was entered
-    # incorrectly)
-    TEMP_MPICC_COMP=`basename "${MPICC_COMP}"`
-    # Extract the first word of "${TEMP_MPICC_COMP}", so it can be a program name with args.
-set dummy ${TEMP_MPICC_COMP}; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_path_MPICC_COMP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  case $MPICC_COMP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_MPICC_COMP="$MPICC_COMP" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_MPICC_COMP="$as_dir/$ac_word$ac_exec_ext"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_path_MPICC_COMP" && ac_cv_path_MPICC_COMP="none"
-  ;;
-esac
-fi
-MPICC_COMP=$ac_cv_path_MPICC_COMP
-
-if test -n "$MPICC_COMP"; then
-  echo "$as_me:$LINENO: result: $MPICC_COMP" >&5
-echo "${ECHO_T}$MPICC_COMP" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-    # Cannot find executable in PATH
-    if test "X${MPICC_COMP}" = "Xnone"; then
-      MPICC_COMP_EXISTS="no"
-      MPICC_COMP=""
-    # Found executable and set MPICC_COMP to absolute pathname
-    else
-      MPICC_COMP_EXISTS="yes"
-      MPI_BASE_DIR=`(dirname "${MPICC_COMP}") 2>/dev/null ||
-$as_expr X"${MPICC_COMP}" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"${MPICC_COMP}" : 'X\(//\)[^/]' \| \
-	 X"${MPICC_COMP}" : 'X\(//\)$' \| \
-	 X"${MPICC_COMP}" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"${MPICC_COMP}" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-      TMP_MPI_INC_DIR="${MPI_BASE_DIR}/../include"
-      TMP_MPI_LIB_DIR="${MPI_BASE_DIR}/../lib"
-    fi
-
-  # CASE 3: MPICC_COMP could NOT be found, but MPI_ROOT_DIR was specified
-  else
-
-    echo "$as_me:$LINENO: checking if ${MPICC_COMP} exists in ${MPI_ROOT_DIR}/bin" >&5
-echo $ECHO_N "checking if ${MPICC_COMP} exists in ${MPI_ROOT_DIR}/bin... $ECHO_C" >&6
-    # MPICC_COMP should really only contain an executable name
-    # Found location of MPICC_COMP
-    if test -f ${MPI_ROOT_DIR}/bin/${MPICC_COMP} ; then
-      echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-      MPICC_COMP_EXISTS="yes"
-      MPICC_COMP="${MPI_ROOT_DIR}/bin/${MPICC_COMP}"
-      TMP_MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-      TMP_MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    # Could NOT find MPICC_COMP anywhere
-    else
-      echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-      MPICC_COMP_EXISTS="no"
-      MPICC_COMP=""
-    fi
-
-  fi
-
-fi
-
-# If MPICC_COMP exists, set MPICC and (conditionally) set MPI_INC_DIR
-# and MPI_LIB_DIR so that we do not end up with empty -I options.
-# Otherwise, issue warning message
-if test "X${MPICC_COMP_EXISTS}" = "Xyes"; then
-
-  MPICC="${MPICC_COMP}"
-  MPI_C_COMP_OK="yes"
-
-  # If MPI_INC_DIR is empty, set it to TMP_MPI_INC_DIR
-  if test "X${MPI_INC_DIR}" = "X"; then
-    MPI_INC_DIR="$TMP_MPI_INC_DIR"
-  fi
-
-  # If MPI_LIB_DIR is empty, set it to TMP_MPI_LIB_DIR
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="$TMP_MPI_LIB_DIR"
-  fi
-
-else
-
-  { echo "$as_me:$LINENO: WARNING: cannot find MPI-C compiler" >&5
-echo "$as_me: WARNING: cannot find MPI-C compiler" >&2;}
-  echo ""
-  echo "   Unable to find a functional MPI-C compiler."
-  echo ""
-  echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-  echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-  echo "   to specify the locations of all relevant MPI files, or"
-  echo "   --with-mpi-root to specify the base installation directory"
-  echo "   of the MPI implementation to be used."
-  echo ""
-  echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-  echo ""
-  MPICC=""
-  MPI_C_COMP_OK="no"
-  SUNDIALS_WARN_FLAG="yes"
-
-fi
-
-
-else
-  MPICC_COMP="${CC}"
-  MPICC="${CC}"
-
-
-# Test if we can compile MPI programs using the CC compiler
-# and current MPI settings
-
-{ echo "$as_me:$LINENO: Testing CC with MPI settings" >&5
-echo "$as_me: Testing CC with MPI settings" >&6;}
-
-# Save copies of CPPFLAGS, LDFLAGS and LIBS (preserve information)
-# Temporarily overwritten so we can test MPI implementation
-SAVED_CPPFLAGS="${CPPFLAGS}"
-SAVED_LDFLAGS="${LDFLAGS}"
-SAVED_LIBS="${LIBS}"
-
-# Determine location of MPI header files (find MPI include directory)
-MPI_EXISTS="yes"
-
-echo "$as_me:$LINENO: checking for location of MPI implementation" >&5
-echo $ECHO_N "checking for location of MPI implementation... $ECHO_C" >&6
-
-# If MPI include directory was NOT explicitly specified, check if MPI root
-# directory was given by user
-if test "X${MPI_INC_DIR}" = "X"; then
-  # If MPI root directory was NOT given so issue a warning message
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    echo "$as_me:$LINENO: result: not found" >&5
-echo "${ECHO_T}not found" >&6
-    MPI_EXISTS="no"
-    { echo "$as_me:$LINENO: WARNING: cannot find MPI implementation files" >&5
-echo "$as_me: WARNING: cannot find MPI implementation files" >&2;}
-    echo ""
-    echo "   Unable to find MPI implementation files."
-    echo ""
-    echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-    echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-    echo "   to specify the locations of all relevant MPI files, or"
-    echo "   --with-mpi-root to specify the base installation directory"
-    echo "   of the MPI implementation to be used."
-    echo ""
-    echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-    echo ""
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI root directory was given so set MPI_INC_DIR accordingly
-  # Update CPPFLAGS
-  else
-    MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-    echo "$as_me:$LINENO: result: ${MPI_INC_DIR}" >&5
-echo "${ECHO_T}${MPI_INC_DIR}" >&6
-    if test "X${CPPFLAGS}" = "X"; then
-      CPPFLAGS="-I${MPI_INC_DIR}"
-    else
-      CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-    fi
-    # Add MPI_FLAGS if non-empty
-    if test "X${MPI_FLAGS}" = "X"; then
-      CPPFLAGS="${CPPFLAGS}"
-    else
-      CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-    fi
-  fi
-# MPI include directory was specified so update CPPFLAGS
-else
-  echo "$as_me:$LINENO: result: ${MPI_INC_DIR}" >&5
-echo "${ECHO_T}${MPI_INC_DIR}" >&6
-  if test "X${CPPFLAGS}" = "X"; then
-    CPPFLAGS="-I${MPI_INC_DIR}"
-  else
-    CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-  fi
-  # Add MPI_FLAGS if non-empty
-  if test "X${MPI_FLAGS}" = "X"; then
-    CPPFLAGS="${CPPFLAGS}"
-  else
-    CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-  fi
-fi
-
-# Only continue if found an MPI implementation
-if test "X${MPI_EXISTS}" = "Xyes"; then
-
-  echo "$as_me:$LINENO: checking for location of MPI libraries" >&5
-echo $ECHO_N "checking for location of MPI libraries... $ECHO_C" >&6
-
-  # Determine location of MPI libraries
-  # MPI library directory was NOT specified by user so set based upon MPI_ROOT_DIR
-  # Update LDFLAGS
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    echo "$as_me:$LINENO: result: ${MPI_LIB_DIR}" >&5
-echo "${ECHO_T}${MPI_LIB_DIR}" >&6
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  # MPI library directory was specified so update LDFLAGS
-  else
-    echo "$as_me:$LINENO: result: ${MPI_LIB_DIR}" >&5
-echo "${ECHO_T}${MPI_LIB_DIR}" >&6
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  fi
-
-  # Check if user specified which MPI libraries must be included
-  # If no libraries are given, then issue a warning message
-  echo "$as_me:$LINENO: checking for MPI libraries" >&5
-echo $ECHO_N "checking for MPI libraries... $ECHO_C" >&6
-  if test "X${MPI_LIBS}" = "X"; then
-    echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-    { echo "$as_me:$LINENO: WARNING: no MPI libraries were given" >&5
-echo "$as_me: WARNING: no MPI libraries were given" >&2;}
-    echo ""
-    echo "   Unable to compile MPI program using C compiler because"
-    echo "   MPI libraries were not specified."
-    echo ""
-    echo "   Try using --with-mpi-libdir and --with-mpi-libs to"
-    echo "   specify the location and names of the MPI libraries."
-    echo ""
-    echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-    echo ""
-    MPI_C_COMP_OK="no"
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI libraries were specified so update LIBS
-  else
-    echo "$as_me:$LINENO: result: ${MPI_LIBS}" >&5
-echo "${ECHO_T}${MPI_LIBS}" >&6
-    if test "X${LIBS}" = "X"; then
-      LIBS="${MPI_LIBS}"
-    else
-      LIBS="${LIBS} ${MPI_LIBS}"
-    fi
-    # Set the MPI_C_COMP_OK variable to NULL so we can conditionally execute
-    # the next test
-    MPI_C_COMP_OK=""
-  fi
-
-  if test "X${MPI_C_COMP_OK}" = "X"; then
-    echo "$as_me:$LINENO: checking if C compiler can compile MPI programs" >&5
-echo $ECHO_N "checking if C compiler can compile MPI programs... $ECHO_C" >&6
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include "mpi.h"
-int
-main ()
-{
-int c; char **v; MPI_Init(&c,&v);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-     MPI_C_COMP_OK="yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-     { echo "$as_me:$LINENO: WARNING: C compiler cannot compile MPI programs" >&5
-echo "$as_me: WARNING: C compiler cannot compile MPI programs" >&2;}
-     echo ""
-     echo "   Unable to compile MPI program using C compiler."
-     echo ""
-     echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-     echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-     echo "   to specify the locations of all relevant MPI files, or"
-     echo "   --with-mpi-root to specify the base installation directory"
-     echo "   of the MPI implementation to be used."
-     echo ""
-     echo "   Disabling the parallel NVECTOR module and all parallel examples..."
-     echo ""
-     MPI_C_COMP_OK="no"
-     SUNDIALS_WARN_FLAG="yes"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-  fi
-else
-  MPI_C_COMP_OK="no"
-fi
-
-# Restore CPPFLAGS, LDFLAGS and LIBS
-CPPFLAGS="${SAVED_CPPFLAGS}"
-LDFLAGS="${SAVED_LDFLAGS}"
-LIBS="${SAVED_LIBS}"
-
-
-fi
-
-
-fi
-if test "X${MPI_C_COMP_OK}" = "Xyes"; then
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    echo ""
-    echo "MPI-2 Functionality"
-    echo "-------------------"
-    echo ""
-
-
-# Determine if MPI implementation used to build SUNDIALS provides
-# MPI-2 functionality.
-#
-# Test for MPI_Comm_f2c() function:
-#   (1) NO  : FNVECTOR_PARALLEL module will NOT allow user to specify
-#             an MPI communicator and MPI_COMM_WORLD will be used
-#   (2) YES : FNVECTOR_PARALLEL module will allow user to specify
-#             an MPI communicator
-#
-
-# Provide variable description templates for config.hin and config.h files
-# Required by autoheader utility
-
-
-
-# Save copies of CPPFLAGS, LDFLAGS and LIBS (preserve information)
-# Temporarily overwritten so we can test MPI implementation
-SAVED_CPPFLAGS="${CPPFLAGS}"
-SAVED_LDFLAGS="${LDFLAGS}"
-SAVED_LIBS="${LIBS}"
-
-# Determine location of MPI header files (find MPI include directory)
-MPI_EXISTS="yes"
-
-# MPI include directory was NOT explicitly specified so check if MPI root
-# directory was given by user
-if test "X${MPI_INC_DIR}" = "X"; then
-  # MPI root directory was NOT given so issue a warning message
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    MPI_EXISTS="no"
-    { echo "$as_me:$LINENO: WARNING: cannot find MPI implementation files" >&5
-echo "$as_me: WARNING: cannot find MPI implementation files" >&2;}
-    echo ""
-    echo "   Unable to find MPI implementation files."
-    echo ""
-    echo "   Try using --with-mpicc to specify a MPI-C compiler script,"
-    echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-    echo "   to specify the locations of all relevant MPI files, or"
-    echo "   --with-mpi-root to specify the base installation directory"
-    echo "   of the MPI implementation to be used."
-    echo ""
-    echo "   Disabling FNVECTOR_PARALLEL support for user-specified"
-    echo "   MPI communicator..."
-    echo ""
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI root directory was given so set MPI_INC_DIR accordingly
-  # Update CPPFLAGS
-  else
-    MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-    if test "X${CPPFLAGS}" = "X"; then
-      CPPFLAGS="-I${MPI_INC_DIR}"
-    else
-      CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-    fi
-    # Add MPI_FLAGS if non-empty
-    if test "X${MPI_FLAGS}" = "X"; then
-      CPPFLAGS="${CPPFLAGS}"
-    else
-      CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-    fi
-  fi
-# MPI include directory was specified so update CPPFLAGS
-else
-  if test "X${CPPFLAGS}" = "X"; then
-    CPPFLAGS="-I${MPI_INC_DIR}"
-  else
-    CPPFLAGS="${CPPFLAGS} -I${MPI_INC_DIR}"
-  fi
-  # Add MPI_FLAGS if non-empty
-  if test "X${MPI_FLAGS}" = "X"; then
-    CPPFLAGS="${CPPFLAGS}"
-  else
-    CPPFLAGS="${CPPFLAGS} ${MPI_FLAGS}"
-  fi
-fi
-
-# Only continue if found an MPI implementation
-if test "X${MPI_EXISTS}" = "Xyes"; then
-
-  # Determine location of MPI libraries
-  # MPI library directory was NOT specified by user so set based upon MPI_ROOT_DIR
-  # Update LDFLAGS
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  # MPI library directory was specified so update LDFLAGS
-  else
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  fi
-
-  # Check if user specified which MPI libraries linker should be use
-  if test "X${MPI_LIBS}" = "X"; then
-    :
-  # MPI libraries were specified so update LIBS
-  else
-    if test "X${LIBS}" = "X"; then
-      LIBS="${MPI_LIBS}"
-    else
-      LIBS="${LIBS} ${MPI_LIBS}"
-    fi
-  fi
-
-  # Since AC_LINK_IFELSE uses CC, set CC = MPICC if using
-  # an MPI compiler script
-  if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-    SAVED_CC="${CC}"
-    CC="${MPICC_COMP}"
-  fi
-
-  # Check if MPI implementation supports MPI_Comm_f2c() from
-  # MPI-2 specification
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    echo "$as_me:$LINENO: checking for MPI_Comm_f2c() from MPI-2 specification" >&5
-echo $ECHO_N "checking for MPI_Comm_f2c() from MPI-2 specification... $ECHO_C" >&6
-    cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include "mpi.h"
-int
-main ()
-{
-
-        int c;
-        char **v;
-        MPI_Comm C_comm;
-        MPI_Init(&c, &v);
-        C_comm = MPI_Comm_f2c((MPI_Fint) 1);
-        MPI_Finalize();
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-     cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_MPI_COMM_F2C 1
-_ACEOF
-
-     F77_MPI_COMM_F2C="#define SUNDIALS_MPI_COMM_F2C 1"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-     cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_MPI_COMM_F2C 0
-_ACEOF
-
-     F77_MPI_COMM_F2C="#define SUNDIALS_MPI_COMM_F2C 0"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-  fi
-
-  # Reset CC if necessary
-  if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-    CC="${SAVED_CC}"
-  fi
-
-else
-  cat >>confdefs.h <<\_ACEOF
-#define SUNDIALS_MPI_COMM_F2C 0
-_ACEOF
-
-  F77_MPI_COMM_F2C="#define SUNDIALS_MPI_COMM_F2C 0"
-fi
-
-# Restore CPPFLAGS, LDFLAGS and LIBS
-CPPFLAGS="${SAVED_CPPFLAGS}"
-LDFLAGS="${SAVED_LDFLAGS}"
-LIBS="${SAVED_LIBS}"
-
-
-  fi
-  if test "X${F77_EXAMPLES_ENABLED}" = "Xyes"; then
-    echo ""
-    echo "MPI-Fortran Settings"
-    echo "--------------------"
-    echo ""
-
-
-echo "$as_me:$LINENO: checking if using MPI-Fortran script" >&5
-echo $ECHO_N "checking if using MPI-Fortran script... $ECHO_C" >&6
-
-# Check whether --with-mpif77 or --without-mpif77 was given.
-if test "${with_mpif77+set}" = set; then
-  withval="$with_mpif77"
-
-if test "X${withval}" = "Xno"; then
-  USE_MPIF77_SCRIPT="no"
-else
-  USE_MPIF77_SCRIPT="yes"
-  MPIF77_COMP="${withval}"
-fi
-
-else
-
-USE_MPIF77_SCRIPT="yes"
-MPIF77_COMP="mpif77"
-
-fi;
-echo "$as_me:$LINENO: result: ${USE_MPIF77_SCRIPT}" >&5
-echo "${ECHO_T}${USE_MPIF77_SCRIPT}" >&6
-
-# Check MPI-Fortran compiler (either MPI compiler script or regular Fortran compiler)
-if test "X${USE_MPIF77_SCRIPT}" = "Xyes"; then
-
-
-# Test the MPI-Fortran compiler (meaning test MPIF77_COMP)
-# Check if MPI-Fortran compiler can be found
-
-echo "$as_me:$LINENO: checking if absolute path to ${MPIF77_COMP} was given" >&5
-echo $ECHO_N "checking if absolute path to ${MPIF77_COMP} was given... $ECHO_C" >&6
-
-# CASE 1: MPIF77_COMP was found (cannot check if executable because the
-# "-x" flag is NOT portable)
-if test -f ${MPIF77_COMP} ; then
-
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-  MPIF77_COMP_EXISTS="yes"
-  # Determine MPI_INC_DIR and MPI_LIB_DIR for use by Makefile
-  MPI_BASE_DIR=`(dirname "${MPIF77_COMP}") 2>/dev/null ||
-$as_expr X"${MPIF77_COMP}" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"${MPIF77_COMP}" : 'X\(//\)[^/]' \| \
-	 X"${MPIF77_COMP}" : 'X\(//\)$' \| \
-	 X"${MPIF77_COMP}" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"${MPIF77_COMP}" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-
-# CASE 2: MPIF77_COMP could NOT be found and MPI_ROOT_DIR was NOT specified,
-# so search in PATH
-else
-
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-
-    # Try to find location of executable (perhaps directory was entered incorrectly)
-    TEMP_MPIF77_COMP=`basename "${MPIF77_COMP}"`
-    # Extract the first word of "${TEMP_MPIF77_COMP}", so it can be a program name with args.
-set dummy ${TEMP_MPIF77_COMP}; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_path_MPIF77_COMP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  case $MPIF77_COMP in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_MPIF77_COMP="$MPIF77_COMP" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_MPIF77_COMP="$as_dir/$ac_word$ac_exec_ext"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_path_MPIF77_COMP" && ac_cv_path_MPIF77_COMP="none"
-  ;;
-esac
-fi
-MPIF77_COMP=$ac_cv_path_MPIF77_COMP
-
-if test -n "$MPIF77_COMP"; then
-  echo "$as_me:$LINENO: result: $MPIF77_COMP" >&5
-echo "${ECHO_T}$MPIF77_COMP" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-    # Cannot find executable in PATH
-    if test "X${MPIF77_COMP}" = "Xnone"; then
-      MPIF77_COMP_EXISTS="no"
-      MPIF77_COMP=""
-    # Found executable and set MPIF77_COMP to absolute pathname
-    else
-      MPIF77_COMP_EXISTS="yes"
-      MPI_BASE_DIR=`(dirname "${MPIF77_COMP}") 2>/dev/null ||
-$as_expr X"${MPIF77_COMP}" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"${MPIF77_COMP}" : 'X\(//\)[^/]' \| \
-	 X"${MPIF77_COMP}" : 'X\(//\)$' \| \
-	 X"${MPIF77_COMP}" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"${MPIF77_COMP}" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    fi
-
-  # CASE 3: MPIF77_COMP could NOT be found, but MPI_ROOT_DIR was specified
-  else
-
-    echo "$as_me:$LINENO: checking if ${MPIF77_COMP} exists in ${MPI_ROOT_DIR}/bin" >&5
-echo $ECHO_N "checking if ${MPIF77_COMP} exists in ${MPI_ROOT_DIR}/bin... $ECHO_C" >&6
-    # MPIF77_COMP should really only contain an executable name
-    # Found location of MPIF77_COMP
-    if test -f ${MPI_ROOT_DIR}/bin/${MPIF77_COMP} ; then
-      echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-      MPIF77_COMP_EXISTS="yes"
-      MPIF77_COMP="${MPI_ROOT_DIR}/bin/${MPIF77_COMP}"
-    # Could NOT find MPIF77_COMP anywhere
-    else
-      echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-      MPIF77_COMP_EXISTS="no"
-      MPIF77_COMP=""
-    fi
-
-  fi
-
-fi
-
-# Issue warning message if MPIF77_COMP does NOT exist, else set MPIF77
-if test "X${MPIF77_COMP_EXISTS}" = "Xyes"; then
-
-  MPIF77="${MPIF77_COMP}"
-  MPI_F77_COMP_OK="yes"
-
-  # Note that we do not have to worry about empty MPI_INC_DIR and MPI_LIB_DIR
-  # here as they were set in SUNDIALS_CHECK_MPICC
-
-  # Check if we must use the MPI-Fortran compiler script (MPIF77) to link
-  # the Fortran examples (default is to use MPICC)
-
-
-# If we are NOT using an MPI script, then MPICC_COMP == CC and we do NOT need
-# to check again if CC is a C++ compiler as we already know the answer
-if test "X${USE_MPICC_SCRIPT}" = "Xyes"; then
-
-  # Check if using a C++ compiler (meaning MPI-C++ script)
-  # Save result from CC check
-  SAVED_USING_CPLUSPLUS_COMP="${USING_CPLUSPLUS_COMP}"
-
-
-# Rename argument
-COMP_NAME="${MPICC_COMP}"
-
-# Update the language stack
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Check if using a C++ compiler
-echo "$as_me:$LINENO: checking if ${COMP_NAME} is a C++ compiler" >&5
-echo $ECHO_N "checking if ${COMP_NAME} is a C++ compiler... $ECHO_C" >&6
-if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-#ifdef __cplusplus
-  return(0);
-#else
-  return(1);
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-# COMP_NAME is a C++ compiler
-USING_CPLUSPLUS_COMP="yes"
-
-else
-  echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-# COMP_NAMPE is NOT a C++ compiler
-USING_CPLUSPLUS_COMP="no"
-
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-# Revert back to previous language
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-  # MPICC uses a C++ compiler so run the next test
-  if test "X${USING_CPLUSPLUS_COMP}" = "Xyes" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xyes"; then
-    RUN_MPIF77_LNKR_CHECK="yes"
-  # ERROR
-  elif test "X${USING_CPLUSPLUS_COMP}" = "Xyes" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xno"; then
-    { { echo "$as_me:$LINENO: error: ${MPICC_COMP} is a C++ compiler but ${CC} is a C compiler" >&5
-echo "$as_me: error: ${MPICC_COMP} is a C++ compiler but ${CC} is a C compiler" >&2;}
-   { (exit 1); exit 1; }; }
-  # MPICC uses a C compiler so skip the next test
-  elif test "X${USING_CPLUSPLUS_COMP}" = "Xno" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xno" ; then
-    RUN_MPIF77_LNKR_CHECK="no"
-  # ERROR
-  elif test "X${USING_CPLUSPLUS_COMP}" = "Xno" && test "X${SAVED_USING_CPLUSPLUS_COMP}" = "Xyes" ; then
-    { { echo "$as_me:$LINENO: error: ${MPICC_COMP} is a C compiler but ${CC} is a C++ compiler" >&5
-echo "$as_me: error: ${MPICC_COMP} is a C compiler but ${CC} is a C++ compiler" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-  # Restore result from CC check
-  USING_CPLUSPLUS_COMP="${SAVED_USING_CPLUSPLUS_COMP}"
-
-else
-
-  echo "$as_me:$LINENO: checking if ${MPICC_COMP} is a C++ compiler" >&5
-echo $ECHO_N "checking if ${MPICC_COMP} is a C++ compiler... $ECHO_C" >&6
-  if test "X${USING_CPLUSPLUS_COMP}" = "Xyes"; then
-    echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-  else
-    echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-  fi
-
-fi
-
-echo "$as_me:$LINENO: checking which linker to use" >&5
-echo $ECHO_N "checking which linker to use... $ECHO_C" >&6
-# Perform the next test only if using a C++ compiler to build NVECTOR_PARALLEL
-if test "X${RUN_MPIF77_LNKR_CHECK}" = "Xyes"; then
-
-  MPIF77_LNKR_CHECK_OK="no"
-
-  # Switch language to "Fortran 77"
-  ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-  # Temporarily reset F77 environment variable to perform test
-  SAVED_F77="${F77}"
-  F77="${MPIF77_COMP}"
-
-  # Compile simple Fortran example, but do NOT link
-  # Note: result stored as conftest.${ac_objext}
-  cat >conftest.$ac_ext <<_ACEOF
-
-	PROGRAM SUNDIALS
-	INTEGER IER
-	CALL MPI_INIT(IER)
-	END
-
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-
-  # Reset F77 to original value
-  F77="${SAVED_F77}"
-
-  # Revert to previous language
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-  # Temporarily reset LIBS environment variable to perform test
-  SAVED_LIBS="${LIBS}"
-  LIBS="${LIBS} ${FLIBS}"
-
-  # Switch working language to C for next test
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-  # Temporarily reset CC environment variable to perform next test
-  SAVED_CC="${CC}"
-  CC="${MPICC_COMP}"
-
-  # Check if MPICC_COMP can link Fortran example
-  # Note: AC_LINKONLY_IFELSE is a custom macro (modifications made to
-  # general.m4 and c.m4)
-  if { (eval echo "$as_me:$LINENO: \"$ac_linkonly\"") >&5
-  (eval $ac_linkonly) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  MPIF77_LNKR_CHECK_OK="yes"
-else
-  echo "$as_me: failed program was:" >&5
-if test -f conftest.c ; then
-  sed 's/^/| /' conftest.c >&5
-elif test -f conftest.cc ; then
-  sed 's/^/| /' conftest.cc >&5
-elif test -f conftest.f ; then
-  sed 's/^/| /' conftest.f >&5
-elif test -f conftest.${FC_SRCEXT-f} ; then
-  sed 's/^/| /' conftest.${FC_SRCEXT-f} >&5
-fi
-
-MPIF77_LNKR_CHECK_OK="no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext
-
-  # Reset CC to original value
-  CC="${SAVED_CC}"
-
-  # Revert back to previous language (Fortran 77)
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-  # Set LIBS environment variable back to original value
-  LIBS="${SAVED_LIBS}"
-
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-  # If either the compilation or the linking failed, we should
-  # disable building the parallel Fortran examples
-  # For now, use MPIF77 as the linker...
-
-  if test "X${MPIF77_LNKR_CHECK_OK}" = "Xyes"; then
-    MPIF77_LNKR="${MPICC}"
-  else
-    MPIF77_LNKR="${MPIF77}"
-  fi
-
-else
-
-  # Using a C compiler so use MPIF77 to link parallel Fortran examples
-  MPIF77_LNKR="${MPIF77}"
-
-fi
-echo "$as_me:$LINENO: result: ${MPIF77_LNKR}" >&5
-echo "${ECHO_T}${MPIF77_LNKR}" >&6
-
-
-
-
-else
-
-  { echo "$as_me:$LINENO: WARNING: cannot find MPI-Fortran compiler" >&5
-echo "$as_me: WARNING: cannot find MPI-Fortran compiler" >&2;}
-  echo ""
-  echo "   Unable to find a functional MPI-Fortran compiler."
-  echo ""
-  echo "   Try using --with-mpif77 to specify a MPI-Fortran compiler script,"
-  echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-  echo "   to specify the locations of all relevant MPI files, or"
-  echo "   --with-mpi-root to specify the base installation directory"
-  echo "   of the MPI implementation to be used."
-  echo ""
-  echo "   Disabling parallel Fortran examples...."
-  echo ""
-  MPIF77=""
-  MPI_F77_COMP_OK="no"
-  SUNDIALS_WARN_FLAG="yes"
-
-fi
-
-
-else
-  MPIF77_COMP="${F77}"
-  MPIF77="${F77}"
-
-
-# Test if we can compile MPI programs using the F77 compiler
-# and current MPI settings
-
-{ echo "$as_me:$LINENO: Testing F77 with MPI settings" >&5
-echo "$as_me: Testing F77 with MPI settings" >&6;}
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-# Save copies of FFLAGS, LDFLAGS and LIBS (preserve information)
-# Temporarily overwritten so we can test MPI implementation
-SAVED_FFLAGS="${FFLAGS}"
-SAVED_LDFLAGS="${LDFLAGS}"
-SAVED_LIBS="${LIBS}"
-
-# This may seem redundant, but we are not guaranteed that
-# SUNDIALS_CC_WITH_MPI_CHECK has been executed
-# Determine location of MPI header files (find MPI include directory)
-MPI_EXISTS="yes"
-
-echo "$as_me:$LINENO: checking for location of MPI implementation" >&5
-echo $ECHO_N "checking for location of MPI implementation... $ECHO_C" >&6
-
-# If MPI include directory was NOT explicitly specified so check if MPI root
-# directory was given by user
-if test "X${MPI_INC_DIR}" = "X"; then
-  # If MPI root directory was NOT given so issue a warning message
-  if test "X${MPI_ROOT_DIR}" = "X"; then
-    echo "$as_me:$LINENO: result: not found" >&5
-echo "${ECHO_T}not found" >&6
-    MPI_EXISTS="no"
-    { echo "$as_me:$LINENO: WARNING: cannot find MPI implementation files" >&5
-echo "$as_me: WARNING: cannot find MPI implementation files" >&2;}
-    echo ""
-    echo "   Unable to find MPI implementation files."
-    echo ""
-    echo "   Try using --with-mpif77 to specify a MPI-Fortran compiler script,"
-    echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-    echo "   to specify the locations of all relevant MPI files, or"
-    echo "   --with-mpi-root to specify the base installation directory"
-    echo "   of the MPI implementation to be used."
-    echo ""
-    echo "   Disabling all parallel Fortran examples..."
-    echo ""
-    SUNDIALS_WARN_FLAG="yes"
-  # MPI root directory was given so set MPI_INC_DIR accordingly
-  # Update FFLAGS
-  else
-    MPI_INC_DIR="${MPI_ROOT_DIR}/include"
-    echo "$as_me:$LINENO: result: ${MPI_INC_DIR}" >&5
-echo "${ECHO_T}${MPI_INC_DIR}" >&6
-    if test "X${FFLAGS}" = "X"; then
-      FFLAGS="-I${MPI_INC_DIR}"
-    else
-      FFLAGS="${FFLAGS} -I${MPI_INC_DIR}"
-    fi
-  fi
-# MPI include directory was specified so update FFLAGS
-else
-  echo "$as_me:$LINENO: result: ${MPI_INC_DIR}" >&5
-echo "${ECHO_T}${MPI_INC_DIR}" >&6
-  if test "X${FFLAGS}" = "X"; then
-    FFLAGS="-I${MPI_INC_DIR}"
-  else
-    FFLAGS="${FFLAGS} -I${MPI_INC_DIR}"
-  fi
-fi
-
-# Only continue if found an MPI implementation
-if test "X${MPI_EXISTS}" = "Xyes"; then
-
-  echo "$as_me:$LINENO: checking for location of MPI libraries" >&5
-echo $ECHO_N "checking for location of MPI libraries... $ECHO_C" >&6
-
-  # Determine location of MPI libraries
-  # MPI library directory was NOT specified by user so set based upon MPI_ROOT_DIR
-  # Update LDFLAGS
-  if test "X${MPI_LIB_DIR}" = "X"; then
-    MPI_LIB_DIR="${MPI_ROOT_DIR}/lib"
-    echo "$as_me:$LINENO: result: ${MPI_LIB_DIR}" >&5
-echo "${ECHO_T}${MPI_LIB_DIR}" >&6
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  # MPI library directory was specified so update LDFLAGS
-  else
-    echo "$as_me:$LINENO: result: ${MPI_LIB_DIR}" >&5
-echo "${ECHO_T}${MPI_LIB_DIR}" >&6
-    if test "X${LDFLAGS}" = "X"; then
-      LDFLAGS="-L${MPI_LIB_DIR}"
-    else
-      LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR}"
-    fi
-  fi
-
-  # Check if user specified which MPI libraries must be included
-  # If no libraries are given, then issue a warning message
-  echo "$as_me:$LINENO: checking for MPI libraries" >&5
-echo $ECHO_N "checking for MPI libraries... $ECHO_C" >&6
-  if test "X${MPI_LIBS}" = "X"; then
-    echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-    echo ""
-    echo "   Unable to compile MPI program using Fortran compiler because"
-    echo "   MPI libraries were not specified."
-    echo ""
-    echo "   Try using --with-mpi-libdir and --with-mpi-libs to"
-    echo "   specify the location and names of the MPI libraries."
-    echo ""
-    echo "   Disabling all parallel Fortran examples..."
-    echo ""
-    MPI_F77_COMP_OK="no"
-  # MPI libraries were specified so update LIBS
-  else
-    echo "$as_me:$LINENO: result: ${MPI_LIBS}" >&5
-echo "${ECHO_T}${MPI_LIBS}" >&6
-    if test "X${LIBS}" = "X"; then
-      LIBS="${MPI_LIBS}"
-    else
-      LIBS="${LIBS} ${MPI_LIBS}"
-    fi
-    # Set the MPI_F77_COMP_OK variable to NULL so we can conditionally execute
-    # the next test
-    MPI_F77_COMP_OK=""
-  fi
-
-  if test "X${MPI_F77_COMP_OK}" = "X"; then
-    echo "$as_me:$LINENO: checking if Fortran compiler can compile MPI programs" >&5
-echo $ECHO_N "checking if Fortran compiler can compile MPI programs... $ECHO_C" >&6
-    cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-        INCLUDE "mpif.h"
-        CALL MPI_INIT(IER)
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-     MPI_F77_COMP_OK="yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-     { echo "$as_me:$LINENO: WARNING: Fortran compiler cannot compile MPI programs" >&5
-echo "$as_me: WARNING: Fortran compiler cannot compile MPI programs" >&2;}
-     echo ""
-     echo "   Unable to compile MPI program using Fortran compiler."
-     echo ""
-     echo "   Try using --with-mpif77 to specify a MPI-Fortran compiler script,"
-     echo "   --with-mpi-incdir, --with-mpi-libdir and --with-mpi-libs"
-     echo "   to specify the locations of all relevant MPI files, or"
-     echo "   --with-mpi-root to specify the base installation directory"
-     echo "   of the MPI implementation to be used."
-     echo ""
-     echo "   Disabling all parallel Fortran examples..."
-     echo ""
-     MPI_F77_COMP_OK="no"
-     SUNDIALS_WARN_FLAG="yes"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-
-    # Set MPIF77_LNKR based on value of F77_LNKR
-    # Note: setting MPIF77_LNKR is trivial if NOT using the MPI compiler script
-    # since the SUNDIALS_F77_LNKR_CHECK macro already checked if CC or F77
-    # should be used
-    echo "$as_me:$LINENO: checking which linker to use" >&5
-echo $ECHO_N "checking which linker to use... $ECHO_C" >&6
-    if test "X${F77_LNKR}" = "X${CC}"; then
-      MPIF77_LNKR="${MPICC}"
-    elif test "X${F77_LNKR}" = "X${F77}"; then
-      MPIF77_LNKR="${MPIF77}"
-    fi
-    echo "$as_me:$LINENO: result: ${MPIF77_LNKR}" >&5
-echo "${ECHO_T}${MPIF77_LNKR}" >&6
-  fi
-
-else
-  MPI_F77_COMP_OK="no"
-fi
-
-# Restore FFLAGS, LDFLAGS and LIBS
-FFLAGS="${SAVED_FFLAGS}"
-LDFLAGS="${SAVED_LDFLAGS}"
-LIBS="${SAVED_LIBS}"
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-fi
-
-
-  fi
-fi
-
-# Set examples modules
-if test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-  echo ""
-  echo "Examples"
-  echo "--------"
-  echo ""
-
-
-# Set proper object file extension
-# Must export OBJ_EXT via AC_SUBST
-OBJEXT=".lo"
-
-# Check if serial C examples can actually be built
-SERIAL_C_EXAMPLES="yes"
-
-# Check if parallel C examples can actually be built
-if test "X${MPI_ENABLED}" = "Xyes"; then
-  if test "X${MPI_C_COMP_OK}" = "Xyes"; then
-    PARALLEL_C_EXAMPLES="yes"
-  else
-    PARALLEL_C_EXAMPLES="no"
-  fi
-else
-  PARALLEL_C_EXAMPLES="disabled"
-fi
-
-# Check if serial F77 examples can actually be built
-if test "X${FCMIX_ENABLED}" = "Xyes"; then
-  if test "X${F77_OK}" = "Xyes"; then
-    SERIAL_F77_EXAMPLES="yes"
-  else
-    SERIAL_F77_EXAMPLES="no"
-  fi
-else
-  SERIAL_F77_EXAMPLES="disabled"
-fi
-
-# Check if parallel F77 examples can actually be built
-if test "X${FCMIX_ENABLED}" = "Xyes" &&  test "X${MPI_ENABLED}" = "Xyes"; then
-  if test "X${MPI_F77_COMP_OK}" = "Xyes"; then
-    PARALLEL_F77_EXAMPLES="yes"
-  else
-    PARALLEL_F77_EXAMPLES="no"
-  fi
-else
-  PARALLEL_F77_EXAMPLES="disabled"
-fi
-
-# Notify user
-echo "$as_me:$LINENO: checking if we can build serial C examples" >&5
-echo $ECHO_N "checking if we can build serial C examples... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: ${SERIAL_C_EXAMPLES}" >&5
-echo "${ECHO_T}${SERIAL_C_EXAMPLES}" >&6
-echo "$as_me:$LINENO: checking if we can build parallel C examples" >&5
-echo $ECHO_N "checking if we can build parallel C examples... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: ${PARALLEL_C_EXAMPLES}" >&5
-echo "${ECHO_T}${PARALLEL_C_EXAMPLES}" >&6
-echo "$as_me:$LINENO: checking if we can build serial Fortran examples" >&5
-echo $ECHO_N "checking if we can build serial Fortran examples... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: ${SERIAL_F77_EXAMPLES}" >&5
-echo "${ECHO_T}${SERIAL_F77_EXAMPLES}" >&6
-echo "$as_me:$LINENO: checking if we can build parallel Fortran examples" >&5
-echo $ECHO_N "checking if we can build parallel Fortran examples... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: ${PARALLEL_F77_EXAMPLES}" >&5
-echo "${ECHO_T}${PARALLEL_F77_EXAMPLES}" >&6
-
-# Check if the Fortran update script (bin/fortran-update.in) is needed
-if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" || test "X${PARALLEL_F77_EXAMPLES}" = "Xyes"; then
-  BUILD_F77_UPDATE_SCRIPT="yes";
-else
-  BUILD_F77_UPDATE_SCRIPT="no"
-fi
-
-# Where should we install the examples?
-# Note: setting this to "no" will disable example installation!
-echo "$as_me:$LINENO: checking where to install the SUNDIALS examples" >&5
-echo $ECHO_N "checking where to install the SUNDIALS examples... $ECHO_C" >&6
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Check whether --with-exinstdir or --without-exinstdir was given.
-if test "${with_exinstdir+set}" = set; then
-  withval="$with_exinstdir"
-
-  EXS_INSTDIR="${withval}"
-
-else
-
-  if test "X${exec_prefix}" = "XNONE"; then
-    if test "X${prefix}" = "XNONE"; then
-      EXS_INSTDIR="\${exec_prefix}/examples"
-    else
-      EXS_INSTDIR="${prefix}/examples"
-    fi
-  else
-    EXS_INSTDIR="${exec_prefix}/examples"
-  fi
-
-fi;
-echo "$as_me:$LINENO: result: ${EXS_INSTDIR}" >&5
-echo "${ECHO_T}${EXS_INSTDIR}" >&6
-
-# Prepare substitution variables to create the exported example Makefiles
-
-F77_LIBS="${FLIBS} ${LIBS}"
-if test "X${F77_LNKR}" = "X${F77}"; then
-  F77_LDFLAGS="${FFLAGS} ${LDFLAGS}"
-else
-  F77_LDFLAGS="${CFLAGS} ${LDFLAGS}"
-fi
-
-
-fi
-
-# Run libtool checks
-echo ""
-echo "Libtool Settings"
-echo "----------------"
-echo ""
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
-  enableval="$enable_shared"
-  p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_shared=yes ;;
-    no) enable_shared=no ;;
-    *)
-      enable_shared=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_shared=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac
-else
-  enable_shared=no
-fi;
-
-
-
-
-# Check whether --enable-static or --disable-static was given.
-if test "${enable_static+set}" = set; then
-  enableval="$enable_static"
-  p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_static=yes ;;
-    no) enable_static=no ;;
-    *)
-     enable_static=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_static=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac
-else
-  enable_static=yes
-fi;
-
-# Check whether --enable-fast-install or --disable-fast-install was given.
-if test "${enable_fast_install+set}" = set; then
-  enableval="$enable_fast_install"
-  p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_fast_install=yes ;;
-    no) enable_fast_install=no ;;
-    *)
-      enable_fast_install=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_fast_install=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac
-else
-  enable_fast_install=yes
-fi;
-
-echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
-echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6
-if test "${lt_cv_path_SED+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for lt_ac_prog in sed gsed; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
-        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
-      fi
-    done
-  done
-done
-IFS=$as_save_IFS
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
-  test ! -f $lt_ac_sed && continue
-  cat /dev/null > conftest.in
-  lt_ac_count=0
-  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
-  # Check for GNU sed and select it if it is found.
-  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
-    lt_cv_path_SED=$lt_ac_sed
-    break
-  fi
-  while true; do
-    cat conftest.in conftest.in >conftest.tmp
-    mv conftest.tmp conftest.in
-    cp conftest.in conftest.nl
-    echo >>conftest.nl
-    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
-    cmp -s conftest.out conftest.nl || break
-    # 10000 chars as input seems more than enough
-    test $lt_ac_count -gt 10 && break
-    lt_ac_count=`expr $lt_ac_count + 1`
-    if test $lt_ac_count -gt $lt_ac_max; then
-      lt_ac_max=$lt_ac_count
-      lt_cv_path_SED=$lt_ac_sed
-    fi
-  done
-done
-
-fi
-
-SED=$lt_cv_path_SED
-
-echo "$as_me:$LINENO: result: $SED" >&5
-echo "${ECHO_T}$SED" >&6
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
-  withval="$with_gnu_ld"
-  test "$withval" = no || with_gnu_ld=yes
-else
-  with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [\\/]* | ?:[\\/]*)
-      re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
-      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
-  echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
-      *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
-	;;
-      *)
-	test "$with_gnu_ld" != yes && break
-	;;
-      esac
-    fi
-  done
-  IFS="$lt_save_ifs"
-else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
-  echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
-   { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
-  lt_cv_prog_gnu_ld=yes
-  ;;
-*)
-  lt_cv_prog_gnu_ld=no
-  ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
-echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
-if test "${lt_cv_ld_reload_flag+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_ld_reload_flag='-r'
-fi
-echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
-echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
-
-echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
-echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
-if test "${lt_cv_path_NM+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi
-fi
-echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
-echo "${ECHO_T}$lt_cv_path_NM" >&6
-NM="$lt_cv_path_NM"
-
-echo "$as_me:$LINENO: checking whether ln -s works" >&5
-echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-  echo "$as_me:$LINENO: result: no, using $LN_S" >&5
-echo "${ECHO_T}no, using $LN_S" >&6
-fi
-
-echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5
-echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6
-if test "${lt_cv_deplibs_check_method+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-beos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-bsdi[45]*)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
-  lt_cv_file_magic_cmd='/usr/bin/file -L'
-  lt_cv_file_magic_test_file=/shlib/libc.so
-  ;;
-
-cygwin*)
-  # func_win32_libid is a shell function defined in ltmain.sh
-  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-  lt_cv_file_magic_cmd='func_win32_libid'
-  ;;
-
-mingw* | pw32*)
-  # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
-  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
-  ;;
-
-darwin* | rhapsody*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
-  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
-    case $host_cpu in
-    i*86 )
-      # Not sure whether the presence of OpenBSD here was a mistake.
-      # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
-      lt_cv_file_magic_cmd=/usr/bin/file
-      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
-      ;;
-    esac
-  else
-    lt_cv_deplibs_check_method=pass_all
-  fi
-  ;;
-
-gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-hpux10.20* | hpux11*)
-  lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
-  hppa*64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
-    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
-    ;;
-  *)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
-    lt_cv_file_magic_test_file=/usr/lib/libc.sl
-    ;;
-  esac
-  ;;
-
-interix3*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $LD in
-  *-32|*"-32 ") libmagic=32-bit;;
-  *-n32|*"-n32 ") libmagic=N32;;
-  *-64|*"-64 ") libmagic=64-bit;;
-  *) libmagic=never-match;;
-  esac
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-# This must be Linux ELF.
-linux*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-netbsd*)
-  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
-  fi
-  ;;
-
-newos6*)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
-  lt_cv_file_magic_cmd=/usr/bin/file
-  lt_cv_file_magic_test_file=/usr/lib/libnls.so
-  ;;
-
-nto-qnx*)
-  lt_cv_deplibs_check_method=unknown
-  ;;
-
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
-  fi
-  ;;
-
-osf3* | osf4* | osf5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-solaris*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv4 | sysv4.3*)
-  case $host_vendor in
-  motorola)
-    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
-    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
-    ;;
-  ncr)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  sequent)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
-    ;;
-  sni)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
-    lt_cv_file_magic_test_file=/lib/libc.so
-    ;;
-  siemens)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  esac
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-esac
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
-echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
-  enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-    case `/usr/bin/file conftest.$ac_objext` in
-    *ELF-32*)
-      HPUX_IA64_MODE="32"
-      ;;
-    *ELF-64*)
-      HPUX_IA64_MODE="64"
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-*-*-irix6*)
-  # Find out which ABI we are using.
-  echo '#line 11692 "configure"' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-   if test "$lt_cv_prog_gnu_ld" = yes; then
-    case `/usr/bin/file conftest.$ac_objext` in
-    *32-bit*)
-      LD="${LD-ld} -melf32bsmip"
-      ;;
-    *N32*)
-      LD="${LD-ld} -melf32bmipn32"
-      ;;
-    *64-bit*)
-      LD="${LD-ld} -melf64bmip"
-      ;;
-    esac
-   else
-    case `/usr/bin/file conftest.$ac_objext` in
-    *32-bit*)
-      LD="${LD-ld} -32"
-      ;;
-    *N32*)
-      LD="${LD-ld} -n32"
-      ;;
-    *64-bit*)
-      LD="${LD-ld} -64"
-      ;;
-    esac
-   fi
-  fi
-  rm -rf conftest*
-  ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-    case `/usr/bin/file conftest.o` in
-    *32-bit*)
-      case $host in
-        x86_64-*linux*)
-          LD="${LD-ld} -m elf_i386"
-          ;;
-        ppc64-*linux*|powerpc64-*linux*)
-          LD="${LD-ld} -m elf32ppclinux"
-          ;;
-        s390x-*linux*)
-          LD="${LD-ld} -m elf_s390"
-          ;;
-        sparc64-*linux*)
-          LD="${LD-ld} -m elf32_sparc"
-          ;;
-      esac
-      ;;
-    *64-bit*)
-      case $host in
-        x86_64-*linux*)
-          LD="${LD-ld} -m elf_x86_64"
-          ;;
-        ppc*-*linux*|powerpc*-*linux*)
-          LD="${LD-ld} -m elf64ppc"
-          ;;
-        s390*-*linux*)
-          LD="${LD-ld} -m elf64_s390"
-          ;;
-        sparc*-*linux*)
-          LD="${LD-ld} -m elf64_sparc"
-          ;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
-*-*-sco3.2v5*)
-  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -belf"
-  echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
-echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
-if test "${lt_cv_cc_needs_belf+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-     cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  lt_cv_cc_needs_belf=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-lt_cv_cc_needs_belf=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-     ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
-echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
-    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
-  fi
-  ;;
-sparc*-*solaris*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*) LD="${LD-ld} -m elf64_sparc" ;;
-      *)    LD="${LD-ld} -64" ;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
-*-*-cygwin* | *-*-mingw* | *-*-pw32*)
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
-set dummy ${ac_tool_prefix}dlltool; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_DLLTOOL+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$DLLTOOL"; then
-  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-DLLTOOL=$ac_cv_prog_DLLTOOL
-if test -n "$DLLTOOL"; then
-  echo "$as_me:$LINENO: result: $DLLTOOL" >&5
-echo "${ECHO_T}$DLLTOOL" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_DLLTOOL"; then
-  ac_ct_DLLTOOL=$DLLTOOL
-  # Extract the first word of "dlltool", so it can be a program name with args.
-set dummy dlltool; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_DLLTOOL"; then
-  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_prog_ac_ct_DLLTOOL" && ac_cv_prog_ac_ct_DLLTOOL="false"
-fi
-fi
-ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
-if test -n "$ac_ct_DLLTOOL"; then
-  echo "$as_me:$LINENO: result: $ac_ct_DLLTOOL" >&5
-echo "${ECHO_T}$ac_ct_DLLTOOL" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  DLLTOOL=$ac_ct_DLLTOOL
-else
-  DLLTOOL="$ac_cv_prog_DLLTOOL"
-fi
-
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
-set dummy ${ac_tool_prefix}as; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_AS+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$AS"; then
-  ac_cv_prog_AS="$AS" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_AS="${ac_tool_prefix}as"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-AS=$ac_cv_prog_AS
-if test -n "$AS"; then
-  echo "$as_me:$LINENO: result: $AS" >&5
-echo "${ECHO_T}$AS" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_AS"; then
-  ac_ct_AS=$AS
-  # Extract the first word of "as", so it can be a program name with args.
-set dummy as; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_AS+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_AS"; then
-  ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_AS="as"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_prog_ac_ct_AS" && ac_cv_prog_ac_ct_AS="false"
-fi
-fi
-ac_ct_AS=$ac_cv_prog_ac_ct_AS
-if test -n "$ac_ct_AS"; then
-  echo "$as_me:$LINENO: result: $ac_ct_AS" >&5
-echo "${ECHO_T}$ac_ct_AS" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  AS=$ac_ct_AS
-else
-  AS="$ac_cv_prog_AS"
-fi
-
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
-set dummy ${ac_tool_prefix}objdump; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_OBJDUMP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$OBJDUMP"; then
-  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-OBJDUMP=$ac_cv_prog_OBJDUMP
-if test -n "$OBJDUMP"; then
-  echo "$as_me:$LINENO: result: $OBJDUMP" >&5
-echo "${ECHO_T}$OBJDUMP" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_OBJDUMP"; then
-  ac_ct_OBJDUMP=$OBJDUMP
-  # Extract the first word of "objdump", so it can be a program name with args.
-set dummy objdump; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_OBJDUMP"; then
-  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_OBJDUMP="objdump"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_prog_ac_ct_OBJDUMP" && ac_cv_prog_ac_ct_OBJDUMP="false"
-fi
-fi
-ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
-if test -n "$ac_ct_OBJDUMP"; then
-  echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5
-echo "${ECHO_T}$ac_ct_OBJDUMP" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  OBJDUMP=$ac_ct_OBJDUMP
-else
-  OBJDUMP="$ac_cv_prog_OBJDUMP"
-fi
-
-  ;;
-
-esac
-
-need_locks="$enable_libtool_lock"
-
-
-
-for ac_header in dlfcn.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
-  # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_header_compiler=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  ac_header_preproc=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    (
-      cat <<\_ASBOX
-## ---------------------------- ##
-## Report this to radu at llnl.gov ##
-## ---------------------------- ##
-_ASBOX
-    ) |
-      sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
-  echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-    test -n "$CXX" && break
-  done
-fi
-if test -z "$CXX"; then
-  ac_ct_CXX=$CXX
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_CXX"; then
-  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CXX="$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  test -n "$ac_ct_CXX" && break
-done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
-
-  CXX=$ac_ct_CXX
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
-     "checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_compiler_gnu=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cxx_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_cxx_g=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-for ac_declaration in \
-   '' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
-echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
-if test -z "$CXXCPP"; then
-  if test "${ac_cv_prog_CXXCPP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-      # Double quotes because CXXCPP needs to be expanded
-    for CXXCPP in "$CXX -E" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether non-existent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  # Broken: success on invalid input.
-continue
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  break
-fi
-
-    done
-    ac_cv_prog_CXXCPP=$CXXCPP
-
-fi
-  CXXCPP=$ac_cv_prog_CXXCPP
-else
-  ac_cv_prog_CXXCPP=$CXXCPP
-fi
-echo "$as_me:$LINENO: result: $CXXCPP" >&5
-echo "${ECHO_T}$CXXCPP" >&6
-ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
-  # OK, works on sane cases.  Now check whether non-existent headers
-  # can be detected and how.
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  # Broken: success on invalid input.
-continue
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
-  :
-else
-  { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-fi
-
-
-
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-
-# find the maximum length of command line arguments
-echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
-echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
-if test "${lt_cv_sys_max_cmd_len+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-    i=0
-  teststring="ABCD"
-
-  case $build_os in
-  msdosdjgpp*)
-    # On DJGPP, this test can blow up pretty badly due to problems in libc
-    # (any single argument exceeding 2000 bytes causes a buffer overrun
-    # during glob expansion).  Even if it were fixed, the result of this
-    # check would be larger than it should be.
-    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
-    ;;
-
-  gnu*)
-    # Under GNU Hurd, this test is not required because there is
-    # no limit to the length of command line arguments.
-    # Libtool will interpret -1 as no limit whatsoever
-    lt_cv_sys_max_cmd_len=-1;
-    ;;
-
-  cygwin* | mingw*)
-    # On Win9x/ME, this test blows up -- it succeeds, but takes
-    # about 5 minutes as the teststring grows exponentially.
-    # Worse, since 9x/ME are not pre-emptively multitasking,
-    # you end up with a "frozen" computer, even though with patience
-    # the test eventually succeeds (with a max line length of 256k).
-    # Instead, let's just punt: use the minimum linelength reported by
-    # all of the supported platforms: 8192 (on NT/2K/XP).
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  amigaos*)
-    # On AmigaOS with pdksh, this test takes hours, literally.
-    # So we just punt and use a minimum line length of 8192.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
-
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ 	]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
-    # If test is not a shell built-in, we'll probably end up computing a
-    # maximum length that is only half of the actual maximum length, but
-    # we can't tell.
-    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-    while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
-	       = "XX$teststring") >/dev/null 2>&1 &&
-	    new_result=`expr "X$teststring" : ".*" 2>&1` &&
-	    lt_cv_sys_max_cmd_len=$new_result &&
-	    test $i != 17 # 1/2 MB should be enough
-    do
-      i=`expr $i + 1`
-      teststring=$teststring$teststring
-    done
-    teststring=
-    # Add a significant safety factor because C++ compilers can tack on massive
-    # amounts of additional arguments before passing them to the linker.
-    # It appears as though 1/2 is a usable value.
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
-    ;;
-  esac
-
-fi
-
-if test -n $lt_cv_sys_max_cmd_len ; then
-  echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
-echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
-else
-  echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-fi
-
-
-
-
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
-echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6
-if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[BCDEGRST]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
-  symcode='[BCDT]'
-  ;;
-cygwin* | mingw* | pw32*)
-  symcode='[ABCDGISTW]'
-  ;;
-hpux*) # Its linker distinguishes data from code symbols
-  if test "$host_cpu" = ia64; then
-    symcode='[ABCDEGRST]'
-  fi
-  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  ;;
-linux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[ABCDGIRSTW]'
-    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
-    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
-  fi
-  ;;
-irix* | nonstopux*)
-  symcode='[BCDEGRST]'
-  ;;
-osf*)
-  symcode='[BCDEGQRST]'
-  ;;
-solaris*)
-  symcode='[BDRT]'
-  ;;
-sco3.2v5*)
-  symcode='[DT]'
-  ;;
-sysv4.2uw2*)
-  symcode='[DT]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[ABDT]'
-  ;;
-sysv4)
-  symcode='[DFNSTU]'
-  ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
-  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
-  ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
-  symcode='[ABCDGIRSTW]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
-
-  # Write the raw and C identifiers.
-  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode$symcode*\)[ 	][ 	]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
-  # Check to see that the pipe works correctly.
-  pipe_works=no
-
-  rm -f conftest*
-  cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-    # Now try to grab the symbols.
-    nlist=conftest.nm
-    if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
-  (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && test -s "$nlist"; then
-      # Try sorting and uniquifying the output.
-      if sort "$nlist" | uniq > "$nlist"T; then
-	mv -f "$nlist"T "$nlist"
-      else
-	rm -f "$nlist"T
-      fi
-
-      # Make sure that we snagged all the symbols we need.
-      if grep ' nm_test_var$' "$nlist" >/dev/null; then
-	if grep ' nm_test_func$' "$nlist" >/dev/null; then
-	  cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
-	  # Now generate the symbol file.
-	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
-	  cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
-  const char *name;
-  lt_ptr_t address;
-}
-lt_preloaded_symbols[] =
-{
-EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
-	  cat <<\EOF >> conftest.$ac_ext
-  {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
-	  # Now try linking the two files.
-	  mv conftest.$ac_objext conftstm.$ac_objext
-	  lt_save_LIBS="$LIBS"
-	  lt_save_CFLAGS="$CFLAGS"
-	  LIBS="conftstm.$ac_objext"
-	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
-	  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && test -s conftest${ac_exeext}; then
-	    pipe_works=yes
-	  fi
-	  LIBS="$lt_save_LIBS"
-	  CFLAGS="$lt_save_CFLAGS"
-	else
-	  echo "cannot find nm_test_func in $nlist" >&5
-	fi
-      else
-	echo "cannot find nm_test_var in $nlist" >&5
-      fi
-    else
-      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
-    fi
-  else
-    echo "$progname: failed program was:" >&5
-    cat conftest.$ac_ext >&5
-  fi
-  rm -f conftest* conftst*
-
-  # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
-    break
-  else
-    lt_cv_sys_global_symbol_pipe=
-  fi
-done
-
-fi
-
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
-  lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
-  echo "$as_me:$LINENO: result: failed" >&5
-echo "${ECHO_T}failed" >&6
-else
-  echo "$as_me:$LINENO: result: ok" >&5
-echo "${ECHO_T}ok" >&6
-fi
-
-echo "$as_me:$LINENO: checking for objdir" >&5
-echo $ECHO_N "checking for objdir... $ECHO_C" >&6
-if test "${lt_cv_objdir+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
-  lt_cv_objdir=.libs
-else
-  # MS-DOS does not allow filenames that begin with a dot.
-  lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null
-fi
-echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
-echo "${ECHO_T}$lt_cv_objdir" >&6
-objdir=$lt_cv_objdir
-
-
-
-
-
-case $host_os in
-aix3*)
-  # AIX sometimes has problems with the GCC collect2 program.  For some
-  # reason, if we set the COLLECT_NAMES environment variable, the problems
-  # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
-    COLLECT_NAMES=
-    export COLLECT_NAMES
-  fi
-  ;;
-esac
-
-# Sed substitution that helps us do robust quoting.  It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_AR+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$AR"; then
-  ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_AR="${ac_tool_prefix}ar"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
-  echo "$as_me:$LINENO: result: $AR" >&5
-echo "${ECHO_T}$AR" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_AR"; then
-  ac_ct_AR=$AR
-  # Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_AR"; then
-  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_AR="ar"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false"
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
-  echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
-echo "${ECHO_T}$ac_ct_AR" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  AR=$ac_ct_AR
-else
-  AR="$ac_cv_prog_AR"
-fi
-
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  RANLIB=$ac_ct_RANLIB
-else
-  RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_STRIP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$STRIP"; then
-  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
-  echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
-  ac_ct_STRIP=$STRIP
-  # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_STRIP"; then
-  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_STRIP="strip"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
-  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  STRIP=$ac_ct_STRIP
-else
-  STRIP="$ac_cv_prog_STRIP"
-fi
-
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
-  case $host_os in
-  openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
-    ;;
-  *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
-    ;;
-  esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
-  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
-echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  case $MAGIC_CMD in
-[\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
-  for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool at gnu.org
-
-EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
-  ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$lt_cv_path_MAGIC_CMD"; then
-  if test -n "$ac_tool_prefix"; then
-    echo "$as_me:$LINENO: checking for file" >&5
-echo $ECHO_N "checking for file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  case $MAGIC_CMD in
-[\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
-  for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool at gnu.org
-
-EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
-  ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  else
-    MAGIC_CMD=:
-  fi
-fi
-
-  fi
-  ;;
-esac
-
-enable_dlopen=no
-enable_win32_dll=yes
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
-  enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-
-# Check whether --with-pic or --without-pic was given.
-if test "${with_pic+set}" = set; then
-  withval="$with_pic"
-  pic_mode="$withval"
-else
-  pic_mode=default
-fi;
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-lt_save_CC="$CC"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-objext=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-
-lt_prog_compiler_no_builtin_flag=
-
-if test "$GCC" = yes; then
-  lt_prog_compiler_no_builtin_flag=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_rtti_exceptions=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13780: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:13784: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_rtti_exceptions=yes
-     fi
-   fi
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
-    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
-else
-    :
-fi
-
-fi
-
-lt_prog_compiler_wl=
-lt_prog_compiler_pic=
-lt_prog_compiler_static=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl='-Wl,'
-    lt_prog_compiler_static='-static'
-
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
-      ;;
-
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic='-DDLL_EXPORT'
-      ;;
-
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic='-fno-common'
-      ;;
-
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared=no
-      enable_shared=no
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic=-Kconform_pic
-      fi
-      ;;
-
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic='-fPIC'
-	;;
-      esac
-      ;;
-
-    *)
-      lt_prog_compiler_pic='-fPIC'
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      else
-	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic='-qnocommon'
-         lt_prog_compiler_wl='-Wl,'
-         ;;
-       esac
-       ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic='-DDLL_EXPORT'
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='${wl}-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static='-non_shared'
-      ;;
-
-    newsos6)
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    linux*)
-      case $cc_basename in
-      icc* | ecc*)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-KPIC'
-	lt_prog_compiler_static='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fpic'
-	lt_prog_compiler_static='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static='-non_shared'
-        ;;
-      esac
-      ;;
-
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static='-non_shared'
-      ;;
-
-    solaris*)
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl='-Wl,';;
-      esac
-      ;;
-
-    sunos4*)
-      lt_prog_compiler_wl='-Qoption ld '
-      lt_prog_compiler_pic='-PIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic='-Kconform_pic'
-	lt_prog_compiler_static='-Bstatic'
-      fi
-      ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    unicos*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_can_build_shared=no
-      ;;
-
-    uts4*)
-      lt_prog_compiler_pic='-pic'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    *)
-      lt_prog_compiler_can_build_shared=no
-      ;;
-    esac
-  fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_pic_works=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14048: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:14052: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works=yes
-     fi
-   fi
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6
-
-if test x"$lt_prog_compiler_pic_works" = xyes; then
-    case $lt_prog_compiler_pic in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
-     esac
-else
-    lt_prog_compiler_pic=
-     lt_prog_compiler_can_build_shared=no
-fi
-
-fi
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic=
-    ;;
-  *)
-    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
-    ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works=yes
-       fi
-     else
-       lt_prog_compiler_static_works=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
-
-if test x"$lt_prog_compiler_static_works" = xyes; then
-    :
-else
-    lt_prog_compiler_static=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_c_o=no
-   $rm -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14152: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:14156: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $rm conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
-   $rm out/* && rmdir out
-   cd ..
-   rmdir conftest
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
-  if test "$hard_links" = no; then
-    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
-  runpath_var=
-  allow_undefined_flag=
-  enable_shared_with_static_runtimes=no
-  archive_cmds=
-  archive_expsym_cmds=
-  old_archive_From_new_cmds=
-  old_archive_from_expsyms_cmds=
-  export_dynamic_flag_spec=
-  whole_archive_flag_spec=
-  thread_safe_flag_spec=
-  hardcode_libdir_flag_spec=
-  hardcode_libdir_flag_spec_ld=
-  hardcode_libdir_separator=
-  hardcode_direct=no
-  hardcode_minus_L=no
-  hardcode_shlibpath_var=unsupported
-  link_all_deplibs=unknown
-  hardcode_automatic=no
-  module_cmds=
-  module_expsym_cmds=
-  always_export_symbols=no
-  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
-
-  ld_shlibs=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
-
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix3* | aix4* | aix5*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs=no
-	cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
-      fi
-      ;;
-
-    amigaos*)
-      archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-
-      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
-      # that the semantics of dynamic libraries on AmigaOS, at least up
-      # to version 4, is to share data among multiple programs linked
-      # with the same dynamic library.  Since this doesn't match the
-      # behavior of shared libraries on other platforms, we can't use
-      # them.
-      ld_shlibs=no
-      ;;
-
-    beos*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec='-L$libdir'
-      allow_undefined_flag=unsupported
-      always_export_symbols=no
-      enable_shared_with_static_runtimes=yes
-      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
-      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
-    interix3*)
-      hardcode_direct=no
-      hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
-
-    solaris*)
-      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
-	ld_shlibs=no
-	cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
-      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-	;;
-	*)
-	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-	  else
-	    ld_shlibs=no
-	  fi
-	;;
-      esac
-      ;;
-
-    sunos4*)
-      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
-
-    *)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
-    esac
-
-    if test "$ld_shlibs" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec=
-      export_dynamic_flag_spec=
-      whole_archive_flag_spec=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag=unsupported
-      always_export_symbols=yes
-      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct=unsupported
-      fi
-      ;;
-
-    aix4* | aix5*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
-
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
-	  for ld_flag in $LDFLAGS; do
-  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-  	    aix_use_runtimelinking=yes
-  	    break
-  	  fi
-	  done
-	  ;;
-	esac
-
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
-
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-      archive_cmds=''
-      hardcode_direct=yes
-      hardcode_libdir_separator=':'
-      link_all_deplibs=yes
-
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" && \
-  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
-	  then
-  	  # We have reworked collect2
-  	  hardcode_direct=yes
-	  else
-  	  # We have old collect2
-  	  hardcode_direct=unsupported
-  	  # It fails to find uninstalled libraries when the uninstalled
-  	  # path is not listed in the libpath.  Setting hardcode_minus_L
-  	  # to unsupported forces relinking
-  	  hardcode_minus_L=yes
-  	  hardcode_libdir_flag_spec='-L$libdir'
-  	  hardcode_libdir_separator=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-  	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
-
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag='-berok'
-       # Determine the default libpath from the value encoded in an empty executable.
-       cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-       hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-	archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an empty executable.
-	 cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' ${wl}-bernotok'
-	  allow_undefined_flag=' ${wl}-berok'
-	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec='$convenience'
-	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
-
-    amigaos*)
-      archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-      # see comment about different semantics on the GNU ld section
-      ld_shlibs=no
-      ;;
-
-    bsdi[45]*)
-      export_dynamic_flag_spec=-rdynamic
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      hardcode_libdir_flag_spec=' '
-      allow_undefined_flag=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      old_archive_From_new_cmds='true'
-      # FIXME: Should let the user specify the lib program.
-      old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path='`cygpath -w "$srcfile"`'
-      enable_shared_with_static_runtimes=yes
-      ;;
-
-    darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
-      archive_cmds_need_lc=no
-      hardcode_direct=no
-      hardcode_automatic=yes
-      hardcode_shlibpath_var=unsupported
-      whole_archive_flag_spec=''
-      link_all_deplibs=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs=no
-          ;;
-      esac
-    fi
-      ;;
-
-    dgux*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_shlibpath_var=no
-      ;;
-
-    freebsd1*)
-      ld_shlibs=no
-      ;;
-
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
-
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct=yes
-      hardcode_minus_L=yes
-      hardcode_shlibpath_var=no
-      ;;
-
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
-      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
-
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator=:
-      hardcode_direct=yes
-
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L=yes
-      export_dynamic_flag_spec='${wl}-E'
-      ;;
-
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator=:
-
-	hardcode_direct=yes
-	export_dynamic_flag_spec='${wl}-E'
-
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L=yes
-      fi
-      ;;
-
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator=:
-
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_libdir_flag_spec_ld='+b $libdir'
-	  hardcode_direct=no
-	  hardcode_shlibpath_var=no
-	  ;;
-	*)
-	  hardcode_direct=yes
-	  export_dynamic_flag_spec='${wl}-E'
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L=yes
-	  ;;
-	esac
-      fi
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_ld='-rpath $libdir'
-      fi
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator=:
-      link_all_deplibs=yes
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
-
-    newsos6)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct=yes
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator=:
-      hardcode_shlibpath_var=no
-      ;;
-
-    openbsd*)
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec='${wl}-E'
-      else
-       case $host_os in
-	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	   archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   hardcode_libdir_flag_spec='-R$libdir'
-	   ;;
-	 *)
-	   archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	   ;;
-       esac
-      fi
-      ;;
-
-    os2*)
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-      allow_undefined_flag=unsupported
-      archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
-
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator=:
-      ;;
-
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec='-rpath $libdir'
-      fi
-      hardcode_libdir_separator=:
-      ;;
-
-    solaris*)
-      no_undefined_flag=' -z text'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
-      else
-	wlarc=''
-	archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
-      fi
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_shlibpath_var=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
-      esac
-      link_all_deplibs=yes
-      ;;
-
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_direct=yes
-      hardcode_minus_L=yes
-      hardcode_shlibpath_var=no
-      ;;
-
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds='$CC -r -o $output$reload_objs'
-	  hardcode_direct=no
-        ;;
-	motorola)
-	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var=no
-      ;;
-
-    sysv4.3*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var=no
-      export_dynamic_flag_spec='-Bexport'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs=yes
-      fi
-      ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
-      no_undefined_flag='${wl}-z,text'
-      archive_cmds_need_lc=no
-      hardcode_shlibpath_var=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
-      archive_cmds_need_lc=no
-      hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      hardcode_libdir_separator=':'
-      link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    uts4*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_shlibpath_var=no
-      ;;
-
-    *)
-      ld_shlibs=no
-      ;;
-    esac
-  fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs" >&5
-echo "${ECHO_T}$ld_shlibs" >&6
-test "$ld_shlibs" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc=yes
-
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
-      $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl
-	pic_flag=$lt_prog_compiler_pic
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag
-        allow_undefined_flag=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc=no
-        else
-	  archive_cmds_need_lc=yes
-        fi
-        allow_undefined_flag=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $rm conftest*
-      echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
-echo "${ECHO_T}$archive_cmds_need_lc" >&6
-      ;;
-    esac
-  fi
-  ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
-
-aix4* | aix5*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
-
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-  ;;
-
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
-
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
-
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $rm \$dlpath'
-    shlibpath_overrides_runpath=yes
-
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    ;;
-
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
-
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
-
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
-
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-   hppa*64*)
-     shrext_cmds='.sl'
-     hardcode_into_libs=yes
-     dynamic_linker="$host_os dld.sl"
-     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-     soname_spec='${libname}${release}${shared_ext}$major'
-     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-     ;;
-   *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
-
-# This must be Linux ELF.
-linux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
-
-  # find out which ABI we are using
-  libsuff=
-  case "$host_cpu" in
-  x86_64*|s390x*|powerpc64*)
-    echo '#line 15621 "configure"' > conftest.$ac_ext
-    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
-  fi
-
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
-
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
-
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-nto-qnx*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
-
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
-
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      export_dynamic_flag_spec='${wl}-Blargedynsym'
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action=
-if test -n "$hardcode_libdir_flag_spec" || \
-   test -n "$runpath_var" || \
-   test "X$hardcode_automatic" = "Xyes" ; then
-
-  # We can hardcode non-existant directories.
-  if test "$hardcode_direct" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no &&
-     test "$hardcode_minus_L" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action" >&5
-echo "${ECHO_T}$hardcode_action" >&6
-
-if test "$hardcode_action" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-
-striplib=
-old_striplib=
-echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
-echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-   darwin*)
-       if test -n "$STRIP" ; then
-         striplib="$STRIP -x"
-         echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-       else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-       ;;
-   *)
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-    ;;
-  esac
-fi
-
-if test "x$enable_dlopen" != xyes; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-  lt_cv_dlopen=no
-  lt_cv_dlopen_libs=
-
-  case $host_os in
-  beos*)
-    lt_cv_dlopen="load_add_on"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ;;
-
-  mingw* | pw32*)
-    lt_cv_dlopen="LoadLibrary"
-    lt_cv_dlopen_libs=
-   ;;
-
-  cygwin*)
-    lt_cv_dlopen="dlopen"
-    lt_cv_dlopen_libs=
-   ;;
-
-  darwin*)
-  # if libdl is installed we need to link against it
-    echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_dl_dlopen=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-
-    lt_cv_dlopen="dyld"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-
-fi
-
-   ;;
-
-  *)
-    echo "$as_me:$LINENO: checking for shl_load" >&5
-echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
-if test "${ac_cv_func_shl_load+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define shl_load innocuous_shl_load
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char shl_load (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef shl_load
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char shl_load ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_shl_load) || defined (__stub___shl_load)
-choke me
-#else
-char (*f) () = shl_load;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != shl_load;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_shl_load=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
-echo "${ECHO_T}$ac_cv_func_shl_load" >&6
-if test $ac_cv_func_shl_load = yes; then
-  lt_cv_dlopen="shl_load"
-else
-  echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
-echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_shl_load+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char shl_load ();
-int
-main ()
-{
-shl_load ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_dld_shl_load=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
-if test $ac_cv_lib_dld_shl_load = yes; then
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
-else
-  echo "$as_me:$LINENO: checking for dlopen" >&5
-echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
-if test "${ac_cv_func_dlopen+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define dlopen innocuous_dlopen
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char dlopen (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef dlopen
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char dlopen ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_dlopen) || defined (__stub___dlopen)
-choke me
-#else
-char (*f) () = dlopen;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != dlopen;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_dlopen=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
-echo "${ECHO_T}$ac_cv_func_dlopen" >&6
-if test $ac_cv_func_dlopen = yes; then
-  lt_cv_dlopen="dlopen"
-else
-  echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_dl_dlopen=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-  echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
-echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
-if test "${ac_cv_lib_svld_dlopen+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsvld  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_svld_dlopen=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_svld_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
-if test $ac_cv_lib_svld_dlopen = yes; then
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
-else
-  echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
-echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_dld_link+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char dld_link ();
-int
-main ()
-{
-dld_link ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_dld_dld_link=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_dld_link=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
-if test $ac_cv_lib_dld_dld_link = yes; then
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-    ;;
-  esac
-
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
-    enable_dlopen=no
-  fi
-
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
-    save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
-    save_LIBS="$LIBS"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
-
-    echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
-echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<EOF
-#line 16518 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
-
-    exit (status);
-}
-EOF
-  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self=no
-  fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self" >&6
-
-    if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
-echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self_static+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self_static=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<EOF
-#line 16618 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
-
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
-
-    exit (status);
-}
-EOF
-  if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self_static=no
-  fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
-    fi
-
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
-
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
-
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
-
-
-# Report which library types will actually be built
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
-  test "$enable_shared" = yes && enable_static=no
-  if test -n "$RANLIB"; then
-    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-    postinstall_cmds='$RANLIB $lib'
-  fi
-  ;;
-
-aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
-    ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    compiler \
-    CC \
-    LD \
-    lt_prog_compiler_wl \
-    lt_prog_compiler_pic \
-    lt_prog_compiler_static \
-    lt_prog_compiler_no_builtin_flag \
-    export_dynamic_flag_spec \
-    thread_safe_flag_spec \
-    whole_archive_flag_spec \
-    enable_shared_with_static_runtimes \
-    old_archive_cmds \
-    old_archive_from_new_cmds \
-    predep_objects \
-    postdep_objects \
-    predeps \
-    postdeps \
-    compiler_lib_search_path \
-    archive_cmds \
-    archive_expsym_cmds \
-    postinstall_cmds \
-    postuninstall_cmds \
-    old_archive_from_expsyms_cmds \
-    allow_undefined_flag \
-    no_undefined_flag \
-    export_symbols_cmds \
-    hardcode_libdir_flag_spec \
-    hardcode_libdir_flag_spec_ld \
-    hardcode_libdir_separator \
-    hardcode_automatic \
-    module_cmds \
-    module_expsym_cmds \
-    lt_cv_prog_compiler_c_o \
-    exclude_expsyms \
-    include_expsyms; do
-
-    case $var in
-    old_archive_cmds | \
-    old_archive_from_new_cmds | \
-    archive_cmds | \
-    archive_expsym_cmds | \
-    module_cmds | \
-    module_expsym_cmds | \
-    old_archive_from_expsyms_cmds | \
-    export_symbols_cmds | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\$0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
-    ;;
-  esac
-
-cfgfile="${ofile}T"
-  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
-  $rm -f "$cfgfile"
-  { echo "$as_me:$LINENO: creating $ofile" >&5
-echo "$as_me: creating $ofile" >&6;}
-
-  cat <<__EOF__ >> "$cfgfile"
-#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC
-
-gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-gcc_ver=\`gcc -dumpversion\`
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds
-archive_expsym_cmds=$lt_archive_expsym_cmds
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds
-module_expsym_cmds=$lt_module_expsym_cmds
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=\`echo $lt_predep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=\`echo $lt_postdep_objects | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=\`echo $lt_compiler_lib_search_path | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms
-
-# ### END LIBTOOL CONFIG
-
-__EOF__
-
-
-  case $host_os in
-  aix3*)
-    cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program.  For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
-  COLLECT_NAMES=
-  export COLLECT_NAMES
-fi
-EOF
-    ;;
-  esac
-
-  # We use sed instead of cat because bash on DJGPP gets confused if
-  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
-  # text mode, it properly converts lines to CR/LF.  This bash problem
-  # is reportedly fixed, but why not run on old versions too?
-  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
-  mv -f "$cfgfile" "$ofile" || \
-    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
-  chmod +x "$ofile"
-
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
-  fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-
-# Check whether --with-tags or --without-tags was given.
-if test "${with_tags+set}" = set; then
-  withval="$with_tags"
-  tagnames="$withval"
-fi;
-
-if test -f "$ltmain" && test -n "$tagnames"; then
-  if test ! -f "${ofile}"; then
-    { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
-  fi
-
-  if test -z "$LTCC"; then
-    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
-    if test -z "$LTCC"; then
-      { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
-    else
-      { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
-echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
-    fi
-  fi
-  if test -z "$LTCFLAGS"; then
-    eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
-  fi
-
-  # Extract list of available tagged configurations in $ofile.
-  # Note that this assumes the entire list is on one line.
-  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
-  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-  for tagname in $tagnames; do
-    IFS="$lt_save_ifs"
-    # Check whether tagname contains only valid characters
-    case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
-    "") ;;
-    *)  { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5
-echo "$as_me: error: invalid tag name: $tagname" >&2;}
-   { (exit 1); exit 1; }; }
-	;;
-    esac
-
-    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
-    then
-      { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5
-echo "$as_me: error: tag name \"$tagname\" already exists" >&2;}
-   { (exit 1); exit 1; }; }
-    fi
-
-    # Update the list of available tags.
-    if test -n "$tagname"; then
-      echo appending configuration tag \"$tagname\" to $ofile
-
-      case $tagname in
-      CXX)
-	if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-	    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-	    (test "X$CXX" != "Xg++"))) ; then
-	  ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-
-
-archive_cmds_need_lc_CXX=no
-allow_undefined_flag_CXX=
-always_export_symbols_CXX=no
-archive_expsym_cmds_CXX=
-export_dynamic_flag_spec_CXX=
-hardcode_direct_CXX=no
-hardcode_libdir_flag_spec_CXX=
-hardcode_libdir_flag_spec_ld_CXX=
-hardcode_libdir_separator_CXX=
-hardcode_minus_L_CXX=no
-hardcode_shlibpath_var_CXX=unsupported
-hardcode_automatic_CXX=no
-module_cmds_CXX=
-module_expsym_cmds_CXX=
-link_all_deplibs_CXX=unknown
-old_archive_cmds_CXX=$old_archive_cmds
-no_undefined_flag_CXX=
-whole_archive_flag_spec_CXX=
-enable_shared_with_static_runtimes_CXX=no
-
-# Dependencies to place before and after the object being linked:
-predep_objects_CXX=
-postdep_objects_CXX=
-predeps_CXX=
-postdeps_CXX=
-compiler_lib_search_path_CXX=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-objext_CXX=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
-  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
-  $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
-  lt_cv_path_LD=$lt_cv_path_LDCXX
-else
-  $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-compiler_CXX=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
-  lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
-else
-  lt_prog_compiler_no_builtin_flag_CXX=
-fi
-
-if test "$GXX" = yes; then
-  # Set up default GNU C++ configuration
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
-  withval="$with_gnu_ld"
-  test "$withval" = no || with_gnu_ld=yes
-else
-  with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [\\/]* | ?:[\\/]*)
-      re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
-      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
-  echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
-      *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
-	;;
-      *)
-	test "$with_gnu_ld" != yes && break
-	;;
-      esac
-    fi
-  done
-  IFS="$lt_save_ifs"
-else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
-  echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
-   { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
-  lt_cv_prog_gnu_ld=yes
-  ;;
-*)
-  lt_cv_prog_gnu_ld=no
-  ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-
-  # Check if GNU C++ uses GNU ld as the underlying linker, since the
-  # archiving commands below assume that GNU ld is being used.
-  if test "$with_gnu_ld" = yes; then
-    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-    archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
-    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
-    #     investigate it a little bit more. (MM)
-    wlarc='${wl}'
-
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
-	grep 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    else
-      whole_archive_flag_spec_CXX=
-    fi
-  else
-    with_gnu_ld=no
-    wlarc=
-
-    # A generic and very simple default shared library creation
-    # command for GNU C++ for the case where it uses the native
-    # linker, instead of GNU ld.  If possible, this setting should
-    # overridden to take advantage of the native linker features on
-    # the platform it is being used on.
-    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-  fi
-
-  # Commands to make compiler produce verbose output that lists
-  # what "hidden" libraries, object files and flags are used when
-  # linking a shared library.
-  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
-  GXX=no
-  with_gnu_ld=no
-  wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-ld_shlibs_CXX=yes
-case $host_os in
-  aix3*)
-    # FIXME: insert proper C++ library support
-    ld_shlibs_CXX=no
-    ;;
-  aix4* | aix5*)
-    if test "$host_cpu" = ia64; then
-      # On IA64, the linker does run time linking by default, so we don't
-      # have to do anything special.
-      aix_use_runtimelinking=no
-      exp_sym_flag='-Bexport'
-      no_entry_flag=""
-    else
-      aix_use_runtimelinking=no
-
-      # Test if we are trying to use run time linking or normal
-      # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-      # need to do runtime linking.
-      case $host_os in aix4.[23]|aix4.[23].*|aix5*)
-	for ld_flag in $LDFLAGS; do
-	  case $ld_flag in
-	  *-brtl*)
-	    aix_use_runtimelinking=yes
-	    break
-	    ;;
-	  esac
-	done
-	;;
-      esac
-
-      exp_sym_flag='-bexport'
-      no_entry_flag='-bnoentry'
-    fi
-
-    # When large executables or shared objects are built, AIX ld can
-    # have problems creating the table of contents.  If linking a library
-    # or program results in "error TOC overflow" add -mminimal-toc to
-    # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-    # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-    archive_cmds_CXX=''
-    hardcode_direct_CXX=yes
-    hardcode_libdir_separator_CXX=':'
-    link_all_deplibs_CXX=yes
-
-    if test "$GXX" = yes; then
-      case $host_os in aix4.[012]|aix4.[012].*)
-      # We only want to do this on AIX 4.2 and lower, the check
-      # below for broken collect2 doesn't work under 4.3+
-	collect2name=`${CC} -print-prog-name=collect2`
-	if test -f "$collect2name" && \
-	   strings "$collect2name" | grep resolve_lib_name >/dev/null
-	then
-	  # We have reworked collect2
-	  hardcode_direct_CXX=yes
-	else
-	  # We have old collect2
-	  hardcode_direct_CXX=unsupported
-	  # It fails to find uninstalled libraries when the uninstalled
-	  # path is not listed in the libpath.  Setting hardcode_minus_L
-	  # to unsupported forces relinking
-	  hardcode_minus_L_CXX=yes
-	  hardcode_libdir_flag_spec_CXX='-L$libdir'
-	  hardcode_libdir_separator_CXX=
-	fi
-	;;
-      esac
-      shared_flag='-shared'
-      if test "$aix_use_runtimelinking" = yes; then
-	shared_flag="$shared_flag "'${wl}-G'
-      fi
-    else
-      # not using gcc
-      if test "$host_cpu" = ia64; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	shared_flag='-G'
-      else
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag='${wl}-G'
-	else
-	  shared_flag='${wl}-bM:SRE'
-	fi
-      fi
-    fi
-
-    # It seems that -bexpall does not export symbols beginning with
-    # underscore (_), so it is better to generate a list of symbols to export.
-    always_export_symbols_CXX=yes
-    if test "$aix_use_runtimelinking" = yes; then
-      # Warning - without using the other runtime loading flags (-brtl),
-      # -berok will link without error, but may produce a broken library.
-      allow_undefined_flag_CXX='-berok'
-      # Determine the default libpath from the value encoded in an empty executable.
-      cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-      hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
-
-      archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-     else
-      if test "$host_cpu" = ia64; then
-	hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
-	allow_undefined_flag_CXX="-z nodefs"
-	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-      else
-	# Determine the default libpath from the value encoded in an empty executable.
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-	hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
-	# Warning - without using the other run time loading flags,
-	# -berok will link without error, but may produce a broken library.
-	no_undefined_flag_CXX=' ${wl}-bernotok'
-	allow_undefined_flag_CXX=' ${wl}-berok'
-	# Exported symbols can be pulled into shared objects from archives
-	whole_archive_flag_spec_CXX='$convenience'
-	archive_cmds_need_lc_CXX=yes
-	# This is similar to how AIX traditionally builds its shared libraries.
-	archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-      fi
-    fi
-    ;;
-
-  beos*)
-    if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-      allow_undefined_flag_CXX=unsupported
-      # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-      # support --undefined.  This deserves some investigation.  FIXME
-      archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-    else
-      ld_shlibs_CXX=no
-    fi
-    ;;
-
-  chorus*)
-    case $cc_basename in
-      *)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-    esac
-    ;;
-
-  cygwin* | mingw* | pw32*)
-    # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
-    # as there is no search path for DLLs.
-    hardcode_libdir_flag_spec_CXX='-L$libdir'
-    allow_undefined_flag_CXX=unsupported
-    always_export_symbols_CXX=no
-    enable_shared_with_static_runtimes_CXX=yes
-
-    if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-      archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      # If the export-symbols file already is a .def file (1st line
-      # is EXPORTS), use it as is; otherwise, prepend...
-      archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	cp $export_symbols $output_objdir/$soname.def;
-      else
-	echo EXPORTS > $output_objdir/$soname.def;
-	cat $export_symbols >> $output_objdir/$soname.def;
-      fi~
-      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-    else
-      ld_shlibs_CXX=no
-    fi
-  ;;
-      darwin* | rhapsody*)
-        case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-        esac
-      archive_cmds_need_lc_CXX=no
-      hardcode_direct_CXX=no
-      hardcode_automatic_CXX=yes
-      hardcode_shlibpath_var_CXX=unsupported
-      whole_archive_flag_spec_CXX=''
-      link_all_deplibs_CXX=yes
-
-    if test "$GXX" = yes ; then
-      lt_int_apple_cc_single_mod=no
-      output_verbose_link_cmd='echo'
-      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
-       lt_int_apple_cc_single_mod=yes
-      fi
-      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-       archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      else
-          archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-        fi
-        module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          else
-            archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          fi
-            module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-          archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-          module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-          archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_CXX=no
-          ;;
-      esac
-      fi
-        ;;
-
-  dgux*)
-    case $cc_basename in
-      ec++*)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      ghcx*)
-	# Green Hills C++ Compiler
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      *)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-    esac
-    ;;
-  freebsd[12]*)
-    # C++ shared libraries reported to be fairly broken before switch to ELF
-    ld_shlibs_CXX=no
-    ;;
-  freebsd-elf*)
-    archive_cmds_need_lc_CXX=no
-    ;;
-  freebsd* | kfreebsd*-gnu | dragonfly*)
-    # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
-    # conventions
-    ld_shlibs_CXX=yes
-    ;;
-  gnu*)
-    ;;
-  hpux9*)
-    hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
-    hardcode_libdir_separator_CXX=:
-    export_dynamic_flag_spec_CXX='${wl}-E'
-    hardcode_direct_CXX=yes
-    hardcode_minus_L_CXX=yes # Not in the search PATH,
-				# but as the default
-				# location of the library.
-
-    case $cc_basename in
-    CC*)
-      # FIXME: insert proper C++ library support
-      ld_shlibs_CXX=no
-      ;;
-    aCC*)
-      archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      # Commands to make compiler produce verbose output that lists
-      # what "hidden" libraries, object files and flags are used when
-      # linking a shared library.
-      #
-      # There doesn't appear to be a way to prevent this compiler from
-      # explicitly linking system object files so we need to strip them
-      # from the output so that they don't get included in the library
-      # dependencies.
-      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-      ;;
-    *)
-      if test "$GXX" = yes; then
-        archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-        # FIXME: insert proper C++ library support
-        ld_shlibs_CXX=no
-      fi
-      ;;
-    esac
-    ;;
-  hpux10*|hpux11*)
-    if test $with_gnu_ld = no; then
-      hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_CXX=:
-
-      case $host_cpu in
-      hppa*64*|ia64*)
-	hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
-        ;;
-      *)
-	export_dynamic_flag_spec_CXX='${wl}-E'
-        ;;
-      esac
-    fi
-    case $host_cpu in
-    hppa*64*|ia64*)
-      hardcode_direct_CXX=no
-      hardcode_shlibpath_var_CXX=no
-      ;;
-    *)
-      hardcode_direct_CXX=yes
-      hardcode_minus_L_CXX=yes # Not in the search PATH,
-					      # but as the default
-					      # location of the library.
-      ;;
-    esac
-
-    case $cc_basename in
-      CC*)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      aCC*)
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	  ;;
-	esac
-	# Commands to make compiler produce verbose output that lists
-	# what "hidden" libraries, object files and flags are used when
-	# linking a shared library.
-	#
-	# There doesn't appear to be a way to prevent this compiler from
-	# explicitly linking system object files so we need to strip them
-	# from the output so that they don't get included in the library
-	# dependencies.
-	output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-	;;
-      *)
-	if test "$GXX" = yes; then
-	  if test $with_gnu_ld = no; then
-	    case $host_cpu in
-	    hppa*64*)
-	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      ;;
-	    ia64*)
-	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      ;;
-	    *)
-	      archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      ;;
-	    esac
-	  fi
-	else
-	  # FIXME: insert proper C++ library support
-	  ld_shlibs_CXX=no
-	fi
-	;;
-    esac
-    ;;
-  interix3*)
-    hardcode_direct_CXX=no
-    hardcode_shlibpath_var_CXX=no
-    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-    export_dynamic_flag_spec_CXX='${wl}-E'
-    # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-    # Instead, shared libraries are loaded at an image base (0x10000000 by
-    # default) and relocated if they conflict, which is a slow very memory
-    # consuming and fragmenting process.  To avoid this, we pick a random,
-    # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-    # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-    archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-    ;;
-  irix5* | irix6*)
-    case $cc_basename in
-      CC*)
-	# SGI C++
-	archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
-	# Archives containing C++ object files must be created using
-	# "CC -ar", where "CC" is the IRIX C++ compiler.  This is
-	# necessary to make sure instantiated templates are included
-	# in the archive.
-	old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
-	;;
-      *)
-	if test "$GXX" = yes; then
-	  if test "$with_gnu_ld" = no; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	  else
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
-	  fi
-	fi
-	link_all_deplibs_CXX=yes
-	;;
-    esac
-    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-    hardcode_libdir_separator_CXX=:
-    ;;
-  linux*)
-    case $cc_basename in
-      KCC*)
-	# Kuck and Associates, Inc. (KAI) C++ Compiler
-
-	# KCC will only create a shared library if the output file
-	# ends with ".so" (or ".sl" for HP-UX), so rename the library
-	# to its proper name (with version) after linking.
-	archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
-	# Commands to make compiler produce verbose output that lists
-	# what "hidden" libraries, object files and flags are used when
-	# linking a shared library.
-	#
-	# There doesn't appear to be a way to prevent this compiler from
-	# explicitly linking system object files so we need to strip them
-	# from the output so that they don't get included in the library
-	# dependencies.
-	output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
-	hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir'
-	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
-	# Archives containing C++ object files must be created using
-	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
-	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
-	;;
-      icpc*)
-	# Intel C++
-	with_gnu_ld=yes
-	# version 8.0 and above of icpc choke on multiply defined symbols
-	# if we add $predep_objects and $postdep_objects, however 7.1 and
-	# earlier do not add the objects themselves.
-	case `$CC -V 2>&1` in
-	*"Version 7."*)
-  	  archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-  	  archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	*)  # Version 8.0 or newer
-	  tmp_idyn=
-	  case $host_cpu in
-	    ia64*) tmp_idyn=' -i_dynamic';;
-	  esac
-  	  archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	  archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  ;;
-	esac
-	archive_cmds_need_lc_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	;;
-      pgCC*)
-        # Portland Group C++ compiler
-	archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-  	archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
-	hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-        ;;
-      cxx*)
-	# Compaq C++
-	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
-	runpath_var=LD_RUN_PATH
-	hardcode_libdir_flag_spec_CXX='-rpath $libdir'
-	hardcode_libdir_separator_CXX=:
-
-	# Commands to make compiler produce verbose output that lists
-	# what "hidden" libraries, object files and flags are used when
-	# linking a shared library.
-	#
-	# There doesn't appear to be a way to prevent this compiler from
-	# explicitly linking system object files so we need to strip them
-	# from the output so that they don't get included in the library
-	# dependencies.
-	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-	;;
-    esac
-    ;;
-  lynxos*)
-    # FIXME: insert proper C++ library support
-    ld_shlibs_CXX=no
-    ;;
-  m88k*)
-    # FIXME: insert proper C++ library support
-    ld_shlibs_CXX=no
-    ;;
-  mvs*)
-    case $cc_basename in
-      cxx*)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      *)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-    esac
-    ;;
-  netbsd*)
-    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-      archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
-      wlarc=
-      hardcode_libdir_flag_spec_CXX='-R$libdir'
-      hardcode_direct_CXX=yes
-      hardcode_shlibpath_var_CXX=no
-    fi
-    # Workaround some broken pre-1.5 toolchains
-    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
-    ;;
-  openbsd2*)
-    # C++ shared libraries are fairly broken
-    ld_shlibs_CXX=no
-    ;;
-  openbsd*)
-    hardcode_direct_CXX=yes
-    hardcode_shlibpath_var_CXX=no
-    archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-      export_dynamic_flag_spec_CXX='${wl}-E'
-      whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    fi
-    output_verbose_link_cmd='echo'
-    ;;
-  osf3*)
-    case $cc_basename in
-      KCC*)
-	# Kuck and Associates, Inc. (KAI) C++ Compiler
-
-	# KCC will only create a shared library if the output file
-	# ends with ".so" (or ".sl" for HP-UX), so rename the library
-	# to its proper name (with version) after linking.
-	archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	hardcode_libdir_separator_CXX=:
-
-	# Archives containing C++ object files must be created using
-	# "CC -Bstatic", where "CC" is the KAI C++ compiler.
-	old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
-
-	;;
-      RCC*)
-	# Rational C++ 2.4.1
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      cxx*)
-	allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	hardcode_libdir_separator_CXX=:
-
-	# Commands to make compiler produce verbose output that lists
-	# what "hidden" libraries, object files and flags are used when
-	# linking a shared library.
-	#
-	# There doesn't appear to be a way to prevent this compiler from
-	# explicitly linking system object files so we need to strip them
-	# from the output so that they don't get included in the library
-	# dependencies.
-	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-	;;
-      *)
-	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	  archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
-	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	  hardcode_libdir_separator_CXX=:
-
-	  # Commands to make compiler produce verbose output that lists
-	  # what "hidden" libraries, object files and flags are used when
-	  # linking a shared library.
-	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-	else
-	  # FIXME: insert proper C++ library support
-	  ld_shlibs_CXX=no
-	fi
-	;;
-    esac
-    ;;
-  osf4* | osf5*)
-    case $cc_basename in
-      KCC*)
-	# Kuck and Associates, Inc. (KAI) C++ Compiler
-
-	# KCC will only create a shared library if the output file
-	# ends with ".so" (or ".sl" for HP-UX), so rename the library
-	# to its proper name (with version) after linking.
-	archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	hardcode_libdir_separator_CXX=:
-
-	# Archives containing C++ object files must be created using
-	# the KAI C++ compiler.
-	old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
-	;;
-      RCC*)
-	# Rational C++ 2.4.1
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      cxx*)
-	allow_undefined_flag_CXX=' -expect_unresolved \*'
-	archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	  echo "-hidden">> $lib.exp~
-	  $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version	$verstring` -update_registry ${output_objdir}/so_locations -o $lib~
-	  $rm $lib.exp'
-
-	hardcode_libdir_flag_spec_CXX='-rpath $libdir'
-	hardcode_libdir_separator_CXX=:
-
-	# Commands to make compiler produce verbose output that lists
-	# what "hidden" libraries, object files and flags are used when
-	# linking a shared library.
-	#
-	# There doesn't appear to be a way to prevent this compiler from
-	# explicitly linking system object files so we need to strip them
-	# from the output so that they don't get included in the library
-	# dependencies.
-	output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-	;;
-      *)
-	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	  allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
-	  hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	  hardcode_libdir_separator_CXX=:
-
-	  # Commands to make compiler produce verbose output that lists
-	  # what "hidden" libraries, object files and flags are used when
-	  # linking a shared library.
-	  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-	else
-	  # FIXME: insert proper C++ library support
-	  ld_shlibs_CXX=no
-	fi
-	;;
-    esac
-    ;;
-  psos*)
-    # FIXME: insert proper C++ library support
-    ld_shlibs_CXX=no
-    ;;
-  sunos4*)
-    case $cc_basename in
-      CC*)
-	# Sun C++ 4.x
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      lcc*)
-	# Lucid
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      *)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-    esac
-    ;;
-  solaris*)
-    case $cc_basename in
-      CC*)
-	# Sun C++ 4.2, 5.x and Centerline C++
-        archive_cmds_need_lc_CXX=yes
-	no_undefined_flag_CXX=' -zdefs'
-	archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	$CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
-	hardcode_libdir_flag_spec_CXX='-R$libdir'
-	hardcode_shlibpath_var_CXX=no
-	case $host_os in
-	  solaris2.[0-5] | solaris2.[0-5].*) ;;
-	  *)
-	    # The C++ compiler is used as linker so we must use $wl
-	    # flag to pass the commands to the underlying system
-	    # linker. We must also pass each convience library through
-	    # to the system linker between allextract/defaultextract.
-	    # The C++ compiler will combine linker options so we
-	    # cannot just pass the convience library names through
-	    # without $wl.
-	    # Supported since Solaris 2.6 (maybe 2.5.1?)
-	    whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
-	    ;;
-	esac
-	link_all_deplibs_CXX=yes
-
-	output_verbose_link_cmd='echo'
-
-	# Archives containing C++ object files must be created using
-	# "CC -xar", where "CC" is the Sun C++ compiler.  This is
-	# necessary to make sure instantiated templates are included
-	# in the archive.
-	old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
-	;;
-      gcx*)
-	# Green Hills C++ Compiler
-	archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
-	# The C++ compiler must be used to create the archive.
-	old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
-	;;
-      *)
-	# GNU C++ compiler with Solaris linker
-	if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	  no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
-	  if $CC --version | grep -v '^2\.7' > /dev/null; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	    archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-		$CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
-	  else
-	    # g++ 2.7 appears to require `-G' NOT `-shared' on this
-	    # platform.
-	    archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	    archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-		$CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
-	  fi
-
-	  hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
-	fi
-	;;
-    esac
-    ;;
-  sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-    no_undefined_flag_CXX='${wl}-z,text'
-    archive_cmds_need_lc_CXX=no
-    hardcode_shlibpath_var_CXX=no
-    runpath_var='LD_RUN_PATH'
-
-    case $cc_basename in
-      CC*)
-	archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-      *)
-	archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-    esac
-    ;;
-  sysv5* | sco3.2v5* | sco5v6*)
-    # Note: We can NOT use -z defs as we might desire, because we do not
-    # link with -lc, and that would cause any symbols used from libc to
-    # always be unresolved, which means just about no library would
-    # ever link correctly.  If we're not using GNU ld we use -z text
-    # though, which does catch some bad symbols but isn't as heavy-handed
-    # as -z defs.
-    # For security reasons, it is highly recommended that you always
-    # use absolute paths for naming shared libraries, and exclude the
-    # DT_RUNPATH tag from executables and libraries.  But doing so
-    # requires that you compile everything twice, which is a pain.
-    # So that behaviour is only enabled if SCOABSPATH is set to a
-    # non-empty value in the environment.  Most likely only useful for
-    # creating official distributions of packages.
-    # This is a hack until libtool officially supports absolute path
-    # names for shared libraries.
-    no_undefined_flag_CXX='${wl}-z,text'
-    allow_undefined_flag_CXX='${wl}-z,nodefs'
-    archive_cmds_need_lc_CXX=no
-    hardcode_shlibpath_var_CXX=no
-    hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-    hardcode_libdir_separator_CXX=':'
-    link_all_deplibs_CXX=yes
-    export_dynamic_flag_spec_CXX='${wl}-Bexport'
-    runpath_var='LD_RUN_PATH'
-
-    case $cc_basename in
-      CC*)
-	archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-      *)
-	archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	;;
-    esac
-    ;;
-  tandem*)
-    case $cc_basename in
-      NCC*)
-	# NonStop-UX NCC 3.20
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-      *)
-	# FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
-    esac
-    ;;
-  vxworks*)
-    # FIXME: insert proper C++ library support
-    ld_shlibs_CXX=no
-    ;;
-  *)
-    # FIXME: insert proper C++ library support
-    ld_shlibs_CXX=no
-    ;;
-esac
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-GCC_CXX="$GXX"
-LD_CXX="$LD"
-
-
-cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
-  Foo (void) { a = 0; }
-private:
-  int a;
-};
-EOF
-
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-  # Parse the compiler output and extract the necessary
-  # objects, libraries and library flags.
-
-  # Sentinel used to keep track of whether or not we are before
-  # the conftest object file.
-  pre_test_object_deps_done=no
-
-  # The `*' in the case matches for architectures that use `case' in
-  # $output_verbose_cmd can trigger glob expansion during the loop
-  # eval without this substitution.
-  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
-  for p in `eval $output_verbose_link_cmd`; do
-    case $p in
-
-    -L* | -R* | -l*)
-       # Some compilers place space between "-{L,R}" and the path.
-       # Remove the space.
-       if test $p = "-L" \
-	  || test $p = "-R"; then
-	 prev=$p
-	 continue
-       else
-	 prev=
-       fi
-
-       if test "$pre_test_object_deps_done" = no; then
-	 case $p in
-	 -L* | -R*)
-	   # Internal compiler library paths should come after those
-	   # provided the user.  The postdeps already come after the
-	   # user supplied libs so there is no need to process them.
-	   if test -z "$compiler_lib_search_path_CXX"; then
-	     compiler_lib_search_path_CXX="${prev}${p}"
-	   else
-	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
-	   fi
-	   ;;
-	 # The "-l" case would never come before the object being
-	 # linked, so don't bother handling this case.
-	 esac
-       else
-	 if test -z "$postdeps_CXX"; then
-	   postdeps_CXX="${prev}${p}"
-	 else
-	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
-	 fi
-       fi
-       ;;
-
-    *.$objext)
-       # This assumes that the test object file only shows up
-       # once in the compiler output.
-       if test "$p" = "conftest.$objext"; then
-	 pre_test_object_deps_done=yes
-	 continue
-       fi
-
-       if test "$pre_test_object_deps_done" = no; then
-	 if test -z "$predep_objects_CXX"; then
-	   predep_objects_CXX="$p"
-	 else
-	   predep_objects_CXX="$predep_objects_CXX $p"
-	 fi
-       else
-	 if test -z "$postdep_objects_CXX"; then
-	   postdep_objects_CXX="$p"
-	 else
-	   postdep_objects_CXX="$postdep_objects_CXX $p"
-	 fi
-       fi
-       ;;
-
-    *) ;; # Ignore the rest.
-
-    esac
-  done
-
-  # Clean up.
-  rm -f a.out a.exe
-else
-  echo "libtool.m4: error: problem compiling CXX test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-case $host_os in
-interix3*)
-  # Interix 3.5 installs completely hosed .la files for C++, so rather than
-  # hack all around it, let's just trust "g++" to DTRT.
-  predep_objects_CXX=
-  postdep_objects_CXX=
-  postdeps_CXX=
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC*)
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    postdeps_CXX='-lCstd -lCrun'
-    ;;
-  esac
-  ;;
-esac
-
-
-case " $postdeps_CXX " in
-*" -lc "*) archive_cmds_need_lc_CXX=no ;;
-esac
-
-lt_prog_compiler_wl_CXX=
-lt_prog_compiler_pic_CXX=
-lt_prog_compiler_static_CXX=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
-  # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
-    lt_prog_compiler_wl_CXX='-Wl,'
-    lt_prog_compiler_static_CXX='-static'
-
-    case $host_os in
-    aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_CXX='-Bstatic'
-      fi
-      ;;
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
-      ;;
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-    mingw* | os2* | pw32*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
-      ;;
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_CXX='-fno-common'
-      ;;
-    *djgpp*)
-      # DJGPP does not support shared libraries at all
-      lt_prog_compiler_pic_CXX=
-      ;;
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_CXX=-Kconform_pic
-      fi
-      ;;
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	;;
-      *)
-	lt_prog_compiler_pic_CXX='-fPIC'
-	;;
-      esac
-      ;;
-    *)
-      lt_prog_compiler_pic_CXX='-fPIC'
-      ;;
-    esac
-  else
-    case $host_os in
-      aix4* | aix5*)
-	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
-	  # AIX 5 now supports IA64 processor
-	  lt_prog_compiler_static_CXX='-Bstatic'
-	else
-	  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
-	fi
-	;;
-      chorus*)
-	case $cc_basename in
-	cxch68*)
-	  # Green Hills C++ Compiler
-	  # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
-	  ;;
-	esac
-	;;
-       darwin*)
-         # PIC is the default on this platform
-         # Common symbols not allowed in MH_DYLIB files
-         case $cc_basename in
-           xlc*)
-           lt_prog_compiler_pic_CXX='-qnocommon'
-           lt_prog_compiler_wl_CXX='-Wl,'
-           ;;
-         esac
-       ;;
-      dgux*)
-	case $cc_basename in
-	  ec++*)
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    ;;
-	  ghcx*)
-	    # Green Hills C++ Compiler
-	    lt_prog_compiler_pic_CXX='-pic'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      freebsd* | kfreebsd*-gnu | dragonfly*)
-	# FreeBSD uses GNU C++
-	;;
-      hpux9* | hpux10* | hpux11*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
-	      lt_prog_compiler_pic_CXX='+Z'
-	    fi
-	    ;;
-	  aCC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    case $host_cpu in
-	    hppa*64*|ia64*)
-	      # +Z the default
-	      ;;
-	    *)
-	      lt_prog_compiler_pic_CXX='+Z'
-	      ;;
-	    esac
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      interix*)
-	# This is c89, which is MS Visual C++ (no shared libs)
-	# Anyone wants to do a port?
-	;;
-      irix5* | irix6* | nonstopux*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='-non_shared'
-	    # CC pic flag -KPIC is the default.
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      linux*)
-	case $cc_basename in
-	  KCC*)
-	    # KAI C++ Compiler
-	    lt_prog_compiler_wl_CXX='--backend -Wl,'
-	    lt_prog_compiler_pic_CXX='-fPIC'
-	    ;;
-	  icpc* | ecpc*)
-	    # Intel C++
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    lt_prog_compiler_static_CXX='-static'
-	    ;;
-	  pgCC*)
-	    # Portland Group C++ compiler.
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-fpic'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	  cxx*)
-	    # Compaq C++
-	    # Make sure the PIC flag is empty.  It appears that all Alpha
-	    # Linux and Compaq Tru64 Unix objects are PIC.
-	    lt_prog_compiler_pic_CXX=
-	    lt_prog_compiler_static_CXX='-non_shared'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      lynxos*)
-	;;
-      m88k*)
-	;;
-      mvs*)
-	case $cc_basename in
-	  cxx*)
-	    lt_prog_compiler_pic_CXX='-W c,exportall'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      netbsd*)
-	;;
-      osf3* | osf4* | osf5*)
-	case $cc_basename in
-	  KCC*)
-	    lt_prog_compiler_wl_CXX='--backend -Wl,'
-	    ;;
-	  RCC*)
-	    # Rational C++ 2.4.1
-	    lt_prog_compiler_pic_CXX='-pic'
-	    ;;
-	  cxx*)
-	    # Digital/Compaq C++
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    # Make sure the PIC flag is empty.  It appears that all Alpha
-	    # Linux and Compaq Tru64 Unix objects are PIC.
-	    lt_prog_compiler_pic_CXX=
-	    lt_prog_compiler_static_CXX='-non_shared'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      psos*)
-	;;
-      solaris*)
-	case $cc_basename in
-	  CC*)
-	    # Sun C++ 4.2, 5.x and Centerline C++
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    lt_prog_compiler_wl_CXX='-Qoption ld '
-	    ;;
-	  gcx*)
-	    # Green Hills C++ Compiler
-	    lt_prog_compiler_pic_CXX='-PIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      sunos4*)
-	case $cc_basename in
-	  CC*)
-	    # Sun C++ 4.x
-	    lt_prog_compiler_pic_CXX='-pic'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	  lcc*)
-	    # Lucid
-	    lt_prog_compiler_pic_CXX='-pic'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      tandem*)
-	case $cc_basename in
-	  NCC*)
-	    # NonStop-UX NCC 3.20
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	esac
-	;;
-      vxworks*)
-	;;
-      *)
-	lt_prog_compiler_can_build_shared_CXX=no
-	;;
-    esac
-  fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_CXX"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_pic_works_CXX=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:18962: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:18966: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_CXX=yes
-     fi
-   fi
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6
-
-if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then
-    case $lt_prog_compiler_pic_CXX in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
-     esac
-else
-    lt_prog_compiler_pic_CXX=
-     lt_prog_compiler_can_build_shared_CXX=no
-fi
-
-fi
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_CXX=
-    ;;
-  *)
-    lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
-    ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works_CXX=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_CXX=yes
-       fi
-     else
-       lt_prog_compiler_static_works_CXX=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6
-
-if test x"$lt_prog_compiler_static_works_CXX" = xyes; then
-    :
-else
-    lt_prog_compiler_static_CXX=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_c_o_CXX=no
-   $rm -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:19066: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:19070: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_CXX=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $rm conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
-   $rm out/* && rmdir out
-   cd ..
-   rmdir conftest
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
-  if test "$hard_links" = no; then
-    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
-  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  case $host_os in
-  aix4* | aix5*)
-    # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-    else
-      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-    fi
-    ;;
-  pw32*)
-    export_symbols_cmds_CXX="$ltdll_cmds"
-  ;;
-  cygwin* | mingw*)
-    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-  ;;
-  *)
-    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  ;;
-  esac
-
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_CXX" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_CXX=yes
-
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_CXX in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
-      $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl_CXX
-	pic_flag=$lt_prog_compiler_pic_CXX
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
-        allow_undefined_flag_CXX=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc_CXX=no
-        else
-	  archive_cmds_need_lc_CXX=yes
-        fi
-        allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $rm conftest*
-      echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6
-      ;;
-    esac
-  fi
-  ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
-
-aix4* | aix5*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
-
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-  ;;
-
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
-
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
-
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $rm \$dlpath'
-    shlibpath_overrides_runpath=yes
-
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    ;;
-
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
-
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
-
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
-
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-   hppa*64*)
-     shrext_cmds='.sl'
-     hardcode_into_libs=yes
-     dynamic_linker="$host_os dld.sl"
-     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-     soname_spec='${libname}${release}${shared_ext}$major'
-     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-     ;;
-   *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
-
-# This must be Linux ELF.
-linux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
-
-  # find out which ABI we are using
-  libsuff=
-  case "$host_cpu" in
-  x86_64*|s390x*|powerpc64*)
-    echo '#line 19602 "configure"' > conftest.$ac_ext
-    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
-  fi
-
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
-
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
-
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-nto-qnx*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
-
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
-
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      export_dynamic_flag_spec='${wl}-Blargedynsym'
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_CXX=
-if test -n "$hardcode_libdir_flag_spec_CXX" || \
-   test -n "$runpath_var_CXX" || \
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
-
-  # We can hardcode non-existant directories.
-  if test "$hardcode_direct_CXX" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
-     test "$hardcode_minus_L_CXX" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_CXX=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_CXX=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_CXX=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
-echo "${ECHO_T}$hardcode_action_CXX" >&6
-
-if test "$hardcode_action_CXX" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    compiler_CXX \
-    CC_CXX \
-    LD_CXX \
-    lt_prog_compiler_wl_CXX \
-    lt_prog_compiler_pic_CXX \
-    lt_prog_compiler_static_CXX \
-    lt_prog_compiler_no_builtin_flag_CXX \
-    export_dynamic_flag_spec_CXX \
-    thread_safe_flag_spec_CXX \
-    whole_archive_flag_spec_CXX \
-    enable_shared_with_static_runtimes_CXX \
-    old_archive_cmds_CXX \
-    old_archive_from_new_cmds_CXX \
-    predep_objects_CXX \
-    postdep_objects_CXX \
-    predeps_CXX \
-    postdeps_CXX \
-    compiler_lib_search_path_CXX \
-    archive_cmds_CXX \
-    archive_expsym_cmds_CXX \
-    postinstall_cmds_CXX \
-    postuninstall_cmds_CXX \
-    old_archive_from_expsyms_cmds_CXX \
-    allow_undefined_flag_CXX \
-    no_undefined_flag_CXX \
-    export_symbols_cmds_CXX \
-    hardcode_libdir_flag_spec_CXX \
-    hardcode_libdir_flag_spec_ld_CXX \
-    hardcode_libdir_separator_CXX \
-    hardcode_automatic_CXX \
-    module_cmds_CXX \
-    module_expsym_cmds_CXX \
-    lt_cv_prog_compiler_c_o_CXX \
-    exclude_expsyms_CXX \
-    include_expsyms_CXX; do
-
-    case $var in
-    old_archive_cmds_CXX | \
-    old_archive_from_new_cmds_CXX | \
-    archive_cmds_CXX | \
-    archive_expsym_cmds_CXX | \
-    module_cmds_CXX | \
-    module_expsym_cmds_CXX | \
-    old_archive_from_expsyms_cmds_CXX | \
-    export_symbols_cmds_CXX | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\$0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
-    ;;
-  esac
-
-cfgfile="$ofile"
-
-  cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_CXX
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_CXX
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_CXX
-
-gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-gcc_ver=\`gcc -dumpversion\`
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_CXX
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_CXX
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_CXX
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_CXX
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_CXX
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_CXX
-archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_CXX
-module_expsym_cmds=$lt_module_expsym_cmds_CXX
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=\`echo $lt_predep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=\`echo $lt_postdep_objects_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_CXX
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_CXX
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_CXX | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_CXX
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_CXX
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_CXX
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_CXX
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_CXX
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_CXX
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_CXX
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_CXX"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_CXX
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_CXX
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_CXX
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_CXX
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
-  fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-
-	else
-	  tagname=""
-	fi
-	;;
-
-      F77)
-	if test -n "$F77" && test "X$F77" != "Xno"; then
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-archive_cmds_need_lc_F77=no
-allow_undefined_flag_F77=
-always_export_symbols_F77=no
-archive_expsym_cmds_F77=
-export_dynamic_flag_spec_F77=
-hardcode_direct_F77=no
-hardcode_libdir_flag_spec_F77=
-hardcode_libdir_flag_spec_ld_F77=
-hardcode_libdir_separator_F77=
-hardcode_minus_L_F77=no
-hardcode_automatic_F77=no
-module_cmds_F77=
-module_expsym_cmds_F77=
-link_all_deplibs_F77=unknown
-old_archive_cmds_F77=$old_archive_cmds
-no_undefined_flag_F77=
-whole_archive_flag_spec_F77=
-enable_shared_with_static_runtimes_F77=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-objext_F77=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="      program t\n      end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-compiler_F77=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
-  test "$enable_shared" = yes && enable_static=no
-  if test -n "$RANLIB"; then
-    archive_cmds="$archive_cmds~\$RANLIB \$lib"
-    postinstall_cmds='$RANLIB $lib'
-  fi
-  ;;
-aix4* | aix5*)
-  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-    test "$enable_shared" = yes && enable_static=no
-  fi
-  ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-GCC_F77="$G77"
-LD_F77="$LD"
-
-lt_prog_compiler_wl_F77=
-lt_prog_compiler_pic_F77=
-lt_prog_compiler_static_F77=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl_F77='-Wl,'
-    lt_prog_compiler_static_F77='-static'
-
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_F77='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
-      ;;
-
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
-      ;;
-
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_F77='-fno-common'
-      ;;
-
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared_F77=no
-      enable_shared=no
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_F77=-Kconform_pic
-      fi
-      ;;
-
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_F77='-fPIC'
-	;;
-      esac
-      ;;
-
-    *)
-      lt_prog_compiler_pic_F77='-fPIC'
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_F77='-Bstatic'
-      else
-	lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic_F77='-qnocommon'
-         lt_prog_compiler_wl_F77='-Wl,'
-         ;;
-       esac
-       ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_F77='-DDLL_EXPORT'
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_F77='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static_F77='-non_shared'
-      ;;
-
-    newsos6)
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    linux*)
-      case $cc_basename in
-      icc* | ecc*)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-KPIC'
-	lt_prog_compiler_static_F77='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_F77='-Wl,'
-	lt_prog_compiler_pic_F77='-fpic'
-	lt_prog_compiler_static_F77='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl_F77='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static_F77='-non_shared'
-        ;;
-      esac
-      ;;
-
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static_F77='-non_shared'
-      ;;
-
-    solaris*)
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_F77='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_F77='-Wl,';;
-      esac
-      ;;
-
-    sunos4*)
-      lt_prog_compiler_wl_F77='-Qoption ld '
-      lt_prog_compiler_pic_F77='-PIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic_F77='-Kconform_pic'
-	lt_prog_compiler_static_F77='-Bstatic'
-      fi
-      ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_pic_F77='-KPIC'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    unicos*)
-      lt_prog_compiler_wl_F77='-Wl,'
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
-
-    uts4*)
-      lt_prog_compiler_pic_F77='-pic'
-      lt_prog_compiler_static_F77='-Bstatic'
-      ;;
-
-    *)
-      lt_prog_compiler_can_build_shared_F77=no
-      ;;
-    esac
-  fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_F77"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_pic_works_F77=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_F77"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:20661: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:20665: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_F77=yes
-     fi
-   fi
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6
-
-if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
-    case $lt_prog_compiler_pic_F77 in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
-     esac
-else
-    lt_prog_compiler_pic_F77=
-     lt_prog_compiler_can_build_shared_F77=no
-fi
-
-fi
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_F77=
-    ;;
-  *)
-    lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
-    ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works_F77=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_F77=yes
-       fi
-     else
-       lt_prog_compiler_static_works_F77=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6
-
-if test x"$lt_prog_compiler_static_works_F77" = xyes; then
-    :
-else
-    lt_prog_compiler_static_F77=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_c_o_F77=no
-   $rm -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:20765: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:20769: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_F77=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $rm conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
-   $rm out/* && rmdir out
-   cd ..
-   rmdir conftest
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
-  if test "$hard_links" = no; then
-    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
-  runpath_var=
-  allow_undefined_flag_F77=
-  enable_shared_with_static_runtimes_F77=no
-  archive_cmds_F77=
-  archive_expsym_cmds_F77=
-  old_archive_From_new_cmds_F77=
-  old_archive_from_expsyms_cmds_F77=
-  export_dynamic_flag_spec_F77=
-  whole_archive_flag_spec_F77=
-  thread_safe_flag_spec_F77=
-  hardcode_libdir_flag_spec_F77=
-  hardcode_libdir_flag_spec_ld_F77=
-  hardcode_libdir_separator_F77=
-  hardcode_direct_F77=no
-  hardcode_minus_L_F77=no
-  hardcode_shlibpath_var_F77=unsupported
-  link_all_deplibs_F77=unknown
-  hardcode_automatic_F77=no
-  module_cmds_F77=
-  module_expsym_cmds_F77=
-  always_export_symbols_F77=no
-  export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms_F77=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
-
-  ld_shlibs_F77=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
-
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_F77='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_F77=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix3* | aix4* | aix5*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs_F77=no
-	cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
-      fi
-      ;;
-
-    amigaos*)
-      archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_minus_L_F77=yes
-
-      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
-      # that the semantics of dynamic libraries on AmigaOS, at least up
-      # to version 4, is to share data among multiple programs linked
-      # with the same dynamic library.  Since this doesn't match the
-      # behavior of shared libraries on other platforms, we can't use
-      # them.
-      ld_shlibs_F77=no
-      ;;
-
-    beos*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag_F77=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      allow_undefined_flag_F77=unsupported
-      always_export_symbols_F77=no
-      enable_shared_with_static_runtimes_F77=yes
-      export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
-      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
-    interix3*)
-      hardcode_direct_F77=no
-      hardcode_shlibpath_var_F77=no
-      hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec_F77='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
-
-    solaris*)
-      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
-	ld_shlibs_F77=no
-	cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
-      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs_F77=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-	;;
-	*)
-	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-	    archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-	    archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-	  else
-	    ld_shlibs_F77=no
-	  fi
-	;;
-      esac
-      ;;
-
-    sunos4*)
-      archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    *)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_F77=no
-      fi
-      ;;
-    esac
-
-    if test "$ld_shlibs_F77" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_F77=
-      export_dynamic_flag_spec_F77=
-      whole_archive_flag_spec_F77=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag_F77=unsupported
-      always_export_symbols_F77=yes
-      archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L_F77=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct_F77=unsupported
-      fi
-      ;;
-
-    aix4* | aix5*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-	  export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
-
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
-	  for ld_flag in $LDFLAGS; do
-  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-  	    aix_use_runtimelinking=yes
-  	    break
-  	  fi
-	  done
-	  ;;
-	esac
-
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
-
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-      archive_cmds_F77=''
-      hardcode_direct_F77=yes
-      hardcode_libdir_separator_F77=':'
-      link_all_deplibs_F77=yes
-
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" && \
-  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
-	  then
-  	  # We have reworked collect2
-  	  hardcode_direct_F77=yes
-	  else
-  	  # We have old collect2
-  	  hardcode_direct_F77=unsupported
-  	  # It fails to find uninstalled libraries when the uninstalled
-  	  # path is not listed in the libpath.  Setting hardcode_minus_L
-  	  # to unsupported forces relinking
-  	  hardcode_minus_L_F77=yes
-  	  hardcode_libdir_flag_spec_F77='-L$libdir'
-  	  hardcode_libdir_separator_F77=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-  	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
-
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols_F77=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag_F77='-berok'
-       # Determine the default libpath from the value encoded in an empty executable.
-       cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-       hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
-	archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag_F77="-z nodefs"
-	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an empty executable.
-	 cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-	 hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag_F77=' ${wl}-bernotok'
-	  allow_undefined_flag_F77=' ${wl}-berok'
-	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec_F77='$convenience'
-	  archive_cmds_need_lc_F77=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
-
-    amigaos*)
-      archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_minus_L_F77=yes
-      # see comment about different semantics on the GNU ld section
-      ld_shlibs_F77=no
-      ;;
-
-    bsdi[45]*)
-      export_dynamic_flag_spec_F77=-rdynamic
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      hardcode_libdir_flag_spec_F77=' '
-      allow_undefined_flag_F77=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      old_archive_From_new_cmds_F77='true'
-      # FIXME: Should let the user specify the lib program.
-      old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
-      enable_shared_with_static_runtimes_F77=yes
-      ;;
-
-    darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
-      archive_cmds_need_lc_F77=no
-      hardcode_direct_F77=no
-      hardcode_automatic_F77=yes
-      hardcode_shlibpath_var_F77=unsupported
-      whole_archive_flag_spec_F77=''
-      link_all_deplibs_F77=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_F77=no
-          ;;
-      esac
-    fi
-      ;;
-
-    dgux*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    freebsd1*)
-      ld_shlibs_F77=no
-      ;;
-
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_F77=yes
-      hardcode_minus_L_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
-      archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      hardcode_direct_F77=yes
-
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L_F77=yes
-      export_dynamic_flag_spec_F77='${wl}-E'
-      ;;
-
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_F77=:
-
-	hardcode_direct_F77=yes
-	export_dynamic_flag_spec_F77='${wl}-E'
-
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L_F77=yes
-      fi
-      ;;
-
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_F77=:
-
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_libdir_flag_spec_ld_F77='+b $libdir'
-	  hardcode_direct_F77=no
-	  hardcode_shlibpath_var_F77=no
-	  ;;
-	*)
-	  hardcode_direct_F77=yes
-	  export_dynamic_flag_spec_F77='${wl}-E'
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L_F77=yes
-	  ;;
-	esac
-      fi
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
-      fi
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      link_all_deplibs_F77=yes
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    newsos6)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_F77=yes
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    openbsd*)
-      hardcode_direct_F77=yes
-      hardcode_shlibpath_var_F77=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_F77='${wl}-E'
-      else
-       case $host_os in
-	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	   archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   hardcode_libdir_flag_spec_F77='-R$libdir'
-	   ;;
-	 *)
-	   archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
-	   ;;
-       esac
-      fi
-      ;;
-
-    os2*)
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_minus_L_F77=yes
-      allow_undefined_flag_F77=unsupported
-      archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
-
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag_F77=' -expect_unresolved \*'
-	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_F77=:
-      ;;
-
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag_F77=' -expect_unresolved \*'
-	archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec_F77='-rpath $libdir'
-      fi
-      hardcode_libdir_separator_F77=:
-      ;;
-
-    solaris*)
-      no_undefined_flag_F77=' -z text'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
-      else
-	wlarc=''
-	archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
-      fi
-      hardcode_libdir_flag_spec_F77='-R$libdir'
-      hardcode_shlibpath_var_F77=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
-      esac
-      link_all_deplibs_F77=yes
-      ;;
-
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_direct_F77=yes
-      hardcode_minus_L_F77=yes
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_F77=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds_F77='$CC -r -o $output$reload_objs'
-	  hardcode_direct_F77=no
-        ;;
-	motorola)
-	  archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    sysv4.3*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var_F77=no
-      export_dynamic_flag_spec_F77='-Bexport'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var_F77=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs_F77=yes
-      fi
-      ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
-      no_undefined_flag_F77='${wl}-z,text'
-      archive_cmds_need_lc_F77=no
-      hardcode_shlibpath_var_F77=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag_F77='${wl}-z,text'
-      allow_undefined_flag_F77='${wl}-z,nodefs'
-      archive_cmds_need_lc_F77=no
-      hardcode_shlibpath_var_F77=no
-      hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      hardcode_libdir_separator_F77=':'
-      link_all_deplibs_F77=yes
-      export_dynamic_flag_spec_F77='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    uts4*)
-      archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_F77='-L$libdir'
-      hardcode_shlibpath_var_F77=no
-      ;;
-
-    *)
-      ld_shlibs_F77=no
-      ;;
-    esac
-  fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
-echo "${ECHO_T}$ld_shlibs_F77" >&6
-test "$ld_shlibs_F77" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_F77" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_F77=yes
-
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_F77 in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
-      $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl_F77
-	pic_flag=$lt_prog_compiler_pic_F77
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag_F77
-        allow_undefined_flag_F77=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc_F77=no
-        else
-	  archive_cmds_need_lc_F77=yes
-        fi
-        allow_undefined_flag_F77=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $rm conftest*
-      echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6
-      ;;
-    esac
-  fi
-  ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
-
-aix4* | aix5*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
-
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-  ;;
-
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
-
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
-
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $rm \$dlpath'
-    shlibpath_overrides_runpath=yes
-
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    ;;
-
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
-
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
-
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
-
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-   hppa*64*)
-     shrext_cmds='.sl'
-     hardcode_into_libs=yes
-     dynamic_linker="$host_os dld.sl"
-     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-     soname_spec='${libname}${release}${shared_ext}$major'
-     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-     ;;
-   *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
-
-# This must be Linux ELF.
-linux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
-
-  # find out which ABI we are using
-  libsuff=
-  case "$host_cpu" in
-  x86_64*|s390x*|powerpc64*)
-    echo '#line 22214 "configure"' > conftest.$ac_ext
-    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
-  fi
-
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
-
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
-
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-nto-qnx*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
-
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
-
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      export_dynamic_flag_spec='${wl}-Blargedynsym'
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_F77=
-if test -n "$hardcode_libdir_flag_spec_F77" || \
-   test -n "$runpath_var_F77" || \
-   test "X$hardcode_automatic_F77" = "Xyes" ; then
-
-  # We can hardcode non-existant directories.
-  if test "$hardcode_direct_F77" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
-     test "$hardcode_minus_L_F77" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_F77=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_F77=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_F77=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
-echo "${ECHO_T}$hardcode_action_F77" >&6
-
-if test "$hardcode_action_F77" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    compiler_F77 \
-    CC_F77 \
-    LD_F77 \
-    lt_prog_compiler_wl_F77 \
-    lt_prog_compiler_pic_F77 \
-    lt_prog_compiler_static_F77 \
-    lt_prog_compiler_no_builtin_flag_F77 \
-    export_dynamic_flag_spec_F77 \
-    thread_safe_flag_spec_F77 \
-    whole_archive_flag_spec_F77 \
-    enable_shared_with_static_runtimes_F77 \
-    old_archive_cmds_F77 \
-    old_archive_from_new_cmds_F77 \
-    predep_objects_F77 \
-    postdep_objects_F77 \
-    predeps_F77 \
-    postdeps_F77 \
-    compiler_lib_search_path_F77 \
-    archive_cmds_F77 \
-    archive_expsym_cmds_F77 \
-    postinstall_cmds_F77 \
-    postuninstall_cmds_F77 \
-    old_archive_from_expsyms_cmds_F77 \
-    allow_undefined_flag_F77 \
-    no_undefined_flag_F77 \
-    export_symbols_cmds_F77 \
-    hardcode_libdir_flag_spec_F77 \
-    hardcode_libdir_flag_spec_ld_F77 \
-    hardcode_libdir_separator_F77 \
-    hardcode_automatic_F77 \
-    module_cmds_F77 \
-    module_expsym_cmds_F77 \
-    lt_cv_prog_compiler_c_o_F77 \
-    exclude_expsyms_F77 \
-    include_expsyms_F77; do
-
-    case $var in
-    old_archive_cmds_F77 | \
-    old_archive_from_new_cmds_F77 | \
-    archive_cmds_F77 | \
-    archive_expsym_cmds_F77 | \
-    module_cmds_F77 | \
-    module_expsym_cmds_F77 | \
-    old_archive_from_expsyms_cmds_F77 | \
-    export_symbols_cmds_F77 | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\$0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
-    ;;
-  esac
-
-cfgfile="$ofile"
-
-  cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_F77
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_F77
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_F77
-
-gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-gcc_ver=\`gcc -dumpversion\`
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_F77
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_F77
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_F77
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_F77
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_F77
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_F77
-archive_expsym_cmds=$lt_archive_expsym_cmds_F77
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_F77
-module_expsym_cmds=$lt_module_expsym_cmds_F77
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=\`echo $lt_predep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=\`echo $lt_postdep_objects_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_F77
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_F77 | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_F77
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_F77
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_F77
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_F77
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_F77
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_F77
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_F77
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_F77"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_F77
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_F77
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_F77
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_F77
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
-  fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-	else
-	  tagname=""
-	fi
-	;;
-
-      GCJ)
-	if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-
-
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-objext_GCJ=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-compiler_GCJ=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-archive_cmds_need_lc_GCJ=no
-
-old_archive_cmds_GCJ=$old_archive_cmds
-
-
-lt_prog_compiler_no_builtin_flag_GCJ=
-
-if test "$GCC" = yes; then
-  lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_rtti_exceptions=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:22993: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:22997: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_rtti_exceptions=yes
-     fi
-   fi
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
-    lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
-else
-    :
-fi
-
-fi
-
-lt_prog_compiler_wl_GCJ=
-lt_prog_compiler_pic_GCJ=
-lt_prog_compiler_static_GCJ=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl_GCJ='-Wl,'
-    lt_prog_compiler_static_GCJ='-static'
-
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_GCJ='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      # FIXME: we need at least 68020 code to build shared libraries, but
-      # adding the `-m68020' flag to GCC prevents building anything better,
-      # like `-m68040'.
-      lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
-      ;;
-
-    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
-      ;;
-
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_GCJ='-fno-common'
-      ;;
-
-    interix3*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared_GCJ=no
-      enable_shared=no
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_GCJ=-Kconform_pic
-      fi
-      ;;
-
-    hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_GCJ='-fPIC'
-	;;
-      esac
-      ;;
-
-    *)
-      lt_prog_compiler_pic_GCJ='-fPIC'
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_GCJ='-Bstatic'
-      else
-	lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-      darwin*)
-        # PIC is the default on this platform
-        # Common symbols not allowed in MH_DYLIB files
-       case $cc_basename in
-         xlc*)
-         lt_prog_compiler_pic_GCJ='-qnocommon'
-         lt_prog_compiler_wl_GCJ='-Wl,'
-         ;;
-       esac
-       ;;
-
-    mingw* | pw32* | os2*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_GCJ='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static_GCJ='-non_shared'
-      ;;
-
-    newsos6)
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
-
-    linux*)
-      case $cc_basename in
-      icc* | ecc*)
-	lt_prog_compiler_wl_GCJ='-Wl,'
-	lt_prog_compiler_pic_GCJ='-KPIC'
-	lt_prog_compiler_static_GCJ='-static'
-        ;;
-      pgcc* | pgf77* | pgf90* | pgf95*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_GCJ='-Wl,'
-	lt_prog_compiler_pic_GCJ='-fpic'
-	lt_prog_compiler_static_GCJ='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl_GCJ='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static_GCJ='-non_shared'
-        ;;
-      esac
-      ;;
-
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static_GCJ='-non_shared'
-      ;;
-
-    solaris*)
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95*)
-	lt_prog_compiler_wl_GCJ='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_GCJ='-Wl,';;
-      esac
-      ;;
-
-    sunos4*)
-      lt_prog_compiler_wl_GCJ='-Qoption ld '
-      lt_prog_compiler_pic_GCJ='-PIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
-
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic_GCJ='-Kconform_pic'
-	lt_prog_compiler_static_GCJ='-Bstatic'
-      fi
-      ;;
-
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_pic_GCJ='-KPIC'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
-
-    unicos*)
-      lt_prog_compiler_wl_GCJ='-Wl,'
-      lt_prog_compiler_can_build_shared_GCJ=no
-      ;;
-
-    uts4*)
-      lt_prog_compiler_pic_GCJ='-pic'
-      lt_prog_compiler_static_GCJ='-Bstatic'
-      ;;
-
-    *)
-      lt_prog_compiler_can_build_shared_GCJ=no
-      ;;
-    esac
-  fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_GCJ"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_pic_works_GCJ=no
-  ac_outfile=conftest.$ac_objext
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:23261: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:23265: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_prog_compiler_pic_works_GCJ=yes
-     fi
-   fi
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
-    case $lt_prog_compiler_pic_GCJ in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
-     esac
-else
-    lt_prog_compiler_pic_GCJ=
-     lt_prog_compiler_can_build_shared_GCJ=no
-fi
-
-fi
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_GCJ=
-    ;;
-  *)
-    lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
-    ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_prog_compiler_static_works_GCJ=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   printf "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_prog_compiler_static_works_GCJ=yes
-       fi
-     else
-       lt_prog_compiler_static_works_GCJ=yes
-     fi
-   fi
-   $rm conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then
-    :
-else
-    lt_prog_compiler_static_GCJ=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_prog_compiler_c_o_GCJ=no
-   $rm -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:23365: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:23369: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_GCJ=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $rm conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
-   $rm out/* && rmdir out
-   cd ..
-   rmdir conftest
-   $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
-  hard_links=yes
-  $rm conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
-  if test "$hard_links" = no; then
-    { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
-  runpath_var=
-  allow_undefined_flag_GCJ=
-  enable_shared_with_static_runtimes_GCJ=no
-  archive_cmds_GCJ=
-  archive_expsym_cmds_GCJ=
-  old_archive_From_new_cmds_GCJ=
-  old_archive_from_expsyms_cmds_GCJ=
-  export_dynamic_flag_spec_GCJ=
-  whole_archive_flag_spec_GCJ=
-  thread_safe_flag_spec_GCJ=
-  hardcode_libdir_flag_spec_GCJ=
-  hardcode_libdir_flag_spec_ld_GCJ=
-  hardcode_libdir_separator_GCJ=
-  hardcode_direct_GCJ=no
-  hardcode_minus_L_GCJ=no
-  hardcode_shlibpath_var_GCJ=unsupported
-  link_all_deplibs_GCJ=unknown
-  hardcode_automatic_GCJ=no
-  module_cmds_GCJ=
-  module_expsym_cmds_GCJ=
-  always_export_symbols_GCJ=no
-  export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms_GCJ=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  extract_expsyms_cmds=
-  # Just being paranoid about ensuring that cc_basename is set.
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-  case $host_os in
-  cygwin* | mingw* | pw32*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
-
-  ld_shlibs_GCJ=yes
-  if test "$with_gnu_ld" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
-
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
-    export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
-	whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-      else
-  	whole_archive_flag_spec_GCJ=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>/dev/null` in
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
-
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix3* | aix4* | aix5*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs_GCJ=no
-	cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
-      fi
-      ;;
-
-    amigaos*)
-      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_minus_L_GCJ=yes
-
-      # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
-      # that the semantics of dynamic libraries on AmigaOS, at least up
-      # to version 4, is to share data among multiple programs linked
-      # with the same dynamic library.  Since this doesn't match the
-      # behavior of shared libraries on other platforms, we can't use
-      # them.
-      ld_shlibs_GCJ=no
-      ;;
-
-    beos*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag_GCJ=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs_GCJ=no
-      fi
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      allow_undefined_flag_GCJ=unsupported
-      always_export_symbols_GCJ=no
-      enable_shared_with_static_runtimes_GCJ=yes
-      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
-      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
-        archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs_GCJ=no
-      fi
-      ;;
-
-    interix3*)
-      hardcode_direct_GCJ=no
-      hardcode_shlibpath_var_GCJ=no
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec_GCJ='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
-
-    linux*)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	tmp_addflag=
-	case $cc_basename,$host_cpu in
-	pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95*)	# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)		# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	esac
-	archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
-	if test $supports_anon_versioning = yes; then
-	  archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
-  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-  $echo "local: *; };" >> $output_objdir/$libname.ver~
-	  $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	fi
-      else
-	ld_shlibs_GCJ=no
-      fi
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
-
-    solaris*)
-      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
-	ld_shlibs_GCJ=no
-	cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
-      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_GCJ=no
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs_GCJ=no
-	cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
-	;;
-	*)
-	  if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
-	    archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
-	    archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
-	  else
-	    ld_shlibs_GCJ=no
-	  fi
-	;;
-      esac
-      ;;
-
-    sunos4*)
-      archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    *)
-      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_GCJ=no
-      fi
-      ;;
-    esac
-
-    if test "$ld_shlibs_GCJ" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_GCJ=
-      export_dynamic_flag_spec_GCJ=
-      whole_archive_flag_spec_GCJ=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag_GCJ=unsupported
-      always_export_symbols_GCJ=yes
-      archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L_GCJ=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct_GCJ=unsupported
-      fi
-      ;;
-
-    aix4* | aix5*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
-	  export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
-
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix5*)
-	  for ld_flag in $LDFLAGS; do
-  	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-  	    aix_use_runtimelinking=yes
-  	    break
-  	  fi
-	  done
-	  ;;
-	esac
-
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
-
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-      archive_cmds_GCJ=''
-      hardcode_direct_GCJ=yes
-      hardcode_libdir_separator_GCJ=':'
-      link_all_deplibs_GCJ=yes
-
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" && \
-  	   strings "$collect2name" | grep resolve_lib_name >/dev/null
-	  then
-  	  # We have reworked collect2
-  	  hardcode_direct_GCJ=yes
-	  else
-  	  # We have old collect2
-  	  hardcode_direct_GCJ=unsupported
-  	  # It fails to find uninstalled libraries when the uninstalled
-  	  # path is not listed in the libpath.  Setting hardcode_minus_L
-  	  # to unsupported forces relinking
-  	  hardcode_minus_L_GCJ=yes
-  	  hardcode_libdir_flag_spec_GCJ='-L$libdir'
-  	  hardcode_libdir_separator_GCJ=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-  	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-  	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
-
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols_GCJ=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag_GCJ='-berok'
-       # Determine the default libpath from the value encoded in an empty executable.
-       cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-       hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
-	archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-       else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag_GCJ="-z nodefs"
-	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an empty executable.
-	 cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
-}'`; fi
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
-	 hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag_GCJ=' ${wl}-bernotok'
-	  allow_undefined_flag_GCJ=' ${wl}-berok'
-	  # Exported symbols can be pulled into shared objects from archives
-	  whole_archive_flag_spec_GCJ='$convenience'
-	  archive_cmds_need_lc_GCJ=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
-
-    amigaos*)
-      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_minus_L_GCJ=yes
-      # see comment about different semantics on the GNU ld section
-      ld_shlibs_GCJ=no
-      ;;
-
-    bsdi[45]*)
-      export_dynamic_flag_spec_GCJ=-rdynamic
-      ;;
-
-    cygwin* | mingw* | pw32*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      hardcode_libdir_flag_spec_GCJ=' '
-      allow_undefined_flag_GCJ=unsupported
-      # Tell ltmain to make .lib files, not .a files.
-      libext=lib
-      # Tell ltmain to make .dll files, not .so files.
-      shrext_cmds=".dll"
-      # FIXME: Setting linknames here is a bad hack.
-      archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
-      # The linker will automatically build a .lib file if we build a DLL.
-      old_archive_From_new_cmds_GCJ='true'
-      # FIXME: Should let the user specify the lib program.
-      old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
-      fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
-      enable_shared_with_static_runtimes_GCJ=yes
-      ;;
-
-    darwin* | rhapsody*)
-      case $host_os in
-        rhapsody* | darwin1.[012])
-         allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
-         ;;
-       *) # Darwin 1.3 on
-         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
-           allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-         else
-           case ${MACOSX_DEPLOYMENT_TARGET} in
-             10.[012])
-               allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
-               ;;
-             10.*)
-               allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
-               ;;
-           esac
-         fi
-         ;;
-      esac
-      archive_cmds_need_lc_GCJ=no
-      hardcode_direct_GCJ=no
-      hardcode_automatic_GCJ=yes
-      hardcode_shlibpath_var_GCJ=unsupported
-      whole_archive_flag_spec_GCJ=''
-      link_all_deplibs_GCJ=yes
-    if test "$GCC" = yes ; then
-    	output_verbose_link_cmd='echo'
-        archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
-      module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-      archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-      module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    else
-      case $cc_basename in
-        xlc*)
-         output_verbose_link_cmd='echo'
-         archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
-         module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
-          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
-         archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
-          ;;
-       *)
-         ld_shlibs_GCJ=no
-          ;;
-      esac
-    fi
-      ;;
-
-    dgux*)
-      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    freebsd1*)
-      ld_shlibs_GCJ=no
-      ;;
-
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
-      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_GCJ=yes
-      hardcode_minus_L_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu | dragonfly*)
-      archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      hardcode_direct_GCJ=yes
-
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L_GCJ=yes
-      export_dynamic_flag_spec_GCJ='${wl}-E'
-      ;;
-
-    hpux10*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_GCJ=:
-
-	hardcode_direct_GCJ=yes
-	export_dynamic_flag_spec_GCJ='${wl}-E'
-
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L_GCJ=yes
-      fi
-      ;;
-
-    hpux11*)
-      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_GCJ=:
-
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
-	  hardcode_direct_GCJ=no
-	  hardcode_shlibpath_var_GCJ=no
-	  ;;
-	*)
-	  hardcode_direct_GCJ=yes
-	  export_dynamic_flag_spec_GCJ='${wl}-E'
-
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L_GCJ=yes
-	  ;;
-	esac
-      fi
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
-      fi
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      link_all_deplibs_GCJ=yes
-      ;;
-
-    netbsd*)
-      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-	archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    newsos6)
-      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_GCJ=yes
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    openbsd*)
-      hardcode_direct_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_GCJ='${wl}-E'
-      else
-       case $host_os in
-	 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	   archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	   hardcode_libdir_flag_spec_GCJ='-R$libdir'
-	   ;;
-	 *)
-	   archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	   hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
-	   ;;
-       esac
-      fi
-      ;;
-
-    os2*)
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_minus_L_GCJ=yes
-      allow_undefined_flag_GCJ=unsupported
-      archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
-
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag_GCJ=' -expect_unresolved \*'
-	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_GCJ=:
-      ;;
-
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag_GCJ=' -expect_unresolved \*'
-	archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
-	$LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
-      fi
-      hardcode_libdir_separator_GCJ=:
-      ;;
-
-    solaris*)
-      no_undefined_flag_GCJ=' -z text'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-	  $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
-      else
-	wlarc=''
-	archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
-  	$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
-      fi
-      hardcode_libdir_flag_spec_GCJ='-R$libdir'
-      hardcode_shlibpath_var_GCJ=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
- 	# The compiler driver will combine linker options so we
- 	# cannot just pass the convience library names through
- 	# without $wl, iff we do not link with $LD.
- 	# Luckily, gcc supports the same syntax we need for Sun Studio.
- 	# Supported since Solaris 2.6 (maybe 2.5.1?)
- 	case $wlarc in
- 	'')
- 	  whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
- 	*)
- 	  whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- 	esac ;;
-      esac
-      link_all_deplibs_GCJ=yes
-      ;;
-
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_direct_GCJ=yes
-      hardcode_minus_L_GCJ=yes
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_GCJ=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds_GCJ='$CC -r -o $output$reload_objs'
-	  hardcode_direct_GCJ=no
-        ;;
-	motorola)
-	  archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    sysv4.3*)
-      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var_GCJ=no
-      export_dynamic_flag_spec_GCJ='-Bexport'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var_GCJ=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs_GCJ=yes
-      fi
-      ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
-      no_undefined_flag_GCJ='${wl}-z,text'
-      archive_cmds_need_lc_GCJ=no
-      hardcode_shlibpath_var_GCJ=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag_GCJ='${wl}-z,text'
-      allow_undefined_flag_GCJ='${wl}-z,nodefs'
-      archive_cmds_need_lc_GCJ=no
-      hardcode_shlibpath_var_GCJ=no
-      hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
-      hardcode_libdir_separator_GCJ=':'
-      link_all_deplibs_GCJ=yes
-      export_dynamic_flag_spec_GCJ='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    uts4*)
-      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_GCJ='-L$libdir'
-      hardcode_shlibpath_var_GCJ=no
-      ;;
-
-    *)
-      ld_shlibs_GCJ=no
-      ;;
-    esac
-  fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
-echo "${ECHO_T}$ld_shlibs_GCJ" >&6
-test "$ld_shlibs_GCJ" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_GCJ" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_GCJ=yes
-
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_GCJ in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
-      $rm conftest*
-      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-      if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } 2>conftest.err; then
-        soname=conftest
-        lib=conftest
-        libobjs=conftest.$ac_objext
-        deplibs=
-        wl=$lt_prog_compiler_wl_GCJ
-	pic_flag=$lt_prog_compiler_pic_GCJ
-        compiler_flags=-v
-        linker_flags=-v
-        verstring=
-        output_objdir=.
-        libname=conftest
-        lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
-        allow_undefined_flag_GCJ=
-        if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
-  (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-        then
-	  archive_cmds_need_lc_GCJ=no
-        else
-	  archive_cmds_need_lc_GCJ=yes
-        fi
-        allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
-      else
-        cat conftest.err 1>&5
-      fi
-      $rm conftest*
-      echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6
-      ;;
-    esac
-  fi
-  ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
-  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-  else
-    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-  fi
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
-
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
-
-aix4* | aix5*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
-
-amigaos*)
-  library_names_spec='$libname.ixlibrary $libname.a'
-  # Create ${libname}_ixlibrary.a entries in /sys/libs.
-  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-  ;;
-
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
-
-bsdi[45]*)
-  version_type=linux
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
-
-  case $GCC,$host_os in
-  yes,cygwin* | yes,mingw* | yes,pw32*)
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $rm \$dlpath'
-    shlibpath_overrides_runpath=yes
-
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
-      ;;
-    mingw*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
-      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH printed by
-        # mingw gcc, but we are running on Cygwin. Gcc prints its search
-        # path with ; separators, and with drive letters. We can handle the
-        # drive letters (cygwin fileutils understands them), so leave them,
-        # especially as we might pass files found there to a mingw objdump,
-        # which wouldn't understand a cygwinified path. Ahh.
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    ;;
-
-  *)
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    ;;
-  esac
-  dynamic_linker='Win32 ld.exe'
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
-
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
-  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
-  if test "$GCC" = yes; then
-    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
-  else
-    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
-  fi
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
-
-dgux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-freebsd1*)
-  dynamic_linker=no
-  ;;
-
-kfreebsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[123]*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  freebsd*) # from 4.6 on
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
-
-gnu*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  ;;
-
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-   hppa*64*)
-     shrext_cmds='.sl'
-     hardcode_into_libs=yes
-     dynamic_linker="$host_os dld.sl"
-     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-     soname_spec='${libname}${release}${shared_ext}$major'
-     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-     ;;
-   *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
-  postinstall_cmds='chmod 555 $lib'
-  ;;
-
-interix3*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
-
-# This must be Linux ELF.
-linux*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
-
-  # find out which ABI we are using
-  libsuff=
-  case "$host_cpu" in
-  x86_64*|s390x*|powerpc64*)
-    echo '#line 24834 "configure"' > conftest.$ac_ext
-    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-      case `/usr/bin/file conftest.$ac_objext` in
-      *64-bit*)
-        libsuff=64
-        sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
-        ;;
-      esac
-    fi
-    rm -rf conftest*
-    ;;
-  esac
-
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
-  fi
-
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
-
-knetbsd*-gnu)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='GNU ld.so'
-  ;;
-
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
-
-newsos6)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-nto-qnx*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
-
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
-    *)                         need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
-
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
-
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
-
-solaris*)
-  version_type=linux
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.3*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      export_dynamic_flag_spec='${wl}-Blargedynsym'
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-    shlibpath_overrides_runpath=no
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    shlibpath_overrides_runpath=yes
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-uts4*)
-  version_type=linux
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_GCJ=
-if test -n "$hardcode_libdir_flag_spec_GCJ" || \
-   test -n "$runpath_var_GCJ" || \
-   test "X$hardcode_automatic_GCJ" = "Xyes" ; then
-
-  # We can hardcode non-existant directories.
-  if test "$hardcode_direct_GCJ" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
-     test "$hardcode_minus_L_GCJ" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_GCJ=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_GCJ=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_GCJ=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
-echo "${ECHO_T}$hardcode_action_GCJ" >&6
-
-if test "$hardcode_action_GCJ" = relink; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    compiler_GCJ \
-    CC_GCJ \
-    LD_GCJ \
-    lt_prog_compiler_wl_GCJ \
-    lt_prog_compiler_pic_GCJ \
-    lt_prog_compiler_static_GCJ \
-    lt_prog_compiler_no_builtin_flag_GCJ \
-    export_dynamic_flag_spec_GCJ \
-    thread_safe_flag_spec_GCJ \
-    whole_archive_flag_spec_GCJ \
-    enable_shared_with_static_runtimes_GCJ \
-    old_archive_cmds_GCJ \
-    old_archive_from_new_cmds_GCJ \
-    predep_objects_GCJ \
-    postdep_objects_GCJ \
-    predeps_GCJ \
-    postdeps_GCJ \
-    compiler_lib_search_path_GCJ \
-    archive_cmds_GCJ \
-    archive_expsym_cmds_GCJ \
-    postinstall_cmds_GCJ \
-    postuninstall_cmds_GCJ \
-    old_archive_from_expsyms_cmds_GCJ \
-    allow_undefined_flag_GCJ \
-    no_undefined_flag_GCJ \
-    export_symbols_cmds_GCJ \
-    hardcode_libdir_flag_spec_GCJ \
-    hardcode_libdir_flag_spec_ld_GCJ \
-    hardcode_libdir_separator_GCJ \
-    hardcode_automatic_GCJ \
-    module_cmds_GCJ \
-    module_expsym_cmds_GCJ \
-    lt_cv_prog_compiler_c_o_GCJ \
-    exclude_expsyms_GCJ \
-    include_expsyms_GCJ; do
-
-    case $var in
-    old_archive_cmds_GCJ | \
-    old_archive_from_new_cmds_GCJ | \
-    archive_cmds_GCJ | \
-    archive_expsym_cmds_GCJ | \
-    module_cmds_GCJ | \
-    module_expsym_cmds_GCJ | \
-    old_archive_from_expsyms_cmds_GCJ | \
-    export_symbols_cmds_GCJ | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\$0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
-    ;;
-  esac
-
-cfgfile="$ofile"
-
-  cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_GCJ
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_GCJ
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_GCJ
-
-gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-gcc_ver=\`gcc -dumpversion\`
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_GCJ
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_GCJ
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_GCJ
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_GCJ
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_GCJ
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_GCJ
-archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_GCJ
-module_expsym_cmds=$lt_module_expsym_cmds_GCJ
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=\`echo $lt_predep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=\`echo $lt_postdep_objects_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_GCJ
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_GCJ
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_GCJ | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_GCJ
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_GCJ
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_GCJ
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_GCJ
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_GCJ
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_GCJ
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_GCJ
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_GCJ"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_GCJ
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_GCJ
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_GCJ
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_GCJ
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
-  fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-	else
-	  tagname=""
-	fi
-	;;
-
-      RC)
-
-
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-objext_RC=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-compiler_RC=$CC
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-lt_cv_prog_compiler_c_o_RC=yes
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # See if we are running on zsh, and set the options which allow our commands through
-  # without removal of \ escapes.
-  if test -n "${ZSH_VERSION+set}" ; then
-    setopt NO_GLOB_SUBST
-  fi
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
-    SED SHELL STRIP \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    compiler_RC \
-    CC_RC \
-    LD_RC \
-    lt_prog_compiler_wl_RC \
-    lt_prog_compiler_pic_RC \
-    lt_prog_compiler_static_RC \
-    lt_prog_compiler_no_builtin_flag_RC \
-    export_dynamic_flag_spec_RC \
-    thread_safe_flag_spec_RC \
-    whole_archive_flag_spec_RC \
-    enable_shared_with_static_runtimes_RC \
-    old_archive_cmds_RC \
-    old_archive_from_new_cmds_RC \
-    predep_objects_RC \
-    postdep_objects_RC \
-    predeps_RC \
-    postdeps_RC \
-    compiler_lib_search_path_RC \
-    archive_cmds_RC \
-    archive_expsym_cmds_RC \
-    postinstall_cmds_RC \
-    postuninstall_cmds_RC \
-    old_archive_from_expsyms_cmds_RC \
-    allow_undefined_flag_RC \
-    no_undefined_flag_RC \
-    export_symbols_cmds_RC \
-    hardcode_libdir_flag_spec_RC \
-    hardcode_libdir_flag_spec_ld_RC \
-    hardcode_libdir_separator_RC \
-    hardcode_automatic_RC \
-    module_cmds_RC \
-    module_expsym_cmds_RC \
-    lt_cv_prog_compiler_c_o_RC \
-    exclude_expsyms_RC \
-    include_expsyms_RC; do
-
-    case $var in
-    old_archive_cmds_RC | \
-    old_archive_from_new_cmds_RC | \
-    archive_cmds_RC | \
-    archive_expsym_cmds_RC | \
-    module_cmds_RC | \
-    module_expsym_cmds_RC | \
-    old_archive_from_expsyms_cmds_RC | \
-    export_symbols_cmds_RC | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\$0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
-    ;;
-  esac
-
-cfgfile="$ofile"
-
-  cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_RC
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_RC
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_RC
-
-gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
-gcc_ver=\`gcc -dumpversion\`
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_RC
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_RC
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_RC
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_RC
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names.  First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_RC
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_RC
-archive_expsym_cmds=$lt_archive_expsym_cmds_RC
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_RC
-module_expsym_cmds=$lt_module_expsym_cmds_RC
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=\`echo $lt_predep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=\`echo $lt_postdep_objects_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_RC
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_RC
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=\`echo $lt_compiler_lib_search_path_RC | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_RC
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_RC
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_RC
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_RC
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_RC
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_RC
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_RC
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_RC"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_RC
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_RC
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_RC
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_RC
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
-  if test -f "$ltmain_in"; then
-    test -f Makefile && make "$ltmain"
-  fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_linkonly='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_objext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-	;;
-
-      *)
-	{ { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5
-echo "$as_me: error: Unsupported tag name: $tagname" >&2;}
-   { (exit 1); exit 1; }; }
-	;;
-      esac
-
-      # Append the new tag name to the list of available tags.
-      if test -n "$tagname" ; then
-      available_tags="$available_tags $tagname"
-    fi
-    fi
-  done
-  IFS="$lt_save_ifs"
-
-  # Now substitute the updated list of available tags.
-  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
-    mv "${ofile}T" "$ofile"
-    chmod +x "$ofile"
-  else
-    rm -f "${ofile}T"
-    { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5
-echo "$as_me: error: unable to update list of available tagged configurations." >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-fi
-
-
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-
-# Prevent multiple expansion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Do we build shared libraries?
-# (enable_shared is set by the function AC_ENABLE_SHARED in libtool.m4)
-SHARED_LIBS="${enable_shared}"
-
-# Print a few more lines for configure --help
-
-
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-# Check whether --with- or --without- was given.
-if test "${with_+set}" = set; then
-  withval="$with_"
-
-fi;
-
-
-
-# Substitute variables
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Generate makefiles
-echo ""
-echo "Create Makefiles and configuration files"
-echo "----------------------------------------"
-echo ""
-
-
-# Initialize the list of Makefiles to be created
-SUNDIALS_MAKEFILES="Makefile"
-
-# Initialize list of additional configure files to be created
-SUNDIALS_CONFIGFILES="include/sundials/sundials_config.h:include/sundials/sundials_config.in"
-SUNDIALS_CONFIGFILES="${SUNDIALS_CONFIGFILES} bin/sundials-config:bin/sundials-config.in"
-
-# Initialize lists of solver modules and example modules
-SLV_MODULES="src/sundials"
-SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/sundials/Makefile"
-
-EXS_MODULES=""
-
-# NVECTOR modules
-if test -d ${srcdir}/src/nvec_ser ; then
-  SLV_MODULES="${SLV_MODULES} src/nvec_ser"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/nvec_ser/Makefile"
-fi
-
-if test -d ${srcdir}/src/nvec_par && test "X${MPI_C_COMP_OK}" = "Xyes"; then
-  SLV_MODULES="${SLV_MODULES} src/nvec_par"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/nvec_par/Makefile"
-fi
-
-if test -d ${srcdir}/src/nvec_spcpar && test "X${MPI_C_COMP_OK}" = "Xyes"; then
-  SLV_MODULES="${SLV_MODULES} src/nvec_spcpar"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/nvec_spcpar/Makefile"
-fi
-
-# CVODE module
-if test "X${CVODE_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/cvode"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cvode/Makefile"
-
-  if test "X${FCMIX_ENABLED}" = "Xyes" && test -d ${srcdir}/src/cvode/fcmix ; then
-    SLV_MODULES="${SLV_MODULES} src/cvode/fcmix"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cvode/fcmix/Makefile"
-  fi
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/fcmix_serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_serial/Makefile_ex:examples/templates/makefile_serial_F77_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvode/fcmix_parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvode/fcmix_parallel/Makefile_ex:examples/templates/makefile_parallel_F77_ex.in"
-  fi
-
-fi
-
-# CVODES module
-if test "X${CVODES_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/cvodes"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cvodes/Makefile"
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvodes/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cvodes/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cvodes/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-fi
-
-# IDA module
-if test "X${IDA_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/ida"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/ida/Makefile"
-
-  if test "X${FCMIX_ENABLED}" = "Xyes" && test -d ${srcdir}/src/ida/fcmix ; then
-    SLV_MODULES="${SLV_MODULES} src/ida/fcmix"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/ida/fcmix/Makefile"
-  fi
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/fcmix_serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_serial/Makefile_ex:examples/templates/makefile_serial_F77_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/ida/fcmix_parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/ida/fcmix_parallel/Makefile_ex:examples/templates/makefile_parallel_F77_ex.in"
-  fi
-
-fi
-
-# IDAS module
-if test "X${IDAS_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/idas"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/idas/Makefile"
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/idas/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/idas/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/idas/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-fi
-
-# KINSOL module
-if test "X${KINSOL_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/kinsol"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/kinsol/Makefile"
-
-  if test "X${FCMIX_ENABLED}" = "Xyes" && test -d ${srcdir}/src/kinsol/fcmix ; then
-    SLV_MODULES="${SLV_MODULES} src/kinsol/fcmix"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/kinsol/fcmix/Makefile"
-  fi
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/fcmix_serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_serial/Makefile_ex:examples/templates/makefile_serial_F77_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/kinsol/fcmix_parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/kinsol/fcmix_parallel/Makefile_ex:examples/templates/makefile_parallel_F77_ex.in"
-  fi
-
-fi
-
-# CPODES module
-if test "X${CPODES_ENABLED}" = "Xyes"; then
-
-  SLV_MODULES="${SLV_MODULES} src/cpodes"
-  SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} src/cpodes/Makefile"
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/serial ; then
-    EXS_MODULES="${EXS_MODULES} examples/cpodes/serial"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/serial/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/serial/Makefile_ex:examples/templates/makefile_serial_C_ex.in"
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/parallel ; then
-    EXS_MODULES="${EXS_MODULES} examples/cpodes/parallel"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/parallel/Makefile"
-    SUNDIALS_MAKEFILES="${SUNDIALS_MAKEFILES} examples/cpodes/parallel/Makefile_ex:examples/templates/makefile_parallel_C_ex.in"
-  fi
-
-fi
-
-# Add Fortran update script to the list of additional files to be generated
-if test "X${BUILD_F77_UPDATE_SCRIPT}" = "Xyes"; then
-  SUNDIALS_CONFIGFILES="${SUNDIALS_CONFIGFILES} bin/fortran-update.sh:bin/fortran-update.in"
-fi
-
-# If needed, add Makefile update script to the list of additional files to be generated
-if test "X${EXAMPLES_ENABLED}" = "Xyes" && test "X${EXS_INSTDIR}" != "Xno"; then
-  SUNDIALS_CONFIGFILES="${SUNDIALS_CONFIGFILES} bin/makefile-update.sh:bin/makefile-update.in"
-fi
-
-
-
-# Set-up postprocessing commands
-if test "X${EXAMPLES_ENABLED}" = "Xyes" && test "X${EXS_INSTDIR}" != "Xno"; then
-            ac_config_commands="$ac_config_commands postprocessing"
-
-
-
-# If installing examples, the Makefiles that will be exported must
-# be post-processed to complete the substitution of all variables.
-# After config.status runs, each example subdirectory contains an
-# export makefile, named Makefile_ex, which was created from the
-# common template in examples/templates.
-#
-# The following variables are still to be substituted at this point:
-#   SOLVER
-#   EXAMPLES
-#   EXAMPLES_BL
-#   SOLVER_LIB SOLVER_FLIB
-#   NVEC_LIB NVEC_FLIB
-#
-# This function is called ONLY if examples are enabled AND examples will
-# be installed. If so, it sets up commands to be called after config.status
-# has generated a first version of the Makefiles for export:
-#
-# (1) For each solver, proceed ONLY if the solver is enabled.
-# (2) For each type of examples, proceed ONLY if they can be compiled AND
-#     the example directory exists.
-
-# CVODE module
-if test "X${CVODE_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands cvode_ser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands cvode_ser_ex"
-
-     fi
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands cvode_fser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands cvode_fser_ex"
-
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/parallel ; then
-               ac_config_commands="$ac_config_commands cvode_par_ex"
-
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvode/fcmix_parallel ; then
-               ac_config_commands="$ac_config_commands cvode_fpar_ex"
-
-  fi
-
-fi
-
-
-# CVODES module
-if test "X${CVODES_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands cvodes_ser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands cvodes_ser_ex"
-
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cvodes/parallel ; then
-               ac_config_commands="$ac_config_commands cvodes_par_ex"
-
-  fi
-
-fi
-
-
-# IDA module
-if test "X${IDA_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands ida_ser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands ida_ser_ex"
-
-     fi
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands ida_fser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands ida_fser_ex"
-
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/parallel ; then
-               ac_config_commands="$ac_config_commands ida_par_ex"
-
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/ida/fcmix_parallel ; then
-               ac_config_commands="$ac_config_commands ida_fpar_ex"
-
-  fi
-
-fi
-
-
-# IDAS module
-if test "X${IDAS_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands idas_ser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands idas_ser_ex"
-
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/idas/parallel ; then
-               ac_config_commands="$ac_config_commands idas_par_ex"
-
-  fi
-
-fi
-
-
-# KINSOL module
-if test "X${KINSOL_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands kinsol_ser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands kinsol_ser_ex"
-
-     fi
-  fi
-
-  if test "X${SERIAL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands kinsol_fser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands kinsol_fser_ex"
-
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/parallel ; then
-               ac_config_commands="$ac_config_commands kinsol_par_ex"
-
-  fi
-
-  if test "X${PARALLEL_F77_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/kinsol/fcmix_parallel ; then
-               ac_config_commands="$ac_config_commands kinsol_fpar_ex"
-
-  fi
-
-fi
-
-
-# CPODES module
-if test "X${CPODES_ENABLED}" = "Xyes"; then
-
-  if test "X${SERIAL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/serial ; then
-     if test "X${LAPACK_ENABLED}" = "Xyes"; then
-                 ac_config_commands="$ac_config_commands cpodes_ser_ex_bl"
-
-     else
-                 ac_config_commands="$ac_config_commands cpodes_ser_ex"
-
-     fi
-  fi
-
-  if test "X${PARALLEL_C_EXAMPLES}" = "Xyes" && test -d ${srcdir}/examples/cpodes/parallel ; then
-               ac_config_commands="$ac_config_commands cpodes_par_ex"
-
-  fi
-
-fi
-
-
-fi
-
-# Specify files to be configured and call AC_OUTPUT
-          ac_config_files="$ac_config_files ${SUNDIALS_MAKEFILES}"
-
-          ac_config_files="$ac_config_files ${SUNDIALS_CONFIGFILES}"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-{
-  (set) 2>&1 |
-    case `(ac_space=' '; set | grep ac_space) 2>&1` in
-    *ac_space=\ *)
-      # `set' does not quote correctly, so add quotes (double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \).
-      sed -n \
-	"s/'/'\\\\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;;
-    *)
-      # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n \
-	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
-      ;;
-    esac;
-} |
-  sed '
-     t clear
-     : clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
-     t end
-     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
-  if test -w $cache_file; then
-    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
-    cat confcache >$cache_file
-  else
-    echo "not updating unwritable cache $cache_file"
-  fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[	 ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[	 ]*$//;
-}'
-fi
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
-  # 1. Remove the extension, and $U if already installed.
-  ac_i=`echo "$ac_i" |
-	 sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
-  # 2. Add them.
-  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
-  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization.  ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
-  emulate sh
-  NULLCMD=:
-  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
-  set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  as_unset=unset
-else
-  as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
-  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
-  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
-  LC_TELEPHONE LC_TIME
-do
-  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
-    eval $as_var=C; export $as_var
-  else
-    $as_unset $as_var
-  fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)$' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
-  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\/\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-    PATH_SEPARATOR=';'
-  else
-    PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
-fi
-
-
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
-  # Find who we are.  Look in the path if we contain no path at all
-  # relative or not.
-  case $0 in
-    *[\\/]* ) as_myself=$0 ;;
-    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
-       ;;
-  esac
-  # We did not find ourselves, most probably we were run as `sh COMMAND'
-  # in which case we are not to be found in the path.
-  if test "x$as_myself" = x; then
-    as_myself=$0
-  fi
-  if test ! -f "$as_myself"; then
-    { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-  case $CONFIG_SHELL in
-  '')
-    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for as_base in sh bash ksh sh5; do
-	 case $as_dir in
-	 /*)
-	   if ("$as_dir/$as_base" -c '
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
-	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
-	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
-	     CONFIG_SHELL=$as_dir/$as_base
-	     export CONFIG_SHELL
-	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
-	   fi;;
-	 esac
-       done
-done
-;;
-  esac
-
-  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
-  # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line before each line; the second 'sed' does the real
-  # work.  The second script uses 'N' to pair each line-number line
-  # with the numbered line, and appends trailing '-' during
-  # substitution so that $LINENO is not a special case at line end.
-  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
-  sed '=' <$as_myself |
-    sed '
-      N
-      s,$,-,
-      : loop
-      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
-      t loop
-      s,-$,,
-      s,^['$as_cr_digits']*\n,,
-    ' >$as_me.lineno &&
-  chmod +x $as_me.lineno ||
-    { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
-   { (exit 1); exit 1; }; }
-
-  # Don't try to exec as it changes $[0], causing all sort of problems
-  # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensible to this).
-  . ./$as_me.lineno
-  # Exit status is that of the last command.
-  exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
-  # We could just check for DJGPP; but this test a) works b) is more generic
-  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
-  if test -f conf$$.exe; then
-    # Don't use ln at all; we don't have any links
-    as_ln_s='cp -p'
-  else
-    as_ln_s='ln -s'
-  fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
-  as_ln_s=ln
-else
-  as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p=:
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" 	$as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-exec 6>&1
-
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.  Logging --version etc. is OK.
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by SUNDIALS $as_me 2.5.0, which was
-generated by GNU Autoconf 2.59.  Invocation command line was
-
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  $ $0 $@
-
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
-_ACEOF
-
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
-  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_headers"; then
-  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_links"; then
-  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
-  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
-  -h, --help       print this help, then exit
-  -V, --version    print version number, then exit
-  -q, --quiet      do not print progress messages
-  -d, --debug      don't remove temporary files
-      --recheck    update $as_me by reconfiguring in the same conditions
-  --file=FILE[:TEMPLATE]
-		   instantiate the configuration file FILE
-  --header=FILE[:TEMPLATE]
-		   instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Configuration commands:
-$config_commands
-
-Report bugs to <bug-autoconf at gnu.org>."
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-SUNDIALS config.status 2.5.0
-configured by $0, generated by GNU Autoconf 2.59,
-  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-INSTALL="$INSTALL"
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value.  By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
-  case $1 in
-  --*=*)
-    ac_option=`expr "x$1" : 'x\([^=]*\)='`
-    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  -*)
-    ac_option=$1
-    ac_optarg=$2
-    ac_shift=shift
-    ;;
-  *) # This is not an option, so the user has probably given explicit
-     # arguments.
-     ac_option=$1
-     ac_need_defaults=false;;
-  esac
-
-  case $ac_option in
-  # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    ac_cs_recheck=: ;;
-  --version | --vers* | -V )
-    echo "$ac_cs_version"; exit 0 ;;
-  --he | --h)
-    # Conflict between --help and --header
-    { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
-   { (exit 1); exit 1; }; };;
-  --help | --hel | -h )
-    echo "$ac_cs_usage"; exit 0 ;;
-  --debug | --d* | -d )
-    debug=: ;;
-  --file | --fil | --fi | --f )
-    $ac_shift
-    CONFIG_FILES="$CONFIG_FILES $ac_optarg"
-    ac_need_defaults=false;;
-  --header | --heade | --head | --hea )
-    $ac_shift
-    CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
-    ac_need_defaults=false;;
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil | --si | --s)
-    ac_cs_silent=: ;;
-
-  # This is an error.
-  -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
-   { (exit 1); exit 1; }; } ;;
-
-  *) ac_config_targets="$ac_config_targets $1" ;;
-
-  esac
-  shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
-  exec 6>/dev/null
-  ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
-  echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
-  exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-
-
-
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_config_target in $ac_config_targets
-do
-  case "$ac_config_target" in
-  # Handling of arguments.
-  "${SUNDIALS_MAKEFILES}" ) CONFIG_FILES="$CONFIG_FILES ${SUNDIALS_MAKEFILES}" ;;
-  "${SUNDIALS_CONFIGFILES}" ) CONFIG_FILES="$CONFIG_FILES ${SUNDIALS_CONFIGFILES}" ;;
-  "postprocessing" ) CONFIG_COMMANDS="$CONFIG_COMMANDS postprocessing" ;;
-  "cvode_ser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvode_ser_ex_bl" ;;
-  "cvode_ser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvode_ser_ex" ;;
-  "cvode_fser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvode_fser_ex_bl" ;;
-  "cvode_fser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvode_fser_ex" ;;
-  "cvode_par_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvode_par_ex" ;;
-  "cvode_fpar_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvode_fpar_ex" ;;
-  "cvodes_ser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvodes_ser_ex_bl" ;;
-  "cvodes_ser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvodes_ser_ex" ;;
-  "cvodes_par_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cvodes_par_ex" ;;
-  "ida_ser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS ida_ser_ex_bl" ;;
-  "ida_ser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS ida_ser_ex" ;;
-  "ida_fser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS ida_fser_ex_bl" ;;
-  "ida_fser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS ida_fser_ex" ;;
-  "ida_par_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS ida_par_ex" ;;
-  "ida_fpar_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS ida_fpar_ex" ;;
-  "idas_ser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS idas_ser_ex_bl" ;;
-  "idas_ser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS idas_ser_ex" ;;
-  "idas_par_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS idas_par_ex" ;;
-  "kinsol_ser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS kinsol_ser_ex_bl" ;;
-  "kinsol_ser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS kinsol_ser_ex" ;;
-  "kinsol_fser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS kinsol_fser_ex_bl" ;;
-  "kinsol_fser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS kinsol_fser_ex" ;;
-  "kinsol_par_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS kinsol_par_ex" ;;
-  "kinsol_fpar_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS kinsol_fpar_ex" ;;
-  "cpodes_ser_ex_bl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cpodes_ser_ex_bl" ;;
-  "cpodes_ser_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cpodes_ser_ex" ;;
-  "cpodes_par_ex" ) CONFIG_COMMANDS="$CONFIG_COMMANDS cpodes_par_ex" ;;
-  "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;;
-  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
-   { (exit 1); exit 1; }; };;
-  esac
-done
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used.  Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
-fi
-
-# Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
-$debug ||
-{
-  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
-  trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-
-{
-  tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
-  test -n "$tmp" && test -d "$tmp"
-}  ||
-{
-  tmp=./confstat$$-$RANDOM
-  (umask 077 && mkdir $tmp)
-} ||
-{
-   echo "$me: cannot create a temporary directory in ." >&2
-   { (exit 1); exit 1; }
-}
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
-#
-# CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
-  # Protect against being on the right side of a sed subst in config.status.
-  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
-   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s, at SHELL@,$SHELL,;t t
-s, at PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s, at PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s, at PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s, at PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s, at PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s, at PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s, at exec_prefix@,$exec_prefix,;t t
-s, at prefix@,$prefix,;t t
-s, at program_transform_name@,$program_transform_name,;t t
-s, at bindir@,$bindir,;t t
-s, at sbindir@,$sbindir,;t t
-s, at libexecdir@,$libexecdir,;t t
-s, at datadir@,$datadir,;t t
-s, at sysconfdir@,$sysconfdir,;t t
-s, at sharedstatedir@,$sharedstatedir,;t t
-s, at localstatedir@,$localstatedir,;t t
-s, at libdir@,$libdir,;t t
-s, at includedir@,$includedir,;t t
-s, at oldincludedir@,$oldincludedir,;t t
-s, at infodir@,$infodir,;t t
-s, at mandir@,$mandir,;t t
-s, at build_alias@,$build_alias,;t t
-s, at host_alias@,$host_alias,;t t
-s, at target_alias@,$target_alias,;t t
-s, at DEFS@,$DEFS,;t t
-s, at ECHO_C@,$ECHO_C,;t t
-s, at ECHO_N@,$ECHO_N,;t t
-s, at ECHO_T@,$ECHO_T,;t t
-s, at LIBS@,$LIBS,;t t
-s, at build@,$build,;t t
-s, at build_cpu@,$build_cpu,;t t
-s, at build_vendor@,$build_vendor,;t t
-s, at build_os@,$build_os,;t t
-s, at host@,$host,;t t
-s, at host_cpu@,$host_cpu,;t t
-s, at host_vendor@,$host_vendor,;t t
-s, at host_os@,$host_os,;t t
-s, at SET_MAKE@,$SET_MAKE,;t t
-s, at INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
-s, at INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
-s, at INSTALL_DATA@,$INSTALL_DATA,;t t
-s, at CC@,$CC,;t t
-s, at CFLAGS@,$CFLAGS,;t t
-s, at LDFLAGS@,$LDFLAGS,;t t
-s, at CPPFLAGS@,$CPPFLAGS,;t t
-s, at ac_ct_CC@,$ac_ct_CC,;t t
-s, at EXEEXT@,$EXEEXT,;t t
-s, at OBJEXT@,$OBJEXT,;t t
-s, at CPP@,$CPP,;t t
-s, at EGREP@,$EGREP,;t t
-s, at FGREP@,$FGREP,;t t
-s, at F77@,$F77,;t t
-s, at FFLAGS@,$FFLAGS,;t t
-s, at ac_ct_F77@,$ac_ct_F77,;t t
-s, at FLIBS@,$FLIBS,;t t
-s, at MPICC_COMP@,$MPICC_COMP,;t t
-s, at MPIF77_COMP@,$MPIF77_COMP,;t t
-s, at SED@,$SED,;t t
-s, at LN_S@,$LN_S,;t t
-s, at ECHO@,$ECHO,;t t
-s, at AR@,$AR,;t t
-s, at ac_ct_AR@,$ac_ct_AR,;t t
-s, at RANLIB@,$RANLIB,;t t
-s, at ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
-s, at STRIP@,$STRIP,;t t
-s, at ac_ct_STRIP@,$ac_ct_STRIP,;t t
-s, at DLLTOOL@,$DLLTOOL,;t t
-s, at ac_ct_DLLTOOL@,$ac_ct_DLLTOOL,;t t
-s, at AS@,$AS,;t t
-s, at ac_ct_AS@,$ac_ct_AS,;t t
-s, at OBJDUMP@,$OBJDUMP,;t t
-s, at ac_ct_OBJDUMP@,$ac_ct_OBJDUMP,;t t
-s, at CXX@,$CXX,;t t
-s, at CXXFLAGS@,$CXXFLAGS,;t t
-s, at ac_ct_CXX@,$ac_ct_CXX,;t t
-s, at CXXCPP@,$CXXCPP,;t t
-s, at LIBTOOL@,$LIBTOOL,;t t
-s, at SHARED_LIBS@,$SHARED_LIBS,;t t
-s, at MPICC@,$MPICC,;t t
-s, at MPIF77@,$MPIF77,;t t
-s, at MPI_INC_DIR@,$MPI_INC_DIR,;t t
-s, at MPI_LIB_DIR@,$MPI_LIB_DIR,;t t
-s, at MPI_LIBS@,$MPI_LIBS,;t t
-s, at MPI_FLAGS@,$MPI_FLAGS,;t t
-s, at FCMIX_ENABLED@,$FCMIX_ENABLED,;t t
-s, at FLOAT_TYPE@,$FLOAT_TYPE,;t t
-s, at LIBTOOL_DEPS@,$LIBTOOL_DEPS,;t t
-s, at F77_MANGLE_MACRO1@,$F77_MANGLE_MACRO1,;t t
-s, at F77_MANGLE_MACRO2@,$F77_MANGLE_MACRO2,;t t
-s, at F77_CASE@,$F77_CASE,;t t
-s, at F77_UNDERSCORES@,$F77_UNDERSCORES,;t t
-s, at PRECISION_LEVEL@,$PRECISION_LEVEL,;t t
-s, at GENERIC_MATH_LIB@,$GENERIC_MATH_LIB,;t t
-s, at BLAS_LAPACK_MACRO@,$BLAS_LAPACK_MACRO,;t t
-s, at SUNDIALS_EXPORT@,$SUNDIALS_EXPORT,;t t
-s, at F77_MPI_COMM_F2C@,$F77_MPI_COMM_F2C,;t t
-s, at F77_LNKR@,$F77_LNKR,;t t
-s, at F77_LIBS@,$F77_LIBS,;t t
-s, at F77_LDFLAGS@,$F77_LDFLAGS,;t t
-s, at LAPACK_ENABLED@,$LAPACK_ENABLED,;t t
-s, at BLAS_LAPACK_LIBS@,$BLAS_LAPACK_LIBS,;t t
-s, at MPIF77_LNKR@,$MPIF77_LNKR,;t t
-s, at SLV_MODULES@,$SLV_MODULES,;t t
-s, at EXS_MODULES@,$EXS_MODULES,;t t
-s, at EXS_INSTDIR@,$EXS_INSTDIR,;t t
-s, at LIBOBJS@,$LIBOBJS,;t t
-s, at LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
-  cat >>$CONFIG_STATUS <<\_ACEOF
-  # Split the substitutions into bite-sized pieces for seds with
-  # small command number limits, like on Digital OSF/1 and HP-UX.
-  ac_max_sed_lines=48
-  ac_sed_frag=1 # Number of current file.
-  ac_beg=1 # First line for current file.
-  ac_end=$ac_max_sed_lines # Line after last line for current file.
-  ac_more_lines=:
-  ac_sed_cmds=
-  while $ac_more_lines; do
-    if test $ac_beg -gt 1; then
-      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
-    else
-      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
-    fi
-    if test ! -s $tmp/subs.frag; then
-      ac_more_lines=false
-    else
-      # The purpose of the label and of the branching condition is to
-      # speed up the sed processing (if there are no `@' at all, there
-      # is no need to browse any of the substitutions).
-      # These are the two extra sed commands mentioned above.
-      (echo ':t
-  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
-      if test -z "$ac_sed_cmds"; then
-	ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
-      else
-	ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
-      fi
-      ac_sed_frag=`expr $ac_sed_frag + 1`
-      ac_beg=$ac_end
-      ac_end=`expr $ac_end + $ac_max_sed_lines`
-    fi
-  done
-  if test -z "$ac_sed_cmds"; then
-    ac_sed_cmds=cat
-  fi
-fi # test -n "$CONFIG_FILES"
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case $ac_file in
-  - | *:- | *:-:* ) # input from stdin
-	cat >$tmp/stdin
-	ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
-  esac
-
-  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
-  ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-  { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
-    as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }; }
-
-  ac_builddir=.
-
-if test "$ac_dir" != .; then
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
-    ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
-
-
-  case $INSTALL in
-  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
-  *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
-  esac
-
-  if test x"$ac_file" != x-; then
-    { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-    rm -f "$ac_file"
-  fi
-  # Let's still pretend it is `configure' which instantiates (i.e., don't
-  # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated by config.status.  */
-  if test x"$ac_file" = x-; then
-    configure_input=
-  else
-    configure_input="$ac_file.  "
-  fi
-  configure_input=$configure_input"Generated from `echo $ac_file_in |
-				     sed 's,.*/,,'` by configure."
-
-  # First look for the input files in the build tree, otherwise in the
-  # src tree.
-  ac_file_inputs=`IFS=:
-    for f in $ac_file_in; do
-      case $f in
-      -) echo $tmp/stdin ;;
-      [\\/$]*)
-	 # Absolute (can't be DOS-style, as IFS=:)
-	 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 echo "$f";;
-      *) # Relative
-	 if test -f "$f"; then
-	   # Build tree
-	   echo "$f"
-	 elif test -f "$srcdir/$f"; then
-	   # Source tree
-	   echo "$srcdir/$f"
-	 else
-	   # /dev/null tree
-	   { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 fi;;
-      esac
-    done` || { (exit 1); exit 1; }
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-  sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s, at configure_input@,$configure_input,;t t
-s, at srcdir@,$ac_srcdir,;t t
-s, at abs_srcdir@,$ac_abs_srcdir,;t t
-s, at top_srcdir@,$ac_top_srcdir,;t t
-s, at abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s, at builddir@,$ac_builddir,;t t
-s, at abs_builddir@,$ac_abs_builddir,;t t
-s, at top_builddir@,$ac_top_builddir,;t t
-s, at abs_top_builddir@,$ac_abs_top_builddir,;t t
-s, at INSTALL@,$ac_INSTALL,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
-  rm -f $tmp/stdin
-  if test x"$ac_file" != x-; then
-    mv $tmp/out $ac_file
-  else
-    cat $tmp/out
-    rm -f $tmp/out
-  fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([	 ]*\)#\([	 ]*define[	 ][	 ]*\)'
-ac_dB='[	 ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([	 ]*\)#\([	 ]*\)undef\([	 ][	 ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case $ac_file in
-  - | *:- | *:-:* ) # input from stdin
-	cat >$tmp/stdin
-	ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
-  esac
-
-  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
-  # First look for the input files in the build tree, otherwise in the
-  # src tree.
-  ac_file_inputs=`IFS=:
-    for f in $ac_file_in; do
-      case $f in
-      -) echo $tmp/stdin ;;
-      [\\/$]*)
-	 # Absolute (can't be DOS-style, as IFS=:)
-	 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 # Do quote $f, to prevent DOS paths from being IFS'd.
-	 echo "$f";;
-      *) # Relative
-	 if test -f "$f"; then
-	   # Build tree
-	   echo "$f"
-	 elif test -f "$srcdir/$f"; then
-	   # Source tree
-	   echo "$srcdir/$f"
-	 else
-	   # /dev/null tree
-	   { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 fi;;
-      esac
-    done` || { (exit 1); exit 1; }
-  # Remove the trailing spaces.
-  sed 's/[	 ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h.  The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status.  Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*\)\(([^)]*)\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless.  Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments.  This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[	 ]*#[	 ]*undef[	 ][	 ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo '  if grep "^[	 ]*#[	 ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo '  :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
-  # Write a limited-size here document to $tmp/defines.sed.
-  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
-  # Speed up: don't consider the non `#define' lines.
-  echo '/^[	 ]*#[	 ]*define/!b' >>$CONFIG_STATUS
-  # Work around the forget-to-reset-the-flag bug.
-  echo 't clr' >>$CONFIG_STATUS
-  echo ': clr' >>$CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
-  echo 'CEOF
-  sed -f $tmp/defines.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
-  rm -f conftest.defines
-  mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo '  fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
-  # Write a limited-size here document to $tmp/undefs.sed.
-  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
-  # Speed up: don't consider the non `#undef'
-  echo '/^[	 ]*#[	 ]*undef/!b' >>$CONFIG_STATUS
-  # Work around the forget-to-reset-the-flag bug.
-  echo 't clr' >>$CONFIG_STATUS
-  echo ': clr' >>$CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
-  echo 'CEOF
-  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
-  rm -f conftest.undefs
-  mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-  # Let's still pretend it is `configure' which instantiates (i.e., don't
-  # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated by config.status.  */
-  if test x"$ac_file" = x-; then
-    echo "/* Generated by configure.  */" >$tmp/config.h
-  else
-    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
-  fi
-  cat $tmp/in >>$tmp/config.h
-  rm -f $tmp/in
-  if test x"$ac_file" != x-; then
-    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
-      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
-    else
-      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-      { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
-    as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }; }
-
-      rm -f $ac_file
-      mv $tmp/config.h $ac_file
-    fi
-  else
-    cat $tmp/config.h
-    rm -f $tmp/config.h
-  fi
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_COMMANDS section.
-#
-for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
-  ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
-  ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
-  ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
-$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_dest" : 'X\(//\)[^/]' \| \
-	 X"$ac_dest" : 'X\(//\)$' \| \
-	 X"$ac_dest" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$ac_dest" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-  { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
-    as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }; }
-
-  ac_builddir=.
-
-if test "$ac_dir" != .; then
-  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
-    ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
-
-
-  { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
-echo "$as_me: executing $ac_dest commands" >&6;}
-  case $ac_dest in
-    postprocessing )
-    echo ""
-    echo "Postprocess exported Makefiles"
-    echo "------------------------------"
-    echo ""
-   ;;
-    cvode_ser_ex_bl )
-       IN_FILE="examples/cvode/serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB=""
-       EXAMPLES="cvAdvDiff_bnd cvDirectDemo_ls cvDiurnal_kry_bp cvDiurnal_kry cvKrylovDemo_ls cvKrylovDemo_prec cvRoberts_dns cvRoberts_dns_uw"
-       EXAMPLES_BL="cvAdvDiff_bndL cvRoberts_dnsL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cvode_ser_ex )
-       IN_FILE="examples/cvode/serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB=""
-       EXAMPLES="cvAdvDiff_bnd cvDirectDemo_ls cvDiurnal_kry_bp cvDiurnal_kry cvKrylovDemo_ls cvKrylovDemo_prec cvRoberts_dns cvRoberts_dns_uw"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cvode_fser_ex_bl )
-       IN_FILE="examples/cvode/fcmix_serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB="sundials_fcvode"
-       EXAMPLES="fcvAdvDiff_bnd fcvDiurnal_kry_bp fcvDiurnal_kry fcvRoberts_dns"
-       EXAMPLES_BL="fcvRoberts_dnsL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cvode_fser_ex )
-       IN_FILE="examples/cvode/fcmix_serial/Makefile_ex"
-       SOLVER="CVODE"
-       SOLVER_LIB="sundials_cvode"
-       SOLVER_FLIB="sundials_fcvode"
-       EXAMPLES="fcvAdvDiff_bnd fcvDiurnal_kry_bp fcvDiurnal_kry fcvRoberts_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cvode_par_ex )
-     IN_FILE="examples/cvode/parallel/Makefile_ex"
-     SOLVER="CVODE"
-     SOLVER_LIB="sundials_cvode"
-     SOLVER_FLIB=""
-     EXAMPLES="cvAdvDiff_non_p cvDiurnal_kry_bbd_p cvDiurnal_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    cvode_fpar_ex )
-     IN_FILE="examples/cvode/fcmix_parallel/Makefile_ex"
-     SOLVER="CVODE"
-     SOLVER_LIB="sundials_cvode"
-     SOLVER_FLIB="sundials_fcvode"
-     EXAMPLES="fcvDiag_non_p fcvDiag_kry_bbd_p fcvDiag_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    cvodes_ser_ex_bl )
-       IN_FILE="examples/cvodes/serial/Makefile_ex"
-       SOLVER="CVODES"
-       SOLVER_LIB="sundials_cvodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cvsAdvDiff_ASAi_bnd cvsAdvDiff_FSA_non cvsDiurnal_kry_bp cvsFoodWeb_ASAp_kry cvsKrylovDemo_prec cvsAdvDiff_bnd cvsDirectDemo_ls cvsDiurnal_kry cvsHessian_ASA_FSA cvsRoberts_ASAi_dns cvsRoberts_dns_uw  cvsDiurnal_FSA_kry cvsFoodWeb_ASAi_kry cvsKrylovDemo_ls cvsRoberts_dns cvsRoberts_FSA_dns"
-       EXAMPLES_BL="cvsRoberts_dnsL cvsAdvDiff_bndL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cvodes_ser_ex )
-       IN_FILE="examples/cvodes/serial/Makefile_ex"
-       SOLVER="CVODES"
-       SOLVER_LIB="sundials_cvodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cvsAdvDiff_ASAi_bnd cvsAdvDiff_FSA_non cvsDiurnal_kry_bp cvsFoodWeb_ASAp_kry cvsKrylovDemo_prec cvsAdvDiff_bnd cvsDirectDemo_ls cvsDiurnal_kry cvsHessian_ASA_FSA cvsRoberts_ASAi_dns cvsRoberts_dns_uw  cvsDiurnal_FSA_kry cvsFoodWeb_ASAi_kry cvsKrylovDemo_ls cvsRoberts_dns cvsRoberts_FSA_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cvodes_par_ex )
-     IN_FILE="examples/cvodes/parallel/Makefile_ex"
-     SOLVER="CVODES"
-     SOLVER_LIB="sundials_cvodes"
-     SOLVER_FLIB=""
-     EXAMPLES="cvsAdvDiff_ASAp_non_p cvsAdvDiff_non_p cvsDiurnal_FSA_kry_p cvsDiurnal_kry_p cvsAdvDiff_FSA_non_p cvsAtmDisp_ASAi_kry_bbd_p cvsDiurnal_kry_bbd_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    ida_ser_ex_bl )
-       IN_FILE="examples/ida/serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB=""
-       EXAMPLES="idaFoodWeb_bnd idaHeat2D_bnd idaHeat2D_kry idaKrylovDemo_ls idaRoberts_dns idaSlCrank_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    ida_ser_ex )
-       IN_FILE="examples/ida/serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB=""
-       EXAMPLES="idaFoodWeb_bnd idaHeat2D_bnd idaHeat2D_kry idaKrylovDemo_ls idaRoberts_dns idaSlCrank_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    ida_fser_ex_bl )
-       IN_FILE="examples/ida/fcmix_serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB="sundials_fida"
-       EXAMPLES="fidaRoberts_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    ida_fser_ex )
-       IN_FILE="examples/ida/fcmix_serial/Makefile_ex"
-       SOLVER="IDA"
-       SOLVER_LIB="sundials_ida"
-       SOLVER_FLIB="sundials_fida"
-       EXAMPLES="fidaRoberts_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    ida_par_ex )
-     IN_FILE="examples/ida/parallel/Makefile_ex"
-     SOLVER="IDA"
-     SOLVER_LIB="sundials_ida"
-     SOLVER_FLIB=""
-     EXAMPLES="idaFoodWeb_kry_bbd_p idaFoodWeb_kry_p idaHeat2D_kry_bbd_p idaHeat2D_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    ida_fpar_ex )
-     IN_FILE="examples/ida/fcmix_parallel/Makefile_ex"
-     SOLVER="IDA"
-     SOLVER_LIB="sundials_ida"
-     SOLVER_FLIB="sundials_fida"
-     EXAMPLES="fidaHeat2D_kry_bbd_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    idas_ser_ex_bl )
-       IN_FILE="examples/idas/serial/Makefile_ex"
-       SOLVER="IDAS"
-       SOLVER_LIB="sundials_idas"
-       SOLVER_FLIB=""
-       EXAMPLES="idasAkzoNob_ASAi_dns idasFoodWeb_bnd idasHeat2D_kry idasKrylovDemo_ls idasRoberts_dns idasSlCrank_dns idasAkzoNob_dns idasHeat2D_bnd idasHessian_ASA_FSA idasRoberts_ASAi_dns idasRoberts_FSA_dns idasSlCrank_FSA_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    idas_ser_ex )
-       IN_FILE="examples/idas/serial/Makefile_ex"
-       SOLVER="IDAS"
-       SOLVER_LIB="sundials_idas"
-       SOLVER_FLIB=""
-       EXAMPLES="idasAkzoNob_ASAi_dns idasFoodWeb_bnd idasHeat2D_kry idasKrylovDemo_ls idasRoberts_dns idasSlCrank_dns idasAkzoNob_dns idasHeat2D_bnd idasHessian_ASA_FSA idasRoberts_ASAi_dns idasRoberts_FSA_dns idasSlCrank_FSA_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    idas_par_ex )
-     IN_FILE="examples/idas/parallel/Makefile_ex"
-     SOLVER="IDAS"
-     SOLVER_LIB="sundials_idas"
-     SOLVER_FLIB=""
-     EXAMPLES="idasBruss_ASAp_kry_bbd_p idasBruss_kry_bbd_p idasFoodWeb_kry_p idasHeat2D_kry_bbd_p idasBruss_FSA_kry_bbd_p idasFoodWeb_kry_bbd_p idasHeat2D_FSA_kry_bbd_p idasHeat2D_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    kinsol_ser_ex_bl )
-       IN_FILE="examples/kinsol/serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB=""
-       EXAMPLES="kinFerTron_dns kinFoodWeb_kry kinKrylovDemo_ls kinLaplace_bnd kinRoboKin_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    kinsol_ser_ex )
-       IN_FILE="examples/kinsol/serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB=""
-       EXAMPLES="kinFerTron_dns kinFoodWeb_kry kinKrylovDemo_ls kinLaplace_bnd kinRoboKin_dns"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    kinsol_fser_ex_bl )
-       IN_FILE="examples/kinsol/fcmix_serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB="sundials_fkinsol"
-       EXAMPLES="fkinDiagon_kry"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    kinsol_fser_ex )
-       IN_FILE="examples/kinsol/fcmix_serial/Makefile_ex"
-       SOLVER="KINSOL"
-       SOLVER_LIB="sundials_kinsol"
-       SOLVER_FLIB="sundials_fkinsol"
-       EXAMPLES="fkinDiagon_kry"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    kinsol_par_ex )
-     IN_FILE="examples/kinsol/parallel/Makefile_ex"
-     SOLVER="KINSOL"
-     SOLVER_LIB="sundials_kinsol"
-     SOLVER_FLIB=""
-     EXAMPLES="kinFoodWeb_kry_bbd_p kinFoodWeb_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    kinsol_fpar_ex )
-     IN_FILE="examples/kinsol/fcmix_parallel/Makefile_ex"
-     SOLVER="KINSOL"
-     SOLVER_LIB="sundials_kinsol"
-     SOLVER_FLIB="sundials_fkinsol"
-     EXAMPLES="fkinDiagon_kry_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-    cpodes_ser_ex_bl )
-       IN_FILE="examples/cpodes/serial/Makefile_ex"
-       SOLVER="CPODES"
-       SOLVER_LIB="sundials_cpodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cpsAdvDiff_bnd cpsAdvDiff_non cpsNewtCrd_dns cpsPend_dns cpsRoberts_dns cpsVanDPol_non"
-       EXAMPLES_BL="cpsAdvDiff_bndL cpsPend_dnsL cpsRoberts_dnsL"
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cpodes_ser_ex )
-       IN_FILE="examples/cpodes/serial/Makefile_ex"
-       SOLVER="CPODES"
-       SOLVER_LIB="sundials_cpodes"
-       SOLVER_FLIB=""
-       EXAMPLES="cpsAdvDiff_bnd cpsAdvDiff_non cpsNewtCrd_dns cpsPend_dns cpsRoberts_dns cpsVanDPol_non"
-       EXAMPLES_BL=""
-       ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-        ;;
-    cpodes_par_ex )
-     IN_FILE="examples/cpodes/parallel/Makefile_ex"
-     SOLVER="CPODES"
-     SOLVER_LIB="sundials_cpodes"
-     SOLVER_FLIB=""
-     EXAMPLES="cpsHeat2D_kry_bbd_p"
-     EXAMPLES_BL=""
-     ${SHELL} bin/makefile-update.sh "${IN_FILE}" "${SOLVER}" "${EXAMPLES}" "${EXAMPLES_BL}" "${SOLVER_LIB}" "${SOLVER_FLIB}"
-      ;;
-  esac
-done
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded.  So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status.  When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
-  ac_cs_success=:
-  ac_config_status_args=
-  test "$silent" = yes &&
-    ac_config_status_args="$ac_config_status_args --quiet"
-  exec 5>/dev/null
-  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
-  exec 5>>config.log
-  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
-  # would make configure fail if this is the last instruction.
-  $ac_cs_success || { (exit 1); exit 1; }
-fi
-
-
-# Display summary
-
-
-if test "X${SUNDIALS_WARN_FLAG}" = "Xyes"; then
-echo "
-***************
-*   WARNING   *
-***************
-
-At least one warning was issued. Some features were disabled.
-
-Review the configure output and/or the contents of config.log
-before proceeding with the build.
-"
-fi
-
-echo "
-------------------------------
-SUNDIALS Configuration Summary
-------------------------------"
-
-echo "
-Configuration
--------------
-
-  Host System:               ${host}
-  Build System:              ${build}
-
-  C Preprocessor:            ${CPP}
-  C Preprocessor Flags:      ${CPPFLAGS}
-  C Compiler:	             ${CC}
-  C Compiler Flags           ${CFLAGS}
-  C Linker:                  ${CC}
-  Linker Flags:              ${LDFLAGS}
-  Libraries:                 ${LIBS}"
-
-if test "X${F77_OK}" = "Xyes"; then
-echo "
-  Fortran Compiler:          ${F77}
-  Fortran Compiler Flags:    ${FFLAGS}
-  Fortran Linker:            ${F77_LNKR}
-  Extra Fortran Libraries:   ${FLIBS}"
-fi
-
-if test "X${MPI_ENABLED}" = "Xyes" && test "X${MPI_C_COMP_OK}" = "Xyes"; then
-echo "
-  MPI Root Directory:        ${MPI_ROOT_DIR}
-  MPI Include Directory:     ${MPI_INC_DIR}
-  MPI Library Directory:     ${MPI_LIB_DIR}
-  MPI Flags:                 ${MPI_FLAGS}
-  Extra MPI Libraries:       ${MPI_LIBS}
-
-  Using MPI-C script?        ${USE_MPICC_SCRIPT}
-  MPI-C:                     ${MPICC}"
-fi
-
-if test "X${MPI_ENABLED}" = "Xyes" && test "X${F77_EXAMPLES_ENABLED}" = "Xyes" && test "X${MPI_F77_COMP_OK}" = "Xyes"; then
-echo "
-  Using MPI-Fortran script?  ${USE_MPIF77_SCRIPT}
-  MPI-Fortran:               ${MPIF77}
-  MPI-Fortran Linker:        ${MPIF77_LNKR}"
-fi
-
-# Determine SOURCE, BUILD, and EXEC_PREFIX directories
-cv_srcdir=`( cd ${srcdir} ; pwd )`
-cv_builddir=`pwd`
-if test "X${exec_prefix}" = "XNONE"; then
-  cv_exec_prefix="${prefix}"
-else
-  cv_exec_prefix="${exec_prefix}"
-fi
-
-echo "
-  srcdir:                    ${cv_srcdir}
-  builddir:                  ${cv_builddir}
-  prefix:                    ${prefix}
-  exec_prefix:               ${cv_exec_prefix}
-  includedir:                ${includedir}
-  libdir:                    ${libdir}"
-
-if test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-echo "  examples installed in:     ${EXS_INSTDIR}"
-fi
-
-echo "
-Modules
--------
-"
-
-if test "X${CVODE_ENABLED}" = "Xyes"; then
-  THIS_LINE="CVODE"
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    THIS_LINE="${THIS_LINE}  FCVODE"
-  fi
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${CVODES_ENABLED}" = "Xyes"; then
-  THIS_LINE="CVODES"
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${IDA_ENABLED}" = "Xyes"; then
-  THIS_LINE="IDA"
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    THIS_LINE="${THIS_LINE}    FIDA"
-  fi
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${IDAS_ENABLED}" = "Xyes"; then
-  THIS_LINE="IDAS"
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${KINSOL_ENABLED}" = "Xyes"; then
-  THIS_LINE="KINSOL"
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    THIS_LINE="${THIS_LINE} FKINSOL"
-  fi
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${CPODES_ENABLED}" = "Xyes"; then
-  THIS_LINE="CPODES"
-  echo "  ${THIS_LINE}"
-fi
-
-if test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-echo "
-Examples
---------
-"
-
-echo "  Serial C examples:         ${SERIAL_C_EXAMPLES}"
-echo "  Parallel C examples:       ${PARALLEL_C_EXAMPLES}"
-echo "  Serial Fortran examples:   ${SERIAL_F77_EXAMPLES}"
-echo "  Parallel Fortran examples: ${PARALLEL_F77_EXAMPLES}"
-
-fi
-
-
-echo "
-  Type 'make' and then 'make install' to build and install ${PACKAGE_STRING}."
-
-
-
-echo "
-----------------------------------
-Finished SUNDIALS Configure Script
-----------------------------------
-"
-
-
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 51d70b8..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,157 +0,0 @@
-# ------------------------------------------------------------------------
-# $Revision: 1.52 $
-# $Date: 2009/02/17 03:11:47 $
-# ------------------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# ------------------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# ------------------------------------------------------------------------
-# Process this file with autoconf to produce a configure script.
-# ------------------------------------------------------------------------
-
-# Initialize configure
-AC_INIT(SUNDIALS, 2.5.0, radu at llnl.gov)
-
-# Display greeting
-SUNDIALS_GREETING
-
-# Specify directory containing auxillary build tools and M4 files
-AC_CONFIG_AUX_DIR([config])
-
-# Miscellaneous SUNDIALS initializations
-echo "Initialization"
-echo "--------------"
-echo ""
-SUNDIALS_INITIALIZE
-
-# Test enable/disable features
-SUNDIALS_ENABLES
-
-# Set C compilation (Required)
-echo ""
-echo "C Compiler Settings"
-echo "-------------------"
-echo ""
-AC_PROG_CC(cc gcc)
-SUNDIALS_SET_CC
-
-# Set Fortran support
-if test "X${FCMIX_ENABLED}" = "Xyes" || test "X${LAPACK_ENABLED}" = "Xyes"; then
-  echo ""
-  echo "Fortran Settings"
-  echo "----------------"
-  echo ""
-  SUNDIALS_F77_SUPPORT
-fi
-
-# Set MPI support (Optional)
-if test "X${MPI_ENABLED}" = "Xyes"; then
-  echo ""
-  echo "MPI-C Settings"
-  echo "--------------"
-  echo ""
-  SUNDIALS_SET_MPICC
-fi
-if test "X${MPI_C_COMP_OK}" = "Xyes"; then
-  if test "X${FCMIX_ENABLED}" = "Xyes"; then
-    echo ""
-    echo "MPI-2 Functionality"
-    echo "-------------------"
-    echo ""
-    SUNDIALS_CHECK_MPI2
-  fi
-  if test "X${F77_EXAMPLES_ENABLED}" = "Xyes"; then
-    echo ""
-    echo "MPI-Fortran Settings"
-    echo "--------------------"
-    echo ""
-    SUNDIALS_SET_MPIF77
-  fi
-fi
-
-# Set examples modules
-if test "X${EXAMPLES_ENABLED}" = "Xyes"; then
-  echo ""
-  echo "Examples"
-  echo "--------"
-  echo ""
-  SUNDIALS_SET_EXAMPLES
-fi
-
-# Run libtool checks
-echo ""
-echo "Libtool Settings"
-echo "----------------"
-echo ""
-AC_DISABLE_SHARED
-AC_LIBTOOL_WIN32_DLL
-AC_PROG_LIBTOOL
-
-# Do we build shared libraries?
-# (enable_shared is set by the function AC_ENABLE_SHARED in libtool.m4)
-SHARED_LIBS="${enable_shared}"
-
-# Print a few more lines for configure --help
-SUNDIALS_MORE_HELP
-
-# Substitute variables
-AC_SUBST(SHARED_LIBS)
-AC_SUBST(MPICC)
-AC_SUBST(MPIF77)
-AC_SUBST(MPI_INC_DIR)
-AC_SUBST(MPI_LIB_DIR)
-AC_SUBST(MPI_LIBS)
-AC_SUBST(MPI_FLAGS)
-AC_SUBST(FCMIX_ENABLED)
-AC_SUBST(FLOAT_TYPE)
-AC_SUBST(LIBTOOL_DEPS)
-AC_SUBST(F77_MANGLE_MACRO1)
-AC_SUBST(F77_MANGLE_MACRO2)
-AC_SUBST(F77_CASE)
-AC_SUBST(F77_UNDERSCORES)
-AC_SUBST(PRECISION_LEVEL)
-AC_SUBST(GENERIC_MATH_LIB)
-AC_SUBST(BLAS_LAPACK_MACRO)
-AC_SUBST(SUNDIALS_EXPORT)
-AC_SUBST(F77_MPI_COMM_F2C)
-AC_SUBST(F77_LNKR)
-AC_SUBST(F77_LIBS)
-AC_SUBST(F77_LDFLAGS)
-AC_SUBST(LAPACK_ENABLED)
-AC_SUBST(BLAS_LAPACK_LIBS)
-AC_SUBST(MPIF77_LNKR)
-AC_SUBST(OBJEXT)
-AC_SUBST(EXEEXT)
-AC_SUBST(SLV_MODULES)
-AC_SUBST(EXS_MODULES)
-AC_SUBST(EXS_INSTDIR)
-
-# Generate makefiles
-echo ""
-echo "Create Makefiles and configuration files"
-echo "----------------------------------------"
-echo ""
-SUNDIALS_BUILD_MODULES_LIST
-
-# Set-up postprocessing commands
-if test "X${EXAMPLES_ENABLED}" = "Xyes" && test "X${EXS_INSTDIR}" != "Xno"; then
-  AC_CONFIG_COMMANDS([postprocessing],
-  [
-    echo ""
-    echo "Postprocess exported Makefiles"
-    echo "------------------------------"
-    echo ""
-  ])
-  SUNDIALS_POST_PROCESSING
-fi
-
-# Specify files to be configured and call AC_OUTPUT
-AC_CONFIG_FILES([${SUNDIALS_MAKEFILES}])
-AC_CONFIG_FILES([${SUNDIALS_CONFIGFILES}])
-AC_OUTPUT
-
-# Display summary
-SUNDIALS_REPORT
diff --git a/examples/arkode/CXX_parallel/CMakeLists.txt b/examples/arkode/CXX_parallel/CMakeLists.txt
new file mode 100644
index 0000000..8f51139
--- /dev/null
+++ b/examples/arkode/CXX_parallel/CMakeLists.txt
@@ -0,0 +1,141 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for ARKODE C++ parallel examples
+
+
+# Add variable ARKODE_examples with the names of the parallel ARKODE examples
+
+SET(ARKODE_examples
+  ark_heat2D
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+
+SET(ARKODE_extras
+  plot_heat2D.py
+  )
+
+# Check whether we use MPI compiler scripts.
+# If yes, then change the C compiler to the MPICC script.
+# If not, then add the MPI include directory for MPI headers.
+
+IF(MPI_MPICXX)
+  # use MPI_MPICXX as the compiler
+  SET(CMAKE_CXX_COMPILER ${MPI_MPICXX})
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX -DLAM_BUILDING")
+ELSE(MPI_MPICXX)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICXX)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECP_LIB sundials_nvecparallel_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECP_LIB sundials_nvecparallel_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each ARKODE example
+
+FOREACH(example ${ARKODE_examples})
+  ADD_EXECUTABLE(${example} ${example}.cpp)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(NOT MPI_MPICXX)
+    TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
+  ENDIF(NOT MPI_MPICXX)
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.cpp ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_parallel)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${ARKODE_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_parallel)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_parallel)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  LIST2STRING(ARKODE_examples EXAMPLES)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_CXX_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/CXX_parallel/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/CXX_parallel/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_parallel 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_CXX_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/CXX_parallel/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/CXX_parallel/Makefile_ex
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_parallel
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/CXX_parallel/README b/examples/arkode/CXX_parallel/README
new file mode 100644
index 0000000..5c2f8b4
--- /dev/null
+++ b/examples/arkode/CXX_parallel/README
@@ -0,0 +1,55 @@
+List of parallel ARKODE C++ examples
+
+  ark_heat2D : 2-D diffusion (PCG with Jacobi preconditioner)
+
+Sample results:
+
+  The example output was produced by running with 4 MPI processes:
+  
+      mpiexec -n 4 ./ark_heat2D
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/CXX_parallel/ark_heat2D.cpp b/examples/arkode/CXX_parallel/ark_heat2D.cpp
new file mode 100644
index 0000000..3d9528b
--- /dev/null
+++ b/examples/arkode/CXX_parallel/ark_heat2D.cpp
@@ -0,0 +1,813 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a simple anisotropic 2D heat 
+ * equation,
+ *    u_t = kx*u_xx + ky*u_yy + h,
+ * for t in [0, 10], (x,y) in [0, 1]^2, with initial conditions
+ *    u(0,x,y) =  0,
+ * stationary boundary conditions, i.e. 
+ *    u_t(t,0,y) = u_t(t,1,y) = u_t(t,x,0) = u_t(t,x,1) = 0,
+ * and a heat source of the form
+ *    h(x,y) = sin(pi*x)*sin(2*pi*y).
+ *
+ * Under this setup, the problem has an analytical solution:
+ *    u(t,x,y) = a(t)*sin(pi*x)*sin(2*pi*y), where
+ *    a(t) = (1 - exp(-(kx+4*ky)*pi^2*t)) / ((kx+4*ky)*pi^2).
+ * 
+ * The spatial derivatives are computed using second-order 
+ * centered differences, with the data distributed over nx*ny
+ * points on a uniform spatial grid.
+ *
+ * This program solves the problem with a DIRK method.  This 
+ * employs a Newton iteration with the PCG iterative linear solver, 
+ * which itself uses a Jacobi preconditioner.  The example uses the 
+ * built-in finite-difference Jacobian-vector product routine, but 
+ * supplies both the RHS and preconditioner setup/solve functions.
+ *
+ * 20 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *---------------------------------------------------------------*/
+
+// Header files 
+#include <stdio.h>
+#include <iostream>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#include "arkode/arkode.h"            // prototypes for ARKode fcts., consts. 
+#include "nvector/nvector_parallel.h" // parallel N_Vector types, fcts., macros 
+#include "arkode/arkode_pcg.h"        // prototype for ARKPcg solver 
+#include "sundials/sundials_types.h"  // def. of type 'realtype' 
+#include "mpi.h"                      // MPI header file
+
+using namespace std;
+
+// accessor macros between (x,y) location and 1D NVector array
+#define IDX(x,y,n) ((n)*(y)+(x))
+#define PI RCONST(3.1415926535897932)
+#define ONE RCONST(1.0)
+#define TWO RCONST(2.0)
+
+// user data structure 
+typedef struct {
+  long int nx;          // global number of x grid points 
+  long int ny;          // global number of y grid points
+  long int is;          // global x indices of this subdomain
+  long int ie;
+  long int js;          // global y indices of this subdomain
+  long int je;
+  long int nxl;         // local number of x grid points 
+  long int nyl;         // local number of y grid points 
+  realtype dx;          // x-directional mesh spacing 
+  realtype dy;          // y-directional mesh spacing 
+  realtype kx;          // x-directional diffusion coefficient 
+  realtype ky;          // y-directional diffusion coefficient 
+  N_Vector h;           // heat source vector
+  N_Vector d;           // inverse of Jacobian diagonal
+  MPI_Comm comm;        // communicator object
+  int myid;             // MPI process ID
+  int nprocs;           // total number of MPI processes
+  bool HaveBdry[2][2];  // flags denoting if on physical boundary
+  realtype *Erecv;      // receive buffers for neighbor exchange
+  realtype *Wrecv;
+  realtype *Nrecv;
+  realtype *Srecv;
+  realtype *Esend;      // send buffers for neighbor exchange
+  realtype *Wsend;
+  realtype *Nsend;
+  realtype *Ssend;
+} UserData;
+
+// User-supplied Functions Called by the Solver 
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int PSet(realtype t, N_Vector y, N_Vector fy, booleantype jok, 
+		booleantype *jcurPtr, realtype gamma, void *user_data,
+		N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+static int PSol(realtype t, N_Vector y, N_Vector fy, N_Vector r, 
+		N_Vector z, realtype gamma, realtype delta, int lr, 
+		void *user_data, N_Vector tmp);
+
+// Private functions 
+//    checks function return values 
+static int check_flag(void *flagvalue, const string funcname, int opt);
+//    sets default values into UserData structure
+static int InitUserData(UserData *udata);
+//    sets up parallel decomposition
+static int SetupDecomp(UserData *udata);
+//    performs neighbor exchange
+static int Exchange(N_Vector y, UserData *udata);
+//    frees memory allocated within UserData
+static int FreeUserData(UserData *udata);
+
+// Main Program 
+int main(int argc, char* argv[]) {
+
+  // general problem parameters 
+  realtype T0 = RCONST(0.0);   // initial time 
+  realtype Tf = RCONST(0.3);   // final time 
+  int Nt = 20;                 // total number of output times 
+  long int nx = 60;            // spatial mesh size
+  long int ny = 120;
+  realtype kx = 0.5;           // heat conductivity coefficients
+  realtype ky = 0.75;
+  realtype rtol = 1.e-5;       // relative and absolute tolerances
+  realtype atol = 1.e-10;
+  UserData *udata = NULL;
+  realtype *data;
+  long int N, Ntot, i, j;
+
+  // general problem variables 
+  int flag;                      // reusable error-checking flag 
+  int myid;                      // MPI process ID
+  N_Vector y = NULL;             // empty vector for storing solution 
+  void *arkode_mem = NULL;       // empty ARKode memory structure 
+
+  // initialize MPI
+  flag = MPI_Init(&argc, &argv);
+  if (check_flag(&flag, "MPI_Init", 1)) return 1;
+  flag = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+  if (check_flag(&flag, "MPI_Comm_rank", 1)) return 1;
+
+  // allocate and fill udata structure 
+  udata = new UserData;
+  flag = InitUserData(udata);
+  if (check_flag(&flag, "InitUserData", 1)) return 1;
+  udata->nx = nx;
+  udata->ny = ny;
+  udata->kx = kx;
+  udata->ky = ky;
+  udata->dx = RCONST(1.0)/(1.0*nx-1.0);   // x mesh spacing 
+  udata->dy = RCONST(1.0)/(1.0*ny-1.0);   // y mesh spacing 
+
+  // Set up parallel decomposition
+  flag = SetupDecomp(udata);
+  if (check_flag(&flag, "SetupDecomp", 1)) return 1;
+
+  // Initial problem output 
+  bool outproc = (udata->myid == 0);
+  if (outproc) {
+    cout << "\n2D Heat PDE test problem:\n";
+    cout << "   nprocs = " << udata->nprocs << "\n";
+    cout << "   nx = " << udata->nx << "\n";
+    cout << "   ny = " << udata->ny << "\n";
+    cout << "   kx = " << udata->kx << "\n";
+    cout << "   ky = " << udata->ky << "\n";
+    cout << "   rtol = " << rtol << "\n";
+    cout << "   atol = " << atol << "\n";
+    cout << "   nxl (proc 0) = " << udata->nxl << "\n";
+    cout << "   nyl (proc 0) = " << udata->nyl << "\n\n";
+  }
+
+  // Initialize data structures 
+  N = (udata->nxl)*(udata->nyl);
+  Ntot = nx*ny;
+  y = N_VNew_Parallel(udata->comm, N, Ntot);         // Create parallel vector for solution 
+  if (check_flag((void *) y, "N_VNew_Parallel", 0)) return 1;
+  N_VConst(0.0, y);                                  // Set initial conditions 
+  udata->h = N_VNew_Parallel(udata->comm, N, Ntot);  // Create vector for heat source
+  if (check_flag((void *) udata->h, "N_VNew_Parallel", 0)) return 1;
+  udata->d = N_VNew_Parallel(udata->comm, N, Ntot);  // Create vector for Jacobian diagonal
+  if (check_flag((void *) udata->d, "N_VNew_Parallel", 0)) return 1;
+  arkode_mem = ARKodeCreate();                       // Create the solver memory 
+  if (check_flag((void *) arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  // fill in the heat source array
+  data = N_VGetArrayPointer(udata->h);
+  for (j=0; j<udata->nyl; j++)
+    for (i=0; i<udata->nxl; i++)
+      data[IDX(i,j,udata->nxl)] = sin(PI*(udata->is+i)*udata->dx) 
+                                * sin(TWO*PI*(udata->js+j)*udata->dy);
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  // Set routines 
+  flag = ARKodeSetUserData(arkode_mem, (void *) udata);   // Pass udata to user functions 
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSetNonlinConvCoef(arkode_mem, 1.e-7);      // Update solver convergence coeff.
+  if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, rtol, atol);      // Specify tolerances 
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  // Linear solver specification 
+  flag = ARKPcg(arkode_mem, 1, 20);                           // Specify the PCG solver 
+  if (check_flag(&flag, "ARKPcg", 1)) return 1;
+  flag = ARKSpilsSetPreconditioner(arkode_mem, PSet, PSol);   // Specify the Preconditoner
+  if (check_flag(&flag, "ARKSpilsSetPreconditioner", 1)) return 1;
+
+  // Specify linearly implicit RHS, with non-time-dependent preconditioner
+  flag = ARKodeSetLinear(arkode_mem, 0);
+  if (check_flag(&flag, "ARKodeSetLinear", 1)) return 1;
+
+  // Each processor outputs subdomain information
+  char outname[100];
+  sprintf(outname, "heat2d_subdomain.%03i.txt", udata->myid);
+  FILE *UFID = fopen(outname,"w");
+  fprintf(UFID, "%li  %li  %li  %li  %li  %li\n", 
+	  udata->nx, udata->ny, udata->is, udata->ie, udata->js, udata->je);
+  fclose(UFID);
+
+  // Open output streams for results, access data array 
+  sprintf(outname, "heat2d.%03i.txt", udata->myid);
+  UFID = fopen(outname,"w");
+  data = N_VGetArrayPointer(y);
+
+  // output initial condition to disk 
+  for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[i]);
+  fprintf(UFID,"\n");
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  realtype t = T0;
+  realtype dTout = (Tf-T0)/Nt;
+  realtype tout = T0+dTout;
+  realtype urms = sqrt(N_VDotProd(y,y)/nx/ny);
+  if (outproc) {
+    cout << "        t      ||u||_rms\n";
+    cout << "   ----------------------\n";
+    printf("  %10.6f  %10.6f\n", t, urms);
+  }
+  int iout;
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);         // call integrator 
+    if (check_flag(&flag, "ARKode", 1)) break;
+    urms = sqrt(N_VDotProd(y,y)/nx/ny);
+    if (outproc)  printf("  %10.6f  %10.6f\n", t, urms);        // print solution stats 
+    if (flag >= 0) {                                            // successful solve: update output time
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                    // unsuccessful solve: break 
+      if (outproc)  
+	cerr << "Solver failure, stopping integration\n";
+      break;
+    }
+
+    // output results to disk 
+    for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[i]);
+    fprintf(UFID,"\n");
+  }
+  if (outproc)  cout << "   ----------------------\n";
+  fclose(UFID);
+
+  // Print some final statistics 
+  long int nst, nst_a, nfe, nfi, nsetups, nli, nJv, nlcf, nni, ncfn, netf, npe, nps;
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  if (check_flag(&flag, "ARKodeGetNumSteps", 1)) return 1;
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) return 1;
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  if (check_flag(&flag, "ARKodeGetNumRhsEvals", 1)) return 1;
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) return 1;
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) return 1;
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) return 1;
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) return 1;
+  flag = ARKSpilsGetNumLinIters(arkode_mem, &nli);
+  if (check_flag(&flag, "ARKSpilsGetNumLinIters", 1)) return 1;
+  flag = ARKSpilsGetNumJtimesEvals(arkode_mem, &nJv);
+  if (check_flag(&flag, "ARKSpilsGetNumJtimesEvals", 1)) return 1;
+  flag = ARKSpilsGetNumConvFails(arkode_mem, &nlcf);
+  if (check_flag(&flag, "ARKSpilsGetNumConvFails", 1)) return 1;
+  flag = ARKSpilsGetNumPrecEvals(arkode_mem, &npe);
+  if (check_flag(&flag, "ARKSpilsGetNumPrecEvals", 1)) return 1;
+  flag = ARKSpilsGetNumPrecSolves(arkode_mem, &nps);
+
+  if (outproc) {
+    cout << "\nFinal Solver Statistics:\n";
+    cout << "   Internal solver steps = " << nst << " (attempted = " << nst_a << ")\n";
+    cout << "   Total RHS evals:  Fe = " << nfe << ",  Fi = " << nfi << "\n";
+    cout << "   Total linear solver setups = " << nsetups << "\n";
+    cout << "   Total linear iterations = " << nli << "\n";
+    cout << "   Total number of Jacobian-vector products = " << nJv << "\n";
+    cout << "   Total number of Preconditioner setups = " << npe << "\n";
+    cout << "   Total number of Preconditioner solves = " << nps << "\n";
+    cout << "   Total number of linear solver convergence failures = " << nlcf << "\n";
+    cout << "   Total number of Newton iterations = " << nni << "\n";
+    cout << "   Total number of nonlinear solver convergence failures = " << ncfn << "\n";
+    cout << "   Total number of error test failures = " << netf << "\n";
+  }
+
+  // Clean up and return with successful completion 
+  N_VDestroy_Parallel(y);        // Free vectors 
+  N_VDestroy_Parallel(udata->h);
+  N_VDestroy_Parallel(udata->d);
+  FreeUserData(udata);         // Free user data 
+  delete udata;       
+  ARKodeFree(&arkode_mem);     // Free integrator memory 
+  flag = MPI_Finalize();       // Finalize MPI
+  return 0;
+}
+
+/*--------------------------------
+ * Functions called by the solver
+ *--------------------------------*/
+
+// f routine to compute the ODE RHS function f(t,y). 
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  N_VConst(0.0, ydot);                           // Initialize ydot to zero 
+  UserData *udata = (UserData *) user_data;      // access problem data 
+  long int nxl = udata->nxl;                     // set variable shortcuts 
+  long int nyl = udata->nyl;
+  realtype kx = udata->kx;
+  realtype ky = udata->ky;
+  realtype dx = udata->dx;
+  realtype dy = udata->dy;
+  realtype *Y = N_VGetArrayPointer(y);           // access data arrays 
+  if (check_flag((void *) Y, "N_VGetArrayPointer", 0)) return -1;
+  realtype *Ydot = N_VGetArrayPointer(ydot);
+  if (check_flag((void *) Ydot, "N_VGetArrayPointer", 0)) return -1;
+
+  // Exchange boundary data with neighbors
+  int ierr = Exchange(y, udata);
+  if (check_flag(&ierr, "Exchange", 1)) return -1;
+
+  // iterate over subdomain interior, computing approximation to RHS
+  realtype c1 = kx/dx/dx;
+  realtype c2 = ky/dy/dy;
+  realtype c3 = -TWO*(c1 + c2);
+  long int i, j;
+  for (j=1; j<nyl-1; j++)                        // diffusive terms
+    for (i=1; i<nxl-1; i++)
+      Ydot[IDX(i,j,nxl)] = c1*(Y[IDX(i-1,j,nxl)] + Y[IDX(i+1,j,nxl)])
+                         + c2*(Y[IDX(i,j-1,nxl)] + Y[IDX(i,j+1,nxl)])
+                         + c3*Y[IDX(i,j,nxl)];
+  
+  // iterate over subdomain boundaries (if not at overall domain boundary)
+  if (!udata->HaveBdry[0][0]) {    // West face
+    i=0;
+    for (j=1; j<nyl-1; j++)  
+      Ydot[IDX(i,j,nxl)] = c1*(udata->Wrecv[j]   + Y[IDX(i+1,j,nxl)])
+                         + c2*(Y[IDX(i,j-1,nxl)] + Y[IDX(i,j+1,nxl)])
+                         + c3*Y[IDX(i,j,nxl)];
+  }
+  if (!udata->HaveBdry[0][1]) {    // East face
+    i=nxl-1;
+    for (j=1; j<nyl-1; j++)  
+      Ydot[IDX(i,j,nxl)] = c1*(Y[IDX(i-1,j,nxl)] + udata->Erecv[j])
+                         + c2*(Y[IDX(i,j-1,nxl)] + Y[IDX(i,j+1,nxl)])
+                         + c3*Y[IDX(i,j,nxl)];
+  }
+  if (!udata->HaveBdry[1][0]) {    // South face
+    j=0;
+    for (i=1; i<nxl-1; i++)  
+      Ydot[IDX(i,j,nxl)] = c1*(Y[IDX(i-1,j,nxl)] + Y[IDX(i+1,j,nxl)])
+                         + c2*(udata->Srecv[i]   + Y[IDX(i,j+1,nxl)])
+                         + c3*Y[IDX(i,j,nxl)];
+  }
+  if (!udata->HaveBdry[1][1]) {    // West face
+    j=nyl-1;
+    for (i=1; i<nxl-1; i++)  
+      Ydot[IDX(i,j,nxl)] = c1*(Y[IDX(i-1,j,nxl)] + Y[IDX(i+1,j,nxl)])
+                         + c2*(Y[IDX(i,j-1,nxl)] + udata->Nrecv[i])
+                         + c3*Y[IDX(i,j,nxl)];
+  }
+  if (!udata->HaveBdry[0][0] && !udata->HaveBdry[1][0]) {  // South-West corner
+    i = 0; 
+    j = 0;
+    Ydot[IDX(i,j,nxl)] = c1*(udata->Wrecv[j] + Y[IDX(i+1,j,nxl)])
+                       + c2*(udata->Srecv[i] + Y[IDX(i,j+1,nxl)])
+                       + c3*Y[IDX(i,j,nxl)];
+  }
+  if (!udata->HaveBdry[0][0] && !udata->HaveBdry[1][1]) {  // North-West corner
+    i = 0; 
+    j = nyl-1;
+    Ydot[IDX(i,j,nxl)] = c1*(udata->Wrecv[j]   + Y[IDX(i+1,j,nxl)])
+                       + c2*(Y[IDX(i,j-1,nxl)] + udata->Nrecv[i])
+                       + c3*Y[IDX(i,j,nxl)];
+  }
+  if (!udata->HaveBdry[0][1] && !udata->HaveBdry[1][0]) {  // South-East corner
+    i = nxl-1; 
+    j = 0;
+    Ydot[IDX(i,j,nxl)] = c1*(Y[IDX(i-1,j,nxl)] + udata->Erecv[j])
+                       + c2*(udata->Srecv[i]   + Y[IDX(i,j+1,nxl)])
+                       + c3*Y[IDX(i,j,nxl)];
+  }
+  if (!udata->HaveBdry[0][1] && !udata->HaveBdry[1][1]) {  // North-East corner
+    i = nxl-1; 
+    j = nyl-1;
+    Ydot[IDX(i,j,nxl)] = c1*(Y[IDX(i-1,j,nxl)] + udata->Erecv[j])
+                       + c2*(Y[IDX(i,j-1,nxl)] + udata->Nrecv[i])
+                       + c3*Y[IDX(i,j,nxl)];
+  }
+
+  // add in heat source
+  N_VLinearSum(1.0, ydot, 1.0, udata->h, ydot);
+  return 0;                                      // Return with success 
+}
+
+// Preconditioner setup routine (fills inverse of Jacobian diagonal)
+static int PSet(realtype t, N_Vector y, N_Vector fy, booleantype jok, 
+		booleantype *jcurPtr, realtype gamma, void *user_data,
+		N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  UserData *udata = (UserData *) user_data;      // variable shortcuts 
+  realtype kx = udata->kx;
+  realtype ky = udata->ky;
+  realtype dx = udata->dx;
+  realtype dy = udata->dy;
+  realtype *diag = N_VGetArrayPointer(tmp1);  // access data arrays 
+  if (check_flag((void *) diag, "N_VGetArrayPointer", 0)) return -1;
+
+  // set all entries of tmp1 to the diagonal values of interior
+  // (since boundary RHS is 0, set boundary diagonals to the same)
+  realtype c = ONE + gamma*TWO*(kx/dx/dx + ky/dy/dy);
+  N_VConst(c, tmp1);
+  N_VInv(tmp1, udata->d);      // set d to inverse of diagonal
+  return 0;                    // Return with success 
+}
+
+// Preconditioner solve routine
+static int PSol(realtype t, N_Vector y, N_Vector fy, N_Vector r, 
+		N_Vector z, realtype gamma, realtype delta, int lr, 
+		void *user_data, N_Vector tmp)
+{
+  UserData *udata = (UserData *) user_data;  // access user_data structure
+  N_VProd(r, udata->d, z);                   // perform Jacobi iteration
+  return 0;                                  // Return with success 
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const string funcname, int opt)
+{
+  int *errflag;
+
+  // Check if SUNDIALS function returned NULL pointer - no memory allocated
+  if (opt == 0 && flagvalue == NULL) {
+    cerr << "\nSUNDIALS_ERROR: " << funcname << " failed - returned NULL pointer\n\n";
+    return 1; }
+
+  // Check if flag < 0
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      cerr << "\nSUNDIALS_ERROR: " << funcname << " failed with flag = " << *errflag << "\n\n";
+      return 1; 
+    }
+  }
+  
+  // Check if function returned NULL pointer - no memory allocated
+  else if (opt == 2 && flagvalue == NULL) {
+    cerr << "\nMEMORY_ERROR: " << funcname << " failed - returned NULL pointer\n\n";
+    return 1; }
+
+  return 0;
+}
+
+// Set up parallel decomposition
+static int SetupDecomp(UserData *udata)
+{
+  // check that this has not been called before
+  if (udata->Erecv != NULL || udata->Wrecv != NULL || 
+      udata->Srecv != NULL || udata->Nrecv != NULL) {
+    cerr << "SetupDecomp warning: parallel decomposition already set up\n";
+    return 1;
+  }
+
+  // get suggested parallel decomposition
+  int ierr, dims[] = {0, 0};
+  ierr = MPI_Comm_size(MPI_COMM_WORLD, &(udata->nprocs));
+  if (ierr != MPI_SUCCESS) {
+    cerr << "Error in MPI_Comm_size = " << ierr << "\n";
+    return -1;
+  }
+  ierr = MPI_Dims_create(udata->nprocs, 2, dims);
+  if (ierr != MPI_SUCCESS) {
+    cerr << "Error in MPI_Dims_create = " << ierr << "\n";
+    return -1;
+  }
+
+  // set up 2D Cartesian communicator
+  int periods[] = {0, 0};
+  ierr = MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, &(udata->comm));
+  if (ierr != MPI_SUCCESS) {
+    cerr << "Error in MPI_Cart_create = " << ierr << "\n";
+    return -1;
+  }
+  ierr = MPI_Comm_rank(udata->comm, &(udata->myid));
+  if (ierr != MPI_SUCCESS) {
+    cerr << "Error in MPI_Comm_rank = " << ierr << "\n";
+    return -1;
+  }
+
+  // determine local extents
+  int coords[2];
+  ierr = MPI_Cart_get(udata->comm, 2, dims, periods, coords);
+  if (ierr != MPI_SUCCESS) {
+    cerr << "Error in MPI_Cart_get = " << ierr << "\n";
+    return -1;
+  }
+  udata->is = (udata->nx)*(coords[0])/(dims[0]);
+  udata->ie = (udata->nx)*(coords[0]+1)/(dims[0])-1;
+  udata->js = (udata->ny)*(coords[1])/(dims[1]);
+  udata->je = (udata->ny)*(coords[1]+1)/(dims[1])-1;
+  udata->nxl = (udata->ie)-(udata->is)+1;
+  udata->nyl = (udata->je)-(udata->js)+1;
+
+  // determine if I have neighbors, and allocate exchange buffers
+  udata->HaveBdry[0][0] = (udata->is == 0);
+  udata->HaveBdry[0][1] = (udata->ie == udata->nx-1);
+  udata->HaveBdry[1][0] = (udata->js == 0);
+  udata->HaveBdry[1][1] = (udata->je == udata->ny-1);
+  if (!udata->HaveBdry[0][0]) {
+    udata->Wrecv = new realtype[udata->nyl];
+    udata->Wsend = new realtype[udata->nyl];
+  }
+  if (!udata->HaveBdry[0][1]) {
+    udata->Erecv = new realtype[udata->nyl];
+    udata->Esend = new realtype[udata->nyl];
+  }
+  if (!udata->HaveBdry[1][0]) {
+    udata->Srecv = new realtype[udata->nxl];
+    udata->Ssend = new realtype[udata->nxl];
+  }
+  if (!udata->HaveBdry[1][1]) {
+    udata->Nrecv = new realtype[udata->nxl];
+    udata->Nsend = new realtype[udata->nxl];
+  }
+
+  return 0;     // return with success flag
+}
+
+// Perform neighbor exchange
+static int Exchange(N_Vector y, UserData *udata)
+{
+  // local variables
+  MPI_Request reqSW, reqSE, reqSS, reqSN, reqRW, reqRE, reqRS, reqRN;
+  MPI_Status stat;
+  int ierr, i, ipW=-1, ipE=-1, ipS=-1, ipN=-1;
+  int coords[2], dims[2], periods[2], nbcoords[2];
+  int nyl = udata->nyl;
+  int nxl = udata->nxl;
+
+  // access data array
+  realtype *Y = N_VGetArrayPointer(y);
+  if (check_flag((void *) Y, "N_VGetArrayPointer", 0)) return -1;
+
+  // MPI equivalent of realtype type
+  #if defined(SUNDIALS_SINGLE_PRECISION)
+  #define REALTYPE_MPI_TYPE MPI_FLOAT
+  #elif defined(SUNDIALS_DOUBLE_PRECISION)
+  #define REALTYPE_MPI_TYPE MPI_DOUBLE
+  #elif defined(SUNDIALS_EXTENDED_PRECISION)
+  #define REALTYPE_MPI_TYPE MPI_LONG_DOUBLE
+  #endif
+
+  // MPI neighborhood information
+  ierr = MPI_Cart_get(udata->comm, 2, dims, periods, coords);
+  if (ierr != MPI_SUCCESS) {
+    cerr << "Error in MPI_Cart_get = " << ierr << "\n";
+    return -1;
+  }
+  if (!udata->HaveBdry[0][0]) {
+    nbcoords[0] = coords[0]-1; 
+    nbcoords[1] = coords[1];
+    ierr = MPI_Cart_rank(udata->comm, nbcoords, &ipW);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Cart_rank = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[0][1]) {
+    nbcoords[0] = coords[0]+1; 
+    nbcoords[1] = coords[1];
+    ierr = MPI_Cart_rank(udata->comm, nbcoords, &ipE);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Cart_rank = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][0]) {
+    nbcoords[0] = coords[0]; 
+    nbcoords[1] = coords[1]-1;
+    ierr = MPI_Cart_rank(udata->comm, nbcoords, &ipS);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Cart_rank = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][1]) {
+    nbcoords[0] = coords[0]; 
+    nbcoords[1] = coords[1]+1;
+    ierr = MPI_Cart_rank(udata->comm, nbcoords, &ipN);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Cart_rank = " << ierr << "\n";
+      return -1;
+    }
+  }
+  
+  // open Irecv buffers
+  if (!udata->HaveBdry[0][0]) {
+    ierr = MPI_Irecv(udata->Wrecv, udata->nyl, REALTYPE_MPI_TYPE, ipW,
+                   MPI_ANY_TAG, udata->comm, &reqRW);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Irecv = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[0][1]) {
+    ierr = MPI_Irecv(udata->Erecv, udata->nyl, REALTYPE_MPI_TYPE, ipE,
+                   MPI_ANY_TAG, udata->comm, &reqRE);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Irecv = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][0]) {
+    ierr = MPI_Irecv(udata->Srecv, udata->nxl, REALTYPE_MPI_TYPE, ipS,
+                   MPI_ANY_TAG, udata->comm, &reqRS);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Irecv = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][1]) {
+    ierr = MPI_Irecv(udata->Nrecv, udata->nxl, REALTYPE_MPI_TYPE, ipN,
+                   MPI_ANY_TAG, udata->comm, &reqRN);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Irecv = " << ierr << "\n";
+      return -1;
+    }
+  }
+
+  // send data
+  if (!udata->HaveBdry[0][0]) {
+    for (i=0; i<nyl; i++)  udata->Wsend[i] = Y[IDX(0,i,nxl)];
+    ierr = MPI_Isend(udata->Wsend, udata->nyl, REALTYPE_MPI_TYPE, ipW, 0,
+              udata->comm, &reqSW);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Isend = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[0][1]) {
+    for (i=0; i<nyl; i++)  udata->Esend[i] = Y[IDX(nxl-1,i,nxl)];
+    ierr = MPI_Isend(udata->Esend, udata->nyl, REALTYPE_MPI_TYPE, ipE, 1,
+              udata->comm, &reqSE);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Isend = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][0]) {
+    for (i=0; i<nxl; i++)  udata->Ssend[i] = Y[IDX(i,0,nxl)];
+    ierr = MPI_Isend(udata->Ssend, udata->nxl, REALTYPE_MPI_TYPE, ipS, 2,
+              udata->comm, &reqSS);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Isend = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][1]) {
+    for (i=0; i<nxl; i++)  udata->Nsend[i] = Y[IDX(i,nyl-1,nxl)];
+    ierr = MPI_Isend(udata->Nsend, udata->nxl, REALTYPE_MPI_TYPE, ipN, 3,
+              udata->comm, &reqSN);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Isend = " << ierr << "\n";
+      return -1;
+    }
+  }
+
+  // wait for messages to finish
+  if (!udata->HaveBdry[0][0]) {
+    ierr = MPI_Wait(&reqRW, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+    ierr = MPI_Wait(&reqSW, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[0][1]) {
+    ierr = MPI_Wait(&reqRE, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+    ierr = MPI_Wait(&reqSE, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][0]) {
+    ierr = MPI_Wait(&reqRS, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+    ierr = MPI_Wait(&reqSS, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+  }
+  if (!udata->HaveBdry[1][1]) {
+    ierr = MPI_Wait(&reqRN, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+    ierr = MPI_Wait(&reqSN, &stat);
+    if (ierr != MPI_SUCCESS) {
+      cerr << "Error in MPI_Wait = " << ierr << "\n";
+      return -1;
+    }
+  }
+
+  return 0;     // return with success flag
+}
+
+// Initialize memory allocated within Userdata
+static int InitUserData(UserData *udata)
+{
+  udata->nx = 0;
+  udata->ny = 0;
+  udata->is = 0;
+  udata->ie = 0;  
+  udata->js = 0;
+  udata->je = 0;  
+  udata->nxl = 0;
+  udata->nyl = 0;
+  udata->dx = 0.0;
+  udata->dy = 0.0;
+  udata->kx = 0.0;
+  udata->ky = 0.0;
+  udata->h = NULL;
+  udata->d = NULL;
+  udata->comm = MPI_COMM_WORLD;
+  udata->myid = 0;
+  udata->nprocs = 0;
+  udata->HaveBdry[0][0] = 1;
+  udata->HaveBdry[0][1] = 1;
+  udata->HaveBdry[1][0] = 1;
+  udata->HaveBdry[1][1] = 1;
+  udata->Erecv = NULL;
+  udata->Wrecv = NULL;
+  udata->Nrecv = NULL;
+  udata->Srecv = NULL;
+  udata->Esend = NULL;
+  udata->Wsend = NULL;
+  udata->Nsend = NULL;
+  udata->Ssend = NULL;
+
+  return 0;     // return with success flag
+}
+
+// Free memory allocated within Userdata
+static int FreeUserData(UserData *udata)
+{
+  // free exchange buffers
+  if (udata->Wrecv != NULL)  delete[] udata->Wrecv;
+  if (udata->Wsend != NULL)  delete[] udata->Wsend;
+  if (udata->Erecv != NULL)  delete[] udata->Erecv;
+  if (udata->Esend != NULL)  delete[] udata->Esend;
+  if (udata->Srecv != NULL)  delete[] udata->Srecv;
+  if (udata->Ssend != NULL)  delete[] udata->Ssend;
+  if (udata->Nrecv != NULL)  delete[] udata->Nrecv;
+  if (udata->Nsend != NULL)  delete[] udata->Nsend;
+
+  return 0;     // return with success flag
+}
+
+
+//---- end of file ----
diff --git a/examples/arkode/CXX_parallel/ark_heat2D.out b/examples/arkode/CXX_parallel/ark_heat2D.out
new file mode 100644
index 0000000..dc415b3
--- /dev/null
+++ b/examples/arkode/CXX_parallel/ark_heat2D.out
@@ -0,0 +1,49 @@
+
+2D Heat PDE test problem:
+   nprocs = 1
+   nx = 60
+   ny = 120
+   kx = 0.5
+   ky = 0.75
+   rtol = 1e-05
+   atol = 1e-10
+   nxl (proc 0) = 60
+   nyl (proc 0) = 120
+
+        t      ||u||_rms
+   ----------------------
+    0.000000    0.000000
+    0.015000    0.005780
+    0.030000    0.009224
+    0.045000    0.011275
+    0.060000    0.012497
+    0.075000    0.013224
+    0.090000    0.013658
+    0.105000    0.013916
+    0.120000    0.014070
+    0.135000    0.014162
+    0.150000    0.014216
+    0.165000    0.014249
+    0.180000    0.014268
+    0.195000    0.014280
+    0.210000    0.014287
+    0.225000    0.014291
+    0.240000    0.014293
+    0.255000    0.014295
+    0.270000    0.014295
+    0.285000    0.014296
+    0.300000    0.014296
+   ----------------------
+
+Final Solver Statistics:
+   Internal solver steps = 51 (attempted = 51)
+   Total RHS evals:  Fe = 0,  Fi = 514
+   Total linear solver setups = 18
+   Total linear iterations = 4094
+   Total number of Jacobian-vector products = 4094
+   Total number of Preconditioner setups = 1
+   Total number of Preconditioner solves = 4237
+   Total number of linear solver convergence failures = 143
+   Total number of Newton iterations = 255
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 0
diff --git a/examples/arkode/CXX_parallel/plot_heat2D.py b/examples/arkode/CXX_parallel/plot_heat2D.py
new file mode 100755
index 0000000..f6a41b9
--- /dev/null
+++ b/examples/arkode/CXX_parallel/plot_heat2D.py
@@ -0,0 +1,142 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s):  Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for heat2D.cpp example
+# ----------------------------------------------------------------
+
+# imports
+import sys
+import numpy as np
+from pylab import *
+from mpl_toolkits.mplot3d import Axes3D
+from matplotlib import cm
+import matplotlib.pyplot as plt
+
+# determine the number of MPI processes used
+nprocs=1
+for i in range(1000):
+    sname = 'heat2d_subdomain.' + repr(i).zfill(3) + '.txt'
+    try:
+        f = open(sname,'r')
+        f.close()
+    except IOError:
+        nprocs = i
+        break
+
+# load subdomain information, store in table
+subdomains = np.zeros((nprocs,4), dtype=np.int)
+for i in range(nprocs):
+    sname = 'heat2d_subdomain.' + repr(i).zfill(3) + '.txt'
+    subd = np.loadtxt(sname, dtype=np.int)
+    if (i == 0):
+        nx = subd[0]
+        ny = subd[1]
+    else:
+        if ((subd[0] != nx) or (subd[1] != ny)):
+            sys.exit("error: subdomain files incompatible (clean up and re-run test)")
+    subdomains[i,:] = subd[2:6]
+    
+# load first processor's data, and determine total number of time steps
+data = np.loadtxt('heat2d.000.txt', dtype=np.double)
+nt = np.shape(data)[0]
+
+# create empty array for all solution data
+results = np.zeros((nt,ny,nx))
+
+# insert first processor's data into results array
+istart = subdomains[0,0]
+iend = subdomains[0,1]
+jstart = subdomains[0,2]
+jend = subdomains[0,3]
+nxl = iend-istart+1
+nyl = jend-jstart+1
+for i in range(nt):
+    results[i,jstart:jend+1,istart:iend+1] = np.reshape(data[i,:], (nyl,nxl))
+    
+# iterate over remaining data files, inserting into output
+if (nprocs > 1):
+    for isub in range(1,nprocs):
+        data = np.loadtxt('heat2d.' + repr(isub).zfill(3) + '.txt', dtype=np.double)
+        # check that subdomain has correct number of time steps
+        if (np.shape(data)[0] != nt):
+            sys.exit('error: subdomain ' + isub + ' has an incorrect number of time steps')
+        istart = subdomains[isub,0]
+        iend = subdomains[isub,1]
+        jstart = subdomains[isub,2]
+        jend = subdomains[isub,3]
+        nxl = iend-istart+1
+        nyl = jend-jstart+1
+        for i in range(nt):
+            results[i,jstart:jend+1,istart:iend+1] = np.reshape(data[i,:], (nyl,nxl))
+
+# determine extents of plots
+maxtemp = 1.1*results.max()
+mintemp = 0.9*results.min()
+
+# generate plots of results
+kx = 0.5
+ky = 0.75
+kprod = (kx+4.0*ky)*np.pi**2
+dt = 0.015
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'heat2d_surf.' + repr(tstep).zfill(3) + '.png'
+    cname = 'heat2d_err.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(nx)
+    nystr = repr(ny)
+
+    # set x and y meshgrid objects
+    xspan = np.linspace(0.0, 1.0, nx)
+    yspan = np.linspace(0.0, 1.0, ny)
+    X,Y = np.meshgrid(xspan,yspan)
+
+    # plot current solution as a surface, and save to disk
+    fig = plt.figure(1)
+    ax = fig.add_subplot(111, projection='3d')
+    ax.plot_surface(X, Y, results[tstep,:,:], rstride=1, cstride=1, 
+                    cmap=cm.jet, linewidth=0, antialiased=True, shade=True)
+    ax.set_xlabel('x')
+    ax.set_ylabel('y')
+    ax.set_zlim((mintemp, maxtemp))
+    ax.view_init(20,45)
+    title('u(x,y) at output ' + tstr + ', mesh = ' + nxstr + 'x' + nystr)
+    savefig(pname)
+    plt.close()
+
+    # plot error in current solution (as a contour, and save to disk)
+    t = tstep*dt;
+    at = (1.0 - np.exp(-t*kprod))/kprod
+    utrue = at*np.sin(np.pi*X)*np.sin(2.0*np.pi*Y);
+    uerr = np.abs(utrue - results[tstep,:,:])
+    plt.contourf(xspan,yspan,uerr,15, cmap=plt.cm.jet)
+    plt.colorbar()
+    plt.xlabel('x')
+    plt.ylabel('y')
+    plt.title('Error at output ' + tstr + ', mesh = ' + nxstr + 'x' + nystr)
+    plt.savefig(cname)
+    plt.close()
+
+
+
+
+##### end of script #####
diff --git a/examples/arkode/CXX_serial/CMakeLists.txt b/examples/arkode/CXX_serial/CMakeLists.txt
new file mode 100644
index 0000000..8ebc0f3
--- /dev/null
+++ b/examples/arkode/CXX_serial/CMakeLists.txt
@@ -0,0 +1,149 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for ARKODE serial examples
+
+# Add variable ARKODE_examples with the names of the serial ARKODE examples
+
+SET(ARKODE_examples
+  ark_analytic_sys
+  )
+
+# Add variable ARKODE_examples_BL with the names of the serial ARKODE examples
+# that use Lapack
+
+SET(ARKODE_examples_BL
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+
+SET(ARKODE_extras
+  plot_sol.py
+  )
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECS_LIB sundials_nvecserial_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECS_LIB sundials_nvecserial_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each ARKODE example
+
+FOREACH(example ${ARKODE_examples})
+  ADD_EXECUTABLE(${example} ${example}.cpp)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.cpp ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_serial)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${ARKODE_examples})
+
+# Add the build and install targets for each Lapack ARKODE example (if needed)
+
+IF(LAPACK_FOUND)
+  FOREACH(example ${ARKODE_examples_BL})
+    ADD_EXECUTABLE(${example} ${example}.cpp)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.cpp ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${ARKODE_examples_BL})
+ENDIF(LAPACK_FOUND)
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_serial)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_serial)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  LIST2STRING(ARKODE_examples EXAMPLES)
+  IF(LAPACK_FOUND)
+    LIST2STRING(ARKODE_examples_BL EXAMPLES_BL)
+  ELSE(LAPACK_FOUND)
+    SET(EXAMPLES_BL "")
+  ENDIF(LAPACK_FOUND)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_CXX_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/CXX_serial/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/CXX_serial/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_serial 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_CXX_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/CXX_serial/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/CXX_serial/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/CXX_serial 
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/CXX_serial/README b/examples/arkode/CXX_serial/README
new file mode 100644
index 0000000..7f114b2
--- /dev/null
+++ b/examples/arkode/CXX_serial/README
@@ -0,0 +1,49 @@
+List of serial ARKODE C++ examples
+
+  ark_analytic_sys : simple stiff, linear, ODE system example
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/CXX_serial/ark_analytic_sys.cpp b/examples/arkode/CXX_serial/ark_analytic_sys.cpp
new file mode 100644
index 0000000..f9779e0
--- /dev/null
+++ b/examples/arkode/CXX_serial/ark_analytic_sys.cpp
@@ -0,0 +1,352 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem with analytical 
+ * solution,
+ *    dy/dt = A*y
+ * where A = V*D*Vi, 
+ *      V = [1 -1 1; -1 2 1; 0 -1 2];
+ *      Vi = 0.25*[5 1 -3; 2 2 -2; 1 1 1];
+ *      D = [-0.5 0 0; 0 -0.1 0; 0 0 lam];
+ * where lam is a large negative number. The analytical solution to
+ * this problem is 
+ *   Y(t) = V*exp(D*t)*Vi*Y0
+ * for t in the interval [0.0, 0.05], with initial condition: 
+ * y(0) = [1,1,1]'.
+ * 
+ * The stiffness of the problem is directly proportional to the 
+ * value of "lamda".  The value of lamda should be negative to 
+ * result in a well-posed ODE; for values with magnitude larger than
+ * 100 the problem becomes quite stiff.
+ * 
+ * In this example, we choose lamda = -100.
+ * 
+ * This program solves the problem with the DIRK method,
+ * Newton iteration with the ARKDENSE dense linear solver, and a
+ * user-supplied Jacobian routine.
+ * Output is printed every 1.0 units of time (10 total).
+ * Run statistics (optional outputs) are printed at the end.
+ *-----------------------------------------------------------------*/
+
+// Header files
+#include <stdio.h>
+#include <iostream>
+#include <string.h>
+#include <math.h>
+#include <arkode/arkode.h>            // prototypes for ARKode fcts., consts.
+#include <nvector/nvector_serial.h>   // serial N_Vector types, fcts., macros
+#include <arkode/arkode_dense.h>      // prototype for ARKDense solver
+#include <sundials/sundials_dense.h>  // defs. of DlsMat and DENSE_ELEM
+#include <sundials/sundials_types.h>  // def. of type 'realtype'
+
+using namespace std;
+
+// User-supplied Functions Called by the Solver
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+// Private function to perform matrix-matrix product
+static int dense_MM(DlsMat A, DlsMat B, DlsMat C);
+
+// Private function to check function return values
+static int check_flag(void *flagvalue, const string funcname, int opt);
+
+// Main Program
+int main()
+{
+  // general problem parameters
+  realtype T0 = RCONST(0.0);       // initial time
+  realtype Tf = RCONST(0.05);      // final time
+  realtype dTout = RCONST(0.005);  // time between outputs
+  long int NEQ = 3;                // number of dependent vars.
+  realtype reltol = 1.0e-6;        // tolerances
+  realtype abstol = 1.0e-10;
+  realtype lamda  = -100.0;        // stiffness parameter
+
+  // general problem variables
+  int flag;                      // reusable error-checking flag
+  N_Vector y = NULL;             // empty vector for storing solution
+  void *arkode_mem = NULL;       // empty ARKode memory structure
+
+  // Initial problem output
+  cout << "\nAnalytical ODE test problem:\n";
+  cout << "    lamda = " << lamda << "\n";
+  cout << "   reltol = " << reltol << "\n";
+  cout << "   abstol = " << abstol << "\n\n";
+
+  // Initialize data structures
+  y = N_VNew_Serial(NEQ);         // Create serial vector solution
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  NV_Ith_S(y,0) = 1.0;            // Specify initial condition
+  NV_Ith_S(y,1) = 1.0;
+  NV_Ith_S(y,2) = 1.0;
+  arkode_mem = ARKodeCreate();    // Create the solver memory
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  // Set routines
+  flag = ARKodeSetUserData(arkode_mem, (void *) &lamda);   // Pass lamda to user functions
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);   // Specify tolerances
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  // Linear solver specification
+  flag = ARKDense(arkode_mem, NEQ);              // Specify dense linear solver
+  if (check_flag(&flag, "ARKDense", 1)) return 1;
+  flag = ARKDlsSetDenseJacFn(arkode_mem, Jac);   // Set Jacobian routine
+  if (check_flag(&flag, "ARKDlsSetDenseJacFn", 1)) return 1;
+
+  // Specify linearly implicit RHS, with non-time-dependent Jacobian
+  flag = ARKodeSetLinear(arkode_mem, 0);
+  if (check_flag(&flag, "ARKodeSetLinear", 1)) return 1;
+
+  // Open output stream for results, output comment line
+  FILE *UFID = fopen("solution.txt","w");
+  fprintf(UFID,"# t y1 y2 y3\n");
+
+  // output initial condition to disk 
+  fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	  T0, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  realtype t = T0;
+  realtype tout = T0+dTout;
+  cout << "      t        y0        y1        y2\n";
+  cout << "   --------------------------------------\n";
+  while (Tf - t > 1.0e-15) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);       // call integrator
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %8.4f  %8.5f  %8.5f  %8.5f\n",                  // access/print solution
+           t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));
+    fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	    t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+    if (flag >= 0) {                                          // successful solve: update time
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                  // unsuccessful solve: break
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+  }
+  cout << "   --------------------------------------\n";
+  fclose(UFID);
+
+  // Print some final statistics
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nfeLS, nni, ncfn, netf;
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKDlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKDlsGetNumJacEvals", 1);
+  flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
+
+  cout << "\nFinal Solver Statistics:\n";
+  cout << "   Internal solver steps = " << nst << " (attempted = " << nst_a << ")\n";
+  cout << "   Total RHS evals:  Fe = " << nfe << ",  Fi = " << nfi << "\n";
+  cout << "   Total linear solver setups = " << nsetups << "\n";
+  cout << "   Total RHS evals for setting up the linear system = " << nfeLS << "\n";
+  cout << "   Total number of Jacobian evaluations = " << nje << "\n";
+  cout << "   Total number of Newton iterations = " << nni << "\n";
+  cout << "   Total number of linear solver convergence failures = " << ncfn << "\n";
+  cout << "   Total number of error test failures = " << netf << "\n\n";
+
+  // Clean up and return with successful completion
+  N_VDestroy_Serial(y);        // Free y vector
+  ARKodeFree(&arkode_mem);     // Free integrator memory
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+// f routine to compute the ODE RHS function f(t,y).
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype *rdata = (realtype *) user_data;   // cast user_data to realtype
+  realtype lam = rdata[0];                    // set shortcut for stiffness parameter
+  realtype y0 = NV_Ith_S(y,0);                // access current solution values
+  realtype y1 = NV_Ith_S(y,1);
+  realtype y2 = NV_Ith_S(y,2);
+  realtype yd0, yd1, yd2;
+
+  // fill in the RHS function: f(t,y) = V*D*Vi*y
+  yd0 = 0.25*(5.0*y0 + 1.0*y1 - 3.0*y2);     // yd = Vi*y
+  yd1 = 0.25*(2.0*y0 + 2.0*y1 - 2.0*y2);
+  yd2 = 0.25*(1.0*y0 + 1.0*y1 + 1.0*y2);
+  y0  = -0.5*yd0;                            //  y = D*yd
+  y1  = -0.1*yd1;
+  y2  =  lam*yd2;
+  yd0 =  1.0*y0 - 1.0*y1 + 1.0*y2;           // yd = V*y
+  yd1 = -1.0*y0 + 2.0*y1 + 1.0*y2;
+  yd2 =  0.0*y0 - 1.0*y1 + 2.0*y2;
+  NV_Ith_S(ydot,0) = yd0;
+  NV_Ith_S(ydot,1) = yd1;
+  NV_Ith_S(ydot,2) = yd2;
+
+  return 0;                                  // Return with success
+}
+
+// Jacobian routine to compute J(t,y) = df/dy.
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *rdata = (realtype *) user_data;   // cast user_data to realtype
+  realtype lam = rdata[0];                    // set shortcut for stiffness parameter
+  DlsMat V  = NewDenseMat(3,3);               // create temporary DlsMat objects
+  DlsMat D  = NewDenseMat(3,3);
+  DlsMat Vi = NewDenseMat(3,3);
+
+  DenseScale(0.0, V);     // initialize temporary matrices to zero
+  DenseScale(0.0, D);
+  DenseScale(0.0, Vi);
+
+  // Fill in temporary matrices:
+  //    V = [1 -1 1; -1 2 1; 0 -1 2]
+  DENSE_ELEM(V,0,0) =  1.0;
+  DENSE_ELEM(V,0,1) = -1.0;
+  DENSE_ELEM(V,0,2) =  1.0;
+  DENSE_ELEM(V,1,0) = -1.0;
+  DENSE_ELEM(V,1,1) =  2.0;
+  DENSE_ELEM(V,1,2) =  1.0;
+  DENSE_ELEM(V,2,0) =  0.0;
+  DENSE_ELEM(V,2,1) = -1.0;
+  DENSE_ELEM(V,2,2) =  2.0;
+
+  //    Vi = 0.25*[5 1 -3; 2 2 -2; 1 1 1]
+  DENSE_ELEM(Vi,0,0) =  0.25*5.0;
+  DENSE_ELEM(Vi,0,1) =  0.25*1.0;
+  DENSE_ELEM(Vi,0,2) = -0.25*3.0;
+  DENSE_ELEM(Vi,1,0) =  0.25*2.0;
+  DENSE_ELEM(Vi,1,1) =  0.25*2.0;
+  DENSE_ELEM(Vi,1,2) = -0.25*2.0;
+  DENSE_ELEM(Vi,2,0) =  0.25*1.0;
+  DENSE_ELEM(Vi,2,1) =  0.25*1.0;
+  DENSE_ELEM(Vi,2,2) =  0.25*1.0;
+
+  //    D = [-0.5 0 0; 0 -0.1 0; 0 0 lam]
+  DENSE_ELEM(D,0,0) = -0.5;
+  DENSE_ELEM(D,1,1) = -0.1;
+  DENSE_ELEM(D,2,2) = lam;
+
+  // Compute J = V*D*Vi
+  if (dense_MM(D,Vi,J) != 0) {     // J = D*Vi
+    cerr << "matmul error\n";
+    return 1;
+  }
+  if (dense_MM(V,J,D) != 0) {      // D = V*J [= V*D*Vi]
+    cerr << "matmul error\n";
+    return 1;
+  }
+  DenseCopy(D, J);                 // J = D [= V*D*Vi]
+
+  return 0;                        // Return with success
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+// DlsMat matrix-multiply utility routine: C = A*B.
+static int dense_MM(DlsMat A, DlsMat B, DlsMat C)
+{
+  // check for legal dimensions
+  if ((A->N != B->M) || (C->M != A->M) || (C->N != B->N)) {
+    cerr << "\n matmul error: dimension mismatch\n\n";
+    return 1;
+  }
+
+  realtype **adata = A->cols;     // access data and extents
+  realtype **bdata = B->cols;
+  realtype **cdata = C->cols;
+  long int m = C->M;
+  long int n = C->N;
+  long int l = A->N;
+  int i, j, k;
+  DenseScale(0.0, C);             // initialize output
+
+  // perform multiply (not optimal, but fine for 3x3 matrices)
+  for (i=0; i<m; i++)
+    for (j=0; j<n; j++)
+      for (k=0; k<l; k++)
+     cdata[i][j] += adata[i][k] * bdata[k][j];
+
+  return 0;                       // Return with success
+}
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const string funcname, int opt)
+{
+  int *errflag;
+
+  // Check if SUNDIALS function returned NULL pointer - no memory allocated
+  if (opt == 0 && flagvalue == NULL) {
+    cerr << "\nSUNDIALS_ERROR: " << funcname << " failed - returned NULL pointer\n\n";
+    return 1; }
+
+  // Check if flag < 0
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      cerr << "\nSUNDIALS_ERROR: " << funcname << " failed with flag = " << *errflag << "\n\n";
+      return 1; 
+    }
+  }
+  
+  // Check if function returned NULL pointer - no memory allocated
+  else if (opt == 2 && flagvalue == NULL) {
+    cerr << "\nMEMORY_ERROR: " << funcname << " failed - returned NULL pointer\n\n";
+    return 1; }
+
+  return 0;
+}
+
+
+
+//---- end of file ----
diff --git a/examples/arkode/CXX_serial/ark_analytic_sys.out b/examples/arkode/CXX_serial/ark_analytic_sys.out
new file mode 100644
index 0000000..858d646
--- /dev/null
+++ b/examples/arkode/CXX_serial/ark_analytic_sys.out
@@ -0,0 +1,30 @@
+
+Analytical ODE test problem:
+    lamda = -100
+   reltol = 1e-06
+   abstol = 1e-10
+
+      t        y0        y1        y2
+   --------------------------------------
+    0.0050   0.70327   0.70627   0.41004
+    0.0100   0.52267   0.52865   0.05231
+    0.0150   0.41249   0.42145  -0.16456
+    0.0200   0.34504   0.35696  -0.29600
+    0.0250   0.30349   0.31838  -0.37563
+    0.0300   0.27767   0.29551  -0.42383
+    0.0350   0.26138   0.28216  -0.45296
+    0.0400   0.25088   0.27459  -0.47053
+    0.0450   0.24389   0.27053  -0.48109
+    0.0500   0.23903   0.26858  -0.48740
+   --------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 91 (attempted = 93)
+   Total RHS evals:  Fe = 0,  Fi = 934
+   Total linear solver setups = 12
+   Total RHS evals for setting up the linear system = 0
+   Total number of Jacobian evaluations = 4
+   Total number of Newton iterations = 465
+   Total number of linear solver convergence failures = 0
+   Total number of error test failures = 2
+
diff --git a/examples/arkode/CXX_serial/plot_sol.py b/examples/arkode/CXX_serial/plot_sol.py
new file mode 100755
index 0000000..9a61de9
--- /dev/null
+++ b/examples/arkode/CXX_serial/plot_sol.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s):  Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for ODE examples
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load solution data file
+data = np.loadtxt('solution.txt', dtype=np.double)
+
+# determine number of time steps, number of fields
+nt,nv = np.shape(data)
+
+# extract time array
+times = data[:,0]
+
+# parse comment line to determine solution names
+f = open('solution.txt', 'r')
+commentline = f.readline()
+commentsplit = commentline.split()
+names = commentsplit[2:]
+
+# create plot
+plt.figure()
+
+# add curves to figure
+for i in range(nv-1):
+    plt.plot(times,data[:,i+1],label=names[i])
+plt.xlabel('t')
+if (nv > 2):
+    plt.ylabel('solutions')
+else:
+    plt.ylabel('solution')
+plt.legend(loc='upper right', shadow=True)
+plt.grid()
+plt.savefig('solution.png')
+
+
+
+
+##### end of script #####
diff --git a/examples/arkode/C_openmp/CMakeLists.txt b/examples/arkode/C_openmp/CMakeLists.txt
new file mode 100644
index 0000000..788f249
--- /dev/null
+++ b/examples/arkode/C_openmp/CMakeLists.txt
@@ -0,0 +1,133 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for ARKODE OpenMP examples
+
+# Only include tests if OpenMP is enabled
+IF(OPENMP_FOUND)
+
+# Add variable ARKode_examples_OMP with the names of the openmp ARKode examples
+SET(ARKODE_examples_OMP
+  ark_brusselator1D_omp
+  )
+
+# Add variable ARKODE_extras_OMP with the names of auxiliary files to install
+SET(ARKODE_extras_OMP
+  plot_brusselator1D.py
+  )
+
+ENDIF(OPENMP_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECOMP_LIB sundials_nvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECOMP_LIB sundials_nvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECOMP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# update the compilation flags to include OpenMP support
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+
+# Add the build and install targets for each ARKODE example
+FOREACH(example ${ARKODE_examples_OMP})
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} TEST_ARGS 4)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${ARKODE_examples_OMP})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_openmp)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras_OMP})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_openmp)
+  ENDFOREACH(extrafile ${ARKODE_extras_OMP})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  LIST2STRING(ARKODE_examples_OMP EXAMPLES)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_openmp 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/C_openmp/README b/examples/arkode/C_openmp/README
new file mode 100644
index 0000000..4b4d911
--- /dev/null
+++ b/examples/arkode/C_openmp/README
@@ -0,0 +1,55 @@
+List of OpenMP ARKODE C examples
+
+  ark_brusselator1D_omp : stiff chemical kinetics PDE system example (DIRK/BAND)
+
+Sample results:
+
+  SUNDIALS was built with OpenMP enabled, and the example output was run using 4 OpenMP threads:
+ 
+  BASH/SH:   export OMP_NUM_THREADS=4
+  TCSH/CSH:  setenv OMP_NUM_THREADS 4
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/C_openmp/ark_brusselator1D_omp.c b/examples/arkode/C_openmp/ark_brusselator1D_omp.c
new file mode 100644
index 0000000..cac3dea
--- /dev/null
+++ b/examples/arkode/C_openmp/ark_brusselator1D_omp.c
@@ -0,0 +1,514 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a brusselator problem from chemical 
+ * kinetics.  This is n PDE system with 3 components, Y = [u,v,w], 
+ * satisfying the equations,
+ *    u_t = du*u_xx + a - (w+1)*u + v*u^2
+ *    v_t = dv*v_xx + w*u - v*u^2
+ *    w_t = dw*w_xx + (b-w)/ep - w*u
+ * for t in [0, 80], x in [0, 1], with initial conditions
+ *    u(0,x) =  a  + 0.1*sin(pi*x)
+ *    v(0,x) = b/a + 0.1*sin(pi*x)
+ *    w(0,x) =  b  + 0.1*sin(pi*x),
+ * and with stationary boundary conditions, i.e. 
+ *    u_t(t,0) = u_t(t,1) = 0,
+ *    v_t(t,0) = v_t(t,1) = 0,
+ *    w_t(t,0) = w_t(t,1) = 0.
+ * Note: these can also be implemented as Dirichlet boundary 
+ * conditions with values identical to the initial conditions.
+ * 
+ * The spatial derivatives are computed using second-order 
+ * centered differences, with the data distributed over N points 
+ * on a uniform spatial grid.
+ *
+ * This program solves the problem with the DIRK method, using a
+ * Newton iteration with the ARKBAND band linear solver, and a
+ * user-supplied Jacobian routine.  This example uses the OpenMP 
+ * vector kernel, and employs OpenMP threading within the 
+ * right-hand side and Jacobian construction functions.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_openmp.h>   /* OpenMP N_Vector types, fcts., macros */
+#include <arkode/arkode_band.h>       /* prototype for ARKBand solver */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+#include <sundials/sundials_math.h>   /* def. of SUNRsqrt, etc. */
+#ifdef _OPENMP
+#include <omp.h>                      /* OpenMP functions */
+#endif
+
+/* accessor macros between (x,v) location and 1D NVector array */
+#define IDX(x,v) (3*(x)+v)
+
+/* user data structure */
+typedef struct {  
+  long int N;    /* number of intervals      */
+  int nthreads;  /* number of OpenMP threads */
+  realtype dx;   /* mesh spacing             */
+  realtype a;    /* constant forcing on u    */
+  realtype b;    /* steady-state value of w  */
+  realtype du;   /* diffusion coeff for u    */
+  realtype dv;   /* diffusion coeff for v    */
+  realtype dw;   /* diffusion coeff for w    */
+  realtype ep;   /* stiffness parameter      */
+} *UserData;
+
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(long int N, long int mu, long int ml,
+               realtype t, N_Vector y, N_Vector fy, 
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private helper functions  */
+static int LaplaceMatrix(realtype c, DlsMat Jac, UserData udata);
+static int ReactionJac(realtype c, N_Vector y, DlsMat Jac, UserData udata);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main(int argc, char *argv[])
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);    /* initial time */
+  realtype Tf = RCONST(10.0);   /* final time */
+  int Nt = 100;                 /* total number of output times */
+  int Nvar = 3;                 /* number of solution fields */
+  UserData udata = NULL;
+  realtype *data;
+  long int N = 201;             /* spatial mesh size */
+  realtype a = 0.6;             /* problem parameters */
+  realtype b = 2.0;
+  realtype du = 0.025;
+  realtype dv = 0.025;
+  realtype dw = 0.025;
+  realtype ep = 1.0e-5;         /* stiffness parameter */
+  realtype reltol = 1.0e-6;     /* tolerances */
+  realtype abstol = 1.0e-10;
+  long int NEQ, i;
+
+  /* general problem variables */
+  int flag;                     /* reusable error-checking flag */
+  N_Vector y = NULL;            /* empty vector for storing solution */
+  N_Vector umask = NULL;        /* empty mask vectors for viewing solution components */
+  N_Vector vmask = NULL;
+  N_Vector wmask = NULL;
+  void *arkode_mem = NULL;      /* empty ARKode memory structure */
+  realtype pi, t, dTout, tout, u, v, w;
+  FILE *FID, *UFID, *VFID, *WFID;
+  int iout, num_threads;
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nfeLS, nni, ncfn, netf;
+
+  /* allocate udata structure */
+  udata = (UserData) malloc(sizeof(*udata));
+  if (check_flag((void *) udata, "malloc", 2)) return 1;
+
+  /* set the number of threads to use */
+  num_threads = 1; /* default value */
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();   /* overwrite with OMP_NUM_THREADS environment variable */
+#endif
+  if (argc > 1)   /* overwrite with command line value, if supplied */
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* store the inputs in the UserData structure */
+  udata->N  = N;
+  udata->a  = a;
+  udata->b  = b;
+  udata->du = du;
+  udata->dv = dv;
+  udata->dw = dw;
+  udata->ep = ep;
+  udata->nthreads = num_threads;
+
+  /* set total allocated vector length */
+  NEQ = Nvar*udata->N;
+
+  /* Initial problem output */
+  printf("\n1D Brusselator PDE test problem:\n");
+  printf("    N = %li,  NEQ = %li\n", udata->N, NEQ);
+  printf("    num_threads = %i\n", num_threads);
+  printf("    problem parameters:  a = %g,  b = %g,  ep = %g\n",
+	 udata->a, udata->b, udata->ep);
+  printf("    diffusion coefficients:  du = %g,  dv = %g,  dw = %g\n", 
+	 udata->du, udata->dv, udata->dw);
+  printf("    reltol = %.1e,  abstol = %.1e\n\n", reltol, abstol);
+
+  /* Initialize data structures */
+  y = N_VNew_OpenMP(NEQ, num_threads);      /* Create vector for solution */
+  if (check_flag((void *)y, "N_VNew_OpenMP", 0)) return 1;
+  udata->dx = RCONST(1.0)/(N-1);            /* set spatial mesh spacing */
+  data = N_VGetArrayPointer(y);             /* Access data array for new NVector y */
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  umask = N_VNew_OpenMP(NEQ, num_threads);  /* Create vector masks */
+  if (check_flag((void *)umask, "N_VNew_OpenMP", 0)) return 1;
+  vmask = N_VNew_OpenMP(NEQ, num_threads);
+  if (check_flag((void *)vmask, "N_VNew_OpenMP", 0)) return 1;
+  wmask = N_VNew_OpenMP(NEQ, num_threads);
+  if (check_flag((void *)wmask, "N_VNew_OpenMP", 0)) return 1;
+
+  /* Set initial conditions into y */
+  pi = RCONST(4.0)*atan(RCONST(1.0));
+  for (i=0; i<N; i++) {
+    data[IDX(i,0)] =  a  + RCONST(0.1)*sin(pi*i*udata->dx);  /* u */
+    data[IDX(i,1)] = b/a + RCONST(0.1)*sin(pi*i*udata->dx);  /* v */
+    data[IDX(i,2)] =  b  + RCONST(0.1)*sin(pi*i*udata->dx);  /* w */
+  }
+
+  /* Set mask array values for each solution component */
+  N_VConst(0.0, umask);
+  data = N_VGetArrayPointer(umask);
+  if (check_flag((void *) data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,0)] = RCONST(1.0);
+
+  N_VConst(0.0, vmask);
+  data = N_VGetArrayPointer(vmask);
+  if (check_flag((void *) data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,1)] = RCONST(1.0);
+
+  N_VConst(0.0, wmask);
+  data = N_VGetArrayPointer(wmask);
+  if (check_flag((void *) data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,2)] = RCONST(1.0);
+
+  /* Create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) udata);     /* Pass udata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);    /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKBand(arkode_mem, NEQ, 4, 4);          /* Specify the band linear solver */
+  if (check_flag(&flag, "ARKBand", 1)) return 1;
+  flag = ARKDlsSetBandJacFn(arkode_mem, Jac);     /* Set the Jacobian routine */
+  if (check_flag(&flag, "ARKDlsSetBandJacFn", 1)) return 1;
+
+  /* output spatial mesh to disk */
+  FID=fopen("bruss_mesh.txt","w");
+  for (i=0; i<N; i++)  fprintf(FID,"  %.16e\n", udata->dx*i);
+  fclose(FID);
+  
+  /* Open output stream for results, access data arrays */
+  UFID=fopen("bruss_u.txt","w");
+  VFID=fopen("bruss_v.txt","w");
+  WFID=fopen("bruss_w.txt","w");
+
+  /* output initial condition to disk */
+  data = N_VGetArrayPointer(y);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+  for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+  for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+  fprintf(UFID,"\n");
+  fprintf(VFID,"\n");
+  fprintf(WFID,"\n");
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  dTout = (Tf-T0)/Nt;
+  tout = T0+dTout;
+  printf("        t      ||u||_rms   ||v||_rms   ||w||_rms\n");
+  printf("   ----------------------------------------------\n");
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);    /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    u = N_VWL2Norm(y,umask);                               /* access/print solution statistics */
+    u = SUNRsqrt(u*u/N);
+    v = N_VWL2Norm(y,vmask);
+    v = SUNRsqrt(v*v/N);
+    w = N_VWL2Norm(y,wmask);
+    w = SUNRsqrt(w*w/N);
+    printf("  %10.6f  %10.6f  %10.6f  %10.6f\n", t, u, v, w);
+    if (flag >= 0) {                                       /* successful solve: update output time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                               /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+
+    /* output results to disk */
+    for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+    for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+    for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+    fprintf(UFID,"\n");
+    fprintf(VFID,"\n");
+    fprintf(WFID,"\n");
+  }
+  printf("   ----------------------------------------------\n");
+  fclose(UFID);
+  fclose(VFID);
+  fclose(WFID);
+    
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKDlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKDlsGetNumJacEvals", 1);
+  flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total RHS evals for setting up the linear system = %li\n", nfeLS);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_OpenMP(y);         /* Free vectors */
+  N_VDestroy_OpenMP(umask);
+  N_VDestroy_OpenMP(vmask);
+  N_VDestroy_OpenMP(wmask);
+  free(udata);                  /* Free user data */
+  ARKodeFree(&arkode_mem);      /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  UserData udata = (UserData) user_data;      /* access problem data */
+  long int N  = udata->N;                     /* set variable shortcuts */
+  realtype a  = udata->a;
+  realtype b  = udata->b;
+  realtype ep = udata->ep;
+  realtype du = udata->du;
+  realtype dv = udata->dv;
+  realtype dw = udata->dw;
+  realtype dx = udata->dx;
+  realtype *Ydata=NULL, *dYdata=NULL;
+  realtype uconst, vconst, wconst, u, ul, ur, v, vl, vr, w, wl, wr;
+  long int i;
+
+  /* clear out ydot (to be careful) */
+  N_VConst(0.0, ydot);
+
+  Ydata = N_VGetArrayPointer(y);     /* access data arrays */
+  if (check_flag((void *)Ydata, "N_VGetArrayPointer", 0)) return 1;
+  dYdata = N_VGetArrayPointer(ydot);
+  if (check_flag((void *)dYdata, "N_VGetArrayPointer", 0)) return 1;
+  N_VConst(0.0, ydot);                        /* initialize ydot to zero */
+
+  /* iterate over domain, computing all equations */
+  uconst = du/dx/dx;
+  vconst = dv/dx/dx;
+  wconst = dw/dx/dx;
+#pragma omp parallel for default(shared) private(i,u,ul,ur,v,vl,vr,w,wl,wr) schedule(static) num_threads(udata->nthreads)
+  for (i=1; i<N-1; i++) {
+
+    /* set shortcuts */
+    u = Ydata[IDX(i,0)];  ul = Ydata[IDX(i-1,0)];  ur = Ydata[IDX(i+1,0)];
+    v = Ydata[IDX(i,1)];  vl = Ydata[IDX(i-1,1)];  vr = Ydata[IDX(i+1,1)];
+    w = Ydata[IDX(i,2)];  wl = Ydata[IDX(i-1,2)];  wr = Ydata[IDX(i+1,2)];
+
+    /* u_t = du*u_xx + a - (w+1)*u + v*u^2 */
+    dYdata[IDX(i,0)] = (ul - RCONST(2.0)*u + ur)*uconst + a - (w+RCONST(1.0))*u + v*u*u;
+
+    /* v_t = dv*v_xx + w*u - v*u^2 */
+    dYdata[IDX(i,1)] = (vl - RCONST(2.0)*v + vr)*vconst + w*u - v*u*u;
+
+    /* w_t = dw*w_xx + (b-w)/ep - w*u */
+    dYdata[IDX(i,2)] = (wl - RCONST(2.0)*w + wr)*wconst + (b-w)/ep - w*u;
+
+  }
+
+  /* enforce stationary boundaries */
+  dYdata[IDX(0,0)]   = dYdata[IDX(0,1)]   = dYdata[IDX(0,2)]   = 0.0;
+  dYdata[IDX(N-1,0)] = dYdata[IDX(N-1,1)] = dYdata[IDX(N-1,2)] = 0.0;
+
+  return 0;
+}
+
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(long int M, long int mu, long int ml,
+               realtype t, N_Vector y, N_Vector fy, 
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  UserData udata = (UserData) user_data;     /* access problem data */
+  SetToZero(J);                              /* Initialize Jacobian to zero */
+
+  /* Fill in the Laplace matrix */
+  if (LaplaceMatrix(RCONST(1.0), J, udata)) {
+    printf("Jacobian calculation error in calling LaplaceMatrix!\n");
+    return 1;
+  }
+
+  /* Add in the Jacobian of the reaction terms matrix */
+  if (ReactionJac(RCONST(1.0), y, J, udata)) {
+    printf("Jacobian calculation error in calling ReactionJac!\n");
+    return 1;
+  }
+
+  return 0;
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Routine to compute the stiffness matrix from (L*y), scaled by the factor c.
+   We add the result into Jac and do not erase what was already there */
+static int LaplaceMatrix(realtype c, DlsMat Jac, UserData udata)
+{
+  long int i;                /* set shortcuts */
+  long int N = udata->N;
+  realtype dx = udata->dx;
+  
+  /* iterate over intervals, filling in Jacobian entries */
+#pragma omp parallel for default(shared) private(i) schedule(static) num_threads(udata->nthreads)
+  for (i=1; i<N-1; i++) {
+
+    /* Jacobian of (L*y) at this node */
+    BAND_ELEM(Jac,IDX(i,0),IDX(i-1,0)) += c*udata->du/dx/dx;
+    BAND_ELEM(Jac,IDX(i,1),IDX(i-1,1)) += c*udata->dv/dx/dx;
+    BAND_ELEM(Jac,IDX(i,2),IDX(i-1,2)) += c*udata->dw/dx/dx;
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,0)) += -c*RCONST(2.0)*udata->du/dx/dx;
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,1)) += -c*RCONST(2.0)*udata->dv/dx/dx;
+    BAND_ELEM(Jac,IDX(i,2),IDX(i,2)) += -c*RCONST(2.0)*udata->dw/dx/dx;
+    BAND_ELEM(Jac,IDX(i,0),IDX(i+1,0)) += c*udata->du/dx/dx;
+    BAND_ELEM(Jac,IDX(i,1),IDX(i+1,1)) += c*udata->dv/dx/dx;
+    BAND_ELEM(Jac,IDX(i,2),IDX(i+1,2)) += c*udata->dw/dx/dx;
+  }
+
+  return 0;
+}
+
+
+
+/* Routine to compute the Jacobian matrix from R(y), scaled by the factor c.
+   We add the result into Jac and do not erase what was already there */
+static int ReactionJac(realtype c, N_Vector y, DlsMat Jac, UserData udata)
+{
+  long int N  = udata->N;                      /* set shortcuts */
+  long int i;
+  realtype u, v, w;
+  realtype ep = udata->ep;
+  realtype *Ydata = N_VGetArrayPointer(y);     /* access solution array */
+  if (check_flag((void *)Ydata, "N_VGetArrayPointer", 0)) return 1;
+  
+  /* iterate over nodes, filling in Jacobian entries */
+#pragma omp parallel for default(shared) private(i,u,v,w) schedule(static) num_threads(udata->nthreads)
+  for (i=1; i<N-1; i++) {
+
+    /* set nodal value shortcuts (shifted index due to start at first interior node) */
+    u = Ydata[IDX(i,0)];
+    v = Ydata[IDX(i,1)];
+    w = Ydata[IDX(i,2)];
+
+    /* all vars wrt u */
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,0)) += c*(RCONST(2.0)*u*v-(w+RCONST(1.0)));
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,0)) += c*(w - RCONST(2.0)*u*v);
+    BAND_ELEM(Jac,IDX(i,2),IDX(i,0)) += c*(-w);
+
+    /* all vars wrt v */
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,1)) += c*(u*u);
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,1)) += c*(-u*u);
+
+    /* all vars wrt w */
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,2)) += c*(-u);
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,2)) += c*(u);
+    BAND_ELEM(Jac,IDX(i,2),IDX(i,2)) += c*(-RCONST(1.0)/ep - u);
+
+  }
+
+  return 0;
+}
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_openmp/ark_brusselator1D_omp.out b/examples/arkode/C_openmp/ark_brusselator1D_omp.out
new file mode 100644
index 0000000..1213d4d
--- /dev/null
+++ b/examples/arkode/C_openmp/ark_brusselator1D_omp.out
@@ -0,0 +1,122 @@
+
+1D Brusselator PDE test problem:
+    N = 201,  NEQ = 603
+    num_threads = 4
+    problem parameters:  a = 0.6,  b = 2,  ep = 1e-05
+    diffusion coefficients:  du = 0.025,  dv = 0.025,  dw = 0.025
+    reltol = 1.0e-06,  abstol = 1.0e-10
+
+        t      ||u||_rms   ||v||_rms   ||w||_rms
+   ----------------------------------------------
+    0.100000    0.673914    3.377329    1.999987
+    0.200000    0.684316    3.356619    1.999987
+    0.300000    0.695306    3.334633    1.999986
+    0.400000    0.706918    3.311313    1.999986
+    0.500000    0.719185    3.286601    1.999986
+    0.600000    0.732137    3.260442    1.999986
+    0.700000    0.745798    3.232787    1.999985
+    0.800000    0.760185    3.203596    1.999985
+    0.900000    0.775303    3.172839    1.999985
+    1.000000    0.791135    3.140510    1.999984
+    1.100000    0.807648    3.106624    1.999984
+    1.200000    0.824771    3.071233    1.999984
+    1.300000    0.842402    3.034426    1.999983
+    1.400000    0.860384    2.996350    1.999983
+    1.500000    0.878514    2.957206    1.999983
+    1.600000    0.896525    2.917266    1.999982
+    1.700000    0.914089    2.876873    1.999982
+    1.800000    0.930823    2.836438    1.999982
+    1.900000    0.946292    2.796446    1.999982
+    2.000000    0.960033    2.757430    1.999981
+    2.100000    0.971576    2.719962    1.999981
+    2.200000    0.980475    2.684623    1.999981
+    2.300000    0.986338    2.651980    1.999981
+    2.400000    0.988852    2.622560    1.999981
+    2.500000    0.987815    2.596818    1.999981
+    2.600000    0.983141    2.575128    1.999981
+    2.700000    0.974858    2.557766    1.999981
+    2.800000    0.963114    2.544903    1.999981
+    2.900000    0.948154    2.536611    1.999981
+    3.000000    0.930299    2.532868    1.999982
+    3.100000    0.909930    2.533567    1.999982
+    3.200000    0.887464    2.538529    1.999983
+    3.300000    0.863335    2.547515    1.999983
+    3.400000    0.837978    2.560241    1.999983
+    3.500000    0.811818    2.576391    1.999984
+    3.600000    0.785255    2.595624    1.999984
+    3.700000    0.758659    2.617587    1.999985
+    3.800000    0.732363    2.641922    1.999986
+    3.900000    0.706662    2.668274    1.999986
+    4.000000    0.681809    2.696300    1.999986
+    4.100000    0.658012    2.725670    1.999987
+    4.200000    0.635435    2.756075    1.999987
+    4.300000    0.614205    2.787228    1.999988
+    4.400000    0.594404    2.818869    1.999988
+    4.500000    0.576082    2.850764    1.999989
+    4.600000    0.559255    2.882710    1.999989
+    4.700000    0.543909    2.914529    1.999989
+    4.800000    0.530011    2.946071    1.999990
+    4.900000    0.517506    2.977209    1.999990
+    5.000000    0.506326    3.007843    1.999990
+    5.100000    0.496394    3.037889    1.999990
+    5.200000    0.487626    3.067283    1.999990
+    5.300000    0.479935    3.095976    1.999991
+    5.400000    0.473237    3.123932    1.999991
+    5.500000    0.467445    3.151125    1.999991
+    5.600000    0.462480    3.177540    1.999991
+    5.700000    0.458264    3.203165    1.999991
+    5.800000    0.454726    3.227997    1.999991
+    5.900000    0.451800    3.252035    1.999991
+    6.000000    0.449425    3.275283    1.999991
+    6.100000    0.447546    3.297744    1.999991
+    6.200000    0.446115    3.319428    1.999991
+    6.300000    0.445086    3.340340    1.999991
+    6.400000    0.444419    3.360491    1.999991
+    6.500000    0.444079    3.379890    1.999991
+    6.600000    0.444034    3.398547    1.999991
+    6.700000    0.444257    3.416470    1.999991
+    6.800000    0.444722    3.433669    1.999991
+    6.900000    0.445409    3.450154    1.999991
+    7.000000    0.446297    3.465934    1.999991
+    7.100000    0.447370    3.481018    1.999991
+    7.200000    0.448614    3.495414    1.999991
+    7.300000    0.450016    3.509131    1.999991
+    7.400000    0.451564    3.522176    1.999991
+    7.500000    0.453249    3.534557    1.999991
+    7.600000    0.455064    3.546280    1.999991
+    7.700000    0.457000    3.557353    1.999991
+    7.800000    0.459052    3.567781    1.999991
+    7.900000    0.461216    3.577571    1.999991
+    8.000000    0.463486    3.586728    1.999991
+    8.100000    0.465860    3.595257    1.999991
+    8.200000    0.468335    3.603162    1.999991
+    8.300000    0.470909    3.610447    1.999991
+    8.400000    0.473582    3.617116    1.999991
+    8.500000    0.476352    3.623171    1.999991
+    8.600000    0.479220    3.628616    1.999991
+    8.700000    0.482186    3.633451    1.999991
+    8.800000    0.485250    3.637679    1.999990
+    8.900000    0.488416    3.641299    1.999990
+    9.000000    0.491684    3.644311    1.999990
+    9.100000    0.495058    3.646715    1.999990
+    9.200000    0.498540    3.648509    1.999990
+    9.300000    0.502134    3.649691    1.999990
+    9.400000    0.505844    3.650257    1.999990
+    9.500000    0.509675    3.650202    1.999990
+    9.600000    0.513632    3.649521    1.999990
+    9.700000    0.517722    3.648209    1.999990
+    9.800000    0.521951    3.646257    1.999990
+    9.900000    0.526326    3.643656    1.999990
+   10.000000    0.530857    3.640396    1.999990
+   ----------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 99 (attempted = 99)
+   Total RHS evals:  Fe = 0,  Fi = 1695
+   Total linear solver setups = 35
+   Total RHS evals for setting up the linear system = 0
+   Total number of Jacobian evaluations = 14
+   Total number of Newton iterations = 1196
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 0
+
diff --git a/examples/arkode/C_openmp/plot_brusselator1D.py b/examples/arkode/C_openmp/plot_brusselator1D.py
new file mode 100755
index 0000000..bf65e8e
--- /dev/null
+++ b/examples/arkode/C_openmp/plot_brusselator1D.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for brusselator1D.c example
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load mesh data file
+mesh = np.loadtxt('bruss_mesh.txt', dtype=np.double)
+
+# load solution data files
+udata = np.loadtxt('bruss_u.txt', dtype=np.double)
+vdata = np.loadtxt('bruss_v.txt', dtype=np.double)
+wdata = np.loadtxt('bruss_w.txt', dtype=np.double)
+
+# determine number of time steps, mesh size
+nt,nx = np.shape(udata)
+
+# determine min/max values
+umin = 0.9*udata.min()
+umax = 1.1*udata.max()
+vmin = 0.9*vdata.min()
+vmax = 1.1*vdata.max()
+wmin = 0.9*wdata.min()
+wmax = 1.1*wdata.max()
+minval = np.array([umin, vmin, wmin]).min()
+maxval = np.array([umax, vmax, wmax]).max()
+
+# generate plots of results
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'brusselator1D.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(nx)
+
+    # plot current solution and save to disk
+    plt.figure(1)
+    plt.plot(mesh,udata[tstep,:],label="u")
+    plt.plot(mesh,vdata[tstep,:],label="v")
+    plt.plot(mesh,wdata[tstep,:],label="w")
+    plt.xlabel('x')
+    plt.ylabel('solution')
+    plt.title('Solutions at output ' + tstr + ', mesh = ' + nxstr)
+    plt.axis((0.0, 1.0, minval, maxval))
+    plt.grid()
+    plt.legend(loc='upper right', shadow=True)
+    plt.savefig(pname)
+    plt.close()
+
+
+##### end of script #####
diff --git a/examples/arkode/C_parallel/CMakeLists.txt b/examples/arkode/C_parallel/CMakeLists.txt
new file mode 100644
index 0000000..6d866f4
--- /dev/null
+++ b/examples/arkode/C_parallel/CMakeLists.txt
@@ -0,0 +1,144 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for ARKODE parallel C examples
+
+
+# Add variable ARKODE_examples with the names of the parallel ARKODE examples
+# "name\;nodes\;tasks"
+SET(ARKODE_examples
+  "ark_diurnal_kry_p\;1\;4"
+  "ark_diurnal_kry_bbd_p\;1\;4"
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+SET(ARKODE_extras
+  # none yet
+  )
+
+# Check whether we use MPI compiler scripts.
+# If yes, then change the C compiler to the MPICC script.
+# If not, then add the MPI include directory for MPI headers.
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICC)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECP_LIB sundials_nvecparallel_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECP_LIB sundials_nvecparallel_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each ARKODE example
+FOREACH(example_tuple ${ARKODE_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(NOT MPI_MPICC)
+    TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
+  ENDIF(NOT MPI_MPICC)
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parallel)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example_tuple ${ARKODE_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parallel)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parallel)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  FOREACH(example_tuple ${ARKODE_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${ARKODE_examples})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_parallel/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_parallel/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parallel 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_parallel/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_parallel/Makefile_ex
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parallel
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/C_parallel/README b/examples/arkode/C_parallel/README
new file mode 100644
index 0000000..ea16e11
--- /dev/null
+++ b/examples/arkode/C_parallel/README
@@ -0,0 +1,52 @@
+List of parallel ARKODE C examples
+
+  ark_diurnal_kry_bbd_p : 2-D 2-species diurnal advection-diffusion with BBD preconditioner
+  ark_diurnal_kry_p     : 2-D 2-species diurnal advection-diffusion
+
+Sample results:
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c
new file mode 100644
index 0000000..04f22db
--- /dev/null
+++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c
@@ -0,0 +1,843 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ *
+ * An ODE system is generated from the following 2-species diurnal
+ * kinetics advection-diffusion PDE system in 2 space dimensions:
+ *
+ * dc(i)/dt = Kh*(d/dx)^2 c(i) + V*dc(i)/dx + (d/dy)(Kv(y)*dc(i)/dy)
+ *                 + Ri(c1,c2,t)      for i = 1,2,   where
+ *   R1(c1,c2,t) = -q1*c1*c3 - q2*c1*c2 + 2*q3(t)*c3 + q4(t)*c2 ,
+ *   R2(c1,c2,t) =  q1*c1*c3 - q2*c1*c2 - q4(t)*c2 ,
+ *   Kv(y) = Kv0*exp(y/5) ,
+ * Kh, V, Kv0, q1, q2, and c3 are constants, and q3(t) and q4(t)
+ * vary diurnally. The problem is posed on the square
+ *   0 <= x <= 20,    30 <= y <= 50   (all in km),
+ * with homogeneous Neumann boundary conditions, and for time t in
+ *   0 <= t <= 86400 sec (1 day).
+ * The PDE system is treated by central differences on a uniform
+ * mesh, with simple polynomial initial profiles.
+ *
+ * The problem is solved by ARKODE on NPE processors, treated
+ * as a rectangular process grid of size NPEX by NPEY, with
+ * NPE = NPEX*NPEY. Each processor contains a subgrid of size MXSUB
+ * by MYSUB of the (x,y) mesh. Thus the actual mesh sizes are
+ * MX = MXSUB*NPEX and MY = MYSUB*NPEY, and the ODE system size is
+ * neq = 2*MX*MY.
+ *
+ * The solution is done with the DIRK/GMRES method (i.e. using the
+ * ARKSPGMR linear solver) and a block-diagonal matrix with banded
+ * blocks as a preconditioner, using the ARKBBDPRE module.
+ * Each block is generated using difference quotients, with
+ * half-bandwidths mudq = mldq = 2*MXSUB, but the retained banded
+ * blocks have half-bandwidths mukeep = mlkeep = 2.
+ * A copy of the approximate Jacobian is saved and conditionally
+ * reused within the preconditioner routine.
+ *
+ * The problem is solved twice -- with left and right preconditioning.
+ *
+ * Performance data and sampled solution values are printed at
+ * selected output times, and all performance counters are printed
+ * on completion.
+ *
+ * This version uses MPI for user routines.
+ * Execute with number of processors = NPEX*NPEY (see constants below).
+ *------------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKODE fcts. */
+#include <arkode/arkode_spgmr.h>      /* prototypes and constants for ARKSPGMR */
+#include <arkode/arkode_bbdpre.h>     /* prototypes for ARKBBDPRE module */
+#include <nvector/nvector_parallel.h> /* def. of N_Vector, macro NV_DATA_P */
+#include <sundials/sundials_types.h>  /* definitions of realtype, booleantype */
+#include <sundials/sundials_math.h>   /* definition of macros SUNSQR and EXP */
+#include <mpi.h>                      /* MPI constants and types */
+
+
+/* Problem Constants */
+#define ZERO         RCONST(0.0)
+#define NVARS        2                 /* number of species         */
+#define KH           RCONST(4.0e-6)    /* horizontal diffusivity Kh */
+#define VEL          RCONST(0.001)     /* advection velocity V      */
+#define KV0          RCONST(1.0e-8)    /* coefficient in Kv(y)      */
+#define Q1           RCONST(1.63e-16)  /* coefficients q1, q2, c3   */ 
+#define Q2           RCONST(4.66e-16)
+#define C3           RCONST(3.7e16)
+#define A3           RCONST(22.62)     /* coefficient in expression for q3(t) */
+#define A4           RCONST(7.601)     /* coefficient in expression for q4(t) */
+#define C1_SCALE     RCONST(1.0e6)     /* coefficients in initial profiles    */
+#define C2_SCALE     RCONST(1.0e12)
+
+#define T0           ZERO                /* initial time */
+#define NOUT         12                  /* number of output times */
+#define TWOHR        RCONST(7200.0)      /* number of seconds in two hours  */
+#define HALFDAY      RCONST(4.32e4)      /* number of seconds in a half day */
+#define PI       RCONST(3.1415926535898) /* pi */ 
+
+#define XMIN         ZERO                /* grid boundaries in x  */
+#define XMAX         RCONST(20.0)
+#define YMIN         RCONST(30.0)        /* grid boundaries in y  */
+#define YMAX         RCONST(50.0)
+
+#define NPEX         2              /* no. PEs in x direction of PE array */
+#define NPEY         2              /* no. PEs in y direction of PE array */
+                                    /* Total no. PEs = NPEX*NPEY */
+#define MXSUB        5              /* no. x points per subgrid */
+#define MYSUB        5              /* no. y points per subgrid */
+
+#define MX           (NPEX*MXSUB)   /* MX = number of x mesh points */
+#define MY           (NPEY*MYSUB)   /* MY = number of y mesh points */
+                                    /* Spatial mesh is MX by MY */
+/* ARKodeInit Constants */
+#define RTOL    RCONST(1.0e-5)    /* scalar relative tolerance */
+#define FLOOR   RCONST(100.0)     /* value of C1 or C2 at which tolerances */
+                                  /* change from relative to absolute      */
+#define ATOL    (RTOL*FLOOR)      /* scalar absolute tolerance */
+
+/* Type : UserData 
+   contains problem constants, extended dependent variable array,
+   grid constants, processor indices, MPI communicator */
+typedef struct {
+  realtype q4, om, dx, dy, hdco, haco, vdco;
+  realtype uext[NVARS*(MXSUB+2)*(MYSUB+2)];
+  int my_pe, isubx, isuby;
+  long int nvmxsub, nvmxsub2, Nlocal;
+  MPI_Comm comm;
+} *UserData;
+
+/* Prototypes of private helper functions */
+static void InitUserData(int my_pe, long int local_N, MPI_Comm comm,
+                         UserData data);
+static void SetInitialProfiles(N_Vector u, UserData data);
+static void PrintIntro(int npes, long int mudq, long int mldq,
+		       long int mukeep, long int mlkeep);
+static void PrintOutput(void *arkode_mem, int my_pe, MPI_Comm comm,
+                        N_Vector u, realtype t);
+static void PrintFinalStats(void *arkode_mem);
+static void BSend(MPI_Comm comm, 
+                  int my_pe, int isubx, int isuby, 
+                  long int dsizex, long int dsizey,
+                  realtype uarray[]);
+static void BRecvPost(MPI_Comm comm, MPI_Request request[], 
+                      int my_pe, int isubx, int isuby,
+		      long int dsizex, long int dsizey,
+		      realtype uext[], realtype buffer[]);
+static void BRecvWait(MPI_Request request[], 
+                      int isubx, int isuby, 
+                      long int dsizex, realtype uext[],
+                      realtype buffer[]);
+static void fucomm(realtype t, N_Vector u, void *user_data);
+
+/* Prototype of function called by the solver */
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
+
+/* Prototype of functions called by the ARKBBDPRE module */
+static int flocal(long int Nlocal, realtype t, N_Vector u,
+                  N_Vector udot, void *user_data);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
+
+
+/***************************** Main Program ******************************/
+int main(int argc, char *argv[])
+{
+  UserData data;
+  void *arkode_mem;
+  realtype abstol, reltol, t, tout;
+  N_Vector u;
+  int iout, my_pe, npes, flag, jpre;
+  long int neq, local_N, mudq, mldq, mukeep, mlkeep;
+  MPI_Comm comm;
+
+  data = NULL;
+  arkode_mem = NULL;
+  u = NULL;
+
+  /* Set problem size neq */
+  neq = NVARS*MX*MY;
+
+  /* Get processor number and total number of pe's */
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &npes);
+  MPI_Comm_rank(comm, &my_pe);
+
+  if (npes != NPEX*NPEY) {
+    if (my_pe == 0)
+      fprintf(stderr, "\nMPI_ERROR(0): npes = %d is not equal to NPEX*NPEY = %d\n\n",
+              npes, NPEX*NPEY);
+    MPI_Finalize();
+    return(1);
+  }
+
+  /* Set local length */
+  local_N = NVARS*MXSUB*MYSUB;
+
+  /* Allocate and load user data block */
+  data = (UserData) malloc(sizeof *data);
+  if(check_flag((void *)data, "malloc", 2, my_pe)) MPI_Abort(comm, 1);
+  InitUserData(my_pe, local_N, comm, data);
+
+  /* Allocate and initialize u, and set tolerances */ 
+  u = N_VNew_Parallel(comm, local_N, neq);
+  if(check_flag((void *)u, "N_VNew_Parallel", 0, my_pe)) MPI_Abort(comm, 1);
+  SetInitialProfiles(u, data);
+  abstol = ATOL;
+  reltol = RTOL;
+
+  /* Call ARKodeCreate to create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if(check_flag((void *)arkode_mem, "ARKodeCreate", 0, my_pe)) MPI_Abort(comm, 1);
+
+  /* Set the pointer to user-defined data */
+  flag = ARKodeSetUserData(arkode_mem, data);
+  if(check_flag(&flag, "ARKodeSetUserData", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     user's right hand side functions in u'=fe(t,u)+fi(t,u) [here fe is NULL], 
+     the inital time T0, and the initial dependent variable vector u. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, u);
+  if(check_flag(&flag, "ARKodeInit", 1, my_pe)) return(1);
+
+  /* Call ARKodeSetMaxNumSteps to increase default */
+  flag = ARKodeSetMaxNumSteps(arkode_mem, 10000);
+  if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1, my_pe)) return(1);
+
+  /* Call ARKodeSStolerances to specify the scalar relative tolerance
+     and scalar absolute tolerances */
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);
+  if (check_flag(&flag, "ARKodeSStolerances", 1, my_pe)) return(1);
+
+  /* Call ARKSpgmr to specify the linear solver ARKSPGMR with left
+     preconditioning and the default Krylov dimension maxl */
+  flag = ARKSpgmr(arkode_mem, PREC_LEFT, 0);
+  if(check_flag(&flag, "ARKBBDSpgmr", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Initialize BBD preconditioner */
+  mudq = mldq = NVARS*MXSUB;
+  mukeep = mlkeep = NVARS;
+  flag = ARKBBDPrecInit(arkode_mem, local_N, mudq, mldq, 
+			mukeep, mlkeep, ZERO, flocal, NULL);
+  if(check_flag(&flag, "ARKBBDPrecAlloc", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Print heading */
+  if (my_pe == 0) PrintIntro(npes, mudq, mldq, mukeep, mlkeep);
+
+  /* Loop over jpre (= PREC_LEFT, PREC_RIGHT), and solve the problem */
+  for (jpre=PREC_LEFT; jpre<=PREC_RIGHT; jpre++) {
+
+    /* On second run, re-initialize u, the integrator, ARKBBDPRE, and ARKSPGMR */
+    if (jpre == PREC_RIGHT) {
+
+      SetInitialProfiles(u, data);
+
+      flag = ARKodeReInit(arkode_mem, NULL, f, T0, u);
+      if(check_flag(&flag, "ARKodeReInit", 1, my_pe)) MPI_Abort(comm, 1);
+
+      flag = ARKBBDPrecReInit(arkode_mem, mudq, mldq, ZERO);
+      if(check_flag(&flag, "ARKBBDPrecReInit", 1, my_pe)) MPI_Abort(comm, 1);
+
+      flag = ARKSpilsSetPrecType(arkode_mem, PREC_RIGHT);
+      check_flag(&flag, "ARKSpilsSetPrecType", 1, my_pe);
+
+      if (my_pe == 0) {
+	printf("\n\n-------------------------------------------------------");
+	printf("------------\n");
+      }
+
+    }
+
+    if (my_pe == 0) {
+      printf("\n\nPreconditioner type is:  jpre = %s\n\n",
+	     (jpre == PREC_LEFT) ? "PREC_LEFT" : "PREC_RIGHT");
+    }
+
+    /* In loop over output points, call ARKode, print results, test for error */
+    for (iout=1, tout=TWOHR; iout<=NOUT; iout++, tout+=TWOHR) {
+      flag = ARKode(arkode_mem, tout, u, &t, ARK_NORMAL);
+      if(check_flag(&flag, "ARKode", 1, my_pe)) break;
+      PrintOutput(arkode_mem, my_pe, comm, u, t);
+    }
+    
+    /* Print final statistics */
+    if (my_pe == 0) PrintFinalStats(arkode_mem);
+    
+  } /* End of jpre loop */
+
+  /* Free memory */
+  N_VDestroy_Parallel(u);
+  free(data);
+  ARKodeFree(&arkode_mem);
+  MPI_Finalize();
+  return(0);
+}
+
+/*********************** Private Helper Functions ************************/
+
+/* Load constants in data */
+static void InitUserData(int my_pe, long int local_N, MPI_Comm comm,
+                         UserData data)
+{
+  int isubx, isuby;
+
+  /* Set problem constants */
+  data->om = PI/HALFDAY;
+  data->dx = (XMAX-XMIN)/((realtype)(MX-1));
+  data->dy = (YMAX-YMIN)/((realtype)(MY-1));
+  data->hdco = KH/SUNSQR(data->dx);
+  data->haco = VEL/(RCONST(2.0)*data->dx);
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
+
+  /* Set machine-related constants */
+  data->comm = comm;
+  data->my_pe = my_pe;
+  data->Nlocal = local_N;
+  /* isubx and isuby are the PE grid indices corresponding to my_pe */
+  isuby = my_pe/NPEX;
+  isubx = my_pe - isuby*NPEX;
+  data->isubx = isubx;
+  data->isuby = isuby;
+  /* Set the sizes of a boundary x-line in u and uext */
+  data->nvmxsub = NVARS*MXSUB;
+  data->nvmxsub2 = NVARS*(MXSUB+2);
+}
+
+/* Set initial conditions in u */
+static void SetInitialProfiles(N_Vector u, UserData data)
+{
+  int isubx, isuby;
+  int lx, ly, jx, jy;
+  long int offset;
+  realtype dx, dy, x, y, cx, cy, xmid, ymid;
+  realtype *uarray;
+
+  /* Set pointer to data array in vector u */
+  uarray = N_VGetArrayPointer(u);
+
+  /* Get mesh spacings, and subgrid indices for this PE */
+  dx = data->dx;         dy = data->dy;
+  isubx = data->isubx;   isuby = data->isuby;
+
+  /* Load initial profiles of c1 and c2 into local u vector.
+  Here lx and ly are local mesh point indices on the local subgrid,
+  and jx and jy are the global mesh point indices. */
+  offset = 0;
+  xmid = RCONST(0.5)*(XMIN + XMAX);
+  ymid = RCONST(0.5)*(YMIN + YMAX);
+  for (ly = 0; ly < MYSUB; ly++) {
+    jy = ly + isuby*MYSUB;
+    y = YMIN + jy*dy;
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
+    for (lx = 0; lx < MXSUB; lx++) {
+      jx = lx + isubx*MXSUB;
+      x = XMIN + jx*dx;
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
+      uarray[offset  ] = C1_SCALE*cx*cy; 
+      uarray[offset+1] = C2_SCALE*cx*cy;
+      offset = offset + 2;
+    }
+  }
+}
+
+/* Print problem introduction */
+static void PrintIntro(int npes, long int mudq, long int mldq,
+		       long int mukeep, long int mlkeep)
+{
+  printf("\n2-species diurnal advection-diffusion problem\n");
+  printf("  %d by %d mesh on %d processors\n", MX, MY, npes);
+  printf("  Using ARKBBDPRE preconditioner module\n");
+  printf("    Difference-quotient half-bandwidths are");
+  printf(" mudq = %ld,  mldq = %ld\n", mudq, mldq);
+  printf("    Retained band block half-bandwidths are");
+  printf(" mukeep = %ld,  mlkeep = %ld", mukeep, mlkeep);
+  return;
+}
+
+/* Print current t, step count, order, stepsize, and sampled c1,c2 values */
+static void PrintOutput(void *arkode_mem, int my_pe, MPI_Comm comm, 
+                        N_Vector u, realtype t)
+{
+  int flag, npelast;
+  long int i0, i1, nst;
+  realtype hu, *uarray, tempu[2];
+  MPI_Status status;
+
+  npelast = NPEX*NPEY - 1;
+  uarray = N_VGetArrayPointer(u);
+
+  /* Send c1,c2 at top right mesh point to PE 0 */
+  if (my_pe == npelast) {
+    i0 = NVARS*MXSUB*MYSUB - 2;
+    i1 = i0 + 1;
+    if (npelast != 0)
+      MPI_Send(&uarray[i0], 2, PVEC_REAL_MPI_TYPE, 0, 0, comm);
+    else {
+      tempu[0] = uarray[i0];
+      tempu[1] = uarray[i1];
+    }
+  }
+
+  /* On PE 0, receive c1,c2 at top right, then print performance data
+     and sampled solution values */ 
+  if (my_pe == 0) {
+    if (npelast != 0)
+      MPI_Recv(&tempu[0], 2, PVEC_REAL_MPI_TYPE, npelast, 0, comm, &status);
+    flag = ARKodeGetNumSteps(arkode_mem, &nst);
+    check_flag(&flag, "ARKodeGetNumSteps", 1, my_pe);
+    flag = ARKodeGetLastStep(arkode_mem, &hu);
+    check_flag(&flag, "ARKodeGetLastStep", 1, my_pe);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf("t = %.2Le   no. steps = %ld   stepsize = %.2Le\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3Le %12.3Le \n", uarray[0], uarray[1]);
+    printf("At top right:    c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf("t = %.2e   no. steps = %ld   stepsize = %.2e\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", uarray[0], uarray[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
+#else
+    printf("t = %.2e   no. steps = %ld   stepsize = %.2e\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", uarray[0], uarray[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
+#endif
+  }
+}
+
+/* Print final statistics contained in iopt */
+static void PrintFinalStats(void *arkode_mem)
+{
+  long int lenrw, leniw ;
+  long int lenrwLS, leniwLS;
+  long int lenrwBBDP, leniwBBDP, ngevalsBBDP;
+  long int nst, nfe, nfi, nsetups, nni, ncfn, netf;
+  long int nli, npe, nps, ncfl, nfeLS;
+  int flag;
+
+  flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw);
+  check_flag(&flag, "ARKodeGetWorkSpace", 1, 0);
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1, 0);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1, 0);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1, 0);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1, 0);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1, 0);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1, 0);
+
+  flag = ARKSpilsGetWorkSpace(arkode_mem, &lenrwLS, &leniwLS);
+  check_flag(&flag, "ARKSpilsGetWorkSpace", 1, 0);
+  flag = ARKSpilsGetNumLinIters(arkode_mem, &nli);
+  check_flag(&flag, "ARKSpilsGetNumLinIters", 1, 0);
+  flag = ARKSpilsGetNumPrecEvals(arkode_mem, &npe);
+  check_flag(&flag, "ARKSpilsGetNumPrecEvals", 1, 0);
+  flag = ARKSpilsGetNumPrecSolves(arkode_mem, &nps);
+  check_flag(&flag, "ARKSpilsGetNumPrecSolves", 1, 0);
+  flag = ARKSpilsGetNumConvFails(arkode_mem, &ncfl);
+  check_flag(&flag, "ARKSpilsGetNumConvFails", 1, 0);
+  flag = ARKSpilsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKSpilsGetNumRhsEvals", 1, 0);
+
+  printf("\nFinal Statistics: \n\n");
+  printf("lenrw   = %5ld     leniw   = %5ld\n", lenrw, leniw);
+  printf("lenrwls = %5ld     leniwls = %5ld\n", lenrwLS, leniwLS);
+  printf("nst     = %5ld     nfe     = %5ld\n", nst, nfe);
+  printf("nfe     = %5ld     nfels   = %5ld\n", nfi, nfeLS);
+  printf("nni     = %5ld     nli     = %5ld\n", nni, nli);
+  printf("nsetups = %5ld     netf    = %5ld\n", nsetups, netf);
+  printf("npe     = %5ld     nps     = %5ld\n", npe, nps);
+  printf("ncfn    = %5ld     ncfl    = %5ld\n\n", ncfn, ncfl);
+
+  flag = ARKBBDPrecGetWorkSpace(arkode_mem, &lenrwBBDP, &leniwBBDP);
+  check_flag(&flag, "ARKBBDPrecGetWorkSpace", 1, 0);
+  flag = ARKBBDPrecGetNumGfnEvals(arkode_mem, &ngevalsBBDP);
+  check_flag(&flag, "ARKBBDPrecGetNumGfnEvals", 1, 0);
+  printf("In ARKBBDPRE: real/integer local work space sizes = %ld, %ld\n",
+	 lenrwBBDP, leniwBBDP);  
+  printf("             no. flocal evals. = %ld\n",ngevalsBBDP);
+}
+ 
+/* Routine to send boundary data to neighboring PEs */
+static void BSend(MPI_Comm comm, 
+                  int my_pe, int isubx, int isuby, 
+                  long int dsizex, long int dsizey,
+                  realtype uarray[])
+{
+  int i, ly;
+  long int offsetu, offsetbuf;
+  realtype bufleft[NVARS*MYSUB], bufright[NVARS*MYSUB];
+
+  /* If isuby > 0, send data from bottom x-line of u */
+  if (isuby != 0)
+    MPI_Send(&uarray[0], dsizex, PVEC_REAL_MPI_TYPE, my_pe-NPEX, 0, comm);
+
+  /* If isuby < NPEY-1, send data from top x-line of u */
+  if (isuby != NPEY-1) {
+    offsetu = (MYSUB-1)*dsizex;
+    MPI_Send(&uarray[offsetu], dsizex, PVEC_REAL_MPI_TYPE, my_pe+NPEX, 0, comm);
+  }
+
+  /* If isubx > 0, send data from left y-line of u (via bufleft) */
+  if (isubx != 0) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetu = ly*dsizex;
+      for (i = 0; i < NVARS; i++)
+        bufleft[offsetbuf+i] = uarray[offsetu+i];
+    }
+    MPI_Send(&bufleft[0], dsizey, PVEC_REAL_MPI_TYPE, my_pe-1, 0, comm);   
+  }
+
+  /* If isubx < NPEX-1, send data from right y-line of u (via bufright) */
+  if (isubx != NPEX-1) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetu = offsetbuf*MXSUB + (MXSUB-1)*NVARS;
+      for (i = 0; i < NVARS; i++)
+        bufright[offsetbuf+i] = uarray[offsetu+i];
+    }
+    MPI_Send(&bufright[0], dsizey, PVEC_REAL_MPI_TYPE, my_pe+1, 0, comm);   
+  }
+}
+ 
+/* Routine to start receiving boundary data from neighboring PEs.
+   Notes:
+   1) buffer should be able to hold 2*NVARS*MYSUB realtype entries, should be
+   passed to both the BRecvPost and BRecvWait functions, and should not
+   be manipulated between the two calls.
+   2) request should have 4 entries, and should be passed in both calls also. */
+static void BRecvPost(MPI_Comm comm, MPI_Request request[], 
+                      int my_pe, int isubx, int isuby,
+		      long int dsizex, long int dsizey,
+		      realtype uext[], realtype buffer[])
+{
+  long int offsetue;
+  /* Have bufleft and bufright use the same buffer */
+  realtype *bufleft = buffer, *bufright = buffer+NVARS*MYSUB;
+
+  /* If isuby > 0, receive data for bottom x-line of uext */
+  if (isuby != 0)
+    MPI_Irecv(&uext[NVARS], dsizex, PVEC_REAL_MPI_TYPE,
+    					 my_pe-NPEX, 0, comm, &request[0]);
+
+  /* If isuby < NPEY-1, receive data for top x-line of uext */
+  if (isuby != NPEY-1) {
+    offsetue = NVARS*(1 + (MYSUB+1)*(MXSUB+2));
+    MPI_Irecv(&uext[offsetue], dsizex, PVEC_REAL_MPI_TYPE,
+                                         my_pe+NPEX, 0, comm, &request[1]);
+  }
+
+  /* If isubx > 0, receive data for left y-line of uext (via bufleft) */
+  if (isubx != 0) {
+    MPI_Irecv(&bufleft[0], dsizey, PVEC_REAL_MPI_TYPE,
+                                         my_pe-1, 0, comm, &request[2]);
+  }
+
+  /* If isubx < NPEX-1, receive data for right y-line of uext (via bufright) */
+  if (isubx != NPEX-1) {
+    MPI_Irecv(&bufright[0], dsizey, PVEC_REAL_MPI_TYPE,
+                                         my_pe+1, 0, comm, &request[3]);
+  }
+}
+
+/* Routine to finish receiving boundary data from neighboring PEs.
+   Notes:
+   1) buffer should be able to hold 2*NVARS*MYSUB realtype entries, should be
+   passed to both the BRecvPost and BRecvWait functions, and should not
+   be manipulated between the two calls.
+   2) request should have 4 entries, and should be passed in both calls also. */
+static void BRecvWait(MPI_Request request[], 
+                      int isubx, int isuby, 
+                      long int dsizex, realtype uext[],
+                      realtype buffer[])
+{
+  int i, ly;
+  long int dsizex2, offsetue, offsetbuf;
+  realtype *bufleft = buffer, *bufright = buffer+NVARS*MYSUB;
+  MPI_Status status;
+
+  dsizex2 = dsizex + 2*NVARS;
+
+  /* If isuby > 0, receive data for bottom x-line of uext */
+  if (isuby != 0)
+    MPI_Wait(&request[0],&status);
+
+  /* If isuby < NPEY-1, receive data for top x-line of uext */
+  if (isuby != NPEY-1)
+    MPI_Wait(&request[1],&status);
+
+  /* If isubx > 0, receive data for left y-line of uext (via bufleft) */
+  if (isubx != 0) {
+    MPI_Wait(&request[2],&status);
+
+    /* Copy the buffer to uext */
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetue = (ly+1)*dsizex2;
+      for (i = 0; i < NVARS; i++)
+        uext[offsetue+i] = bufleft[offsetbuf+i];
+    }
+  }
+
+  /* If isubx < NPEX-1, receive data for right y-line of uext (via bufright) */
+  if (isubx != NPEX-1) {
+    MPI_Wait(&request[3],&status);
+
+    /* Copy the buffer to uext */
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetue = (ly+2)*dsizex2 - NVARS;
+      for (i = 0; i < NVARS; i++)
+	uext[offsetue+i] = bufright[offsetbuf+i];
+    }
+  }
+}
+
+/* fucomm routine.  This routine performs all inter-processor
+   communication of data in u needed to calculate f.         */
+static void fucomm(realtype t, N_Vector u, void *user_data)
+{
+  UserData data;
+  realtype *uarray, *uext, buffer[2*NVARS*MYSUB];
+  MPI_Comm comm;
+  int my_pe, isubx, isuby;
+  long int nvmxsub, nvmysub;
+  MPI_Request request[4];
+
+  data = (UserData) user_data;
+  uarray = N_VGetArrayPointer(u);
+
+  /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
+  comm = data->comm;  my_pe = data->my_pe;
+  isubx = data->isubx;   isuby = data->isuby;
+  nvmxsub = data->nvmxsub;
+  nvmysub = NVARS*MYSUB;
+  uext = data->uext;
+
+  /* Start receiving boundary data from neighboring PEs */
+  BRecvPost(comm, request, my_pe, isubx, isuby, nvmxsub, nvmysub, uext, buffer);
+
+  /* Send data from boundary of local grid to neighboring PEs */
+  BSend(comm, my_pe, isubx, isuby, nvmxsub, nvmysub, uarray);
+
+  /* Finish receiving boundary data from neighboring PEs */
+  BRecvWait(request, isubx, isuby, nvmxsub, uext, buffer);
+}
+
+/***************** Function called by the solver **************************/
+
+/* f routine.  Evaluate f(t,y).  First call fucomm to do communication of 
+   subgrid boundary data into uext.  Then calculate f by a call to flocal. */
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
+{
+  UserData data;
+
+  data = (UserData) user_data;
+
+  /* Call fucomm to do inter-processor communication */
+  fucomm (t, u, user_data);
+
+  /* Call flocal to calculate all right-hand sides */
+  flocal (data->Nlocal, t, u, udot, user_data);
+
+  return(0);
+}
+
+/***************** Functions called by the ARKBBDPRE module ****************/
+
+/* flocal routine.  Compute f(t,y).  This routine assumes that all
+   inter-processor communication of data needed to calculate f has already
+   been done, and this data is in the work array uext.                    */
+static int flocal(long int Nlocal, realtype t, N_Vector u,
+                  N_Vector udot, void *user_data)
+{
+  realtype *uext;
+  realtype q3, c1, c2, c1dn, c2dn, c1up, c2up, c1lt, c2lt;
+  realtype c1rt, c2rt, cydn, cyup, hord1, hord2, horad1, horad2;
+  realtype qq1, qq2, qq3, qq4, rkin1, rkin2, s, vertd1, vertd2, ydn, yup;
+  realtype q4coef, dely, verdco, hordco, horaco;
+  int i, lx, ly, jy;
+  int isubx, isuby;
+  long int nvmxsub, nvmxsub2, offsetu, offsetue;
+  UserData data;
+  realtype *uarray, *duarray;
+
+  uarray = N_VGetArrayPointer(u);
+  duarray = N_VGetArrayPointer(udot);
+
+  /* Get subgrid indices, array sizes, extended work array uext */
+  data = (UserData) user_data;
+  isubx = data->isubx;   isuby = data->isuby;
+  nvmxsub = data->nvmxsub; nvmxsub2 = data->nvmxsub2;
+  uext = data->uext;
+
+  /* Copy local segment of u vector into the working extended array uext */
+  offsetu = 0;
+  offsetue = nvmxsub2 + NVARS;
+  for (ly = 0; ly < MYSUB; ly++) {
+    for (i = 0; i < nvmxsub; i++) uext[offsetue+i] = uarray[offsetu+i];
+    offsetu = offsetu + nvmxsub;
+    offsetue = offsetue + nvmxsub2;
+  }
+
+  /* To facilitate homogeneous Neumann boundary conditions, when this is
+  a boundary PE, copy data from the first interior mesh line of u to uext */
+
+  /* If isuby = 0, copy x-line 2 of u to uext */
+  if (isuby == 0) {
+    for (i = 0; i < nvmxsub; i++) uext[NVARS+i] = uarray[nvmxsub+i];
+  }
+
+  /* If isuby = NPEY-1, copy x-line MYSUB-1 of u to uext */
+  if (isuby == NPEY-1) {
+    offsetu = (MYSUB-2)*nvmxsub;
+    offsetue = (MYSUB+1)*nvmxsub2 + NVARS;
+    for (i = 0; i < nvmxsub; i++) uext[offsetue+i] = uarray[offsetu+i];
+  }
+
+  /* If isubx = 0, copy y-line 2 of u to uext */
+  if (isubx == 0) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetu = ly*nvmxsub + NVARS;
+      offsetue = (ly+1)*nvmxsub2;
+      for (i = 0; i < NVARS; i++) uext[offsetue+i] = uarray[offsetu+i];
+    }
+  }
+
+  /* If isubx = NPEX-1, copy y-line MXSUB-1 of u to uext */
+  if (isubx == NPEX-1) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetu = (ly+1)*nvmxsub - 2*NVARS;
+      offsetue = (ly+2)*nvmxsub2 - NVARS;
+      for (i = 0; i < NVARS; i++) uext[offsetue+i] = uarray[offsetu+i];
+    }
+  }
+
+  /* Make local copies of problem variables, for efficiency */
+  dely = data->dy;
+  verdco = data->vdco;
+  hordco = data->hdco;
+  horaco = data->haco;
+
+  /* Set diurnal rate coefficients as functions of t, and save q4 in 
+  data block for use by preconditioner evaluation routine            */
+
+  s = sin((data->om)*t);
+  if (s > ZERO) {
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
+  } else {
+    q3 = ZERO;
+    q4coef = ZERO;
+  }
+  data->q4 = q4coef;
+
+
+  /* Loop over all grid points in local subgrid */
+  for (ly = 0; ly < MYSUB; ly++) {
+
+    jy = ly + isuby*MYSUB;
+
+    /* Set vertical diffusion coefficients at jy +- 1/2 */
+    ydn = YMIN + (jy - RCONST(0.5))*dely;
+    yup = ydn + dely;
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
+    for (lx = 0; lx < MXSUB; lx++) {
+
+      /* Extract c1 and c2, and set kinetic rate terms */
+      offsetue = (lx+1)*NVARS + (ly+1)*nvmxsub2;
+      c1 = uext[offsetue];
+      c2 = uext[offsetue+1];
+      qq1 = Q1*c1*C3;
+      qq2 = Q2*c1*c2;
+      qq3 = q3*C3;
+      qq4 = q4coef*c2;
+      rkin1 = -qq1 - qq2 + 2.0*qq3 + qq4;
+      rkin2 = qq1 - qq2 - qq4;
+
+      /* Set vertical diffusion terms */
+      c1dn = uext[offsetue-nvmxsub2];
+      c2dn = uext[offsetue-nvmxsub2+1];
+      c1up = uext[offsetue+nvmxsub2];
+      c2up = uext[offsetue+nvmxsub2+1];
+      vertd1 = cyup*(c1up - c1) - cydn*(c1 - c1dn);
+      vertd2 = cyup*(c2up - c2) - cydn*(c2 - c2dn);
+
+      /* Set horizontal diffusion and advection terms */
+      c1lt = uext[offsetue-2];
+      c2lt = uext[offsetue-1];
+      c1rt = uext[offsetue+2];
+      c2rt = uext[offsetue+3];
+      hord1 = hordco*(c1rt - RCONST(2.0)*c1 + c1lt);
+      hord2 = hordco*(c2rt - RCONST(2.0)*c2 + c2lt);
+      horad1 = horaco*(c1rt - c1lt);
+      horad2 = horaco*(c2rt - c2lt);
+
+      /* Load all terms into duarray */
+      offsetu = lx*NVARS + ly*nvmxsub;
+      duarray[offsetu]   = vertd1 + hord1 + horad1 + rkin1; 
+      duarray[offsetu+1] = vertd2 + hord2 + horad2 + rkin2;
+    }
+  }
+
+  return(0);
+}
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed with flag = %d\n\n",
+              id, funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out
new file mode 100644
index 0000000..400b519
--- /dev/null
+++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out
@@ -0,0 +1,140 @@
+
+2-species diurnal advection-diffusion problem
+  10 by 10 mesh on 4 processors
+  Using ARKBBDPRE preconditioner module
+    Difference-quotient half-bandwidths are mudq = 10,  mldq = 10
+    Retained band block half-bandwidths are mukeep = 2,  mlkeep = 2
+
+Preconditioner type is:  jpre = PREC_LEFT
+
+t = 7.20e+03   no. steps = 979   stepsize = 3.07e+00
+At bottom left:  c1, c2 =    1.047e+04    2.527e+11 
+At top right:    c1, c2 =    1.119e+04    2.700e+11 
+
+t = 1.44e+04   no. steps = 2737   stepsize = 6.94e+00
+At bottom left:  c1, c2 =    6.659e+06    2.582e+11 
+At top right:    c1, c2 =    7.301e+06    2.833e+11 
+
+t = 2.16e+04   no. steps = 3536   stepsize = 1.04e+01
+At bottom left:  c1, c2 =    2.665e+07    2.993e+11 
+At top right:    c1, c2 =    2.931e+07    3.313e+11 
+
+t = 2.88e+04   no. steps = 4696   stepsize = 3.57e+00
+At bottom left:  c1, c2 =    8.702e+06    3.380e+11 
+At top right:    c1, c2 =    9.650e+06    3.751e+11 
+
+t = 3.60e+04   no. steps = 6153   stepsize = 2.55e+00
+At bottom left:  c1, c2 =    1.404e+04    3.387e+11 
+At top right:    c1, c2 =    1.561e+04    3.765e+11 
+
+t = 4.32e+04   no. steps = 7347   stepsize = 2.70e+02
+At bottom left:  c1, c2 =   -3.646e-07    3.382e+11 
+At top right:    c1, c2 =    1.550e-06    3.804e+11 
+
+t = 5.04e+04   no. steps = 7367   stepsize = 4.18e+02
+At bottom left:  c1, c2 =    7.306e-08    3.358e+11 
+At top right:    c1, c2 =   -9.873e-07    3.864e+11 
+
+t = 5.76e+04   no. steps = 7384   stepsize = 3.72e+02
+At bottom left:  c1, c2 =    1.527e-09    3.320e+11 
+At top right:    c1, c2 =    4.335e-08    3.909e+11 
+
+t = 6.48e+04   no. steps = 7399   stepsize = 6.63e+02
+At bottom left:  c1, c2 =    1.013e-07    3.313e+11 
+At top right:    c1, c2 =    5.434e-07    3.963e+11 
+
+t = 7.20e+04   no. steps = 7410   stepsize = 6.63e+02
+At bottom left:  c1, c2 =    1.955e-07    3.330e+11 
+At top right:    c1, c2 =    1.942e-06    4.039e+11 
+
+t = 7.92e+04   no. steps = 7421   stepsize = 6.63e+02
+At bottom left:  c1, c2 =   -9.651e-08    3.334e+11 
+At top right:    c1, c2 =   -4.421e-07    4.120e+11 
+
+t = 8.64e+04   no. steps = 7432   stepsize = 6.63e+02
+At bottom left:  c1, c2 =    2.720e-08    3.352e+11 
+At top right:    c1, c2 =    3.334e-07    4.163e+11 
+
+
+Final Statistics: 
+
+lenrw   =  3058     leniw   =   160
+lenrwls =  2046     leniwls =    80
+nst     =  7432     nfe     =     0
+nfe     = 78033     nfels   = 83813
+nni     = 40719     nli     = 83813
+nsetups =   450     netf    =    30
+npe     =   125     nps     = 122360
+ncfn    =     0     ncfl    =     0
+
+In ARKBBDPRE: real/integer local work space sizes = 600, 50
+             no. flocal evals. = 2750
+
+
+-------------------------------------------------------------------
+
+
+Preconditioner type is:  jpre = PREC_RIGHT
+
+t = 7.20e+03   no. steps = 981   stepsize = 3.06e+00
+At bottom left:  c1, c2 =    1.047e+04    2.527e+11 
+At top right:    c1, c2 =    1.119e+04    2.700e+11 
+
+t = 1.44e+04   no. steps = 2731   stepsize = 6.90e+00
+At bottom left:  c1, c2 =    6.659e+06    2.582e+11 
+At top right:    c1, c2 =    7.301e+06    2.833e+11 
+
+t = 2.16e+04   no. steps = 3534   stepsize = 1.04e+01
+At bottom left:  c1, c2 =    2.665e+07    2.993e+11 
+At top right:    c1, c2 =    2.931e+07    3.313e+11 
+
+t = 2.88e+04   no. steps = 4682   stepsize = 3.53e+00
+At bottom left:  c1, c2 =    8.702e+06    3.380e+11 
+At top right:    c1, c2 =    9.650e+06    3.751e+11 
+
+t = 3.60e+04   no. steps = 6149   stepsize = 2.55e+00
+At bottom left:  c1, c2 =    1.404e+04    3.387e+11 
+At top right:    c1, c2 =    1.561e+04    3.765e+11 
+
+t = 4.32e+04   no. steps = 7339   stepsize = 4.35e+02
+At bottom left:  c1, c2 =    8.121e-08    3.382e+11 
+At top right:    c1, c2 =   -2.045e-14    3.804e+11 
+
+t = 5.04e+04   no. steps = 7357   stepsize = 3.70e+02
+At bottom left:  c1, c2 =    1.123e-07    3.358e+11 
+At top right:    c1, c2 =   -2.964e-15    3.864e+11 
+
+t = 5.76e+04   no. steps = 7373   stepsize = 1.86e+02
+At bottom left:  c1, c2 =   -1.175e-07    3.320e+11 
+At top right:    c1, c2 =   -1.860e-11    3.909e+11 
+
+t = 6.48e+04   no. steps = 7389   stepsize = 5.22e+02
+At bottom left:  c1, c2 =   -2.231e-08    3.313e+11 
+At top right:    c1, c2 =   -1.392e-13    3.963e+11 
+
+t = 7.20e+04   no. steps = 7402   stepsize = 5.22e+02
+At bottom left:  c1, c2 =   -6.583e-19    3.330e+11 
+At top right:    c1, c2 =    1.864e-24    4.039e+11 
+
+t = 7.92e+04   no. steps = 7416   stepsize = 5.22e+02
+At bottom left:  c1, c2 =   -2.240e-19    3.334e+11 
+At top right:    c1, c2 =    4.536e-24    4.120e+11 
+
+t = 8.64e+04   no. steps = 7430   stepsize = 5.22e+02
+At bottom left:  c1, c2 =   -7.473e-19    3.352e+11 
+At top right:    c1, c2 =    1.656e-25    4.163e+11 
+
+
+Final Statistics: 
+
+lenrw   =  3058     leniw   =   160
+lenrwls =  2046     leniwls =    80
+nst     =  7430     nfe     =     0
+nfe     = 78034     nfels   = 101865
+nni     = 40725     nli     = 101865
+nsetups =   451     netf    =    31
+npe     =   125     nps     = 139198
+ncfn    =     0     ncfl    =     0
+
+In ARKBBDPRE: real/integer local work space sizes = 600, 50
+             no. flocal evals. = 2750
diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.c b/examples/arkode/C_parallel/ark_diurnal_kry_p.c
new file mode 100644
index 0000000..d7439e3
--- /dev/null
+++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.c
@@ -0,0 +1,956 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ *
+ * An ODE system is generated from the following 2-species diurnal
+ * kinetics advection-diffusion PDE system in 2 space dimensions:
+ *
+ * dc(i)/dt = Kh*(d/dx)^2 c(i) + V*dc(i)/dx + (d/dy)(Kv(y)*dc(i)/dy)
+ *                 + Ri(c1,c2,t)      for i = 1,2,   where
+ *   R1(c1,c2,t) = -q1*c1*c3 - q2*c1*c2 + 2*q3(t)*c3 + q4(t)*c2 ,
+ *   R2(c1,c2,t) =  q1*c1*c3 - q2*c1*c2 - q4(t)*c2 ,
+ *   Kv(y) = Kv0*exp(y/5) ,
+ * Kh, V, Kv0, q1, q2, and c3 are constants, and q3(t) and q4(t)
+ * vary diurnally. The problem is posed on the square
+ *   0 <= x <= 20,    30 <= y <= 50   (all in km),
+ * with homogeneous Neumann boundary conditions, and for time t in
+ *   0 <= t <= 86400 sec (1 day).
+ * The PDE system is treated by central differences on a uniform
+ * mesh, with simple polynomial initial profiles.
+ *
+ * The problem is solved by ARKODE on NPE processors, treated
+ * as a rectangular process grid of size NPEX by NPEY, with
+ * NPE = NPEX*NPEY. Each processor contains a subgrid of size MXSUB
+ * by MYSUB of the (x,y) mesh.  Thus the actual mesh sizes are
+ * MX = MXSUB*NPEX and MY = MYSUB*NPEY, and the ODE system size is
+ * neq = 2*MX*MY.
+ *
+ * The solution is done with the DIRK/GMRES method (i.e. using the
+ * ARKSPGMR linear solver) and the block-diagonal part of the
+ * Newton matrix as a left preconditioner. A copy of the
+ * block-diagonal part of the Jacobian is saved and conditionally
+ * reused within the preconditioner routine.
+ *
+ * Performance data and sampled solution values are printed at
+ * selected output times, and all performance counters are printed
+ * on completion.
+ *
+ * This version uses MPI for user routines.
+ * 
+ * Execution: mpiexec -n N ark_diurnal_kry_p   with N = NPEX*NPEY
+ * (see constants below).
+ *---------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>             /* prototypes for ARKODE fcts. */
+#include <arkode/arkode_spgmr.h>       /* prototypes & constants for ARKSPGMR  */
+#include <nvector/nvector_parallel.h>  /* def. of N_Vector, macro NV_DATA_P  */
+#include <sundials/sundials_dense.h>   /* prototypes for small dense fcts. */
+#include <sundials/sundials_types.h>   /* definitions of realtype, booleantype */
+#include <sundials/sundials_math.h>    /* definition of macros SUNSQR and EXP */
+#include <mpi.h>                       /* MPI constants and types */
+
+/* Problem Constants */
+#define NVARS        2                    /* number of species         */
+#define KH           RCONST(4.0e-6)       /* horizontal diffusivity Kh */
+#define VEL          RCONST(0.001)        /* advection velocity V      */
+#define KV0          RCONST(1.0e-8)       /* coefficient in Kv(y)      */
+#define Q1           RCONST(1.63e-16)     /* coefficients q1, q2, c3   */ 
+#define Q2           RCONST(4.66e-16)
+#define C3           RCONST(3.7e16)
+#define A3           RCONST(22.62)        /* coefficient in expression for q3(t) */
+#define A4           RCONST(7.601)        /* coefficient in expression for q4(t) */
+#define C1_SCALE     RCONST(1.0e6)        /* coefficients in initial profiles    */
+#define C2_SCALE     RCONST(1.0e12)
+
+#define T0           RCONST(0.0)          /* initial time */
+#define NOUT         12                   /* number of output times */
+#define TWOHR        RCONST(7200.0)       /* number of seconds in two hours  */
+#define HALFDAY      RCONST(4.32e4)       /* number of seconds in a half day */
+#define PI       RCONST(3.1415926535898)  /* pi */ 
+
+#define XMIN         RCONST(0.0)          /* grid boundaries in x  */
+#define XMAX         RCONST(20.0)           
+#define YMIN         RCONST(30.0)         /* grid boundaries in y  */
+#define YMAX         RCONST(50.0)
+
+#define NPEX         2                    /* no. PEs in x direction of PE array */
+#define NPEY         2                    /* no. PEs in y direction of PE array */
+                                          /* Total no. PEs = NPEX*NPEY */
+#define MXSUB        5                    /* no. x points per subgrid */
+#define MYSUB        5                    /* no. y points per subgrid */
+
+#define MX           (NPEX*MXSUB)         /* MX = number of x mesh points */
+#define MY           (NPEY*MYSUB)         /* MY = number of y mesh points */
+                                          /* Spatial mesh is MX by MY */
+
+/* ARKodeInit Constants */
+#define RTOL    RCONST(1.0e-5)            /* scalar relative tolerance */
+#define FLOOR   RCONST(100.0)             /* value of C1 or C2 at which tolerances */
+                                          /* change from relative to absolute      */
+#define ATOL    (RTOL*FLOOR)              /* scalar absolute tolerance */
+
+
+/* User-defined matrix accessor macro: IJth 
+
+   IJth is defined in order to write code which indexes into dense
+   matrices with a (row,column) pair, where 1 <= row,column <= NVARS.   
+
+   IJth(a,i,j) references the (i,j)th entry of the small matrix realtype **a,
+   where 1 <= i,j <= NVARS. The small matrix routines in sundials_dense.h
+   work with matrices stored by column in a 2-dimensional array. In C,
+   arrays are indexed starting at 0, not 1. */
+#define IJth(a,i,j) (a[j-1][i-1])
+
+/* Type : UserData 
+   contains problem constants, preconditioner blocks, pivot arrays, 
+   grid constants, and processor indices, as well as data needed
+   for the preconditiner */
+typedef struct {
+
+  realtype q4, om, dx, dy, hdco, haco, vdco;
+  realtype uext[NVARS*(MXSUB+2)*(MYSUB+2)];
+  int my_pe, isubx, isuby;
+  int nvmxsub, nvmxsub2;
+  MPI_Comm comm;
+
+  /* For preconditioner */
+  realtype **P[MXSUB][MYSUB], **Jbd[MXSUB][MYSUB];
+  long int *pivot[MXSUB][MYSUB];
+
+} *UserData;
+
+/* Private Helper Functions */
+static void InitUserData(int my_pe, MPI_Comm comm, UserData data);
+static void FreeUserData(UserData data);
+static void SetInitialProfiles(N_Vector u, UserData data);
+static void PrintOutput(void *arkode_mem, int my_pe, MPI_Comm comm,
+                        N_Vector u, realtype t);
+static void PrintFinalStats(void *arkode_mem);
+static void BSend(MPI_Comm comm, 
+                  int my_pe, int isubx, int isuby, 
+                  long int dsizex, long int dsizey,
+                  realtype udata[]);
+static void BRecvPost(MPI_Comm comm, MPI_Request request[], 
+                      int my_pe, int isubx, int isuby,
+		      long int dsizex, long int dsizey,
+		      realtype uext[], realtype buffer[]);
+static void BRecvWait(MPI_Request request[], 
+                      int isubx, int isuby, 
+                      long int dsizex, realtype uext[],
+                      realtype buffer[]);
+static void ucomm(realtype t, N_Vector u, UserData data);
+static void fcalc(realtype t, realtype udata[], realtype dudata[],
+                  UserData data);
+
+
+/* Functions Called by the Solver */
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
+static int Precond(realtype tn, N_Vector u, N_Vector fu,
+                   booleantype jok, booleantype *jcurPtr, 
+                   realtype gamma, void *user_data, 
+                   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+static int PSolve(realtype tn, N_Vector u, N_Vector fu, 
+                  N_Vector r, N_Vector z, 
+                  realtype gamma, realtype delta,
+                  int lr, void *user_data, N_Vector vtemp);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
+
+
+/***************************** Main Program ******************************/
+int main(int argc, char *argv[])
+{
+  realtype abstol, reltol, t, tout;
+  N_Vector u;
+  UserData data;
+  void *arkode_mem;
+  int iout, flag, my_pe, npes;
+  long int neq, local_N;
+  MPI_Comm comm;
+
+  u = NULL;
+  data = NULL;
+  arkode_mem = NULL;
+
+  /* Set problem size neq */
+  neq = NVARS*MX*MY;
+
+  /* Get processor number and total number of pe's */
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &npes);
+  MPI_Comm_rank(comm, &my_pe);
+
+  if (npes != NPEX*NPEY) {
+    if (my_pe == 0)
+      fprintf(stderr, "\nMPI_ERROR(0): npes = %d is not equal to NPEX*NPEY = %d\n\n",
+	      npes,NPEX*NPEY);
+    MPI_Finalize();
+    return(1);
+  }
+
+  /* Set local length */
+  local_N = NVARS*MXSUB*MYSUB;
+
+  /* Allocate and load user data block; allocate preconditioner block */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2, my_pe)) MPI_Abort(comm, 1);
+  InitUserData(my_pe, comm, data);
+
+  /* Allocate u, and set initial values and tolerances */ 
+  u = N_VNew_Parallel(comm, local_N, neq);
+  if (check_flag((void *)u, "N_VNew", 0, my_pe)) MPI_Abort(comm, 1);
+  SetInitialProfiles(u, data);
+  abstol = ATOL; reltol = RTOL;
+
+  /* Call ARKodeCreate to create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0, my_pe)) MPI_Abort(comm, 1);
+
+  /* Set the pointer to user-defined data */
+  flag = ARKodeSetUserData(arkode_mem, data);
+  if (check_flag(&flag, "ARKodeSetUserData", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     user's right hand side functions in u'=fe(t,u)+fi(t,u) [here fe is NULL], 
+     the inital time T0, and the initial dependent variable vector u. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, u);
+  if(check_flag(&flag, "ARKodeInit", 1, my_pe)) return(1);
+
+  /* Call ARKodeSetMaxNumSteps to increase default */
+  flag = ARKodeSetMaxNumSteps(arkode_mem, 10000);
+  if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1, my_pe)) return(1);
+
+  /* Call ARKodeSStolerances to specify the scalar relative tolerance
+     and scalar absolute tolerances */
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);
+  if (check_flag(&flag, "ARKodeSStolerances", 1, my_pe)) return(1);
+
+  /* Call ARKSpgmr to specify the linear solver ARKSPGMR 
+     with left preconditioning and the default Krylov dimension maxl */
+  flag = ARKSpgmr(arkode_mem, PREC_LEFT, 0);
+  if (check_flag(&flag, "ARKSpgmr", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Set preconditioner setup and solve routines Precond and PSolve, 
+     and the pointer to the user-defined block data */
+  flag = ARKSpilsSetPreconditioner(arkode_mem, Precond, PSolve);
+  if (check_flag(&flag, "ARKSpilsSetPreconditioner", 1, my_pe)) MPI_Abort(comm, 1);
+
+  if (my_pe == 0)
+    printf("\n2-species diurnal advection-diffusion problem\n\n");
+
+  /* In loop over output points, call ARKode, print results, test for error */
+  for (iout=1, tout=TWOHR; iout<=NOUT; iout++, tout+=TWOHR) {
+    flag = ARKode(arkode_mem, tout, u, &t, ARK_NORMAL);
+    if (check_flag(&flag, "ARKode", 1, my_pe)) break;
+    PrintOutput(arkode_mem, my_pe, comm, u, t);
+  }
+
+  /* Print final statistics */  
+  if (my_pe == 0) PrintFinalStats(arkode_mem);
+
+  /* Free memory */
+  N_VDestroy_Parallel(u);
+  FreeUserData(data);
+  ARKodeFree(&arkode_mem);
+  MPI_Finalize();
+  return(0);
+}
+
+/*********************** Private Helper Functions ************************/
+
+/* Load constants in data */
+static void InitUserData(int my_pe, MPI_Comm comm, UserData data)
+{
+  int isubx, isuby;
+  int lx, ly;
+
+  /* Set problem constants */
+  data->om = PI/HALFDAY;
+  data->dx = (XMAX-XMIN)/((realtype)(MX-1));
+  data->dy = (YMAX-YMIN)/((realtype)(MY-1));
+  data->hdco = KH/SUNSQR(data->dx);
+  data->haco = VEL/(RCONST(2.0)*data->dx);
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
+
+  /* Set machine-related constants */
+  data->comm = comm;
+  data->my_pe = my_pe;
+
+  /* isubx and isuby are the PE grid indices corresponding to my_pe */
+  isuby = my_pe/NPEX;
+  isubx = my_pe - isuby*NPEX;
+  data->isubx = isubx;
+  data->isuby = isuby;
+
+  /* Set the sizes of a boundary x-line in u and uext */
+  data->nvmxsub = NVARS*MXSUB;
+  data->nvmxsub2 = NVARS*(MXSUB+2);
+
+  /* Preconditioner-related fields */
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      (data->P)[lx][ly] = newDenseMat(NVARS, NVARS);
+      (data->Jbd)[lx][ly] = newDenseMat(NVARS, NVARS);
+      (data->pivot)[lx][ly] = newLintArray(NVARS);
+    }
+  }
+}
+
+/* Free user data memory */
+static void FreeUserData(UserData data)
+{
+  int lx, ly;
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      destroyMat((data->P)[lx][ly]);
+      destroyMat((data->Jbd)[lx][ly]);
+      destroyArray((data->pivot)[lx][ly]);
+    }
+  }
+  free(data);
+}
+
+/* Set initial conditions in u */
+static void SetInitialProfiles(N_Vector u, UserData data)
+{
+  int isubx, isuby, lx, ly, jx, jy;
+  long int offset;
+  realtype dx, dy, x, y, cx, cy, xmid, ymid;
+  realtype *udata;
+
+  /* Set pointer to data array in vector u */
+  udata = N_VGetArrayPointer(u);
+
+  /* Get mesh spacings, and subgrid indices for this PE */
+  dx = data->dx;         dy = data->dy;
+  isubx = data->isubx;   isuby = data->isuby;
+
+  /* Load initial profiles of c1 and c2 into local u vector.
+  Here lx and ly are local mesh point indices on the local subgrid,
+  and jx and jy are the global mesh point indices. */
+  offset = 0;
+  xmid = RCONST(0.5)*(XMIN + XMAX);
+  ymid = RCONST(0.5)*(YMIN + YMAX);
+  for (ly = 0; ly < MYSUB; ly++) {
+    jy = ly + isuby*MYSUB;
+    y = YMIN + jy*dy;
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
+    for (lx = 0; lx < MXSUB; lx++) {
+      jx = lx + isubx*MXSUB;
+      x = XMIN + jx*dx;
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
+      udata[offset  ] = C1_SCALE*cx*cy; 
+      udata[offset+1] = C2_SCALE*cx*cy;
+      offset = offset + 2;
+    }
+  }
+}
+
+/* Print current t, step count, order, stepsize, and sampled c1,c2 values */
+static void PrintOutput(void *arkode_mem, int my_pe, MPI_Comm comm,
+                        N_Vector u, realtype t)
+{
+  int flag;
+  realtype hu, *udata, tempu[2];
+  int npelast;
+  long int i0, i1, nst;
+  MPI_Status status;
+
+  npelast = NPEX*NPEY - 1;
+  udata = N_VGetArrayPointer(u);
+
+  /* Send c1,c2 at top right mesh point to PE 0 */
+  if (my_pe == npelast) {
+    i0 = NVARS*MXSUB*MYSUB - 2;
+    i1 = i0 + 1;
+    if (npelast != 0)
+      MPI_Send(&udata[i0], 2, PVEC_REAL_MPI_TYPE, 0, 0, comm);
+    else {
+      tempu[0] = udata[i0];
+      tempu[1] = udata[i1];
+    }
+  }
+
+  /* On PE 0, receive c1,c2 at top right, then print performance data
+     and sampled solution values */ 
+  if (my_pe == 0) {
+    if (npelast != 0)
+      MPI_Recv(&tempu[0], 2, PVEC_REAL_MPI_TYPE, npelast, 0, comm, &status);
+    flag = ARKodeGetNumSteps(arkode_mem, &nst);
+    check_flag(&flag, "ARKodeGetNumSteps", 1, my_pe);
+    flag = ARKodeGetLastStep(arkode_mem, &hu);
+    check_flag(&flag, "ARKodeGetLastStep", 1, my_pe);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf("t = %.2Le   no. steps = %ld   stepsize = %.2Le\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3Le %12.3Le \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf("t = %.2e   no. steps = %ld   stepsize = %.2e\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
+#else
+    printf("t = %.2e   no. steps = %ld   stepsize = %.2e\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
+#endif
+  }
+}
+
+/* Print final statistics contained in iopt */
+static void PrintFinalStats(void *arkode_mem)
+{
+  long int lenrw, leniw ;
+  long int lenrwLS, leniwLS;
+  long int nst, nfe, nfi, nsetups, nni, ncfn, netf;
+  long int nli, npe, nps, ncfl, nfeLS;
+  int flag;
+
+  flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw);
+  check_flag(&flag, "ARKodeGetWorkSpace", 1, 0);
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1, 0);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1, 0);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1, 0);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1, 0);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1, 0);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1, 0);
+
+  flag = ARKSpilsGetWorkSpace(arkode_mem, &lenrwLS, &leniwLS);
+  check_flag(&flag, "ARKSpilsGetWorkSpace", 1, 0);
+  flag = ARKSpilsGetNumLinIters(arkode_mem, &nli);
+  check_flag(&flag, "ARKSpilsGetNumLinIters", 1, 0);
+  flag = ARKSpilsGetNumPrecEvals(arkode_mem, &npe);
+  check_flag(&flag, "ARKSpilsGetNumPrecEvals", 1, 0);
+  flag = ARKSpilsGetNumPrecSolves(arkode_mem, &nps);
+  check_flag(&flag, "ARKSpilsGetNumPrecSolves", 1, 0);
+  flag = ARKSpilsGetNumConvFails(arkode_mem, &ncfl);
+  check_flag(&flag, "ARKSpilsGetNumConvFails", 1, 0);
+  flag = ARKSpilsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKSpilsGetNumRhsEvals", 1, 0);
+
+  printf("\nFinal Statistics: \n\n");
+  printf("lenrw   = %5ld     leniw   = %5ld\n", lenrw, leniw);
+  printf("lenrwls = %5ld     leniwls = %5ld\n", lenrwLS, leniwLS);
+  printf("nst     = %5ld     nfe     = %5ld\n", nst, nfe);
+  printf("nfi     = %5ld     nfels   = %5ld\n", nfi, nfeLS);
+  printf("nni     = %5ld     nli     = %5ld\n", nni, nli);
+  printf("nsetups = %5ld     netf    = %5ld\n", nsetups, netf);
+  printf("npe     = %5ld     nps     = %5ld\n", npe, nps);
+  printf("ncfn    = %5ld     ncfl    = %5ld\n\n", ncfn, ncfl); 
+}
+ 
+/* Routine to send boundary data to neighboring PEs */
+static void BSend(MPI_Comm comm, 
+                  int my_pe, int isubx, int isuby, 
+                  long int dsizex, long int dsizey,
+                  realtype udata[])
+{
+  int i, ly;
+  long int offsetu, offsetbuf;
+  realtype bufleft[NVARS*MYSUB], bufright[NVARS*MYSUB];
+
+  /* If isuby > 0, send data from bottom x-line of u */
+  if (isuby != 0)
+    MPI_Send(&udata[0], dsizex, PVEC_REAL_MPI_TYPE, my_pe-NPEX, 0, comm);
+
+  /* If isuby < NPEY-1, send data from top x-line of u */
+  if (isuby != NPEY-1) {
+    offsetu = (MYSUB-1)*dsizex;
+    MPI_Send(&udata[offsetu], dsizex, PVEC_REAL_MPI_TYPE, my_pe+NPEX, 0, comm);
+  }
+
+  /* If isubx > 0, send data from left y-line of u (via bufleft) */
+  if (isubx != 0) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetu = ly*dsizex;
+      for (i = 0; i < NVARS; i++)
+        bufleft[offsetbuf+i] = udata[offsetu+i];
+    }
+    MPI_Send(&bufleft[0], dsizey, PVEC_REAL_MPI_TYPE, my_pe-1, 0, comm);   
+  }
+
+  /* If isubx < NPEX-1, send data from right y-line of u (via bufright) */
+  if (isubx != NPEX-1) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetu = offsetbuf*MXSUB + (MXSUB-1)*NVARS;
+      for (i = 0; i < NVARS; i++)
+        bufright[offsetbuf+i] = udata[offsetu+i];
+    }
+    MPI_Send(&bufright[0], dsizey, PVEC_REAL_MPI_TYPE, my_pe+1, 0, comm);   
+  }
+}
+ 
+/* Routine to start receiving boundary data from neighboring PEs.
+   Notes:
+   1) buffer should be able to hold 2*NVARS*MYSUB realtype entries, should be
+   passed to both the BRecvPost and BRecvWait functions, and should not
+   be manipulated between the two calls.
+   2) request should have 4 entries, and should be passed in both calls also. */
+
+static void BRecvPost(MPI_Comm comm, MPI_Request request[], 
+                      int my_pe, int isubx, int isuby,
+		      long int dsizex, long int dsizey,
+		      realtype uext[], realtype buffer[])
+{
+  long int offsetue;
+  /* Have bufleft and bufright use the same buffer */
+  realtype *bufleft = buffer, *bufright = buffer+NVARS*MYSUB;
+
+  /* If isuby > 0, receive data for bottom x-line of uext */
+  if (isuby != 0)
+    MPI_Irecv(&uext[NVARS], dsizex, PVEC_REAL_MPI_TYPE,
+    					 my_pe-NPEX, 0, comm, &request[0]);
+
+  /* If isuby < NPEY-1, receive data for top x-line of uext */
+  if (isuby != NPEY-1) {
+    offsetue = NVARS*(1 + (MYSUB+1)*(MXSUB+2));
+    MPI_Irecv(&uext[offsetue], dsizex, PVEC_REAL_MPI_TYPE,
+                                         my_pe+NPEX, 0, comm, &request[1]);
+  }
+
+  /* If isubx > 0, receive data for left y-line of uext (via bufleft) */
+  if (isubx != 0) {
+    MPI_Irecv(&bufleft[0], dsizey, PVEC_REAL_MPI_TYPE,
+                                         my_pe-1, 0, comm, &request[2]);
+  }
+
+  /* If isubx < NPEX-1, receive data for right y-line of uext (via bufright) */
+  if (isubx != NPEX-1) {
+    MPI_Irecv(&bufright[0], dsizey, PVEC_REAL_MPI_TYPE,
+                                         my_pe+1, 0, comm, &request[3]);
+  }
+}
+
+/* Routine to finish receiving boundary data from neighboring PEs.
+   Notes:
+   1) buffer should be able to hold 2*NVARS*MYSUB realtype entries, should be
+   passed to both the BRecvPost and BRecvWait functions, and should not
+   be manipulated between the two calls.
+   2) request should have 4 entries, and should be passed in both calls also. */
+
+static void BRecvWait(MPI_Request request[], 
+                      int isubx, int isuby, 
+                      long int dsizex, realtype uext[],
+                      realtype buffer[])
+{
+  int i, ly;
+  long int dsizex2, offsetue, offsetbuf;
+  realtype *bufleft = buffer, *bufright = buffer+NVARS*MYSUB;
+  MPI_Status status;
+
+  dsizex2 = dsizex + 2*NVARS;
+
+  /* If isuby > 0, receive data for bottom x-line of uext */
+  if (isuby != 0)
+    MPI_Wait(&request[0],&status);
+
+  /* If isuby < NPEY-1, receive data for top x-line of uext */
+  if (isuby != NPEY-1)
+    MPI_Wait(&request[1],&status);
+
+  /* If isubx > 0, receive data for left y-line of uext (via bufleft) */
+  if (isubx != 0) {
+    MPI_Wait(&request[2],&status);
+
+    /* Copy the buffer to uext */
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetue = (ly+1)*dsizex2;
+      for (i = 0; i < NVARS; i++)
+        uext[offsetue+i] = bufleft[offsetbuf+i];
+    }
+  }
+
+  /* If isubx < NPEX-1, receive data for right y-line of uext (via bufright) */
+  if (isubx != NPEX-1) {
+    MPI_Wait(&request[3],&status);
+
+    /* Copy the buffer to uext */
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetue = (ly+2)*dsizex2 - NVARS;
+      for (i = 0; i < NVARS; i++)
+	uext[offsetue+i] = bufright[offsetbuf+i];
+    }
+  }
+}
+
+/* ucomm routine.  This routine performs all communication 
+   between processors of data needed to calculate f. */
+
+static void ucomm(realtype t, N_Vector u, UserData data)
+{
+
+  realtype *udata, *uext, buffer[2*NVARS*MYSUB];
+  MPI_Comm comm;
+  int my_pe, isubx, isuby;
+  long int nvmxsub, nvmysub;
+  MPI_Request request[4];
+
+  udata = N_VGetArrayPointer(u);
+
+  /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
+  comm = data->comm;  my_pe = data->my_pe;
+  isubx = data->isubx;   isuby = data->isuby;
+  nvmxsub = data->nvmxsub;
+  nvmysub = NVARS*MYSUB;
+  uext = data->uext;
+
+  /* Start receiving boundary data from neighboring PEs */
+  BRecvPost(comm, request, my_pe, isubx, isuby, nvmxsub, nvmysub, uext, buffer);
+
+  /* Send data from boundary of local grid to neighboring PEs */
+  BSend(comm, my_pe, isubx, isuby, nvmxsub, nvmysub, udata);
+
+  /* Finish receiving boundary data from neighboring PEs */
+  BRecvWait(request, isubx, isuby, nvmxsub, uext, buffer);
+}
+
+/* fcalc routine. Compute f(t,y).  This routine assumes that communication 
+   between processors of data needed to calculate f has already been done,
+   and this data is in the work array uext. */
+
+static void fcalc(realtype t, realtype udata[],
+                  realtype dudata[], UserData data)
+{
+  realtype *uext;
+  realtype q3, c1, c2, c1dn, c2dn, c1up, c2up, c1lt, c2lt;
+  realtype c1rt, c2rt, cydn, cyup, hord1, hord2, horad1, horad2;
+  realtype qq1, qq2, qq3, qq4, rkin1, rkin2, s, vertd1, vertd2, ydn, yup;
+  realtype q4coef, dely, verdco, hordco, horaco;
+  int i, lx, ly, jy;
+  int isubx, isuby;
+  long int nvmxsub, nvmxsub2, offsetu, offsetue;
+
+  /* Get subgrid indices, data sizes, extended work array uext */
+  isubx = data->isubx;   isuby = data->isuby;
+  nvmxsub = data->nvmxsub; nvmxsub2 = data->nvmxsub2;
+  uext = data->uext;
+
+  /* Copy local segment of u vector into the working extended array uext */
+  offsetu = 0;
+  offsetue = nvmxsub2 + NVARS;
+  for (ly = 0; ly < MYSUB; ly++) {
+    for (i = 0; i < nvmxsub; i++) uext[offsetue+i] = udata[offsetu+i];
+    offsetu = offsetu + nvmxsub;
+    offsetue = offsetue + nvmxsub2;
+  }
+
+  /* To facilitate homogeneous Neumann boundary conditions, when this is
+  a boundary PE, copy data from the first interior mesh line of u to uext */
+
+  /* If isuby = 0, copy x-line 2 of u to uext */
+  if (isuby == 0) {
+    for (i = 0; i < nvmxsub; i++) uext[NVARS+i] = udata[nvmxsub+i];
+  }
+
+  /* If isuby = NPEY-1, copy x-line MYSUB-1 of u to uext */
+  if (isuby == NPEY-1) {
+    offsetu = (MYSUB-2)*nvmxsub;
+    offsetue = (MYSUB+1)*nvmxsub2 + NVARS;
+    for (i = 0; i < nvmxsub; i++) uext[offsetue+i] = udata[offsetu+i];
+  }
+
+  /* If isubx = 0, copy y-line 2 of u to uext */
+  if (isubx == 0) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetu = ly*nvmxsub + NVARS;
+      offsetue = (ly+1)*nvmxsub2;
+      for (i = 0; i < NVARS; i++) uext[offsetue+i] = udata[offsetu+i];
+    }
+  }
+
+  /* If isubx = NPEX-1, copy y-line MXSUB-1 of u to uext */
+  if (isubx == NPEX-1) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetu = (ly+1)*nvmxsub - 2*NVARS;
+      offsetue = (ly+2)*nvmxsub2 - NVARS;
+      for (i = 0; i < NVARS; i++) uext[offsetue+i] = udata[offsetu+i];
+    }
+  }
+
+  /* Make local copies of problem variables, for efficiency */
+  dely = data->dy;
+  verdco = data->vdco;
+  hordco  = data->hdco;
+  horaco  = data->haco;
+
+  /* Set diurnal rate coefficients as functions of t, and save q4 in 
+  data block for use by preconditioner evaluation routine */
+  s = sin((data->om)*t);
+  if (s > RCONST(0.0)) {
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
+  } else {
+    q3 = RCONST(0.0);
+    q4coef = RCONST(0.0);
+  }
+  data->q4 = q4coef;
+
+  /* Loop over all grid points in local subgrid */
+  for (ly = 0; ly < MYSUB; ly++) {
+
+    jy = ly + isuby*MYSUB;
+
+    /* Set vertical diffusion coefficients at jy +- 1/2 */
+    ydn = YMIN + (jy - RCONST(0.5))*dely;
+    yup = ydn + dely;
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
+    for (lx = 0; lx < MXSUB; lx++) {
+
+      /* Extract c1 and c2, and set kinetic rate terms */
+      offsetue = (lx+1)*NVARS + (ly+1)*nvmxsub2;
+      c1 = uext[offsetue];
+      c2 = uext[offsetue+1];
+      qq1 = Q1*c1*C3;
+      qq2 = Q2*c1*c2;
+      qq3 = q3*C3;
+      qq4 = q4coef*c2;
+      rkin1 = -qq1 - qq2 + RCONST(2.0)*qq3 + qq4;
+      rkin2 = qq1 - qq2 - qq4;
+
+      /* Set vertical diffusion terms */
+      c1dn = uext[offsetue-nvmxsub2];
+      c2dn = uext[offsetue-nvmxsub2+1];
+      c1up = uext[offsetue+nvmxsub2];
+      c2up = uext[offsetue+nvmxsub2+1];
+      vertd1 = cyup*(c1up - c1) - cydn*(c1 - c1dn);
+      vertd2 = cyup*(c2up - c2) - cydn*(c2 - c2dn);
+
+      /* Set horizontal diffusion and advection terms */
+      c1lt = uext[offsetue-2];
+      c2lt = uext[offsetue-1];
+      c1rt = uext[offsetue+2];
+      c2rt = uext[offsetue+3];
+      hord1 = hordco*(c1rt - RCONST(2.0)*c1 + c1lt);
+      hord2 = hordco*(c2rt - RCONST(2.0)*c2 + c2lt);
+      horad1 = horaco*(c1rt - c1lt);
+      horad2 = horaco*(c2rt - c2lt);
+
+      /* Load all terms into dudata */
+      offsetu = lx*NVARS + ly*nvmxsub;
+      dudata[offsetu]   = vertd1 + hord1 + horad1 + rkin1; 
+      dudata[offsetu+1] = vertd2 + hord2 + horad2 + rkin2;
+    }
+  }
+}
+
+
+/***************** Functions Called by the Solver *************************/
+
+/* f routine.  Evaluate f(t,y).  First call ucomm to do communication of 
+   subgrid boundary data into uext.  Then calculate f by a call to fcalc. */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
+{
+  realtype *udata, *dudata;
+  UserData data;
+
+  udata = N_VGetArrayPointer(u);
+  dudata = N_VGetArrayPointer(udot);
+  data = (UserData) user_data;
+
+  /* Call ucomm to do inter-processor communication */
+  ucomm(t, u, data);
+
+  /* Call fcalc to calculate all right-hand sides */
+  fcalc(t, udata, dudata, data);
+
+  return(0);
+}
+
+/* Preconditioner setup routine. Generate and preprocess P. */
+static int Precond(realtype tn, N_Vector u, N_Vector fu,
+                   booleantype jok, booleantype *jcurPtr, 
+                   realtype gamma, void *user_data, 
+                   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  realtype c1, c2, cydn, cyup, diag, ydn, yup, q4coef, dely, verdco, hordco;
+  realtype **(*P)[MYSUB], **(*Jbd)[MYSUB];
+  int nvmxsub, ier, offset;
+  long int *(*pivot)[MYSUB];
+  int lx, ly, jy, isuby;
+  realtype *udata, **a, **j;
+  UserData data;
+
+  /* Make local copies of pointers in user_data, pointer to u's data,
+     and PE index pair */
+  data = (UserData) user_data;
+  P = data->P;
+  Jbd = data->Jbd;
+  pivot = data->pivot;
+  udata = N_VGetArrayPointer(u);
+  isuby = data->isuby;
+  nvmxsub = data->nvmxsub;
+
+  if (jok) {
+
+  /* jok = TRUE: Copy Jbd to P */
+    for (ly = 0; ly < MYSUB; ly++)
+      for (lx = 0; lx < MXSUB; lx++)
+        denseCopy(Jbd[lx][ly], P[lx][ly], NVARS, NVARS);
+
+  *jcurPtr = FALSE;
+
+  }
+
+  else {
+
+  /* jok = FALSE: Generate Jbd from scratch and copy to P */
+
+  /* Make local copies of problem variables, for efficiency */
+  q4coef = data->q4;
+  dely = data->dy;
+  verdco = data->vdco;
+  hordco  = data->hdco;
+
+  /* Compute 2x2 diagonal Jacobian blocks (using q4 values 
+     computed on the last f call).  Load into P. */
+    for (ly = 0; ly < MYSUB; ly++) {
+      jy = ly + isuby*MYSUB;
+      ydn = YMIN + (jy - RCONST(0.5))*dely;
+      yup = ydn + dely;
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
+      diag = -(cydn + cyup + RCONST(2.0)*hordco);
+      for (lx = 0; lx < MXSUB; lx++) {
+        offset = lx*NVARS + ly*nvmxsub;
+        c1 = udata[offset];
+        c2 = udata[offset+1];
+        j = Jbd[lx][ly];
+        a = P[lx][ly];
+        IJth(j,1,1) = (-Q1*C3 - Q2*c2) + diag;
+        IJth(j,1,2) = -Q2*c1 + q4coef;
+        IJth(j,2,1) = Q1*C3 - Q2*c2;
+        IJth(j,2,2) = (-Q2*c1 - q4coef) + diag;
+        denseCopy(j, a, NVARS, NVARS);
+      }
+    }
+
+  *jcurPtr = TRUE;
+
+  }
+
+  /* Scale by -gamma */
+    for (ly = 0; ly < MYSUB; ly++)
+      for (lx = 0; lx < MXSUB; lx++)
+        denseScale(-gamma, P[lx][ly], NVARS, NVARS);
+
+  /* Add identity matrix and do LU decompositions on blocks in place */
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      denseAddIdentity(P[lx][ly], NVARS);
+      ier = denseGETRF(P[lx][ly], NVARS, NVARS, pivot[lx][ly]);
+      if (ier != 0) return(1);
+    }
+  }
+
+  return(0);
+}
+
+/* Preconditioner solve routine */
+static int PSolve(realtype tn, N_Vector u, N_Vector fu, 
+                  N_Vector r, N_Vector z, 
+                  realtype gamma, realtype delta,
+                  int lr, void *user_data, N_Vector vtemp)
+{
+  realtype **(*P)[MYSUB];
+  int nvmxsub;
+  long int *(*pivot)[MYSUB];
+  int lx, ly;
+  realtype *zdata, *v;
+  UserData data;
+
+  /* Extract the P and pivot arrays from user_data */
+  data = (UserData) user_data;
+  P = data->P;
+  pivot = data->pivot;
+
+  /* Solve the block-diagonal system Px = r using LU factors stored
+     in P and pivot data in pivot, and return the solution in z.
+     First copy vector r to z. */
+  N_VScale(RCONST(1.0), r, z);
+
+  nvmxsub = data->nvmxsub;
+  zdata = N_VGetArrayPointer(z);
+
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      v = &(zdata[lx*NVARS + ly*nvmxsub]);
+      denseGETRS(P[lx][ly], NVARS, pivot[lx][ly], v);
+    }
+  }
+
+  return(0);
+}
+
+
+/*********************** Private Helper Function ************************/
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+	    id, funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed with flag = %d\n\n",
+	      id, funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+	    id, funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_p.out
new file mode 100644
index 0000000..de34bc8
--- /dev/null
+++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.out
@@ -0,0 +1,63 @@
+
+2-species diurnal advection-diffusion problem
+
+t = 7.20e+03   no. steps = 979   stepsize = 3.07e+00
+At bottom left:  c1, c2 =    1.047e+04    2.527e+11 
+At top right:    c1, c2 =    1.119e+04    2.700e+11 
+
+t = 1.44e+04   no. steps = 2735   stepsize = 6.93e+00
+At bottom left:  c1, c2 =    6.659e+06    2.582e+11 
+At top right:    c1, c2 =    7.301e+06    2.833e+11 
+
+t = 2.16e+04   no. steps = 3533   stepsize = 1.05e+01
+At bottom left:  c1, c2 =    2.665e+07    2.993e+11 
+At top right:    c1, c2 =    2.931e+07    3.313e+11 
+
+t = 2.88e+04   no. steps = 4593   stepsize = 3.95e+00
+At bottom left:  c1, c2 =    8.702e+06    3.380e+11 
+At top right:    c1, c2 =    9.650e+06    3.751e+11 
+
+t = 3.60e+04   no. steps = 5950   stepsize = 2.56e+00
+At bottom left:  c1, c2 =    1.404e+04    3.387e+11 
+At top right:    c1, c2 =    1.561e+04    3.765e+11 
+
+t = 4.32e+04   no. steps = 7138   stepsize = 4.42e+02
+At bottom left:  c1, c2 =   -1.581e-07    3.382e+11 
+At top right:    c1, c2 =    1.503e-07    3.804e+11 
+
+t = 5.04e+04   no. steps = 7155   stepsize = 5.12e+02
+At bottom left:  c1, c2 =   -2.237e-17    3.358e+11 
+At top right:    c1, c2 =    9.286e-17    3.864e+11 
+
+t = 5.76e+04   no. steps = 7170   stepsize = 3.90e+02
+At bottom left:  c1, c2 =    4.963e-18    3.320e+11 
+At top right:    c1, c2 =   -1.508e-17    3.909e+11 
+
+t = 6.48e+04   no. steps = 7184   stepsize = 5.91e+02
+At bottom left:  c1, c2 =   -3.047e-20    3.313e+11 
+At top right:    c1, c2 =   -1.306e-18    3.963e+11 
+
+t = 7.20e+04   no. steps = 7196   stepsize = 5.91e+02
+At bottom left:  c1, c2 =    2.184e-19    3.330e+11 
+At top right:    c1, c2 =   -6.748e-18    4.039e+11 
+
+t = 7.92e+04   no. steps = 7208   stepsize = 5.91e+02
+At bottom left:  c1, c2 =    6.659e-19    3.334e+11 
+At top right:    c1, c2 =   -6.289e-18    4.120e+11 
+
+t = 8.64e+04   no. steps = 7220   stepsize = 5.91e+02
+At bottom left:  c1, c2 =   -2.252e-28    3.352e+11 
+At top right:    c1, c2 =   -1.129e-28    4.163e+11 
+
+
+Final Statistics: 
+
+lenrw   =  3058     leniw   =   160
+lenrwls =  2046     leniwls =    80
+nst     =  7220     nfe     =     0
+nfi     = 75855     nfels   = 88509
+nni     = 39606     nli     = 88509
+nsetups =   442     netf    =    29
+npe     =   122     nps     = 125772
+ncfn    =     0     ncfl    =     0
+
diff --git a/examples/arkode/C_parhyp/CMakeLists.txt b/examples/arkode/C_parhyp/CMakeLists.txt
new file mode 100644
index 0000000..b34b640
--- /dev/null
+++ b/examples/arkode/C_parhyp/CMakeLists.txt
@@ -0,0 +1,146 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for ARKODE parhyp C examples
+
+
+# Add variable ARKODE_examples with the names of the parhyp ARKODE examples
+# "name\;nodes\;tasks"
+SET(ARKODE_examples
+  "ark_diurnal_kry_ph\;1\;4"
+#  "ark_diurnal_kry_bbd_ph\;1\;4"
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+SET(ARKODE_extras
+  # none yet
+  )
+
+# Check whether we use MPI compiler scripts.
+# If yes, then change the C compiler to the MPICC script.
+# If not, then add the MPI include directory for MPI headers.
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICC)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECP_LIB sundials_nvecparhyp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECP_LIB sundials_nvecparhyp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
+SET(HYPRE_LIBS ${HYPRE_LIBRARIES})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each ARKODE example
+FOREACH(example_tuple ${ARKODE_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  TARGET_LINK_LIBRARIES(${example} ${HYPRE_LIBS})
+  IF(NOT MPI_MPICC)
+    TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
+  ENDIF(NOT MPI_MPICC)
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parhyp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example_tuple ${ARKODE_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parhyp)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parhyp)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  FOREACH(example_tuple ${ARKODE_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${ARKODE_examples})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parhyp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_parhyp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_parhyp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parhyp 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parhyp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_parhyp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_parhyp/Makefile_ex
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_parhyp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/C_parhyp/README b/examples/arkode/C_parhyp/README
new file mode 100644
index 0000000..20608f4
--- /dev/null
+++ b/examples/arkode/C_parhyp/README
@@ -0,0 +1,50 @@
+List of parallel ARKODE C examples
+
+  ark_diurnal_kry_ph     : 2-D 2-species diurnal advection-diffusion
+
+Sample results:
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c
new file mode 100644
index 0000000..f8df6a2
--- /dev/null
+++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c
@@ -0,0 +1,1009 @@
+/*-----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds, Jean Sexton @ SMU
+ *                Slaven Peles @ LLNL
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ *
+ * An ODE system is generated from the following 2-species diurnal
+ * kinetics advection-diffusion PDE system in 2 space dimensions:
+ *
+ * dc(i)/dt = Kh*(d/dx)^2 c(i) + V*dc(i)/dx + (d/dy)(Kv(y)*dc(i)/dy)
+ *                 + Ri(c1,c2,t)      for i = 1,2,   where
+ *   R1(c1,c2,t) = -q1*c1*c3 - q2*c1*c2 + 2*q3(t)*c3 + q4(t)*c2 ,
+ *   R2(c1,c2,t) =  q1*c1*c3 - q2*c1*c2 - q4(t)*c2 ,
+ *   Kv(y) = Kv0*exp(y/5) ,
+ * Kh, V, Kv0, q1, q2, and c3 are constants, and q3(t) and q4(t)
+ * vary diurnally. The problem is posed on the square
+ *   0 <= x <= 20,    30 <= y <= 50   (all in km),
+ * with homogeneous Neumann boundary conditions, and for time t in
+ *   0 <= t <= 86400 sec (1 day).
+ * The PDE system is treated by central differences on a uniform
+ * mesh, with simple polynomial initial profiles.
+ *
+ * The problem is solved by ARKODE on NPE processors, treated
+ * as a rectangular process grid of size NPEX by NPEY, with
+ * NPE = NPEX*NPEY. Each processor contains a subgrid of size MXSUB
+ * by MYSUB of the (x,y) mesh.  Thus the actual mesh sizes are
+ * MX = MXSUB*NPEX and MY = MYSUB*NPEY, and the ODE system size is
+ * neq = 2*MX*MY.
+ *
+ * The solution is done with the DIRK/GMRES method (i.e. using the
+ * ARKSPGMR linear solver) and the block-diagonal part of the
+ * Newton matrix as a left preconditioner. A copy of the
+ * block-diagonal part of the Jacobian is saved and conditionally
+ * reused within the preconditioner routine.
+ *
+ * Performance data and sampled solution values are printed at
+ * selected output times, and all performance counters are printed
+ * on completion.
+ *
+ * This example uses Hypre vector and MPI parallelization. User is 
+ * expected to be familiar with the Hypre library. 
+ * 
+ * Execution: mpiexec -n N ark_diurnal_kry_p   with N = NPEX*NPEY
+ * (see constants below).
+ *---------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>             /* prototypes for ARKODE fcts. */
+#include <arkode/arkode_spgmr.h>       /* prototypes & constants for ARKSPGMR  */
+#include <nvector/nvector_parhyp.h>    /* declaration of N_Vector  */
+#include <sundials/sundials_dense.h>   /* prototypes for small dense fcts. */
+#include <sundials/sundials_types.h>   /* definitions of realtype, booleantype */
+#include <sundials/sundials_math.h>    /* definition of macros SUNSQR and EXP */
+#include <mpi.h>                       /* MPI constants and types */
+
+#include <HYPRE.h>
+#include <HYPRE_IJ_mv.h>
+
+/* Problem Constants */
+#define NVARS        2                    /* number of species         */
+#define KH           RCONST(4.0e-6)       /* horizontal diffusivity Kh */
+#define VEL          RCONST(0.001)        /* advection velocity V      */
+#define KV0          RCONST(1.0e-8)       /* coefficient in Kv(y)      */
+#define Q1           RCONST(1.63e-16)     /* coefficients q1, q2, c3   */ 
+#define Q2           RCONST(4.66e-16)
+#define C3           RCONST(3.7e16)
+#define A3           RCONST(22.62)        /* coefficient in expression for q3(t) */
+#define A4           RCONST(7.601)        /* coefficient in expression for q4(t) */
+#define C1_SCALE     RCONST(1.0e6)        /* coefficients in initial profiles    */
+#define C2_SCALE     RCONST(1.0e12)
+
+#define T0           RCONST(0.0)          /* initial time */
+#define NOUT         12                   /* number of output times */
+#define TWOHR        RCONST(7200.0)       /* number of seconds in two hours  */
+#define HALFDAY      RCONST(4.32e4)       /* number of seconds in a half day */
+#define PI       RCONST(3.1415926535898)  /* pi */ 
+
+#define XMIN         RCONST(0.0)          /* grid boundaries in x  */
+#define XMAX         RCONST(20.0)           
+#define YMIN         RCONST(30.0)         /* grid boundaries in y  */
+#define YMAX         RCONST(50.0)
+
+#define NPEX         2                    /* no. PEs in x direction of PE array */
+#define NPEY         2                    /* no. PEs in y direction of PE array */
+                                          /* Total no. PEs = NPEX*NPEY */
+#define MXSUB        5                    /* no. x points per subgrid */
+#define MYSUB        5                    /* no. y points per subgrid */
+
+#define MX           (NPEX*MXSUB)         /* MX = number of x mesh points */
+#define MY           (NPEY*MYSUB)         /* MY = number of y mesh points */
+                                          /* Spatial mesh is MX by MY */
+
+/* ARKodeInit Constants */
+#define RTOL    RCONST(1.0e-5)            /* scalar relative tolerance */
+#define FLOOR   RCONST(100.0)             /* value of C1 or C2 at which tolerances */
+                                          /* change from relative to absolute      */
+#define ATOL    (RTOL*FLOOR)              /* scalar absolute tolerance */
+
+
+/* User-defined matrix accessor macro: IJth 
+
+   IJth is defined in order to write code which indexes into dense
+   matrices with a (row,column) pair, where 1 <= row,column <= NVARS.   
+
+   IJth(a,i,j) references the (i,j)th entry of the small matrix realtype **a,
+   where 1 <= i,j <= NVARS. The small matrix routines in sundials_dense.h
+   work with matrices stored by column in a 2-dimensional array. In C,
+   arrays are indexed starting at 0, not 1. */
+#define IJth(a,i,j) (a[j-1][i-1])
+
+/* Type : UserData 
+   contains problem constants, preconditioner blocks, pivot arrays, 
+   grid constants, and processor indices, as well as data needed
+   for the preconditiner */
+typedef struct {
+
+  realtype q4, om, dx, dy, hdco, haco, vdco;
+  realtype uext[NVARS*(MXSUB+2)*(MYSUB+2)];
+  int my_pe, isubx, isuby;
+  int nvmxsub, nvmxsub2;
+  MPI_Comm comm;
+
+  /* For preconditioner */
+  realtype **P[MXSUB][MYSUB], **Jbd[MXSUB][MYSUB];
+  long int *pivot[MXSUB][MYSUB];
+
+} *UserData;
+
+/* Private Helper Functions */
+static void InitUserData(int my_pe, MPI_Comm comm, UserData data);
+static void FreeUserData(UserData data);
+static void SetInitialProfiles(HYPRE_IJVector Uij, UserData data, long int local_length, 
+                               long int my_base);
+static void PrintOutput(void *arkode_mem, int my_pe, MPI_Comm comm,
+                        N_Vector u, realtype t);
+static void PrintFinalStats(void *arkode_mem);
+static void BSend(MPI_Comm comm, 
+                  int my_pe, int isubx, int isuby, 
+                  long int dsizex, long int dsizey,
+                  realtype udata[]);
+static void BRecvPost(MPI_Comm comm, MPI_Request request[], 
+                      int my_pe, int isubx, int isuby,
+                      long int dsizex, long int dsizey,
+                      realtype uext[], realtype buffer[]);
+static void BRecvWait(MPI_Request request[], 
+                      int isubx, int isuby, 
+                      long int dsizex, realtype uext[],
+                      realtype buffer[]);
+static void ucomm(realtype t, N_Vector u, UserData data);
+static void fcalc(realtype t, realtype udata[], realtype dudata[],
+                  UserData data);
+
+
+/* Functions Called by the Solver */
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
+static int Precond(realtype tn, N_Vector u, N_Vector fu,
+                   booleantype jok, booleantype *jcurPtr, 
+                   realtype gamma, void *user_data, 
+                   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+static int PSolve(realtype tn, N_Vector u, N_Vector fu, 
+                  N_Vector r, N_Vector z, 
+                  realtype gamma, realtype delta,
+                  int lr, void *user_data, N_Vector vtemp);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
+
+
+/***************************** Main Program ******************************/
+int main(int argc, char *argv[])
+{
+  realtype abstol, reltol, t, tout;
+  N_Vector u;
+  UserData data;
+  void *arkode_mem;
+  int iout, flag;
+  MPI_Comm comm;
+  
+  HYPRE_Int local_N, npes, my_pe;
+  HYPRE_ParVector Upar; /* Declare HYPRE parallel vector */
+  HYPRE_IJVector  Uij;  /* Declare "IJ" interface to HYPRE vector */
+
+  u = NULL;
+  data = NULL;
+  arkode_mem = NULL;
+
+  /* Set problem size neq */
+  /* neq = NVARS*MX*MY;   */
+
+  /* Get processor number and total number of pe's */
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &npes);
+  MPI_Comm_rank(comm, &my_pe);
+
+  if (npes != NPEX*NPEY) {
+    if (my_pe == 0)
+      fprintf(stderr, "\nMPI_ERROR(0): npes = %d is not equal to NPEX*NPEY = %d\n\n",
+              npes,NPEX*NPEY);
+    MPI_Finalize();
+    return(1);
+  }
+
+  /* Set local length */
+  local_N = NVARS*MXSUB*MYSUB;
+
+  /* Allocate hypre vector */
+  HYPRE_IJVectorCreate(comm, my_pe*local_N, (my_pe + 1)*local_N - 1, &Uij);
+  HYPRE_IJVectorSetObjectType(Uij, HYPRE_PARCSR);
+  HYPRE_IJVectorInitialize(Uij);
+
+  /* Allocate and load user data block; allocate preconditioner block */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2, my_pe)) MPI_Abort(comm, 1);
+  InitUserData(my_pe, comm, data);
+
+  /* Set initial values and allocate u */ 
+  SetInitialProfiles(Uij, data, local_N, my_pe*local_N);
+  HYPRE_IJVectorAssemble(Uij);
+  HYPRE_IJVectorGetObject(Uij, (void**) &Upar);
+
+  u = N_VMake_ParHyp(Upar);  /* Create wrapper u around hypre vector */
+  if (check_flag((void *)u, "N_VNew", 0, my_pe)) MPI_Abort(comm, 1);
+
+  /* Set tolerances */
+  abstol = ATOL; reltol = RTOL;
+
+  /* Call ARKodeCreate to create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0, my_pe)) MPI_Abort(comm, 1);
+
+  /* Set the pointer to user-defined data */
+  flag = ARKodeSetUserData(arkode_mem, data);
+  if (check_flag(&flag, "ARKodeSetUserData", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     user's right hand side functions in u'=fe(t,u)+fi(t,u) [here fe is NULL], 
+     the inital time T0, and the initial dependent variable vector u. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, u);
+  if(check_flag(&flag, "ARKodeInit", 1, my_pe)) return(1);
+
+  /* Call ARKodeSetMaxNumSteps to increase default */
+  flag = ARKodeSetMaxNumSteps(arkode_mem, 1000000);
+  if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1, my_pe)) return(1);
+
+  /* Call ARKodeSStolerances to specify the scalar relative tolerance
+     and scalar absolute tolerances */
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);
+  if (check_flag(&flag, "ARKodeSStolerances", 1, my_pe)) return(1);
+
+  /* Call ARKSpgmr to specify the linear solver ARKSPGMR 
+     with left preconditioning and the default Krylov dimension maxl */
+  flag = ARKSpgmr(arkode_mem, PREC_LEFT, 0);
+  if (check_flag(&flag, "ARKSpgmr", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Set preconditioner setup and solve routines Precond and PSolve, 
+     and the pointer to the user-defined block data */
+  flag = ARKSpilsSetPreconditioner(arkode_mem, Precond, PSolve);
+  if (check_flag(&flag, "ARKSpilsSetPreconditioner", 1, my_pe)) MPI_Abort(comm, 1);
+
+  if (my_pe == 0)
+    printf("\n2-species diurnal advection-diffusion problem\n\n");
+
+  /* In loop over output points, call ARKode, print results, test for error */
+  for (iout=1, tout=TWOHR; iout<=NOUT; iout++, tout+=TWOHR) {
+    flag = ARKode(arkode_mem, tout, u, &t, ARK_NORMAL);
+    if (check_flag(&flag, "ARKode", 1, my_pe)) break;
+    PrintOutput(arkode_mem, my_pe, comm, u, t);
+  }
+
+  /* Print final statistics */  
+  if (my_pe == 0) PrintFinalStats(arkode_mem);
+
+  /* Free memory */
+  N_VDestroy(u);              /* Free hypre vector wrapper */
+  HYPRE_IJVectorDestroy(Uij); /* Free the underlying hypre vector */
+  FreeUserData(data);
+  ARKodeFree(&arkode_mem);
+  MPI_Finalize();
+  return(0);
+}
+
+/*********************** Private Helper Functions ************************/
+
+/* Load constants in data */
+static void InitUserData(int my_pe, MPI_Comm comm, UserData data)
+{
+  int isubx, isuby;
+  int lx, ly;
+
+  /* Set problem constants */
+  data->om = PI/HALFDAY;
+  data->dx = (XMAX-XMIN)/((realtype)(MX-1));
+  data->dy = (YMAX-YMIN)/((realtype)(MY-1));
+  data->hdco = KH/SUNSQR(data->dx);
+  data->haco = VEL/(RCONST(2.0)*data->dx);
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
+
+  /* Set machine-related constants */
+  data->comm = comm;
+  data->my_pe = my_pe;
+
+  /* isubx and isuby are the PE grid indices corresponding to my_pe */
+  isuby = my_pe/NPEX;
+  isubx = my_pe - isuby*NPEX;
+  data->isubx = isubx;
+  data->isuby = isuby;
+
+  /* Set the sizes of a boundary x-line in u and uext */
+  data->nvmxsub = NVARS*MXSUB;
+  data->nvmxsub2 = NVARS*(MXSUB+2);
+
+  /* Preconditioner-related fields */
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      (data->P)[lx][ly] = newDenseMat(NVARS, NVARS);
+      (data->Jbd)[lx][ly] = newDenseMat(NVARS, NVARS);
+      (data->pivot)[lx][ly] = newLintArray(NVARS);
+    }
+  }
+}
+
+/* Free user data memory */
+static void FreeUserData(UserData data)
+{
+  int lx, ly;
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      destroyMat((data->P)[lx][ly]);
+      destroyMat((data->Jbd)[lx][ly]);
+      destroyArray((data->pivot)[lx][ly]);
+    }
+  }
+  free(data);
+}
+
+/* Set initial conditions in u */
+static void SetInitialProfiles(HYPRE_IJVector Uij, UserData data, long int local_length, 
+                               long int my_base)
+{
+  int isubx, isuby, lx, ly, jx, jy;
+  long int offset;
+  realtype dx, dy, x, y, cx, cy, xmid, ymid;
+  realtype *udata;
+  HYPRE_Int *iglobal;
+
+  /* Set pointer to data array in vector u */
+  udata   = (realtype*) malloc(local_length*sizeof(realtype));
+  iglobal = (HYPRE_Int*) malloc(local_length*sizeof(HYPRE_Int));
+  
+
+  /* Get mesh spacings, and subgrid indices for this PE */
+  dx = data->dx;         dy = data->dy;
+  isubx = data->isubx;   isuby = data->isuby;
+
+  /* Load initial profiles of c1 and c2 into local u vector.
+  Here lx and ly are local mesh point indices on the local subgrid,
+  and jx and jy are the global mesh point indices. */
+  offset = 0;
+  xmid = RCONST(0.5)*(XMIN + XMAX);
+  ymid = RCONST(0.5)*(YMIN + YMAX);
+  for (ly = 0; ly < MYSUB; ly++) {
+    jy = ly + isuby*MYSUB;
+    y = YMIN + jy*dy;
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
+    for (lx = 0; lx < MXSUB; lx++) {
+      jx = lx + isubx*MXSUB;
+      x = XMIN + jx*dx;
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
+      iglobal[offset] = my_base + offset;
+      udata[offset++] = C1_SCALE*cx*cy; 
+      iglobal[offset] = my_base + offset;
+      udata[offset++] = C2_SCALE*cx*cy;
+    }
+  }
+  HYPRE_IJVectorSetValues(Uij, local_length, iglobal, udata);
+  free(iglobal);
+  free(udata);
+}
+
+/* Print current t, step count, order, stepsize, and sampled c1,c2 values */
+static void PrintOutput(void *arkode_mem, int my_pe, MPI_Comm comm,
+                        N_Vector u, realtype t)
+{
+  int flag;
+  realtype hu, *udata, tempu[2];
+  int npelast;
+  long int i0, i1, nst;
+  MPI_Status status;
+  HYPRE_ParVector uhyp;
+  
+  npelast = NPEX*NPEY - 1;
+
+  uhyp  = N_VGetVector_ParHyp(u);
+  udata = hypre_VectorData(hypre_ParVectorLocalVector(uhyp));
+
+  /* Send c1,c2 at top right mesh point to PE 0 */
+  if (my_pe == npelast) {
+    i0 = NVARS*MXSUB*MYSUB - 2;
+    i1 = i0 + 1;
+    if (npelast != 0)
+      MPI_Send(&udata[i0], 2, PVEC_REAL_MPI_TYPE, 0, 0, comm);
+    else {
+      tempu[0] = udata[i0];
+      tempu[1] = udata[i1];
+    }
+  }
+
+  /* On PE 0, receive c1,c2 at top right, then print performance data
+     and sampled solution values */ 
+  if (my_pe == 0) {
+    if (npelast != 0)
+      MPI_Recv(&tempu[0], 2, PVEC_REAL_MPI_TYPE, npelast, 0, comm, &status);
+    flag = ARKodeGetNumSteps(arkode_mem, &nst);
+    check_flag(&flag, "ARKodeGetNumSteps", 1, my_pe);
+    flag = ARKodeGetLastStep(arkode_mem, &hu);
+    check_flag(&flag, "ARKodeGetLastStep", 1, my_pe);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf("t = %.2Le   no. steps = %ld   stepsize = %.2Le\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3Le %12.3Le \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf("t = %.2e   no. steps = %ld   stepsize = %.2e\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
+#else
+    printf("t = %.2e   no. steps = %ld   stepsize = %.2e\n",
+           t, nst, hu);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
+#endif
+  }
+}
+
+/* Print final statistics contained in iopt */
+static void PrintFinalStats(void *arkode_mem)
+{
+  long int lenrw, leniw ;
+  long int lenrwLS, leniwLS;
+  long int nst, nfe, nfi, nsetups, nni, ncfn, netf;
+  long int nli, npe, nps, ncfl, nfeLS;
+  int flag;
+
+  flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw);
+  check_flag(&flag, "ARKodeGetWorkSpace", 1, 0);
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1, 0);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1, 0);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1, 0);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1, 0);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1, 0);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1, 0);
+
+  flag = ARKSpilsGetWorkSpace(arkode_mem, &lenrwLS, &leniwLS);
+  check_flag(&flag, "ARKSpilsGetWorkSpace", 1, 0);
+  flag = ARKSpilsGetNumLinIters(arkode_mem, &nli);
+  check_flag(&flag, "ARKSpilsGetNumLinIters", 1, 0);
+  flag = ARKSpilsGetNumPrecEvals(arkode_mem, &npe);
+  check_flag(&flag, "ARKSpilsGetNumPrecEvals", 1, 0);
+  flag = ARKSpilsGetNumPrecSolves(arkode_mem, &nps);
+  check_flag(&flag, "ARKSpilsGetNumPrecSolves", 1, 0);
+  flag = ARKSpilsGetNumConvFails(arkode_mem, &ncfl);
+  check_flag(&flag, "ARKSpilsGetNumConvFails", 1, 0);
+  flag = ARKSpilsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKSpilsGetNumRhsEvals", 1, 0);
+
+  printf("\nFinal Statistics: \n\n");
+  printf("lenrw   = %5ld     leniw   = %5ld\n", lenrw, leniw);
+  printf("lenrwls = %5ld     leniwls = %5ld\n", lenrwLS, leniwLS);
+  printf("nst     = %5ld     nfe     = %5ld\n", nst, nfe);
+  printf("nfi     = %5ld     nfels   = %5ld\n", nfi, nfeLS);
+  printf("nni     = %5ld     nli     = %5ld\n", nni, nli);
+  printf("nsetups = %5ld     netf    = %5ld\n", nsetups, netf);
+  printf("npe     = %5ld     nps     = %5ld\n", npe, nps);
+  printf("ncfn    = %5ld     ncfl    = %5ld\n\n", ncfn, ncfl); 
+}
+ 
+/* Routine to send boundary data to neighboring PEs */
+static void BSend(MPI_Comm comm, 
+                  int my_pe, int isubx, int isuby, 
+                  long int dsizex, long int dsizey,
+                  realtype udata[])
+{
+  int i, ly;
+  long int offsetu, offsetbuf;
+  realtype bufleft[NVARS*MYSUB], bufright[NVARS*MYSUB];
+
+  /* If isuby > 0, send data from bottom x-line of u */
+  if (isuby != 0)
+    MPI_Send(&udata[0], dsizex, PVEC_REAL_MPI_TYPE, my_pe-NPEX, 0, comm);
+
+  /* If isuby < NPEY-1, send data from top x-line of u */
+  if (isuby != NPEY-1) {
+    offsetu = (MYSUB-1)*dsizex;
+    MPI_Send(&udata[offsetu], dsizex, PVEC_REAL_MPI_TYPE, my_pe+NPEX, 0, comm);
+  }
+
+  /* If isubx > 0, send data from left y-line of u (via bufleft) */
+  if (isubx != 0) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetu = ly*dsizex;
+      for (i = 0; i < NVARS; i++)
+        bufleft[offsetbuf+i] = udata[offsetu+i];
+    }
+    MPI_Send(&bufleft[0], dsizey, PVEC_REAL_MPI_TYPE, my_pe-1, 0, comm);   
+  }
+
+  /* If isubx < NPEX-1, send data from right y-line of u (via bufright) */
+  if (isubx != NPEX-1) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetu = offsetbuf*MXSUB + (MXSUB-1)*NVARS;
+      for (i = 0; i < NVARS; i++)
+        bufright[offsetbuf+i] = udata[offsetu+i];
+    }
+    MPI_Send(&bufright[0], dsizey, PVEC_REAL_MPI_TYPE, my_pe+1, 0, comm);   
+  }
+}
+ 
+/* Routine to start receiving boundary data from neighboring PEs.
+   Notes:
+   1) buffer should be able to hold 2*NVARS*MYSUB realtype entries, should be
+   passed to both the BRecvPost and BRecvWait functions, and should not
+   be manipulated between the two calls.
+   2) request should have 4 entries, and should be passed in both calls also. */
+
+static void BRecvPost(MPI_Comm comm, MPI_Request request[], 
+                      int my_pe, int isubx, int isuby,
+                      long int dsizex, long int dsizey,
+                      realtype uext[], realtype buffer[])
+{
+  long int offsetue;
+  /* Have bufleft and bufright use the same buffer */
+  realtype *bufleft = buffer, *bufright = buffer+NVARS*MYSUB;
+
+  /* If isuby > 0, receive data for bottom x-line of uext */
+  if (isuby != 0)
+    MPI_Irecv(&uext[NVARS], dsizex, PVEC_REAL_MPI_TYPE,
+              my_pe-NPEX, 0, comm, &request[0]);
+
+  /* If isuby < NPEY-1, receive data for top x-line of uext */
+  if (isuby != NPEY-1) {
+    offsetue = NVARS*(1 + (MYSUB+1)*(MXSUB+2));
+    MPI_Irecv(&uext[offsetue], dsizex, PVEC_REAL_MPI_TYPE,
+                                         my_pe+NPEX, 0, comm, &request[1]);
+  }
+
+  /* If isubx > 0, receive data for left y-line of uext (via bufleft) */
+  if (isubx != 0) {
+    MPI_Irecv(&bufleft[0], dsizey, PVEC_REAL_MPI_TYPE,
+                                         my_pe-1, 0, comm, &request[2]);
+  }
+
+  /* If isubx < NPEX-1, receive data for right y-line of uext (via bufright) */
+  if (isubx != NPEX-1) {
+    MPI_Irecv(&bufright[0], dsizey, PVEC_REAL_MPI_TYPE,
+                                         my_pe+1, 0, comm, &request[3]);
+  }
+}
+
+/* Routine to finish receiving boundary data from neighboring PEs.
+   Notes:
+   1) buffer should be able to hold 2*NVARS*MYSUB realtype entries, should be
+   passed to both the BRecvPost and BRecvWait functions, and should not
+   be manipulated between the two calls.
+   2) request should have 4 entries, and should be passed in both calls also. */
+
+static void BRecvWait(MPI_Request request[], 
+                      int isubx, int isuby, 
+                      long int dsizex, realtype uext[],
+                      realtype buffer[])
+{
+  int i, ly;
+  long int dsizex2, offsetue, offsetbuf;
+  realtype *bufleft = buffer, *bufright = buffer+NVARS*MYSUB;
+  MPI_Status status;
+
+  dsizex2 = dsizex + 2*NVARS;
+
+  /* If isuby > 0, receive data for bottom x-line of uext */
+  if (isuby != 0)
+    MPI_Wait(&request[0],&status);
+
+  /* If isuby < NPEY-1, receive data for top x-line of uext */
+  if (isuby != NPEY-1)
+    MPI_Wait(&request[1],&status);
+
+  /* If isubx > 0, receive data for left y-line of uext (via bufleft) */
+  if (isubx != 0) {
+    MPI_Wait(&request[2],&status);
+
+    /* Copy the buffer to uext */
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetue = (ly+1)*dsizex2;
+      for (i = 0; i < NVARS; i++)
+        uext[offsetue+i] = bufleft[offsetbuf+i];
+    }
+  }
+
+  /* If isubx < NPEX-1, receive data for right y-line of uext (via bufright) */
+  if (isubx != NPEX-1) {
+    MPI_Wait(&request[3],&status);
+
+    /* Copy the buffer to uext */
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetbuf = ly*NVARS;
+      offsetue = (ly+2)*dsizex2 - NVARS;
+      for (i = 0; i < NVARS; i++)
+        uext[offsetue+i] = bufright[offsetbuf+i];
+    }
+  }
+}
+
+
+/* ucomm routine.  This routine performs all communication 
+   between processors of data needed to calculate f. */
+
+static void ucomm(realtype t, N_Vector u, UserData data)
+{
+
+  realtype *udata, *uext, buffer[2*NVARS*MYSUB];
+  MPI_Comm comm;
+  int my_pe, isubx, isuby;
+  long int nvmxsub, nvmysub;
+  MPI_Request request[4];
+  HYPRE_ParVector uhyp;
+  
+  uhyp  = N_VGetVector_ParHyp(u);
+  udata = hypre_VectorData(hypre_ParVectorLocalVector(uhyp));
+
+  /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
+  comm = data->comm;  my_pe = data->my_pe;
+  isubx = data->isubx;   isuby = data->isuby;
+  nvmxsub = data->nvmxsub;
+  nvmysub = NVARS*MYSUB;
+  uext = data->uext;
+
+  /* Start receiving boundary data from neighboring PEs */
+  BRecvPost(comm, request, my_pe, isubx, isuby, nvmxsub, nvmysub, uext, buffer);
+
+  /* Send data from boundary of local grid to neighboring PEs */
+  BSend(comm, my_pe, isubx, isuby, nvmxsub, nvmysub, udata);
+
+  /* Finish receiving boundary data from neighboring PEs */
+  BRecvWait(request, isubx, isuby, nvmxsub, uext, buffer);
+}
+
+
+/* fcalc routine. Compute f(t,y).  This routine assumes that communication 
+   between processors of data needed to calculate f has already been done,
+   and this data is in the work array uext. */
+
+static void fcalc(realtype t, realtype udata[],
+                  realtype dudata[], UserData data)
+{
+  realtype *uext;
+  realtype q3, c1, c2, c1dn, c2dn, c1up, c2up, c1lt, c2lt;
+  realtype c1rt, c2rt, cydn, cyup, hord1, hord2, horad1, horad2;
+  realtype qq1, qq2, qq3, qq4, rkin1, rkin2, s, vertd1, vertd2, ydn, yup;
+  realtype q4coef, dely, verdco, hordco, horaco;
+  int i, lx, ly, jy;
+  int isubx, isuby;
+  long int nvmxsub, nvmxsub2, offsetu, offsetue;
+
+  /* Get subgrid indices, data sizes, extended work array uext */
+  isubx = data->isubx;   isuby = data->isuby;
+  nvmxsub = data->nvmxsub; nvmxsub2 = data->nvmxsub2;
+  uext = data->uext;
+
+  /* Copy local segment of u vector into the working extended array uext */
+  offsetu = 0;
+  offsetue = nvmxsub2 + NVARS;
+  for (ly = 0; ly < MYSUB; ly++) {
+    for (i = 0; i < nvmxsub; i++) uext[offsetue+i] = udata[offsetu+i];
+    offsetu = offsetu + nvmxsub;
+    offsetue = offsetue + nvmxsub2;
+  }
+
+  /* To facilitate homogeneous Neumann boundary conditions, when this is
+  a boundary PE, copy data from the first interior mesh line of u to uext */
+
+  /* If isuby = 0, copy x-line 2 of u to uext */
+  if (isuby == 0) {
+    for (i = 0; i < nvmxsub; i++) uext[NVARS+i] = udata[nvmxsub+i];
+  }
+
+  /* If isuby = NPEY-1, copy x-line MYSUB-1 of u to uext */
+  if (isuby == NPEY-1) {
+    offsetu = (MYSUB-2)*nvmxsub;
+    offsetue = (MYSUB+1)*nvmxsub2 + NVARS;
+    for (i = 0; i < nvmxsub; i++) uext[offsetue+i] = udata[offsetu+i];
+  }
+
+  /* If isubx = 0, copy y-line 2 of u to uext */
+  if (isubx == 0) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetu = ly*nvmxsub + NVARS;
+      offsetue = (ly+1)*nvmxsub2;
+      for (i = 0; i < NVARS; i++) uext[offsetue+i] = udata[offsetu+i];
+    }
+  }
+
+  /* If isubx = NPEX-1, copy y-line MXSUB-1 of u to uext */
+  if (isubx == NPEX-1) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      offsetu = (ly+1)*nvmxsub - 2*NVARS;
+      offsetue = (ly+2)*nvmxsub2 - NVARS;
+      for (i = 0; i < NVARS; i++) uext[offsetue+i] = udata[offsetu+i];
+    }
+  }
+
+  /* Make local copies of problem variables, for efficiency */
+  dely = data->dy;
+  verdco = data->vdco;
+  hordco  = data->hdco;
+  horaco  = data->haco;
+
+  /* Set diurnal rate coefficients as functions of t, and save q4 in 
+  data block for use by preconditioner evaluation routine */
+  s = sin((data->om)*t);
+  if (s > RCONST(0.0)) {
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
+  } else {
+    q3 = RCONST(0.0);
+    q4coef = RCONST(0.0);
+  }
+  data->q4 = q4coef;
+
+  /* Loop over all grid points in local subgrid */
+  for (ly = 0; ly < MYSUB; ly++) {
+
+    jy = ly + isuby*MYSUB;
+
+    /* Set vertical diffusion coefficients at jy +- 1/2 */
+    ydn = YMIN + (jy - RCONST(0.5))*dely;
+    yup = ydn + dely;
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
+    for (lx = 0; lx < MXSUB; lx++) {
+
+      /* Extract c1 and c2, and set kinetic rate terms */
+      offsetue = (lx+1)*NVARS + (ly+1)*nvmxsub2;
+      c1 = uext[offsetue];
+      c2 = uext[offsetue+1];
+      qq1 = Q1*c1*C3;
+      qq2 = Q2*c1*c2;
+      qq3 = q3*C3;
+      qq4 = q4coef*c2;
+      rkin1 = -qq1 - qq2 + RCONST(2.0)*qq3 + qq4;
+      rkin2 = qq1 - qq2 - qq4;
+
+      /* Set vertical diffusion terms */
+      c1dn = uext[offsetue-nvmxsub2];
+      c2dn = uext[offsetue-nvmxsub2+1];
+      c1up = uext[offsetue+nvmxsub2];
+      c2up = uext[offsetue+nvmxsub2+1];
+      vertd1 = cyup*(c1up - c1) - cydn*(c1 - c1dn);
+      vertd2 = cyup*(c2up - c2) - cydn*(c2 - c2dn);
+
+      /* Set horizontal diffusion and advection terms */
+      c1lt = uext[offsetue-2];
+      c2lt = uext[offsetue-1];
+      c1rt = uext[offsetue+2];
+      c2rt = uext[offsetue+3];
+      hord1 = hordco*(c1rt - RCONST(2.0)*c1 + c1lt);
+      hord2 = hordco*(c2rt - RCONST(2.0)*c2 + c2lt);
+      horad1 = horaco*(c1rt - c1lt);
+      horad2 = horaco*(c2rt - c2lt);
+
+      /* Load all terms into dudata */
+      offsetu = lx*NVARS + ly*nvmxsub;
+      dudata[offsetu]   = vertd1 + hord1 + horad1 + rkin1; 
+      dudata[offsetu+1] = vertd2 + hord2 + horad2 + rkin2;
+    }
+  }
+}
+
+
+/***************** Functions Called by the Solver *************************/
+
+/* f routine.  Evaluate f(t,y).  First call ucomm to do communication of 
+   subgrid boundary data into uext.  Then calculate f by a call to fcalc. */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
+{
+  realtype *udata, *udotdata;
+  UserData data;
+  HYPRE_ParVector uhyp;
+  HYPRE_ParVector udothyp;
+  
+  /* Extract hypre vectors */  
+  uhyp  = N_VGetVector_ParHyp(u);
+  udothyp  = N_VGetVector_ParHyp(udot);
+  
+  /* Access hypre vectors local data */
+  udata = hypre_VectorData(hypre_ParVectorLocalVector(uhyp));
+  udotdata = hypre_VectorData(hypre_ParVectorLocalVector(udothyp));
+
+  data = (UserData) user_data;
+
+  /* Call ucomm to do inter-processor communication */
+  ucomm(t, u, data);
+
+  /* Call fcalc to calculate all right-hand sides */
+  fcalc(t, udata, udotdata, data);
+
+  return(0);
+}
+
+
+/* Preconditioner setup routine. Generate and preprocess P. */
+
+static int Precond(realtype tn, N_Vector u, N_Vector fu,
+                   booleantype jok, booleantype *jcurPtr, 
+                   realtype gamma, void *user_data, 
+                   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  realtype c1, c2, cydn, cyup, diag, ydn, yup, q4coef, dely, verdco, hordco;
+  realtype **(*P)[MYSUB], **(*Jbd)[MYSUB];
+  int nvmxsub, ier, offset;
+  long int *(*pivot)[MYSUB];
+  int lx, ly, jy, isuby;
+  realtype *udata, **a, **j;
+  HYPRE_ParVector uhyp;
+  UserData data;
+  
+  /* Make local copies of pointers in user_data, pointer to u's data,
+     and PE index pair */
+  data = (UserData) user_data;
+  P = data->P;
+  Jbd = data->Jbd;
+  pivot = data->pivot;
+  isuby = data->isuby;
+  nvmxsub = data->nvmxsub;
+
+  uhyp  = N_VGetVector_ParHyp(u);
+  udata = hypre_VectorData(hypre_ParVectorLocalVector(uhyp));
+
+  if (jok) {
+
+    /* jok = TRUE: Copy Jbd to P */
+    for (ly = 0; ly < MYSUB; ly++)
+      for (lx = 0; lx < MXSUB; lx++)
+        denseCopy(Jbd[lx][ly], P[lx][ly], NVARS, NVARS);
+
+  *jcurPtr = FALSE;
+
+  }
+
+  else {
+
+    /* jok = FALSE: Generate Jbd from scratch and copy to P */
+
+    /* Make local copies of problem variables, for efficiency */
+    q4coef = data->q4;
+    dely = data->dy;
+    verdco = data->vdco;
+    hordco  = data->hdco;
+    
+    /* Compute 2x2 diagonal Jacobian blocks (using q4 values 
+     c*omputed on the last f call).  Load into P. */
+    for (ly = 0; ly < MYSUB; ly++) {
+      jy = ly + isuby*MYSUB;
+      ydn = YMIN + (jy - RCONST(0.5))*dely;
+      yup = ydn + dely;
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
+      diag = -(cydn + cyup + RCONST(2.0)*hordco);
+      for (lx = 0; lx < MXSUB; lx++) {
+        offset = lx*NVARS + ly*nvmxsub;
+        c1 = udata[offset];
+        c2 = udata[offset+1];
+        j = Jbd[lx][ly];
+        a = P[lx][ly];
+        IJth(j,1,1) = (-Q1*C3 - Q2*c2) + diag;
+        IJth(j,1,2) = -Q2*c1 + q4coef;
+        IJth(j,2,1) = Q1*C3 - Q2*c2;
+        IJth(j,2,2) = (-Q2*c1 - q4coef) + diag;
+        denseCopy(j, a, NVARS, NVARS);
+      }
+    }
+
+    *jcurPtr = TRUE;
+
+  }
+
+  /* Scale by -gamma */
+  for (ly = 0; ly < MYSUB; ly++)
+    for (lx = 0; lx < MXSUB; lx++)
+      denseScale(-gamma, P[lx][ly], NVARS, NVARS);
+
+  /* Add identity matrix and do LU decompositions on blocks in place */
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      denseAddIdentity(P[lx][ly], NVARS);
+      ier = denseGETRF(P[lx][ly], NVARS, NVARS, pivot[lx][ly]);
+      if (ier != 0) return(1);
+    }
+  }
+
+  return(0);
+}
+
+
+/* Preconditioner solve routine */
+
+static int PSolve(realtype tn, N_Vector u, N_Vector fu, 
+                  N_Vector r, N_Vector z, 
+                  realtype gamma, realtype delta,
+                  int lr, void *user_data, N_Vector vtemp)
+{
+  realtype **(*P)[MYSUB];
+  int nvmxsub;
+  long int *(*pivot)[MYSUB];
+  int lx, ly;
+  realtype *zdata, *v;
+  HYPRE_ParVector zhyp;
+  UserData data;
+  
+  /* Extract the P and pivot arrays from user_data */
+  data = (UserData) user_data;
+  P = data->P;
+  pivot = data->pivot;
+
+  /* Solve the block-diagonal system Px = r using LU factors stored
+     in P and pivot data in pivot, and return the solution in z.
+     First copy vector r to z. */
+  N_VScale(RCONST(1.0), r, z);
+
+  nvmxsub = data->nvmxsub;
+  zhyp  = N_VGetVector_ParHyp(z); /* extract hypre vector */
+  zdata = hypre_VectorData(hypre_ParVectorLocalVector(zhyp));
+
+  for (lx = 0; lx < MXSUB; lx++) {
+    for (ly = 0; ly < MYSUB; ly++) {
+      v = &(zdata[lx*NVARS + ly*nvmxsub]);
+      denseGETRS(P[lx][ly], NVARS, pivot[lx][ly], v);
+    }
+  }
+
+  return(0);
+}
+
+
+/*********************** Private Helper Function ************************/
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); 
+  } else if (opt == 1) { /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed with flag = %d\n\n",
+              id, funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) { /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, "\nMEMORY_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); 
+  }
+
+  return(0);
+}
diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out
new file mode 100644
index 0000000..de34bc8
--- /dev/null
+++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out
@@ -0,0 +1,63 @@
+
+2-species diurnal advection-diffusion problem
+
+t = 7.20e+03   no. steps = 979   stepsize = 3.07e+00
+At bottom left:  c1, c2 =    1.047e+04    2.527e+11 
+At top right:    c1, c2 =    1.119e+04    2.700e+11 
+
+t = 1.44e+04   no. steps = 2735   stepsize = 6.93e+00
+At bottom left:  c1, c2 =    6.659e+06    2.582e+11 
+At top right:    c1, c2 =    7.301e+06    2.833e+11 
+
+t = 2.16e+04   no. steps = 3533   stepsize = 1.05e+01
+At bottom left:  c1, c2 =    2.665e+07    2.993e+11 
+At top right:    c1, c2 =    2.931e+07    3.313e+11 
+
+t = 2.88e+04   no. steps = 4593   stepsize = 3.95e+00
+At bottom left:  c1, c2 =    8.702e+06    3.380e+11 
+At top right:    c1, c2 =    9.650e+06    3.751e+11 
+
+t = 3.60e+04   no. steps = 5950   stepsize = 2.56e+00
+At bottom left:  c1, c2 =    1.404e+04    3.387e+11 
+At top right:    c1, c2 =    1.561e+04    3.765e+11 
+
+t = 4.32e+04   no. steps = 7138   stepsize = 4.42e+02
+At bottom left:  c1, c2 =   -1.581e-07    3.382e+11 
+At top right:    c1, c2 =    1.503e-07    3.804e+11 
+
+t = 5.04e+04   no. steps = 7155   stepsize = 5.12e+02
+At bottom left:  c1, c2 =   -2.237e-17    3.358e+11 
+At top right:    c1, c2 =    9.286e-17    3.864e+11 
+
+t = 5.76e+04   no. steps = 7170   stepsize = 3.90e+02
+At bottom left:  c1, c2 =    4.963e-18    3.320e+11 
+At top right:    c1, c2 =   -1.508e-17    3.909e+11 
+
+t = 6.48e+04   no. steps = 7184   stepsize = 5.91e+02
+At bottom left:  c1, c2 =   -3.047e-20    3.313e+11 
+At top right:    c1, c2 =   -1.306e-18    3.963e+11 
+
+t = 7.20e+04   no. steps = 7196   stepsize = 5.91e+02
+At bottom left:  c1, c2 =    2.184e-19    3.330e+11 
+At top right:    c1, c2 =   -6.748e-18    4.039e+11 
+
+t = 7.92e+04   no. steps = 7208   stepsize = 5.91e+02
+At bottom left:  c1, c2 =    6.659e-19    3.334e+11 
+At top right:    c1, c2 =   -6.289e-18    4.120e+11 
+
+t = 8.64e+04   no. steps = 7220   stepsize = 5.91e+02
+At bottom left:  c1, c2 =   -2.252e-28    3.352e+11 
+At top right:    c1, c2 =   -1.129e-28    4.163e+11 
+
+
+Final Statistics: 
+
+lenrw   =  3058     leniw   =   160
+lenrwls =  2046     leniwls =    80
+nst     =  7220     nfe     =     0
+nfi     = 75855     nfels   = 88509
+nni     = 39606     nli     = 88509
+nsetups =   442     netf    =    29
+npe     =   122     nps     = 125772
+ncfn    =     0     ncfl    =     0
+
diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt
new file mode 100644
index 0000000..97c3027
--- /dev/null
+++ b/examples/arkode/C_serial/CMakeLists.txt
@@ -0,0 +1,218 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for ARKODE serial examples
+
+# Add variable ARKODE_examples with the names of the serial ARKODE examples
+
+SET(ARKODE_examples
+  ark_analytic
+  ark_analytic_nonlin
+  ark_brusselator
+  ark_brusselator_fp
+  ark_brusselator1D
+  ark_heat1D
+  ark_heat1D_adapt
+  ark_KrylovDemo_prec
+  ark_robertson
+  ark_robertson_root
+  )
+
+# Add variable ARKODE_examples_BL with the names of the serial ARKODE examples
+# that use Lapack
+
+SET(ARKODE_examples_BL
+  )
+
+# Add variable ARKODE_examples_KLU with the names of the serial ARKODE examples
+# that use KLU
+
+SET(ARKODE_examples_KLU
+  ark_brusselator1D_klu
+  )
+
+# Add variable ARKODE_examples_SUPERLUMT with the names of the serial ARKODE examples
+# that use SUPERLUMT
+
+SET(ARKODE_examples_SUPERLUMT
+  ark_brusselator1D_FEM_slu
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+
+SET(ARKODE_extras
+  plot_brusselator1D.py
+  plot_brusselator1D_FEM.py
+  plot_heat1D.py
+  plot_heat1D_adapt.py
+  plot_sol.py
+  plot_sol_log.py
+  )
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECS_LIB sundials_nvecserial_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECS_LIB sundials_nvecserial_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${ARKODE_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each ARKODE example
+
+FOREACH(example ${ARKODE_examples})
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${ARKODE_examples})
+
+# Add the build and install targets for each Lapack ARKODE example (if needed)
+
+IF(LAPACK_FOUND)
+  FOREACH(example ${ARKODE_examples_BL})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${ARKODE_examples_BL})
+ENDIF(LAPACK_FOUND)
+
+# If KLU support is enabled, add the build and install targets for 
+# the examples using KLU
+IF(KLU_FOUND)
+  FOREACH(example ${ARKODE_examples_KLU})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${ARKODE_examples_KLU})
+ENDIF(KLU_FOUND)
+
+# If SuperLUMT support is enabled, add the build and install targets for 
+# the examples using SuperLUMT
+IF(SUPERLUMT_FOUND)
+  FOREACH(example ${ARKODE_examples_SUPERLUMT})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${ARKODE_examples_SUPERLUMT})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  LIST2STRING(ARKODE_examples EXAMPLES)
+
+  IF(LAPACK_FOUND)
+    LIST2STRING(ARKODE_examples_BL EXAMPLES_BL)
+  ELSE(LAPACK_FOUND)
+    SET(EXAMPLES_BL "")
+  ENDIF(LAPACK_FOUND)
+
+  IF(KLU_FOUND)
+    LIST2STRING(ARKODE_examples_KLU EXAMPLES)
+  ENDIF(KLU_FOUND)
+
+  IF(SUPERLUMT_FOUND)
+    LIST2STRING(ARKODE_examples_SUPERLUMT EXAMPLES)
+  ENDIF(SUPERLUMT_FOUND)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_serial/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_serial/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/C_serial/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/C_serial/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/C_serial 
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/C_serial/README b/examples/arkode/C_serial/README
new file mode 100644
index 0000000..91c6135
--- /dev/null
+++ b/examples/arkode/C_serial/README
@@ -0,0 +1,62 @@
+List of serial ARKODE C examples
+
+  ark_analytic              : simple stiff, linear, ODE           (DIRK/DENSE)
+  ark_analytic_nonlin       : simple nonstiff, nonlinear ODE      (ERK)
+  ark_brusselator           : stiff chemical kinetics ODE system  (DIRK/DENSE)
+  ark_brusselator_fp        : stiff chemical kinetics ODE system  (ARK/Fixed point) 
+  ark_brusselator1D         : stiff chemical kinetics PDE system  (DIRK/BAND)
+  ark_brusselator1D_FEM_slu : stiff chemical kinetics PDE, with 
+                              FEM spatial discretization          (DIRK/SuperLU)
+  ark_brusselator1D_klu     : stiff chemical kinetics PDE system  (DIRK/KLU)
+  ark_heat1D                : stiff 1D heat PDE example           (DIRK/PCG)
+  ark_heat1D_adapt          : stiff 1D heat PDE, adaptive mesh    (DIRK/PCG/ARKodeResize)
+  ark_KrylovDemo_prec       : Krylov method demonstration program (SPGMR)
+  ark_robertson             : stiff chemical kinetics ODE system  (DIRK/DENSE)
+  ark_robertson_root        : stiff chemical kinetics ODE system 
+                              with root-finding                   (DIRK/DENSE)
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.c b/examples/arkode/C_serial/ark_KrylovDemo_prec.c
new file mode 100644
index 0000000..27c0062
--- /dev/null
+++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.c
@@ -0,0 +1,1155 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Demonstration program for ARKODE - Krylov linear solver.
+ * ODE system from ns-species interaction PDE in 2 dimensions.
+ * 
+ * This program solves a stiff ODE system that arises from a system
+ * of partial differential equations. The PDE system is a food web
+ * population model, with predator-prey interaction and diffusion on
+ * the unit square in two dimensions. The dependent variable vector is:
+ *
+ *        1   2        ns
+ *  c = (c , c , ..., c  )
+ *
+ * and the PDEs are as follows:
+ *
+ *    i               i      i
+ *  dc /dt  =  d(i)*(c    + c   )  +  f (x,y,c)  (i=1,...,ns)
+ *                    xx     yy        i   
+ *
+ * where
+ *
+ *                 i          ns         j
+ *  f (x,y,c)  =  c *(b(i) + sum a(i,j)*c )
+ *   i                       j=1                                         
+ *                                                                       
+ * The number of species is ns = 2*np, with the first np being prey
+ * and the last np being predators. The coefficients a(i,j), b(i),
+ * d(i) are:
+ *
+ *  a(i,i) = -a  (all i)
+ *  a(i,j) = -g  (i <= np, j > np)
+ *  a(i,j) =  e  (i > np, j <= np)
+ *  b(i) =  b*(1 + alpha*x*y)  (i <= np)
+ *  b(i) = -b*(1 + alpha*x*y)  (i > np)
+ *  d(i) = Dprey  (i <= np)
+ *  d(i) = Dpred  (i > np)
+ *
+ * The spatial domain is the unit square. The final time is 10.
+ * The boundary conditions are: normal derivative = 0.
+ * A polynomial in x and y is used to set the initial conditions.
+ *
+ * The PDEs are discretized by central differencing on an MX by MY mesh.
+ *
+ * The resulting ODE system is stiff.
+ *
+ * The ODE system is solved using Newton iteration and the ARKSPGMR
+ * linear solver (scaled preconditioned GMRES).
+ *
+ * The preconditioner matrix used is the product of two matrices:
+ * (1) A matrix, only defined implicitly, based on a fixed number
+ * of Gauss-Seidel iterations using the diffusion terms only.
+ * (2) A block-diagonal matrix based on the partial derivatives
+ * of the interaction terms f only, using block-grouping (computing
+ * only a subset of the ns by ns blocks).
+ *
+ * Four different runs are made for this problem.
+ * The product preconditoner is applied on the left and on the
+ * right. In each case, both the modified and classical Gram-Schmidt
+ * options are tested.
+ * In the series of runs, ARKodeInit and ARKSpgmr are called only
+ * for the first run, whereas ARKodeReInit, ARKSpilsSetPrecType and
+ * ARKSpilsSetGSType are called for each of the remaining three runs.
+ *
+ * A problem description, performance statistics at selected output
+ * times, and final statistics are written to standard output.
+ * On the first run, solution values are also printed at output
+ * times. Error and warning messages are written to standard error,
+ * but there should be no such messages.
+ *
+ * Note: This program requires the dense linear solver functions
+ * newDenseMat, newLintArray, denseAddIdentity, denseGETRF, denseGETRS, 
+ * destroyMat and destroyArray.
+ *
+ * Note: This program assumes the sequential implementation for the
+ * type N_Vector and uses the N_VGetArrayPointer_Serial to gain access 
+ * to the contiguous array of components of an N_Vector.
+ *-------------------------------------------------------------------
+ * Reference: Peter N. Brown and Alan C. Hindmarsh, Reduced Storage
+ * Matrix Methods in Stiff ODE Systems, J. Appl. Math. & Comp., 31
+ * (1989), pp. 40-91.  Also available as Lawrence Livermore National
+ * Laboratory Report UCRL-95088, Rev. 1, June 1987.
+ *-----------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <arkode/arkode.h>           /* main integrator header file */
+#include <arkode/arkode_spgmr.h>     /* prototypes & constants for ARKSPGMR solver */
+#include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
+#include <sundials/sundials_dense.h> /* use generic DENSE solver in preconditioning */
+#include <sundials/sundials_types.h> /* definition of realtype */
+#include <sundials/sundials_math.h>  /* contains the macros ABS and SUNSQR */
+
+/* Constants */
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* Problem Specification Constants */
+
+#define AA    ONE               /* AA = a */
+#define EE    RCONST(1.0e4)     /* EE = e */
+#define GG    RCONST(0.5e-6)    /* GG = g */
+#define BB    ONE               /* BB = b */
+#define DPREY ONE
+#define DPRED RCONST(0.5)
+#define ALPH  ONE
+#define NP    3
+#define NS    (2*NP)
+
+/* Method Constants */
+
+#define MX    6
+#define MY    6
+#define MXNS  (MX*NS)
+#define AX    ONE
+#define AY    ONE
+#define DX    (AX/(realtype)(MX-1))
+#define DY    (AY/(realtype)(MY-1))
+#define MP    NS
+#define MQ    (MX*MY)
+#define MXMP  (MX*MP)
+#define NGX   2
+#define NGY   2
+#define NGRP  (NGX*NGY)
+#define ITMAX 5
+
+/* CVodeInit Constants */
+
+#define NEQ  (NS*MX*MY)
+#define T0   ZERO
+#define RTOL RCONST(1.0e-5)
+#define ATOL RCONST(1.0e-5)
+
+/* CVSpgmr Constants */
+
+#define MAXL 0     /* => use default = MIN(NEQ, 5)            */
+#define DELT ZERO  /* => use default = 0.05                   */
+
+/* Output Constants */
+
+#define T1        RCONST(1.0e-8)
+#define TOUT_MULT RCONST(10.0)
+#define DTOUT     ONE
+#define NOUT      18
+
+/* Note: The value for species i at mesh point (j,k) is stored in */
+/* component number (i-1) + j*NS + k*NS*MX of an N_Vector,        */
+/* where 1 <= i <= NS, 0 <= j < MX, 0 <= k < MY.                  */
+
+/* Structure for user data */
+
+typedef struct {
+  realtype **P[NGRP];
+  long int *pivot[NGRP];
+  int ns, mxns;
+  int mp, mq, mx, my, ngrp, ngx, ngy, mxmp;
+  int jgx[NGX+1], jgy[NGY+1], jigx[MX], jigy[MY];
+  int jxr[NGX], jyr[NGY];
+  realtype acoef[NS][NS], bcoef[NS], diff[NS];
+  realtype cox[NS], coy[NS], dx, dy, srur;
+  realtype fsave[NEQ];
+  N_Vector rewt;
+  void *arkode_mem;
+} *WebData;
+
+/* Private Helper Functions */
+
+static WebData AllocUserData(void);
+static void InitUserData(WebData wdata);
+static void SetGroups(int m, int ng, int jg[], int jig[], int jr[]);
+static void CInit(N_Vector c, WebData wdata);
+static void PrintIntro(void);
+static void PrintHeader(int jpre, int gstype);
+static void PrintAllSpecies(N_Vector c, int ns, int mxns, realtype t);
+static void PrintOutput(void *arkode_mem, realtype t);
+static void PrintFinalStats(void *arkode_mem);
+static void FreeUserData(WebData wdata);
+static void WebRates(realtype x, realtype y, realtype t, realtype c[],
+		     realtype rate[], WebData wdata);
+static void fblock (realtype t, realtype cdata[], int jx, int jy,
+		    realtype cdotdata[], WebData wdata);
+static void GSIter(realtype gamma, N_Vector z, N_Vector x,WebData wdata);
+
+/* Small Vector Kernels */
+
+static void v_inc_by_prod(realtype u[], realtype v[], realtype w[], int n);
+static void v_sum_prods(realtype u[], realtype p[], realtype q[], realtype v[],
+                        realtype w[], int n);
+static void v_prod(realtype u[], realtype v[], realtype w[], int n);
+static void v_zero(realtype u[], int n);
+
+/* Functions Called By The Solver */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+static int Precond(realtype tn, N_Vector c, N_Vector fc,
+		   booleantype jok, booleantype *jcurPtr, realtype gamma,
+		   void *user_data, N_Vector vtemp1, N_Vector vtemp2,
+                   N_Vector vtemp3);
+
+static int PSolve(realtype tn, N_Vector c, N_Vector fc,
+                  N_Vector r, N_Vector z,
+                  realtype gamma, realtype delta,
+                  int lr, void *user_data, N_Vector vtemp);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Implementation */
+
+int main()
+{
+  realtype abstol=ATOL, reltol=RTOL, t, tout;
+  N_Vector c;
+  WebData wdata;
+  void *arkode_mem;
+  booleantype firstrun;
+  int jpre, gstype, flag;
+  int ns, mxns, iout;
+
+  c = NULL;
+  wdata = NULL;
+  arkode_mem = NULL;
+
+  /* Initializations */
+  c = N_VNew_Serial(NEQ);
+  if(check_flag((void *)c, "N_VNew_Serial", 0)) return(1);
+  wdata = AllocUserData();
+  if(check_flag((void *)wdata, "AllocUserData", 2)) return(1);
+  InitUserData(wdata);
+  ns = wdata->ns;
+  mxns = wdata->mxns;
+
+  /* Print problem description */
+  PrintIntro();
+
+  /* Loop over jpre and gstype (four cases) */
+  for (jpre = PREC_LEFT; jpre <= PREC_RIGHT; jpre++) {
+    for (gstype = MODIFIED_GS; gstype <= CLASSICAL_GS; gstype++) {
+      
+      /* Initialize c and print heading */
+      CInit(c, wdata);
+      PrintHeader(jpre, gstype);
+
+      /* Call ARKodeInit or ARKodeReInit, then ARKSpgmr to set up problem */
+      
+      firstrun = (jpre == PREC_LEFT) && (gstype == MODIFIED_GS);
+      if (firstrun) {
+        arkode_mem = ARKodeCreate();
+        if(check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return(1);
+
+        wdata->arkode_mem = arkode_mem;
+
+        flag = ARKodeSetUserData(arkode_mem, wdata);
+        if(check_flag(&flag, "ARKodeSetUserData", 1)) return(1);
+
+        flag = ARKodeInit(arkode_mem, NULL, f, T0, c);
+        if(check_flag(&flag, "ARKodeInit", 1)) return(1);
+
+        flag = ARKodeSStolerances(arkode_mem, reltol, abstol);
+        if (check_flag(&flag, "ARKodeSStolerances", 1)) return(1);
+
+	flag = ARKodeSetMaxNumSteps(arkode_mem, 1000);
+	if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) return(1);
+
+	flag = ARKodeSetNonlinConvCoef(arkode_mem, 1.e-3);
+	if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) return(1);
+
+        flag = ARKSpgmr(arkode_mem, jpre, MAXL);
+        if(check_flag(&flag, "ARKSpgmr", 1)) return(1);
+
+        flag = ARKSpilsSetGSType(arkode_mem, gstype);
+        if(check_flag(&flag, "ARKSpilsSetGSType", 1)) return(1);
+
+        flag = ARKSpilsSetEpsLin(arkode_mem, DELT);
+        if(check_flag(&flag, "ARKSpilsSetEpsLin", 1)) return(1);
+
+        flag = ARKSpilsSetPreconditioner(arkode_mem, Precond, PSolve);
+        if(check_flag(&flag, "ARKSpilsSetPreconditioner", 1)) return(1);
+
+      } else {
+
+        flag = ARKodeReInit(arkode_mem, NULL, f, T0, c);
+        if(check_flag(&flag, "ARKodeReInit", 1)) return(1);
+
+        flag = ARKSpilsSetPrecType(arkode_mem, jpre);
+        check_flag(&flag, "ARKSpilsSetPrecType", 1);
+        flag = ARKSpilsSetGSType(arkode_mem, gstype);
+        if(check_flag(&flag, "ARKSpilsSetGSType", 1)) return(1);
+
+      }
+      
+      /* Print initial values */
+      if (firstrun) PrintAllSpecies(c, ns, mxns, T0);
+      
+      /* Loop over output points, call ARKode, print sample solution values. */
+      tout = T1;
+      for (iout = 1; iout <= NOUT; iout++) {
+        flag = ARKode(arkode_mem, tout, c, &t, ARK_NORMAL);
+        PrintOutput(arkode_mem, t);
+        if (firstrun && (iout % 3 == 0)) PrintAllSpecies(c, ns, mxns, t);
+        if(check_flag(&flag, "ARKode", 1)) break;
+        if (tout > RCONST(0.9)) tout += DTOUT; else tout *= TOUT_MULT; 
+      }
+      
+      /* Print final statistics, and loop for next case */
+      PrintFinalStats(arkode_mem);
+      
+    }
+  }
+
+  /* Free all memory */
+  ARKodeFree(&arkode_mem);
+  N_VDestroy_Serial(c);
+  FreeUserData(wdata);
+
+  return(0);
+}
+
+static WebData AllocUserData(void)
+{
+  int i, ngrp = NGRP;
+  long int ns = NS;
+  WebData wdata;
+  
+  wdata = (WebData) malloc(sizeof *wdata);
+  for(i=0; i < ngrp; i++) {
+    (wdata->P)[i] = newDenseMat(ns, ns);
+    (wdata->pivot)[i] = newLintArray(ns);
+  }
+  wdata->rewt = N_VNew_Serial(NEQ);
+  return(wdata);
+}
+
+static void InitUserData(WebData wdata)
+{
+  int i, j, ns;
+  realtype *bcoef, *diff, *cox, *coy, dx, dy;
+  realtype (*acoef)[NS];
+  
+  acoef = wdata->acoef;
+  bcoef = wdata->bcoef;
+  diff = wdata->diff;
+  cox = wdata->cox;
+  coy = wdata->coy;
+  ns = wdata->ns = NS;
+  
+  for (j = 0; j < NS; j++) { for (i = 0; i < NS; i++) acoef[i][j] = 0.; }
+  for (j = 0; j < NP; j++) {
+    for (i = 0; i < NP; i++) {
+      acoef[NP+i][j] = EE;
+      acoef[i][NP+j] = -GG;
+    }
+    acoef[j][j] = -AA;
+    acoef[NP+j][NP+j] = -AA;
+    bcoef[j] = BB;
+    bcoef[NP+j] = -BB;
+    diff[j] = DPREY;
+    diff[NP+j] = DPRED;
+  }
+
+  /* Set remaining problem parameters */
+
+  wdata->mxns = MXNS;
+  dx = wdata->dx = DX;
+  dy = wdata->dy = DY;
+  for (i = 0; i < ns; i++) {
+    cox[i] = diff[i]/SUNSQR(dx);
+    coy[i] = diff[i]/SUNSQR(dy);
+  }
+
+  /* Set remaining method parameters */
+
+  wdata->mp = MP;
+  wdata->mq = MQ;
+  wdata->mx = MX;
+  wdata->my = MY;
+  wdata->srur = SUNRsqrt(UNIT_ROUNDOFF);
+  wdata->mxmp = MXMP;
+  wdata->ngrp = NGRP;
+  wdata->ngx = NGX;
+  wdata->ngy = NGY;
+  SetGroups(MX, NGX, wdata->jgx, wdata->jigx, wdata->jxr);
+  SetGroups(MY, NGY, wdata->jgy, wdata->jigy, wdata->jyr);
+}
+
+/*
+ This routine sets arrays jg, jig, and jr describing
+ a uniform partition of (0,1,2,...,m-1) into ng groups.
+ The arrays set are:
+   jg    = length ng+1 array of group boundaries.
+           Group ig has indices j = jg[ig],...,jg[ig+1]-1.
+   jig   = length m array of group indices vs node index.
+           Node index j is in group jig[j].
+   jr    = length ng array of indices representing the groups.
+           The index for group ig is j = jr[ig].
+*/
+static void SetGroups(int m, int ng, int jg[], int jig[], int jr[])
+{
+  int ig, j, len1, mper, ngm1;
+
+  mper = m/ng; /* does integer division */
+  for (ig=0; ig < ng; ig++) jg[ig] = ig*mper;
+  jg[ng] = m;
+  
+  ngm1 = ng - 1;
+  len1 = ngm1*mper;
+  for (j = 0; j < len1; j++) jig[j] = j/mper;
+  for (j = len1; j < m; j++) jig[j] = ngm1;
+
+  for (ig = 0; ig < ngm1; ig++) jr[ig] = ((2*ig+1)*mper-1)/2;
+  jr[ngm1] = (ngm1*mper+m-1)/2;
+}
+
+/* This routine computes and loads the vector of initial values. */
+static void CInit(N_Vector c, WebData wdata)
+{
+  int jx, jy, ns, mxns, ioff, iyoff, i, ici;
+  realtype argx, argy, x, y, dx, dy, x_factor, y_factor, *cdata;
+  
+  cdata = N_VGetArrayPointer(c);
+  ns = wdata->ns;
+  mxns = wdata->mxns;
+  dx = wdata->dx;
+  dy = wdata->dy;
+
+  x_factor = RCONST(4.0)/SUNSQR(AX);
+  y_factor = RCONST(4.0)/SUNSQR(AY);
+  for (jy = 0; jy < MY; jy++) {
+    y = jy*dy;
+    argy = SUNSQR(y_factor*y*(AY-y));
+    iyoff = mxns*jy;
+    for (jx = 0; jx < MX; jx++) {
+      x = jx*dx;
+      argx = SUNSQR(x_factor*x*(AX-x));
+      ioff = iyoff + ns*jx;
+      for (i = 1; i <= ns; i++) {
+        ici = ioff + i-1;
+        cdata[ici] = RCONST(10.0) + i*argx*argy;
+      }
+    }
+  }
+}
+
+static void PrintIntro(void)
+{
+  printf("\n\nDemonstration program for ARKODE - ARKSPGMR linear solver\n\n");
+  printf("Food web problem with ns species, ns = %d\n", NS);
+  printf("Predator-prey interaction and diffusion on a 2-D square\n\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Matrix parameters: a = %.2Lg   e = %.2Lg   g = %.2Lg\n",
+         AA, EE, GG);
+  printf("b parameter = %.2Lg\n", BB);
+  printf("Diffusion coefficients: Dprey = %.2Lg   Dpred = %.2Lg\n",
+         DPREY, DPRED);
+  printf("Rate parameter alpha = %.2Lg\n\n", ALPH);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Matrix parameters: a = %.2g   e = %.2g   g = %.2g\n",
+         AA, EE, GG);
+  printf("b parameter = %.2g\n", BB);
+  printf("Diffusion coefficients: Dprey = %.2g   Dpred = %.2g\n",
+         DPREY, DPRED);
+  printf("Rate parameter alpha = %.2g\n\n", ALPH);
+#else
+  printf("Matrix parameters: a = %.2g   e = %.2g   g = %.2g\n",
+         AA, EE, GG);
+  printf("b parameter = %.2g\n", BB);
+  printf("Diffusion coefficients: Dprey = %.2g   Dpred = %.2g\n",
+         DPREY, DPRED);
+  printf("Rate parameter alpha = %.2g\n\n", ALPH);
+#endif
+  printf("Mesh dimensions (mx,my) are %d, %d.  ", MX, MY);
+  printf("Total system size is neq = %d \n\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerances: reltol = %.2Lg, abstol = %.2Lg \n\n",
+         RTOL, ATOL);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n",
+         RTOL, ATOL);
+#else
+  printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n",
+         RTOL, ATOL);
+#endif
+  printf("Preconditioning uses a product of:\n");
+  printf("  (1) Gauss-Seidel iterations with ");
+  printf("itmax = %d iterations, and\n", ITMAX);
+  printf("  (2) interaction-only block-diagonal matrix ");
+  printf("with block-grouping\n");
+  printf("  Number of diagonal block groups = ngrp = %d", NGRP);
+  printf("  (ngx by ngy, ngx = %d, ngy = %d)\n", NGX, NGY);
+  printf("\n\n--------------------------------------------------------------");
+  printf("--------------\n");
+}
+
+static void PrintHeader(int jpre, int gstype)
+{
+  if(jpre == PREC_LEFT)
+    printf("\n\nPreconditioner type is           jpre = %s\n", "PREC_LEFT");
+  else
+    printf("\n\nPreconditioner type is           jpre = %s\n", "PREC_RIGHT");
+
+  if(gstype == MODIFIED_GS)
+    printf("\nGram-Schmidt method type is    gstype = %s\n\n\n", "MODIFIED_GS");
+  else
+    printf("\nGram-Schmidt method type is    gstype = %s\n\n\n", "CLASSICAL_GS");
+}
+
+static void PrintAllSpecies(N_Vector c, int ns, int mxns, realtype t)
+{
+  int i, jx ,jy;
+  realtype *cdata;
+  
+  cdata = N_VGetArrayPointer(c);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("c values at t = %Lg:\n\n", t);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("c values at t = %g:\n\n", t);
+#else
+  printf("c values at t = %g:\n\n", t);
+#endif
+  for (i=1; i <= ns; i++) {
+    printf("Species %d\n", i);
+    for (jy=MY-1; jy >= 0; jy--) {
+      for (jx=0; jx < MX; jx++) {
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+        printf("%-10.6Lg", cdata[(i-1) + jx*ns + jy*mxns]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+        printf("%-10.6g", cdata[(i-1) + jx*ns + jy*mxns]);
+#else
+        printf("%-10.6g", cdata[(i-1) + jx*ns + jy*mxns]);
+#endif
+      }
+      printf("\n");
+    }
+    printf("\n");
+  }
+}
+
+static void PrintOutput(void *arkode_mem, realtype t)
+{
+  long int nst, nfe, nfi, nni;
+  int flag;
+  realtype hu;
+
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetLastStep(arkode_mem, &hu);
+  check_flag(&flag, "ARKodeGetLastStep", 1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("t = %10.2Le  nst = %ld  nfe = %ld  nfi = %ld  nni = %ld", t, nst, nfe, nfi, nni);
+  printf("  hu = %11.2Le\n\n", hu);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("t = %10.2e  nst = %ld  nfe = %ld  nfi = %ld  nni = %ld", t, nst, nfe, nfi, nni);
+  printf("  hu = %11.2e\n\n", hu);
+#else
+  printf("t = %10.2e  nst = %ld  nfe = %ld  nfi = %ld  nni = %ld", t, nst, nfe, nfi, nni);
+  printf("  hu = %11.2e\n\n", hu);
+#endif
+}
+
+static void PrintFinalStats(void *arkode_mem)
+{
+  long int lenrw, leniw ;
+  long int lenrwLS, leniwLS;
+  long int nst, nfe, nfi, nsetups, nni, ncfn, netf;
+  long int nli, npe, nps, ncfl, nfeLS;
+  int flag;
+  realtype avdim;
+  
+  flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw);
+  check_flag(&flag, "ARKodeGetWorkSpace", 1);
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+
+  flag = ARKSpilsGetWorkSpace(arkode_mem, &lenrwLS, &leniwLS);
+  check_flag(&flag, "ARKSpilsGetWorkSpace", 1);
+  flag = ARKSpilsGetNumLinIters(arkode_mem, &nli);
+  check_flag(&flag, "ARKSpilsGetNumLinIters", 1);
+  flag = ARKSpilsGetNumPrecEvals(arkode_mem, &npe);
+  check_flag(&flag, "ARKSpilsGetNumPrecEvals", 1);
+  flag = ARKSpilsGetNumPrecSolves(arkode_mem, &nps);
+  check_flag(&flag, "ARKSpilsGetNumPrecSolves", 1);
+  flag = ARKSpilsGetNumConvFails(arkode_mem, &ncfl);
+  check_flag(&flag, "ARKSpilsGetNumConvFails", 1);
+  flag = ARKSpilsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKSpilsGetNumRhsEvals", 1);
+
+  printf("\n\n Final statistics for this run:\n\n");
+  printf(" ARKode real workspace length           = %4ld \n", lenrw);
+  printf(" ARKode integer workspace length        = %4ld \n", leniw);
+  printf(" ARKSPGMR real workspace length         = %4ld \n", lenrwLS);
+  printf(" ARKSPGMR integer workspace length      = %4ld \n", leniwLS);
+  printf(" Number of steps                       = %4ld \n", nst);
+  printf(" Number of f-s (explicit)              = %4ld \n", nfe);
+  printf(" Number of f-s (implicit)              = %4ld \n", nfi);
+  printf(" Number of f-s (SPGMR)                 = %4ld \n", nfeLS);
+  printf(" Number of f-s (TOTAL)                 = %4ld \n", nfe + nfeLS);
+  printf(" Number of setups                      = %4ld \n", nsetups);
+  printf(" Number of nonlinear iterations        = %4ld \n", nni);
+  printf(" Number of linear iterations           = %4ld \n", nli);
+  printf(" Number of preconditioner evaluations  = %4ld \n", npe);
+  printf(" Number of preconditioner solves       = %4ld \n", nps);
+  printf(" Number of error test failures         = %4ld \n", netf);
+  printf(" Number of nonlinear conv. failures    = %4ld \n", ncfn);
+  printf(" Number of linear convergence failures = %4ld \n", ncfl);
+  avdim = (nni > 0) ? ((realtype)nli)/((realtype)nni) : ZERO;
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf(" Average Krylov subspace dimension     = %.3Lf \n", avdim);
+#else
+  printf(" Average Krylov subspace dimension     = %.3f \n", avdim);
+#endif
+  printf("\n\n--------------------------------------------------------------");
+  printf("--------------\n");
+  printf(    "--------------------------------------------------------------");
+  printf("--------------\n");
+}
+
+static void FreeUserData(WebData wdata)
+{
+  int i, ngrp;
+
+  ngrp = wdata->ngrp;
+  for(i=0; i < ngrp; i++) {
+    destroyMat((wdata->P)[i]);
+    destroyArray((wdata->pivot)[i]);
+  }
+  N_VDestroy_Serial(wdata->rewt);
+  free(wdata);
+}
+
+/*
+ This routine computes the right-hand side of the ODE system and
+ returns it in cdot. The interaction rates are computed by calls to WebRates,
+ and these are saved in fsave for use in preconditioning.
+*/
+static int f(realtype t, N_Vector c, N_Vector cdot,void *user_data)
+{
+  int i, ic, ici, idxl, idxu, jx, ns, mxns, iyoff, jy, idyu, idyl;
+  realtype dcxli, dcxui, dcyli, dcyui, x, y, *cox, *coy, *fsave, dx, dy;
+  realtype *cdata, *cdotdata;
+  WebData wdata;
+  
+  wdata = (WebData) user_data;
+  cdata = N_VGetArrayPointer(c);
+  cdotdata = N_VGetArrayPointer(cdot);
+  
+  mxns = wdata->mxns;
+  ns = wdata->ns;
+  fsave = wdata->fsave;
+  cox = wdata->cox;
+  coy = wdata->coy;
+  mxns = wdata->mxns;
+  dx = wdata->dx;
+  dy = wdata->dy;
+  
+  for (jy = 0; jy < MY; jy++) {
+    y = jy*dy;
+    iyoff = mxns*jy;
+    idyu = (jy == MY-1) ? -mxns : mxns;
+    idyl = (jy == 0) ? -mxns : mxns;
+    for (jx = 0; jx < MX; jx++) {
+      x = jx*dx;
+      ic = iyoff + ns*jx;
+      /* Get interaction rates at one point (x,y). */
+      WebRates(x, y, t, cdata+ic, fsave+ic, wdata);
+      idxu = (jx == MX-1) ? -ns : ns;
+      idxl = (jx == 0) ? -ns : ns;
+      for (i = 1; i <= ns; i++) {
+        ici = ic + i-1;
+        /* Do differencing in y. */
+        dcyli = cdata[ici] - cdata[ici-idyl];
+        dcyui = cdata[ici+idyu] - cdata[ici];
+        /* Do differencing in x. */
+        dcxli = cdata[ici] - cdata[ici-idxl];
+        dcxui = cdata[ici+idxu] - cdata[ici];
+        /* Collect terms and load cdot elements. */
+        cdotdata[ici] = coy[i-1]*(dcyui - dcyli) + cox[i-1]*(dcxui - dcxli) +
+          fsave[ici];
+      }
+    }
+  }
+
+  return(0);
+}
+
+/*
+  This routine computes the interaction rates for the species
+  c_1, ... ,c_ns (stored in c[0],...,c[ns-1]), at one spatial point 
+  and at time t.
+*/
+static void WebRates(realtype x, realtype y, realtype t, realtype c[],
+                     realtype rate[], WebData wdata)
+{
+  int i, j, ns;
+  realtype fac, *bcoef;
+  realtype (*acoef)[NS];
+  
+  ns = wdata->ns;
+  acoef = wdata->acoef;
+  bcoef = wdata->bcoef;
+  
+  for (i = 0; i < ns; i++)
+    rate[i] = ZERO;
+  
+  for (j = 0; j < ns; j++) 
+    for (i = 0; i < ns; i++) 
+      rate[i] += c[j] * acoef[i][j];
+  
+  fac = ONE + ALPH*x*y;
+  for (i = 0; i < ns; i++) 
+    rate[i] = c[i]*(bcoef[i]*fac + rate[i]);
+}
+
+/*
+ This routine generates the block-diagonal part of the Jacobian
+ corresponding to the interaction rates, multiplies by -gamma, adds
+ the identity matrix, and calls denseGETRF to do the LU decomposition of
+ each diagonal block. The computation of the diagonal blocks uses
+ the preset block and grouping information. One block per group is
+ computed. The Jacobian elements are generated by difference
+ quotients using calls to the routine fblock.
+
+ This routine can be regarded as a prototype for the general case
+ of a block-diagonal preconditioner. The blocks are of size mp, and
+ there are ngrp=ngx*ngy blocks computed in the block-grouping scheme.
+*/ 
+static int Precond(realtype t, N_Vector c, N_Vector fc,
+		   booleantype jok, booleantype *jcurPtr, realtype gamma,
+		   void *user_data, N_Vector vtemp1, N_Vector vtemp2,
+                   N_Vector vtemp3)
+{
+  realtype ***P;
+  int ier;
+  long int **pivot;
+  int i, if0, if00, ig, igx, igy, j, jj, jx, jy;
+  int *jxr, *jyr, ngrp, ngx, ngy, mxmp, flag;
+  long int mp;
+  realtype uround, fac, r, r0, save, srur;
+  realtype *f1, *fsave, *cdata, *rewtdata;
+  WebData wdata;
+  void *arkode_mem;
+  N_Vector rewt;
+  
+  wdata = (WebData) user_data;
+  arkode_mem = wdata->arkode_mem;
+  cdata = N_VGetArrayPointer(c);
+  rewt = wdata->rewt;
+  flag = ARKodeGetErrWeights(arkode_mem, rewt);
+  if(check_flag(&flag, "ARKodeGetErrWeights", 1)) return(1);
+  rewtdata = N_VGetArrayPointer(rewt);
+
+  uround = UNIT_ROUNDOFF;
+
+  P = wdata->P;
+  pivot = wdata->pivot;
+  jxr = wdata->jxr;
+  jyr = wdata->jyr;
+  mp = wdata->mp;
+  srur = wdata->srur;
+  ngrp = wdata->ngrp;
+  ngx = wdata->ngx;
+  ngy = wdata->ngy;
+  mxmp = wdata->mxmp;
+  fsave = wdata->fsave;
+  
+  /* Make mp calls to fblock to approximate each diagonal block of Jacobian.
+     Here, fsave contains the base value of the rate vector and 
+     r0 is a minimum increment factor for the difference quotient. */
+  
+  f1 = N_VGetArrayPointer(vtemp1);
+  
+  fac = N_VWrmsNorm (fc, rewt);
+  r0 = RCONST(1000.0)*SUNRabs(gamma)*uround*NEQ*fac;
+  if (r0 == ZERO) r0 = ONE;
+  
+  for (igy = 0; igy < ngy; igy++) {
+    jy = jyr[igy];
+    if00 = jy*mxmp;
+    for (igx = 0; igx < ngx; igx++) { 
+      jx = jxr[igx];
+      if0 = if00 + jx*mp;
+      ig = igx + igy*ngx; 
+      /* Generate ig-th diagonal block */
+      for (j = 0; j < mp; j++) {
+        /* Generate the jth column as a difference quotient */
+        jj = if0 + j; 
+        save = cdata[jj];
+        r = SUNMAX(srur*SUNRabs(save),r0/rewtdata[jj]);
+        cdata[jj] += r;
+        fac = -gamma/r;
+        fblock (t, cdata, jx, jy, f1, wdata);
+        for (i = 0; i < mp; i++) {
+          P[ig][j][i] = (f1[i] - fsave[if0+i])*fac;
+        }
+        cdata[jj] = save;
+      }
+    }
+  }
+  
+  /* Add identity matrix and do LU decompositions on blocks. */
+  
+  for (ig = 0; ig < ngrp; ig++) {
+    denseAddIdentity(P[ig], mp);
+    ier = denseGETRF(P[ig], mp, mp, pivot[ig]);
+    if (ier != 0) return(1);
+  }
+  
+  *jcurPtr = TRUE;
+  return(0);
+}
+
+/*
+  This routine computes one block of the interaction terms of the
+  system, namely block (jx,jy), for use in preconditioning.
+  Here jx and jy count from 0.
+*/
+static void fblock(realtype t, realtype cdata[], int jx, int jy,
+                   realtype cdotdata[], WebData wdata)
+{
+  int iblok, ic;
+  realtype x, y;
+  
+  iblok = jx + jy*(wdata->mx);
+  y = jy*(wdata->dy);
+  x = jx*(wdata->dx);
+  ic = (wdata->ns)*(iblok);
+  WebRates(x, y, t, cdata+ic, cdotdata, wdata);
+}
+
+/*
+  This routine applies two inverse preconditioner matrices
+  to the vector r, using the interaction-only block-diagonal Jacobian
+  with block-grouping, denoted Jr, and Gauss-Seidel applied to the
+  diffusion contribution to the Jacobian, denoted Jd.
+  It first calls GSIter for a Gauss-Seidel approximation to
+  ((I - gamma*Jd)-inverse)*r, and stores the result in z.
+  Then it computes ((I - gamma*Jr)-inverse)*z, using LU factors of the
+  blocks in P, and pivot information in pivot, and returns the result in z.
+*/
+static int PSolve(realtype tn, N_Vector c, N_Vector fc,
+                  N_Vector r, N_Vector z,
+                  realtype gamma, realtype delta,
+                  int lr, void *user_data, N_Vector vtemp)
+{
+  realtype   ***P;
+  long int **pivot;
+  int jx, jy, igx, igy, iv, ig, *jigx, *jigy, mx, my, ngx;
+  long int mp;
+  WebData wdata;
+  
+  wdata = (WebData) user_data;
+  
+  N_VScale(ONE, r, z);
+  
+  /* call GSIter for Gauss-Seidel iterations */
+  
+  GSIter(gamma, z, vtemp, wdata);
+  
+  /* Do backsolves for inverse of block-diagonal preconditioner factor */
+  
+  P = wdata->P;
+  pivot = wdata->pivot;
+  mx = wdata->mx;
+  my = wdata->my;
+  ngx = wdata->ngx;
+  mp = wdata->mp;
+  jigx = wdata->jigx;
+  jigy = wdata->jigy;
+  
+  iv = 0;
+  for (jy = 0; jy < my; jy++) {
+    igy = jigy[jy];
+    for (jx = 0; jx < mx; jx++) {
+      igx = jigx[jx];
+      ig = igx + igy*ngx;
+      denseGETRS(P[ig], mp, pivot[ig], &(N_VGetArrayPointer(z)[iv]));
+      iv += mp;
+    }
+  }
+  
+  return(0);
+}
+
+/*
+  This routine performs ITMAX=5 Gauss-Seidel iterations to compute an
+  approximation to (P-inverse)*z, where P = I - gamma*Jd, and
+  Jd represents the diffusion contributions to the Jacobian.
+  The answer is stored in z on return, and x is a temporary vector.
+  The dimensions below assume a global constant NS >= ns.
+  Some inner loops of length ns are implemented with the small
+  vector kernels v_sum_prods, v_prod, v_inc_by_prod.
+*/
+static void GSIter(realtype gamma, N_Vector z, N_Vector x, WebData wdata)
+{
+  int jx, jy, mx, my, x_loc, y_loc;
+  int ns, mxns, i, iyoff, ic, iter;
+  realtype beta[NS], beta2[NS], cof1[NS], gam[NS], gam2[NS];
+  realtype temp, *cox, *coy, *xd, *zd;
+  
+  xd = N_VGetArrayPointer(x);
+  zd = N_VGetArrayPointer(z);
+  ns = wdata->ns;
+  mx = wdata->mx;
+  my = wdata->my;
+  mxns = wdata->mxns;
+  cox = wdata->cox;
+  coy = wdata->coy;
+  
+  /* Write matrix as P = D - L - U.
+     Load local arrays beta, beta2, gam, gam2, and cof1. */
+  
+  for (i = 0; i < ns; i++) {
+    temp = ONE/(ONE + RCONST(2.0)*gamma*(cox[i] + coy[i]));
+    beta[i] = gamma*cox[i]*temp;
+    beta2[i] = RCONST(2.0)*beta[i];
+    gam[i] = gamma*coy[i]*temp;
+    gam2[i] = RCONST(2.0)*gam[i];
+    cof1[i] = temp;
+  }
+  
+  /* Begin iteration loop.
+     Load vector x with (D-inverse)*z for first iteration. */
+  
+  for (jy = 0; jy < my; jy++) {
+    iyoff = mxns*jy;
+    for (jx = 0; jx < mx; jx++) {
+      ic = iyoff + ns*jx;
+      v_prod(xd+ic, cof1, zd+ic, ns); /* x[ic+i] = cof1[i]z[ic+i] */
+    }
+  }
+  N_VConst(ZERO, z);
+  
+  /* Looping point for iterations. */
+  
+  for (iter=1; iter <= ITMAX; iter++) {
+    
+    /* Calculate (D-inverse)*U*x if not the first iteration. */
+    
+    if (iter > 1) {
+      for (jy=0; jy < my; jy++) {
+        iyoff = mxns*jy;
+        for (jx=0; jx < mx; jx++) { /* order of loops matters */
+          ic = iyoff + ns*jx;
+          x_loc = (jx == 0) ? 0 : ((jx == mx-1) ? 2 : 1);
+          y_loc = (jy == 0) ? 0 : ((jy == my-1) ? 2 : 1);
+          switch (3*y_loc+x_loc) {
+          case 0 : 
+            /* jx == 0, jy == 0 */
+            /* x[ic+i] = beta2[i]x[ic+ns+i] + gam2[i]x[ic+mxns+i] */
+            v_sum_prods(xd+ic, beta2, xd+ic+ns, gam2, xd+ic+mxns, ns);
+            break;
+          case 1 : 
+            /* 1 <= jx <= mx-2, jy == 0 */
+            /* x[ic+i] = beta[i]x[ic+ns+i] + gam2[i]x[ic+mxns+i] */
+            v_sum_prods(xd+ic, beta, xd+ic+ns, gam2, xd+ic+mxns, ns);
+            break;
+          case 2 : 
+            /* jx == mx-1, jy == 0 */
+            /* x[ic+i] = gam2[i]x[ic+mxns+i] */
+            v_prod(xd+ic, gam2, xd+ic+mxns, ns);
+            break;
+          case 3 : 
+            /* jx == 0, 1 <= jy <= my-2 */
+            /* x[ic+i] = beta2[i]x[ic+ns+i] + gam[i]x[ic+mxns+i] */
+            v_sum_prods(xd+ic, beta2, xd+ic+ns, gam, xd+ic+mxns, ns);
+            break;
+          case 4 : 
+            /* 1 <= jx <= mx-2, 1 <= jy <= my-2 */
+            /* x[ic+i] = beta[i]x[ic+ns+i] + gam[i]x[ic+mxns+i] */
+            v_sum_prods(xd+ic, beta, xd+ic+ns, gam, xd+ic+mxns, ns);
+            break;
+          case 5 : 
+            /* jx == mx-1, 1 <= jy <= my-2 */
+            /* x[ic+i] = gam[i]x[ic+mxns+i] */
+            v_prod(xd+ic, gam, xd+ic+mxns, ns);
+            break;
+          case 6 : 
+            /* jx == 0, jy == my-1 */
+            /* x[ic+i] = beta2[i]x[ic+ns+i] */
+            v_prod(xd+ic, beta2, xd+ic+ns, ns);
+            break;
+          case 7 : 
+            /* 1 <= jx <= mx-2, jy == my-1 */
+            /* x[ic+i] = beta[i]x[ic+ns+i] */
+            v_prod(xd+ic, beta, xd+ic+ns, ns);
+            break;
+          case 8 : 
+            /* jx == mx-1, jy == my-1 */
+            /* x[ic+i] = 0.0 */
+            v_zero(xd+ic, ns);
+            break;
+          }
+        }
+      }
+    }  /* end if (iter > 1) */
+    
+    /* Overwrite x with [(I - (D-inverse)*L)-inverse]*x. */
+    
+    for (jy=0; jy < my; jy++) {
+      iyoff = mxns*jy;
+      for (jx=0; jx < mx; jx++) { /* order of loops matters */
+        ic = iyoff + ns*jx;
+        x_loc = (jx == 0) ? 0 : ((jx == mx-1) ? 2 : 1);
+        y_loc = (jy == 0) ? 0 : ((jy == my-1) ? 2 : 1);
+        switch (3*y_loc+x_loc) {
+        case 0 : 
+          /* jx == 0, jy == 0 */
+          break;
+        case 1 : 
+          /* 1 <= jx <= mx-2, jy == 0 */
+          /* x[ic+i] += beta[i]x[ic-ns+i] */
+          v_inc_by_prod(xd+ic, beta, xd+ic-ns, ns);
+          break;
+        case 2 : 
+          /* jx == mx-1, jy == 0 */
+          /* x[ic+i] += beta2[i]x[ic-ns+i] */
+          v_inc_by_prod(xd+ic, beta2, xd+ic-ns, ns);
+          break;
+        case 3 : 
+          /* jx == 0, 1 <= jy <= my-2 */
+          /* x[ic+i] += gam[i]x[ic-mxns+i] */
+          v_inc_by_prod(xd+ic, gam, xd+ic-mxns, ns);
+          break;
+        case 4 : 
+          /* 1 <= jx <= mx-2, 1 <= jy <= my-2 */
+          /* x[ic+i] += beta[i]x[ic-ns+i] + gam[i]x[ic-mxns+i] */
+          v_inc_by_prod(xd+ic, beta, xd+ic-ns, ns);
+          v_inc_by_prod(xd+ic, gam, xd+ic-mxns, ns);
+          break;
+        case 5 : 
+          /* jx == mx-1, 1 <= jy <= my-2 */
+          /* x[ic+i] += beta2[i]x[ic-ns+i] + gam[i]x[ic-mxns+i] */
+          v_inc_by_prod(xd+ic, beta2, xd+ic-ns, ns);
+          v_inc_by_prod(xd+ic, gam, xd+ic-mxns, ns);
+          break;
+        case 6 : 
+          /* jx == 0, jy == my-1 */
+          /* x[ic+i] += gam2[i]x[ic-mxns+i] */
+          v_inc_by_prod(xd+ic, gam2, xd+ic-mxns, ns);
+          break;
+        case 7 : 
+          /* 1 <= jx <= mx-2, jy == my-1 */
+          /* x[ic+i] += beta[i]x[ic-ns+i] + gam2[i]x[ic-mxns+i] */
+          v_inc_by_prod(xd+ic, beta, xd+ic-ns, ns);
+          v_inc_by_prod(xd+ic, gam2, xd+ic-mxns, ns);
+          break;
+        case 8 : 
+          /* jx == mx-1, jy == my-1 */
+          /* x[ic+i] += beta2[i]x[ic-ns+i] + gam2[i]x[ic-mxns+i] */
+          v_inc_by_prod(xd+ic, beta2, xd+ic-ns, ns);
+          v_inc_by_prod(xd+ic, gam2, xd+ic-mxns, ns);
+          break;
+        }
+      }
+    }
+    
+    /* Add increment x to z : z <- z+x */
+    
+    N_VLinearSum(ONE, z, ONE, x, z);
+    
+  }
+}
+
+static void v_inc_by_prod(realtype u[], realtype v[], realtype w[], int n)
+{
+  int i;  
+  for (i=0; i < n; i++) u[i] += v[i]*w[i];
+}
+
+static void v_sum_prods(realtype u[], realtype p[], realtype q[],
+                        realtype v[], realtype w[], int n)
+{
+  int i;  
+  for (i=0; i < n; i++) u[i] = p[i]*q[i] + v[i]*w[i];
+}
+
+static void v_prod(realtype u[], realtype v[], realtype w[], int n)
+{ 
+  int i;
+  for (i=0; i < n; i++) u[i] = v[i]*w[i];
+}
+
+static void v_zero(realtype u[], int n)
+{
+  int i;  
+  for (i=0; i < n; i++) u[i] = ZERO;
+}
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+              funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out
new file mode 100644
index 0000000..d8a9257
--- /dev/null
+++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out
@@ -0,0 +1,649 @@
+
+
+Demonstration program for ARKODE - ARKSPGMR linear solver
+
+Food web problem with ns species, ns = 6
+Predator-prey interaction and diffusion on a 2-D square
+
+Matrix parameters: a = 1   e = 1e+04   g = 5e-07
+b parameter = 1
+Diffusion coefficients: Dprey = 1   Dpred = 0.5
+Rate parameter alpha = 1
+
+Mesh dimensions (mx,my) are 6, 6.  Total system size is neq = 216 
+
+Tolerances: reltol = 1e-05, abstol = 1e-05 
+
+Preconditioning uses a product of:
+  (1) Gauss-Seidel iterations with itmax = 5 iterations, and
+  (2) interaction-only block-diagonal matrix with block-grouping
+  Number of diagonal block groups = ngrp = 4  (ngx by ngy, ngx = 2, ngy = 2)
+
+
+----------------------------------------------------------------------------
+
+
+Preconditioner type is           jpre = PREC_LEFT
+
+Gram-Schmidt method type is    gstype = MODIFIED_GS
+
+
+c values at t = 0:
+
+Species 1
+10        10        10        10        10        10        
+10        10.1678   10.3775   10.3775   10.1678   10        
+10        10.3775   10.8493   10.8493   10.3775   10        
+10        10.3775   10.8493   10.8493   10.3775   10        
+10        10.1678   10.3775   10.3775   10.1678   10        
+10        10        10        10        10        10        
+
+Species 2
+10        10        10        10        10        10        
+10        10.3355   10.755    10.755    10.3355   10        
+10        10.755    11.6987   11.6987   10.755    10        
+10        10.755    11.6987   11.6987   10.755    10        
+10        10.3355   10.755    10.755    10.3355   10        
+10        10        10        10        10        10        
+
+Species 3
+10        10        10        10        10        10        
+10        10.5033   11.1325   11.1325   10.5033   10        
+10        11.1325   12.548    12.548    11.1325   10        
+10        11.1325   12.548    12.548    11.1325   10        
+10        10.5033   11.1325   11.1325   10.5033   10        
+10        10        10        10        10        10        
+
+Species 4
+10        10        10        10        10        10        
+10        10.6711   11.5099   11.5099   10.6711   10        
+10        11.5099   13.3974   13.3974   11.5099   10        
+10        11.5099   13.3974   13.3974   11.5099   10        
+10        10.6711   11.5099   11.5099   10.6711   10        
+10        10        10        10        10        10        
+
+Species 5
+10        10        10        10        10        10        
+10        10.8389   11.8874   11.8874   10.8389   10        
+10        11.8874   14.2467   14.2467   11.8874   10        
+10        11.8874   14.2467   14.2467   11.8874   10        
+10        10.8389   11.8874   11.8874   10.8389   10        
+10        10        10        10        10        10        
+
+Species 6
+10        10        10        10        10        10        
+10        11.0066   12.2649   12.2649   11.0066   10        
+10        12.2649   15.0961   15.0961   12.2649   10        
+10        12.2649   15.0961   15.0961   12.2649   10        
+10        11.0066   12.2649   12.2649   11.0066   10        
+10        10        10        10        10        10        
+
+t =   1.00e-08  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-07  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-06  nst = 8  nfe = 0  nfi = 121  nni = 77  hu =    4.79e-07
+
+c values at t = 1e-06:
+
+Species 1
+9.99991   9.99992   9.99993   9.99993   9.99993   9.99992   
+9.99992   10.1677   10.3774   10.3774   10.1677   9.99993   
+9.99993   10.3774   10.8492   10.8492   10.3774   9.99993   
+9.99993   10.3774   10.8492   10.8492   10.3774   9.99993   
+9.99992   10.1677   10.3774   10.3774   10.1677   9.99992   
+9.99991   9.99992   9.99993   9.99993   9.99992   9.99991   
+
+Species 2
+9.99991   9.99993   9.99995   9.99995   9.99993   9.99992   
+9.99993   10.3355   10.7549   10.7549   10.3355   9.99993   
+9.99995   10.7549   11.6985   11.6985   10.7549   9.99995   
+9.99995   10.7549   11.6985   11.6985   10.7549   9.99995   
+9.99993   10.3355   10.7549   10.7549   10.3355   9.99993   
+9.99991   9.99993   9.99995   9.99995   9.99993   9.99991   
+
+Species 3
+9.99991   9.99994   9.99997   9.99997   9.99994   9.99992   
+9.99994   10.5032   11.1323   11.1323   10.5032   9.99994   
+9.99997   11.1323   12.5478   12.5478   11.1323   9.99997   
+9.99997   11.1323   12.5478   12.5478   11.1323   9.99997   
+9.99994   10.5032   11.1323   11.1323   10.5032   9.99994   
+9.99991   9.99994   9.99997   9.99997   9.99994   9.99991   
+
+Species 4
+13.4984   13.4984   13.4984   13.4984   13.4984   13.4984   
+13.4984   14.55     15.8924   15.8924   14.55     13.4984   
+13.4984   15.8924   19.0296   19.0296   15.8924   13.4984   
+13.4984   15.8924   19.0296   19.0296   15.8924   13.4984   
+13.4984   14.55     15.8924   15.8924   14.55     13.4984   
+13.4984   13.4984   13.4984   13.4984   13.4984   13.4984   
+
+Species 5
+13.4984   13.4984   13.4985   13.4985   13.4984   13.4984   
+13.4984   14.7787   16.4136   16.4136   14.7787   13.4984   
+13.4985   16.4136   20.236    20.236    16.4136   13.4985   
+13.4985   16.4136   20.236    20.236    16.4136   13.4985   
+13.4984   14.7787   16.4136   16.4136   14.7787   13.4984   
+13.4984   13.4984   13.4985   13.4985   13.4984   13.4984   
+
+Species 6
+13.4984   13.4984   13.4985   13.4985   13.4984   13.4984   
+13.4984   15.0075   16.9348   16.9348   15.0075   13.4984   
+13.4985   16.9348   21.4423   21.4423   16.9348   13.4985   
+13.4985   16.9348   21.4423   21.4423   16.9348   13.4985   
+13.4984   15.0075   16.9348   16.9348   15.0075   13.4984   
+13.4984   13.4984   13.4985   13.4985   13.4984   13.4984   
+
+t =   1.00e-05  nst = 27  nfe = 0  nfi = 408  nni = 269  hu =    4.79e-07
+
+t =   1.00e-04  nst = 106  nfe = 0  nfi = 1689  nni = 1155  hu =    1.70e-05
+
+t =   1.00e-03  nst = 110  nfe = 0  nfi = 1751  nni = 1197  hu =    1.51e-03
+
+c values at t = 0.001:
+
+Species 1
+9.90702   9.91664   9.92836   9.93033   9.92253   9.91674   
+9.91472   10.0747   10.2769   10.2785   10.0795   9.92253   
+9.92446   10.2748   10.7181   10.7194   10.2785   9.93033   
+9.92445   10.2744   10.7173   10.7181   10.2769   9.92836   
+9.91469   10.0734   10.2744   10.2748   10.0747   9.91664   
+9.90698   9.91469   9.92445   9.92446   9.91472   9.90702   
+
+Species 2
+9.90742   9.92474   9.94622   9.94819   9.93064   9.91713   
+9.92282   10.2412   10.644    10.6457   10.2461   9.93064   
+9.94232   10.6419   11.5267   11.5281   10.6457   9.94819   
+9.94231   10.6415   11.5258   11.5267   10.644    9.94622   
+9.92279   10.24     10.6415   10.6419   10.2412   9.92474   
+9.90737   9.92279   9.94231   9.94232   9.92282   9.90742   
+
+Species 3
+9.90781   9.93284   9.96408   9.96605   9.93874   9.91753   
+9.93092   10.4078   11.0109   11.0127   10.4127   9.93874   
+9.96017   11.0088   12.3339   12.3354   11.0127   9.96605   
+9.96016   11.0083   12.333    12.3339   11.0109   9.96408   
+9.93088   10.4065   11.0083   11.0088   10.4078   9.93284   
+9.90776   9.93088   9.96016   9.96017   9.93092   9.90781   
+
+Species 4
+297231    297749    298392    298451    297925    297520    
+297692    307245    319327    319378    307390    297925    
+298276    319264    345799    345840    319378    298451    
+298276    319252    345772    345799    319327    298392    
+297691    307208    319252    319264    307245    297749    
+297229    297691    298276    298276    297692    297231    
+
+Species 5
+297231    297749    298392    298451    297925    297520    
+297692    307245    319327    319378    307390    297925    
+298276    319264    345799    345840    319378    298451    
+298276    319252    345772    345799    319327    298392    
+297691    307208    319252    319264    307245    297749    
+297229    297691    298276    298276    297692    297231    
+
+Species 6
+297231    297749    298392    298451    297925    297520    
+297692    307245    319327    319378    307390    297925    
+298276    319264    345799    345840    319378    298451    
+298276    319252    345772    345799    319327    298392    
+297691    307208    319252    319264    307245    297749    
+297229    297691    298276    298276    297692    297231    
+
+t =   1.00e-02  nst = 113  nfe = 0  nfi = 1798  nni = 1229  hu =    3.46e-03
+
+t =   1.00e-01  nst = 127  nfe = 0  nfi = 2025  nni = 1386  hu =    1.28e-02
+
+t =   1.00e+00  nst = 154  nfe = 0  nfi = 2490  nni = 1716  hu =    6.84e-02
+
+c values at t = 1:
+
+Species 1
+1.58851   1.59924   1.62152   1.64764   1.67036   1.68149   
+1.58533   1.59503   1.61548   1.63952   1.66033   1.67036   
+1.57757   1.58547   1.60239   1.62235   1.63952   1.64764   
+1.5682    1.57412   1.58706   1.60239   1.61548   1.62152   
+1.56048   1.56463   1.57412   1.58547   1.59503   1.59924   
+1.55733   1.56048   1.5682    1.57757   1.58533   1.58851   
+
+Species 2
+1.59067   1.60141   1.62371   1.64987   1.67261   1.68375   
+1.58748   1.5972    1.61766   1.64173   1.66257   1.67261   
+1.57971   1.58763   1.60457   1.62454   1.64173   1.64987   
+1.57034   1.57626   1.58921   1.60457   1.61766   1.62371   
+1.56261   1.56676   1.57626   1.58763   1.5972    1.60141   
+1.55945   1.56261   1.57034   1.57971   1.58748   1.59067   
+
+Species 3
+1.5927    1.60346   1.62578   1.65197   1.67474   1.68589   
+1.58951   1.59924   1.61973   1.64383   1.66468   1.67474   
+1.58174   1.58966   1.60662   1.62662   1.64383   1.65197   
+1.57236   1.57828   1.59125   1.60662   1.61973   1.62578   
+1.56462   1.56878   1.57828   1.58966   1.59924   1.60346   
+1.56146   1.56462   1.57236   1.58174   1.58951   1.5927    
+
+Species 4
+47718.3   48040.3   48709     49493.5   50175.5   50509.4   
+47622.8   47914     48527.8   49249.6   49874.4   50175.5   
+47389.7   47627     48134.9   48734.2   49249.6   49493.5   
+47108.5   47286     47674.6   48134.9   48527.8   48709     
+46876.6   47001.2   47286     47627     47914     48040.3   
+46781.9   46876.6   47108.5   47389.7   47622.8   47718.3   
+
+Species 5
+47718.3   48040.3   48709     49493.5   50175.5   50509.4   
+47622.8   47914     48527.8   49249.6   49874.4   50175.5   
+47389.7   47627     48134.9   48734.2   49249.6   49493.5   
+47108.5   47286     47674.6   48134.9   48527.8   48709     
+46876.6   47001.2   47286     47627     47914     48040.3   
+46781.9   46876.6   47108.5   47389.7   47622.8   47718.3   
+
+Species 6
+47718.3   48040.3   48709     49493.5   50175.5   50509.4   
+47622.8   47914     48527.8   49249.6   49874.4   50175.5   
+47389.7   47627     48134.9   48734.2   49249.6   49493.5   
+47108.5   47286     47674.6   48134.9   48527.8   48709     
+46876.6   47001.2   47286     47627     47914     48040.3   
+46781.9   46876.6   47108.5   47389.7   47622.8   47718.3   
+
+t =   2.00e+00  nst = 165  nfe = 0  nfi = 2662  nni = 1833  hu =    4.14e-02
+
+t =   3.00e+00  nst = 177  nfe = 0  nfi = 2849  nni = 1960  hu =    1.08e-01
+
+t =   4.00e+00  nst = 187  nfe = 0  nfi = 3014  nni = 2073  hu =    1.23e-01
+
+c values at t = 4:
+
+Species 1
+1.19535   1.20368   1.2211    1.24157   1.25935   1.268     
+1.1928    1.20035   1.21636   1.23523   1.25154   1.25935   
+1.18657   1.19274   1.20602   1.22173   1.23523   1.24157   
+1.17904   1.18368   1.19389   1.20602   1.21636   1.2211    
+1.17284   1.17613   1.18368   1.19274   1.20035   1.20368   
+1.17032   1.17284   1.17904   1.18657   1.1928    1.19535   
+
+Species 2
+1.19538   1.20371   1.22113   1.24161   1.25938   1.26804   
+1.19284   1.20038   1.21639   1.23526   1.25157   1.25938   
+1.1866    1.19277   1.20606   1.22177   1.23526   1.24161   
+1.17908   1.18371   1.19393   1.20606   1.21639   1.22113   
+1.17288   1.17616   1.18371   1.19277   1.20038   1.20371   
+1.17035   1.17288   1.17908   1.1866    1.19284   1.19538   
+
+Species 3
+1.19542   1.20374   1.22116   1.24164   1.25942   1.26807   
+1.19287   1.20042   1.21642   1.2353    1.2516    1.25942   
+1.18663   1.1928    1.20609   1.2218    1.2353    1.24164   
+1.17911   1.18374   1.19396   1.20609   1.21642   1.22116   
+1.17291   1.17619   1.18374   1.1928    1.20042   1.20374   
+1.17039   1.17291   1.17911   1.18663   1.19287   1.19542   
+
+Species 4
+35860.6   36110.2   36632.4   37246.4   37779.5   38038.7   
+35784.2   36010.4   36490.4   37056.3   37545.3   37779.5   
+35597.2   35782     36180.5   36651.6   37056.3   37246.4   
+35371.4   35510.4   35816.7   36180.5   36490.4   36632.4   
+35185.4   35283.8   35510.4   35782     36010.4   36110.2   
+35109.7   35185.4   35371.4   35597.2   35784.2   35860.6   
+
+Species 5
+35860.6   36110.2   36632.4   37246.4   37779.5   38038.7   
+35784.2   36010.4   36490.4   37056.3   37545.3   37779.5   
+35597.2   35782     36180.5   36651.6   37056.3   37246.4   
+35371.4   35510.4   35816.7   36180.5   36490.4   36632.4   
+35185.4   35283.8   35510.4   35782     36010.4   36110.2   
+35109.7   35185.4   35371.4   35597.2   35784.2   35860.6   
+
+Species 6
+35860.6   36110.2   36632.4   37246.4   37779.5   38038.7   
+35784.2   36010.4   36490.4   37056.3   37545.3   37779.5   
+35597.2   35782     36180.5   36651.6   37056.3   37246.4   
+35371.4   35510.4   35816.7   36180.5   36490.4   36632.4   
+35185.4   35283.8   35510.4   35782     36010.4   36110.2   
+35109.7   35185.4   35371.4   35597.2   35784.2   35860.6   
+
+t =   5.00e+00  nst = 198  nfe = 0  nfi = 3180  nni = 2182  hu =    9.99e-02
+
+t =   6.00e+00  nst = 207  nfe = 0  nfi = 3337  nni = 2284  hu =    9.66e-02
+
+t =   7.00e+00  nst = 216  nfe = 0  nfi = 3478  nni = 2375  hu =    1.51e-01
+
+c values at t = 7:
+
+Species 1
+1.18854   1.19682   1.21415   1.23453   1.25221   1.26082   
+1.186     1.19351   1.20944   1.22822   1.24444   1.25221   
+1.1798    1.18593   1.19916   1.21479   1.22822   1.23453   
+1.17231   1.17692   1.18708   1.19916   1.20944   1.21415   
+1.16614   1.1694    1.17692   1.18593   1.19351   1.19682   
+1.16363   1.16614   1.17231   1.1798    1.186     1.18854   
+
+Species 2
+1.18854   1.19683   1.21415   1.23453   1.25222   1.26082   
+1.186     1.19351   1.20944   1.22822   1.24444   1.25222   
+1.1798    1.18594   1.19916   1.21479   1.22822   1.23453   
+1.17231   1.17692   1.18709   1.19916   1.20944   1.21415   
+1.16614   1.1694    1.17692   1.18594   1.19351   1.19683   
+1.16363   1.16614   1.17231   1.1798    1.186     1.18854   
+
+Species 3
+1.18854   1.19683   1.21416   1.23453   1.25222   1.26082   
+1.18601   1.19351   1.20944   1.22822   1.24444   1.25222   
+1.1798    1.18594   1.19916   1.21479   1.22822   1.23453   
+1.17231   1.17692   1.18709   1.19916   1.20944   1.21416   
+1.16614   1.1694    1.17692   1.18594   1.19351   1.19683   
+1.16363   1.16614   1.17231   1.1798    1.18601   1.18854   
+
+Species 4
+35656.3   35903.1   36424.2   37033.8   37564.6   37822.3   
+35578.4   35804.9   36281.3   36845.5   37330.9   37564.6   
+35393.9   35575.9   35974.4   36441.4   36845.5   37033.8   
+35167.5   35307.4   35610.6   35974.4   36281.3   36424.2   
+34984.3   35080.2   35307.4   35575.9   35804.9   35903.1   
+34907.5   34984.3   35167.5   35393.9   35578.4   35656.3   
+
+Species 5
+35656.3   35903.1   36424.2   37033.8   37564.6   37822.3   
+35578.4   35804.9   36281.3   36845.5   37330.9   37564.6   
+35393.9   35575.9   35974.4   36441.4   36845.5   37033.8   
+35167.5   35307.4   35610.6   35974.4   36281.3   36424.2   
+34984.3   35080.2   35307.4   35575.9   35804.9   35903.1   
+34907.5   34984.3   35167.5   35393.9   35578.4   35656.3   
+
+Species 6
+35656.3   35903.1   36424.2   37033.8   37564.6   37822.3   
+35578.4   35804.9   36281.3   36845.5   37330.9   37564.6   
+35393.9   35575.9   35974.4   36441.4   36845.5   37033.8   
+35167.5   35307.4   35610.6   35974.4   36281.3   36424.2   
+34984.3   35080.2   35307.4   35575.9   35804.9   35903.1   
+34907.5   34984.3   35167.5   35393.9   35578.4   35656.3   
+
+t =   8.00e+00  nst = 232  nfe = 0  nfi = 3781  nni = 2567  hu =    1.06e-01
+
+t =   9.00e+00  nst = 242  nfe = 0  nfi = 3931  nni = 2652  hu =    8.10e-02
+
+t =   1.00e+01  nst = 258  nfe = 0  nfi = 4238  nni = 2839  hu =    1.04e-01
+
+c values at t = 10:
+
+Species 1
+1.18838   1.19667   1.21399   1.23437   1.25205   1.26066   
+1.18585   1.19335   1.20928   1.22805   1.24428   1.25205   
+1.17964   1.18578   1.199     1.21463   1.22805   1.23437   
+1.17215   1.17676   1.18693   1.199     1.20928   1.21399   
+1.16598   1.16925   1.17676   1.18578   1.19335   1.19667   
+1.16347   1.16598   1.17215   1.17964   1.18585   1.18838   
+
+Species 2
+1.18838   1.19667   1.21399   1.23437   1.25205   1.26066   
+1.18585   1.19335   1.20928   1.22805   1.24428   1.25205   
+1.17964   1.18578   1.199     1.21463   1.22805   1.23437   
+1.17215   1.17676   1.18693   1.199     1.20928   1.21399   
+1.16598   1.16925   1.17676   1.18578   1.19335   1.19667   
+1.16347   1.16598   1.17215   1.17964   1.18585   1.18838   
+
+Species 3
+1.18838   1.19667   1.21399   1.23437   1.25205   1.26066   
+1.18585   1.19335   1.20928   1.22805   1.24428   1.25205   
+1.17964   1.18578   1.199     1.21463   1.22805   1.23437   
+1.17215   1.17676   1.18693   1.199     1.20928   1.21399   
+1.16598   1.16925   1.17676   1.18578   1.19335   1.19667   
+1.16347   1.16598   1.17215   1.17964   1.18585   1.18838   
+
+Species 4
+35650.7   35898.7   36418.4   37029.1   37559.5   37817.2   
+35574.6   35799.6   36277     36840.1   37326.5   37559.5   
+35388.4   35572.2   35968.8   36437.6   36840.1   37029.1   
+35163.6   35302     35606.7   35968.8   36277     36418.4   
+34978.7   35076.4   35302     35572.2   35799.6   35898.7   
+34903.4   34978.7   35163.6   35388.4   35574.6   35650.7   
+
+Species 5
+35650.7   35898.7   36418.4   37029.1   37559.5   37817.2   
+35574.6   35799.6   36277     36840.1   37326.5   37559.5   
+35388.4   35572.2   35968.8   36437.6   36840.1   37029.1   
+35163.6   35302     35606.7   35968.8   36277     36418.4   
+34978.7   35076.4   35302     35572.2   35799.6   35898.7   
+34903.4   34978.7   35163.6   35388.4   35574.6   35650.7   
+
+Species 6
+35650.7   35898.7   36418.4   37029.1   37559.5   37817.2   
+35574.6   35799.6   36277     36840.1   37326.5   37559.5   
+35388.4   35572.2   35968.8   36437.6   36840.1   37029.1   
+35163.6   35302     35606.7   35968.8   36277     36418.4   
+34978.7   35076.4   35302     35572.2   35799.6   35898.7   
+34903.4   34978.7   35163.6   35388.4   35574.6   35650.7   
+
+
+
+ Final statistics for this run:
+
+ ARKode real workspace length           = 3298 
+ ARKode integer workspace length        =   55 
+ ARKSPGMR real workspace length         = 2206 
+ ARKSPGMR integer workspace length      =   10 
+ Number of steps                       =  258 
+ Number of f-s (explicit)              =    0 
+ Number of f-s (implicit)              = 4238 
+ Number of f-s (SPGMR)                 = 8818 
+ Number of f-s (TOTAL)                 = 8818 
+ Number of setups                      =  109 
+ Number of nonlinear iterations        = 2839 
+ Number of linear iterations           = 8818 
+ Number of preconditioner evaluations  =  109 
+ Number of preconditioner solves       = 11560 
+ Number of error test failures         =   20 
+ Number of nonlinear conv. failures    =    9 
+ Number of linear convergence failures =  508 
+ Average Krylov subspace dimension     = 3.106 
+
+
+----------------------------------------------------------------------------
+----------------------------------------------------------------------------
+
+
+Preconditioner type is           jpre = PREC_LEFT
+
+Gram-Schmidt method type is    gstype = CLASSICAL_GS
+
+
+t =   1.00e-08  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-07  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-06  nst = 8  nfe = 0  nfi = 121  nni = 77  hu =    4.79e-07
+
+t =   1.00e-05  nst = 27  nfe = 0  nfi = 408  nni = 269  hu =    4.79e-07
+
+t =   1.00e-04  nst = 106  nfe = 0  nfi = 1689  nni = 1155  hu =    1.70e-05
+
+t =   1.00e-03  nst = 110  nfe = 0  nfi = 1751  nni = 1197  hu =    1.51e-03
+
+t =   1.00e-02  nst = 113  nfe = 0  nfi = 1798  nni = 1229  hu =    3.46e-03
+
+t =   1.00e-01  nst = 127  nfe = 0  nfi = 2025  nni = 1386  hu =    1.28e-02
+
+t =   1.00e+00  nst = 154  nfe = 0  nfi = 2492  nni = 1718  hu =    7.60e-02
+
+t =   2.00e+00  nst = 169  nfe = 0  nfi = 2747  nni = 1896  hu =    8.04e-02
+
+t =   3.00e+00  nst = 181  nfe = 0  nfi = 2951  nni = 2036  hu =    1.01e-01
+
+t =   4.00e+00  nst = 189  nfe = 0  nfi = 3074  nni = 2119  hu =    1.33e-01
+
+t =   5.00e+00  nst = 199  nfe = 0  nfi = 3243  nni = 2227  hu =    9.38e-02
+
+t =   6.00e+00  nst = 211  nfe = 0  nfi = 3443  nni = 2352  hu =    1.13e-01
+
+t =   7.00e+00  nst = 220  nfe = 0  nfi = 3613  nni = 2457  hu =    1.11e-01
+
+t =   8.00e+00  nst = 230  nfe = 0  nfi = 3752  nni = 2536  hu =    1.01e-01
+
+t =   9.00e+00  nst = 247  nfe = 0  nfi = 4060  nni = 2725  hu =    9.38e-02
+
+t =   1.00e+01  nst = 264  nfe = 0  nfi = 4356  nni = 2901  hu =    9.24e-02
+
+
+
+ Final statistics for this run:
+
+ ARKode real workspace length           = 3298 
+ ARKode integer workspace length        =   55 
+ ARKSPGMR real workspace length         = 2206 
+ ARKSPGMR integer workspace length      =   10 
+ Number of steps                       =  264 
+ Number of f-s (explicit)              =    0 
+ Number of f-s (implicit)              = 4356 
+ Number of f-s (SPGMR)                 = 9113 
+ Number of f-s (TOTAL)                 = 9113 
+ Number of setups                      =  106 
+ Number of nonlinear iterations        = 2901 
+ Number of linear iterations           = 9113 
+ Number of preconditioner evaluations  =  106 
+ Number of preconditioner solves       = 11919 
+ Number of error test failures         =   24 
+ Number of nonlinear conv. failures    =    8 
+ Number of linear convergence failures =  577 
+ Average Krylov subspace dimension     = 3.141 
+
+
+----------------------------------------------------------------------------
+----------------------------------------------------------------------------
+
+
+Preconditioner type is           jpre = PREC_RIGHT
+
+Gram-Schmidt method type is    gstype = MODIFIED_GS
+
+
+t =   1.00e-08  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-07  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-06  nst = 8  nfe = 0  nfi = 121  nni = 77  hu =    4.79e-07
+
+t =   1.00e-05  nst = 27  nfe = 0  nfi = 408  nni = 269  hu =    4.79e-07
+
+t =   1.00e-04  nst = 106  nfe = 0  nfi = 1689  nni = 1155  hu =    1.70e-05
+
+t =   1.00e-03  nst = 110  nfe = 0  nfi = 1751  nni = 1197  hu =    1.50e-03
+
+t =   1.00e-02  nst = 113  nfe = 0  nfi = 1798  nni = 1229  hu =    3.42e-03
+
+t =   1.00e-01  nst = 127  nfe = 0  nfi = 2024  nni = 1385  hu =    1.23e-02
+
+t =   1.00e+00  nst = 166  nfe = 0  nfi = 2715  nni = 1875  hu =    2.40e-02
+
+t =   2.00e+00  nst = 214  nfe = 0  nfi = 3551  nni = 2460  hu =    2.34e-02
+
+t =   3.00e+00  nst = 249  nfe = 0  nfi = 4112  nni = 2846  hu =    3.57e-02
+
+t =   4.00e+00  nst = 272  nfe = 0  nfi = 4473  nni = 3092  hu =    5.08e-02
+
+t =   5.00e+00  nst = 297  nfe = 0  nfi = 4852  nni = 3346  hu =    5.14e-02
+
+t =   6.00e+00  nst = 315  nfe = 0  nfi = 5118  nni = 3522  hu =    6.88e-02
+
+t =   7.00e+00  nst = 328  nfe = 0  nfi = 5303  nni = 3642  hu =    8.22e-02
+
+t =   8.00e+00  nst = 338  nfe = 0  nfi = 5442  nni = 3731  hu =    8.52e-02
+
+t =   9.00e+00  nst = 349  nfe = 0  nfi = 5593  nni = 3827  hu =    1.11e-01
+
+t =   1.00e+01  nst = 359  nfe = 0  nfi = 5723  nni = 3907  hu =    1.35e-01
+
+
+
+ Final statistics for this run:
+
+ ARKode real workspace length           = 3298 
+ ARKode integer workspace length        =   55 
+ ARKSPGMR real workspace length         = 2206 
+ ARKSPGMR integer workspace length      =   10 
+ Number of steps                       =  359 
+ Number of f-s (explicit)              =    0 
+ Number of f-s (implicit)              = 5723 
+ Number of f-s (SPGMR)                 = 12904 
+ Number of f-s (TOTAL)                 = 12904 
+ Number of setups                      =  253 
+ Number of nonlinear iterations        = 3907 
+ Number of linear iterations           = 12904 
+ Number of preconditioner evaluations  =  253 
+ Number of preconditioner solves       = 16594 
+ Number of error test failures         =    0 
+ Number of nonlinear conv. failures    =  103 
+ Number of linear convergence failures = 1072 
+ Average Krylov subspace dimension     = 3.303 
+
+
+----------------------------------------------------------------------------
+----------------------------------------------------------------------------
+
+
+Preconditioner type is           jpre = PREC_RIGHT
+
+Gram-Schmidt method type is    gstype = CLASSICAL_GS
+
+
+t =   1.00e-08  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-07  nst = 5  nfe = 0  nfi = 76  nni = 47  hu =    9.89e-08
+
+t =   1.00e-06  nst = 8  nfe = 0  nfi = 121  nni = 77  hu =    4.79e-07
+
+t =   1.00e-05  nst = 27  nfe = 0  nfi = 408  nni = 269  hu =    4.79e-07
+
+t =   1.00e-04  nst = 106  nfe = 0  nfi = 1689  nni = 1155  hu =    1.70e-05
+
+t =   1.00e-03  nst = 110  nfe = 0  nfi = 1751  nni = 1197  hu =    1.50e-03
+
+t =   1.00e-02  nst = 113  nfe = 0  nfi = 1798  nni = 1229  hu =    3.42e-03
+
+t =   1.00e-01  nst = 127  nfe = 0  nfi = 2024  nni = 1385  hu =    1.23e-02
+
+t =   1.00e+00  nst = 166  nfe = 0  nfi = 2715  nni = 1875  hu =    2.40e-02
+
+t =   2.00e+00  nst = 214  nfe = 0  nfi = 3557  nni = 2465  hu =    2.34e-02
+
+t =   3.00e+00  nst = 249  nfe = 0  nfi = 4118  nni = 2851  hu =    3.57e-02
+
+t =   4.00e+00  nst = 272  nfe = 0  nfi = 4479  nni = 3097  hu =    5.08e-02
+
+t =   5.00e+00  nst = 297  nfe = 0  nfi = 4858  nni = 3351  hu =    5.14e-02
+
+t =   6.00e+00  nst = 315  nfe = 0  nfi = 5124  nni = 3527  hu =    6.89e-02
+
+t =   7.00e+00  nst = 328  nfe = 0  nfi = 5309  nni = 3647  hu =    9.31e-02
+
+t =   8.00e+00  nst = 339  nfe = 0  nfi = 5465  nni = 3748  hu =    9.70e-02
+
+t =   9.00e+00  nst = 349  nfe = 0  nfi = 5599  nni = 3832  hu =    1.12e-01
+
+t =   1.00e+01  nst = 359  nfe = 0  nfi = 5729  nni = 3912  hu =    1.31e-01
+
+
+
+ Final statistics for this run:
+
+ ARKode real workspace length           = 3298 
+ ARKode integer workspace length        =   55 
+ ARKSPGMR real workspace length         = 2206 
+ ARKSPGMR integer workspace length      =   10 
+ Number of steps                       =  359 
+ Number of f-s (explicit)              =    0 
+ Number of f-s (implicit)              = 5729 
+ Number of f-s (SPGMR)                 = 12934 
+ Number of f-s (TOTAL)                 = 12934 
+ Number of setups                      =  254 
+ Number of nonlinear iterations        = 3912 
+ Number of linear iterations           = 12934 
+ Number of preconditioner evaluations  =  254 
+ Number of preconditioner solves       = 16627 
+ Number of error test failures         =    0 
+ Number of nonlinear conv. failures    =  103 
+ Number of linear convergence failures = 1076 
+ Average Krylov subspace dimension     = 3.306 
+
+
+----------------------------------------------------------------------------
+----------------------------------------------------------------------------
diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c
new file mode 100644
index 0000000..beadb5e
--- /dev/null
+++ b/examples/arkode/C_serial/ark_analytic.c
@@ -0,0 +1,249 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem with analytical 
+ * solution,
+ *    dy/dt = lamda*y + 1/(1+t^2) - lamda*atan(t)
+ * for t in the interval [0.0, 10.0], with initial condition: y=0. 
+ * 
+ * The stiffness of the problem is directly proportional to the 
+ * value of "lamda".  The value of lamda should be negative to
+ * result in a well-posed ODE; for values with magnitude larger 
+ * than 100 the problem becomes quite stiff.
+ * 
+ * This program solves the problem with the DIRK method,
+ * Newton iteration with the ARKDENSE dense linear solver, and a
+ * user-supplied Jacobian routine.
+ * Output is printed every 1.0 units of time (10 total).
+ * Run statistics (optional outputs) are printed at the end.
+ *-----------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <math.h>
+#include <arkode/arkode.h>           /* prototypes for ARKODE fcts., consts. */
+#include <nvector/nvector_serial.h>  /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_dense.h>     /* prototype for ARKDense */
+#include <sundials/sundials_dense.h> /* definitions DlsMat DENSE_ELEM */
+#include <sundials/sundials_types.h> /* definition of type realtype */
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);      /* initial time */
+  realtype Tf = RCONST(10.0);     /* final time */
+  realtype dTout = RCONST(1.0);   /* time between outputs */
+  long int NEQ = 1;               /* number of dependent vars. */
+  realtype reltol = 1.0e-6;       /* tolerances */
+  realtype abstol = 1.0e-10;
+  realtype lamda  = -100.0;       /* stiffness parameter */
+
+  /* general problem variables */
+  int flag;                       /* reusable error-checking flag */
+  N_Vector y = NULL;              /* empty vector for storing solution */
+  void *arkode_mem = NULL;        /* empty ARKode memory structure */
+  FILE *UFID;
+  realtype t, tout;
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nfeLS, nni, ncfn, netf;
+
+  /* Initial diagnostics output */
+  printf("\nAnalytical ODE test problem:\n");
+  printf("    lamda = %g\n",    lamda);
+  printf("   reltol = %.1e\n",  reltol);
+  printf("   abstol = %.1e\n\n",abstol);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(NEQ);          /* Create serial vector for solution */
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  N_VConst(0.0, y);             /* Specify initial condition */
+  arkode_mem = ARKodeCreate();     /* Create the solver memory */
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) &lamda);  /* Pass lamda to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);  /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKDense(arkode_mem, NEQ);                       /* Specify dense linear solver */
+  if (check_flag(&flag, "ARKDense", 1)) return 1;
+  flag = ARKDlsSetDenseJacFn(arkode_mem, Jac);            /* Set Jacobian routine */
+  if (check_flag(&flag, "ARKDlsSetDenseJacFn", 1)) return 1;
+
+  /* Specify linearly implicit RHS, with non-time-dependent Jacobian */
+  flag = ARKodeSetLinear(arkode_mem, 0);
+  if (check_flag(&flag, "ARKodeSetLinear", 1)) return 1;
+
+  /* Open output stream for results, output comment line */
+  UFID = fopen("solution.txt","w");
+  fprintf(UFID,"# t u\n");
+
+  /* output initial condition to disk */
+  fprintf(UFID," %.16e %.16e\n", T0, NV_Ith_S(y,0));  
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  tout = T0+dTout;
+  printf("        t           u\n");
+  printf("   ---------------------\n");
+  while (Tf - t > 1.0e-15) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);      /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %10.6f  %10.6f\n", t, NV_Ith_S(y,0));          /* access/print solution */
+    fprintf(UFID," %.16e %.16e\n", t, NV_Ith_S(y,0));  
+    if (flag >= 0) {                                         /* successful solve: update time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                 /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+  }
+  printf("   ---------------------\n");
+  fclose(UFID);
+
+  /* Get/print some final statistics on how the solve progressed */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKDlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKDlsGetNumJacEvals", 1);
+  flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total RHS evals for setting up the linear system = %li\n", nfeLS);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total number of linear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy(y);            /* Free y vector */
+  ARKodeFree(&arkode_mem);  /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype *rdata = (realtype *) user_data;   /* cast user_data to realtype */
+  realtype lamda = rdata[0];                  /* set shortcut for stiffness parameter */
+  realtype u = NV_Ith_S(y,0);                 /* access current solution value */
+
+  /* fill in the RHS function: "NV_Ith_S" accesses the 0th entry of ydot */
+  NV_Ith_S(ydot,0) = lamda*u + 1.0/(1.0+t*t) - lamda*atan(t);
+
+  return 0;                                   /* return with success */
+}
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *rdata = (realtype *) user_data;   /* cast user_data to realtype */
+  realtype lamda = rdata[0];                  /* set shortcut for stiffness parameter */
+
+  /* Fill in Jacobian of f: "DENSE_ELEM" accesses the (0,0) entry of J */
+  DENSE_ELEM(J,0,0) = lamda;
+
+  return 0;                                   /* return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_analytic.out b/examples/arkode/C_serial/ark_analytic.out
new file mode 100644
index 0000000..f3e2fc1
--- /dev/null
+++ b/examples/arkode/C_serial/ark_analytic.out
@@ -0,0 +1,30 @@
+
+Analytical ODE test problem:
+    lamda = -100
+   reltol = 1.0e-06
+   abstol = 1.0e-10
+
+        t           u
+   ---------------------
+    1.000000    0.785398
+    2.000000    1.107149
+    3.000000    1.249046
+    4.000000    1.325818
+    5.000000    1.373401
+    6.000000    1.405648
+    7.000000    1.428899
+    8.000000    1.446441
+    9.000000    1.460139
+   10.000000    1.471128
+   ---------------------
+
+Final Solver Statistics:
+   Internal solver steps = 559 (attempted = 559)
+   Total RHS evals:  Fe = 0,  Fi = 5594
+   Total linear solver setups = 25
+   Total RHS evals for setting up the linear system = 0
+   Total number of Jacobian evaluations = 5
+   Total number of Newton iterations = 2795
+   Total number of linear solver convergence failures = 0
+   Total number of error test failures = 0
+
diff --git a/examples/arkode/C_serial/ark_analytic_nonlin.c b/examples/arkode/C_serial/ark_analytic_nonlin.c
new file mode 100644
index 0000000..4b35bcd
--- /dev/null
+++ b/examples/arkode/C_serial/ark_analytic_nonlin.c
@@ -0,0 +1,190 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem with analytical 
+ * solution,
+ *     dy/dt = (t+1)*exp(-y)
+ * for t in the interval [0.0, 10.0], with initial condition: y=0. 
+ * This has analytical solution 
+ *      y(t) = log(0.5*t^2 + t + 1)
+ * 
+ * This program solves the problem with the ERK method.
+ * Output is printed every 1.0 units of time (10 total).
+ * Run statistics (optional outputs) are printed at the end.
+ *-----------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+#include <sundials/sundials_math.h>   /* def. of SUNRsqrt, etc. */
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);     /* initial time */
+  realtype Tf = RCONST(10.0);    /* final time */
+  realtype dTout = RCONST(1.0);  /* time between outputs */
+  long int NEQ = 1;              /* number of dependent vars. */
+  realtype reltol = 1.0e-6;      /* tolerances */
+  realtype abstol = 1.0e-10;
+
+  /* general problem variables */
+  int flag;                      /* reusable error-checking flag */
+  N_Vector y = NULL;             /* empty vector for storing solution */
+  void *arkode_mem = NULL;       /* empty ARKode memory structure */
+  FILE *UFID;
+  realtype t, tout;
+  long int nst, nst_a, nfe, nfi, netf;
+
+  /* Initial problem output */
+  printf("\nAnalytical ODE test problem:\n");
+  printf("   reltol = %.1e\n",  reltol);
+  printf("   abstol = %.1e\n\n",abstol);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(NEQ);          /* Create serial vector for solution */
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  NV_Ith_S(y,0) = 0.0;             /* Specify initial condition */
+  arkode_mem = ARKodeCreate();     /* Create the solver memory */
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully explicit, we set f_U to NULL and f_E to f. */
+  flag = ARKodeInit(arkode_mem, f, NULL, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Specify tolerances */
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Open output stream for results, output comment line */
+  UFID = fopen("solution.txt","w");
+  fprintf(UFID,"# t u\n");
+
+  /* output initial condition to disk */
+  fprintf(UFID," %.16e %.16e\n", T0, NV_Ith_S(y,0));  
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  tout = T0+dTout;
+  printf("        t           u\n");
+  printf("   ---------------------\n");
+  while (Tf - t > 1.0e-15) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);       /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %10.6f  %10.6f\n", t, NV_Ith_S(y,0));           /* access/print solution */
+    fprintf(UFID," %.16e %.16e\n", t, NV_Ith_S(y,0));  
+    if (flag >= 0) {                                          /* successful solve: update time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                  /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+  }
+  printf("   ---------------------\n");
+  fclose(UFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total number of error test failures = %li\n\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);        /* Free y vector */
+  ARKodeFree(&arkode_mem);     /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  NV_Ith_S(ydot,0) = (t+1.0)*SUNRexp(-NV_Ith_S(y,0));
+  return 0;
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_analytic_nonlin.out b/examples/arkode/C_serial/ark_analytic_nonlin.out
new file mode 100644
index 0000000..fab6545
--- /dev/null
+++ b/examples/arkode/C_serial/ark_analytic_nonlin.out
@@ -0,0 +1,24 @@
+
+Analytical ODE test problem:
+   reltol = 1.0e-06
+   abstol = 1.0e-10
+
+        t           u
+   ---------------------
+    1.000000    0.916291
+    2.000000    1.609438
+    3.000000    2.140066
+    4.000000    2.564949
+    5.000000    2.917771
+    6.000000    3.218876
+    7.000000    3.481240
+    8.000000    3.713572
+    9.000000    3.921973
+   10.000000    4.110874
+   ---------------------
+
+Final Solver Statistics:
+   Internal solver steps = 97 (attempted = 97)
+   Total RHS evals:  Fe = 586,  Fi = 0
+   Total number of error test failures = 0
+
diff --git a/examples/arkode/C_serial/ark_brusselator.c b/examples/arkode/C_serial/ark_brusselator.c
new file mode 100644
index 0000000..9869114
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator.c
@@ -0,0 +1,322 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a brusselator problem from chemical 
+ * kinetics.  This is an ODE system with 3 components, Y = [u,v,w], 
+ * satisfying the equations,
+ *    du/dt = a - (w+1)*u + v*u^2
+ *    dv/dt = w*u - v*u^2
+ *    dw/dt = (b-w)/ep - w*u
+ * for t in the interval [0.0, 10.0], with initial conditions 
+ * Y0 = [u0,v0,w0]. 
+ * 
+ * We have 3 different testing scenarios:
+ *
+ * Test 1:  u0=3.9,  v0=1.1,  w0=2.8,  a=1.2,  b=2.5,  ep=1.0e-5
+ *    Here, all three components exhibit a rapid transient change 
+ *    during the first 0.2 time units, followed by a slow and 
+ *    smooth evolution.
+ *
+ * Test 2:  u0=1.2,  v0=3.1,  w0=3,  a=1,  b=3.5,  ep=5.0e-6
+ *    Here, w experiences a fast initial transient, jumping 0.5 
+ *    within a few steps.  All values proceed smoothly until 
+ *    around t=6.5, when both u and v undergo a sharp transition, 
+ *    with u increaseing from around 0.5 to 5 and v decreasing 
+ *    from around 6 to 1 in less than 0.5 time units.  After this
+ *    transition, both u and v continue to evolve somewhat 
+ *    rapidly for another 1.4 time units, and finish off smoothly.
+ *
+ * Test 3:  u0=3,  v0=3,  w0=3.5,  a=0.5,  b=3,  ep=5.0e-4
+ *    Here, all components undergo very rapid initial transients 
+ *    during the first 0.3 time units, and all then proceed very 
+ *    smoothly for the remainder of the simulation.
+ *
+ * This file is hard-coded to use test 2.
+ * 
+ * This program solves the problem with the DIRK method, using a
+ * Newton iteration with the ARKDENSE dense linear solver, and a
+ * user-supplied Jacobian routine.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *-----------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_dense.h>      /* prototype for ARKDense solver */
+#include <sundials/sundials_dense.h>  /* defs. of DlsMat and DENSE_ELEM */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);     /* initial time */
+  realtype Tf = RCONST(10.0);    /* final time */
+  realtype dTout = RCONST(1.0);  /* time between outputs */
+  long int NEQ = 3;              /* number of dependent vars. */
+  int Nt = ceil(Tf/dTout);       /* number of output times */
+  int test = 2;                  /* test problem to run */
+  realtype reltol = 1.0e-6;      /* tolerances */
+  realtype abstol = 1.0e-10;
+  realtype a, b, ep, u0, v0, w0;
+
+  /* general problem variables */
+  int flag;                      /* reusable error-checking flag */
+  N_Vector y = NULL;             /* empty vector for storing solution */
+  void *arkode_mem = NULL;       /* empty ARKode memory structure */
+  realtype rdata[3];
+  FILE *UFID;
+  realtype t, tout;
+  int iout;
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nfeLS, nni, ncfn, netf;
+
+  /* set up the test problem according to the desired test */
+  if (test == 1) {
+    u0 = RCONST(3.9);
+    v0 = RCONST(1.1);
+    w0 = RCONST(2.8);
+    a  = RCONST(1.2);
+    b  = RCONST(2.5);
+    ep = RCONST(1.0e-5);
+  } else if (test == 3) {
+    u0 = RCONST(3.0);
+    v0 = RCONST(3.0);
+    w0 = RCONST(3.5);
+    a  = RCONST(0.5);
+    b  = RCONST(3.0);
+    ep = RCONST(5.0e-4);
+  } else {
+    u0 = RCONST(1.2);
+    v0 = RCONST(3.1);
+    w0 = RCONST(3.0);
+    a  = RCONST(1.0);
+    b  = RCONST(3.5);
+    ep = RCONST(5.0e-6);
+  }
+
+  /* Initial problem output */
+  printf("\nBrusselator ODE test problem:\n");
+  printf("    initial conditions:  u0 = %g,  v0 = %g,  w0 = %g\n",u0,v0,w0);
+  printf("    problem parameters:  a = %g,  b = %g,  ep = %g\n",a,b,ep);
+  printf("    reltol = %.1e,  abstol = %.1e\n\n",reltol,abstol);
+
+  /* Initialize data structures */
+  rdata[0] = a;     /* set user data  */
+  rdata[1] = b;
+  rdata[2] = ep;
+  y = N_VNew_Serial(NEQ);           /* Create serial vector for solution */
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  NV_Ith_S(y,0) = u0;               /* Set initial conditions */
+  NV_Ith_S(y,1) = v0;
+  NV_Ith_S(y,2) = w0;
+  arkode_mem = ARKodeCreate();      /* Create the solver memory */
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) rdata);     /* Pass rdata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);    /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKDense(arkode_mem, NEQ);                         /* Specify dense linear solver */
+  if (check_flag(&flag, "ARKDense", 1)) return 1;
+  flag = ARKDlsSetDenseJacFn(arkode_mem, Jac);              /* Set Jacobian routine */
+  if (check_flag(&flag, "ARKDlsSetDenseJacFn", 1)) return 1;
+
+  /* Open output stream for results, output comment line */
+  UFID = fopen("solution.txt","w");
+  fprintf(UFID,"# t u v w\n");
+
+  /* output initial condition to disk */
+  fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	  T0, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  tout = T0+dTout;
+  printf("        t           u           v           w\n");
+  printf("   -------------------------------------------\n");
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);      /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %10.6f  %10.6f  %10.6f  %10.6f\n",             /* access/print solution */
+           t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));
+    fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	    t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+    if (flag >= 0) {                                         /* successful solve: update time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                 /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+  }
+  printf("   -------------------------------------------\n");
+  fclose(UFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKDlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKDlsGetNumJacEvals", 1);
+  flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total RHS evals for setting up the linear system = %li\n", nfeLS);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total number of linear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);        /* Free y vector */
+  ARKodeFree(&arkode_mem);     /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype *rdata = (realtype *) user_data;   /* cast user_data to realtype */
+  realtype a  = rdata[0];                     /* access data entries */
+  realtype b  = rdata[1];
+  realtype ep = rdata[2];
+  realtype u = NV_Ith_S(y,0);                 /* access solution values */
+  realtype v = NV_Ith_S(y,1);
+  realtype w = NV_Ith_S(y,2);
+
+  /* fill in the RHS function */
+  NV_Ith_S(ydot,0) = a - (w+1.0)*u + v*u*u;
+  NV_Ith_S(ydot,1) = w*u - v*u*u;
+  NV_Ith_S(ydot,2) = (b-w)/ep - w*u;
+
+  return 0;                                  /* Return with success */
+}
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *rdata = (realtype *) user_data;   /* cast user_data to realtype */
+  realtype ep = rdata[2];                     /* access data entries */
+  realtype u = NV_Ith_S(y,0);                 /* access solution values */
+  realtype v = NV_Ith_S(y,1);
+  realtype w = NV_Ith_S(y,2);
+
+  /* fill in the Jacobian */
+  DENSE_ELEM(J,0,0) = -(w+1.0) + 2.0*u*v;
+  DENSE_ELEM(J,0,1) = u*u;
+  DENSE_ELEM(J,0,2) = -u;
+
+  DENSE_ELEM(J,1,0) = w - 2.0*u*v;
+  DENSE_ELEM(J,1,1) = -u*u;
+  DENSE_ELEM(J,1,2) = u;
+
+  DENSE_ELEM(J,2,0) = -w;
+  DENSE_ELEM(J,2,1) = 0.0;
+  DENSE_ELEM(J,2,2) = -1.0/ep - u;
+
+  return 0;                                  /* Return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_brusselator.out b/examples/arkode/C_serial/ark_brusselator.out
new file mode 100644
index 0000000..e27309a
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator.out
@@ -0,0 +1,30 @@
+
+Brusselator ODE test problem:
+    initial conditions:  u0 = 1.2,  v0 = 3.1,  w0 = 3
+    problem parameters:  a = 1,  b = 3.5,  ep = 5e-06
+    reltol = 1.0e-06,  abstol = 1.0e-10
+
+        t           u           v           w
+   -------------------------------------------
+    1.000000    1.103849    3.013163    3.499981
+    2.000000    0.688000    3.521381    3.499988
+    3.000000    0.409466    4.277885    3.499993
+    4.000000    0.367886    4.942005    3.499994
+    5.000000    0.413854    5.510624    3.499993
+    6.000000    0.589233    5.855678    3.499990
+    7.000000    4.756553    0.735408    3.499917
+    8.000000    1.813439    1.575779    3.499968
+    9.000000    0.527897    2.807368    3.499991
+   10.000000    0.305599    3.657381    3.499995
+   -------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 254 (attempted = 258)
+   Total RHS evals:  Fe = 0,  Fi = 4714
+   Total linear solver setups = 99
+   Total RHS evals for setting up the linear system = 0
+   Total number of Jacobian evaluations = 66
+   Total number of Newton iterations = 3428
+   Total number of linear solver convergence failures = 2
+   Total number of error test failures = 2
+
diff --git a/examples/arkode/C_serial/ark_brusselator1D.c b/examples/arkode/C_serial/ark_brusselator1D.c
new file mode 100644
index 0000000..e704619
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator1D.c
@@ -0,0 +1,478 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a brusselator problem from chemical 
+ * kinetics.  This is n PDE system with 3 components, Y = [u,v,w], 
+ * satisfying the equations,
+ *    u_t = du*u_xx + a - (w+1)*u + v*u^2
+ *    v_t = dv*v_xx + w*u - v*u^2
+ *    w_t = dw*w_xx + (b-w)/ep - w*u
+ * for t in [0, 80], x in [0, 1], with initial conditions
+ *    u(0,x) =  a  + 0.1*sin(pi*x)
+ *    v(0,x) = b/a + 0.1*sin(pi*x)
+ *    w(0,x) =  b  + 0.1*sin(pi*x),
+ * and with stationary boundary conditions, i.e. 
+ *    u_t(t,0) = u_t(t,1) = 0,
+ *    v_t(t,0) = v_t(t,1) = 0,
+ *    w_t(t,0) = w_t(t,1) = 0.
+ * Note: these can also be implemented as Dirichlet boundary 
+ * conditions with values identical to the initial conditions.
+ * 
+ * The spatial derivatives are computed using second-order 
+ * centered differences, with the data distributed over N points 
+ * on a uniform spatial grid.
+ *
+ * This program solves the problem with the DIRK method, using a
+ * Newton iteration with the ARKBAND band linear solver, and a
+ * user-supplied Jacobian routine.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_band.h>       /* prototype for ARKBand solver */
+#include <sundials/sundials_band.h>   /* defs. of DlsMat and BAND_ELEM */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+#include <sundials/sundials_math.h>   /* def. of SUNRsqrt, etc. */
+
+/* accessor macros between (x,v) location and 1D NVector array */
+#define IDX(x,v) (3*(x)+v)
+
+/* user data structure */
+typedef struct {
+  long int N;    /* number of intervals     */
+  realtype dx;   /* mesh spacing            */
+  realtype a;    /* constant forcing on u   */
+  realtype b;    /* steady-state value of w */
+  realtype du;   /* diffusion coeff for u   */
+  realtype dv;   /* diffusion coeff for v   */
+  realtype dw;   /* diffusion coeff for w   */
+  realtype ep;   /* stiffness parameter     */
+} *UserData;
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(long int N, long int mu, long int ml,
+               realtype t, N_Vector y, N_Vector fy,
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private helper functions  */
+static int LaplaceMatrix(realtype c, DlsMat Jac, UserData udata);
+static int ReactionJac(realtype c, N_Vector y, DlsMat Jac, UserData udata);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);    /* initial time */
+  realtype Tf = RCONST(10.0);   /* final time */
+  int Nt = 100;                 /* total number of output times */
+  int Nvar = 3;                 /* number of solution fields */
+  UserData udata = NULL;
+  realtype *data;
+  long int N = 201;             /* spatial mesh size */
+  realtype a = 0.6;             /* problem parameters */
+  realtype b = 2.0;
+  realtype du = 0.025;
+  realtype dv = 0.025;
+  realtype dw = 0.025;
+  realtype ep = 1.0e-5;         /* stiffness parameter */
+  realtype reltol = 1.0e-6;     /* tolerances */
+  realtype abstol = 1.0e-10;
+  long int NEQ, i;
+
+  /* general problem variables */
+  int flag;                     /* reusable error-checking flag */
+  N_Vector y = NULL;            /* empty vector for storing solution */
+  N_Vector umask = NULL;        /* empty mask vectors for viewing solution components */
+  N_Vector vmask = NULL;
+  N_Vector wmask = NULL;
+  void *arkode_mem = NULL;      /* empty ARKode memory structure */
+  realtype pi, t, dTout, tout, u, v, w;
+  FILE *FID, *UFID, *VFID, *WFID;
+  int iout;
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nfeLS, nni, ncfn, netf;
+
+  /* allocate udata structure */
+  udata = (UserData) malloc(sizeof(*udata));
+  if (check_flag((void *) udata, "malloc", 2)) return 1;
+
+  /* store the inputs in the UserData structure */
+  udata->N  = N;
+  udata->a  = a;
+  udata->b  = b;
+  udata->du = du;
+  udata->dv = dv;
+  udata->dw = dw;
+  udata->ep = ep;
+
+  /* set total allocated vector length */
+  NEQ = Nvar*udata->N;
+
+  /* Initial problem output */
+  printf("\n1D Brusselator PDE test problem:\n");
+  printf("    N = %li,  NEQ = %li\n", udata->N, NEQ);
+  printf("    problem parameters:  a = %g,  b = %g,  ep = %g\n",
+      udata->a, udata->b, udata->ep);
+  printf("    diffusion coefficients:  du = %g,  dv = %g,  dw = %g\n",
+      udata->du, udata->dv, udata->dw);
+  printf("    reltol = %.1e,  abstol = %.1e\n\n", reltol, abstol);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(NEQ);           /* Create serial vector for solution */
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  udata->dx = RCONST(1.0)/(N-1);    /* set spatial mesh spacing */
+  data = N_VGetArrayPointer(y);     /* Access data array for new NVector y */
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  umask = N_VNew_Serial(NEQ);       /* Create serial vector masks */
+  if (check_flag((void *)umask, "N_VNew_Serial", 0)) return 1;
+  vmask = N_VNew_Serial(NEQ);
+  if (check_flag((void *)vmask, "N_VNew_Serial", 0)) return 1;
+  wmask = N_VNew_Serial(NEQ);
+  if (check_flag((void *)wmask, "N_VNew_Serial", 0)) return 1;
+
+  /* Set initial conditions into y */
+  pi = RCONST(4.0)*atan(RCONST(1.0));
+  for (i=0; i<N; i++) {
+    data[IDX(i,0)] =  a  + RCONST(0.1)*sin(pi*i*udata->dx);  /* u */
+    data[IDX(i,1)] = b/a + RCONST(0.1)*sin(pi*i*udata->dx);  /* v */
+    data[IDX(i,2)] =  b  + RCONST(0.1)*sin(pi*i*udata->dx);  /* w */
+  }
+
+  /* Set mask array values for each solution component */
+  N_VConst(0.0, umask);
+  data = N_VGetArrayPointer(umask);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,0)] = RCONST(1.0);
+
+  N_VConst(0.0, vmask);
+  data = N_VGetArrayPointer(vmask);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,1)] = RCONST(1.0);
+
+  N_VConst(0.0, wmask);
+  data = N_VGetArrayPointer(wmask);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,2)] = RCONST(1.0);
+
+  /* Create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) udata);     /* Pass udata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);    /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKBand(arkode_mem, NEQ, 4, 4);          /* Specify the band linear solver */
+  if (check_flag(&flag, "ARKBand", 1)) return 1;
+  flag = ARKDlsSetBandJacFn(arkode_mem, Jac);     /* Set the Jacobian routine */
+  if (check_flag(&flag, "ARKDlsSetBandJacFn", 1)) return 1;
+
+  /* output spatial mesh to disk */
+  FID = fopen("bruss_mesh.txt","w");
+  for (i=0; i<N; i++)  fprintf(FID,"  %.16e\n", udata->dx*i);
+  fclose(FID);
+
+  /* Open output streams for results, access data array */
+  UFID=fopen("bruss_u.txt","w");
+  VFID=fopen("bruss_v.txt","w");
+  WFID=fopen("bruss_w.txt","w");
+
+  /* output initial condition to disk */
+  data = N_VGetArrayPointer(y);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+  for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+  for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+  fprintf(UFID,"\n");
+  fprintf(VFID,"\n");
+  fprintf(WFID,"\n");
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  dTout = (Tf-T0)/Nt;
+  tout = T0+dTout;
+  printf("        t      ||u||_rms   ||v||_rms   ||w||_rms\n");
+  printf("   ----------------------------------------------\n");
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);    /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    u = N_VWL2Norm(y,umask);                               /* access/print solution statistics */
+    u = SUNRsqrt(u*u/N);
+    v = N_VWL2Norm(y,vmask);
+    v = SUNRsqrt(v*v/N);
+    w = N_VWL2Norm(y,wmask);
+    w = SUNRsqrt(w*w/N);
+    printf("  %10.6f  %10.6f  %10.6f  %10.6f\n", t, u, v, w);
+    if (flag >= 0) {                                       /* successful solve: update output time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                               /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+
+    /* output results to disk */
+    for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+    for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+    for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+    fprintf(UFID,"\n");
+    fprintf(VFID,"\n");
+    fprintf(WFID,"\n");
+  }
+  printf("   ----------------------------------------------\n");
+  fclose(UFID);
+  fclose(VFID);
+  fclose(WFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKDlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKDlsGetNumJacEvals", 1);
+  flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total RHS evals for setting up the linear system = %li\n", nfeLS);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);         /* Free vectors */
+  N_VDestroy_Serial(umask);
+  N_VDestroy_Serial(vmask);
+  N_VDestroy_Serial(wmask);
+  free(udata);                  /* Free user data */
+  ARKodeFree(&arkode_mem);      /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  UserData udata = (UserData) user_data;      /* access problem data */
+  long int N  = udata->N;                     /* set variable shortcuts */
+  realtype a  = udata->a;
+  realtype b  = udata->b;
+  realtype ep = udata->ep;
+  realtype du = udata->du;
+  realtype dv = udata->dv;
+  realtype dw = udata->dw;
+  realtype dx = udata->dx;
+  realtype *Ydata=NULL, *dYdata=NULL;
+  realtype uconst, vconst, wconst, u, ul, ur, v, vl, vr, w, wl, wr;
+  long int i;
+
+  Ydata = N_VGetArrayPointer(y);     /* access data arrays */
+  if (check_flag((void *)Ydata, "N_VGetArrayPointer", 0)) return 1;
+  dYdata = N_VGetArrayPointer(ydot);
+  if (check_flag((void *)dYdata, "N_VGetArrayPointer", 0)) return 1;
+  N_VConst(0.0, ydot);                        /* initialize ydot to zero */
+
+  /* iterate over domain, computing all equations */
+  uconst = du/dx/dx;
+  vconst = dv/dx/dx;
+  wconst = dw/dx/dx;
+  for (i=1; i<N-1; i++) {
+    /* set shortcuts */
+    u = Ydata[IDX(i,0)];  ul = Ydata[IDX(i-1,0)];  ur = Ydata[IDX(i+1,0)];
+    v = Ydata[IDX(i,1)];  vl = Ydata[IDX(i-1,1)];  vr = Ydata[IDX(i+1,1)];
+    w = Ydata[IDX(i,2)];  wl = Ydata[IDX(i-1,2)];  wr = Ydata[IDX(i+1,2)];
+
+    /* Fill in ODE RHS for u */
+    dYdata[IDX(i,0)] = (ul - RCONST(2.0)*u + ur)*uconst + a - (w+RCONST(1.0))*u + v*u*u;
+
+    /* Fill in ODE RHS for v */
+    dYdata[IDX(i,1)] = (vl - RCONST(2.0)*v + vr)*vconst + w*u - v*u*u;
+
+    /* Fill in ODE RHS for w */
+    dYdata[IDX(i,2)] = (wl - RCONST(2.0)*w + wr)*wconst + (b-w)/ep - w*u;
+  }
+
+  /* enforce stationary boundaries */
+  dYdata[IDX(0,0)]   = dYdata[IDX(0,1)]   = dYdata[IDX(0,2)]   = 0.0;
+  dYdata[IDX(N-1,0)] = dYdata[IDX(N-1,1)] = dYdata[IDX(N-1,2)] = 0.0;
+
+  return 0;     /* Return with success */
+}
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(long int M, long int mu, long int ml,
+               realtype t, N_Vector y, N_Vector fy, 
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  UserData udata = (UserData) user_data;     /* access problem data */
+  SetToZero(J);                              /* Initialize Jacobian to zero */
+
+  /* Fill in the Laplace matrix */
+  LaplaceMatrix(RCONST(1.0), J, udata);
+
+  /* Add in the Jacobian of the reaction terms matrix */
+  ReactionJac(RCONST(1.0), y, J, udata);
+
+  return 0;                                  /* Return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Routine to compute the stiffness matrix from (L*y), scaled by the factor c.
+   We add the result into Jac and do not erase what was already there */
+static int LaplaceMatrix(realtype c, DlsMat Jac, UserData udata)
+{
+  long int i;                /* set shortcuts */
+  long int N = udata->N;
+  realtype dx = udata->dx;
+
+  /* iterate over intervals, filling in Jacobian of (L*y) */
+  for (i=1; i<N-1; i++) {
+    BAND_ELEM(Jac,IDX(i,0),IDX(i-1,0)) += c*udata->du/dx/dx;
+    BAND_ELEM(Jac,IDX(i,1),IDX(i-1,1)) += c*udata->dv/dx/dx;
+    BAND_ELEM(Jac,IDX(i,2),IDX(i-1,2)) += c*udata->dw/dx/dx;
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,0)) += -c*RCONST(2.0)*udata->du/dx/dx;
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,1)) += -c*RCONST(2.0)*udata->dv/dx/dx;
+    BAND_ELEM(Jac,IDX(i,2),IDX(i,2)) += -c*RCONST(2.0)*udata->dw/dx/dx;
+    BAND_ELEM(Jac,IDX(i,0),IDX(i+1,0)) += c*udata->du/dx/dx;
+    BAND_ELEM(Jac,IDX(i,1),IDX(i+1,1)) += c*udata->dv/dx/dx;
+    BAND_ELEM(Jac,IDX(i,2),IDX(i+1,2)) += c*udata->dw/dx/dx;
+  }
+
+  return 0;                  /* Return with success */
+}
+
+/* Routine to compute the Jacobian matrix from R(y), scaled by the factor c.
+   We add the result into Jac and do not erase what was already there */
+static int ReactionJac(realtype c, N_Vector y, DlsMat Jac, UserData udata)
+{
+  long int N  = udata->N;                      /* set shortcuts */
+  long int i;
+  realtype u, v, w;
+  realtype ep = udata->ep;
+  realtype *Ydata = N_VGetArrayPointer(y);     /* access solution array */
+  if (check_flag((void *)Ydata, "N_VGetArrayPointer", 0)) return 1;
+
+  /* iterate over nodes, filling in Jacobian of reaction terms */
+  for (i=1; i<N-1; i++) {
+
+    u = Ydata[IDX(i,0)];                       /* set nodal value shortcuts */
+    v = Ydata[IDX(i,1)];
+    w = Ydata[IDX(i,2)];
+
+    /* all vars wrt u */
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,0)) += c*(RCONST(2.0)*u*v-(w+RCONST(1.0)));
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,0)) += c*(w - RCONST(2.0)*u*v);
+    BAND_ELEM(Jac,IDX(i,2),IDX(i,0)) += c*(-w);
+
+    /* all vars wrt v */
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,1)) += c*(u*u);
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,1)) += c*(-u*u);
+
+    /* all vars wrt w */
+    BAND_ELEM(Jac,IDX(i,0),IDX(i,2)) += c*(-u);
+    BAND_ELEM(Jac,IDX(i,1),IDX(i,2)) += c*(u);
+    BAND_ELEM(Jac,IDX(i,2),IDX(i,2)) += c*(-RCONST(1.0)/ep - u);
+
+  }
+
+  return 0;                                   /* Return with success */
+}
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_brusselator1D.out b/examples/arkode/C_serial/ark_brusselator1D.out
new file mode 100644
index 0000000..f572e99
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator1D.out
@@ -0,0 +1,121 @@
+
+1D Brusselator PDE test problem:
+    N = 201,  NEQ = 603
+    problem parameters:  a = 0.6,  b = 2,  ep = 1e-05
+    diffusion coefficients:  du = 0.025,  dv = 0.025,  dw = 0.025
+    reltol = 1.0e-06,  abstol = 1.0e-10
+
+        t      ||u||_rms   ||v||_rms   ||w||_rms
+   ----------------------------------------------
+    0.100000    0.673914    3.377329    1.999987
+    0.200000    0.684316    3.356619    1.999987
+    0.300000    0.695306    3.334633    1.999986
+    0.400000    0.706918    3.311313    1.999986
+    0.500000    0.719185    3.286601    1.999986
+    0.600000    0.732137    3.260442    1.999986
+    0.700000    0.745798    3.232787    1.999985
+    0.800000    0.760185    3.203596    1.999985
+    0.900000    0.775303    3.172839    1.999985
+    1.000000    0.791135    3.140510    1.999984
+    1.100000    0.807648    3.106624    1.999984
+    1.200000    0.824771    3.071233    1.999984
+    1.300000    0.842402    3.034426    1.999983
+    1.400000    0.860384    2.996350    1.999983
+    1.500000    0.878514    2.957206    1.999983
+    1.600000    0.896525    2.917266    1.999982
+    1.700000    0.914089    2.876873    1.999982
+    1.800000    0.930823    2.836438    1.999982
+    1.900000    0.946292    2.796446    1.999982
+    2.000000    0.960033    2.757430    1.999981
+    2.100000    0.971576    2.719962    1.999981
+    2.200000    0.980475    2.684623    1.999981
+    2.300000    0.986338    2.651980    1.999981
+    2.400000    0.988852    2.622560    1.999981
+    2.500000    0.987815    2.596818    1.999981
+    2.600000    0.983141    2.575128    1.999981
+    2.700000    0.974858    2.557766    1.999981
+    2.800000    0.963114    2.544903    1.999981
+    2.900000    0.948154    2.536611    1.999981
+    3.000000    0.930299    2.532868    1.999982
+    3.100000    0.909930    2.533567    1.999982
+    3.200000    0.887464    2.538529    1.999983
+    3.300000    0.863335    2.547515    1.999983
+    3.400000    0.837978    2.560241    1.999983
+    3.500000    0.811818    2.576391    1.999984
+    3.600000    0.785255    2.595624    1.999984
+    3.700000    0.758659    2.617587    1.999985
+    3.800000    0.732363    2.641922    1.999986
+    3.900000    0.706662    2.668274    1.999986
+    4.000000    0.681809    2.696300    1.999986
+    4.100000    0.658012    2.725670    1.999987
+    4.200000    0.635435    2.756075    1.999987
+    4.300000    0.614205    2.787228    1.999988
+    4.400000    0.594404    2.818869    1.999988
+    4.500000    0.576082    2.850764    1.999989
+    4.600000    0.559255    2.882710    1.999989
+    4.700000    0.543909    2.914529    1.999989
+    4.800000    0.530011    2.946071    1.999990
+    4.900000    0.517506    2.977209    1.999990
+    5.000000    0.506326    3.007843    1.999990
+    5.100000    0.496394    3.037889    1.999990
+    5.200000    0.487626    3.067283    1.999990
+    5.300000    0.479935    3.095976    1.999991
+    5.400000    0.473237    3.123932    1.999991
+    5.500000    0.467445    3.151125    1.999991
+    5.600000    0.462480    3.177540    1.999991
+    5.700000    0.458264    3.203165    1.999991
+    5.800000    0.454726    3.227997    1.999991
+    5.900000    0.451800    3.252035    1.999991
+    6.000000    0.449425    3.275283    1.999991
+    6.100000    0.447546    3.297744    1.999991
+    6.200000    0.446115    3.319428    1.999991
+    6.300000    0.445086    3.340340    1.999991
+    6.400000    0.444419    3.360491    1.999991
+    6.500000    0.444079    3.379890    1.999991
+    6.600000    0.444034    3.398547    1.999991
+    6.700000    0.444257    3.416470    1.999991
+    6.800000    0.444722    3.433669    1.999991
+    6.900000    0.445409    3.450154    1.999991
+    7.000000    0.446297    3.465934    1.999991
+    7.100000    0.447370    3.481018    1.999991
+    7.200000    0.448614    3.495414    1.999991
+    7.300000    0.450016    3.509131    1.999991
+    7.400000    0.451564    3.522176    1.999991
+    7.500000    0.453249    3.534557    1.999991
+    7.600000    0.455064    3.546280    1.999991
+    7.700000    0.457000    3.557353    1.999991
+    7.800000    0.459052    3.567781    1.999991
+    7.900000    0.461216    3.577571    1.999991
+    8.000000    0.463486    3.586728    1.999991
+    8.100000    0.465860    3.595257    1.999991
+    8.200000    0.468335    3.603162    1.999991
+    8.300000    0.470909    3.610447    1.999991
+    8.400000    0.473582    3.617116    1.999991
+    8.500000    0.476352    3.623171    1.999991
+    8.600000    0.479220    3.628616    1.999991
+    8.700000    0.482186    3.633451    1.999991
+    8.800000    0.485250    3.637679    1.999990
+    8.900000    0.488416    3.641299    1.999990
+    9.000000    0.491684    3.644311    1.999990
+    9.100000    0.495058    3.646715    1.999990
+    9.200000    0.498540    3.648509    1.999990
+    9.300000    0.502134    3.649691    1.999990
+    9.400000    0.505844    3.650257    1.999990
+    9.500000    0.509675    3.650202    1.999990
+    9.600000    0.513632    3.649521    1.999990
+    9.700000    0.517722    3.648209    1.999990
+    9.800000    0.521951    3.646257    1.999990
+    9.900000    0.526326    3.643656    1.999990
+   10.000000    0.530857    3.640396    1.999990
+   ----------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 99 (attempted = 99)
+   Total RHS evals:  Fe = 0,  Fi = 1695
+   Total linear solver setups = 35
+   Total RHS evals for setting up the linear system = 0
+   Total number of Jacobian evaluations = 14
+   Total number of Newton iterations = 1196
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 0
+
diff --git a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.c b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.c
new file mode 100644
index 0000000..0546ddc
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.c
@@ -0,0 +1,1352 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a brusselator problem from chemical 
+ * kinetics.  This is a PDE system with 3 components, Y = [u,v,w], 
+ * satisfying the equations,
+ *    u_t = du*u_xx + a - (w+1)*u + v*u^2
+ *    v_t = dv*v_xx + w*u - v*u^2
+ *    w_t = dw*w_xx + (b-w)/ep - w*u
+ * for t in [0, 80], x in [0, 1], with initial conditions
+ *    u(0,x) =  a  + 0.1*sin(pi*x)
+ *    v(0,x) = b/a + 0.1*sin(pi*x)
+ *    w(0,x) =  b  + 0.1*sin(pi*x),
+ * and with stationary boundary conditions, i.e. 
+ *    u_t(t,0) = u_t(t,1) = 0
+ *    v_t(t,0) = v_t(t,1) = 0
+ *    w_t(t,0) = w_t(t,1) = 0.
+ * 
+ * Here, we use a piecewise linear Galerkin finite element 
+ * discretization in space, where all element-wise integrals are 
+ * computed using 3-node Gaussian quadrature (since we will have 
+ * quartic polynomials in the reaction terms for the u_t and v_t 
+ * equations, including the test function).  The time derivative 
+ * terms for this system will include a mass matrix, giving rise 
+ * to an ODE system of the form
+ *      M y_t = L y + R(y),
+ * where M is the block mass matrix for each component, L is 
+ * the block Laplace operator for each component, and R(y) is 
+ * a 3x3 block comprised of the nonlinear reaction terms for 
+ * each component.  Since it it highly inefficient to rewrite 
+ * this system as
+ *      y_t = M^{-1}(L y + R(y)),
+ * we solve this system using ARKode, with a user-supplied mass
+ * matrix.  We therefore provide functions to evaluate the ODE RHS 
+ *    f(t,y) = L y + R(y),
+ * its Jacobian
+ *    J(t,y) = L + dR/dy,
+ * and the mass matrix, M.
+ *
+ * This program solves the problem with the DIRK method, using a
+ * Newton iteration with the ARKSUPERLUMT sparse linear solver.
+ *
+ * 100 outputs are printed at equal time intervals, and run 
+ * statistics are printed at the end.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>             /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>    /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_superlumt.h>   /* prototype for ARKSuperLUMT solver */
+#include <sundials/sundials_types.h>   /* def. of type 'realtype' */
+#include <sundials/sundials_math.h>    /* def. of SUNRsqrt, etc. */
+#include <sundials/sundials_sparse.h>  /* defs. of SlsMat and SlsMat routines */
+
+
+/* accessor macros between (x,v) location and 1D NVector array */
+/* [variables are grouped according to spatial location] */
+#define IDX(x,v) (3*(x)+v)
+
+/* constants */
+#define ZERO (RCONST(0.0))
+#define ONE  (RCONST(1.0))
+#define TWO  (RCONST(2.0))
+#define HALF (RCONST(0.5))
+
+/* Gaussian quadrature nodes, weights and formula (3 node, 7th-order accurate) */
+#define X1(xl,xr)   (HALF*(xl+xr) - HALF*(xr-xl)*RCONST(0.774596669241483377035853079956))
+#define X2(xl,xr)   (HALF*(xl+xr))
+#define X3(xl,xr)   (HALF*(xl+xr) + HALF*(xr-xl)*RCONST(0.774596669241483377035853079956))
+#define W1          (RCONST(0.55555555555555555555555555555556))
+#define W2          (RCONST(0.88888888888888888888888888888889))
+#define W3          (RCONST(0.55555555555555555555555555555556))
+#define Quad(f1,f2,f3,xl,xr) (HALF*(xr-xl)*(W1*f1 + W2*f2 + W3*f3))
+
+/* evaluation macros for variables, basis functions and basis derivatives */
+#define ChiL(xl,xr,x) ((xr-x)/(xr-xl))
+#define ChiR(xl,xr,x) ((x-xl)/(xr-xl))
+#define ChiL_x(xl,xr) (ONE/(xl-xr))
+#define ChiR_x(xl,xr) (ONE/(xr-xl))
+#define Eval(ul,ur,xl,xr,x) (ul*ChiL(xl,xr,x) + ur*ChiR(xl,xr,x))
+#define Eval_x(ul,ur,xl,xr) (ul*ChiL_x(xl,xr) + ur*ChiR_x(xl,xr))
+
+
+/* user data structure */
+typedef struct {  
+  int N;         /* number of intervals     */
+  realtype *x;   /* mesh node locations     */
+  realtype a;    /* constant forcing on u   */
+  realtype b;    /* steady-state value of w */
+  realtype du;   /* diffusion coeff for u   */
+  realtype dv;   /* diffusion coeff for v   */
+  realtype dw;   /* diffusion coeff for w   */
+  realtype ep;   /* stiffness parameter     */
+  N_Vector tmp;  /* temporary vector        */
+  SlsMat R;      /* temporary storage       */
+} *UserData;
+
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int f_diff(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int f_rx(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int MassMatrix(realtype t, SlsMat M, void *user_data, 
+		      N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+static int Jac(realtype t, N_Vector y, N_Vector fy, 
+               SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private helper functions  */
+static int LaplaceMatrix(SlsMat Jac, UserData udata);
+static int ReactionJac(N_Vector y, SlsMat Jac, UserData udata);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main(int argc, char *argv[]) {
+
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);    /* initial time */
+  realtype Tf = RCONST(10.0);   /* final time */
+  int Nt = 100;                 /* total number of output times */
+  int Nvar = 3;                 /* number of solution fields */
+  UserData udata = NULL;
+  realtype *data;
+  int N = 201;                  /* spatial mesh size */
+  realtype a = 0.6;             /* problem parameters */
+  realtype b = 2.0;
+  realtype du = 0.025;
+  realtype dv = 0.025;
+  realtype dw = 0.025;
+  realtype ep = 1.0e-5;         /* stiffness parameter */
+  realtype reltol = 1.0e-6;     /* tolerances */
+  realtype abstol = 1.0e-10;
+  int i, NEQ, NNZ, num_threads;
+
+  /* general problem variables */
+  int flag;                     /* reusable error-checking flag */
+  N_Vector y = NULL;
+  N_Vector umask = NULL;
+  N_Vector vmask = NULL;
+  N_Vector wmask = NULL;
+  void *arkode_mem = NULL;
+  FILE *FID, *UFID, *VFID, *WFID;
+  realtype h, z, t, dTout, tout, u, v, w, pi;
+  int iout;
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nni, ncfn;
+  long int netf, nms, nMv;
+
+  /* if a command-line argument was supplied, set num_threads */
+  num_threads = 1;
+  if (argc > 1)
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* allocate udata structure */
+  udata = (UserData) malloc(sizeof(*udata));
+  udata->x = NULL;
+  udata->tmp = NULL;
+  udata->R = NULL;
+  if (check_flag((void *)udata, "malloc", 2)) return 1;
+
+  /* store the inputs in the UserData structure */
+  udata->N  = N;
+  udata->a  = a;
+  udata->b  = b;
+  udata->du = du;
+  udata->dv = dv;
+  udata->dw = dw;
+  udata->ep = ep;
+
+  /* set total allocated vector length (N-1 intervals, Dirichlet end points) */
+  NEQ = Nvar*udata->N;
+
+  /* Initial problem output */
+  printf("\n1D FEM Brusselator PDE test problem:\n");
+  printf("    N = %i,  NEQ = %i\n", udata->N, NEQ);
+  printf("    num_threads = %i\n", num_threads);
+  printf("    problem parameters:  a = %g,  b = %g,  ep = %g\n",
+	 udata->a, udata->b, udata->ep);
+  printf("    diffusion coefficients:  du = %g,  dv = %g,  dw = %g\n", 
+	 udata->du, udata->dv, udata->dw);
+  printf("    reltol = %.1e,  abstol = %.1e\n\n", reltol, abstol);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(NEQ);           /* Create serial vector for solution */
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  data = N_VGetArrayPointer(y);     /* Access data array for new NVector y */
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  umask = N_VNew_Serial(NEQ);       /* Create serial vector masks */
+  if (check_flag((void *)umask, "N_VNew_Serial", 0)) return 1;
+  vmask = N_VNew_Serial(NEQ);
+  if (check_flag((void *)vmask, "N_VNew_Serial", 0)) return 1;
+  wmask = N_VNew_Serial(NEQ);
+  if (check_flag((void *)wmask, "N_VNew_Serial", 0)) return 1;
+  udata->tmp = N_VNew_Serial(NEQ);  /* temporary N_Vector inside udata */
+  if (check_flag((void *) udata->tmp, "N_VNew_Serial", 0)) return 1;
+
+  /* allocate and set up spatial mesh; this [arbitrarily] clusters 
+     more intervals near the end points of the interval */
+  udata->x = (realtype *) malloc(N*sizeof(realtype));
+  if (check_flag((void *)udata->x, "malloc", 2)) return 1;
+  h = 10.0/(N-1);
+  for (i=0; i<N; i++) {
+    z = -5.0 + h*i;
+    udata->x[i] = 0.5/atan(5.0)*atan(z) + 0.5;
+  }
+
+  /* Set initial conditions into y */
+  pi = RCONST(4.0)*atan(RCONST(1.0));
+  for (i=0; i<N; i++) {
+    data[IDX(i,0)] =  a  + RCONST(0.1)*sin(pi*udata->x[i]);  /* u */
+    data[IDX(i,1)] = b/a + RCONST(0.1)*sin(pi*udata->x[i]);  /* v */
+    data[IDX(i,2)] =  b  + RCONST(0.1)*sin(pi*udata->x[i]);  /* w */
+  }
+
+  /* Set mask array values for each solution component */
+  N_VConst(0.0, umask);
+  data = N_VGetArrayPointer(umask);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,0)] = ONE;
+
+  N_VConst(0.0, vmask);
+  data = N_VGetArrayPointer(vmask);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,1)] = ONE;
+
+  N_VConst(0.0, wmask);
+  data = N_VGetArrayPointer(wmask);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,2)] = ONE;
+
+  
+  /* Create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) udata);     /* Pass udata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);    /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+  flag = ARKodeResStolerance(arkode_mem, abstol);           /* Specify residual tolerance */
+  if (check_flag(&flag, "ARKodeResStolerance", 1)) return 1;
+
+  /* Linear solver specification */
+  NNZ = 15*NEQ;
+  flag = ARKSuperLUMT(arkode_mem, num_threads, NEQ, NNZ);   /* SuperLUMT sparse solver */
+  if (check_flag(&flag, "ARKSuperLUMT", 1)) return 1;
+  flag = ARKSlsSetSparseJacFn(arkode_mem, Jac);             /* Set the Jacobian routine */
+  if (check_flag(&flag, "ARKSlsSetSparseJacFn", 1)) return 1;
+  flag = ARKMassSuperLUMT(arkode_mem, num_threads,          /* Mass matrix linear solver */
+			  NEQ, NNZ, MassMatrix);
+  if (check_flag(&flag, "ARKMassSuperLUMT", 1)) return 1;
+
+  /* output mesh to disk */
+  FID=fopen("bruss_FEM_mesh.txt","w");
+  for (i=0; i<N; i++)  fprintf(FID,"  %.16e\n", udata->x[i]);
+  fclose(FID);
+
+  /* Open output stream for results, access data arrays */
+  UFID = fopen("bruss_FEM_u.txt","w");
+  VFID = fopen("bruss_FEM_v.txt","w");
+  WFID = fopen("bruss_FEM_w.txt","w");
+  data = N_VGetArrayPointer(y);
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+
+  /* output initial condition to disk */
+  for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+  for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+  for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+  fprintf(UFID,"\n");
+  fprintf(VFID,"\n");
+  fprintf(WFID,"\n");
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t  = T0;
+  dTout = Tf/Nt;
+  tout = T0+dTout;
+  printf("        t      ||u||_rms   ||v||_rms   ||w||_rms\n");
+  printf("   ----------------------------------------------\n");
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);    /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    u = N_VWL2Norm(y,umask);                               /* access/print solution statistics */
+    u = SUNRsqrt(u*u/N);
+    v = N_VWL2Norm(y,vmask);
+    v = SUNRsqrt(v*v/N);
+    w = N_VWL2Norm(y,wmask);
+    w = SUNRsqrt(w*w/N);
+    printf("  %10.6f  %10.6f  %10.6f  %10.6f\n", t, u, v, w);
+    if (flag >= 0) {                                       /* successful solve: update output time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                               /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+
+    /* output results to disk */
+    for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+    for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+    for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+    fprintf(UFID,"\n");
+    fprintf(VFID,"\n");
+    fprintf(WFID,"\n");
+  }
+  printf("   ----------------------------------------------\n");
+  fclose(UFID);
+  fclose(VFID);
+  fclose(WFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKodeGetNumMassSolves(arkode_mem, &nms);
+  check_flag(&flag, "ARKodeGetNumMassSolves", 1);
+  flag = ARKodeGetNumMassMultiplies(arkode_mem, &nMv);
+  check_flag(&flag, "ARKodeGetNumMassMultiplies", 1);
+  flag = ARKSlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKSlsGetNumJacEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total mass matrix solves = %li\n", nms);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);            /* Free vectors */
+  N_VDestroy_Serial(umask);
+  N_VDestroy_Serial(vmask);
+  N_VDestroy_Serial(wmask);
+  SparseDestroyMat(udata->R);      /* Free user data */
+  N_VDestroy_Serial(udata->tmp);
+  free(udata->x);
+  free(udata);
+  ARKodeFree(&arkode_mem);         /* Free integrator memory */
+  return 0;
+}
+
+
+/*------------------------------
+  Functions called by the solver
+ *------------------------------*/
+
+
+/* Routine to compute the ODE RHS function f(t,y), where system is of the form
+        M y_t = f(t,y) := Ly + R(y) 
+   This routine only computes the f(t,y), leaving (M y_t) alone. */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data) {
+
+  /* local data */
+  int ier;
+
+  /* clear out RHS (to be careful) */
+  N_VConst(0.0, ydot);
+
+  /* add reaction terms to RHS */
+  ier = f_rx(t, y, ydot, user_data);
+  if (ier != 0)  return ier;
+  
+  /* add diffusion terms to RHS */
+  ier = f_diff(t, y, ydot, user_data);
+  if (ier != 0)  return ier;
+  
+  return 0;
+}
+
+
+/* Routine to compute the diffusion portion of the ODE RHS function f(t,y). */
+static int f_diff(realtype t, N_Vector y, N_Vector ydot, void *user_data) {
+
+  /* problem data */
+  UserData udata = (UserData) user_data;
+
+  /* shortcuts to number of intervals, background values */
+  int N = udata->N;
+  realtype du = udata->du;
+  realtype dv = udata->dv;
+  realtype dw = udata->dw;
+
+  /* local variables */
+  long int i;
+  realtype ul, ur, vl, vr, wl, wr;
+  realtype xl, xr, f1;
+  booleantype left, right;
+  realtype *Ydata, *RHSdata;
+  
+  /* access data arrays */
+  Ydata = N_VGetArrayPointer(y);
+  if (check_flag((void *)Ydata, "N_VGetArrayPointer", 0)) return 1;
+  RHSdata = N_VGetArrayPointer(ydot);
+  if (check_flag((void *)RHSdata, "N_VGetArrayPointer", 0)) return 1;
+
+  /* iterate over intervals, filling in residual function */
+  for (i=0; i<N-1; i++) {
+
+    /* set booleans to determine whether equations exist on the left/right */
+    left  = (i==0)     ? FALSE : TRUE;
+    right = (i==(N-2)) ? FALSE : TRUE;
+
+    /* set nodal value shortcuts (interval index aligns with left node) */
+    ul = Ydata[IDX(i,0)];
+    vl = Ydata[IDX(i,1)];
+    wl = Ydata[IDX(i,2)];
+    ur = Ydata[IDX(i+1,0)];
+    vr = Ydata[IDX(i+1,1)];
+    wr = Ydata[IDX(i+1,2)];
+
+    /* set mesh shortcuts */
+    xl = udata->x[i];
+    xr = udata->x[i+1];
+
+    /* evaluate L*y on this subinterval
+       NOTE: all f values are the same since constant on interval */
+    /*    left test function */
+    if (left) {
+      /*  u */
+      f1 = -du * Eval_x(ul,ur,xl,xr) * ChiL_x(xl,xr);
+      RHSdata[IDX(i,0)] += Quad(f1,f1,f1,xl,xr);
+
+      /*  v */
+      f1 = -dv * Eval_x(vl,vr,xl,xr) * ChiL_x(xl,xr);
+      RHSdata[IDX(i,1)] += Quad(f1,f1,f1,xl,xr);
+      
+      /*  w */
+      f1 = -dw * Eval_x(wl,wr,xl,xr) * ChiL_x(xl,xr);
+      RHSdata[IDX(i,2)] += Quad(f1,f1,f1,xl,xr);
+    }
+    /*    right test function */
+    if (right) {
+      /*  u */
+      f1 = -du * Eval_x(ul,ur,xl,xr) * ChiR_x(xl,xr);
+      RHSdata[IDX(i+1,0)] += Quad(f1,f1,f1,xl,xr);
+
+      /*  v */
+      f1 = -dv * Eval_x(vl,vr,xl,xr) * ChiR_x(xl,xr);
+      RHSdata[IDX(i+1,1)] += Quad(f1,f1,f1,xl,xr);
+
+      /*  w */
+      f1 = -dw * Eval_x(wl,wr,xl,xr) * ChiR_x(xl,xr);
+      RHSdata[IDX(i+1,2)] += Quad(f1,f1,f1,xl,xr);
+    }
+  }
+
+  return 0;
+}
+
+
+
+/* Routine to compute the reaction portion of the ODE RHS function f(t,y). */
+static int f_rx(realtype t, N_Vector y, N_Vector ydot, void *user_data) {
+
+  /* problem data */
+  UserData udata = (UserData) user_data;
+
+  /* shortcuts to number of intervals, background values */
+  int N = udata->N;
+  realtype a  = udata->a;
+  realtype b  = udata->b;
+  realtype ep = udata->ep;
+
+  /* local variables */
+  long int i;
+  realtype ul, ur, vl, vr, wl, wr;
+  realtype u, v, w, xl, xr, f1, f2, f3;
+  booleantype left, right;
+  realtype *Ydata, *RHSdata;
+
+  /* access data arrays */
+  Ydata = N_VGetArrayPointer(y);
+  if (check_flag((void *)Ydata, "N_VGetArrayPointer", 0)) return 1;
+  RHSdata = N_VGetArrayPointer(ydot);
+  if (check_flag((void *)RHSdata, "N_VGetArrayPointer", 0)) return 1;
+
+  /* iterate over intervals, filling in residual function */
+  for (i=0; i<N-1; i++) {
+
+    /* set booleans to determine whether equations exist on the left/right */
+    left  = (i==0)     ? FALSE : TRUE;
+    right = (i==(N-2)) ? FALSE : TRUE;
+
+    /* set nodal value shortcuts (interval index aligns with left node) */
+    ul = Ydata[IDX(i,0)];
+    vl = Ydata[IDX(i,1)];
+    wl = Ydata[IDX(i,2)];
+    ur = Ydata[IDX(i+1,0)];
+    vr = Ydata[IDX(i+1,1)];
+    wr = Ydata[IDX(i+1,2)];
+
+    /* set mesh shortcuts */
+    xl = udata->x[i];
+    xr = udata->x[i+1];
+
+    /* evaluate R(y) on this subinterval */
+    /*    left test function */
+    if (left) {
+      /*  u */
+      u = Eval(ul,ur,xl,xr,X1(xl,xr));
+      v = Eval(vl,vr,xl,xr,X1(xl,xr));
+      w = Eval(wl,wr,xl,xr,X1(xl,xr));
+      f1 = (a - (w+ONE)*u + v*u*u) * ChiL(xl,xr,X1(xl,xr));
+      u = Eval(ul,ur,xl,xr,X2(xl,xr));
+      v = Eval(vl,vr,xl,xr,X2(xl,xr));
+      w = Eval(wl,wr,xl,xr,X2(xl,xr));
+      f2 = (a - (w+ONE)*u + v*u*u) * ChiL(xl,xr,X2(xl,xr));
+      u = Eval(ul,ur,xl,xr,X3(xl,xr));
+      v = Eval(vl,vr,xl,xr,X3(xl,xr));
+      w = Eval(wl,wr,xl,xr,X3(xl,xr));
+      f3 = (a - (w+ONE)*u + v*u*u) * ChiL(xl,xr,X3(xl,xr));
+      RHSdata[IDX(i,0)] += Quad(f1,f2,f3,xl,xr);
+    
+      /*  v */
+      u = Eval(ul,ur,xl,xr,X1(xl,xr));
+      v = Eval(vl,vr,xl,xr,X1(xl,xr));
+      w = Eval(wl,wr,xl,xr,X1(xl,xr));
+      f1 = (w*u - v*u*u) * ChiL(xl,xr,X1(xl,xr));
+      u = Eval(ul,ur,xl,xr,X2(xl,xr));
+      v = Eval(vl,vr,xl,xr,X2(xl,xr));
+      w = Eval(wl,wr,xl,xr,X2(xl,xr));
+      f2 = (w*u - v*u*u) * ChiL(xl,xr,X2(xl,xr));
+      u = Eval(ul,ur,xl,xr,X3(xl,xr));
+      v = Eval(vl,vr,xl,xr,X3(xl,xr));
+      w = Eval(wl,wr,xl,xr,X3(xl,xr));
+      f3 = (w*u - v*u*u) * ChiL(xl,xr,X3(xl,xr));
+      RHSdata[IDX(i,1)] += Quad(f1,f2,f3,xl,xr);
+    
+      /*  w */
+      u = Eval(ul,ur,xl,xr,X1(xl,xr));
+      v = Eval(vl,vr,xl,xr,X1(xl,xr));
+      w = Eval(wl,wr,xl,xr,X1(xl,xr));
+      f1 = ((b-w)/ep - w*u) * ChiL(xl,xr,X1(xl,xr));
+      u = Eval(ul,ur,xl,xr,X2(xl,xr));
+      v = Eval(vl,vr,xl,xr,X2(xl,xr));
+      w = Eval(wl,wr,xl,xr,X2(xl,xr));
+      f2 = ((b-w)/ep - w*u) * ChiL(xl,xr,X2(xl,xr));
+      u = Eval(ul,ur,xl,xr,X3(xl,xr));
+      v = Eval(vl,vr,xl,xr,X3(xl,xr));
+      w = Eval(wl,wr,xl,xr,X3(xl,xr));
+      f3 = ((b-w)/ep - w*u) * ChiL(xl,xr,X3(xl,xr));
+      RHSdata[IDX(i,2)] += Quad(f1,f2,f3,xl,xr);
+    }
+    /*    right test function */
+    if (right) {
+      /*  u */
+      u = Eval(ul,ur,xl,xr,X1(xl,xr));
+      v = Eval(vl,vr,xl,xr,X1(xl,xr));
+      w = Eval(wl,wr,xl,xr,X1(xl,xr));
+      f1 = (a - (w+ONE)*u + v*u*u) * ChiR(xl,xr,X1(xl,xr));
+      u = Eval(ul,ur,xl,xr,X2(xl,xr));
+      v = Eval(vl,vr,xl,xr,X2(xl,xr));
+      w = Eval(wl,wr,xl,xr,X2(xl,xr));
+      f2 = (a - (w+ONE)*u + v*u*u) * ChiR(xl,xr,X2(xl,xr));
+      u = Eval(ul,ur,xl,xr,X3(xl,xr));
+      v = Eval(vl,vr,xl,xr,X3(xl,xr));
+      w = Eval(wl,wr,xl,xr,X3(xl,xr));
+      f3 = (a - (w+ONE)*u + v*u*u) * ChiR(xl,xr,X3(xl,xr));
+      RHSdata[IDX(i+1,0)] += Quad(f1,f2,f3,xl,xr);
+    
+      /*  v */
+      u = Eval(ul,ur,xl,xr,X1(xl,xr));
+      v = Eval(vl,vr,xl,xr,X1(xl,xr));
+      w = Eval(wl,wr,xl,xr,X1(xl,xr));
+      f1 = (w*u - v*u*u) * ChiR(xl,xr,X1(xl,xr));
+      u = Eval(ul,ur,xl,xr,X2(xl,xr));
+      v = Eval(vl,vr,xl,xr,X2(xl,xr));
+      w = Eval(wl,wr,xl,xr,X2(xl,xr));
+      f2 = (w*u - v*u*u) * ChiR(xl,xr,X2(xl,xr));
+      u = Eval(ul,ur,xl,xr,X3(xl,xr));
+      v = Eval(vl,vr,xl,xr,X3(xl,xr));
+      w = Eval(wl,wr,xl,xr,X3(xl,xr));
+      f3 = (w*u - v*u*u) * ChiR(xl,xr,X3(xl,xr));
+      RHSdata[IDX(i+1,1)] += Quad(f1,f2,f3,xl,xr);
+    
+      /*  w */
+      u = Eval(ul,ur,xl,xr,X1(xl,xr));
+      v = Eval(vl,vr,xl,xr,X1(xl,xr));
+      w = Eval(wl,wr,xl,xr,X1(xl,xr));
+      f1 = ((b-w)/ep - w*u) * ChiR(xl,xr,X1(xl,xr));
+      u = Eval(ul,ur,xl,xr,X2(xl,xr));
+      v = Eval(vl,vr,xl,xr,X2(xl,xr));
+      w = Eval(wl,wr,xl,xr,X2(xl,xr));
+      f2 = ((b-w)/ep - w*u) * ChiR(xl,xr,X2(xl,xr));
+      u = Eval(ul,ur,xl,xr,X3(xl,xr));
+      v = Eval(vl,vr,xl,xr,X3(xl,xr));
+      w = Eval(wl,wr,xl,xr,X3(xl,xr));
+      f3 = ((b-w)/ep - w*u) * ChiR(xl,xr,X3(xl,xr));
+      RHSdata[IDX(i+1,2)] += Quad(f1,f2,f3,xl,xr);
+    }
+  }
+
+  return 0;
+}
+
+
+
+/* Interface routine to compute the Jacobian of the full RHS function, f(y) */
+static int Jac(realtype t, N_Vector y, N_Vector fy, 
+               SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) {
+
+  /* temporary variables */
+  int ier;
+  UserData udata = (UserData) user_data;
+  int N = udata->N;
+
+  /* ensure that Jac is the correct size */
+  if ((J->M != N*3) || (J->N != N*3)) {
+    printf("Jacobian calculation error: matrix is the wrong size!\n");
+    return 1;
+  }
+  
+  /* Fill in the Laplace matrix */
+  ier = LaplaceMatrix(J, udata);
+  if (ier != 0) {
+    fprintf(stderr,"Jac: error in filling Laplace matrix = %i\n",ier);
+    return 1;
+  }
+
+  /* Create empty reaction Jacobian matrix (if not done already) */
+  if (udata->R == NULL) {
+    udata->R = SparseNewMat(J->M, J->N, J->NNZ, CSC_MAT);
+    if (udata->R == NULL) {
+      printf("Jac: error in allocating R matrix!\n");
+      return 1;
+    }
+  }
+      
+  /* Add in the Jacobian of the reaction terms matrix */
+  ier = ReactionJac(y, udata->R, udata);
+  if (ier != 0) {
+    fprintf(stderr,"Jac: error in filling reaction Jacobian = %i\n",ier);
+    return 1;
+  }
+
+  /* Add R to J */
+  ier = SparseAddMat(J,udata->R);
+  if (ier != 0) {
+    printf("Jac: error in adding sparse matrices = %i!\n",ier);
+    return 1;
+  }
+
+  return 0;
+}
+
+
+
+/* Routine to compute the mass matrix multiplying y_t. */
+static int MassMatrix(realtype t, SlsMat M, void *user_data, 
+		      N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) {
+
+  /* user data structure */
+  UserData udata = (UserData) user_data;
+
+  /* set shortcuts */
+  int N = udata->N;
+  int i, nz=0;
+  int *colptrs = *M->colptrs;
+  int *rowvals = *M->rowvals;
+
+  /* local data */
+  realtype xl, xr, f1, f2, f3, dtmp;
+
+  /* clear out mass matrix */
+  SparseSetMatToZero(M);
+
+  /* iterate over columns, filling in matrix entries */
+  for (i=0; i<N; i++) {
+
+    /* dependence on u at this node */
+    colptrs[IDX(i,0)] = nz;
+
+    /*    left u trial function */
+    if (i>0) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      M->data[nz] = Quad(f1,f2,f3,xl,xr);
+      rowvals[nz++] = IDX(i-1,0);
+    }
+    /*    this u trial function */
+    dtmp = ZERO;
+    if (i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiL(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiL(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiL(xl,xr,X3(xl,xr));
+      dtmp += Quad(f1,f2,f3,xl,xr);
+    }
+    if (i>0) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      f1 = ChiR(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiR(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiR(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      dtmp += Quad(f1,f2,f3,xl,xr);
+    }
+    M->data[nz] = dtmp;
+    rowvals[nz++] = IDX(i,0);
+    /*    right u trial function */
+    if (i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      M->data[nz] = Quad(f1,f2,f3,xl,xr);
+      rowvals[nz++] = IDX(i+1,0);
+    }
+
+
+    /* dependence on v at this node */
+    colptrs[IDX(i,1)] = nz;
+
+    /*    left v trial function */
+    if (i>0) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      M->data[nz] = Quad(f1,f2,f3,xl,xr);
+      rowvals[nz++] = IDX(i-1,1);
+    }
+    /*    this v trial function */
+    dtmp = ZERO;
+    if (i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiL(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiL(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiL(xl,xr,X3(xl,xr));
+      dtmp += Quad(f1,f2,f3,xl,xr);
+    }
+    if (i>0) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      f1 = ChiR(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiR(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiR(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      dtmp += Quad(f1,f2,f3,xl,xr);
+    }
+    M->data[nz] = dtmp;
+    rowvals[nz++] = IDX(i,1);
+    /*    right v trial function */
+    if (i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      M->data[nz] = Quad(f1,f2,f3,xl,xr);
+      rowvals[nz++] = IDX(i+1,1);
+    }
+
+
+    /* dependence on w at this node */
+    colptrs[IDX(i,2)] = nz;
+
+    /*    left w trial function */
+    if (i>0) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      M->data[nz] = Quad(f1,f2,f3,xl,xr);
+      rowvals[nz++] = IDX(i-1,2);
+    }
+    /*    this w trial function */
+    dtmp = ZERO;
+    if (i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiL(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiL(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiL(xl,xr,X3(xl,xr));
+      dtmp += Quad(f1,f2,f3,xl,xr);
+    }
+    if (i>0) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      f1 = ChiR(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiR(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiR(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      dtmp += Quad(f1,f2,f3,xl,xr);
+    }
+    M->data[nz] = dtmp;
+    rowvals[nz++] = IDX(i,2);
+    /*    right w trial function */
+    if (i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      f1 = ChiL(xl,xr,X1(xl,xr)) * ChiR(xl,xr,X1(xl,xr));
+      f2 = ChiL(xl,xr,X2(xl,xr)) * ChiR(xl,xr,X2(xl,xr));
+      f3 = ChiL(xl,xr,X3(xl,xr)) * ChiR(xl,xr,X3(xl,xr));
+      M->data[nz] = Quad(f1,f2,f3,xl,xr);
+      rowvals[nz++] = IDX(i+1,2);
+    }
+
+  }
+
+  /* signal end of data */
+  colptrs[IDX(N-1,2)+1] = nz;
+
+  return 0;
+}
+
+
+
+
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+
+
+/* Routine to compute the Laplace matrix */
+static int LaplaceMatrix(SlsMat L, UserData udata)
+{
+
+  /* set shortcuts, local variables */
+  int N = udata->N;
+  realtype du = udata->du;
+  realtype dv = udata->dv;
+  realtype dw = udata->dw;
+  int i, nz=0;
+  realtype xl, xr;
+  int *colptrs = *L->colptrs;
+  int *rowvals = *L->rowvals;
+  
+  /* clear out matrix */
+  SparseSetMatToZero(L);
+
+  /* iterate over columns, filling in Laplace matrix entries */
+  for (i=0; i<N; i++) {
+
+    /* dependence on u at this node */
+    colptrs[IDX(i,0)] = nz;
+
+    if (i>1) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      L->data[nz] = (-du) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i-1,0);
+    }
+    if (i<N-1 && i>0) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      L->data[nz] = (-du) * Quad(ONE,ONE,ONE,xl,xr) * ChiR_x(xl,xr) * ChiR_x(xl,xr);
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      L->data[nz] += (-du) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiL_x(xl,xr);
+      rowvals[nz++] = IDX(i,0);
+    }
+    if (i<N-2) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      L->data[nz] = (-du) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i+1,0);
+    }
+
+    /* dependence on v at this node */
+    colptrs[IDX(i,1)] = nz;
+
+    if (i>1) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      L->data[nz] = (-dv) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i-1,1);
+    }
+    if (i>0 && i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      L->data[nz] = (-dv) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiL_x(xl,xr);
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      L->data[nz] += (-dv) * Quad(ONE,ONE,ONE,xl,xr) * ChiR_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i,1);
+    }
+    if (i<N-2) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      L->data[nz] = (-dv) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i+1,1);
+    }
+
+    /* dependence on w at this node */
+    colptrs[IDX(i,2)] = nz;
+
+    if (i>1) {
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      L->data[nz] = (-dw) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i-1,2);
+    }
+    if (i>0 && i<N-1) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      L->data[nz] = (-dw) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiL_x(xl,xr);
+      xl = udata->x[i-1];
+      xr = udata->x[i];
+      L->data[nz] += (-dw) * Quad(ONE,ONE,ONE,xl,xr) * ChiR_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i,2);
+    }
+    if (i<N-2) {
+      xl = udata->x[i];
+      xr = udata->x[i+1];
+      L->data[nz] = (-dw) * Quad(ONE,ONE,ONE,xl,xr) * ChiL_x(xl,xr) * ChiR_x(xl,xr);
+      rowvals[nz++] = IDX(i+1,2);
+    }
+
+  }
+
+  /* signal end of data */
+  colptrs[IDX(N-1,2)+1] = nz;
+
+  return 0;
+}
+
+
+
+/* Routine to compute the Jacobian matrix from R(y) */
+static int ReactionJac(N_Vector y, SlsMat Jac, UserData udata)
+{
+  /* set shortcuts, local variables */
+  int N = udata->N;
+  int i, nz=0;
+  int *colptrs = *Jac->colptrs;
+  int *rowvals = *Jac->rowvals;
+  realtype ep = udata->ep;
+  realtype ul, uc, ur, vl, vc, vr, wl, wc, wr;
+  realtype u1l, u2l, u3l, v1l, v2l, v3l, w1l, w2l, w3l;
+  realtype u1r, u2r, u3r, v1r, v2r, v3r, w1r, w2r, w3r;
+  realtype xl, xc, xr, df1, df2, df3;
+  realtype dQdf1l, dQdf2l, dQdf3l, ChiL1l, ChiL2l, ChiL3l, ChiR1l, ChiR2l, ChiR3l;
+  realtype dQdf1r, dQdf2r, dQdf3r, ChiL1r, ChiL2r, ChiL3r, ChiR1r, ChiR2r, ChiR3r;
+
+  /* access data arrays */
+  realtype *Ydata = N_VGetArrayPointer(y);
+  if (check_flag((void *) Ydata, "N_VGetArrayPointer", 0)) return 1;
+
+  /* initialize all local variables to zero (to avoid uninitialized variable warnings) */
+  ul = uc = ur = vl = vc = vr = wl = wc = wr = 0.0;
+  u1l = u2l = u3l = v1l = v2l = v3l = w1l = w2l = w3l = 0.0;
+  u1r = u2r = u3r = v1r = v2r = v3r = w1r = w2r = w3r = 0.0;
+  xl = xc = xr = df1 = df2 = df3 = 0.0;
+  dQdf1l = dQdf2l = dQdf3l = ChiL1l = ChiL2l = ChiL3l = ChiR1l = ChiR2l = ChiR3l = 0.0;
+  dQdf1r = dQdf2r = dQdf3r = ChiL1r = ChiL2r = ChiL3r = ChiR1r = ChiR2r = ChiR3r = 0.0;
+
+  /* clear out matrix */
+  SparseSetMatToZero(Jac);
+
+  /* iterate over columns, filling in reaction Jacobian */
+  for (i=0; i<N; i++) {
+
+    /* set mesh shortcuts */
+    if (i>0)
+      xl = udata->x[i-1];
+    xc = udata->x[i];
+    if (i<N-1)
+      xr = udata->x[i+1];
+
+    /* set nodal value shortcuts */
+    if (i>0) {
+      ul = Ydata[IDX(i-1,0)];
+      vl = Ydata[IDX(i-1,1)];
+      wl = Ydata[IDX(i-1,2)];
+    }
+    uc = Ydata[IDX(i,0)];
+    vc = Ydata[IDX(i,1)];
+    wc = Ydata[IDX(i,2)];
+    if (i<N-1) {
+      ur = Ydata[IDX(i+1,0)];
+      vr = Ydata[IDX(i+1,1)];
+      wr = Ydata[IDX(i+1,2)];
+    }
+    if (i>0) {
+      u1l = Eval(ul,uc,xl,xc,X1(xl,xc));
+      v1l = Eval(vl,vc,xl,xc,X1(xl,xc));
+      w1l = Eval(wl,wc,xl,xc,X1(xl,xc));
+      u2l = Eval(ul,uc,xl,xc,X2(xl,xc));
+      v2l = Eval(vl,vc,xl,xc,X2(xl,xc));
+      w2l = Eval(wl,wc,xl,xc,X2(xl,xc));
+      u3l = Eval(ul,uc,xl,xc,X3(xl,xc));
+      v3l = Eval(vl,vc,xl,xc,X3(xl,xc));
+      w3l = Eval(wl,wc,xl,xc,X3(xl,xc));
+    }
+    if (i<N-1) {
+      u1r = Eval(uc,ur,xc,xr,X1(xc,xr));
+      v1r = Eval(vc,vr,xc,xr,X1(xc,xr));
+      w1r = Eval(wc,wr,xc,xr,X1(xc,xr));
+      u2r = Eval(uc,ur,xc,xr,X2(xc,xr));
+      v2r = Eval(vc,vr,xc,xr,X2(xc,xr));
+      w2r = Eval(wc,wr,xc,xr,X2(xc,xr));
+      u3r = Eval(uc,ur,xc,xr,X3(xc,xr));
+      v3r = Eval(vc,vr,xc,xr,X3(xc,xr));
+      w3r = Eval(wc,wr,xc,xr,X3(xc,xr));
+    }
+
+    /* set partial derivative shortcuts */
+    if (i>0) {
+      dQdf1l = Quad(ONE, ZERO, ZERO, xl, xc);
+      dQdf2l = Quad(ZERO, ONE, ZERO, xl, xc);
+      dQdf3l = Quad(ZERO, ZERO, ONE, xl, xc);
+      ChiL1l = ChiL(xl,xc,X1(xl,xc));
+      ChiL2l = ChiL(xl,xc,X2(xl,xc));
+      ChiL3l = ChiL(xl,xc,X3(xl,xc));
+      ChiR1l = ChiR(xl,xc,X1(xl,xc));
+      ChiR2l = ChiR(xl,xc,X2(xl,xc));
+      ChiR3l = ChiR(xl,xc,X3(xl,xc));
+    }
+    if (i<N-1) {
+      dQdf1r = Quad(ONE, ZERO, ZERO, xc, xr);
+      dQdf2r = Quad(ZERO, ONE, ZERO, xc, xr);
+      dQdf3r = Quad(ZERO, ZERO, ONE, xc, xr);
+      ChiL1r = ChiL(xc,xr,X1(xc,xr));
+      ChiL2r = ChiL(xc,xr,X2(xc,xr));
+      ChiL3r = ChiL(xc,xr,X3(xc,xr));
+      ChiR1r = ChiR(xc,xr,X1(xc,xr));
+      ChiR2r = ChiR(xc,xr,X2(xc,xr));
+      ChiR3r = ChiR(xc,xr,X3(xc,xr));
+    }
+
+
+    /*** evaluate dR/dy at this node ***/
+
+
+    /* dependence on u at this node */
+    colptrs[IDX(i,0)] = nz;
+
+    if (i>1) {
+      /*  dR_ul/duc */
+      df1 = (-(w1l+ONE) + TWO*v1l*u1l) * ChiL1l * ChiR1l;
+      df2 = (-(w2l+ONE) + TWO*v2l*u2l) * ChiL2l * ChiR2l;
+      df3 = (-(w3l+ONE) + TWO*v3l*u3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,0);
+
+      /*  dR_vl/duc */
+      df1 = (w1l - TWO*v1l*u1l) * ChiL1l * ChiR1l;
+      df2 = (w2l - TWO*v2l*u2l) * ChiL2l * ChiR2l;
+      df3 = (w3l - TWO*v3l*u3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,1);
+
+      /*  dR_wl/duc */
+      df1 = (-w1l) * ChiL1l * ChiR1l;
+      df2 = (-w2l) * ChiL2l * ChiR2l;
+      df3 = (-w3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,2);
+    }
+    if (i>0 && i<N-1) {
+      /*  dR_uc/duc */
+      df1 = (-(w1r+ONE) + TWO*v1r*u1r) * ChiL1r * ChiL1r;
+      df2 = (-(w2r+ONE) + TWO*v2r*u2r) * ChiL2r * ChiL2r;
+      df3 = (-(w3r+ONE) + TWO*v3r*u3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+
+      df1 = (-(w1l+ONE) + TWO*v1l*u1l) * ChiR1l * ChiR1l;
+      df2 = (-(w2l+ONE) + TWO*v2l*u2l) * ChiR2l * ChiR2l;
+      df3 = (-(w3l+ONE) + TWO*v3l*u3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] += dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i,0);
+
+      /*  dR_vc/duc */
+      df1 = (w1l - TWO*v1l*u1l) * ChiR1l * ChiR1l;
+      df2 = (w2l - TWO*v2l*u2l) * ChiR2l * ChiR2l;
+      df3 = (w3l - TWO*v3l*u3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+
+      df1 = (w1r - TWO*v1r*u1r) * ChiL1r * ChiL1r;
+      df2 = (w2r - TWO*v2r*u2r) * ChiL2r * ChiL2r;
+      df3 = (w3r - TWO*v3r*u3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] += dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i,1);
+
+      /*  dR_wc/duc */
+      df1 = (-w1r) * ChiL1r * ChiL1r;
+      df2 = (-w2r) * ChiL2r * ChiL2r;
+      df3 = (-w3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+
+      df1 = (-w1l) * ChiR1l * ChiR1l;
+      df2 = (-w2l) * ChiR2l * ChiR2l;
+      df3 = (-w3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] += dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i,2);
+    }
+    if (i<N-2) {
+      /*  dR_ur/duc */
+      df1 = (-(w1r+ONE) + TWO*v1r*u1r) * ChiL1r * ChiR1r;
+      df2 = (-(w2r+ONE) + TWO*v2r*u2r) * ChiL2r * ChiR2r;
+      df3 = (-(w3r+ONE) + TWO*v3r*u3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,0);
+
+      /*  dR_vr/duc */
+      df1 = (w1r - TWO*v1r*u1r) * ChiL1r * ChiR1r;
+      df2 = (w2r - TWO*v2r*u2r) * ChiL2r * ChiR2r;
+      df3 = (w3r - TWO*v3r*u3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,1);
+
+      /*  dR_wr/duc */
+      df1 = (-w1r) * ChiL1r * ChiR1r;
+      df2 = (-w2r) * ChiL2r * ChiR2r;
+      df3 = (-w3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,2);
+    }
+
+
+    /* dependence on v at this node */
+    colptrs[IDX(i,1)] = nz;
+
+    if (i>1) {
+      /*  dR_ul/dvc */
+      df1 = (u1l*u1l) * ChiL1l * ChiR1l;
+      df2 = (u2l*u2l) * ChiL2l * ChiR2l;
+      df3 = (u3l*u3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,0);
+
+      /*  dR_vl/dvc */
+      df1 = (-u1l*u1l) * ChiL1l * ChiR1l;
+      df2 = (-u2l*u2l) * ChiL2l * ChiR2l;
+      df3 = (-u3l*u3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,1);
+    }
+    if (i>0 && i<N-1) {
+      /*  dR_uc/dvc */
+      df1 = (u1l*u1l) * ChiR1l * ChiR1l;
+      df2 = (u2l*u2l) * ChiR2l * ChiR2l;
+      df3 = (u3l*u3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+
+      df1 = (u1r*u1r) * ChiL1r * ChiL1r;
+      df2 = (u2r*u2r) * ChiL2r * ChiL2r;
+      df3 = (u3r*u3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] += dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i,0);
+
+      /*  dR_vc/dvc */
+      df1 = (-u1l*u1l) * ChiR1l * ChiR1l;
+      df2 = (-u2l*u2l) * ChiR2l * ChiR2l;
+      df3 = (-u3l*u3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+
+      df1 = (-u1r*u1r) * ChiL1r * ChiL1r;
+      df2 = (-u2r*u2r) * ChiL2r * ChiL2r;
+      df3 = (-u3r*u3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] += dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i,1);
+    }
+    if (i<N-2) {
+      /*  dR_ur/dvc */
+      df1 = (u1r*u1r) * ChiL1r * ChiR1r;
+      df2 = (u2r*u2r) * ChiL2r * ChiR2r;
+      df3 = (u3r*u3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,0);
+
+      /*  dR_vr/dvc */
+      df1 = (-u1r*u1r) * ChiL1r * ChiR1r;
+      df2 = (-u2r*u2r) * ChiL2r * ChiR2r;
+      df3 = (-u3r*u3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,1);
+    }
+
+
+    /* dependence on w at this node */
+    colptrs[IDX(i,2)] = nz;
+
+    if (i>1) {
+      /*  dR_ul/dwc */
+      df1 = (-u1l) * ChiL1l * ChiR1l;
+      df2 = (-u2l) * ChiL2l * ChiR2l;
+      df3 = (-u3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,0);
+
+      /*  dR_vl/dwc */
+      df1 = (u1l) * ChiL1l * ChiR1l;
+      df2 = (u2l) * ChiL2l * ChiR2l;
+      df3 = (u3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,1);
+
+      /*  dR_wl/dwc */
+      df1 = (-ONE/ep - u1l) * ChiL1l * ChiR1l;
+      df2 = (-ONE/ep - u2l) * ChiL2l * ChiR2l;
+      df3 = (-ONE/ep - u3l) * ChiL3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+      rowvals[nz++] = IDX(i-1,2);
+    }
+    if (i>0 && i<N-1) {
+      /*  dR_uc/dwc */
+      df1 = (-u1l) * ChiR1l * ChiR1l;
+      df2 = (-u2l) * ChiR2l * ChiR2l;
+      df3 = (-u3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+
+      df1 = (-u1r) * ChiL1r * ChiL1r;
+      df2 = (-u2r) * ChiL2r * ChiL2r;
+      df3 = (-u3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] += dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i,0);
+
+      /*  dR_vc/dwc */
+      df1 = (u1l) * ChiR1l * ChiR1l;
+      df2 = (u2l) * ChiR2l * ChiR2l;
+      df3 = (u3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+
+      df1 = (u1r) * ChiL1r * ChiL1r;
+      df2 = (u2r) * ChiL2r * ChiL2r;
+      df3 = (u3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] += dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i,1);
+
+      /*  dR_wc/dwc */
+      df1 = (-ONE/ep - u1l) * ChiR1l * ChiR1l;
+      df2 = (-ONE/ep - u2l) * ChiR2l * ChiR2l;
+      df3 = (-ONE/ep - u3l) * ChiR3l * ChiR3l;
+      Jac->data[nz] = dQdf1l*df1 + dQdf2l*df2 + dQdf3l*df3;
+
+      df1 = (-ONE/ep - u1r) * ChiL1r * ChiL1r;
+      df2 = (-ONE/ep - u2r) * ChiL2r * ChiL2r;
+      df3 = (-ONE/ep - u3r) * ChiL3r * ChiL3r;
+      Jac->data[nz] += dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i,2);
+    }
+    if (i<N-2) {
+      /*  dR_ur/dwc */
+      df1 = (-u1r) * ChiL1r * ChiR1r;
+      df2 = (-u2r) * ChiL2r * ChiR2r;
+      df3 = (-u3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,0);
+
+      /*  dR_vr/dwc */
+      df1 = (u1r) * ChiL1r * ChiR1r;
+      df2 = (u2r) * ChiL2r * ChiR2r;
+      df3 = (u3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,1);
+
+      /*  dR_wr/dwc */
+      df1 = (-ONE/ep - u1r) * ChiL1r * ChiR1r;
+      df2 = (-ONE/ep - u2r) * ChiL2r * ChiR2r;
+      df3 = (-ONE/ep - u3r) * ChiL3r * ChiR3r;
+      Jac->data[nz] = dQdf1r*df1 + dQdf2r*df2 + dQdf3r*df3;
+      rowvals[nz++] = IDX(i+1,2);
+    }
+
+  }
+
+  /* signal end of data */
+  colptrs[IDX(N-1,2)+1] = nz;
+
+  return 0;
+}
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out
new file mode 100644
index 0000000..b7dc944
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.out
@@ -0,0 +1,121 @@
+
+1D FEM Brusselator PDE test problem:
+    N = 201,  NEQ = 603
+    num_threads = 1
+    problem parameters:  a = 0.6,  b = 2,  ep = 1e-05
+    diffusion coefficients:  du = 0.025,  dv = 0.025,  dw = 0.025
+    reltol = 1.0e-06,  abstol = 1.0e-10
+
+        t      ||u||_rms   ||v||_rms   ||w||_rms
+   ----------------------------------------------
+    0.100000    0.637854    3.356025    1.999989
+    0.200000    0.643035    3.345751    1.999989
+    0.300000    0.648532    3.334867    1.999989
+    0.400000    0.654362    3.323350    1.999989
+    0.500000    0.660542    3.311172    1.999988
+    0.600000    0.667093    3.298310    1.999988
+    0.700000    0.674031    3.284739    1.999988
+    0.800000    0.681370    3.270442    1.999988
+    0.900000    0.689121    3.255404    1.999988
+    1.000000    0.697285    3.239620    1.999988
+    1.100000    0.705854    3.223093    1.999987
+    1.200000    0.714805    3.205842    1.999987
+    1.300000    0.724099    3.187903    1.999987
+    1.400000    0.733671    3.169332    1.999987
+    1.500000    0.743429    3.150211    1.999987
+    1.600000    0.753249    3.130653    1.999987
+    1.700000    0.762974    3.110800    1.999986
+    1.800000    0.772412    3.090827    1.999986
+    1.900000    0.781337    3.070944    1.999986
+    2.000000    0.789500    3.051388    1.999986
+    2.100000    0.796639    3.032420    1.999986
+    2.200000    0.802490    3.014317    1.999986
+    2.300000    0.806810    2.997358    1.999986
+    2.400000    0.809386    2.981818    1.999986
+    2.500000    0.810060    2.967949    1.999986
+    2.600000    0.808729    2.955977    1.999986
+    2.700000    0.805360    2.946085    1.999986
+    2.800000    0.799989    2.938410    1.999986
+    2.900000    0.792711    2.933039    1.999986
+    3.000000    0.783680    2.930010    1.999986
+    3.100000    0.773095    2.929307    1.999986
+    3.200000    0.761187    2.930873    1.999986
+    3.300000    0.748207    2.934612    1.999987
+    3.400000    0.734416    2.940394    1.999987
+    3.500000    0.720073    2.948062    1.999987
+    3.600000    0.705429    2.957444    1.999987
+    3.700000    0.690714    2.968354    1.999988
+    3.800000    0.676141    2.980600    1.999988
+    3.900000    0.661891    2.993989    1.999988
+    4.000000    0.648122    3.008331    1.999989
+    4.100000    0.634961    3.023445    1.999989
+    4.200000    0.622506    3.039157    1.999989
+    4.300000    0.610828    3.055308    1.999989
+    4.400000    0.599972    3.071752    1.999989
+    4.500000    0.589962    3.088356    1.999990
+    4.600000    0.580801    3.105007    1.999990
+    4.700000    0.572477    3.121603    1.999990
+    4.800000    0.564964    3.138059    1.999990
+    4.900000    0.558227    3.154303    1.999990
+    5.000000    0.552224    3.170278    1.999990
+    5.100000    0.546907    3.185935    1.999991
+    5.200000    0.542228    3.201239    1.999991
+    5.300000    0.538137    3.216162    1.999991
+    5.400000    0.534585    3.230683    1.999991
+    5.500000    0.531525    3.244788    1.999991
+    5.600000    0.528910    3.258469    1.999991
+    5.700000    0.526699    3.271719    1.999991
+    5.800000    0.524852    3.284539    1.999991
+    5.900000    0.523334    3.296928    1.999991
+    6.000000    0.522111    3.308889    1.999991
+    6.100000    0.521154    3.320427    1.999991
+    6.200000    0.520436    3.331545    1.999991
+    6.300000    0.519932    3.342251    1.999991
+    6.400000    0.519621    3.352549    1.999991
+    6.500000    0.519484    3.362447    1.999991
+    6.600000    0.519503    3.371950    1.999991
+    6.700000    0.519664    3.381065    1.999991
+    6.800000    0.519953    3.389797    1.999991
+    6.900000    0.520358    3.398153    1.999991
+    7.000000    0.520869    3.406139    1.999991
+    7.100000    0.521477    3.413759    1.999991
+    7.200000    0.522174    3.421020    1.999991
+    7.300000    0.522953    3.427926    1.999991
+    7.400000    0.523807    3.434482    1.999991
+    7.500000    0.524732    3.440692    1.999991
+    7.600000    0.525722    3.446560    1.999991
+    7.700000    0.526775    3.452091    1.999991
+    7.800000    0.527887    3.457288    1.999991
+    7.900000    0.529055    3.462154    1.999991
+    8.000000    0.530276    3.466693    1.999991
+    8.100000    0.531549    3.470907    1.999991
+    8.200000    0.532872    3.474799    1.999991
+    8.300000    0.534244    3.478371    1.999991
+    8.400000    0.535665    3.481625    1.999991
+    8.500000    0.537133    3.484564    1.999991
+    8.600000    0.538649    3.487188    1.999991
+    8.700000    0.540213    3.489499    1.999991
+    8.800000    0.541825    3.491498    1.999991
+    8.900000    0.543486    3.493184    1.999991
+    9.000000    0.545196    3.494560    1.999991
+    9.100000    0.546958    3.495624    1.999991
+    9.200000    0.548771    3.496375    1.999991
+    9.300000    0.550638    3.496814    1.999990
+    9.400000    0.552562    3.496938    1.999990
+    9.500000    0.554543    3.496746    1.999990
+    9.600000    0.556585    3.496235    1.999990
+    9.700000    0.558691    3.495404    1.999990
+    9.800000    0.560864    3.494248    1.999990
+    9.900000    0.563108    3.492763    1.999990
+   10.000000    0.565426    3.490944    1.999990
+   ----------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 95 (attempted = 95)
+   Total RHS evals:  Fe = 0,  Fi = 1615
+   Total mass matrix solves = 289
+   Total linear solver setups = 32
+   Total number of Jacobian evaluations = 12
+   Total number of Newton iterations = 1136
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 0
diff --git a/examples/arkode/C_serial/ark_brusselator1D_klu.c b/examples/arkode/C_serial/ark_brusselator1D_klu.c
new file mode 100644
index 0000000..7a473c6
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator1D_klu.c
@@ -0,0 +1,630 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a brusselator problem from chemical 
+ * kinetics.  This is n PDE system with 3 components, Y = [u,v,w], 
+ * satisfying the equations,
+ *    u_t = du*u_xx + a - (w+1)*u + v*u^2
+ *    v_t = dv*v_xx + w*u - v*u^2
+ *    w_t = dw*w_xx + (b-w)/ep - w*u
+ * for t in [0, 80], x in [0, 1], with initial conditions
+ *    u(0,x) =  a  + 0.1*sin(pi*x)
+ *    v(0,x) = b/a + 0.1*sin(pi*x)
+ *    w(0,x) =  b  + 0.1*sin(pi*x),
+ * and with stationary boundary conditions, i.e. 
+ *    u_t(t,0) = u_t(t,1) = 0,
+ *    v_t(t,0) = v_t(t,1) = 0,
+ *    w_t(t,0) = w_t(t,1) = 0.
+ * Note: these can also be implemented as Dirichlet boundary 
+ * conditions with values identical to the initial conditions.
+ * 
+ * The spatial derivatives are computed using second-order 
+ * centered differences, with the data distributed over N points 
+ * on a uniform spatial grid.
+ *
+ * The number of spatial points N, the parameters a, b, du, dv, 
+ * dw and ep, as well as the desired relative and absolute solver 
+ * tolerances, are provided in the input file 
+ * input_brusselator1D.txt.
+ * 
+ * This program solves the problem with the DIRK method, using a
+ * Newton iteration.  The inner linear systems are solved using 
+ * the ARKKLU linear solver.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <arkode/arkode_klu.h>        /* prototype for ARKKLU solver */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+#include <sundials/sundials_math.h>   /* def. of SUNRsqrt, etc. */
+
+/* accessor macros between (x,v) location and 1D NVector array */
+#define IDX(x,v) (3*(x)+v)
+
+/* constants */
+#define ONE (RCONST(1.0))
+#define TWO (RCONST(2.0))
+
+/* user data structure */
+typedef struct {  
+  int N;         /* number of intervals     */
+  realtype dx;   /* mesh spacing            */
+  realtype a;    /* constant forcing on u   */
+  realtype b;    /* steady-state value of w */
+  realtype du;   /* diffusion coeff for u   */
+  realtype dv;   /* diffusion coeff for v   */
+  realtype dw;   /* diffusion coeff for w   */
+  realtype ep;   /* stiffness parameter     */
+  SlsMat R;      /* temporary storage       */
+} *UserData;
+
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(realtype t, N_Vector y, N_Vector fy, 
+	       SlsMat J, void *user_data, 
+	       N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private function to check function return values */
+static int LaplaceMatrix(SlsMat Jac, UserData udata);
+static int ReactionJac(N_Vector y, SlsMat Jac, UserData udata);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);    /* initial time */
+  realtype Tf = RCONST(10.0);   /* final time */
+  int Nt = 10;                  /* total number of output times */
+  int Nvar = 3;
+  UserData udata = NULL;
+  realtype *data;
+  int N = 201;                  /* spatial mesh size */
+  realtype a = 0.6;             /* problem parameters */
+  realtype b = 2.0;
+  realtype du = 0.025;
+  realtype dv = 0.025;
+  realtype dw = 0.025;
+  realtype ep = 1.0e-5;         /* stiffness parameter */
+  realtype reltol = 1.0e-6;     /* tolerances */
+  realtype abstol = 1.0e-10;
+  int i;
+  long int NEQ, NNZ;
+
+  /* general problem variables */
+  int flag;                     /* reusable error-checking flag */
+  N_Vector y = NULL;
+  N_Vector umask = NULL;
+  N_Vector vmask = NULL;
+  N_Vector wmask = NULL;
+  void *arkode_mem = NULL;
+  realtype pi;
+  FILE *FID, *UFID, *VFID, *WFID;
+  realtype t = T0;
+  realtype dTout = (Tf-T0)/Nt;
+  realtype tout = T0+dTout;
+  realtype u, v, w;
+  int iout;
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nni, ncfn, netf;
+
+  /* allocate udata structure */
+  udata = (UserData) malloc(sizeof(*udata));
+  if (check_flag((void *) udata, "malloc", 2)) return 1;
+
+  /* store the inputs in the UserData structure */
+  udata->N  = N;
+  udata->a  = a;
+  udata->b  = b;
+  udata->du = du;
+  udata->dv = dv;
+  udata->dw = dw;
+  udata->ep = ep;
+  udata->R  = NULL;
+
+  /* set total allocated vector length */
+  NEQ = Nvar*udata->N;
+
+  /* Initial problem output */
+  printf("\n1D Brusselator PDE test problem (KLU solver):\n");
+  printf("    N = %i,  NEQ = %li\n", udata->N, NEQ);
+  printf("    problem parameters:  a = %g,  b = %g,  ep = %g\n",
+	 udata->a, udata->b, udata->ep);
+  printf("    diffusion coefficients:  du = %g,  dv = %g,  dw = %g\n", 
+	 udata->du, udata->dv, udata->dw);
+  printf("    reltol = %.1e,  abstol = %.1e\n\n", reltol, abstol);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(NEQ);           /* Create serial vector for solution */
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  udata->dx = RCONST(1.0)/(N-1);    /* set spatial mesh spacing */
+  data = N_VGetArrayPointer(y);     /* Access data array for new NVector y */
+  if (check_flag((void *)data, "N_VGetArrayPointer", 0)) return 1;
+  umask = N_VNew_Serial(NEQ);       /* Create serial vector masks */
+  if (check_flag((void *)umask, "N_VNew_Serial", 0)) return 1;
+  vmask = N_VNew_Serial(NEQ);
+  if (check_flag((void *)vmask, "N_VNew_Serial", 0)) return 1;
+  wmask = N_VNew_Serial(NEQ);
+  if (check_flag((void *)wmask, "N_VNew_Serial", 0)) return 1;
+
+  /* Set initial conditions into y */
+  pi = RCONST(4.0)*atan(ONE);
+  for (i=0; i<N; i++) {
+    data[IDX(i,0)] =  a  + RCONST(0.1)*sin(pi*i*udata->dx);  /* u */
+    data[IDX(i,1)] = b/a + RCONST(0.1)*sin(pi*i*udata->dx);  /* v */
+    data[IDX(i,2)] =  b  + RCONST(0.1)*sin(pi*i*udata->dx);  /* w */
+  }
+
+  /* Set mask array values for each solution component */
+  N_VConst(0.0, umask);
+  data = N_VGetArrayPointer(umask);
+  if (check_flag((void *) data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,0)] = ONE;
+
+  N_VConst(0.0, vmask);
+  data = N_VGetArrayPointer(vmask);
+  if (check_flag((void *) data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,1)] = ONE;
+
+  N_VConst(0.0, wmask);
+  data = N_VGetArrayPointer(wmask);
+  if (check_flag((void *) data, "N_VGetArrayPointer", 0)) return 1;
+  for (i=0; i<N; i++)  data[IDX(i,2)] = ONE;
+
+
+  /* Create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if (check_flag((void *) arkode_mem, "ARKodeCreate", 0)) return 1;
+  
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) udata);     /* Pass udata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);    /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Specify the KLU sparse linear solver and Jacobian function */
+  NNZ = 5*NEQ;
+  flag = ARKKLU(arkode_mem, NEQ, NNZ, CSC_MAT);
+  if (check_flag(&flag, "ARKKLU", 1)) return 1;
+  flag = ARKSlsSetSparseJacFn(arkode_mem, Jac);
+  if (check_flag(&flag, "ARKSlsSetSparseJacFn", 1)) return 1;
+ 
+   /* output spatial mesh to disk */
+  FID = fopen("bruss_mesh.txt","w");
+  for (i=0; i<N; i++)  fprintf(FID,"  %.16e\n", udata->dx*i);
+  fclose(FID);
+
+  /* Open output stream for results, access data arrays */
+  UFID=fopen("bruss_u.txt","w");
+  VFID=fopen("bruss_v.txt","w");
+  WFID=fopen("bruss_w.txt","w");
+  data = N_VGetArrayPointer(y);
+  if (check_flag((void *) data, "N_VGetArrayPointer", 0)) return 1;
+
+  /* output initial condition to disk */
+  for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+  for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+  for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+  fprintf(UFID,"\n");
+  fprintf(VFID,"\n");
+  fprintf(WFID,"\n");
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t  = T0;
+  dTout = Tf/Nt;
+  tout = T0+dTout;
+  printf("        t      ||u||_rms   ||v||_rms   ||w||_rms\n");
+  printf("   ----------------------------------------------\n");
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);    /* call integrator */
+    u = N_VWL2Norm(y,umask);
+    u = SUNRsqrt(u*u/N);
+    v = N_VWL2Norm(y,vmask);
+    v = SUNRsqrt(v*v/N);
+    w = N_VWL2Norm(y,wmask);
+    w = SUNRsqrt(w*w/N);
+    printf("  %10.6f  %10.6f  %10.6f  %10.6f\n", t, u, v, w);
+    if (flag >= 0) {                                       /* successful solve: update output time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                               /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+
+    /* output results to disk */
+    for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[IDX(i,0)]);
+    for (i=0; i<N; i++)  fprintf(VFID," %.16e", data[IDX(i,1)]);
+    for (i=0; i<N; i++)  fprintf(WFID," %.16e", data[IDX(i,2)]);
+    fprintf(UFID,"\n");
+    fprintf(VFID,"\n");
+    fprintf(WFID,"\n");
+  }
+  printf("   ----------------------------------------------\n");
+  fclose(UFID);
+  fclose(VFID);
+  fclose(WFID);
+    
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKSlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKSlsGetNumJacEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of nonlinear iterations = %li\n", nni);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);         /* Free vectors */
+  N_VDestroy_Serial(umask);
+  N_VDestroy_Serial(vmask);
+  N_VDestroy_Serial(wmask);
+  SparseDestroyMat(udata->R);   /* Free user data */
+  free(udata);
+  ARKodeFree(&arkode_mem);
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  UserData udata = (UserData) user_data;      /* access problem data */
+  int N       = udata->N;                     /* set variable shortcuts */
+  realtype a  = udata->a;
+  realtype b  = udata->b;
+  realtype ep = udata->ep;
+  realtype du = udata->du;
+  realtype dv = udata->dv;
+  realtype dw = udata->dw;
+  realtype dx = udata->dx;
+  realtype *Ydata=NULL, *dYdata=NULL;
+  realtype uconst, vconst, wconst, u, ul, ur, v, vl, vr, w, wl, wr;
+  int i;
+
+  Ydata = N_VGetArrayPointer(y);     /* access data arrays */
+  if (check_flag((void *) Ydata, "N_VGetArrayPointer", 0)) return 1;
+  dYdata = N_VGetArrayPointer(ydot);
+  if (check_flag((void *) dYdata, "N_VGetArrayPointer", 0)) return 1;
+  N_VConst(0.0, ydot);                        /* initialize ydot to zero */
+
+  /* iterate over domain, computing all equations */
+  uconst = du/dx/dx;
+  vconst = dv/dx/dx;
+  wconst = dw/dx/dx;
+  for (i=1; i<N-1; i++) {
+
+    /* set shortcuts */
+    u = Ydata[IDX(i,0)];  ul = Ydata[IDX(i-1,0)];  ur = Ydata[IDX(i+1,0)];
+    v = Ydata[IDX(i,1)];  vl = Ydata[IDX(i-1,1)];  vr = Ydata[IDX(i+1,1)];
+    w = Ydata[IDX(i,2)];  wl = Ydata[IDX(i-1,2)];  wr = Ydata[IDX(i+1,2)];
+
+    /* u_t = du*u_xx + a - (w+1)*u + v*u^2 */
+    dYdata[IDX(i,0)] = (ul - TWO*u + ur)*uconst + a - (w+ONE)*u + v*u*u;
+
+    /* v_t = dv*v_xx + w*u - v*u^2 */
+    dYdata[IDX(i,1)] = (vl - TWO*v + vr)*vconst + w*u - v*u*u;
+
+    /* w_t = dw*w_xx + (b-w)/ep - w*u */
+    dYdata[IDX(i,2)] = (wl - TWO*w + wr)*wconst + (b-w)/ep - w*u;
+
+  }
+
+  /* enforce stationary boundaries */
+  dYdata[IDX(0,0)]   = dYdata[IDX(0,1)]   = dYdata[IDX(0,2)]   = 0.0;
+  dYdata[IDX(N-1,0)] = dYdata[IDX(N-1,1)] = dYdata[IDX(N-1,2)] = 0.0;
+
+  return 0;
+}
+
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(realtype t, N_Vector y, N_Vector fy, 
+	       SlsMat J, void *user_data, 
+	       N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  /* problem data */
+  UserData udata = (UserData) user_data;
+  int N = udata->N;
+
+  /* ensure that Jac is the correct size */
+  if ((J->M != N*3) || (J->N != N*3)) {
+    printf("Jacobian calculation error: matrix is the wrong size!\n");
+    return 1;
+  }
+  
+  /* Fill in the Laplace matrix */
+  if (LaplaceMatrix(J, udata)) {
+    printf("Jacobian calculation error in calling LaplaceMatrix!\n");
+    return 1;
+  }
+
+  /* Add in the Jacobian of the reaction terms matrix */
+  if (udata->R == NULL) {
+    udata->R = SparseNewMat(J->M, J->N, J->NNZ, CSC_MAT);
+    if (udata->R == NULL) {
+      printf("Jacobian calculation error in allocating R matrix!\n");
+      return 1;
+    }
+  }
+      
+  /* Add in the Jacobian of the reaction terms matrix */
+  if (ReactionJac(y, udata->R, udata)) {
+    printf("Jacobian calculation error in calling ReactionJac!\n");
+    return 1;
+  }
+
+  /* Add R to J */
+  if (SparseAddMat(J,udata->R) != 0) {
+    printf("Jacobian calculation error in adding sparse matrices!\n");
+    return 1;
+  }
+
+  return 0;
+}
+
+
+
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Routine to compute the stiffness matrix from (L*y) */
+static int LaplaceMatrix(SlsMat Lap, UserData udata)
+{
+  int N = udata->N;  /* set shortcuts */
+  int i, nz=0;
+  realtype uconst, uconst2, vconst, vconst2, wconst, wconst2;
+  int *colptrs = *Lap->colptrs;
+  int *rowvals = *Lap->rowvals;
+  realtype *data = Lap->data;
+  
+  /* clear out matrix */
+  SparseSetMatToZero(Lap);
+
+  /* set first column to zero */
+  colptrs[IDX(0,0)] = nz;
+  colptrs[IDX(0,1)] = nz;
+  colptrs[IDX(0,2)] = nz;
+  
+  /* iterate over nodes, filling in Laplacian entries depending on these */
+  uconst  = (udata->du)/(udata->dx)/(udata->dx);
+  uconst2 = -TWO*uconst;
+  vconst  = (udata->dv)/(udata->dx)/(udata->dx);
+  vconst2 = -TWO*vconst;
+  wconst  = (udata->dw)/(udata->dx)/(udata->dx);
+  wconst2 = -TWO*wconst;
+  for (i=1; i<N-1; i++) {
+
+    /* dependence on u at this node */
+    colptrs[IDX(i,0)] = nz;
+    if (i>1) {                /* node to left */
+      data[nz] = uconst;
+      rowvals[nz++] = IDX(i-1,0);
+    }
+
+    data[nz] = uconst2;  /* self */
+    rowvals[nz++] = IDX(i,0);
+
+    if (i<N-2) {              /* node to right */
+      data[nz] = uconst;
+      rowvals[nz++] = IDX(i+1,0);
+    }
+
+    /* dependence on v at this node */
+    colptrs[IDX(i,1)] = nz;
+    if (i>1) {                /* node to left */
+      data[nz] = vconst;
+      rowvals[nz++] = IDX(i-1,1);
+    }
+
+    data[nz] = vconst2;  /* self */
+    rowvals[nz++] = IDX(i,1);
+
+    if (i<N-2) {              /* node to right */
+      data[nz] = vconst;
+      rowvals[nz++] = IDX(i+1,1);
+    }
+
+    /* dependence on w at this node */
+    colptrs[IDX(i,2)] = nz;
+    if (i>1) {                /* node to left */
+      data[nz] = wconst;
+      rowvals[nz++] = IDX(i-1,2);
+    }
+
+    data[nz] = wconst2;  /* self */
+    rowvals[nz++] = IDX(i,2);
+
+    if (i<N-2) {              /* node to right */
+      data[nz] = wconst;
+      rowvals[nz++] = IDX(i+1,2);
+    }
+
+  }
+
+  /* set last column to zero */
+  colptrs[IDX(N-1,0)] = nz;
+  colptrs[IDX(N-1,1)] = nz;
+  colptrs[IDX(N-1,2)] = nz;
+  
+  /* end of data */
+  colptrs[IDX(N-1,2)+1] = nz;
+
+  return 0;
+}
+
+
+
+/* Routine to compute the Jacobian matrix from R(y) */
+static int ReactionJac(N_Vector y, SlsMat Jac, UserData udata)
+{
+  int N = udata->N;                            /* set shortcuts */
+  int i, nz=0;
+  realtype u, v, w;
+  realtype ep = udata->ep;
+  int *colptrs = *Jac->colptrs;
+  int *rowvals = *Jac->rowvals;
+  realtype *data = Jac->data;
+  realtype *Ydata = N_VGetArrayPointer(y);     /* access solution array */
+  if (check_flag((void *) Ydata, "N_VGetArrayPointer", 0)) return 1;
+
+  /* clear out matrix */
+  SparseSetMatToZero(Jac);
+
+  /* set first matrix column to zero */
+  colptrs[IDX(0,0)] = 0;
+  colptrs[IDX(0,1)] = 0;
+  colptrs[IDX(0,2)] = 0;
+  
+  /* iterate over interior nodes, filling in Jacobian entries */
+  for (i=1; i<N-1; i++) {
+
+    /* set nodal value shortcuts */
+    u = Ydata[IDX(i,0)];
+    v = Ydata[IDX(i,1)];
+    w = Ydata[IDX(i,2)];
+
+    /* dependence on u at this node */
+    colptrs[IDX(i,0)] = nz;
+
+    rowvals[nz] = IDX(i,0);        /* fu wrt u */
+    data[nz++] = TWO*u*v - w - ONE;
+
+    rowvals[nz] = IDX(i,1);        /* fv wrt u */
+    data[nz++] = w - TWO*u*v;
+
+    rowvals[nz] = IDX(i,2);        /* fw wrt u */
+    data[nz++] = -w;
+
+    /* dependence on v at this node */
+    colptrs[IDX(i,1)] = nz;
+
+    rowvals[nz] = IDX(i,0);        /* fu wrt v */
+    data[nz++] = u*u;
+
+    rowvals[nz] = IDX(i,1);        /* fv wrt v */
+    data[nz++] = -u*u;
+
+    /* dependence on w at this node */
+    colptrs[IDX(i,2)] = nz;
+
+    rowvals[nz] = IDX(i,0);        /* fu wrt w */
+    data[nz++] = -u;
+
+    rowvals[nz] = IDX(i,1);        /* fv wrt w */
+    data[nz++] = u;
+
+    rowvals[nz] = IDX(i,2);        /* fw wrt w */
+    data[nz++] = -ONE/ep - u;
+
+  }
+
+  /* set last matrix column to zero */
+  colptrs[IDX(N-1,0)] = nz;
+  colptrs[IDX(N-1,1)] = nz;
+  colptrs[IDX(N-1,2)] = nz;
+
+  /* end of data */
+  colptrs[IDX(N-1,2)+1] = nz;
+
+  return 0;
+}
+
+
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_brusselator1D_klu.out b/examples/arkode/C_serial/ark_brusselator1D_klu.out
new file mode 100644
index 0000000..ed2d8ed
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator1D_klu.out
@@ -0,0 +1,29 @@
+
+1D Brusselator PDE test problem (KLU solver):
+    N = 201,  NEQ = 603
+    problem parameters:  a = 0.6,  b = 2,  ep = 1e-05
+    diffusion coefficients:  du = 0.025,  dv = 0.025,  dw = 0.025
+    reltol = 1.0e-06,  abstol = 1.0e-10
+
+        t      ||u||_rms   ||v||_rms   ||w||_rms
+   ----------------------------------------------
+    1.000000    0.791135    3.140510    1.999984
+    2.000000    0.960033    2.757430    1.999981
+    3.000000    0.930299    2.532868    1.999982
+    4.000000    0.681809    2.696300    1.999986
+    5.000000    0.506326    3.007843    1.999990
+    6.000000    0.449425    3.275283    1.999991
+    7.000000    0.446297    3.465934    1.999991
+    8.000000    0.463486    3.586728    1.999991
+    9.000000    0.491684    3.644311    1.999990
+   10.000000    0.530857    3.640396    1.999990
+   ----------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 99 (attempted = 99)
+   Total RHS evals:  Fe = 0,  Fi = 1695
+   Total linear solver setups = 35
+   Total number of Jacobian evaluations = 14
+   Total number of nonlinear iterations = 1196
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 0
diff --git a/examples/arkode/C_serial/ark_brusselator_fp.c b/examples/arkode/C_serial/ark_brusselator_fp.c
new file mode 100644
index 0000000..540ded2
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator_fp.c
@@ -0,0 +1,294 @@
+/*-----------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a brusselator problem from chemical 
+ * kinetics.  This is an ODE system with 3 components, Y = [u,v,w], 
+ * satisfying the equations,
+ *    du/dt = a - (w+1)*u + v*u^2
+ *    dv/dt = w*u - v*u^2
+ *    dw/dt = (b-w)/ep - w*u
+ * for t in the interval [0.0, 10.0], with initial conditions 
+ * Y0 = [u0,v0,w0]. 
+ * 
+ * We have 3 different testing scenarios:
+ *
+ * Test 1:  u0=3.9,  v0=1.1,  w0=2.8,  a=1.2,  b=2.5,  ep=1.0e-5
+ *    Here, all three components exhibit a rapid transient change 
+ *    during the first 0.2 time units, followed by a slow and 
+ *    smooth evolution.
+ *
+ * Test 2:  u0=1.2,  v0=3.1,  w0=3,  a=1,  b=3.5,  ep=5.0e-6
+ *    Here, w experiences a fast initial transient, jumping 0.5 
+ *    within a few steps.  All values proceed smoothly until 
+ *    around t=6.5, when both u and v undergo a sharp transition, 
+ *    with u increaseing from around 0.5 to 5 and v decreasing 
+ *    from around 6 to 1 in less than 0.5 time units.  After this
+ *    transition, both u and v continue to evolve somewhat 
+ *    rapidly for another 1.4 time units, and finish off smoothly.
+ *
+ * Test 3:  u0=3,  v0=3,  w0=3.5,  a=0.5,  b=3,  ep=5.0e-4
+ *    Here, all components undergo very rapid initial transients 
+ *    during the first 0.3 time units, and all then proceed very 
+ *    smoothly for the remainder of the simulation.
+ *
+ * This file is hard-coded to use test 3.
+ * 
+ * This program solves the problem with the ARK method, using an
+ * accelerated fixed-point iteration for the nonlinear solver.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *-----------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+
+/* User-supplied Functions Called by the Solver */
+static int fe(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int fi(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);     /* initial time */
+  realtype Tf = RCONST(10.0);    /* final time */
+  realtype dTout = RCONST(1.0);  /* time between outputs */
+  long int NEQ = 3;              /* number of dependent vars. */
+  int Nt = ceil(Tf/dTout);       /* number of output times */
+  int test = 3;                  /* test problem to run */
+  realtype reltol = 1.0e-6;      /* tolerances */
+  realtype abstol = 1.0e-10;
+  int fp_m = 3;                  /* dimension of acceleration subspace */
+  int maxcor = 10;               /* maximum # of nonlinear iterations/step */
+  realtype a, b, ep, u0, v0, w0;
+  realtype rdata[3];
+
+  /* general problem variables */
+  int flag;                      /* reusable error-checking flag */
+  N_Vector y = NULL;             /* empty vector for storing solution */
+  void *arkode_mem = NULL;       /* empty ARKode memory structure */
+  FILE *UFID;
+  realtype t, tout;
+  int iout;
+  long int nst, nst_a, nfe, nfi, nni, ncfn, netf;
+
+  /* set up the test problem according to the desired test */
+  if (test == 1) {
+    u0 = RCONST(3.9);
+    v0 = RCONST(1.1);
+    w0 = RCONST(2.8);
+    a  = RCONST(1.2);
+    b  = RCONST(2.5);
+    ep = RCONST(1.0e-5);
+  } else if (test == 3) {
+    u0 = RCONST(3.0);
+    v0 = RCONST(3.0);
+    w0 = RCONST(3.5);
+    a  = RCONST(0.5);
+    b  = RCONST(3.0);
+    ep = RCONST(5.0e-4);
+  } else {
+    u0 = RCONST(1.2);
+    v0 = RCONST(3.1);
+    w0 = RCONST(3.0);
+    a  = RCONST(1.0);
+    b  = RCONST(3.5);
+    ep = RCONST(5.0e-6);
+  }
+
+  /* Initial problem output */
+  printf("\nBrusselator ODE test problem, fixed-point solver:\n");
+  printf("    initial conditions:  u0 = %g,  v0 = %g,  w0 = %g\n",u0,v0,w0);
+  printf("    problem parameters:  a = %g,  b = %g,  ep = %g\n",a,b,ep);
+  printf("    reltol = %.1e,  abstol = %.1e\n\n",reltol,abstol);
+
+  /* Initialize data structures */
+  rdata[0] = a;    /* set user data  */
+  rdata[1] = b;
+  rdata[2] = ep;
+  y = N_VNew_Serial(NEQ);           /* Create serial vector for solution */
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return 1;
+  NV_Ith_S(y,0) = u0;               /* Set initial conditions */
+  NV_Ith_S(y,1) = v0;
+  NV_Ith_S(y,2) = w0;
+  arkode_mem = ARKodeCreate();      /* Create the solver memory */
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side functions in y'=fe(t,y)+fi(t,y), the inital time T0, 
+     and the initial dependent variable vector y. */
+  flag = ARKodeInit(arkode_mem, fe, fi, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) rdata);     /* Pass rdata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);    /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+  flag = ARKodeSetFixedPoint(arkode_mem, fp_m);             /* Specify fixed-point solver */
+  if (check_flag(&flag, "ARKodeSetFixedPoint", 1)) return 1;
+  flag = ARKodeSetMaxNonlinIters(arkode_mem, maxcor);       /* Increase default iterations */
+  if (check_flag(&flag, "ARKodeSetMaxNonlinIters", 1)) return 1;
+
+  /* Open output stream for results, output comment line */
+  UFID = fopen("solution.txt","w");
+  fprintf(UFID,"# t u v w\n");
+
+  /* output initial condition to disk */
+  fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	  T0, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  tout = T0+dTout;
+  printf("        t           u           v           w\n");
+  printf("   ----------------------------------------------\n");
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);      /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %10.6f  %10.6f  %10.6f  %10.6f\n",             /* access/print solution */
+           t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));
+    fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	    t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+    if (flag >= 0) {                                         /* successful solve: update time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                 /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+  }
+  printf("   ----------------------------------------------\n");
+  fclose(UFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total number of fixed-point iterations = %li\n", nni);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);        /* Free y vector */
+  ARKodeFree(&arkode_mem);     /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* fi routine to compute the implicit portion of the ODE RHS. */
+static int fi(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype *rdata = (realtype *) user_data;   /* cast user_data to realtype */
+  realtype b  = rdata[1];                     /* access data entries */
+  realtype ep = rdata[2];
+  realtype w = NV_Ith_S(y,2);                 /* access solution values */
+
+  /* fill in the RHS function */
+  NV_Ith_S(ydot,0) = 0.0;
+  NV_Ith_S(ydot,1) = 0.0;
+  NV_Ith_S(ydot,2) = (b-w)/ep;
+
+  return 0;                                  /* Return with success */
+}
+
+/* fe routine to compute the explicit portion of the ODE RHS. */
+static int fe(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype *rdata = (realtype *) user_data;   /* cast user_data to realtype */
+  realtype a  = rdata[0];                     /* access data entries */
+  realtype u = NV_Ith_S(y,0);                 /* access solution values */
+  realtype v = NV_Ith_S(y,1);
+  realtype w = NV_Ith_S(y,2);
+
+  /* fill in the RHS function */
+  NV_Ith_S(ydot,0) = a - (w+1.0)*u + v*u*u;
+  NV_Ith_S(ydot,1) = w*u - v*u*u;
+  NV_Ith_S(ydot,2) = -w*u;
+
+  return 0;                                  /* Return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_brusselator_fp.out b/examples/arkode/C_serial/ark_brusselator_fp.out
new file mode 100644
index 0000000..ed3b6a4
--- /dev/null
+++ b/examples/arkode/C_serial/ark_brusselator_fp.out
@@ -0,0 +1,27 @@
+
+Brusselator ODE test problem, fixed-point solver:
+    initial conditions:  u0 = 3,  v0 = 3,  w0 = 3.5
+    problem parameters:  a = 0.5,  b = 3,  ep = 0.0005
+    reltol = 1.0e-06,  abstol = 1.0e-10
+
+        t           u           v           w
+   ----------------------------------------------
+    1.000000    1.897255    1.274939    2.997155
+    2.000000    0.346125    2.366448    2.999481
+    3.000000    0.147442    2.862061    2.999783
+    4.000000    0.140733    3.226731    2.999788
+    5.000000    0.142659    3.583206    2.999785
+    6.000000    0.145095    3.936910    2.999784
+    7.000000    0.147720    4.287893    2.999777
+    8.000000    0.150542    4.635957    2.999776
+    9.000000    0.153590    4.980863    2.999768
+   10.000000    0.156901    5.322330    2.999765
+   ----------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 730 (attempted = 730)
+   Total RHS evals:  Fe = 4384,  Fi = 18798
+   Total number of fixed-point iterations = 14414
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 0
+
diff --git a/examples/arkode/C_serial/ark_heat1D.c b/examples/arkode/C_serial/ark_heat1D.c
new file mode 100644
index 0000000..77c4daa
--- /dev/null
+++ b/examples/arkode/C_serial/ark_heat1D.c
@@ -0,0 +1,320 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a simple 1D heat equation,
+ *    u_t = k*u_xx + f
+ * for t in [0, 10], x in [0, 1], with initial conditions
+ *    u(0,x) =  0
+ * Dirichlet boundary conditions, i.e. 
+ *    u_t(t,0) = u_t(t,1) = 0,
+ * and a point-source heating term,
+ *    f = 1 for x=0.5.
+ * 
+ * The spatial derivatives are computed using second-order 
+ * centered differences, with the data distributed over N points 
+ * on a uniform spatial grid.
+ *
+ * This program solves the problem with either an ERK or DIRK
+ * method.  For the DIRK method, we use a Newton iteration with 
+ * the PCG linear solver, and a user-supplied Jacobian-vector 
+ * product routine.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_pcg.h>        /* prototype for ARKPcg solver */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+#include <sundials/sundials_math.h>   /* def. of SUNRsqrt, etc. */
+
+/* user data structure */
+typedef struct {
+  long int N;    /* number of intervals   */
+  realtype dx;   /* mesh spacing          */
+  realtype k;    /* diffusion coefficient */
+} *UserData;
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(N_Vector v, N_Vector Jv, realtype t, N_Vector y,
+            N_Vector fy, void *user_data, N_Vector tmp);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main() {
+
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);   /* initial time */
+  realtype Tf = RCONST(1.0);   /* final time */
+  int Nt = 10;                 /* total number of output times */
+  realtype rtol = 1.e-6;       /* relative tolerance */
+  realtype atol = 1.e-10;      /* absolute tolerance */
+  UserData udata = NULL;
+  realtype *data;
+  long int N = 201;            /* spatial mesh size */
+  realtype k = 0.5;            /* heat conductivity */
+  long int i;
+
+  /* general problem variables */
+  int flag;                 /* reusable error-checking flag */
+  N_Vector y = NULL;             /* empty vector for storing solution */
+  void *arkode_mem = NULL;        /* empty ARKode memory structure */
+  FILE *FID, *UFID;
+  realtype t, dTout, tout;
+  int iout;
+  long int nst, nst_a, nfe, nfi, nsetups, nli, nJv, nlcf, nni, ncfn, netf;
+
+  /* allocate and fill udata structure */
+  udata = (UserData) malloc(sizeof(*udata));
+  udata->N = N;
+  udata->k = k;
+  udata->dx = RCONST(1.0)/(1.0*N-1.0);     /* mesh spacing */
+
+  /* Initial problem output */
+  printf("\n1D Heat PDE test problem:\n");
+  printf("  N = %li\n", udata->N);
+  printf("  diffusion coefficient:  k = %g\n", udata->k);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(N);            /* Create serial vector for solution */
+  if (check_flag((void *) y, "N_VNew_Serial", 0)) return 1;
+  N_VConst(0.0, y);                /* Set initial conditions */
+  arkode_mem = ARKodeCreate();     /* Create the solver memory */
+  if (check_flag((void *) arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) udata);   /* Pass udata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSetMaxNumSteps(arkode_mem, 10000);         /* Increase max num steps  */
+  if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) return 1;
+  flag = ARKodeSetPredictorMethod(arkode_mem, 1);         /* Specify maximum-order predictor */
+  if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, rtol, atol);      /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKPcg(arkode_mem, 0, N);                        /* Specify the PCG solver */
+  if (check_flag(&flag, "ARKPcg", 1)) return 1;
+  flag = ARKSpilsSetJacTimesVecFn(arkode_mem, Jac);       /* Set the Jacobian routine */
+  if (check_flag(&flag, "ARKSpilsSetJacTimesVecFn", 1)) return 1;
+
+  /* Specify linearly implicit RHS, with non-time-dependent Jacobian */
+  flag = ARKodeSetLinear(arkode_mem, 0);
+  if (check_flag(&flag, "ARKodeSetLinear", 1)) return 1;
+
+  /* output mesh to disk */
+  FID=fopen("heat_mesh.txt","w");
+  for (i=0; i<N; i++)  fprintf(FID,"  %.16e\n", udata->dx*i);
+  fclose(FID);
+
+  /* Open output stream for results, access data array */
+  UFID=fopen("heat1D.txt","w");
+  data = N_VGetArrayPointer(y);
+
+  /* output initial condition to disk */
+  for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[i]);
+  fprintf(UFID,"\n");
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  dTout = (Tf-T0)/Nt;
+  tout = T0+dTout;
+  printf("        t      ||u||_rms\n");
+  printf("   -------------------------\n");
+  printf("  %10.6f  %10.6f\n", t, SUNRsqrt(N_VDotProd(y,y)/N));
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);         /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %10.6f  %10.6f\n", t, SUNRsqrt(N_VDotProd(y,y)/N));   /* print solution stats */
+    if (flag >= 0) {                                            /* successful solve: update output time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                    /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+
+    /* output results to disk */
+    for (i=0; i<N; i++)  fprintf(UFID," %.16e", data[i]);
+    fprintf(UFID,"\n");
+  }
+  printf("   -------------------------\n");
+  fclose(UFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKSpilsGetNumLinIters(arkode_mem, &nli);
+  check_flag(&flag, "ARKSpilsGetNumLinIters", 1);
+  flag = ARKSpilsGetNumJtimesEvals(arkode_mem, &nJv);
+  check_flag(&flag, "ARKSpilsGetNumJtimesEvals", 1);
+  flag = ARKSpilsGetNumConvFails(arkode_mem, &nlcf);
+  check_flag(&flag, "ARKSpilsGetNumConvFails", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total linear iterations = %li\n", nli);
+  printf("   Total number of Jacobian-vector products = %li\n", nJv);
+  printf("   Total number of linear solver convergence failures = %li\n", nlcf);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);        /* Free vectors */
+  free(udata);                 /* Free user data */
+  ARKodeFree(&arkode_mem);     /* Free integrator memory */
+  return 0;
+}
+
+/*--------------------------------
+ * Functions called by the solver
+ *--------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  UserData udata = (UserData) user_data;    /* access problem data */
+  long int N  = udata->N;                   /* set variable shortcuts */
+  realtype k  = udata->k;
+  realtype dx = udata->dx;
+  realtype *Y=NULL, *Ydot=NULL;
+  realtype c1, c2;
+  long int i, isource;
+
+  Y = N_VGetArrayPointer(y);      /* access data arrays */
+  if (check_flag((void *) Y, "N_VGetArrayPointer", 0)) return 1;
+  Ydot = N_VGetArrayPointer(ydot);
+  if (check_flag((void *) Ydot, "N_VGetArrayPointer", 0)) return 1;
+  N_VConst(0.0, ydot);                      /* Initialize ydot to zero */
+
+  /* iterate over domain, computing all equations */
+  c1 = k/dx/dx;
+  c2 = -RCONST(2.0)*k/dx/dx;
+  isource = N/2;
+  Ydot[0] = 0.0;                 /* left boundary condition */
+  for (i=1; i<N-1; i++)
+    Ydot[i] = c1*Y[i-1] + c2*Y[i] + c1*Y[i+1];
+  Ydot[N-1] = 0.0;               /* right boundary condition */
+  Ydot[isource] += 0.01/dx;      /* source term */
+
+  return 0;                      /* Return with success */
+}
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(N_Vector v, N_Vector Jv, realtype t, N_Vector y, 
+	       N_Vector fy, void *user_data, N_Vector tmp)
+{
+  UserData udata = (UserData) user_data;     /* variable shortcuts */
+  long int N  = udata->N;
+  realtype k  = udata->k;
+  realtype dx = udata->dx;
+  realtype *V=NULL, *JV=NULL;
+  realtype c1, c2;
+  long int i;
+
+  V = N_VGetArrayPointer(v);       /* access data arrays */
+  if (check_flag((void *) V, "N_VGetArrayPointer", 0)) return 1;
+  JV = N_VGetArrayPointer(Jv);
+  if (check_flag((void *) JV, "N_VGetArrayPointer", 0)) return 1;
+  N_VConst(0.0, Jv);                         /* initialize Jv product to zero */
+
+  /* iterate over domain, computing all Jacobian-vector products */
+  c1 = k/dx/dx;
+  c2 = -RCONST(2.0)*k/dx/dx;
+  JV[0] = 0.0;
+  for (i=1; i<N-1; i++)
+    JV[i] = c1*V[i-1] + c2*V[i] + c1*V[i+1];
+  JV[N-1] = 0.0;
+
+  return 0;                                  /* Return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_heat1D.out b/examples/arkode/C_serial/ark_heat1D.out
new file mode 100644
index 0000000..dd54665
--- /dev/null
+++ b/examples/arkode/C_serial/ark_heat1D.out
@@ -0,0 +1,29 @@
+
+1D Heat PDE test problem:
+  N = 201
+  diffusion coefficient:  k = 0.5
+        t      ||u||_rms
+   -------------------------
+    0.000000    0.000000
+    0.100000    0.001165
+    0.200000    0.001826
+    0.300000    0.002235
+    0.400000    0.002486
+    0.500000    0.002639
+    0.600000    0.002733
+    0.700000    0.002790
+    0.800000    0.002825
+    0.900000    0.002846
+    1.000000    0.002859
+   -------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 197 (attempted = 197)
+   Total RHS evals:  Fe = 0,  Fi = 1974
+   Total linear solver setups = 0
+   Total linear iterations = 17309
+   Total number of Jacobian-vector products = 17309
+   Total number of linear solver convergence failures = 0
+   Total number of Newton iterations = 985
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 0
diff --git a/examples/arkode/C_serial/ark_heat1D_adapt.c b/examples/arkode/C_serial/ark_heat1D_adapt.c
new file mode 100644
index 0000000..2833111
--- /dev/null
+++ b/examples/arkode/C_serial/ark_heat1D_adapt.c
@@ -0,0 +1,514 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates a simple 1D heat equation,
+ *    u_t = k*u_xx + f
+ * for t in [0, 10], x in [0, 1], with initial conditions
+ *    u(0,x) =  0
+ * Dirichlet boundary conditions, i.e. 
+ *    u_t(t,0) = u_t(t,1) = 0,
+ * and a heating term of the form
+ *    f = 2*exp(-200*(x-0.25)*(x-0.25))
+ *        - exp(-400*(x-0.7)*(x-0.7))
+ *        + exp(-500*(x-0.4)*(x-0.4))
+ *        - 2*exp(-600*(x-0.55)*(x-0.55));
+ * 
+ * The spatial derivatives are computed using a three-point 
+ * centered stencil (second order for a uniform mesh).  The data
+ * is initially uniformly distributed over N points in the interval
+ * [0, 1], but as the simulation proceeds the mesh is adapted.
+ *
+ * This program solves the problem with a DIRK method, solved with 
+ * a Newton iteration and PCG linear solver, with a user-supplied 
+ * Jacobian-vector product routine.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_pcg.h>        /* prototype for ARKPcg solver */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+#include <sundials/sundials_math.h>   /* def. of SUNRsqrt, etc. */
+
+/* user data structure */
+typedef struct {
+  long int N;           /* current number of intervals */
+  realtype *x;          /* current mesh */
+  realtype k;           /* diffusion coefficient */
+  realtype refine_tol;  /* adaptivity tolerance */
+} *UserData;
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(N_Vector v, N_Vector Jv, realtype t, N_Vector y,
+            N_Vector fy, void *user_data, N_Vector tmp);
+
+/* Private function to check function return values */
+realtype * adapt_mesh(N_Vector y, long int *Nnew, UserData udata);
+static int project(long int Nold, realtype *xold, N_Vector yold, 
+		   long int Nnew, realtype *xnew, N_Vector ynew);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main() {
+
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);   /* initial time */
+  realtype Tf = RCONST(1.0);   /* final time */
+  realtype rtol = 1.e-3;       /* relative tolerance */
+  realtype atol = 1.e-10;      /* absolute tolerance */
+  realtype hscale = 1.0;       /* time step change factor on resizes */
+  UserData udata = NULL;
+  realtype *data;
+  long int N = 21;             /* initial spatial mesh size */
+  realtype refine = 3.e-3;     /* adaptivity refinement tolerance */
+  realtype k = 0.5;            /* heat conductivity */
+  long int i, nni, nni_cur=0, nni_tot=0, nli, nli_tot=0;
+  int iout=0;
+
+  /* general problem variables */
+  int flag;                    /* reusable error-checking flag */
+  N_Vector y  = NULL;          /* empty vector for storing solution */
+  N_Vector y2 = NULL;          /* empty vector for storing solution */
+  N_Vector yt = NULL;          /* empty vector for swapping */
+  void *arkode_mem = NULL;     /* empty ARKode memory structure */
+  FILE *XFID, *UFID;
+  realtype t, olddt, newdt;
+  realtype *xnew = NULL;
+  long int Nnew;
+
+  /* allocate and fill initial udata structure */
+  udata = (UserData) malloc(sizeof(*udata));
+  udata->N = N;
+  udata->k = k;
+  udata->refine_tol = refine;
+  udata->x = malloc(N * sizeof(realtype));
+  for (i=0; i<N; i++)  udata->x[i] = 1.0*i/(N-1);
+
+  /* Initial problem output */
+  printf("\n1D adaptive Heat PDE test problem:\n");
+  printf("  diffusion coefficient:  k = %g\n", udata->k);
+  printf("  initial N = %li\n", udata->N);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(N);       /* Create initial serial vector for solution */
+  if (check_flag((void *) y, "N_VNew_Serial", 0)) return 1;
+  N_VConst(0.0, y);           /* Set initial conditions */
+
+  /* output mesh to disk */
+  XFID=fopen("heat_mesh.txt","w");
+
+  /* output initial mesh to disk */
+  for (i=0; i<udata->N; i++)  fprintf(XFID," %.16e", udata->x[i]);
+  fprintf(XFID,"\n");
+
+  /* Open output stream for results, access data array */
+  UFID=fopen("heat1D.txt","w");
+
+  /* output initial condition to disk */
+  data = N_VGetArrayPointer(y);
+  for (i=0; i<udata->N; i++)  fprintf(UFID," %.16e", data[i]);
+  fprintf(UFID,"\n");
+
+
+  /* Create the solver memory */
+  arkode_mem = ARKodeCreate();
+  if (check_flag((void *) arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Initialize the integrator memory */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetUserData(arkode_mem, (void *) udata);   /* Pass udata to user functions */
+  if (check_flag(&flag, "ARKodeSetUserData", 1)) return 1;
+  flag = ARKodeSetMaxNumSteps(arkode_mem, 10000);         /* Increase max num steps  */
+  if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, rtol, atol);      /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+  flag = ARKodeSetAdaptivityMethod(arkode_mem, 2, 1, 0, NULL);  /* Set adaptivity method */
+  if (check_flag(&flag, "ARKodeSetAdaptivityMethod", 1)) return 1;
+  flag = ARKodeSetPredictorMethod(arkode_mem, 0);     /* Set predictor method */
+  if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKPcg(arkode_mem, 0, N);
+  if (check_flag(&flag, "ARKPcg", 1)) return 1;
+  flag = ARKSpilsSetJacTimesVecFn(arkode_mem, Jac);
+  if (check_flag(&flag, "ARKSpilsSetJacTimesVecFn", 1)) return 1;
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  olddt = 0.0;
+  newdt = 0.0;
+  printf("  iout          dt_old                 dt_new               ||u||_rms       N   NNI  NLI\n");
+  printf(" ----------------------------------------------------------------------------------------\n");
+  printf(" %4i  %19.15e  %19.15e  %19.15e  %li   %2i  %3i\n", 
+	 iout, olddt, newdt, SUNRsqrt(N_VDotProd(y,y)/udata->N), udata->N, 0, 0);
+  while (t < Tf) {
+
+    /* "set" routines */
+    flag = ARKodeSetStopTime(arkode_mem, Tf);
+    if (check_flag(&flag, "ARKodeSetStopTime", 1)) return 1;
+    flag = ARKodeSetInitStep(arkode_mem, newdt);
+    if (check_flag(&flag, "ARKodeSetInitStep", 1)) return 1;
+
+    /* call integrator */
+    flag = ARKode(arkode_mem, Tf, y, &t, ARK_ONE_STEP);
+    if (check_flag(&flag, "ARKode", 1)) return 1;
+
+    /* "get" routines */
+    flag = ARKodeGetLastStep(arkode_mem, &olddt);
+    if (check_flag(&flag, "ARKodeGetLastStep", 1)) return 1;
+    flag = ARKodeGetCurrentStep(arkode_mem, &newdt);
+    if (check_flag(&flag, "ARKodeGetCurrentStep", 1)) return 1;
+    flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+    if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) return 1;
+    flag = ARKSpilsGetNumLinIters(arkode_mem, &nli);
+    if (check_flag(&flag, "ARKSpilsGetNumLinIters", 1)) return 1;
+
+    /* print current solution stats */
+    iout++;
+    printf(" %4i  %19.15e  %19.15e  %19.15e  %li   %2li  %3li\n", 
+	   iout, olddt, newdt, SUNRsqrt(N_VDotProd(y,y)/udata->N), udata->N, nni-nni_cur, nli);
+    nni_cur = nni;
+    nni_tot = nni;
+    nli_tot += nli;
+
+    /* output results and current mesh to disk */
+    data = N_VGetArrayPointer(y);
+    for (i=0; i<udata->N; i++)  fprintf(UFID," %.16e", data[i]);
+    fprintf(UFID,"\n");
+    for (i=0; i<udata->N; i++)  fprintf(XFID," %.16e", udata->x[i]);
+    fprintf(XFID,"\n");
+
+    /* adapt the spatial mesh */
+    xnew = adapt_mesh(y, &Nnew, udata);
+    if (check_flag(xnew, "ark_adapt", 0)) return 1;
+
+    /* create N_Vector of new length */
+    y2 = N_VNew_Serial(Nnew);
+    if (check_flag((void *) y2, "N_VNew_Serial", 0)) return 1;
+    
+    /* project solution onto new mesh */
+    flag = project(udata->N, udata->x, y, Nnew, xnew, y2);
+    if (check_flag(&flag, "project", 1)) return 1;
+
+    /* delete old vector, old mesh */
+    N_VDestroy_Serial(y);
+    free(udata->x);
+    
+    /* swap x and xnew so that new mesh is stored in udata structure */
+    udata->x = xnew;
+    xnew = NULL;
+    udata->N = Nnew;   /* store size of new mesh */
+    
+    /* swap y and y2 so that y holds new solution */
+    yt = y;
+    y  = y2;
+    y2 = yt;
+
+    /* call ARKodeResize to notify integrator of change in mesh */
+    flag = ARKodeResize(arkode_mem, y, hscale, t, NULL, NULL);
+    if (check_flag(&flag, "ARKodeResize", 1)) return 1;
+
+    /* destroy and re-allocate linear solver memory */
+    flag = ARKPcg(arkode_mem, 0, udata->N);
+    if (check_flag(&flag, "ARKPcg", 1)) return 1;
+    flag = ARKSpilsSetJacTimesVecFn(arkode_mem, Jac);
+    if (check_flag(&flag, "ARKSpilsSetJacTimesVecFn", 1)) return 1;
+
+  }
+  printf(" ----------------------------------------------------------------------------------------\n");
+
+  /* Free integrator memory */
+  ARKodeFree(&arkode_mem);
+
+  /* print some final statistics */
+  printf(" Final solver statistics:\n");
+  printf("   Total number of time steps = %i\n", iout);
+  printf("   Total nonlinear iterations = %li\n", nni_tot);
+  printf("   Total linear iterations    = %li\n\n", nli_tot);
+
+  /* Clean up and return with successful completion */
+  fclose(UFID);
+  fclose(XFID);
+  N_VDestroy_Serial(y);        /* Free vectors */
+  free(udata->x);              /* Free user data */
+  free(udata);   
+
+  return 0;
+}
+
+/*--------------------------------
+ * Functions called by the solver
+ *--------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  UserData udata = (UserData) user_data;    /* access problem data */
+  long int N  = udata->N;                   /* set variable shortcuts */
+  realtype k  = udata->k;
+  realtype *x = udata->x;
+  realtype *Y=NULL, *Ydot=NULL;
+  realtype dxL, dxR;
+  long int i;
+  Y = N_VGetArrayPointer(y);      /* access data arrays */
+  if (check_flag((void *) Y, "N_VGetArrayPointer", 0)) return 1;
+  Ydot = N_VGetArrayPointer(ydot);
+  if (check_flag((void *) Ydot, "N_VGetArrayPointer", 0)) return 1;
+  N_VConst(0.0, ydot);                      /* Initialize ydot to zero */
+
+  /* iterate over domain, computing all equations */
+  Ydot[0] = 0.0;                 /* left boundary condition */
+  for (i=1; i<N-1; i++) {        /* interior */
+    dxL = x[i]-x[i-1];
+    dxR = x[i+1]-x[i];
+    Ydot[i] = Y[i-1]*k*2.0/(dxL*(dxL+dxR)) 
+            - Y[i]*k*2.0/(dxL*dxR)
+            + Y[i+1]*k*2.0/(dxR*(dxL+dxR));
+  }
+  Ydot[N-1] = 0.0;               /* right boundary condition */
+
+  /* source term */
+  for (i=0; i<N-1; i++) {
+    Ydot[i] += 2.0*SUNRexp(-200.0*(x[i]-0.25)*(x[i]-0.25))
+                 - SUNRexp(-400.0*(x[i]-0.7)*(x[i]-0.7))
+                 + SUNRexp(-500.0*(x[i]-0.4)*(x[i]-0.4))
+             - 2.0*SUNRexp(-600.0*(x[i]-0.55)*(x[i]-0.55));
+  }
+
+  return 0;                      /* Return with success */
+}
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(N_Vector v, N_Vector Jv, realtype t, N_Vector y, 
+	       N_Vector fy, void *user_data, N_Vector tmp)
+{
+  UserData udata = (UserData) user_data;     /* variable shortcuts */
+  long int N  = udata->N;
+  realtype k  = udata->k;
+  realtype *x = udata->x;
+  realtype *V=NULL, *JV=NULL;
+  realtype dxL, dxR;
+  long int i;
+  V = N_VGetArrayPointer(v);       /* access data arrays */
+  if (check_flag((void *) V, "N_VGetArrayPointer", 0)) return 1;
+  JV = N_VGetArrayPointer(Jv);
+  if (check_flag((void *) JV, "N_VGetArrayPointer", 0)) return 1;
+  N_VConst(0.0, Jv);               /* initialize Jv product to zero */
+
+  /* iterate over domain, computing all Jacobian-vector products */
+  JV[0] = 0.0;
+  for (i=1; i<N-1; i++) {
+    dxL = x[i]-x[i-1];
+    dxR = x[i+1]-x[i];
+    JV[i] = V[i-1]*k*2.0/(dxL*(dxL+dxR)) 
+          - V[i]*k*2.0/(dxL*dxR)
+          + V[i+1]*k*2.0/(dxR*(dxL+dxR));
+  }
+  JV[N-1] = 0.0;
+
+  return 0;                                  /* Return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Adapts the current mesh, using a simple adaptivity strategy of 
+   refining when an approximation of the scaled second-derivative is 
+   too large.  We only do this in one sweep, so no attempt is made to 
+   ensure the resulting mesh meets these same criteria after adaptivity:
+      y [input] -- the current solution vector
+      Nnew [output] -- the size of the new mesh
+      udata [input] -- the current system information 
+   The return for this function is a pointer to the new mesh. */
+realtype * adapt_mesh(N_Vector y, long int *Nnew, UserData udata)
+{
+  int i, j;
+  int *marks=NULL;
+  realtype ydd, *xold=NULL, *Y=NULL, *xnew=NULL;
+  long int num_refine, N_new;
+
+  /* Access current solution and mesh arrays */
+  xold = udata->x;
+  Y = N_VGetArrayPointer(y);
+  if (check_flag((void *) Y, "N_VGetArrayPointer", 0)) return NULL;
+
+  /* create marking array */
+  marks = calloc(udata->N-1, sizeof(int));
+
+  /* /\* perform marking:  */
+  /*     0 -> leave alone */
+  /*     1 -> refine */
+  /* realtype ymax, ymin; */
+  /* for (i=0; i<(udata->N-1); i++) { */
+
+  /*   /\* check for refinement *\/ */
+  /*   if (fabs(Y[i+1] - Y[i]) > udata->refine_tol) { */
+  /*     marks[i] = 1; */
+  /*     continue; */
+  /*   } */
+  /* } */
+
+  /* perform marking: 
+      0 -> leave alone
+      1 -> refine */
+  for (i=1; i<udata->N-1; i++) {
+
+    /* approximate scaled second-derivative */
+    ydd = Y[i-1] - 2.0*Y[i] + Y[i+1];
+
+    /* check for refinement */
+    if (fabs(ydd) > udata->refine_tol) {
+      marks[i-1] = 1;
+      marks[i] = 1;
+    }
+    
+  }
+
+  /* allocate new mesh */
+  num_refine = 0;
+  for (i=0; i<udata->N-1; i++) 
+    if (marks[i] == 1)   num_refine++;
+  N_new = udata->N + num_refine;
+  *Nnew = N_new;            /* Store new array length */
+  xnew = malloc((N_new) * sizeof(realtype));
+  
+
+  /* fill new mesh */
+  xnew[0] = udata->x[0];    /* store endpoints */
+  xnew[N_new-1] = udata->x[udata->N-1];
+  j=1;
+  /* iterate over old intervals */
+  for (i=0; i<udata->N-1; i++) {
+    /* if mark is 0, reuse old interval */ 
+    if (marks[i] == 0) {
+      xnew[j++] = xold[i+1];
+      continue;
+    }
+    
+    /* if mark is 1, refine old interval */
+    if (marks[i] == 1) {
+      xnew[j++] = 0.5*(xold[i]+xold[i+1]);
+      xnew[j++] = xold[i+1];
+      continue;
+    }
+  }
+
+  /* verify that new mesh is legal */
+  for (i=0; i<N_new-1; i++) {
+    if (xnew[i+1] <= xnew[i]) {
+      fprintf(stderr,"adapt_mesh error: illegal mesh created\n");
+      free(xnew);
+      return NULL;
+    }
+  }
+
+  free(marks);              /* Delete marking array */
+  return xnew;              /* Return with success */
+}
+
+
+/* Projects one vector onto another:
+      Nold [input] -- the size of the old mesh
+      xold [input] -- the old mesh
+      yold [input] -- the vector defined over the old mesh
+      Nnew [input] -- the size of the new mesh
+      xnew [input] -- the new mesh
+      ynew [output] -- the vector defined over the new mesh
+                       (allocated prior to calling project) */
+static int project(long int Nold, realtype *xold, N_Vector yold, 
+		   long int Nnew, realtype *xnew, N_Vector ynew)
+{
+  int iv, i, j;
+  realtype *Yold=NULL, *Ynew=NULL;
+
+  /* Access data arrays */
+  Yold = N_VGetArrayPointer(yold);    /* access data arrays */
+  if (check_flag((void *) Yold, "N_VGetArrayPointer", 0)) return 1;
+  Ynew = N_VGetArrayPointer(ynew);
+  if (check_flag((void *) Ynew, "N_VGetArrayPointer", 0)) return 1;
+
+  /* loop over new mesh, finding corresponding interval within old mesh, 
+     and perform piecewise linear interpolation from yold to ynew */
+  iv=0;
+  for (i=0; i<Nnew; i++) {
+    
+    /* find old interval, start with previous value since sorted */
+    for (j=iv; j<Nold-1; j++) {
+      if (xnew[i] >= xold[j] && xnew[i] <= xold[j+1]) {
+	iv = j;
+	break;
+      }
+      iv = Nold-1;     /* just in case it wasn't found above */
+    }
+
+    /* perform interpolation */ 
+    Ynew[i] = Yold[iv]*(xnew[i]-xold[iv+1])/(xold[iv]-xold[iv+1]) 
+            + Yold[iv+1]*(xnew[i]-xold[iv])/(xold[iv+1]-xold[iv]);
+  }
+
+  return 0;            /* Return with success */
+}
+
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_heat1D_adapt.out b/examples/arkode/C_serial/ark_heat1D_adapt.out
new file mode 100644
index 0000000..5deda13
--- /dev/null
+++ b/examples/arkode/C_serial/ark_heat1D_adapt.out
@@ -0,0 +1,107 @@
+
+1D adaptive Heat PDE test problem:
+  diffusion coefficient:  k = 0.5
+  initial N = 21
+  iout          dt_old                 dt_new               ||u||_rms       N   NNI  NLI
+ ----------------------------------------------------------------------------------------
+    0  0.000000000000000e+00  0.000000000000000e+00  0.000000000000000e+00  21    0    0
+    1  3.629021901461023e-12  7.505751048377368e-09  2.979166031186306e-12  21    5    5
+    2  7.505751048377368e-09  1.501150209675474e-07  6.164657920203414e-09  21   10    5
+    3  1.501150209675474e-07  3.002300419350948e-06  1.293969127876394e-07  21   10    9
+    4  3.002300419350948e-06  6.004600838701896e-05  2.593514282989167e-06  21   10   10
+    5  6.004600838701896e-05  2.854024143748609e-04  5.166758334585204e-05  21   10   19
+    6  2.854024143748609e-04  2.575205831761056e-04  2.798713300800731e-04  21   10   25
+    7  2.575205831761056e-04  4.094402057669300e-04  4.794364798148849e-04  21   10   24
+    8  4.094402057669300e-04  4.094402057669300e-04  7.863867077537864e-04  21   10   25
+    9  4.094402057669300e-04  6.523109871323949e-04  1.082800057988263e-03  21   10   25
+   10  6.523109871323949e-04  5.699145720577265e-04  1.606864160614628e-03  23   10   38
+   11  5.699145720577265e-04  1.008085270318922e-03  2.005677987304881e-03  23   10   32
+   12  1.008085270318922e-03  1.008085270318922e-03  2.683212443767887e-03  23   10   37
+   13  1.008085270318922e-03  8.454396857243886e-04  3.678750660517184e-03  25   10   37
+   14  8.454396857243886e-04  1.990629597547611e-03  4.265439688800132e-03  25   10   30
+   15  1.990629597547611e-03  1.990629597547611e-03  5.575407085415051e-03  25   10   39
+   16  1.990629597547611e-03  3.607197488602903e-03  6.798927523968801e-03  25   10   30
+   17  4.981039682699363e-04  4.981039682699363e-04  6.927552935378208e-03  27   30  156
+   18  4.981039682699363e-04  4.981039682699363e-04  7.442138500375902e-03  29   10   25
+   19  4.981039682699363e-04  1.668573980211983e-03  7.723152304280749e-03  29   10   24
+   20  1.668573980211983e-03  3.654706558768539e-03  8.637924517668507e-03  29   10   37
+   21  3.654706558768539e-03  7.224979051078588e-03  1.050599896879328e-02  29   10   49
+   22  2.276551141355698e-04  2.276551141355698e-04  1.033397994768772e-02  32   40  256
+   23  2.276551141355698e-04  4.413353554788115e-04  1.092338188288813e-02  34   10   20
+   24  4.413353554788115e-04  1.019444046442095e-03  1.113522375604393e-02  34   10   24
+   25  1.019444046442095e-03  1.019444046442095e-03  1.161555502336150e-02  34   10   35
+   26  1.019444046442095e-03  3.726408116521474e-03  1.208389269353381e-02  34   10   29
+   27  3.726408116521474e-03  3.726408116521474e-03  1.369916870976818e-02  34   10   59
+   28  3.726408116521474e-03  1.017517861007844e-02  1.517662504289777e-02  34   10   55
+   29  1.350491936829535e-03  1.350491936829535e-03  1.559233522680444e-02  36   30  212
+   30  1.350491936829535e-03  3.706502672803281e-03  1.608657213958387e-02  36   10   25
+   31  2.814808489615957e-03  2.814808489615957e-03  1.706503329381448e-02  38   20  119
+   32  6.183994739341915e-04  6.183994739341915e-04  1.691544997123700e-02  40   30  223
+   33  6.183994739341915e-04  1.092896364473831e-03  1.711576767264562e-02  40   10   34
+   34  1.092896364473831e-03  3.025071844878339e-03  1.746342433106013e-02  40   10   43
+   35  3.025071844878339e-03  7.404939993948745e-03  1.838448885341201e-02  40   10   79
+   36  7.404939993948745e-03  1.389603706836776e-02  2.040556371949357e-02  40   10  139
+   37  6.710477939748602e-04  6.710477939748602e-04  1.988129068907885e-02  44   40  647
+   38  6.710477939748602e-04  1.028024256319047e-03  1.965202427908446e-02  46   10   36
+   39  1.028024256319047e-03  2.833952015856033e-03  1.989188365758057e-02  46   10   37
+   40  2.833952015856033e-03  4.952800324532025e-03  2.052762374827459e-02  46   10   66
+   41  4.952800324532025e-03  8.714201527775771e-03  2.155483443164250e-02  46   10  105
+   42  8.714201527775771e-03  1.720615368906233e-02  2.313292126778931e-02  46   10  167
+   43  3.805803440168311e-03  3.805803440168311e-03  2.360451299933607e-02  48   30  689
+   44  8.023837169729728e-04  8.023837169729728e-04  2.346209634272231e-02  50   30  314
+   45  8.023837169729728e-04  1.503536834976284e-03  2.358170211412561e-02  50   10   55
+   46  1.503536834976284e-03  4.513095256928524e-03  2.380061610322121e-02  50   10   59
+   47  3.495461232776950e-03  3.495461232776950e-03  2.428544643707820e-02  50   20  227
+   48  3.495461232776950e-03  1.098574695245117e-02  2.473894746889214e-02  50   10   75
+   49  1.098574695245117e-02  1.818917139221294e-02  2.598434629024265e-02  50   10  172
+   50  1.818917139221294e-02  2.767038680802522e-02  2.756281122436279e-02  50   10  283
+   51  6.917596702006305e-03  6.917596702006305e-03  2.913159038624379e-02  54   15  479
+   52  6.917596702006305e-03  1.065864858639081e-02  2.956607928921659e-02  54   10  134
+   53  1.065864858639081e-02  1.729721723319153e-02  2.981861064666339e-02  56   10  230
+   54  1.729721723319153e-02  2.878451485340029e-02  3.010100614649229e-02  58   10  278
+   55  2.878451485340029e-02  2.878451485340029e-02  3.043378148315333e-02  60   10  334
+   56  7.196128713350072e-03  7.196128713350072e-03  3.058796042164046e-02  60   15  351
+   57  7.196128713350072e-03  1.269773298304222e-02  3.072680212128632e-02  60   10  103
+   58  1.269773298304222e-02  3.569678515456698e-02  3.093999932706822e-02  60   10  165
+   59  3.569678515456698e-02  5.811742143859773e-02  3.138094315135925e-02  60   10  330
+   60  1.452935535964943e-02  1.452935535964943e-02  3.151366976890378e-02  60   18  596
+   61  1.452935535964943e-02  3.911347912422928e-02  3.162764839842241e-02  60   10  145
+   62  3.911347912422928e-02  6.256393965526523e-02  3.186787605580501e-02  60   10  380
+   63  1.564098491381631e-02  1.564098491381631e-02  3.194430211081341e-02  60   12  335
+   64  1.564098491381631e-02  3.474495618112731e-02  3.201248645476758e-02  60   10  135
+   65  8.686239045281827e-03  8.686239045281827e-03  3.204730735551981e-02  60   11  424
+   66  8.686239045281827e-03  1.579835682746987e-02  3.208019059681224e-02  60   10  330
+   67  1.579835682746987e-02  2.864626865176246e-02  3.213558185506317e-02  60   10  224
+   68  2.864626865176246e-02  4.778509342320859e-02  3.222364307660728e-02  60   10  316
+   69  1.194627335580215e-02  1.194627335580215e-02  3.225635676188716e-02  60   21  750
+   70  1.194627335580215e-02  3.465947907026466e-02  3.228701697329782e-02  60   10  162
+   71  3.465947907026466e-02  7.907534915954270e-02  3.236578972146440e-02  60   10  296
+   72  1.976883728988568e-02  1.976883728988568e-02  3.240484236283207e-02  60   12  424
+   73  1.976883728988568e-02  4.238773098868815e-02  3.244021773389890e-02  60   10  267
+   74  4.238773098868815e-02  4.238773098868815e-02  3.250539064364061e-02  60   10  374
+   75  4.238773098868815e-02  4.238773098868815e-02  3.255839583346429e-02  60   10  365
+   76  1.059693274717204e-02  1.059693274717204e-02  3.257003190199415e-02  60   23  675
+   77  1.059693274717204e-02  3.374224101621920e-02  3.258108845266754e-02  60   10  119
+   78  3.374224101621920e-02  7.028500459469654e-02  3.261274207384274e-02  60   14  539
+   79  1.757125114867414e-02  1.757125114867414e-02  3.262729018183993e-02  60   12  317
+   80  1.757125114867414e-02  3.430166354319600e-02  3.264065556631886e-02  60   10  186
+   81  3.430166354319600e-02  5.964635069535813e-02  3.266369564112172e-02  60   10  300
+   82  1.491158767383953e-02  1.491158767383953e-02  3.267257507399515e-02  60   12  303
+   83  1.491158767383953e-02  4.151059356915939e-02  3.268083759515131e-02  60   10  134
+   84  1.037764839228985e-02  1.037764839228985e-02  3.268624676047530e-02  60   23  767
+   85  1.037764839228985e-02  2.337923819490379e-02  3.269138828929134e-02  60   10  214
+   86  2.337923819490379e-02  5.584751455212315e-02  3.270207501116806e-02  60   10  224
+   87  1.396187863803079e-02  1.396187863803079e-02  3.270790060704231e-02  60   12  243
+   88  1.396187863803079e-02  4.841828824573841e-02  3.271334794042778e-02  60   10  155
+   89  4.841828824573841e-02  7.963760672802837e-02  3.272963100640804e-02  60   10  324
+   90  1.990940168200709e-02  1.990940168200709e-02  3.273528876716780e-02  60   12  441
+   91  1.990940168200709e-02  3.127117602453464e-02  3.274045071854639e-02  60   10  212
+   92  3.127117602453464e-02  5.250130431989954e-02  3.274757629125738e-02  60   10  408
+   93  5.250130431989954e-02  1.730734444761127e-02  3.275738955577872e-02  60   10  401
+   94  1.730734444761127e-02  1.730734444761127e-02  3.276011960220934e-02  60   10  134
+ ----------------------------------------------------------------------------------------
+ Final solver statistics:
+   Total number of time steps = 94
+   Total nonlinear iterations = 1187
+   Total linear iterations    = 18988
+
diff --git a/examples/arkode/C_serial/ark_robertson.c b/examples/arkode/C_serial/ark_robertson.c
new file mode 100644
index 0000000..f6b9bfd
--- /dev/null
+++ b/examples/arkode/C_serial/ark_robertson.c
@@ -0,0 +1,280 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates the Robertson problem, 
+ * corresponding to the kinetics of an autocatalytic reaction.  
+ * This is an ODE system with 3 components, Y = [u,v,w], satisfying
+ * the equations,
+ *    du/dt = -0.04*u + 1e4*v*w
+ *    dv/dt = 0.04*u - 1e4*v*w - 3e7*v^2
+ *    dw/dt = 3e7*v^2
+ * for t in the interval [0.0, 1e11], with initial conditions 
+ * Y0 = [1,0,0]. 
+ * 
+ * This program solves the problem with one of the solvers, ERK, 
+ * DIRK or ARK.  For DIRK and ARK, implicit subsystems are solved 
+ * using a Newton iteration with the ARKDENSE dense linear solver, 
+ * and a user-supplied Jacobian routine.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_dense.h>      /* prototype for ARKDense solver */
+#include <sundials/sundials_dense.h>  /* defs. of DlsMat and DENSE_ELEM */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);     /* initial time */
+  realtype Tf = RCONST(1.e11);   /* final time */
+  realtype dTout = (Tf-T0)/100;  /* time between outputs */
+  int Nt = ceil(Tf/dTout);       /* number of output times */
+  long int NEQ = 3;              /* number of dependent vars. */
+
+  /* general problem variables */
+  int flag;                      /* reusable error-checking flag */
+  N_Vector y = NULL;             /* empty vector for storing solution */
+  void *arkode_mem = NULL;       /* empty ARKode memory structure */
+  FILE *UFID;
+  realtype t, tout;
+  int iout;
+  long int nst, nst_a, nfe, nfi, nsetups, nje, nfeLS, nni, ncfn, netf;
+
+  /* set up the initial conditions, tolerances, initial time step size */
+  realtype u0 = RCONST(1.0);
+  realtype v0 = RCONST(0.0);
+  realtype w0 = RCONST(0.0);
+  realtype reltol = 1.e-4;
+  realtype abstol = 1.e-11;
+  realtype h0 = 1.e-4 * reltol;
+
+  /* Initial problem output */
+  printf("\nRobertson ODE test problem:\n");
+  printf("    initial conditions:  u0 = %g,  v0 = %g,  w0 = %g\n",u0,v0,w0);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(NEQ);         /* Create serial vector for solution */
+  if (check_flag((void *) y, "N_VNew_Serial", 0)) return 1;
+  NV_Ith_S(y,0) = u0;             /* Set initial conditions into y */
+  NV_Ith_S(y,1) = v0;
+  NV_Ith_S(y,2) = w0;
+  arkode_mem = ARKodeCreate();    /* Create the solver memory */
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set routines */
+  flag = ARKodeSetInitStep(arkode_mem, h0);                /* Set custom initial step */
+  if (check_flag(&flag, "ARKodeSetInitStep", 1)) return 1;
+  flag = ARKodeSetMaxErrTestFails(arkode_mem, 20);         /* Increase max error test fails */
+  if (check_flag(&flag, "ARKodeSetMaxErrTestFails", 1)) return 1;
+  flag = ARKodeSetMaxNonlinIters(arkode_mem, 8);           /* Increase max nonlin iters  */
+  if (check_flag(&flag, "ARKodeSetMaxNonlinIters", 1)) return 1;
+  flag = ARKodeSetNonlinConvCoef(arkode_mem, 1.e-7);       /* set nonlinear convergence coeff. */
+  if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) return 1;
+  flag = ARKodeSetMaxNumSteps(arkode_mem, 100000);         /* Increase max num steps */
+  if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) return 1;
+  flag = ARKodeSetPredictorMethod(arkode_mem, 1);         /* Specify maximum-order predictor */
+  if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) return 1;
+  flag = ARKodeSStolerances(arkode_mem, reltol, abstol);   /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKDense(arkode_mem, NEQ);                        /* Specify dense linear solver */
+  if (check_flag(&flag, "ARKDense", 1)) return 1;
+  flag = ARKDlsSetDenseJacFn(arkode_mem, Jac);             /* Set the Jacobian routine */
+  if (check_flag(&flag, "ARKDlsSetDenseJacFn", 1)) return 1;
+
+  /* Open output stream for results, output comment line */
+  UFID = fopen("solution.txt","w");
+  fprintf(UFID,"# t u v w\n");
+
+  /* output initial condition to disk */
+  fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	  T0, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  tout = T0+dTout;
+  printf("        t           u           v           w\n");
+  printf("   --------------------------------------------------\n");
+  printf("  %10.3e  %12.5e  %12.5e  %12.5e\n",
+      t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));
+  for (iout=0; iout<Nt; iout++) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);       /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %10.3e  %12.5e  %12.5e  %12.5e\n",              /* access/print solution */
+        t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));
+    fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	    t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+    if (flag >= 0) {                                          /* successful solve: update time */
+      tout += dTout;
+      tout = (tout > Tf) ? Tf : tout;
+    } else {                                                  /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+  }
+  printf("   --------------------------------------------------\n");
+  fclose(UFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKDlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKDlsGetNumJacEvals", 1);
+  flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", 
+	 nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total RHS evals for setting up the linear system = %li\n", nfeLS);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);        /* Free y vector */
+  ARKodeFree(&arkode_mem);     /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype u = NV_Ith_S(y,0);   /* access current solution */
+  realtype v = NV_Ith_S(y,1);
+  realtype w = NV_Ith_S(y,2);
+
+  /* Fill in ODE RHS function */
+  NV_Ith_S(ydot,0) = -0.04*u + 1.e4*v*w;
+  NV_Ith_S(ydot,1) = 0.04*u - 1.e4*v*w - 3.e7*v*v;
+  NV_Ith_S(ydot,2) = 3.e7*v*v;
+
+  return 0;                     /* Return with success */
+}
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype v = NV_Ith_S(y,1);   /* access current solution */
+  realtype w = NV_Ith_S(y,2);
+  SetToZero(J);                 /* initialize Jacobian to zero */
+
+  /* Fill in the Jacobian of the ODE RHS function */
+  DENSE_ELEM(J,0,0) = -0.04;
+  DENSE_ELEM(J,0,1) = 1.e4*w;
+  DENSE_ELEM(J,0,2) = 1.e4*v;
+
+  DENSE_ELEM(J,1,0) = 0.04;
+  DENSE_ELEM(J,1,1) = -1.e4*w - 6.e7*v;
+  DENSE_ELEM(J,1,2) = -1.e4*v;
+
+  DENSE_ELEM(J,2,1) = 6.e7*v;
+
+  return 0;                     /* Return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_robertson.out b/examples/arkode/C_serial/ark_robertson.out
new file mode 100644
index 0000000..d692a76
--- /dev/null
+++ b/examples/arkode/C_serial/ark_robertson.out
@@ -0,0 +1,117 @@
+
+Robertson ODE test problem:
+    initial conditions:  u0 = 1,  v0 = 0,  w0 = 0
+        t           u           v           w
+   --------------------------------------------------
+   0.000e+00   1.00000e+00   0.00000e+00   0.00000e+00
+   1.000e+09   2.08323e-06   8.32676e-12   9.99998e-01
+   2.000e+09   1.04164e-06   4.15999e-12   9.99999e-01
+   3.000e+09   6.94429e-07   2.79925e-12   9.99999e-01
+   4.000e+09   5.20819e-07   2.04568e-12   9.99999e-01
+   5.000e+09   4.16663e-07   1.67589e-12   1.00000e+00
+   6.000e+09   3.47216e-07   1.38088e-12   1.00000e+00
+   7.000e+09   2.97619e-07   1.18461e-12   1.00000e+00
+   8.000e+09   2.60418e-07   1.04042e-12   1.00000e+00
+   9.000e+09   2.31479e-07   9.43288e-13   1.00000e+00
+   1.000e+10   2.08331e-07   8.24029e-13   1.00000e+00
+   1.100e+10   1.89394e-07   7.46758e-13   1.00000e+00
+   1.200e+10   1.73612e-07   6.94891e-13   1.00000e+00
+   1.300e+10   1.60252e-07   6.49283e-13   1.00000e+00
+   1.400e+10   1.48811e-07   5.94089e-13   1.00000e+00
+   1.500e+10   1.38887e-07   5.70262e-13   1.00000e+00
+   1.600e+10   1.30210e-07   5.16806e-13   1.00000e+00
+   1.700e+10   1.22545e-07   4.58568e-13   1.00000e+00
+   1.800e+10   1.15737e-07   4.57110e-13   1.00000e+00
+   1.900e+10   1.09651e-07   4.40546e-13   1.00000e+00
+   2.000e+10   1.04166e-07   4.14493e-13   1.00000e+00
+   2.100e+10   9.92052e-08   4.09664e-13   1.00000e+00
+   2.200e+10   9.46983e-08   3.82358e-13   1.00000e+00
+   2.300e+10   9.05799e-08   3.43987e-13   1.00000e+00
+   2.400e+10   8.68055e-08   3.36094e-13   1.00000e+00
+   2.500e+10   8.33345e-08   3.33250e-13   1.00000e+00
+   2.600e+10   8.01278e-08   3.24553e-13   1.00000e+00
+   2.700e+10   7.71580e-08   3.20079e-13   1.00000e+00
+   2.800e+10   7.44026e-08   3.13812e-13   1.00000e+00
+   2.900e+10   7.18392e-08   2.99428e-13   1.00000e+00
+   3.000e+10   6.94455e-08   2.71839e-13   1.00000e+00
+   3.100e+10   6.72043e-08   2.51612e-13   1.00000e+00
+   3.200e+10   6.51035e-08   2.43819e-13   1.00000e+00
+   3.300e+10   6.31312e-08   2.42722e-13   1.00000e+00
+   3.400e+10   6.12754e-08   2.42584e-13   1.00000e+00
+   3.500e+10   5.95243e-08   2.38297e-13   1.00000e+00
+   3.600e+10   5.78691e-08   2.29877e-13   1.00000e+00
+   3.700e+10   5.63035e-08   2.19436e-13   1.00000e+00
+   3.800e+10   5.48213e-08   2.09053e-13   1.00000e+00
+   3.900e+10   5.34164e-08   2.00809e-13   1.00000e+00
+   4.000e+10   5.20827e-08   1.96786e-13   1.00000e+00
+   4.100e+10   5.08138e-08   1.99063e-13   1.00000e+00
+   4.200e+10   4.96040e-08   2.07948e-13   1.00000e+00
+   4.300e+10   4.84497e-08   2.15392e-13   1.00000e+00
+   4.400e+10   4.73479e-08   2.19410e-13   1.00000e+00
+   4.500e+10   4.62954e-08   2.19156e-13   1.00000e+00
+   4.600e+10   4.52893e-08   2.13788e-13   1.00000e+00
+   4.700e+10   4.43263e-08   2.02463e-13   1.00000e+00
+   4.800e+10   4.34035e-08   1.84338e-13   1.00000e+00
+   4.900e+10   4.25178e-08   1.60111e-13   1.00000e+00
+   5.000e+10   4.16666e-08   1.40398e-13   1.00000e+00
+   5.100e+10   4.08485e-08   1.26720e-13   1.00000e+00
+   5.200e+10   4.00619e-08   1.18280e-13   1.00000e+00
+   5.300e+10   3.93053e-08   1.14277e-13   1.00000e+00
+   5.400e+10   3.85773e-08   1.13913e-13   1.00000e+00
+   5.500e+10   3.78762e-08   1.16387e-13   1.00000e+00
+   5.600e+10   3.72006e-08   1.20901e-13   1.00000e+00
+   5.700e+10   3.65490e-08   1.26656e-13   1.00000e+00
+   5.800e+10   3.59198e-08   1.32851e-13   1.00000e+00
+   5.900e+10   3.53116e-08   1.38688e-13   1.00000e+00
+   6.000e+10   3.47230e-08   1.43341e-13   1.00000e+00
+   6.100e+10   3.41534e-08   1.46349e-13   1.00000e+00
+   6.200e+10   3.36021e-08   1.47818e-13   1.00000e+00
+   6.300e+10   3.30683e-08   1.47881e-13   1.00000e+00
+   6.400e+10   3.25514e-08   1.46671e-13   1.00000e+00
+   6.500e+10   3.20506e-08   1.44318e-13   1.00000e+00
+   6.600e+10   3.15651e-08   1.40956e-13   1.00000e+00
+   6.700e+10   3.10943e-08   1.36717e-13   1.00000e+00
+   6.800e+10   3.06375e-08   1.31732e-13   1.00000e+00
+   6.900e+10   3.01938e-08   1.26134e-13   1.00000e+00
+   7.000e+10   2.97627e-08   1.20055e-13   1.00000e+00
+   7.100e+10   2.93434e-08   1.14310e-13   1.00000e+00
+   7.200e+10   2.89354e-08   1.09946e-13   1.00000e+00
+   7.300e+10   2.85384e-08   1.06807e-13   1.00000e+00
+   7.400e+10   2.81521e-08   1.04720e-13   1.00000e+00
+   7.500e+10   2.77761e-08   1.03511e-13   1.00000e+00
+   7.600e+10   2.74102e-08   1.03008e-13   1.00000e+00
+   7.700e+10   2.70539e-08   1.03038e-13   1.00000e+00
+   7.800e+10   2.67069e-08   1.03427e-13   1.00000e+00
+   7.900e+10   2.63689e-08   1.04003e-13   1.00000e+00
+   8.000e+10   2.60395e-08   1.04594e-13   1.00000e+00
+   8.100e+10   2.57184e-08   1.05025e-13   1.00000e+00
+   8.200e+10   2.54053e-08   1.05125e-13   1.00000e+00
+   8.300e+10   2.50998e-08   1.04721e-13   1.00000e+00
+   8.400e+10   2.48016e-08   1.03638e-13   1.00000e+00
+   8.500e+10   2.45103e-08   1.01705e-13   1.00000e+00
+   8.600e+10   2.42256e-08   9.87493e-14   1.00000e+00
+   8.700e+10   2.39471e-08   9.48747e-14   1.00000e+00
+   8.800e+10   2.36749e-08   9.21258e-14   1.00000e+00
+   8.900e+10   2.34087e-08   9.07554e-14   1.00000e+00
+   9.000e+10   2.31483e-08   9.05235e-14   1.00000e+00
+   9.100e+10   2.28937e-08   9.11904e-14   1.00000e+00
+   9.200e+10   2.26446e-08   9.25164e-14   1.00000e+00
+   9.300e+10   2.24010e-08   9.42617e-14   1.00000e+00
+   9.400e+10   2.21626e-08   9.61864e-14   1.00000e+00
+   9.500e+10   2.19293e-08   9.80510e-14   1.00000e+00
+   9.600e+10   2.17009e-08   9.96155e-14   1.00000e+00
+   9.700e+10   2.14773e-08   1.00640e-13   1.00000e+00
+   9.800e+10   2.12583e-08   1.00885e-13   1.00000e+00
+   9.900e+10   2.10438e-08   1.00111e-13   1.00000e+00
+   1.000e+11   2.08336e-08   9.80782e-14   1.00000e+00
+   --------------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 873 (attempted = 980)
+   Total RHS evals:  Fe = 0,  Fi = 28843
+   Total linear solver setups = 338
+   Total RHS evals for setting up the linear system = 0
+   Total number of Jacobian evaluations = 43
+   Total number of Newton iterations = 23942
+   Total number of nonlinear solver convergence failures = 0
+   Total number of error test failures = 107
diff --git a/examples/arkode/C_serial/ark_robertson_root.c b/examples/arkode/C_serial/ark_robertson_root.c
new file mode 100644
index 0000000..d3bce8a
--- /dev/null
+++ b/examples/arkode/C_serial/ark_robertson_root.c
@@ -0,0 +1,319 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following test simulates the Robertson problem, 
+ * corresponding to the kinetics of an autocatalytic reaction.  
+ * This is an ODE system with 3 components, Y = [u,v,w], satisfying
+ * the equations,
+ *    du/dt = -0.04*u + 1e4*v*w
+ *    dv/dt = 0.04*u - 1e4*v*w - 3e7*v^2
+ *    dw/dt = 3e7*v^2
+ * for t in the interval [0.0, 1e11], with initial conditions 
+ * Y0 = [1,0,0].
+ *
+ * While integrating the system, we use the rootfinding feature 
+ * to find the times at which either u=1e-4 or w=1e-2.
+ * 
+ * This program solves the problem with one of the solvers, ERK, 
+ * DIRK or ARK.  For DIRK and ARK, implicit subsystems are solved 
+ * using a Newton iteration with the ARKDENSE dense linear solver, 
+ * and a user-supplied Jacobian routine.
+ *
+ * 100 outputs are printed at equal intervals, and run statistics 
+ * are printed at the end.
+ *---------------------------------------------------------------*/
+
+/* Header files */
+#include <stdio.h>
+#include <math.h>
+#include <arkode/arkode.h>            /* prototypes for ARKode fcts., consts. */
+#include <nvector/nvector_serial.h>   /* serial N_Vector types, fcts., macros */
+#include <arkode/arkode_dense.h>      /* prototype for ARKDense solver */
+#include <sundials/sundials_dense.h>  /* defs. of DlsMat and DENSE_ELEM */
+#include <sundials/sundials_types.h>  /* def. of type 'realtype' */
+
+/* User-supplied Functions Called by the Solver */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+static int g(realtype t, N_Vector y,
+          realtype *gout, void *user_data);
+
+/* Private function to check function return values */
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/* Main Program */
+int main()
+{
+  /* general problem parameters */
+  realtype T0 = RCONST(0.0);     /* initial time */
+  realtype T1 = RCONST(0.4);     /* first output time */
+  realtype TMult = RCONST(10.0); /* output time multiplication factor */
+  int Nt = 12;                   /* total number of output times */
+  long int NEQ = 3;              /* number of dependent vars. */
+  realtype reltol;
+  int rootsfound[2];
+  long int nst, nst_a, nfe, nfi, nsetups;
+  long int nje, nfeLS, nni, ncfn, netf, nge;
+  int flag, rtflag;              /* reusable error-checking flags */
+  FILE *UFID;
+  realtype t, tout;
+  int iout;
+
+  /* general problem variables */
+  N_Vector y = NULL;             /* empty vector for storing solution */
+  N_Vector atols = NULL;         /* empty vector for absolute tolerances */
+  void *arkode_mem = NULL;       /* empty ARKode memory structure */
+
+  /* set up the initial conditions */
+  realtype u0 = RCONST(1.0);
+  realtype v0 = RCONST(0.0);
+  realtype w0 = RCONST(0.0);
+
+  /* Initial problem output */
+  printf("\nRobertson ODE test problem (with rootfinding):\n");
+  printf("    initial conditions:  u0 = %g,  v0 = %g,  w0 = %g\n",u0,v0,w0);
+
+  /* Initialize data structures */
+  y = N_VNew_Serial(NEQ);        /* Create serial vector for solution */
+  if (check_flag((void *) y, "N_VNew_Serial", 0)) return 1;
+  atols = N_VNew_Serial(NEQ);    /* Create serial vector absolute tolerances */
+  if (check_flag((void *) atols, "N_VNew_Serial", 0)) return 1;
+  NV_Ith_S(y,0) = u0;            /* Set initial conditions into y */
+  NV_Ith_S(y,1) = v0;
+  NV_Ith_S(y,2) = w0;
+  arkode_mem = ARKodeCreate();   /* Create the solver memory */
+  if (check_flag((void *)arkode_mem, "ARKodeCreate", 0)) return 1;
+
+  /* Call ARKodeInit to initialize the integrator memory and specify the
+     right-hand side function in y'=f(t,y), the inital time T0, and
+     the initial dependent variable vector y.  Note: since this
+     problem is fully implicit, we set f_E to NULL and f_I to f. */
+  flag = ARKodeInit(arkode_mem, NULL, f, T0, y);
+  if (check_flag(&flag, "ARKodeInit", 1)) return 1;
+
+  /* Set tolerances */
+  reltol = RCONST(1.0e-4);
+  NV_Ith_S(atols,0) = RCONST(1.0e-8);
+  NV_Ith_S(atols,1) = RCONST(1.0e-11);
+  NV_Ith_S(atols,2) = RCONST(1.0e-8);
+
+  /* Set routines */
+  flag = ARKodeSetMaxErrTestFails(arkode_mem, 20);        /* Increase max error test fails */
+  if (check_flag(&flag, "ARKodeSetMaxErrTestFails", 1)) return 1;
+  flag = ARKodeSetMaxNonlinIters(arkode_mem, 8);          /* Increase max nonlinear iterations  */
+  if (check_flag(&flag, "ARKodeSetMaxNonlinIters", 1)) return 1;
+  flag = ARKodeSetNonlinConvCoef(arkode_mem, 1.e-7);      /* Update nonlinear solver convergence coeff. */
+  if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) return 1;
+  flag = ARKodeSetMaxNumSteps(arkode_mem, 100000);        /* Increase max number of steps */
+  if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) return 1;
+  flag = ARKodeSetPredictorMethod(arkode_mem, 1);         /* Specify maximum-order predictor */
+  if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) return 1;
+  flag = ARKodeSVtolerances(arkode_mem, reltol, atols);   /* Specify tolerances */
+  if (check_flag(&flag, "ARKodeSStolerances", 1)) return 1;
+
+  /* Specify the root-finding function, having 2 equations */
+  flag = ARKodeRootInit(arkode_mem, 2, g);
+  if (check_flag(&flag, "ARKodeRootInit", 1)) return 1;
+
+  /* Linear solver specification */
+  flag = ARKDense(arkode_mem, NEQ);                /* Specify dense linear solver */
+  if (check_flag(&flag, "ARKDense", 1)) return 1;
+  flag = ARKDlsSetDenseJacFn(arkode_mem, Jac);     /* Set the Jacobian routine */
+  if (check_flag(&flag, "ARKDlsSetDenseJacFn", 1)) return 1;
+
+  /* Open output stream for results, output comment line */
+  UFID = fopen("solution.txt","w");
+  fprintf(UFID,"# t u v w\n");
+
+  /* output initial condition to disk */
+  fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	  T0, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+
+  /* Main time-stepping loop: calls ARKode to perform the integration, then
+     prints results.  Stops when the final time has been reached */
+  t = T0;
+  printf("        t             u             v             w\n");
+  printf("   -----------------------------------------------------\n");
+  printf("  %12.5e  %12.5e  %12.5e  %12.5e\n",
+      t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));
+  tout = T1;
+  iout = 0;
+  while(1) {
+
+    flag = ARKode(arkode_mem, tout, y, &t, ARK_NORMAL);     /* call integrator */
+    if (check_flag(&flag, "ARKode", 1)) break;
+    printf("  %12.5e  %12.5e  %12.5e  %12.5e\n",  t,        /* access/print solution */
+        NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));
+    fprintf(UFID," %.16e %.16e %.16e %.16e\n", 
+	    t, NV_Ith_S(y,0), NV_Ith_S(y,1), NV_Ith_S(y,2));  
+    if (flag == ARK_ROOT_RETURN) {                          /* check if a root was found */
+      rtflag = ARKodeGetRootInfo(arkode_mem, rootsfound);
+      if (check_flag(&rtflag, "ARKodeGetRootInfo", 1)) return 1;
+      printf("      rootsfound[] = %3d %3d\n",
+          rootsfound[0], rootsfound[1]);
+    }
+    if (flag >= 0) {                                        /* successful solve: update output time */
+      iout++;
+      tout *= TMult;
+    } else {                                                /* unsuccessful solve: break */
+      fprintf(stderr,"Solver failure, stopping integration\n");
+      break;
+    }
+    if (iout == Nt) break;                                  /* stop after enough outputs */
+  }
+  printf("   -----------------------------------------------------\n");
+  fclose(UFID);
+
+  /* Print some final statistics */
+  flag = ARKodeGetNumSteps(arkode_mem, &nst);
+  check_flag(&flag, "ARKodeGetNumSteps", 1);
+  flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a);
+  check_flag(&flag, "ARKodeGetNumStepAttempts", 1);
+  flag = ARKodeGetNumRhsEvals(arkode_mem, &nfe, &nfi);
+  check_flag(&flag, "ARKodeGetNumRhsEvals", 1);
+  flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups);
+  check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1);
+  flag = ARKodeGetNumErrTestFails(arkode_mem, &netf);
+  check_flag(&flag, "ARKodeGetNumErrTestFails", 1);
+  flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1);
+  flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn);
+  check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1);
+  flag = ARKDlsGetNumJacEvals(arkode_mem, &nje);
+  check_flag(&flag, "ARKDlsGetNumJacEvals", 1);
+  flag = ARKDlsGetNumRhsEvals(arkode_mem, &nfeLS);
+  check_flag(&flag, "ARKDlsGetNumRhsEvals", 1);
+  flag = ARKodeGetNumGEvals(arkode_mem, &nge);
+  check_flag(&flag, "ARKodeGetNumGEvals", 1);
+
+  printf("\nFinal Solver Statistics:\n");
+  printf("   Internal solver steps = %li (attempted = %li)\n", 
+	 nst, nst_a);
+  printf("   Total RHS evals:  Fe = %li,  Fi = %li\n", nfe, nfi);
+  printf("   Total linear solver setups = %li\n", nsetups);
+  printf("   Total RHS evals for setting up the linear system = %li\n", nfeLS);
+  printf("   Total number of Jacobian evaluations = %li\n", nje);
+  printf("   Total number of Newton iterations = %li\n", nni);
+  printf("   Total root-function g evals = %li\n", nge);
+  printf("   Total number of nonlinear solver convergence failures = %li\n", ncfn);
+  printf("   Total number of error test failures = %li\n", netf);
+
+  /* Clean up and return with successful completion */
+  N_VDestroy_Serial(y);        /* Free y vector */
+  ARKodeFree(&arkode_mem);     /* Free integrator memory */
+  return 0;
+}
+
+/*-------------------------------
+ * Functions called by the solver
+ *-------------------------------*/
+
+/* f routine to compute the ODE RHS function f(t,y). */
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype u = NV_Ith_S(y,0);     /* access current solution */
+  realtype v = NV_Ith_S(y,1);
+  realtype w = NV_Ith_S(y,2);
+
+  /* Fill in the ODE RHS function */
+  NV_Ith_S(ydot,0) = -0.04*u + 1.e4*v*w;
+  NV_Ith_S(ydot,1) = 0.04*u - 1.e4*v*w - 3.e7*v*v;
+  NV_Ith_S(ydot,2) = 3.e7*v*v;
+
+  return 0;                      /* Return with success */
+}
+
+/* Jacobian routine to compute J(t,y) = df/dy. */
+static int Jac(long int N, realtype t,
+               N_Vector y, N_Vector fy, DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype v = NV_Ith_S(y,1);    /* access current solution */
+  realtype w = NV_Ith_S(y,2);
+  SetToZero(J);                  /* initialize Jacobian to zero */
+
+  /* Fill in the Jacobian of the ODE RHS function */
+  DENSE_ELEM(J,0,0) = -0.04;
+  DENSE_ELEM(J,0,1) = 1.e4*w;
+  DENSE_ELEM(J,0,2) = 1.e4*v;
+
+  DENSE_ELEM(J,1,0) = 0.04;
+  DENSE_ELEM(J,1,1) = -1.e4*w - 6.e7*v;
+  DENSE_ELEM(J,1,2) = -1.e4*v;
+
+  DENSE_ELEM(J,2,1) = 6.e7*v;
+
+  return 0;                      /* Return with success */
+}
+
+/* g routine to compute the root-finding function g(t,y). */
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data)
+{
+  realtype u = NV_Ith_S(y,0);    /* access current solution */
+  realtype w = NV_Ith_S(y,2);
+
+  gout[0] = u - RCONST(0.0001);  /* check for u == 1e-4 */
+  gout[1] = w - RCONST(0.01);    /* check for w == 1e-2 */
+
+  return 0;                      /* Return with success */
+}
+
+/*-------------------------------
+ * Private helper functions
+ *-------------------------------*/
+
+/* Check function return value...
+    opt == 0 means SUNDIALS function allocates memory so check if
+             returned NULL pointer
+    opt == 1 means SUNDIALS function returns a flag so check if
+             flag >= 0
+    opt == 2 means function allocates memory so check if returned
+             NULL pointer  
+*/
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return 1; }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return 1; }
+
+  return 0;
+}
+
+
+/*---- end of file ----*/
diff --git a/examples/arkode/C_serial/ark_robertson_root.out b/examples/arkode/C_serial/ark_robertson_root.out
new file mode 100644
index 0000000..81c4333
--- /dev/null
+++ b/examples/arkode/C_serial/ark_robertson_root.out
@@ -0,0 +1,32 @@
+
+Robertson ODE test problem (with rootfinding):
+    initial conditions:  u0 = 1,  v0 = 0,  w0 = 0
+        t             u             v             w
+   -----------------------------------------------------
+   0.00000e+00   1.00000e+00   0.00000e+00   0.00000e+00
+   2.64019e-01   9.89965e-01   3.47058e-05   1.00000e-02
+      rootsfound[] =   0   1
+   4.00000e+00   9.05519e-01   2.24048e-05   9.44589e-02
+   4.00000e+01   7.15827e-01   9.18557e-06   2.84164e-01
+   4.00000e+02   4.50519e-01   3.22289e-06   5.49478e-01
+   4.00000e+03   1.83202e-01   8.94239e-07   8.16797e-01
+   4.00000e+04   3.89834e-02   1.62177e-07   9.61016e-01
+   4.00000e+05   4.93828e-03   1.98557e-08   9.95062e-01
+   4.00000e+06   5.16807e-04   2.07133e-09   9.99483e-01
+   2.07957e+07   1.00000e-04   3.99831e-10   9.99900e-01
+      rootsfound[] =  -1   0
+   4.00000e+08   5.20791e-06   2.05800e-11   9.99995e-01
+   4.00000e+09   5.20859e-07   2.07683e-12   9.99999e-01
+   4.00000e+10   5.20842e-08   3.85950e-13   1.00000e+00
+   -----------------------------------------------------
+
+Final Solver Statistics:
+   Internal solver steps = 955 (attempted = 1157)
+   Total RHS evals:  Fe = 0,  Fi = 32555
+   Total linear solver setups = 534
+   Total RHS evals for setting up the linear system = 0
+   Total number of Jacobian evaluations = 68
+   Total number of Newton iterations = 26813
+   Total root-function g evals = 981
+   Total number of nonlinear solver convergence failures = 15
+   Total number of error test failures = 187
diff --git a/examples/arkode/C_serial/bruss_plots.m b/examples/arkode/C_serial/bruss_plots.m
new file mode 100644
index 0000000..66f235c
--- /dev/null
+++ b/examples/arkode/C_serial/bruss_plots.m
@@ -0,0 +1,75 @@
+% ----------------------------------------------------------------
+% Programmer(s): Daniel R. Reynolds @ SMU
+% ----------------------------------------------------------------
+% LLNS/SMU Copyright Start
+% Copyright (c) 2015, Southern Methodist University and 
+% Lawrence Livermore National Security
+%
+% This work was performed under the auspices of the U.S. Department 
+% of Energy by Southern Methodist University and Lawrence Livermore 
+% National Laboratory under Contract DE-AC52-07NA27344.
+% Produced at Southern Methodist University and the Lawrence 
+% Livermore National Laboratory.
+%
+% All rights reserved.
+% For details, see the LICENSE file.
+% LLNS/SMU Copyright End
+% Copyright (c) 2013, Southern Methodist University.
+% All rights reserved.
+% For details, see the LICENSE file.
+% ----------------------------------------------------------------
+% Matlab script to load/plot 1D brusselator results
+
+clear
+
+% load output files
+x = load('bruss_mesh.txt');
+u = load('bruss_u.txt');
+v = load('bruss_v.txt');
+w = load('bruss_w.txt');
+
+% check for compatible sizes
+Nx = length(x);
+[Nt_u,Nx_u] = size(u);
+[Nt_v,Nx_v] = size(v);
+[Nt_w,Nx_w] = size(w);
+if ((Nx ~= Nx_u) | (Nx ~= Nx_v) | (Nx ~= Nx_w))
+   fprintf('Error: incompatible spatial dimensions!\n');
+   fprintf('  Nx = %i,  Nx_u = %i,  Nx_v = %i,  Nx_w = %i\n',Nx,Nx_u,Nx_v,Nx_w);
+   error('Result files are incompatible, re-run simulation')
+end
+Nt = Nt_u;
+if ((Nt ~= Nt_v) | (Nt ~= Nt_w))
+   fprintf('Error: incompatible temporal dimensions!\n');
+   fprintf('  Nt_u = %i,  Nt_v = %i,  Nt_w = %i\n',Nt_u,Nt_v,Nt_w);
+   error('Result files are incompatible, re-run simulation')
+end
+
+% get bounding box size
+ymax = 1.1*max([max(max(u)), max(max(v)), max(max(w))]);
+ymin = 0.9*min([min(min(u)), min(min(v)), min(min(w))]);
+xmax = max(x);
+xmin = min(x);
+
+% plot time series for center of spatial domain
+figure()
+t = linspace(1,Nt,Nt);
+ix = floor(Nx/2);
+plot(t,u(:,ix),'b-',t,v(:,ix),'r--',t,w(:,ix),'k-.','LineWidth',1)
+legend('u','v','w')
+axis([1, Nt, ymin, ymax]);
+title('Time series of solutions at domain center')
+
+
+% loop over output times, plotting results and pausing between each
+figure()
+for it = 1:Nt
+   uvec = u(it,:)';
+   vvec = v(it,:)';
+   wvec = w(it,:)';
+   plot(x,uvec,'b-',x,vvec,'r--',x,wvec,'k-.','LineWidth',1)
+   legend('u','v','w')
+   axis([xmin, xmax, ymin, ymax]);
+   title(sprintf('Solutions, time step %i',it-1))
+   pause
+end
diff --git a/examples/arkode/C_serial/plot_brusselator1D.py b/examples/arkode/C_serial/plot_brusselator1D.py
new file mode 100755
index 0000000..bf65e8e
--- /dev/null
+++ b/examples/arkode/C_serial/plot_brusselator1D.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for brusselator1D.c example
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load mesh data file
+mesh = np.loadtxt('bruss_mesh.txt', dtype=np.double)
+
+# load solution data files
+udata = np.loadtxt('bruss_u.txt', dtype=np.double)
+vdata = np.loadtxt('bruss_v.txt', dtype=np.double)
+wdata = np.loadtxt('bruss_w.txt', dtype=np.double)
+
+# determine number of time steps, mesh size
+nt,nx = np.shape(udata)
+
+# determine min/max values
+umin = 0.9*udata.min()
+umax = 1.1*udata.max()
+vmin = 0.9*vdata.min()
+vmax = 1.1*vdata.max()
+wmin = 0.9*wdata.min()
+wmax = 1.1*wdata.max()
+minval = np.array([umin, vmin, wmin]).min()
+maxval = np.array([umax, vmax, wmax]).max()
+
+# generate plots of results
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'brusselator1D.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(nx)
+
+    # plot current solution and save to disk
+    plt.figure(1)
+    plt.plot(mesh,udata[tstep,:],label="u")
+    plt.plot(mesh,vdata[tstep,:],label="v")
+    plt.plot(mesh,wdata[tstep,:],label="w")
+    plt.xlabel('x')
+    plt.ylabel('solution')
+    plt.title('Solutions at output ' + tstr + ', mesh = ' + nxstr)
+    plt.axis((0.0, 1.0, minval, maxval))
+    plt.grid()
+    plt.legend(loc='upper right', shadow=True)
+    plt.savefig(pname)
+    plt.close()
+
+
+##### end of script #####
diff --git a/examples/arkode/C_serial/plot_brusselator1D_FEM.py b/examples/arkode/C_serial/plot_brusselator1D_FEM.py
new file mode 100755
index 0000000..47ad96e
--- /dev/null
+++ b/examples/arkode/C_serial/plot_brusselator1D_FEM.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+# ------------------------------------------------------------
+# Programmer(s):  Daniel R. Reynolds @ SMU
+# ------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ------------------------------------------------------------
+# matplotlib-based plotting script for brusselator1D.c example
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load mesh data file
+mesh = np.loadtxt('bruss_FEM_mesh.txt', dtype=np.double)
+
+# load solution data files
+udata = np.loadtxt('bruss_FEM_u.txt', dtype=np.double)
+vdata = np.loadtxt('bruss_FEM_v.txt', dtype=np.double)
+wdata = np.loadtxt('bruss_FEM_w.txt', dtype=np.double)
+
+# determine number of time steps, mesh size
+nt,nx = np.shape(udata)
+
+# determine min/max values
+umin = 0.9*udata.min()
+umax = 1.1*udata.max()
+vmin = 0.9*vdata.min()
+vmax = 1.1*vdata.max()
+wmin = 0.9*wdata.min()
+wmax = 1.1*wdata.max()
+minval = np.array([umin, vmin, wmin]).min()
+maxval = np.array([umax, vmax, wmax]).max()
+
+# plot the mesh
+plt.figure(1)
+plt.plot(mesh,0.0*mesh,'o')
+plt.xlabel('x')
+plt.title('FEM mesh')
+plt.savefig('brusselator1D_FEM_mesh.png')
+
+# generate plots of results
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'brusselator1D_FEM.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(nx)
+
+    # plot current solution and save to disk
+    plt.figure(1)
+    plt.plot(mesh,udata[tstep,:],label="u")
+    plt.plot(mesh,vdata[tstep,:],label="v")
+    plt.plot(mesh,wdata[tstep,:],label="w")
+    plt.xlabel('x')
+    plt.ylabel('solution')
+    plt.title('Solutions at output ' + tstr + ', mesh = ' + nxstr)
+    plt.axis((0.0, 1.0, minval, maxval))
+    plt.grid()
+    plt.legend(loc='upper right', shadow=True)
+    plt.savefig(pname)
+    plt.close()
+
+
+##### end of script #####
diff --git a/examples/arkode/C_serial/plot_heat1D.py b/examples/arkode/C_serial/plot_heat1D.py
new file mode 100755
index 0000000..8fdba6c
--- /dev/null
+++ b/examples/arkode/C_serial/plot_heat1D.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for heat1D.c example
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load mesh data file
+mesh = np.loadtxt('heat_mesh.txt', dtype=np.double)
+
+# load solution data file
+data = np.loadtxt('heat1D.txt', dtype=np.double)
+
+# determine number of time steps, mesh size
+nt,nx = np.shape(data)
+
+# determine maximum temperature
+maxtemp = 1.1*data.max()
+
+# generate plots of results
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'heat1d.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(nx)
+
+    # plot current solution and save to disk
+    plt.figure(1)
+    plt.plot(mesh,data[tstep,:])
+    plt.xlabel('x')
+    plt.ylabel('solution')
+    plt.title('u(x) at output ' + tstr + ', mesh = ' + nxstr)
+    plt.axis((0.0, 1.0, 0.0, maxtemp))
+    plt.grid()
+    plt.savefig(pname)
+    plt.close()
+
+
+##### end of script #####
diff --git a/examples/arkode/C_serial/plot_heat1D_adapt.py b/examples/arkode/C_serial/plot_heat1D_adapt.py
new file mode 100755
index 0000000..f217ac2
--- /dev/null
+++ b/examples/arkode/C_serial/plot_heat1D_adapt.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for heat1D.c example
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load mesh data file as list of NumPy arrays
+inp = open('heat_mesh.txt').readlines()
+mesh = []
+for line in inp:
+    mesh.append(np.array(str.split(line), dtype=np.double))
+
+
+# load solution data file as list of NumPy arrays
+inp = open('heat1D.txt').readlines()
+data = []
+for line in inp:
+    data.append(np.array(str.split(line), dtype=np.double))
+
+# determine number of time steps
+nt  = len(mesh)
+nt2 = len(data)
+if (nt != nt2):
+    sys.exit('plot_heat1D_adapt.py error: data and mesh files have different numbers of time steps')
+
+# determine minimum/maximum temperature
+mintemp = 0.0
+maxtemp = 0.0
+for tstep in range(nt):
+    mx = data[tstep].max()
+    if (mx > maxtemp):
+        maxtemp = mx
+    mn = data[tstep].min()
+    if (mn < mintemp):
+        mintemp = mn
+if (maxtemp > 0.0):
+    maxtemp *= 1.1
+else:
+    maxtemp *= 0.9
+if (mintemp > 0.0):
+    mintemp *= 0.9
+else:
+    mintemp *= 1.1
+
+
+# generate plots of results
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'heat1d.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(len(data[tstep]))
+
+    # plot current solution and save to disk
+    plt.figure(1)
+    plt.plot(mesh[tstep],data[tstep],'-o')
+    plt.xlabel('x')
+    plt.ylabel('solution')
+    plt.title('u(x) at output ' + tstr + ', mesh = ' + nxstr)
+    plt.axis((0.0, 1.0, mintemp, maxtemp))
+    plt.grid()
+    plt.savefig(pname)
+    plt.close()
+
+
+##### end of script #####
diff --git a/examples/arkode/C_serial/plot_sol.py b/examples/arkode/C_serial/plot_sol.py
new file mode 100755
index 0000000..554881c
--- /dev/null
+++ b/examples/arkode/C_serial/plot_sol.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for ODE examples
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load solution data file
+data = np.loadtxt('solution.txt', dtype=np.double)
+
+# determine number of time steps, number of fields
+nt,nv = np.shape(data)
+
+# extract time array
+times = data[:,0]
+
+# parse comment line to determine solution names
+f = open('solution.txt', 'r')
+commentline = f.readline()
+commentsplit = commentline.split()
+names = commentsplit[2:]
+
+# create plot
+plt.figure()
+
+# add curves to figure
+for i in range(nv-1):
+    plt.plot(times,data[:,i+1],label=names[i])
+plt.xlabel('t')
+if (nv > 2):
+    plt.ylabel('solutions')
+else:
+    plt.ylabel('solution')
+plt.legend(loc='upper right', shadow=True)
+plt.grid()
+plt.savefig('solution.png')
+
+
+
+
+##### end of script #####
diff --git a/examples/arkode/C_serial/plot_sol_log.py b/examples/arkode/C_serial/plot_sol_log.py
new file mode 100755
index 0000000..1fa4ad9
--- /dev/null
+++ b/examples/arkode/C_serial/plot_sol_log.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for heat2D.cpp example
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load solution data file
+data = np.loadtxt('solution.txt', dtype=np.double)
+
+# determine number of time steps, number of fields
+nt,nv = np.shape(data)
+
+# extract time array
+times = data[:,0]
+
+# parse comment line to determine solution names
+f = open('solution.txt', 'r')
+commentline = f.readline()
+commentsplit = commentline.split()
+names = commentsplit[2:]
+
+# create plot
+plt.figure()
+
+# add curves to figure
+for i in range(nv-1):
+    plt.loglog(times,data[:,i+1],label=names[i])
+plt.xlabel('t')
+if (nv > 2):
+    plt.ylabel('solutions')
+else:
+    plt.ylabel('solution')
+plt.legend(loc='upper right', shadow=True)
+plt.grid()
+plt.savefig('solution.png')
+
+
+
+
+##### end of script #####
diff --git a/examples/arkode/F77_parallel/CMakeLists.txt b/examples/arkode/F77_parallel/CMakeLists.txt
new file mode 100644
index 0000000..5454a4f
--- /dev/null
+++ b/examples/arkode/F77_parallel/CMakeLists.txt
@@ -0,0 +1,154 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for the FARKODE parallel examples
+
+
+# Add variable FARKODE_examples with the names of the parallel ARKODE examples
+
+SET(FARKODE_examples
+  "fark_diag_non_p\;1\;4"
+  "fark_diag_kry_bbd_p\;1\;4"
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+
+SET(ARKODE_extras
+  )
+
+# Check whether we use MPI compiler scripts.
+# If yes, then change the Fortran compiler to the MPIF77 script.
+# If not, then add the MPI include directory for MPI headers.
+
+IF(MPI_MPIF77 )
+  # use MPI_MPIF77 as the compiler
+  SET(CMAKE_Fortran_COMPILER ${MPI_MPIF77})
+ELSE(MPI_MPIF77)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPIF77)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECP_LIB sundials_nvecparallel_static)
+  SET(FNVECP_LIB sundials_fnvecparallel_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECP_LIB sundials_nvecparallel_shared)
+  SET(FNVECP_LIB sundials_fnvecparallel_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Only static FCMIX libraries are available
+
+SET(FARKODE_LIB sundials_farkode_static)
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${FARKODE_LIB} ${ARKODE_LIB} ${FNVECP_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each ARKODE example
+
+FOREACH(example_tuple ${FARKODE_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
+  ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(NOT MPI_MPIF77)
+    TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
+  ENDIF(NOT MPI_MPIF77)
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_parallel)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example_tuple ${FARKODE_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_parallel)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_parallel)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  SET(SOLVER_FLIB "sundials_farkode")
+  FOREACH(example_tuple ${FARKODE_examples})
+    list(GET example_tuple 0 example)
+    LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${FARKODE_examples})
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F77_parallel/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/F77_parallel/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_parallel 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F77_parallel/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/F77_parallel/Makefile_ex
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_parallel 
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/F77_parallel/README b/examples/arkode/F77_parallel/README
new file mode 100644
index 0000000..cfea683
--- /dev/null
+++ b/examples/arkode/F77_parallel/README
@@ -0,0 +1,50 @@
+List of parallel ARKode F77 examples
+
+  fark_diag_non_p     : diagonal ODE example - non-stiff case (ERK)
+  fark_diag_kry_bbd_p : diagonal ODE example - stiff case (DIRK/SPGMR/FARKBBD)
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/F77_parallel/fark_diag_kry_bbd_p.f b/examples/arkode/F77_parallel/fark_diag_kry_bbd_p.f
new file mode 100644
index 0000000..24c7a26
--- /dev/null
+++ b/examples/arkode/F77_parallel/fark_diag_kry_bbd_p.f
@@ -0,0 +1,358 @@
+C     ----------------------------------------------------------------
+C     Programmer(s): Daniel R. Reynolds @ SMU
+C     ----------------------------------------------------------------
+C     LLNS/SMU Copyright Start
+C     Copyright (c) 2015, Southern Methodist University and 
+C     Lawrence Livermore National Security
+C
+C     This work was performed under the auspices of the U.S. Department 
+C     of Energy by Southern Methodist University and Lawrence Livermore 
+C     National Laboratory under Contract DE-AC52-07NA27344.
+C     Produced at Southern Methodist University and the Lawrence 
+C     Livermore National Laboratory.
+C
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     LLNS/SMU Copyright End
+C     Copyright (c) 2013, Southern Methodist University.
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     ----------------------------------------------------------------
+C     Diagonal ODE example.  Stiff case, with diagonal preconditioner.
+C     Uses FARKODE interfaces and FARKBBD interfaces.
+C     Solves problem twice -- with left and right preconditioning.
+C     ----------------------------------------------------------------
+C     
+C     Include MPI-Fortran header file for MPI_COMM_WORLD, MPI types.
+      
+      IMPLICIT NONE
+C
+      INCLUDE "mpif.h"
+C
+      INTEGER*8 NLOCAL
+      PARAMETER (NLOCAL=10)   
+C
+      INTEGER*4 NOUT, MYPE, IER, NPES, METH, IATOL, ITASK, IPRE, IGS
+      INTEGER*4 LLENRW, LLENIW, LNST, LNST_ATT, LNFE, LNFI, LNSETUP
+      INTEGER*4 LNETF, LNNI, LNCF, LLENRWLS, LLENIWLS, LNPE, LNPS, LNLI
+      INTEGER*4 LNCFL, JOUT
+      INTEGER*8 NEQ, I, IPAR(3), IOUT(22), MUDQ, MLDQ, MU, ML, NST
+      INTEGER*8 NST_ATT, NFE, NFI, NPSET, NPE, NPS, NNI, NLI, NCFN, NCFL
+      INTEGER*8 NETF, LENRW, LENIW, LENRWLS, LENIWLS, LENRWBBD, LENIWBBD
+      INTEGER*8 NGEBBD
+      DOUBLE PRECISION Y(1024), ROUT(6), RPAR(1)
+      DOUBLE PRECISION ALPHA, TOUT, ERMAX, AVDIM
+      DOUBLE PRECISION ATOL, ERRI, RTOL, GERMAX, DTOUT, T
+C     
+      DATA ATOL/1.0D-10/, RTOL/1.0D-5/, DTOUT/0.1D0/, NOUT/10/
+      DATA LLENRW/1/, LLENIW/2/, LNST/3/, LNST_ATT/6/, LNFE/7/, LNFI/8/, 
+     1     LNSETUP/9/, LNETF/10/, LNNI/11/, LNCF/12/, LLENRWLS/14/, 
+     1     LLENIWLS/15/, LNPE/19/, LNPS/20/, LNLI/21/, LNCFL/22/
+C
+C     Get NPES and MYPE.  Requires initialization of MPI.
+      CALL MPI_INIT(IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,5) IER
+ 5       FORMAT(///' MPI_ERROR: MPI_INIT returned IER = ', I5)
+         STOP
+      ENDIF
+      CALL MPI_COMM_SIZE(MPI_COMM_WORLD, NPES, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,6) IER
+ 6       FORMAT(///' MPI_ERROR: MPI_COMM_SIZE returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+      CALL MPI_COMM_RANK(MPI_COMM_WORLD, MYPE, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,7) IER
+ 7       FORMAT(///' MPI_ERROR: MPI_COMM_RANK returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF      
+C     
+C     Set input arguments.
+      NEQ = NPES * NLOCAL
+      T = 0.0D0
+      METH = 0
+      IATOL = 1
+      ITASK = 1
+      IPRE = 1
+      IGS = 1
+C     Set parameter alpha
+      ALPHA  = 10.0D0
+C
+C     Load IPAR and RPAR
+      IPAR(1) = NLOCAL
+      IPAR(2) = MYPE
+      IPAR(3) = NEQ
+      RPAR(1) = ALPHA
+C     
+      DO I = 1, NLOCAL
+         Y(I) = 1.0D0
+      ENDDO
+C     
+      IF (MYPE .EQ. 0) THEN
+         WRITE(6,15) NEQ, NLOCAL, ALPHA, RTOL, ATOL, NPES
+ 15      FORMAT('Diagonal test problem:'//
+     &        ' NEQ = ', I3, /
+     &        ' NLOCAL = ', I3, /
+     &        ' parameter alpha = ', F8.3/
+     &        ' ydot_i = -alpha*i * y_i (i = 1,...,NEQ)'/
+     &        ' RTOL, ATOL = ', 2E10.1/
+     &        ' Method is DIRK/NEWTON/SPGMR'/
+     &        ' Precond is band-block-diagonal, using ARKBBDPRE'
+     &        /' Number of processors = ', I3/)
+      ENDIF
+C     
+      CALL FNVINITP(MPI_COMM_WORLD, 4, NLOCAL, NEQ, IER)
+C     
+      IF (IER .NE. 0) THEN
+         WRITE(6,20) IER
+ 20      FORMAT(///' SUNDIALS_ERROR: FNVINITP returned IER = ', I5)
+         CALL MPI_FINALIZE(IER)
+         STOP
+      ENDIF
+C     
+      CALL FARKMALLOC(T, Y, METH, IATOL, RTOL, ATOL,
+     &                IOUT, ROUT, IPAR, RPAR, IER)
+C     
+      IF (IER .NE. 0) THEN
+         WRITE(6,30) IER
+ 30      FORMAT(///' SUNDIALS_ERROR: FARKMALLOC returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+C
+      CALL FARKSPGMR(IPRE, IGS, 0, 0.0D0, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,36) IER
+ 36      FORMAT(///' SUNDIALS_ERROR: FARKSPGMR returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+C     
+      MUDQ = 0
+      MLDQ = 0
+      MU = 0
+      ML = 0
+      CALL FARKBBDINIT(NLOCAL, MUDQ, MLDQ, MU, ML, 0.0D0, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,35) IER
+ 35      FORMAT(///' SUNDIALS_ERROR: FARKBBDINIT returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+C
+      IF (MYPE .EQ. 0) WRITE(6,38)
+ 38   FORMAT(/'Preconditioning on left'/)
+C     
+C     Looping point for cases IPRE = 1 and 2.
+C     
+ 40   CONTINUE
+C     
+C     Loop through tout values, call solver, print output, test for failure.
+      TOUT = DTOUT
+      DO 60 JOUT = 1, NOUT
+C     
+         CALL FARKODE(TOUT, T, Y, ITASK, IER)
+C     
+         IF (MYPE .EQ. 0) WRITE(6,45) T, IOUT(LNST), IOUT(LNST_ATT), 
+     &        IOUT(LNFE), IOUT(LNFI)
+ 45      FORMAT(' t = ', E10.2, 5X, 'no. steps = ', I5, 
+     &        '   no. attempts = ', I5,'   no. fe-s = ', I5,
+     &        '   no. fi-s = ', I5)
+C     
+         IF (IER .NE. 0) THEN
+            WRITE(6,50) IER, IOUT(16)
+ 50         FORMAT(///' SUNDIALS_ERROR: FARKODE returned IER = ', I5, /,
+     &             '                 Linear Solver returned IER = ', I5)
+            CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+            STOP
+         ENDIF
+C     
+         TOUT = TOUT + DTOUT
+ 60   CONTINUE
+C     
+C     Get max. absolute error in the local vector.
+      ERMAX = 0.0D0
+      DO 65 I = 1, NLOCAL
+         ERRI  = Y(I) - EXP(-ALPHA * (MYPE * NLOCAL + I) * T)
+         ERMAX = MAX(ERMAX, ABS(ERRI))
+ 65   CONTINUE
+C     Get global max. error from MPI_REDUCE call.
+      CALL MPI_REDUCE(ERMAX, GERMAX, 1, MPI_DOUBLE_PRECISION, MPI_MAX,
+     &                0, MPI_COMM_WORLD, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,70) IER
+ 70      FORMAT(///' MPI_ERROR: MPI_REDUCE returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+      IF (MYPE .EQ. 0) WRITE(6,75) GERMAX
+ 75   FORMAT(/'Max. absolute error is', E10.2/)
+C     
+C     Print final statistics.
+      IF (MYPE .EQ. 0) THEN
+         NST = IOUT(LNST)
+         NST_ATT = IOUT(LNST_ATT)
+         NFE = IOUT(LNFE)
+         NFI = IOUT(LNFI)
+         NPSET = IOUT(LNSETUP)
+         NPE = IOUT(LNPE)
+         NPS = IOUT(LNPS)
+         NNI = IOUT(LNNI)
+         NLI = IOUT(LNLI)
+         AVDIM = DBLE(NLI) / DBLE(NNI)
+         NCFN = IOUT(LNCF)
+         NCFL = IOUT(LNCFL)
+         NETF = IOUT(LNETF)
+         LENRW = IOUT(LLENRW)
+         LENIW = IOUT(LLENIW)
+         LENRWLS = IOUT(LLENRWLS)
+         LENIWLS = IOUT(LLENIWLS)
+         WRITE(6,80) NST, NST_ATT, NFE, NFI, NPSET, NPE, NPS, NNI, NLI,
+     &        AVDIM, NCFN, NCFL, NETF, LENRW, LENIW, LENRWLS, LENIWLS
+ 80      FORMAT(/'Final statistics:'//
+     &          ' number of steps        = ', I5/
+     &          ' number of steps att.   = ', I5/
+     &          ' number of fe evals.    = ', I5/
+     &          ' number of fi evals.    = ', I5/
+     &          ' number of prec. setups = ', I5/
+     &          ' number of prec. evals. = ', I5/
+     &          ' number of prec. solves = ', I5/
+     &          ' number of nonl. iters. = ', I5/
+     &          ' number of lin. iters.  = ', I5/
+     &          ' average Krylov subspace dimension (NLI/NNI) = ',F8.4/
+     &          ' number of conv. failures.. nonlinear = ', I3,
+     &          '  linear = ', I3/
+     &          ' number of error test failures = ', I3/
+     &          ' main solver real/int workspace sizes   = ',2I5/
+     &          ' linear solver real/int workspace sizes = ',2I5)
+         CALL FARKBBDOPT(LENRWBBD, LENIWBBD, NGEBBD)
+         WRITE(6,82) LENRWBBD, LENIWBBD, NGEBBD
+ 82      FORMAT('In ARKBBDPRE:'/
+     &          ' real/int local workspace = ', 2I5/
+     &          ' number of g evals. = ', I5)
+      ENDIF
+C     
+C     If IPRE = 1, re-initialize T, Y, and the solver, and loop for
+C     case IPRE = 2.  Otherwise jump to final block.
+      IF (IPRE .EQ. 2) GO TO 99
+C
+      T = 0.0D0
+      DO I = 1, NLOCAL
+         Y(I) = 1.0D0
+      ENDDO         
+C
+      CALL FARKREINIT(T, Y, METH, IATOL, RTOL, ATOL, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,91) IER
+ 91      FORMAT(///' SUNDIALS_ERROR: FARKREINIT returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+C
+      IPRE = 2
+C
+      CALL FARKBBDREINIT(NLOCAL, MUDQ, MLDQ, 0.0D0, IER) 
+      IF (IER .NE. 0) THEN
+         WRITE(6,92) IER
+ 92      FORMAT(///' SUNDIALS_ERROR: FARKBBDREINIT returned IER = ', I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+C
+      CALL FARKSPGMRREINIT(IPRE, IGS, 0.0D0, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,93) IER
+ 93      FORMAT(///' SUNDIALS_ERROR: FARKSPGMRREINIT returned IER =',I5)
+         CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+         STOP
+      ENDIF
+C
+      IF (MYPE .EQ. 0) WRITE(6,95)
+ 95   FORMAT(//60('-')///'Preconditioning on right'/)
+      GO TO 40
+C     
+C     Free the memory and finalize MPI.
+ 99   CALL FARKFREE
+      CALL MPI_FINALIZE(IER)
+C     
+      STOP
+      END
+C
+C     ------------------------------------------------------------------------
+C
+      SUBROUTINE FARKIFUN(T, Y, YDOT, IPAR, RPAR, IER)
+C     Routine for right-hand side function fi
+      IMPLICIT NONE
+C
+      INTEGER*8 IPAR(*)
+      INTEGER*4 IER
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
+C
+      INTEGER*8 MYPE, I, NLOCAL
+      DOUBLE PRECISION ALPHA
+C     
+      NLOCAL = IPAR(1)
+      MYPE = IPAR(2)
+      ALPHA = RPAR(1)
+C
+      DO I = 1, NLOCAL
+         YDOT(I) = -ALPHA * (MYPE * NLOCAL + I) * Y(I)
+      ENDDO
+C     
+      IER = 0
+C
+      RETURN
+      END
+C
+C     ------------------------------------------------------------------------
+C
+      SUBROUTINE FARKEFUN(T, Y, YDOT, IPAR, RPAR, IER)
+C     Routine for right-hand side function fe
+      IMPLICIT NONE
+C
+      INTEGER*8 IPAR(*)
+      INTEGER*4 IER
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
+C
+      INTEGER*8 I, NLOCAL
+C     
+      NLOCAL = IPAR(1)
+C
+      DO I = 1, NLOCAL
+         YDOT(I) = 0.D0
+      ENDDO
+C     
+      IER = 0
+C
+      RETURN
+      END
+C
+C     ------------------------------------------------------------------------
+C
+      SUBROUTINE FARKGLOCFN(NLOC, T, YLOC, GLOC, IPAR, RPAR, IER)
+C     Routine to define local approximate function g, here the same as fi. 
+      IMPLICIT NONE
+C
+      INTEGER*8 NLOC, IPAR(*)
+      INTEGER*4 IER
+      DOUBLE PRECISION T, YLOC(*), GLOC(*), RPAR(*)
+C     
+      CALL FARKIFUN(T, YLOC, GLOC, IPAR, RPAR, IER)
+C
+      RETURN
+      END
+C
+C     ------------------------------------------------------------------------
+C      
+      SUBROUTINE FARKCOMMFN(NLOC, T, YLOC, IPAR, RPAR, IER)
+C     Routine to perform communication required for evaluation of g.
+      INTEGER*8 NLOC, IPAR(*)
+      INTEGER*4 IER
+      DOUBLE PRECISION T, YLOC(*), RPAR(*)
+      IER = 0
+      RETURN
+      END
diff --git a/examples/arkode/F77_parallel/fark_diag_kry_bbd_p.out b/examples/arkode/F77_parallel/fark_diag_kry_bbd_p.out
new file mode 100644
index 0000000..6b777a1
--- /dev/null
+++ b/examples/arkode/F77_parallel/fark_diag_kry_bbd_p.out
@@ -0,0 +1,87 @@
+Diagonal test problem:
+
+ NEQ =  40
+ NLOCAL =  10
+ parameter alpha =   10.000
+ ydot_i = -alpha*i * y_i (i = 1,...,NEQ)
+ RTOL, ATOL =    0.1E-04   0.1E-09
+ Method is DIRK/NEWTON/SPGMR
+ Precond is band-block-diagonal, using ARKBBDPRE
+ Number of processors =   4
+
+
+Preconditioning on left
+
+ t =   0.10E+00     no. steps =   173   no. attempts =   173   no. fe-s =     0   no. fi-s =  1847
+ t =   0.20E+00     no. steps =   221   no. attempts =   221   no. fe-s =     0   no. fi-s =  2363
+ t =   0.30E+00     no. steps =   248   no. attempts =   248   no. fe-s =     0   no. fi-s =  2651
+ t =   0.40E+00     no. steps =   266   no. attempts =   266   no. fe-s =     0   no. fi-s =  2849
+ t =   0.50E+00     no. steps =   281   no. attempts =   281   no. fe-s =     0   no. fi-s =  3008
+ t =   0.60E+00     no. steps =   291   no. attempts =   291   no. fe-s =     0   no. fi-s =  3117
+ t =   0.70E+00     no. steps =   300   no. attempts =   300   no. fe-s =     0   no. fi-s =  3216
+ t =   0.80E+00     no. steps =   306   no. attempts =   306   no. fe-s =     0   no. fi-s =  3276
+ t =   0.90E+00     no. steps =   312   no. attempts =   312   no. fe-s =     0   no. fi-s =  3336
+ t =   0.10E+01     no. steps =   319   no. attempts =   319   no. fe-s =     0   no. fi-s =  3411
+
+Max. absolute error is  0.76E-10
+
+
+Final statistics:
+
+ number of steps        =   319
+ number of steps att.   =   319
+ number of fe evals.    =     0
+ number of fi evals.    =  3411
+ number of prec. setups =    25
+ number of prec. evals. =     6
+ number of prec. solves =  3380
+ number of nonl. iters. =  1812
+ number of lin. iters.  =  1785
+ average Krylov subspace dimension (NLI/NNI) =   0.9851
+ number of conv. failures.. nonlinear =   0  linear =   0
+ number of error test failures =   0
+ main solver real/int workspace sizes   =   658  160
+ linear solver real/int workspace sizes =   446   80
+In ARKBBDPRE:
+ real/int local workspace =    20   10
+ number of g evals. =    12
+
+
+------------------------------------------------------------
+
+
+Preconditioning on right
+
+ t =   0.10E+00     no. steps =   173   no. attempts =   173   no. fe-s =     0   no. fi-s =  1847
+ t =   0.20E+00     no. steps =   221   no. attempts =   221   no. fe-s =     0   no. fi-s =  2363
+ t =   0.30E+00     no. steps =   248   no. attempts =   248   no. fe-s =     0   no. fi-s =  2651
+ t =   0.40E+00     no. steps =   266   no. attempts =   266   no. fe-s =     0   no. fi-s =  2849
+ t =   0.50E+00     no. steps =   281   no. attempts =   281   no. fe-s =     0   no. fi-s =  3008
+ t =   0.60E+00     no. steps =   291   no. attempts =   291   no. fe-s =     0   no. fi-s =  3117
+ t =   0.70E+00     no. steps =   300   no. attempts =   300   no. fe-s =     0   no. fi-s =  3216
+ t =   0.80E+00     no. steps =   306   no. attempts =   306   no. fe-s =     0   no. fi-s =  3276
+ t =   0.90E+00     no. steps =   312   no. attempts =   312   no. fe-s =     0   no. fi-s =  3336
+ t =   0.10E+01     no. steps =   319   no. attempts =   319   no. fe-s =     0   no. fi-s =  3411
+
+Max. absolute error is  0.76E-10
+
+
+Final statistics:
+
+ number of steps        =   319
+ number of steps att.   =   319
+ number of fe evals.    =     0
+ number of fi evals.    =  3411
+ number of prec. setups =    25
+ number of prec. evals. =     6
+ number of prec. solves =  3380
+ number of nonl. iters. =  1812
+ number of lin. iters.  =  1785
+ average Krylov subspace dimension (NLI/NNI) =   0.9851
+ number of conv. failures.. nonlinear =   0  linear =   0
+ number of error test failures =   0
+ main solver real/int workspace sizes   =   658  160
+ linear solver real/int workspace sizes =   446   80
+In ARKBBDPRE:
+ real/int local workspace =    20   10
+ number of g evals. =    12
diff --git a/examples/arkode/F77_parallel/fark_diag_non_p.f b/examples/arkode/F77_parallel/fark_diag_non_p.f
new file mode 100644
index 0000000..ee37235
--- /dev/null
+++ b/examples/arkode/F77_parallel/fark_diag_non_p.f
@@ -0,0 +1,238 @@
+C     ----------------------------------------------------------------
+C     Programmer(s): Daniel R. Reynolds @ SMU
+C     ----------------------------------------------------------------
+C     LLNS/SMU Copyright Start
+C     Copyright (c) 2015, Southern Methodist University and 
+C     Lawrence Livermore National Security
+C
+C     This work was performed under the auspices of the U.S. Department 
+C     of Energy by Southern Methodist University and Lawrence Livermore 
+C     National Laboratory under Contract DE-AC52-07NA27344.
+C     Produced at Southern Methodist University and the Lawrence 
+C     Livermore National Laboratory.
+C
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     LLNS/SMU Copyright End
+C     Copyright (c) 2013, Southern Methodist University.
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     ----------------------------------------------------------------
+C     Diagonal ODE example. Nonstiff case: alpha = 10/NEQ.
+C     ----------------------------------------------------------------
+C
+C     Include MPI-Fortran header file for MPI_COMM_WORLD, MPI types.
+C
+      IMPLICIT NONE
+C
+      INCLUDE "mpif.h"
+      INTEGER*8 NLOCAL
+      PARAMETER (NLOCAL=2)
+C
+      INTEGER*4 IER, MYPE, NPES, NOUT, LNST, LNST_ATT, LNFE, LNFI, LNNI
+      INTEGER*4 LNCF, LNETF, METH, IATOL, ITASK, JOUT
+      INTEGER*8 NEQ, I, NST, NST_ATT, NFE, NFI, NNI, NCFN, NETF
+      INTEGER*8 IOUT(22), IPAR(2)
+      DOUBLE PRECISION Y(128), ROUT(6), RPAR(1)
+      DOUBLE PRECISION ATOL, RTOL, DTOUT, T, ALPHA, TOUT
+      DOUBLE PRECISION ERMAX, ERRI, GERMAX
+C
+      DATA ATOL/1.0D-10/, RTOL/1.0D-5/, DTOUT/0.1D0/, NOUT/10/
+      DATA LNST/3/, LNST_ATT/6/, LNFE/7/, LNFI/8/, LNNI/11/, LNCF/12/, 
+     1     LNETF/10/
+C
+C     Get NPES and MYPE.  Requires initialization of MPI.
+      CALL MPI_INIT(IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,5) IER
+ 5      FORMAT(///' MPI_ERROR: MPI_INIT returned IER = ', I5)
+        STOP
+        ENDIF
+      CALL MPI_COMM_SIZE(MPI_COMM_WORLD, NPES, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,6) IER
+ 6      FORMAT(///' MPI_ERROR: MPI_COMM_SIZE returned IER = ', I5)
+        CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+        STOP
+        ENDIF
+      CALL MPI_COMM_RANK(MPI_COMM_WORLD, MYPE, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,7) IER
+ 7      FORMAT(///' MPI_ERROR: MPI_COMM_RANK returned IER = ', I5)
+        CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+        STOP
+        ENDIF
+C
+C     Set input arguments.
+      NEQ = NPES * NLOCAL
+      T = 0.0D0
+      METH = 1
+      IATOL = 1
+      ITASK = 1
+c     Set parameter ALPHA
+      ALPHA  = 10.0D0 / NEQ
+C
+C     Load IPAR and RPAR
+      IPAR(1) = NLOCAL
+      IPAR(2) = MYPE
+      RPAR(1) = ALPHA
+C
+      DO 10 I = 1, NLOCAL
+  10    Y(I) = 1.0D0
+C
+      IF (MYPE .EQ. 0) THEN
+        WRITE(6,11) NEQ, NLOCAL, ALPHA
+  11    FORMAT('Diagonal test problem:'//' NEQ = ', I3, /
+     1       ' NLOCAL = ', I3, /
+     2       ' parameter alpha = ', F8.3)
+        WRITE(6,12)
+  12    FORMAT(' ydot_i = -alpha*i * y_i (i = 1,...,NEQ)')
+        WRITE(6,13) RTOL, ATOL
+  13    FORMAT(' RTOL, ATOL = ', 2E10.1)
+        WRITE(6,14)
+  14    FORMAT(' Method is ERK')
+        WRITE(6,15) NPES
+  15    FORMAT(' Number of processors = ', I3//)
+        ENDIF
+C
+      CALL FNVINITP(MPI_COMM_WORLD, 4, NLOCAL, NEQ, IER)
+C
+      IF (IER .NE. 0) THEN
+        WRITE(6,20) IER
+  20    FORMAT(///' SUNDIALS_ERROR: FNVINITP returned IER = ', I5)
+        CALL MPI_FINALIZE(IER)
+        STOP
+        ENDIF
+C
+      CALL FARKMALLOC(T, Y, METH, IATOL, RTOL, ATOL,
+     1               IOUT, ROUT, IPAR, RPAR, IER)
+C
+      IF (IER .NE. 0) THEN
+        WRITE(6,30) IER
+  30    FORMAT(///' SUNDIALS_ERROR: FARKMALLOC returned IER = ', I5)
+        CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+        STOP
+        ENDIF
+C
+C     Loop through tout values, call solver, print output, test for failure.
+      TOUT = DTOUT
+      DO 70 JOUT = 1, NOUT
+C
+        CALL FARKODE(TOUT, T, Y, ITASK, IER)
+C
+        IF (MYPE .EQ. 0) WRITE(6,40) T, IOUT(LNST), IOUT(LNST_ATT), 
+     &       IOUT(LNFE), IOUT(LNFI)
+  40    FORMAT(' t = ', D10.2, 5X, 'steps = ', I5, 
+     &         '  (attempted = ', I5, '),  fe = ', I5, 
+     &         '  fi = ', I5)
+C
+        IF (IER .NE. 0) THEN
+          WRITE(6,60) IER, IOUT(16)
+  60      FORMAT(///' SUNDIALS_ERROR: FARKODE returned IER = ', I5, /,
+     &           '                 Linear Solver returned IER = ', I5)
+          CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+          STOP
+          ENDIF
+C
+        TOUT = TOUT + DTOUT
+  70    CONTINUE
+C
+C     Get max. absolute error in the local vector.
+      ERMAX = 0.0D0
+      DO 75 I = 1, NLOCAL
+        ERRI  = Y(I) - EXP(-ALPHA * (MYPE * NLOCAL + I) * T)
+        ERMAX = MAX(ERMAX, ABS(ERRI))
+  75    CONTINUE
+C     Get global max. error from MPI_REDUCE call.
+      CALL MPI_REDUCE(ERMAX, GERMAX, 1, MPI_DOUBLE_PRECISION, MPI_MAX,
+     1                0, MPI_COMM_WORLD, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,80) IER
+  80    FORMAT(///' MPI_ERROR: MPI_REDUCE returned IER = ', I5)
+        CALL MPI_ABORT(MPI_COMM_WORLD, 1, IER)
+        STOP
+        ENDIF
+      IF (MYPE .EQ. 0) WRITE(6,85) GERMAX
+  85  FORMAT(/'Max. absolute error is ', E10.2/)
+C
+C     Print final statistics.
+      NST = IOUT(LNST)
+      NST_ATT = IOUT(LNST_ATT)
+      NFE = IOUT(LNFE)
+      NFI = IOUT(LNFI)
+      NNI = IOUT(LNNI)
+      NCFN = IOUT(LNCF)
+      NETF = IOUT(LNETF)
+      IF (MYPE .EQ. 0) WRITE (6,90) NST, NST_ATT, NFE, NFI, NNI, NCFN, 
+     &     NETF
+  90  FORMAT(/'Final statistics:'//
+     &       ' number of steps = ', I5/
+     &       ' number of step attempts = ', I5/
+     &       ' number of fe evals. = ', I5/
+     &       ' number of fi evals. = ', I5/
+     &       ' number of nonlinear iters. = ', I5/
+     &       ' number of nonlinear conv. failures = ', I3/
+     &       ' number of error test failures = ', I3)
+C
+C     Free the memory and finalize MPI.
+      CALL FARKFREE
+      CALL MPI_FINALIZE(IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,95) IER
+ 95     FORMAT(///' MPI_ERROR: MPI_FINALIZE returned IER = ', I5)
+        STOP
+        ENDIF
+C
+      STOP
+      END
+C
+C     ------------------------------------------------------------------------
+C
+      SUBROUTINE FARKIFUN(T, Y, YDOT, IPAR, RPAR, IER)
+C     Routine for right-hand side function fi
+C
+      IMPLICIT NONE
+C
+      INTEGER*4 IER
+      INTEGER*8 IPAR(*)
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
+C
+      INTEGER*8 NLOCAL, I
+C
+      NLOCAL = IPAR(1)
+C
+      DO I = 1, NLOCAL
+         YDOT(I) = 0.D0
+      ENDDO
+C
+      IER = 0
+C
+      RETURN
+      END
+C     ------------------------------------------------------------------------
+C
+      SUBROUTINE FARKEFUN(T, Y, YDOT, IPAR, RPAR, IER)
+C     Routine for right-hand side function fe
+C
+      IMPLICIT NONE
+C
+      INTEGER*4 IER
+      INTEGER*8 IPAR(*)
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
+C
+      INTEGER*8 MYPE
+      INTEGER*8 NLOCAL, I
+      DOUBLE PRECISION ALPHA
+C
+      NLOCAL = IPAR(1)
+      MYPE = IPAR(2)
+      ALPHA = RPAR(1)
+C
+      DO I = 1, NLOCAL
+         YDOT(I) = -ALPHA * (MYPE * NLOCAL + I) * Y(I)
+      ENDDO
+C
+      IER = 0
+C
+      RETURN
+      END
diff --git a/examples/arkode/F77_parallel/fark_diag_non_p.out b/examples/arkode/F77_parallel/fark_diag_non_p.out
new file mode 100644
index 0000000..0ccf375
--- /dev/null
+++ b/examples/arkode/F77_parallel/fark_diag_non_p.out
@@ -0,0 +1,34 @@
+Diagonal test problem:
+
+ NEQ =   8
+ NLOCAL =   2
+ parameter alpha =    1.250
+ ydot_i = -alpha*i * y_i (i = 1,...,NEQ)
+ RTOL, ATOL =    0.1E-04   0.1E-09
+ Method is ERK
+ Number of processors =   4
+
+
+ t =   0.10D+00     steps =    12  (attempted =    12),  fe =    76  fi =     0
+ t =   0.20D+00     steps =    21  (attempted =    21),  fe =   130  fi =     0
+ t =   0.30D+00     steps =    31  (attempted =    31),  fe =   190  fi =     0
+ t =   0.40D+00     steps =    40  (attempted =    40),  fe =   244  fi =     0
+ t =   0.50D+00     steps =    50  (attempted =    50),  fe =   304  fi =     0
+ t =   0.60D+00     steps =    59  (attempted =    59),  fe =   358  fi =     0
+ t =   0.70D+00     steps =    69  (attempted =    69),  fe =   418  fi =     0
+ t =   0.80D+00     steps =    78  (attempted =    78),  fe =   472  fi =     0
+ t =   0.90D+00     steps =    88  (attempted =    88),  fe =   532  fi =     0
+ t =   0.10D+01     steps =    97  (attempted =    97),  fe =   586  fi =     0
+
+Max. absolute error is   0.54E-05
+
+
+Final statistics:
+
+ number of steps =    97
+ number of step attempts =    97
+ number of fe evals. =   586
+ number of fi evals. =     0
+ number of nonlinear iters. =     0
+ number of nonlinear conv. failures =   0
+ number of error test failures =   0
diff --git a/examples/arkode/F77_serial/CMakeLists.txt b/examples/arkode/F77_serial/CMakeLists.txt
new file mode 100644
index 0000000..7a9c40e
--- /dev/null
+++ b/examples/arkode/F77_serial/CMakeLists.txt
@@ -0,0 +1,157 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for the FARKODE F77 serial examples
+
+
+# Add variable FARKODE_examples with the names of the serial FARKODE examples
+
+SET(FARKODE_examples
+  fark_diurnal_kry_bp
+  )
+
+# Add variable FARKODE_bl_examples with the names of the serial FARKODE examples
+# that use Lapack
+
+SET(FARKODE_examples_BL
+  fark_roberts_dnsL
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+
+SET(ARKODE_extras
+  )
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECS_LIB sundials_nvecserial_static)
+  SET(FNVECS_LIB sundials_fnvecserial_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECS_LIB sundials_nvecserial_shared)
+  SET(FNVECS_LIB sundials_fnvecserial_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Only static FCMIX libraries are available
+
+SET(FARKODE_LIB sundials_farkode_static)
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${FARKODE_LIB} ${ARKODE_LIB} ${FNVECS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each FARKODE example
+
+FOREACH(example ${FARKODE_examples})
+  ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_serial)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${FARKODE_examples})
+
+# Add the build and install targets for each Lapack FARKODE example (if needed)
+
+IF(LAPACK_FOUND)
+  FOREACH(example ${FARKODE_examples_BL})
+    ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${FARKODE_examples_BL})
+ENDIF(LAPACK_FOUND)
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_serial)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_serial)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  SET(SOLVER_FLIB "sundials_farkode")
+  LIST2STRING(FARKODE_examples EXAMPLES)
+  IF(LAPACK_FOUND)
+    LIST2STRING(FARKODE_examples_BL EXAMPLES_BL)
+  ELSE(LAPACK_FOUND)
+    SET(EXAMPLES_BL "")
+  ENDIF(LAPACK_FOUND)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F77_serial/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/F77_serial/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_serial 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F77_serial/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/F77_serial/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F77_serial 
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/F77_serial/README b/examples/arkode/F77_serial/README
new file mode 100644
index 0000000..c728e89
--- /dev/null
+++ b/examples/arkode/F77_serial/README
@@ -0,0 +1,50 @@
+List of serial ARKODE F77 examples
+
+  fark_diurnal_kry_bp : kinetics-transport example (DIRK/SPGMR/FARKBP)
+  fark_roberts_dnsL   : chemical kinetics example (DIRK/DENSE lapack)
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/F77_serial/fark_diurnal_kry_bp.f b/examples/arkode/F77_serial/fark_diurnal_kry_bp.f
new file mode 100644
index 0000000..62dda2c
--- /dev/null
+++ b/examples/arkode/F77_serial/fark_diurnal_kry_bp.f
@@ -0,0 +1,403 @@
+C     ----------------------------------------------------------------
+C     Programmer(s): Daniel R. Reynolds @ SMU
+C     ----------------------------------------------------------------
+C     LLNS/SMU Copyright Start
+C     Copyright (c) 2015, Southern Methodist University and 
+C     Lawrence Livermore National Security
+C
+C     This work was performed under the auspices of the U.S. Department 
+C     of Energy by Southern Methodist University and Lawrence Livermore 
+C     National Laboratory under Contract DE-AC52-07NA27344.
+C     Produced at Southern Methodist University and the Lawrence 
+C     Livermore National Laboratory.
+C
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     LLNS/SMU Copyright End
+C     Copyright (c) 2013, Southern Methodist University.
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     ----------------------------------------------------------------
+C     FARKODE Example Problem: 2D kinetics-transport, 
+C     precond. Krylov solver. 
+C     
+C     An ODE system is generated from the following 2-species diurnal
+C     kinetics advection-diffusion PDE system in 2 space dimensions:
+C     
+C     dc(i)/dt = Kh*(d/dx)**2 c(i) + V*dc(i)/dx + (d/dy)(Kv(y)*dc(i)/dy)
+C                           + Ri(c1,c2,t)      for i = 1,2,   where
+C     R1(c1,c2,t) = -q1*c1*c3 - q2*c1*c2 + 2*q3(t)*c3 + q4(t)*c2 ,
+C     R2(c1,c2,t) =  q1*c1*c3 - q2*c1*c2 - q4(t)*c2 ,
+C     Kv(y) = Kv0*exp(y/5) ,
+C     Kh, V, Kv0, q1, q2, and c3 are constants, and q3(t) and q4(t)
+C     vary diurnally.
+C
+C     The problem is posed on the square
+C     0 .le. x .le. 20,    30 .le. y .le. 50   (all in km),
+C     with homogeneous Neumann boundary conditions, and for time t in
+C     0 .le. t .le. 86400 sec (1 day).
+C
+C     The PDE system is treated by central differences on a uniform
+C     10 x 10 mesh, with simple polynomial initial profiles.
+C     The problem is solved with ARKODE, with the DIRK/GMRES method and
+C     using the FARKBP banded preconditioner
+C     
+C     The second and third dimensions of U here must match the values of
+C     MX and MY, for consistency with the output statements below.
+C     ----------------------------------------------------------------
+C
+      IMPLICIT NONE
+      INTEGER*4 MX, MY
+      PARAMETER (MX=10, MY=10)
+      INTEGER*8 NEQ
+      PARAMETER (NEQ=2*MX*MY)
+C
+      INTEGER*4 LNST, LNST_ATT, LNFE, LNFI, LNSETUP, LNNI, LNCF, LNPE
+      INTEGER*4 LNLI, LNPS, LNCFL, LH, LNETF, LLENRW, LLENIW, LLENRWLS
+      INTEGER*4 LLENIWLS, METH, IATOL, ITASK, IER, MAXL, JPRETYPE
+      INTEGER*4 IGSTYPE, JOUT
+      INTEGER*8 IOUT(22), IPAR(4), NST, NST_ATT, NFE, NFI, NPSET, NPE
+      INTEGER*8 NPS, NNI, NLI, NCFN, NCFL, NETF, MU, ML, LENRW, LENIW
+      INTEGER*8 LENRWLS, LENIWLS, LENRWBP, LENIWBP, NFEBP, MXSTEPS
+      DOUBLE PRECISION ATOL, AVDIM, DELT, FLOOR, RTOL, T, TOUT, TWOHR
+      DOUBLE PRECISION ROUT(6), U(2,MX,MY), RPAR(12)
+C
+      DATA TWOHR/7200.0D0/, RTOL/1.0D-5/, FLOOR/100.0D0/,
+     1     JPRETYPE/1/, IGSTYPE/1/, MAXL/0/, DELT/0.0D0/, MXSTEPS/10000/
+      DATA LLENRW/1/, LLENIW/2/, LNST/3/, LNST_ATT/6/, LNFE/7/, LNFI/8/, 
+     1     LNETF/10/, LNCF/12/, LNNI/11/, LNSETUP/9/, LLENRWLS/14/, 
+     1     LLENIWLS/15/, LNPE/19/, LNLI/21/, LNPS/20/, LNCFL/22/
+      DATA LH/2/
+C
+C Load IPAR, RPAR, and initial values
+      CALL INITKX(MX, MY, U, IPAR, RPAR)
+C
+C     Set other input arguments.
+      T = 0.0D0
+      METH = 0
+      IATOL = 1
+      ATOL = RTOL * FLOOR
+      ITASK = 1
+C
+      WRITE(6,10) NEQ
+ 10   FORMAT('Krylov example problem:'//
+     1       ' Kinetics-transport, NEQ = ', I4/)
+C     
+C     Initialize vector specification
+      CALL FNVINITS(4, NEQ, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,20) IER
+ 20      FORMAT(///' SUNDIALS_ERROR: FNVINITS returned IER = ', I5)
+         STOP
+      ENDIF
+C     
+C     Initialize ARKODE
+      CALL FARKMALLOC(T, U, METH, IATOL, RTOL, ATOL,
+     1               IOUT, ROUT, IPAR, RPAR, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,30) IER
+ 30      FORMAT(///' SUNDIALS_ERROR: FARKMALLOC returned IER = ', I5)
+         STOP
+      ENDIF
+C
+      CALL FARKSETIIN('MAX_NSTEPS', MXSTEPS, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,35) IER
+ 35     FORMAT(///' SUNDIALS_ERROR: FARKSETIIN returned IER = ', I5)
+        STOP
+      ENDIF
+C     
+C     Initialize SPGMR solver
+      CALL FARKSPGMR(JPRETYPE, IGSTYPE, MAXL, DELT, IER) 
+      IF (IER .NE. 0) THEN
+         WRITE(6,45) IER
+ 45      FORMAT(///' SUNDIALS_ERROR: FARKSPGMR returned IER = ', I5)
+         CALL FARKFREE
+         STOP
+      ENDIF
+C     
+C     Initialize band preconditioner
+      MU = 2
+      ML = 2
+      CALL FARKBPINIT(NEQ, MU, ML, IER) 
+      IF (IER .NE. 0) THEN
+         WRITE(6,40) IER
+ 40      FORMAT(///' SUNDIALS_ERROR: FARKBPINIT returned IER = ', I5)
+         CALL FARKFREE
+         STOP
+      ENDIF
+C     
+C     Loop over output points, call FARKODE, print sample solution values.
+      TOUT = TWOHR
+      DO 70 JOUT = 1, 12
+C
+         CALL FARKODE(TOUT, T, U, ITASK, IER)
+C     
+         WRITE(6,50) T, IOUT(LNST), IOUT(LNST_ATT), ROUT(LH)
+ 50      FORMAT(/' t = ', E14.6, 5X, 'no. steps = ', I5, 
+     1        '  no. att. steps = ', I5, '   stepsize = ', E14.6)
+         WRITE(6,55) U(1,1,1), U(1,5,5), U(1,10,10),
+     1               U(2,1,1), U(2,5,5), U(2,10,10)
+ 55      FORMAT('  c1 (bot.left/middle/top rt.) = ', 3E14.6/
+     1        '  c2 (bot.left/middle/top rt.) = ', 3E14.6)
+C     
+         IF (IER .NE. 0) THEN
+            WRITE(6,60) IER, IOUT(16)
+ 60         FORMAT(///' SUNDIALS_ERROR: FARKODE returned IER = ', I5, /,
+     1             '                 Linear Solver returned IER = ', I5)
+            CALL FARKFREE
+            STOP
+         ENDIF
+C     
+         TOUT = TOUT + TWOHR
+ 70   CONTINUE
+      
+C     Print final statistics.
+      NST = IOUT(LNST)
+      NST_ATT = IOUT(LNST_ATT)
+      NFE = IOUT(LNFE)
+      NFI = IOUT(LNFI)
+      NPSET = IOUT(LNSETUP)
+      NPE = IOUT(LNPE)
+      NPS = IOUT(LNPS)
+      NNI = IOUT(LNNI)
+      NLI = IOUT(LNLI)
+      AVDIM = DBLE(NLI) / DBLE(NNI)
+      NCFN = IOUT(LNCF)
+      NCFL = IOUT(LNCFL)
+      NETF = IOUT(LNETF)
+      LENRW = IOUT(LLENRW)
+      LENIW = IOUT(LLENIW)
+      LENRWLS = IOUT(LLENRWLS)
+      LENIWLS = IOUT(LLENIWLS)
+      WRITE(6,80) NST, NST_ATT, NFE, NFI, NPSET, NPE, NPS, NNI, NLI, 
+     1     AVDIM, NCFN, NCFL, NETF, LENRW, LENIW, LENRWLS, LENIWLS
+ 80   FORMAT(//'Final statistics:'//
+     &   ' number of steps        = ', I6/
+     &   ' number of step att.    = ', I6/
+     &   ' number of fe evals.    = ', I6/
+     &   ' number of fi evals.    = ', I6/
+     &   ' number of prec. setups = ', I6/
+     &   ' number of prec. evals. = ', I6/
+     &   ' number of prec. solves = ', I6/
+     &   ' number of nonl. iters. = ', I6/
+     &   ' number of lin. iters.  = ', I6/
+     &   ' average Krylov subspace dimension (NLI/NNI) = ', E14.6/
+     &   ' number of conv. failures.. nonlinear =', I3,
+     &   ' linear = ', I3/
+     &   ' number of error test failures = ', I3/
+     &   ' main solver real/int workspace sizes   = ',2I5/
+     &   ' linear solver real/int workspace sizes = ',2I5)
+      CALL FARKBPOPT(LENRWBP, LENIWBP, NFEBP)
+      WRITE(6,82) LENRWBP, LENIWBP, NFEBP
+ 82   FORMAT('In ARKBANDPRE:'/
+     &        ' real/int workspace sizes = ', 2I5/
+     &        ' number of f evaluations  = ', I5)
+C     
+      CALL FARKFREE
+C     
+      STOP
+      END
+
+C     ----------------------------------------------------------------
+
+      SUBROUTINE INITKX(MX, MY, U0, IPAR, RPAR)
+C Routine to set problem constants and initial values
+C
+      IMPLICIT NONE
+C
+      INTEGER*4 MX, MY
+      INTEGER*8 IPAR(*), NEQ
+      DOUBLE PRECISION RPAR(*)
+C
+      INTEGER*8 MM, JY, JX
+      DOUBLE PRECISION U0
+      DIMENSION U0(2,MX,MY)
+      DOUBLE PRECISION Q1, Q2, Q3, Q4, A3, A4, OM, C3, DY, HDCO
+      DOUBLE PRECISION VDCO, HACO, X, Y
+      DOUBLE PRECISION CX, CY, DKH, DKV0, DX, HALFDA, PI, VEL
+C
+      DATA DKH/4.0D-6/, VEL/0.001D0/, DKV0/1.0D-8/, HALFDA/4.32D4/,
+     1     PI/3.1415926535898D0/
+C
+C Problem constants
+      MM = MX * MY
+      NEQ = 2 * MM
+      Q1 = 1.63D-16
+      Q2 = 4.66D-16
+      Q3 = 0.D0
+      Q4 = 0.D0
+      A3 = 22.62D0
+      A4 = 7.601D0
+      OM = PI / HALFDA
+      C3 = 3.7D16
+      DX = 20.0D0 / (MX - 1.0D0)
+      DY = 20.0D0 / (MY - 1.0D0)
+      HDCO = DKH / DX**2
+      HACO = VEL / (2.0D0 * DX)
+      VDCO = (1.0D0 / DY**2) * DKV0
+C Load constants in IPAR and RPAR
+      IPAR(1) = MX
+      IPAR(2) = MY
+      IPAR(3) = MM
+      IPAR(4) = NEQ
+C
+      RPAR(1)  = Q1
+      RPAR(2)  = Q2
+      RPAR(3)  = Q3
+      RPAR(4)  = Q4
+      RPAR(5)  = A3
+      RPAR(6)  = A4
+      RPAR(7)  = OM
+      RPAR(8)  = C3
+      RPAR(9)  = DY
+      RPAR(10) = HDCO
+      RPAR(11) = VDCO
+      RPAR(12) = HACO
+C
+C Set initial profiles.
+      DO 20 JY = 1, MY
+        Y = 30.0D0 + (JY - 1.0D0) * DY
+        CY = (0.1D0 * (Y - 40.0D0))**2
+        CY = 1.0D0 - CY + 0.5D0 * CY**2
+        DO 10 JX = 1, MX
+          X = (JX - 1.0D0) * DX
+          CX = (0.1D0 * (X - 10.0D0))**2
+          CX = 1.0D0 - CX + 0.5D0 * CX**2
+          U0(1,JX,JY) = 1.0D6 * CX * CY
+          U0(2,JX,JY) = 1.0D12 * CX * CY
+ 10       CONTINUE
+ 20     CONTINUE
+C
+      RETURN
+      END
+      
+C     ----------------------------------------------------------------
+
+      SUBROUTINE FARKIFUN(T, U, UDOT, IPAR, RPAR, IER)
+C     Routine for right-hand side function fi
+      IMPLICIT NONE
+C
+      INTEGER*4 IER
+      INTEGER*8 IPAR(*)
+      DOUBLE PRECISION T, U(2,*), UDOT(2,*), RPAR(*)
+C
+      INTEGER*4 ILEFT, IRIGHT
+      INTEGER*8 MX, MY, MM, JY, JX, IBLOK0, IDN, IUP, IBLOK
+      DOUBLE PRECISION Q1,Q2,Q3,Q4, A3, A4, OM, C3, DY, HDCO, VDCO, HACO
+      DOUBLE PRECISION C1, C2, C1DN, C2DN, C1UP, C2UP, C1LT, C2LT
+      DOUBLE PRECISION C1RT, C2RT, CYDN, CYUP, HORD1, HORD2, HORAD1
+      DOUBLE PRECISION HORAD2, QQ1, QQ2, QQ3, QQ4, RKIN1, RKIN2, S
+      DOUBLE PRECISION VERTD1, VERTD2, YDN, YUP
+C
+C     Extract constants from IPAR and RPAR
+      MX = IPAR(1)
+      MY = IPAR(2)
+      MM = IPAR(3)
+C
+      Q1 = RPAR(1)
+      Q2 = RPAR(2)
+      Q3 = RPAR(3)
+      Q4 = RPAR(4)
+      A3 = RPAR(5)
+      A4 = RPAR(6)
+      OM = RPAR(7)
+      C3 = RPAR(8)
+      DY = RPAR(9)
+      HDCO = RPAR(10)
+      VDCO = RPAR(11)
+      HACO = RPAR(12)
+C     
+C     Set diurnal rate coefficients.
+      S = SIN(OM * T)
+      IF (S .GT. 0.0D0) THEN
+         Q3 = EXP(-A3 / S)
+         Q4 = EXP(-A4 / S)
+      ELSE
+         Q3 = 0.0D0
+         Q4 = 0.0D0
+      ENDIF
+C     
+C     Loop over all grid points.
+      DO 20 JY = 1, MY
+         YDN = 30.0D0 + (JY - 1.5D0) * DY
+         YUP = YDN + DY
+         CYDN = VDCO * EXP(0.2D0 * YDN)
+         CYUP = VDCO * EXP(0.2D0 * YUP)
+         IBLOK0 = (JY - 1) * MX
+         IDN = -MX
+         IF (JY .EQ. 1) IDN = MX
+         IUP = MX
+         IF (JY .EQ. MY) IUP = -MX
+         DO 10 JX = 1, MX
+            IBLOK = IBLOK0 + JX
+            C1 = U(1,IBLOK)
+            C2 = U(2,IBLOK)
+C     Set kinetic rate terms.
+            QQ1 = Q1 * C1 * C3
+            QQ2 = Q2 * C1 * C2
+            QQ3 = Q3 * C3
+            QQ4 = Q4 * C2
+            RKIN1 = -QQ1 - QQ2 + 2.0D0 * QQ3 + QQ4
+            RKIN2 = QQ1 - QQ2 - QQ4
+C     Set vertical diffusion terms.
+            C1DN = U(1,IBLOK + IDN)
+            C2DN = U(2,IBLOK + IDN)
+            C1UP = U(1,IBLOK + IUP)
+            C2UP = U(2,IBLOK + IUP)
+            VERTD1 = CYUP * (C1UP - C1) - CYDN * (C1 - C1DN)
+            VERTD2 = CYUP * (C2UP - C2) - CYDN * (C2 - C2DN)
+C     Set horizontal diffusion and advection terms.
+            ILEFT = -1
+            IF (JX .EQ. 1) ILEFT = 1
+            IRIGHT = 1
+            IF (JX .EQ. MX) IRIGHT = -1
+            C1LT = U(1,IBLOK + ILEFT)
+            C2LT = U(2,IBLOK + ILEFT)
+            C1RT = U(1,IBLOK + IRIGHT)
+            C2RT = U(2,IBLOK + IRIGHT)
+            HORD1 = HDCO * (C1RT - 2.0D0 * C1 + C1LT)
+            HORD2 = HDCO * (C2RT - 2.0D0 * C2 + C2LT)
+            HORAD1 = HACO * (C1RT - C1LT)
+            HORAD2 = HACO * (C2RT - C2LT)
+C     Load all terms into UDOT.
+            UDOT(1,IBLOK) = VERTD1 + HORD1 + HORAD1 + RKIN1
+            UDOT(2,IBLOK) = VERTD2 + HORD2 + HORAD2 + RKIN2
+ 10      CONTINUE
+ 20   CONTINUE
+C
+      IER = 0
+C
+      RETURN
+      END
+      
+C     ----------------------------------------------------------------
+
+      SUBROUTINE FARKEFUN(T, U, UDOT, IPAR, RPAR, IER)
+C     Routine for right-hand side function fe
+      IMPLICIT NONE
+C
+      INTEGER*4 IER
+      INTEGER*8 IPAR(*)
+      DOUBLE PRECISION T, U(2,*), UDOT(2,*), RPAR(*)
+C
+      INTEGER*8 MX, MY, JY, JX, IBLOK0, IBLOK
+C
+C     Extract constants from IPAR
+      MX = IPAR(1)
+      MY = IPAR(2)
+C     
+C     Loop over all grid points, setting UDOT to zero
+      DO 20 JY = 1, MY
+         IBLOK0 = (JY - 1) * MX
+         DO 10 JX = 1, MX
+            IBLOK = IBLOK0 + JX
+            UDOT(1,IBLOK) = 0.D0
+            UDOT(2,IBLOK) = 0.D0
+ 10      CONTINUE
+ 20   CONTINUE
+C
+      IER = 0
+C
+      RETURN
+      END
diff --git a/examples/arkode/F77_serial/fark_diurnal_kry_bp.out b/examples/arkode/F77_serial/fark_diurnal_kry_bp.out
new file mode 100644
index 0000000..0d8370b
--- /dev/null
+++ b/examples/arkode/F77_serial/fark_diurnal_kry_bp.out
@@ -0,0 +1,73 @@
+Krylov example problem:
+
+ Kinetics-transport, NEQ =  200
+
+
+ t =   0.720000E+04     no. steps =   987  no. att. steps =   989   stepsize =   0.306506E+01
+  c1 (bot.left/middle/top rt.) =   0.104683E+05  0.296369E+05  0.111853E+05
+  c2 (bot.left/middle/top rt.) =   0.252673E+12  0.715366E+12  0.269977E+12
+
+ t =   0.144000E+05     no. steps =  2737  no. att. steps =  2739   stepsize =   0.689853E+01
+  c1 (bot.left/middle/top rt.) =   0.665902E+07  0.531590E+07  0.730081E+07
+  c2 (bot.left/middle/top rt.) =   0.258191E+12  0.205675E+12  0.283286E+12
+
+ t =   0.216000E+05     no. steps =  3539  no. att. steps =  3541   stepsize =   0.104022E+02
+  c1 (bot.left/middle/top rt.) =   0.266497E+08  0.103652E+08  0.293077E+08
+  c2 (bot.left/middle/top rt.) =   0.299279E+12  0.102829E+12  0.331344E+12
+
+ t =   0.288000E+05     no. steps =  4687  no. att. steps =  4710   stepsize =   0.491311E+01
+  c1 (bot.left/middle/top rt.) =   0.870214E+07  0.129200E+08  0.965006E+07
+  c2 (bot.left/middle/top rt.) =   0.338037E+12  0.502942E+12  0.375097E+12
+
+ t =   0.360000E+05     no. steps =  5918  no. att. steps =  5941   stepsize =   0.254793E+01
+  c1 (bot.left/middle/top rt.) =   0.140404E+05  0.202886E+05  0.156091E+05
+  c2 (bot.left/middle/top rt.) =   0.338679E+12  0.489399E+12  0.376518E+12
+
+ t =   0.432000E+05     no. steps =  7110  no. att. steps =  7133   stepsize =   0.293957E+03
+  c1 (bot.left/middle/top rt.) =   0.502136E-06  0.363249E-04  0.622560E-05
+  c2 (bot.left/middle/top rt.) =   0.338234E+12  0.135516E+12  0.380354E+12
+
+ t =   0.504000E+05     no. steps =  7134  no. att. steps =  7157   stepsize =   0.458474E+03
+  c1 (bot.left/middle/top rt.) =  -0.637359E-06  0.200437E-04 -0.556164E-05
+  c2 (bot.left/middle/top rt.) =   0.335818E+12  0.493035E+12  0.386446E+12
+
+ t =   0.576000E+05     no. steps =  7150  no. att. steps =  7174   stepsize =   0.351495E+03
+  c1 (bot.left/middle/top rt.) =  -0.385214E-08  0.287090E-06 -0.280114E-07
+  c2 (bot.left/middle/top rt.) =   0.332033E+12  0.964976E+12  0.390901E+12
+
+ t =   0.648000E+05     no. steps =  7165  no. att. steps =  7189   stepsize =   0.558311E+03
+  c1 (bot.left/middle/top rt.) =   0.186359E-13  0.263111E-09  0.373337E-12
+  c2 (bot.left/middle/top rt.) =   0.331304E+12  0.892178E+12  0.396344E+12
+
+ t =   0.720000E+05     no. steps =  7178  no. att. steps =  7202   stepsize =   0.558311E+03
+  c1 (bot.left/middle/top rt.) =  -0.420742E-14 -0.420137E-10 -0.127766E-12
+  c2 (bot.left/middle/top rt.) =   0.332974E+12  0.618628E+12  0.403886E+12
+
+ t =   0.792000E+05     no. steps =  7190  no. att. steps =  7214   stepsize =   0.558311E+03
+  c1 (bot.left/middle/top rt.) =   0.246890E-14 -0.103870E-09  0.242802E-12
+  c2 (bot.left/middle/top rt.) =   0.333443E+12  0.666905E+12  0.412027E+12
+
+ t =   0.864000E+05     no. steps =  7203  no. att. steps =  7227   stepsize =   0.558311E+03
+  c1 (bot.left/middle/top rt.) =   0.153924E-13 -0.146365E-10 -0.136898E-13
+  c2 (bot.left/middle/top rt.) =   0.335180E+12  0.910621E+12  0.416253E+12
+
+
+Final statistics:
+
+ number of steps        =   7203
+ number of step att.    =   7227
+ number of fe evals.    =      0
+ number of fi evals.    =  75508
+ number of prec. setups =    426
+ number of prec. evals. =    120
+ number of prec. solves = 109665
+ number of nonl. iters. =  39369
+ number of lin. iters.  =  73165
+ average Krylov subspace dimension (NLI/NNI) =   0.185844E+01
+ number of conv. failures.. nonlinear =  0 linear =   0
+ number of error test failures =  24
+ main solver real/int workspace sizes   =  3058   55
+ linear solver real/int workspace sizes =  2046   10
+In ARKBANDPRE:
+ real/int workspace sizes =  2400  200
+ number of f evaluations  =   600
diff --git a/examples/arkode/F77_serial/fark_roberts_dnsL.f b/examples/arkode/F77_serial/fark_roberts_dnsL.f
new file mode 100644
index 0000000..5397a9f
--- /dev/null
+++ b/examples/arkode/F77_serial/fark_roberts_dnsL.f
@@ -0,0 +1,307 @@
+C     ----------------------------------------------------------------
+C     Programmer(s): Daniel R. Reynolds @ SMU
+C     ----------------------------------------------------------------
+C     LLNS/SMU Copyright Start
+C     Copyright (c) 2015, Southern Methodist University and 
+C     Lawrence Livermore National Security
+C
+C     This work was performed under the auspices of the U.S. Department 
+C     of Energy by Southern Methodist University and Lawrence Livermore 
+C     National Laboratory under Contract DE-AC52-07NA27344.
+C     Produced at Southern Methodist University and the Lawrence 
+C     Livermore National Laboratory.
+C
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     LLNS/SMU Copyright End
+C     Copyright (c) 2013, Southern Methodist University.
+C     All rights reserved.
+C     For details, see the LICENSE file.
+C     ----------------------------------------------------------------
+C     FARKODE Example Problem: Robertson kinetics, Lapack linear solver
+C                             with dense user Jacobian.
+C
+C     The following is a simple example problem, with the coding
+C     needed for its solution by ARKODE. The problem is from chemical
+C     kinetics, and consists of the following three rate equations:
+C
+C     dy1/dt = -.04*y1 + 1.e4*y2*y3
+C     dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+C     dy3/dt = 3.e7*y2**2
+C
+C     on the interval from t = 0.0 to t = 4.e10, with initial
+C     conditions:
+C
+C     y1 = 1.0, y2 = y3 = 0.
+C
+C     The problem is stiff. While integrating the system, we also
+C     employ the root finding feature to find the points at which
+C     y1 = 1.e-4 or at which y3 = 0.01. The following coding solves
+C     this problem with ARKODE, using the Fortran/C interface routine
+C     package. This solution uses the DIRK method and a user-supplied
+C     Jacobian routine, and prints results at t = .4, 4., ..., 4.e10.
+C     It uses ITOL = 2 and ATOL much smaller for y2 than y1 or y3
+C     because y2 has much smaller values. At the end of the run,
+C     various counters of interest are printed.
+C     ----------------------------------------------------------------
+C
+      IMPLICIT NONE
+C
+      INTEGER*4 IER, LNST, LNST_ATT, LNFE, LNFI, LNSETUP, LNNI, LNCF
+      INTEGER*4 LNETF, LNJE, LNGE, METH, ITOL, ITASK, JOUT, NOUT
+      INTEGER*4 IERROOT, INFO(2)
+      INTEGER*8 I, IOUT(22), IPAR, NEQ, MXSTEPS, MXNLI, PRED, MXETF
+      DOUBLE PRECISION RTOL, T, T0, TOUT, H0, NLCONV
+      DOUBLE PRECISION Y(3), ATOL(3), ROUT(6), RPAR
+C
+      DATA LNST/3/, LNST_ATT/6/, LNFE/7/, LNFI/8/, LNETF/10/, LNCF/12/, 
+     1     LNNI/11/, LNSETUP/9/, LNGE/13/, LNJE/18/
+C
+      NEQ = 3
+      MXSTEPS = 10000
+      MXNLI = 8
+      PRED = 1
+      MXETF = 20
+      T0 = 0.0D0
+      Y(1) = 1.0D0
+      Y(2) = 0.0D0
+      Y(3) = 0.0D0
+      METH = 0
+      ITOL = 2
+      RTOL = 1.0D-4
+      ATOL(1) = 1.0D-8
+      ATOL(2) = 1.0D-11
+      ATOL(3) = 1.0D-8
+      H0 = 1.0D-4 * RTOL
+      NLCONV = 1.0D-7
+      TOUT = 0.4D0
+      ITASK = 1
+      JOUT = 0
+      NOUT = 12
+C
+      WRITE(6,10) NEQ
+ 10   FORMAT('Dense example problem:'//
+     1       ' Robertson kinetics, NEQ = ', I2//)
+C
+      CALL FNVINITS(4, NEQ, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,20) IER
+ 20     FORMAT(///' SUNDIALS_ERROR: FNVINITS returned IER = ', I5)
+        STOP
+      ENDIF
+C
+
+      CALL FARKMALLOC(T0, Y, METH, ITOL, RTOL, ATOL,
+     1                IOUT, ROUT, IPAR, RPAR, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,30) IER
+ 30     FORMAT(///' SUNDIALS_ERROR: FARKMALLOC returned IER = ', I5)
+        STOP
+      ENDIF
+C
+      CALL FARKSETRIN('INIT_STEP', H0, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,32) IER
+ 32     FORMAT(///' SUNDIALS_ERROR: FARKSETRIN returned IER = ', I5)
+        STOP
+      ENDIF
+C
+      CALL FARKSETRIN('NLCONV_COEF', NLCONV, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,32) IER
+        STOP
+      ENDIF
+C
+      CALL FARKSETIIN('MAX_NSTEPS', MXSTEPS, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,35) IER
+ 35     FORMAT(///' SUNDIALS_ERROR: FARKSETIIN returned IER = ', I5)
+        STOP
+      ENDIF
+C
+      CALL FARKSETIIN('MAX_NITERS', MXNLI, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,35) IER
+        STOP
+      ENDIF
+C
+      CALL FARKSETIIN('PREDICT_METHOD', PRED, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,35) IER
+        STOP
+      ENDIF
+C
+      CALL FARKSETIIN('MAX_ERRFAIL', MXETF, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,35) IER
+        STOP
+      ENDIF
+c
+      CALL FARKROOTINIT(2, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,45) IER
+ 45      FORMAT(///' SUNDIALS_ERROR: FARKROOTINIT returned IER = ', I5)
+         CALL FARKFREE
+         STOP
+      ENDIF
+C
+      CALL FARKLAPACKDENSE(NEQ, IER)
+      IF (IER .NE. 0) THEN
+        WRITE(6,40) IER
+ 40     FORMAT(///' SUNDIALS_ERROR: FARKLAPACKDENSE returned IER = ',I5)
+        CALL FARKFREE
+        STOP
+      ENDIF
+C
+      CALL FARKLAPACKDENSESETJAC(1, IER)
+C
+      DO WHILE(JOUT .LT. NOUT)
+C
+        CALL FARKODE(TOUT, T, Y, ITASK, IER)
+C
+        WRITE(6,50) T, Y(1), Y(2), Y(3)
+ 50     FORMAT('At t = ', E12.4, '   y = ', 3E14.6)
+C
+        IF (IER .LT. 0) THEN
+           WRITE(6,60) IER, IOUT(16)
+ 60        FORMAT(///' SUNDIALS_ERROR: FARKODE returned IER = ', I5, /,
+     1            '                 Linear Solver returned IER = ', I5)
+           CALL FARKROOTFREE
+           CALL FARKFREE
+           STOP
+        ENDIF
+C
+        IF (IER .EQ. 2) THEN
+           CALL FARKROOTINFO(2, INFO, IERROOT)
+           IF (IERROOT .LT. 0) THEN
+              WRITE(6,65) IERROOT
+ 65           FORMAT(///' SUNDIALS_ERROR: FARKROOTINFO returned IER = ',
+     1              I5)
+              CALL FARKROOTFREE
+              CALL FARKFREE
+              STOP
+           ENDIF
+           WRITE(6,70) (INFO(I), I = 1, 2)
+ 70        FORMAT(5X, 'Above is a root, INFO() = ', 2I3)
+        ENDIF                   
+C
+        IF (IER .EQ. 0) THEN
+           TOUT = TOUT * 10.0D0
+           JOUT = JOUT + 1
+        ENDIF
+C
+      ENDDO
+C
+      CALL FARKDKY(T, 1, Y, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6,80) IER
+ 80      FORMAT(///' SUNDIALS_ERROR: FARKDKY returned IER = ', I4)
+         CALL FARKROOTFREE
+         CALL FARKFREE
+         STOP
+      ENDIF
+      WRITE(6,85) Y(1), Y(2), Y(3)
+ 85   FORMAT(/'Final value of ydot = ', 3E14.6)
+C
+      WRITE(6,90) IOUT(LNST), IOUT(LNST_ATT), IOUT(LNFE), IOUT(LNFI), 
+     1            IOUT(LNJE), IOUT(LNSETUP), IOUT(LNNI), IOUT(LNCF), 
+     2            IOUT(LNETF), IOUT(LNGE)
+ 90   FORMAT(//'Final statistics:'//
+     1       ' No. steps = ', I4, ', attempted = ', I4/
+     2       ' No. fe-s = ', I4, ', No. fi-s = ',I5/
+     3       ' No. J-s = ', I4, ',  No. LU-s = ', I4/
+     4       ' No. nonlinear iterations = ', I5/
+     5       ' No. nonlinear convergence failures = ', I4/
+     6       ' No. error test failures = ', I4/
+     7       ' No. root function evals = ', I4)
+C
+      CALL FARKROOTFREE
+      CALL FARKFREE
+C
+      STOP
+      END
+
+C     ----------------------------------------------------------------
+
+      SUBROUTINE FARKIFUN(T, Y, YDOT, IPAR, RPAR, IER)
+C Fortran routine for right-hand side function, fi
+      IMPLICIT NONE
+C
+      INTEGER*4 IPAR(*), IER
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
+C
+      YDOT(1) = -0.04D0 * Y(1) + 1.0D4 * Y(2) * Y(3)
+      YDOT(3) = 3.0D7 * Y(2) * Y(2)
+      YDOT(2) = -YDOT(1) - YDOT(3)
+C
+      IER = 0
+C
+      RETURN
+      END
+
+C     ----------------------------------------------------------------
+
+      SUBROUTINE FARKEFUN(T, Y, YDOT, IPAR, RPAR, IER)
+C Fortran routine for right-hand side function, fe
+      IMPLICIT NONE
+C
+      INTEGER*4 IPAR(*), IER
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
+C
+      YDOT(1) = 0.D0
+      YDOT(3) = 0.D0
+      YDOT(2) = 0.D0
+C
+      IER = 0
+C
+      RETURN
+      END
+
+C     ----------------------------------------------------------------
+
+      SUBROUTINE FARKROOTFN(T, Y, G, IPAR, RPAR, IER)
+C Fortran routine for root finding
+      IMPLICIT NONE
+C
+      DOUBLE PRECISION T, Y(*), G(*), RPAR(*)
+      INTEGER*4 IPAR(*), IER
+C
+      G(1) = Y(1) - 1.0D-4
+      G(2) = Y(3) - 1.0D-2
+C
+      IER = 0
+
+      RETURN
+      END
+
+C     ----------------------------------------------------------------
+
+      SUBROUTINE FARKDJAC(N, T, Y, FY, JAC, H, IPAR, RPAR, 
+     1                    V1, V2, V3, IER)
+C Fortran routine for dense user-supplied Jacobian.
+      IMPLICIT NONE
+C
+      INTEGER*4 IER
+      INTEGER*8 N, IPAR(*)
+      DOUBLE PRECISION T, Y(*), FY(*), JAC(N,*), H, RPAR(*)
+      DOUBLE PRECISION V1(*), V2(*), V3(*)
+C
+      DOUBLE PRECISION  Y1, Y2, Y3
+C
+      Y1 = Y(1)
+      Y2 = Y(2)
+      Y3 = Y(3)
+      JAC(1,1) = -0.04D0
+      JAC(1,2) = 1.0D4 * Y3
+      JAC(1,3) = 1.0D4 * Y2
+      JAC(2,1) =  0.04D0
+      JAC(2,2) = -1.0D4 * Y3 - 6.0D7 * Y2
+      JAC(2,3) = -1.0D4 * Y2
+      JAC(3,3) = 0.0D0
+      JAC(3,2) = 6.0D7 * Y2
+      JAC(3,3) = 0.0D0
+C
+      IER = 0
+C
+      RETURN
+      END
diff --git a/examples/arkode/F77_serial/fark_roberts_dnsL.out b/examples/arkode/F77_serial/fark_roberts_dnsL.out
new file mode 100644
index 0000000..92a44f8
--- /dev/null
+++ b/examples/arkode/F77_serial/fark_roberts_dnsL.out
@@ -0,0 +1,34 @@
+Dense example problem:
+
+ Robertson kinetics, NEQ =  3
+
+
+At t =   0.2640E+00   y =   0.989965E+00  0.347057E-04  0.100000E-01
+     Above is a root, INFO() =   0  1
+At t =   0.4000E+00   y =   0.985172E+00  0.338640E-04  0.147940E-01
+At t =   0.4000E+01   y =   0.905519E+00  0.224048E-04  0.944589E-01
+At t =   0.4000E+02   y =   0.715827E+00  0.918557E-05  0.284164E+00
+At t =   0.4000E+03   y =   0.450519E+00  0.322290E-05  0.549478E+00
+At t =   0.4000E+04   y =   0.183202E+00  0.894249E-06  0.816797E+00
+At t =   0.4000E+05   y =   0.389834E-01  0.162189E-06  0.961016E+00
+At t =   0.4000E+06   y =   0.493828E-02  0.198408E-07  0.995062E+00
+At t =   0.4000E+07   y =   0.516810E-03  0.206913E-08  0.999483E+00
+At t =   0.2080E+08   y =   0.100000E-03  0.399524E-09  0.999900E+00
+     Above is a root, INFO() =  -1  0
+At t =   0.4000E+08   y =   0.520280E-04  0.206294E-09  0.999948E+00
+At t =   0.4000E+09   y =   0.520789E-05  0.208381E-10  0.999995E+00
+At t =   0.4000E+10   y =   0.520846E-06  0.221245E-11  0.999999E+00
+At t =   0.4000E+11   y =   0.520840E-07  0.317921E-12  0.100000E+01
+
+Final value of ydot =  -0.130212E-17  0.285435E-22  0.130209E-17
+
+
+Final statistics:
+
+ No. steps =  839, attempted =  983
+ No. fe-s =    0, No. fi-s = 29154
+ No. J-s =   70,  No. LU-s =  422
+ No. nonlinear iterations = 24278
+ No. nonlinear convergence failures =   15
+ No. error test failures =  129
+ No. root function evals =  870
diff --git a/examples/arkode/F90_parallel/CMakeLists.txt b/examples/arkode/F90_parallel/CMakeLists.txt
new file mode 100644
index 0000000..fca2903
--- /dev/null
+++ b/examples/arkode/F90_parallel/CMakeLists.txt
@@ -0,0 +1,149 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for the ARKODE parallel F90 examples
+
+
+# Add variable FARKODE_examples with the names of the parallel ARKODE examples
+
+SET(FARKODE_examples
+  "fark_heat2D\;1\;2"
+  )
+
+# Add variable FARKODE_extras with the names of auxiliary files to install
+# "name\;nodes\;tasks"
+SET(FARKODE_extras
+  plot_heat2D.py
+  )
+
+# Check whether we use MPI compiler scripts.
+# If yes, then change the Fortran compiler to the MPIF90 script.
+# If not, then add the MPI include directory for MPI headers.
+IF(MPI_MPIF90)
+  # use MPI_MPIF90 as the compiler
+  SET(CMAKE_Fortran_COMPILER ${MPI_MPIF90})
+ELSE(MPI_MPIF90)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPIF90)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECP_LIB sundials_nvecparallel_static)
+  SET(FNVECP_LIB sundials_fnvecparallel_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECP_LIB sundials_nvecparallel_shared)
+  SET(FNVECP_LIB sundials_fnvecparallel_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Only static FCMIX libraries are available
+SET(FARKODE_LIB sundials_farkode_static)
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${FARKODE_LIB} ${ARKODE_LIB} ${FNVECP_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each ARKODE example
+FOREACH(example_tuple ${FARKODE_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
+  ADD_EXECUTABLE(${example} ${example}.f90)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(NOT MPI_MPIF90)
+    TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
+  ENDIF(NOT MPI_MPIF90)
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.f90 ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_parallel)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example_tuple ${FARKODE_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_parallel)
+
+  # Install the extra files
+  FOREACH(extrafile ${FARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_parallel)
+  ENDFOREACH(extrafile ${FARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  SET(SOLVER_FLIB "sundials_farkode")
+  FOREACH(example_tuple ${FARKODE_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${FARKODE_examples})
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_F90_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F90_parallel/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/F90_parallel/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_parallel 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_F90_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F90_parallel/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/F90_parallel/Makefile_ex
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_parallel 
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/F90_parallel/README b/examples/arkode/F90_parallel/README
new file mode 100644
index 0000000..013d9bb
--- /dev/null
+++ b/examples/arkode/F90_parallel/README
@@ -0,0 +1,55 @@
+List of parallel ARKODE F90 examples
+
+  fark_heat2D : 2-D diffusion (PCG with Jacobi preconditioner)
+
+Sample results:
+
+  The example output was produced by running with 2 MPI processes:
+  
+      mpiexec -n 2 ./fark_heat2D
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/F90_parallel/fark_heat2D.f90 b/examples/arkode/F90_parallel/fark_heat2D.f90
new file mode 100644
index 0000000..0daeeed
--- /dev/null
+++ b/examples/arkode/F90_parallel/fark_heat2D.f90
@@ -0,0 +1,879 @@
+!-----------------------------------------------------------------
+! Programmer(s): Daniel R. Reynolds @ SMU
+!-----------------------------------------------------------------
+! LLNS/SMU Copyright Start
+! Copyright (c) 2015, Southern Methodist University and 
+! Lawrence Livermore National Security
+!
+! This work was performed under the auspices of the U.S. Department 
+! of Energy by Southern Methodist University and Lawrence Livermore 
+! National Laboratory under Contract DE-AC52-07NA27344.
+! Produced at Southern Methodist University and the Lawrence 
+! Livermore National Laboratory.
+!
+! All rights reserved.
+! For details, see the LICENSE file.
+! LLNS/SMU Copyright End
+! Copyright (c) 2013, Southern Methodist University.
+! All rights reserved.
+! For details, see the LICENSE file.
+!-----------------------------------------------------------------
+! Example problem:
+! 
+! The following test simulates a simple anisotropic 2D heat 
+! equation,
+!    u_t = kx*u_xx + ky*u_yy + h,
+! for t in [0, 10], (x,y) in [0, 1]^2, with initial conditions
+!    u(0,x,y) =  0,
+! stationary boundary conditions, i.e. 
+!    u_t(t,0,y) = u_t(t,1,y) = u_t(t,x,0) = u_t(t,x,1) = 0,
+! and a heat source of the form
+!    h(x,y) = sin(pi*x)*sin(2*pi*y).
+!
+! Under this setup, the problem has an analytical solution:
+!    u(t,x,y) = a(t)*sin(pi*x)*sin(2*pi*y), where
+!    a(t) = (1 - exp(-(kx+4*ky)*pi^2*t)) / ((kx+4*ky)*pi^2).
+! 
+! The spatial derivatives are computed using second-order 
+! centered differences, with the data distributed over nx*ny
+! points on a uniform spatial grid.
+!
+! The spatial grid parameters nx and ny, the parameters kx and ky, 
+! as well as the desired relative and absolute solver tolerances, 
+! are provided in the input file input_heat2D.txt.
+! 
+! This program solves the problem with a DIRK method.  This 
+! employs a Newton iteration with the PCG iterative linear solver, 
+! which itself uses a Jacobi preconditioner.  The example uses the 
+! built-in finite-difference Jacobian-vector product routine, but 
+! supplies both the RHS and preconditioner setup/solve functions.
+!
+! 20 outputs are printed at equal intervals, and run statistics 
+! are printed at the end.
+!-----------------------------------------------------------------
+
+!-----------------------------------------------------------------
+! Main driver program
+!-----------------------------------------------------------------
+module UserData
+  !---------------------------------------------------------------
+  ! Description: 
+  !    Module containing problem-defining parameters, as well as
+  !    data buffers for MPI exchanges with neighboring processes.
+  !    Also contains routines to:
+  !      (a) initialize the module
+  !      (b) perform exchanges
+  !      (c) free module data.
+  !---------------------------------------------------------------
+  implicit none
+  save
+
+  integer*8 :: nx          ! global number of x grid points 
+  integer*8 :: ny          ! global number of y grid points 
+  integer*8 :: is          ! global x indices of this subdomain
+  integer*8 :: ie
+  integer*8 :: js          ! global y indices of this subdomain
+  integer*8 :: je
+  integer*8 :: nxl         ! local number of x grid points 
+  integer*8 :: nyl         ! local number of y grid points 
+  real*8    :: dx          ! x-directional mesh spacing 
+  real*8    :: dy          ! y-directional mesh spacing 
+  real*8    :: kx          ! x-directional diffusion coefficient 
+  real*8    :: ky          ! y-directional diffusion coefficient 
+  real*8, dimension(:,:), allocatable :: h    ! heat source vector
+  real*8, dimension(:,:), allocatable :: d    ! inverse of Jacobian diagonal
+  integer :: comm                             ! communicator object
+  integer :: myid                             ! MPI process ID
+  integer :: nprocs                           ! total number of MPI processes
+  logical :: HaveBdry(2,2)                    ! flags denoting if on physical boundary
+  real*8, dimension(:), allocatable :: Erecv  ! receive buffers for neighbor exchange
+  real*8, dimension(:), allocatable :: Wrecv
+  real*8, dimension(:), allocatable :: Nrecv
+  real*8, dimension(:), allocatable :: Srecv
+  real*8, dimension(:), allocatable :: Esend  ! send buffers for neighbor exchange
+  real*8, dimension(:), allocatable :: Wsend
+  real*8, dimension(:), allocatable :: Nsend
+  real*8, dimension(:), allocatable :: Ssend
+
+contains
+
+  !---------------------------------------------------------------
+  ! Initialize memory allocated within Userdata (set to defaults)
+  !---------------------------------------------------------------
+  subroutine InitUserData()
+    implicit none
+    include "mpif.h"
+    nx = 0
+    ny = 0
+    is = 0
+    ie = 0
+    js = 0
+    je = 0
+    nxl = 0
+    nyl = 0
+    dx = 0.d0
+    dy = 0.d0
+    kx = 0.d0
+    ky = 0.d0
+    if (allocated(h))  deallocate(h)
+    if (allocated(d))  deallocate(d)
+    comm = MPI_COMM_WORLD
+    myid = 0
+    nprocs = 0
+    HaveBdry = .true.
+    if (allocated(Erecv))  deallocate(Erecv)
+    if (allocated(Wrecv))  deallocate(Wrecv)
+    if (allocated(Nrecv))  deallocate(Nrecv)
+    if (allocated(Srecv))  deallocate(Srecv)
+    if (allocated(Esend))  deallocate(Esend)
+    if (allocated(Wsend))  deallocate(Wsend)
+    if (allocated(Nsend))  deallocate(Nsend)
+    if (allocated(Ssend))  deallocate(Ssend)
+  end subroutine InitUserData
+  !---------------------------------------------------------------
+
+
+  !---------------------------------------------------------------
+  ! Set up parallel decomposition
+  !---------------------------------------------------------------
+  subroutine SetupDecomp(ierr)
+    ! declarations
+    implicit none
+    include "mpif.h"
+    integer, intent(out) :: ierr
+    integer :: dims(2), periods(2), coords(2)
+    
+    ! internals
+
+    ! check that this has not been called before
+    if (allocated(h) .or. allocated(d)) then
+       write(0,*) "SetupDecomp warning: parallel decomposition already set up"
+       ierr = 1
+       return
+    end if
+
+    ! get suggested parallel decomposition
+    dims = (/0, 0/)
+    call MPI_Comm_size(MPI_COMM_WORLD, nprocs, ierr)
+    if (ierr /= MPI_SUCCESS) then
+       write(0,*) "Error in MPI_Comm_size = " , ierr
+       return
+    end if
+    call MPI_Dims_create(nprocs, 2, dims, ierr)
+    if (ierr /= MPI_SUCCESS) then
+       write(0,*) "Error in MPI_Dims_create = " , ierr
+       return
+    end if
+
+    ! set up 2D Cartesian communicator
+    periods = (/0, 0/)
+    call MPI_Cart_create(MPI_COMM_WORLD, 2, dims, periods, 0, comm, ierr)
+    if (ierr /= MPI_SUCCESS) then
+       write(0,*) "Error in MPI_Cart_create = " , ierr
+       return
+    end if
+    call MPI_Comm_rank(comm, myid, ierr)
+    if (ierr /= MPI_SUCCESS) then
+       write(0,*) "Error in MPI_Comm_rank = " , ierr
+       return
+    end if
+
+    ! determine local extents
+    call MPI_Cart_get(comm, 2, dims, periods, coords, ierr)
+    if (ierr /= MPI_SUCCESS) then
+       write(0,*) "Error in MPI_Cart_get = " , ierr
+       return
+    end if
+    is = nx*coords(1)/dims(1) + 1
+    ie = nx*(coords(1)+1)/dims(1)
+    js = ny*coords(2)/dims(2) + 1
+    je = ny*(coords(2)+1)/dims(2)
+    nxl = ie-is+1
+    nyl = je-js+1
+
+    ! determine if I have neighbors, and allocate exchange buffers
+    HaveBdry(1,1) = (is == 1)
+    HaveBdry(1,2) = (ie == nx)
+    HaveBdry(2,1) = (js == 1)
+    HaveBdry(2,2) = (je == ny)
+    if (.not. HaveBdry(1,1)) then
+       allocate(Wrecv(nyl))
+       allocate(Wsend(nyl))
+    endif
+    if (.not. HaveBdry(1,2)) then
+       allocate(Erecv(nyl))
+       allocate(Esend(nyl))
+    endif
+    if (.not. HaveBdry(2,1)) then
+       allocate(Srecv(nxl))
+       allocate(Ssend(nxl))
+    endif
+    if (.not. HaveBdry(2,2)) then
+       allocate(Nrecv(nxl))
+       allocate(Nsend(nxl))
+    endif
+
+    ! allocate temporary vectors
+    allocate(h(nxl,nyl))    ! Create vector for heat source
+    allocate(d(nxl,nyl))    ! Create vector for Jacobian diagonal
+    
+    ierr = 0     ! return with success flag
+    return
+  end subroutine SetupDecomp
+  !---------------------------------------------------------------
+
+
+  !---------------------------------------------------------------
+  ! Perform neighbor exchange
+  !---------------------------------------------------------------
+  subroutine Exchange(y, ierr)
+    ! declarations
+    implicit none
+    include "mpif.h"
+    real*8,  intent(in)  :: y(nxl,nyl)
+    integer, intent(out) :: ierr
+    integer :: reqSW, reqSE, reqSS, reqSN, reqRW, reqRE, reqRS, reqRN;
+    integer :: stat(MPI_STATUS_SIZE)
+    integer*8 :: i
+    integer :: ipW, ipE, ipS, ipN
+    integer :: coords(2), dims(2), periods(2), nbcoords(2)
+    
+    ! internals
+
+    ! MPI neighborhood information
+    call MPI_Cart_get(comm, 2, dims, periods, coords, ierr)
+    if (ierr /= MPI_SUCCESS) then
+       write(0,*) "Error in MPI_Cart_get = ", ierr
+       return
+    endif
+    if (.not. HaveBdry(1,1)) then
+       nbcoords = (/ coords(1)-1, coords(2) /)
+       call MPI_Cart_rank(comm, nbcoords, ipW, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Cart_rank = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(1,2)) then
+       nbcoords = (/ coords(1)+1, coords(2) /)
+       call MPI_Cart_rank(comm, nbcoords, ipE, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Cart_rank = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,1)) then
+       nbcoords = (/ coords(1), coords(2)-1 /)
+       call MPI_Cart_rank(comm, nbcoords, ipS, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Cart_rank = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,2)) then
+       nbcoords = (/ coords(1), coords(2)+1 /)
+       call MPI_Cart_rank(comm, nbcoords, ipN, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Cart_rank = ", ierr
+          return
+       endif
+    endif
+
+    ! open Irecv buffers
+    if (.not. HaveBdry(1,1)) then
+       call MPI_Irecv(Wrecv, nyl, MPI_DOUBLE_PRECISION, ipW, &
+                      MPI_ANY_TAG, comm, reqRW, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Irecv = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(1,2)) then
+       call MPI_Irecv(Erecv, nyl, MPI_DOUBLE_PRECISION, ipE, &
+                      MPI_ANY_TAG, comm, reqRE, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Irecv = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,1)) then
+       call MPI_Irecv(Srecv, nxl, MPI_DOUBLE_PRECISION, ipS, &
+                      MPI_ANY_TAG, comm, reqRS, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Irecv = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,2)) then
+       call MPI_Irecv(Nrecv, nxl, MPI_DOUBLE_PRECISION, ipN, &
+                      MPI_ANY_TAG, comm, reqRN, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Irecv = ", ierr
+          return
+       endif
+    endif
+
+    ! send data
+    if (.not. HaveBdry(1,1)) then
+       do i=1,nyl
+          Wsend(i) = y(1,i)
+       enddo
+       call MPI_Isend(Wsend, nyl, MPI_DOUBLE_PRECISION, ipW, 0, &
+                      comm, reqSW, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Isend = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(1,2)) then
+       do i=1,nyl
+          Esend(i) = y(nxl,i)
+       enddo
+       call MPI_Isend(Esend, nyl, MPI_DOUBLE_PRECISION, ipE, 1, &
+                      comm, reqSE, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Isend = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,1)) then
+       do i=0,nxl
+          Ssend(i) = y(i,1)
+       enddo
+       call MPI_Isend(Ssend, nxl, MPI_DOUBLE_PRECISION, ipS, 2, &
+                      comm, reqSS, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Isend = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,2)) then
+       do i=0,nxl
+          Nsend(i) = y(i,nyl)
+       enddo
+       call MPI_Isend(Nsend, nxl, MPI_DOUBLE_PRECISION, ipN, 3, &
+                      comm, reqSN, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Isend = ", ierr
+          return
+       endif
+    endif
+
+    ! wait for messages to finish
+    if (.not. HaveBdry(1,1)) then
+       call MPI_Wait(reqRW, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+       call MPI_Wait(reqSW, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(1,2)) then
+       call MPI_Wait(reqRE, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+       call MPI_Wait(reqSE, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,1)) then
+       call MPI_Wait(reqRS, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+       call MPI_Wait(reqSS, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+    endif
+    if (.not. HaveBdry(2,2)) then
+       call MPI_Wait(reqRN, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+       call MPI_Wait(reqSN, stat, ierr)
+       if (ierr /= MPI_SUCCESS) then 
+          write(0,*) "Error in MPI_Wait = ", ierr
+          return
+       endif
+    endif
+
+    ierr = 0     ! return with success flag
+    return
+  end subroutine Exchange
+  !---------------------------------------------------------------
+
+
+  !---------------------------------------------------------------
+  ! Free memory allocated within Userdata
+  !---------------------------------------------------------------
+  subroutine FreeUserData(ierr)
+    implicit none
+    integer, intent(out) :: ierr
+    if (.not. HaveBdry(1,1)) then
+       deallocate(Wrecv)
+       deallocate(Wsend)
+    endif
+    if (.not. HaveBdry(1,2)) then
+       deallocate(Erecv)
+       deallocate(Esend)
+    endif
+    if (.not. HaveBdry(2,1)) then
+       deallocate(Srecv)
+       deallocate(Ssend)
+    endif
+    if (.not. HaveBdry(2,2)) then
+       deallocate(Nrecv)
+       deallocate(Nsend)
+    endif
+    ierr = 0     ! return with success flag
+    return
+  end subroutine FreeUserData
+  !---------------------------------------------------------------
+
+
+  !---------------------------------------------------------------
+  ! RMS norm function for parallel array data
+  !---------------------------------------------------------------
+  subroutine PRMS(y,yrms,ierr)
+    ! declarations
+    implicit none
+    include "mpif.h"
+    integer, intent(out) :: ierr
+    real*8,  intent(in)  :: y(nxl,nyl)
+    real*8,  intent(out) :: yrms
+    real*8 :: lsum, gsum
+
+    ! internals
+    lsum = sum(y**2)
+    call MPI_Allreduce(lsum, gsum, 1, MPI_DOUBLE_PRECISION, &
+                       MPI_SUM, comm, ierr)
+    if (ierr /= MPI_SUCCESS) then
+       write(0,*) "Error in MPI_Allreduce = ", ierr
+       call MPI_Finalize(ierr)
+    endif
+    yrms = sqrt(gsum/nx/ny)
+
+    ierr = 0     ! return with success flag
+    return
+  end subroutine PRMS
+  !---------------------------------------------------------------
+
+end module UserData
+!-----------------------------------------------------------------
+
+
+!-----------------------------------------------------------------
+! Main driver program
+!-----------------------------------------------------------------
+program driver
+
+  ! inclusions
+  use UserData
+  implicit none
+  include "mpif.h"
+
+  ! Declarations
+  ! general problem parameters
+  real*8,    parameter :: pi = 3.1415926535897932d0
+  real*8,    parameter :: T0 = 0.d0     ! initial time 
+  real*8,    parameter :: Tf = 0.3d0    ! final time 
+  integer,   parameter :: Nt = 20       ! total number of output times 
+  real*8,    parameter :: rtol = 1.d-5  ! relative and absolute tolerances
+  real*8,    parameter :: atol = 1.d-10
+  integer*8, parameter :: nx_ = 60      ! spatial mesh size
+  integer*8, parameter :: ny_ = 120
+  real*8,    parameter :: kx_ = 0.5d0   ! heat conductivity coefficients
+  real*8,    parameter :: ky_ = 0.75d0
+  real*8,    parameter :: nlscoef = 1.d-7   ! nonlinear solver tolerance factor
+  integer,   parameter :: PCGpretype = 1    ! enable preconditioner
+  integer,   parameter :: PCGmaxl = 20      ! max num. PCG iterations
+  real*8,    parameter :: PCGdelt = 0.d0    ! use default solver tolerance factor
+
+  ! solution vector and other local variables
+  real*8, allocatable :: y(:,:)
+  real*8    :: rout(6), rpar, t, dTout, tout, urms
+  integer*8 :: N, Ntot, i, j, iout(22), ipar
+  integer   :: flag, ioutput
+  logical   :: outproc
+  character*100 :: outname
+
+  ! initialize MPI
+  call MPI_Init(flag)
+  if (flag /= MPI_SUCCESS) then
+     write(0,*) "Error in MPI_Init = ", flag
+     stop
+  end if
+  call MPI_Comm_rank(MPI_COMM_WORLD, myid, flag)
+  if (flag /= MPI_SUCCESS) then
+     write(0,*) "Error in MPI_Comm_rank = ", flag
+     call MPI_Finalize(flag)
+  end if
+
+  ! Initialize UserData module
+  call InitUserData()
+  nx = nx_
+  ny = ny_
+  kx = kx_
+  ky = ky_
+  dx = 1.d0/(nx-1)   ! x mesh spacing 
+  dy = 1.d0/(ny-1)   ! x mesh spacing 
+
+  ! Set up parallel decomposition (computes local mesh sizes)
+  call SetupDecomp(flag)
+  if (flag /= MPI_SUCCESS) then
+     write(0,*) "Error in SetupDecomp = ", flag
+     call MPI_Finalize(flag)
+  end if
+
+  ! Initial problem output 
+  outproc = (myid == 0)
+  if (outproc) then
+     write(6,*) "  "
+     write(6,*) "2D Heat PDE test problem:";
+     write(6,'(A,i4)') "   nprocs = " , nprocs
+     write(6,'(A,i4)') "   nx = ", nx
+     write(6,'(A,i4)') "   ny = ", ny
+     write(6,'(A,f5.2)') "   kx = ", kx
+     write(6,'(A,f5.2)') "   ky = ", ky
+     write(6,'(A,es9.2)') "   rtol = ", rtol
+     write(6,'(A,es9.2)') "   atol = ", atol
+     write(6,'(A,i4)') "   nxl (proc 0) = ", nxl
+     write(6,'(A,i4)') "   nyl (proc 0) = ", nyl
+     write(6,*) "  "
+  endif
+
+  ! Initialize data structures 
+  N = nxl*nyl
+  Ntot = nx*ny
+  call FNVInitP(comm, 4, N, Ntot, flag)
+  if (flag /= MPI_SUCCESS) then
+     write(0,*) "Error in FNVInitP = ", flag
+     call MPI_Finalize(flag)
+  end if
+  allocate(y(nxl,nyl))         ! Create parallel vector for solution 
+  y = 0.d0                     ! Set initial conditions 
+
+  ! Create the solver memory to use DIRK integrator, scalar tolerances
+  call FARKMalloc(T0, y, 0, 1, rtol, atol, iout, rout, ipar, rpar, flag)
+  if (flag /= MPI_SUCCESS) then
+     write(0,*) "Error in FARKMalloc = ", flag
+     call MPI_Finalize(flag)
+  end if
+
+  ! fill in the heat source array
+  do j=1,nyl
+     do i=1,nxl
+        h(i,j) = sin(pi*(is+i-2)*dx) * sin(2.d0*pi*(js+j-2)*dy)
+     enddo
+  enddo
+
+  ! set integrator options
+  call FARKSetRin("NLCONV_COEF", nlscoef, flag)
+  if (flag < 0) then
+     write(0,*) "Error in FARKSetRin = ", flag
+     call MPI_Finalize(flag)
+  end if
+  call FARKSetIin("PREDICT_METHOD", 1_8, flag)
+  if (flag < 0) then
+     write(0,*) "Error in FARKSetIin = ", flag
+     call MPI_Finalize(flag)
+  end if
+
+
+  ! Linear solver specification 
+  call FARKPCG(PCGpretype, PCGmaxl, PCGdelt, flag)  ! Specify the PCG solver 
+  if (flag < 0) then
+     write(0,*) "Error in FARKPCG = ", flag
+     call MPI_Finalize(flag)
+  end if
+  call FARKSpilsSetPrec(1, flag)                     ! Enable preconditioning
+  if (flag < 0) then
+     write(0,*) "Error in FARKSpilsSetPrec = ", flag
+     call MPI_Finalize(flag)
+  end if
+
+  ! specify that the problem is linearly implicit, but that Jacobian does not depend on time
+  call FARKSetIin("LINEAR", 0_8, flag)
+  if (flag < 0) then
+     write(0,*) "Error in FARKSetIin = ", flag
+     call MPI_Finalize(flag)
+  end if
+
+  ! Each processor outputs subdomain information
+  write(outname,'(16Hheat2d_subdomain,f4.3,4H.txt)') myid/1000.0
+  open(100, file=outname)
+  write(100,'(6(i9,1x))') nx, ny, is, ie, js, je
+  close(100)
+
+  ! Open output streams for results, access data array 
+  write(outname,'(6Hheat2d,f4.3,4H.txt)') myid/1000.0
+  open(101, file=outname)
+
+  ! Output initial condition to disk
+  do j=1,nyl
+     do i=1,nxl
+        write(101,'(es25.16)',advance='no') y(i,j)
+     enddo
+  enddo
+  write(101,*) "  "
+
+  ! Main time-stepping loop: calls ARKode to perform the integration, then
+  ! prints results.  Stops when the final time has been reached
+  t = T0
+  dTout = (Tf-T0)/Nt
+  tout = T0+dTout
+  call PRMS(y, urms, flag)
+  if (outproc) then
+    write(6,*) "        t      ||u||_rms"
+    write(6,*) "   ----------------------"
+    write(6,'(2(2x,f10.6))') t, urms
+  endif
+  do ioutput=1,Nt
+
+     call FARKode(tout, t, y, 1, flag)         ! call integrator 
+     if (flag < 0) then
+        write(0,*) "Error in FARKode = ", flag
+        exit
+     end if
+     
+     call PRMS(y, urms, flag)
+     if (outproc) &
+          write(6,'(2(2x,f10.6))') t, urms     ! print solution stats 
+     if (flag >= 0) then                       ! successful solve: update output time
+        tout = min(tout + dTout, Tf)
+     else                                      ! unsuccessful solve: break 
+        if (outproc) &
+             write(0,*) "Solver failure, stopping integration"
+        exit
+     endif
+
+     ! output results to disk 
+     do j=1,nyl
+        do i=1,nxl
+           write(101,'(es25.16)',advance='no') y(i,j)
+        enddo
+     enddo
+     write(101,*) "  "
+     
+  enddo
+  if (outproc) then
+     write(6,*) "   ----------------------"
+  endif
+  close(101)
+
+  ! Print some final statistics 
+  if (outproc) then
+     write(6,*) "  "
+     write(6,*) "Final Solver Statistics:"
+     write(6,'(2(A,i6),A)') "   Internal solver steps = ", iout(3), &
+          " (attempted = ", iout(6), ")"
+     write(6,'(A,i6,A,i6)') "   Total RHS evals:  Fe = ", iout(7), ",  Fi = ", iout(8)
+     write(6,'(A,i6)') "   Total linear solver setups = ", iout(9)
+     write(6,'(A,i6)') "   Total linear iterations = ", iout(21)
+     write(6,'(A,i6)') "   Total number of Jacobian-vector products = ", iout(18)
+     write(6,'(A,i6)') "   Total number of Preconditioner setups = ", iout(19)
+     write(6,'(A,i6)') "   Total number of Preconditioner solves = ", iout(20)
+     write(6,'(A,i6)') "   Total number of linear solver convergence failures = ", &
+          iout(22)
+     write(6,'(A,i6)') "   Total number of Newton iterations = ", iout(11)
+     write(6,'(A,i6)') "   Total number of nonlinear solver convergence failures = ", &
+          iout(12)
+     write(6,'(A,i6)') "   Total number of error test failures = ", iout(10)
+ endif
+
+ ! Clean up and return with successful completion 
+ deallocate(y)              ! free vectors
+ deallocate(h)
+ deallocate(d)
+ call FreeUserData(flag)    ! free user data 
+ call FARKFree()            ! free integrator memory 
+ call MPI_Barrier(comm, flag)
+ call MPI_Finalize(flag)    ! Finalize MPI
+
+end program driver
+!-----------------------------------------------------------------
+
+
+
+!-----------------------------------------------------------------
+! Functions called by the solver
+!-----------------------------------------------------------------
+
+
+subroutine farkifun(t, y, ydot, ipar, rpar, ierr)
+!-----------------------------------------------------------------
+! f routine to compute the ODE RHS function f(t,y). 
+!-----------------------------------------------------------------
+  ! declarations
+  use UserData
+  implicit none
+  include "mpif.h"
+  real*8,  intent(in)  :: t, rpar
+  integer, intent(in)  :: ipar
+  integer, intent(out) :: ierr
+  real*8,  intent(in)  :: y(nxl,nyl)
+  real*8,  intent(out) :: ydot(nxl,nyl)
+  real*8    :: c1, c2, c3
+  integer*8 :: i, j
+  
+  ! internals
+
+  ! Initialize ydot to zero 
+  ydot = 0.d0
+
+  ! Exchange boundary data with neighbors
+  call Exchange(y, ierr)
+  if (ierr /= MPI_SUCCESS) then
+     write(0,*) "Error in Exchange = " , ierr
+     return
+  end if
+
+  ! iterate over subdomain interior, computing approximation to RHS
+  c1 = kx/dx/dx
+  c2 = ky/dy/dy
+  c3 = -2.d0*(c1 + c2)
+  do j=2,nyl-1
+     do i=2,nxl-1
+        ydot(i,j) = c1*(y(i-1,j)+y(i+1,j)) + c2*(y(i,j-1)+y(i,j+1)) + c3*y(i,j)
+     enddo
+  enddo
+  
+  ! iterate over subdomain boundaries (if not at overall domain boundary)
+  if (.not. HaveBdry(1,1)) then    ! West face
+     i=1
+     do j=2,nyl-1
+        ydot(i,j) = c1*(Wrecv(j)+y(i+1,j)) + c2*(y(i,j-1)+y(i,j+1)) + c3*y(i,j)
+     enddo
+  endif
+  if (.not. HaveBdry(1,2)) then    ! East face
+     i=nxl
+     do j=2,nyl-1
+        ydot(i,j) = c1*(y(i-1,j)+Erecv(j)) + c2*(y(i,j-1)+y(i,j+1)) + c3*y(i,j)
+     enddo
+  endif
+  if (.not. HaveBdry(2,1)) then    ! South face
+     j=1
+     do i=2,nxl-1
+        ydot(i,j) = c1*(y(i-1,j)+y(i+1,j)) + c2*(Srecv(i)+y(i,j+1)) + c3*y(i,j)
+     enddo
+  endif
+  if (.not. HaveBdry(2,2)) then    ! West face
+     j=nyl
+     do i=2,nxl-1
+        ydot(i,j) = c1*(y(i-1,j)+y(i+1,j)) + c2*(y(i,j-1)+Nrecv(i)) + c3*y(i,j)
+     enddo
+  endif
+  if (.not. HaveBdry(1,1) .and. .not. HaveBdry(2,1)) then  ! South-West corner
+     i=1
+     j=1
+     ydot(i,j) = c1*(Wrecv(j)+y(i+1,j)) + c2*(Srecv(i)+y(i,j+1)) + c3*y(i,j)
+  endif
+  if (.not. HaveBdry(1,1) .and. .not. HaveBdry(2,2)) then  ! North-West corner
+     i=1
+     j=nyl
+     ydot(i,j) = c1*(Wrecv(j)+y(i+1,j)) + c2*(y(i,j-1)+Nrecv(i)) + c3*y(i,j)
+  endif
+  if (.not. HaveBdry(1,2) .and. .not. HaveBdry(2,1)) then  ! South-East corner
+     i=nxl 
+     j=1
+     ydot(i,j) = c1*(y(i-1,j)+Erecv(j)) + c2*(Srecv(i)+y(i,j+1)) + c3*y(i,j)
+  endif
+  if (.not. HaveBdry(1,2) .and. .not. HaveBdry(2,2)) then  ! North-East corner
+     i=nxl
+     j=nyl
+     ydot(i,j) = c1*(y(i-1,j)+Erecv(j)) + c2*(y(i,j-1)+Nrecv(i)) + c3*y(i,j)
+  endif
+
+  ydot = ydot + h         ! add in heat source
+
+  ierr = 0                ! Return with success 
+  return
+end subroutine farkifun
+!-----------------------------------------------------------------
+
+
+subroutine farkefun(t, y, ydot, ipar, rpar, ierr)
+!-----------------------------------------------------------------
+! Explicit portion of f routine (empty)
+!-----------------------------------------------------------------
+  ! declarations
+  use UserData
+  implicit none
+  real*8,  intent(in)  :: t, rpar
+  integer, intent(in)  :: ipar
+  integer, intent(out) :: ierr
+  real*8,  intent(in)  :: y(nxl,nyl)
+  real*8,  intent(out) :: ydot(nxl,nyl)
+  
+  ! internals
+
+  ! Initialize ydot to zero and return with success
+  ydot = 0.d0
+  ierr = 0
+  return
+end subroutine farkefun
+!-----------------------------------------------------------------
+
+
+subroutine farkpset(t, y, fy, jok, jcur, gamma, hcur, ipar, &
+                    rpar, v1, v2, v3, ierr)
+!-----------------------------------------------------------------
+! Preconditioner setup routine (fills inverse of Jacobian diagonal)
+!-----------------------------------------------------------------
+  ! declarations
+  use UserData
+  implicit none
+  real*8,  intent(in)  :: t, gamma, hcur, rpar
+  integer, intent(in)  :: ipar, jok
+  integer, intent(out) :: jcur, ierr
+  real*8,  intent(in)  :: y(nxl,nyl), fy(nxl,nyl)
+  real*8               :: v1(nxl,nyl), v2(nxl,nyl), v3(nxl,nyl)
+  real*8 :: c
+
+  ! internals
+  c = 1.d0 + gamma*2.d0*(kx/dx/dx + ky/dy/dy)
+
+  ! set all entries of d to the inverse of the diagonal values in interior
+  ! (since boundary RHS is 0, set boundary diagonals to the same)
+  d = 1.d0/c
+
+  jcur = 1     ! update jcur flag
+  ierr = 0     ! Return with success 
+  return
+end subroutine farkpset
+
+
+subroutine farkpsol(t, y, fy, r, z, gamma, delta, lr, &
+                    ipar, rpar, vt, ierr)
+!-----------------------------------------------------------------
+! Preconditioner solve routine
+!-----------------------------------------------------------------
+  ! declarations
+  use UserData
+  implicit none
+  real*8,  intent(in)  :: t, gamma, delta, rpar
+  integer, intent(in)  :: lr, ipar
+  integer, intent(out) :: ierr
+  real*8,  intent(in)  :: y(nxl,nyl), fy(nxl,nyl), r(nxl,nyl)
+  real*8,  intent(out) :: z(nxl,nyl)
+  real*8               :: vt(nxl,nyl)
+
+  ! internals
+  z = r*d      ! perform Jacobi iteration (whole array operation)
+  ierr = 0     ! Return with success 
+  return
+end subroutine farkpsol
+!-----------------------------------------------------------------
+
diff --git a/examples/arkode/F90_parallel/fark_heat2D.out b/examples/arkode/F90_parallel/fark_heat2D.out
new file mode 100644
index 0000000..3160697
--- /dev/null
+++ b/examples/arkode/F90_parallel/fark_heat2D.out
@@ -0,0 +1,49 @@
+   
+ 2D Heat PDE test problem:
+   nprocs =    2
+   nx =   60
+   ny =  120
+   kx =  0.50
+   ky =  0.75
+   rtol =  1.00E-05
+   atol =  1.00E-10
+   nxl (proc 0) =   30
+   nyl (proc 0) =  120
+   
+         t      ||u||_rms
+    ----------------------
+    0.000000    0.000000
+    0.015000    0.005780
+    0.030000    0.009224
+    0.045000    0.011275
+    0.060000    0.012497
+    0.075000    0.013224
+    0.090000    0.013658
+    0.105000    0.013916
+    0.120000    0.014070
+    0.135000    0.014162
+    0.150000    0.014216
+    0.165000    0.014249
+    0.180000    0.014268
+    0.195000    0.014280
+    0.210000    0.014287
+    0.225000    0.014291
+    0.240000    0.014293
+    0.255000    0.014295
+    0.270000    0.014295
+    0.285000    0.014296
+    0.300000    0.014296
+    ----------------------
+   
+ Final Solver Statistics:
+   Internal solver steps =     58 (attempted =     60)
+   Total RHS evals:  Fe =      0,  Fi =    604
+   Total linear solver setups =     20
+   Total linear iterations =   4963
+   Total number of Jacobian-vector products =   4963
+   Total number of Preconditioner setups =     20
+   Total number of Preconditioner solves =   5142
+   Total number of linear solver convergence failures =    179
+   Total number of Newton iterations =    300
+   Total number of nonlinear solver convergence failures =      0
+   Total number of error test failures =      2
diff --git a/examples/arkode/F90_parallel/plot_heat2D.py b/examples/arkode/F90_parallel/plot_heat2D.py
new file mode 100755
index 0000000..01158eb
--- /dev/null
+++ b/examples/arkode/F90_parallel/plot_heat2D.py
@@ -0,0 +1,141 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for heat2D.cpp example
+
+# imports
+import sys
+import numpy as np
+from pylab import *
+from mpl_toolkits.mplot3d import Axes3D
+from matplotlib import cm
+import matplotlib.pyplot as plt
+
+# determine the number of MPI processes used
+nprocs=1
+for i in range(1000):
+    sname = 'heat2d_subdomain.' + repr(i).zfill(3) + '.txt'
+    try:
+        f = open(sname,'r')
+        f.close()
+    except IOError:
+        nprocs = i
+        break
+
+# load subdomain information, store in table
+subdomains = np.zeros((nprocs,4), dtype=np.int)
+for i in range(nprocs):
+    sname = 'heat2d_subdomain.' + repr(i).zfill(3) + '.txt'
+    subd = np.loadtxt(sname, dtype=np.int)
+    if (i == 0):
+        nx = subd[0]
+        ny = subd[1]
+    else:
+        if ((subd[0] != nx) or (subd[1] != ny)):
+            sys.exit("error: subdomain files incompatible (clean up and re-run test)")
+    subdomains[i,:] = subd[2:6]
+    
+# load first processor's data, and determine total number of time steps
+data = np.loadtxt('heat2d.000.txt', dtype=np.double)
+nt = np.shape(data)[0]
+
+# create empty array for all solution data
+results = np.zeros((nt,ny,nx))
+
+# insert first processor's data into results array
+istart = subdomains[0,0]-1
+iend = subdomains[0,1]-1
+jstart = subdomains[0,2]-1
+jend = subdomains[0,3]-1
+nxl = iend-istart+1
+nyl = jend-jstart+1
+for i in range(nt):
+    results[i,jstart:jend+1,istart:iend+1] = np.reshape(data[i,:], (nyl,nxl))
+    
+# iterate over remaining data files, inserting into output
+if (nprocs > 1):
+    for isub in range(1,nprocs):
+        data = np.loadtxt('heat2d.' + repr(isub).zfill(3) + '.txt', dtype=np.double)
+        # check that subdomain has correct number of time steps
+        if (np.shape(data)[0] != nt):
+            sys.exit('error: subdomain ' + isub + ' has an incorrect number of time steps')
+        istart = subdomains[isub,0]-1
+        iend = subdomains[isub,1]-1
+        jstart = subdomains[isub,2]-1
+        jend = subdomains[isub,3]-1
+        nxl = iend-istart+1
+        nyl = jend-jstart+1
+        for i in range(nt):
+            results[i,jstart:jend+1,istart:iend+1] = np.reshape(data[i,:], (nyl,nxl))
+
+# determine extents of plots
+maxtemp = 1.1*results.max()
+mintemp = 0.9*results.min()
+
+# generate plots of results
+kx = 0.5
+ky = 0.75
+kprod = (kx+4.0*ky)*np.pi**2
+dt = 0.015
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'heat2d_surf.' + repr(tstep).zfill(3) + '.png'
+    cname = 'heat2d_err.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(nx)
+    nystr = repr(ny)
+
+    # set x and y meshgrid objects
+    xspan = np.linspace(0.0, 1.0, nx)
+    yspan = np.linspace(0.0, 1.0, ny)
+    X,Y = np.meshgrid(xspan,yspan)
+
+    # plot current solution as a surface, and save to disk
+    fig = plt.figure(1)
+    ax = fig.add_subplot(111, projection='3d')
+    ax.plot_surface(X, Y, results[tstep,:,:], rstride=1, cstride=1, 
+                    cmap=cm.jet, linewidth=0, antialiased=True, shade=True)
+    ax.set_xlabel('x')
+    ax.set_ylabel('y')
+    ax.set_zlim((mintemp, maxtemp))
+    ax.view_init(20,45)
+    title('u(x,y) at output ' + tstr + ', mesh = ' + nxstr + 'x' + nystr)
+    savefig(pname)
+    plt.close()
+
+    # plot error in current solution (as a contour, and save to disk)
+    t = tstep*dt;
+    at = (1.0 - np.exp(-t*kprod))/kprod
+    utrue = at*np.sin(np.pi*X)*np.sin(2.0*np.pi*Y);
+    uerr = np.abs(utrue - results[tstep,:,:])
+    plt.contourf(xspan,yspan,uerr,15, cmap=plt.cm.jet)
+    plt.colorbar()
+    plt.xlabel('x')
+    plt.ylabel('y')
+    plt.title('Error at output ' + tstr + ', mesh = ' + nxstr + 'x' + nystr)
+    plt.savefig(cname)
+    plt.close()
+
+
+
+
+##### end of script #####
diff --git a/examples/arkode/F90_serial/CMakeLists.txt b/examples/arkode/F90_serial/CMakeLists.txt
new file mode 100644
index 0000000..62e01db
--- /dev/null
+++ b/examples/arkode/F90_serial/CMakeLists.txt
@@ -0,0 +1,185 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for the FARKODE serial examples
+
+
+# Add variable FARKODE_examples with the names of the serial FARKODE examples
+
+SET(FARKODE_examples
+  ark_bruss
+  )
+
+# Add variable FARKODE_examples_BL with the names of the serial FARKODE examples
+# that use Lapack
+
+SET(FARKODE_examples_BL
+  )
+
+# Add variable FARKODE_examples_KLU with the names of the serial FARKODE examples
+# that use KLU
+
+SET(FARKODE_examples_KLU
+  ark_bruss1D_FEM_klu
+  )
+
+# Add variable ARKODE_extras with the names of auxiliary files to install
+
+SET(ARKODE_extras
+  plot_sol.py
+  plot_brusselator1D_FEM.py
+  )
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_static)
+  SET(NVECS_LIB sundials_nvecserial_static)
+  SET(FNVECS_LIB sundials_fnvecserial_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(ARKODE_LIB sundials_arkode_shared)
+  SET(NVECS_LIB sundials_nvecserial_shared)
+  SET(FNVECS_LIB sundials_fnvecserial_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Only static FCMIX libraries are available
+
+SET(FARKODE_LIB sundials_farkode_static)
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${FARKODE_LIB} ${ARKODE_LIB} ${FNVECS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each FARKODE example
+
+FOREACH(example ${FARKODE_examples})
+  ADD_EXECUTABLE(${example} ${example}.f90)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.f90 ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_serial)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${FARKODE_examples})
+
+# Add the build and install targets for each Lapack FARKODE example (if needed)
+
+IF(LAPACK_FOUND)
+  FOREACH(example ${FARKODE_examples_BL})
+    ADD_EXECUTABLE(${example} ${example}.f90)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.f90 ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${FARKODE_examples_BL})
+ENDIF(LAPACK_FOUND)
+
+# If KLU support is enabled, add the build and install targets for 
+# the examples using KLU
+IF(KLU_FOUND)
+  FOREACH(example ${FARKODE_examples_KLU})
+    ADD_EXECUTABLE(${example} ${example}.f90)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.f90 ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${FARKODE_examples_KLU})
+ENDIF(KLU_FOUND)
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_serial)
+
+  # Install the extra files
+  FOREACH(extrafile ${ARKODE_extras})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_serial)
+  ENDFOREACH(extrafile ${ARKODE_extras})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "ARKODE")
+  SET(SOLVER_LIB "sundials_arkode")
+  SET(SOLVER_FLIB "sundials_farkode")
+  LIST2STRING(FARKODE_examples EXAMPLES)
+
+  IF(LAPACK_FOUND)
+    LIST2STRING(FARKODE_examples_BL EXAMPLES_BL)
+  ELSE(LAPACK_FOUND)
+    SET(EXAMPLES_BL "")
+  ENDIF(LAPACK_FOUND)
+
+  IF(KLU_FOUND)
+    LIST2STRING(FARKODE_examples_KLU EXAMPLES)
+  ENDIF(KLU_FOUND)
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_F90_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F90_serial/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/arkode/F90_serial/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_serial 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_F90_ex.in
+      ${PROJECT_BINARY_DIR}/examples/arkode/F90_serial/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/arkode/F90_serial/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/arkode/F90_serial 
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/arkode/F90_serial/README b/examples/arkode/F90_serial/README
new file mode 100644
index 0000000..5bd2743
--- /dev/null
+++ b/examples/arkode/F90_serial/README
@@ -0,0 +1,51 @@
+List of serial ARKODE F90 examples
+
+  ark_bruss : chemical kinetics example (DIRK/DENSE)
+  ark_bruss1D_FEM_klu : stiff chemical kinetics PDE, with FEM
+                        spatial discretization and CSR Jacobian (DIRK/KLU)
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/arkode/F90_serial/ark_bruss.f90 b/examples/arkode/F90_serial/ark_bruss.f90
new file mode 100644
index 0000000..ca57b8f
--- /dev/null
+++ b/examples/arkode/F90_serial/ark_bruss.f90
@@ -0,0 +1,299 @@
+!-----------------------------------------------------------------
+! Programmer(s): Daniel R. Reynolds @ SMU
+!-----------------------------------------------------------------
+! LLNS/SMU Copyright Start
+! Copyright (c) 2015, Southern Methodist University and 
+! Lawrence Livermore National Security
+!
+! This work was performed under the auspices of the U.S. Department 
+! of Energy by Southern Methodist University and Lawrence Livermore 
+! National Laboratory under Contract DE-AC52-07NA27344.
+! Produced at Southern Methodist University and the Lawrence 
+! Livermore National Laboratory.
+!
+! All rights reserved.
+! For details, see the LICENSE file.
+! LLNS/SMU Copyright End
+! Copyright (c) 2013, Southern Methodist University.
+! All rights reserved.
+! For details, see the LICENSE file.
+!-----------------------------------------------------------------
+! Example problem:
+! 
+! The following test simulates a brusselator problem from chemical 
+! kinetics.  This is an ODE system with 3 components, Y = [u,v,w], 
+! satisfying the equations,
+!    du/dt = a - (w+1)*u + v*u^2
+!    dv/dt = w*u - v*u^2
+!    dw/dt = (b-w)/ep - w*u
+! for t in the interval [0.0, 10.0], with initial conditions 
+! Y0 = [u0,v0,w0].  We use the initial conditions and parameters 
+!    u0=3.9,  v0=1.1,  w0=2.8,  a=1.2,  b=2.5,  ep=1.0e-5
+! Here, all three solution components exhibit a rapid transient 
+! change during the first 0.2 time units, followed by a slow and 
+! smooth evolution.
+! 
+! This program solves a the Fortran ODE test problem using the 
+! FARKODE interface for the ARKode ODE solver module.
+! 
+! This program uses the IMEX ARK solver; here the 
+! implicit systems are solved with a modified Newton iteration
+! with the ARKDENSE dense linear solver.  The Jacobian routine 
+! and right-hand side routines come from the file user-supplied 
+! Jacobian routine.
+!
+! Output is printed 10 times throughout the defined time interval.
+! Run statistics (optional outputs) are printed at the end.
+!-----------------------------------------------------------------
+
+!-----------------------------------------------------------------
+! Main driver program
+!-----------------------------------------------------------------
+program driver
+  ! Declarations
+  implicit none
+
+  ! general problem variables
+  integer*8, parameter :: NEQ=3
+  real*8,    parameter :: T0=0.d0, Tf=10.d0
+  real*8    :: dTout, Tout, Tcur, rtol, atol, rout(6)
+  integer   :: it, Nt, ier
+  integer*8 :: iout(22)
+  real*8, dimension(NEQ) :: y
+
+  ! real/integer parameters to pass through to supplied functions
+  !    ipar(1) -> unused
+  !    rpar(1) -> "a" parameter
+  !    rpar(2) -> "b" parameter 
+  !    rpar(3) -> "ep" parameter
+  integer*8 :: ipar
+  real*8    :: rpar(3)
+
+  ! solver parameters
+  integer*8 :: order, adapt_method
+  real*8    :: nlscoef
+
+  !-----------------------
+  ! set some solver parameters
+  order = 3          ! 4th order method
+  adapt_method = 0   ! PID-controller
+  nlscoef = 1.d-2    ! Newton solver tolerance coefficient
+
+  ! time-stepping information
+  dTout = (Tf-T0)/10.d0    ! output time interval
+  Nt = Tf/dTout + 0.5      ! number of outputs
+
+  ! set initial conditions, problem parameters
+  y(1) = 3.9d0     ! u0
+  y(2) = 1.1d0     ! v0
+  y(3) = 2.8d0     ! w0
+  rpar(1) = 1.2d0  ! a
+  rpar(2) = 2.5d0  ! b
+  rpar(3) = 1.d-5  ! ep
+
+  ! set tolerances according to problem specifications
+  atol = 1.d-10
+  rtol = 1.d-6
+  
+  ! initialize vector module
+  call FNVInitS(4, NEQ, ier)
+  if (ier < 0) then
+     write(0,*) 'Error in FNVInitS = ',ier
+     stop
+  endif
+
+  ! initialize ARKode solver to use IMEX integrator, scalar tolerances
+  call FARKMalloc(T0, y, 2, 1, rtol, atol, &
+                  iout, rout, ipar, rpar, ier)
+  if (ier < 0) then
+     write(0,*) 'Error in FARKMalloc = ',ier
+     stop
+  endif
+
+  ! set integrator options
+  call FARKSetIin('ORDER', order, ier)
+  if (ier < 0) then
+     write(0,*) 'Error in FARKSetIin = ',ier
+     stop
+  endif
+  call FARKSetRin('NLCONV_COEF', nlscoef, ier)
+  if (ier < 0) then
+     write(0,*) 'Error in FARKSetIin = ',ier
+     stop
+  endif
+  call FARKSetAdaptivityMethod(adapt_method, 1, 0, 0, ier)
+  if (ier < 0) then
+     write(0,*) 'Error in FARKSetAdaptMethod = ',ier
+     stop
+  endif
+
+  ! specify use of dense linear solver
+  call FARKDense(NEQ, ier)
+  if (ier < 0) then
+     write(0,*) 'Error in FARKDense = ',ier
+     stop
+  endif
+  call FARKDenseSetJac(1, ier)
+  if (ier < 0) then
+     write(0,*) 'Error in FARKDenseSetJac = ',ier
+     stop
+  endif
+
+  ! Open output stream for results, output comment line
+  open(100, file='solution.txt')
+  write(100,*) '# t u v w'
+
+  ! output initial condition to disk 
+  write(100,'(3x,4(es23.16,1x))') T0, y
+
+  ! loop over time outputs
+  Tout = T0
+  Tcur = T0
+  print *, '        t           u           v           w'
+  print *, '  ----------------------------------------------------'
+  print '(3x,4(es12.5,1x))', Tcur, y
+  do it = 1,Nt
+
+     Tout = min(Tout + dTout, Tf)           ! set next output time
+     call FARKode(Tout, Tcur, y, 1, ier)    ! call solver
+     if (ier < 0) then
+        print *, 'Error at step ',it,', FARKode return flag =',ier
+        exit
+     end if
+
+     ! output current solution
+     print '(3x,4(es12.5,1x))', Tcur, y
+     write(100,'(3x,4(es23.16,1x))') Tcur, y
+
+  end do
+  print *, '  ----------------------------------------------------'
+  close(100)
+
+  ! output solver statistics
+  print *, '  '
+  print *, 'Final Solver Statistics:'
+  print '(2(A,i7),A)', '   Internal solver steps =', iout(3), &
+       ' (attempted =', iout(6), ')'
+  print '(2(A,i7))', '   Total RHS evals:  Fe =', iout(7), &
+       ',  Fi =', iout(8)
+  print '(A,i7)', '   Total linear solver setups =', iout(9)
+  print '(A,i7)', '   Total RHS evals for setting up the linear system =', iout(17)
+  print '(A,i7)', '   Total number of Jacobian evaluations =', iout(18)
+  print '(A,i7)', '   Total number of Newton iterations =', iout(11)
+  print '(A,i7)', '   Total number of nonlinear solver convergence failures =', iout(12)
+  print '(A,i7)', '   Total number of error test failures =', iout(10)
+  print *, '  '
+
+  ! clean up
+  call FARKFree()
+
+end program driver
+!-----------------------------------------------------------------
+
+!-----------------------------------------------------------------
+! Required subroutines for FARKODE interface
+!-----------------------------------------------------------------
+
+subroutine farkifun(t, y, ydot, ipar, rpar, ier)
+!-----------------------------------------------------------------
+! Implicit portion of the right-hand side of the ODE system
+!-----------------------------------------------------------------
+
+  ! Declarations
+  implicit none
+
+  ! Arguments
+  real*8,    intent(in)  :: t, rpar(3)
+  integer*8, intent(in)  :: ipar(1)
+  integer,   intent(out) :: ier
+  real*8,    intent(in)  :: y(3)
+  real*8,    intent(out) :: ydot(3)
+
+  ! temporary variables
+  real*8 :: u, v, w, a, b, ep
+
+  ! set temporary values
+  a  = rpar(1)
+  b  = rpar(2)
+  ep = rpar(3)
+  u  = y(1)
+  v  = y(2)
+  w  = y(3)
+
+  ! fill implicit RHS, set success flag
+  ydot(1) = 0.d0
+  ydot(2) = 0.d0
+  ydot(3) = (b-w)/ep
+  ier = 0
+  
+end subroutine farkifun
+!-----------------------------------------------------------------
+
+subroutine farkefun(t, y, ydot, ipar, rpar, ier)
+!-----------------------------------------------------------------
+! Explicit portion of the right-hand side of the ODE system
+!-----------------------------------------------------------------
+
+  ! Declarations
+  implicit none
+
+  ! Arguments
+  real*8,    intent(in)  :: t, rpar(3)
+  integer*8, intent(in)  :: ipar(1)
+  integer,   intent(out) :: ier
+  real*8,    intent(in)  :: y(3)
+  real*8,    intent(out) :: ydot(3)
+
+  ! temporary variables
+  real*8 :: u, v, w, a, b, ep
+
+  ! set temporary values
+  a  = rpar(1)
+  b  = rpar(2)
+  ep = rpar(3)
+  u  = y(1)
+  v  = y(2)
+  w  = y(3)
+
+  ! fill explicit RHS, set success flag
+  ydot(1) = a - (w+1.d0)*u + v*u*u
+  ydot(2) = w*u - v*u*u
+  ydot(3) = -w*u
+  ier = 0
+  
+end subroutine farkefun
+!-----------------------------------------------------------------
+
+subroutine farkdjac(neq,t,y,fy,DJac,h,ipar,rpar,wk1,wk2,wk3,ier)
+!-----------------------------------------------------------------
+! Jacobian computation routine
+!-----------------------------------------------------------------
+
+  ! Declarations
+  implicit none
+
+  ! Arguments
+  real*8,    intent(in)  :: t, h, rpar(3)
+  integer*8, intent(in)  :: neq, ipar(1)
+  integer,   intent(out) :: ier
+  real*8,    intent(in), dimension(neq) :: y, fy, wk1, wk2, wk3
+  real*8,    intent(out) :: DJac(neq,neq)
+
+  ! temporary variables
+  real*8 :: u, v, w, a, b, ep
+
+  ! set temporary values
+  a  = rpar(1)
+  b  = rpar(2)
+  ep = rpar(3)
+  u  = y(1)
+  v  = y(2)
+  w  = y(3)
+
+  ! fill implicit Jacobian, set success flag
+  DJac = 0.d0
+  DJac(3,3) = -1.d0/ep
+  ier = 0
+    
+end subroutine farkdjac
+!-----------------------------------------------------------------
diff --git a/examples/arkode/F90_serial/ark_bruss.out b/examples/arkode/F90_serial/ark_bruss.out
new file mode 100644
index 0000000..cc8b664
--- /dev/null
+++ b/examples/arkode/F90_serial/ark_bruss.out
@@ -0,0 +1,25 @@
+         t           u           v           w
+   ----------------------------------------------------
+    0.00000E+00  3.90000E+00  1.10000E+00  2.80000E+00
+    1.00000E+00  2.07527E+00  1.05960E+00  2.49998E+00
+    2.00000E+00  1.10046E+00  1.72361E+00  2.49999E+00
+    3.00000E+00  7.89620E-01  2.32667E+00  2.50000E+00
+    4.00000E+00  8.11773E-01  2.72558E+00  2.49991E+00
+    5.00000E+00  1.18700E+00  2.59554E+00  2.49990E+00
+    6.00000E+00  1.88731E+00  1.49410E+00  2.49997E+00
+    7.00000E+00  1.32327E+00  1.61902E+00  2.50004E+00
+    8.00000E+00  9.21787E-01  2.13022E+00  2.49999E+00
+    9.00000E+00  8.49543E-01  2.53947E+00  2.49994E+00
+    1.00000E+01  1.06497E+00  2.59595E+00  2.49990E+00
+   ----------------------------------------------------
+   
+ Final Solver Statistics:
+   Internal solver steps =    907 (attempted =    936)
+   Total RHS evals:  Fe =   3748,  Fi =   7536
+   Total linear solver setups =    157
+   Total RHS evals for setting up the linear system =      0
+   Total number of Jacobian evaluations =     28
+   Total number of Newton iterations =   3788
+   Total number of nonlinear solver convergence failures =      0
+   Total number of error test failures =     29
+   
diff --git a/examples/arkode/F90_serial/ark_bruss1D_FEM_klu.f90 b/examples/arkode/F90_serial/ark_bruss1D_FEM_klu.f90
new file mode 100644
index 0000000..5694c29
--- /dev/null
+++ b/examples/arkode/F90_serial/ark_bruss1D_FEM_klu.f90
@@ -0,0 +1,1134 @@
+!-----------------------------------------------------------------
+! Programmer(s): Daniel R. Reynolds @ SMU
+!-----------------------------------------------------------------
+! Copyright (c) 2016, Southern Methodist University.
+! All rights reserved.
+! For details, see the LICENSE file.
+!-----------------------------------------------------------------
+! Example problem:
+! 
+! The following test simulates a brusselator problem from chemical 
+! kinetics.  This is a PDE system with 3 components, Y = [u,v,w], 
+! satisfying the equations,
+!    du/dt = du*u_xx + a - (w+1)*u + v*u^2
+!    dv/dt = dv*v_xx + w*u - v*u^2
+!    dw/dt = dw*w_xx + (b-w)/ep - w*u
+! for t in the interval [0, 10], x in [0, 10], with initial 
+! conditions 
+!    u(0,x) =  a  + 0.1*sin(pi*x),
+!    v(0,x) = b/a + 0.1*sin(pi*x),
+!    w(0,x) =  b  + 0.1*sin(pi*x),
+! and with stationary boundary conditions, i.e.
+!    u_t(t,0) = u_t(t,1) = 0,
+!    v_t(t,0) = v_t(t,1) = 0,
+!    w_t(t,0) = w_t(t,1) = 0.
+!
+! Here, we use a piecewise linear Galerkin finite element 
+! discretization in space, where all element-wise integrals are 
+! computed using 3-node Gaussian quadrature (since we will have 
+! quartic polynomials in the reaction terms for the u_t and v_t 
+! equations (including the test function)).  The time derivative 
+! terms in this system will include a mass matrix, giving rise to 
+! an ODE system of the form
+!      M y_t = L y + R(y),
+! where M is the 3x3 block mass matrix for each component, L is 
+! the 3x3 block Laplace operator for each component, and R(y) is 
+! comprised of the nonlinear reaction terms for each component.  
+! Since it it highly inefficient to rewrite this system as
+!      y_t = M^{-1}(L y + R(y)),
+! we solve this system using FARKODE, with a user-supplied mass
+! matrix.  We therefore provide functions to evaluate the ODE RHS 
+!    f(t,y) = L y + R(y),
+! its Jacobian
+!    J(t,y) = L + dR/dy,
+! and the mass matrix, M.
+!
+! We use N=201 spatial nodes, with parameters 
+!    a=0.6,  b=2.0,  du=0.025,  dv=0.025,  dw=0.025,  ep=1.d-5
+!
+! This program solves the problem with the DIRK method, using a 
+! Newton iteration with the ARKKLU and ARKMASSKLU sparse linear 
+! solvers, where we store the Jacobian and mass matrices in 
+! compressed-sparse-row format.
+!
+! Output is printed 10 times throughout the defined time interval.
+! Run statistics (optional outputs) are printed at the end.
+!-----------------------------------------------------------------
+
+
+! user data structure
+module UserData
+  implicit none
+  save
+  
+  integer :: N                     ! number of intervals
+  real*8, allocatable :: x(:)      ! mesh node locations
+  real*8 :: a                      ! constant forcing on u
+  real*8 :: b                      ! steady-state value of w
+  real*8 :: du                     ! diffusion coeff for u
+  real*8 :: dv                     ! diffusion coeff for v
+  real*8 :: dw                     ! diffusion coeff for w
+  real*8 :: ep                     ! stiffness parameter
+
+contains
+
+  ! function that maps 2D data into 1D address space
+  ! (0-based since CSR matrix will be sent to C solver)
+  integer(kind=8) function idx(ix,ivar)
+    integer :: ivar, ix
+    idx = 3*(ix-1) + ivar - 1
+  end function idx
+
+end module UserData
+
+
+! finite element basis functions
+module FEM
+  
+contains
+  
+  ! left/right basis functions
+  double precision function ChiL(xl,xr,x)
+    double precision :: xl, xr, x
+    ChiL = (xr-x)/(xr-xl)
+  end function ChiL
+
+  double precision function ChiR(xl,xr,x)
+    double precision :: xl, xr, x
+    ChiR = (x-xl)/(xr-xl)
+  end function ChiR
+
+  ! derivatives of left/right basis functions
+  double precision function ChiL_x(xl,xr)
+    double precision :: xl, xr
+    ChiL_x = 1.d0/(xl-xr)
+  end function ChiL_X
+
+  double precision function ChiR_x(xl,xr)
+    double precision :: xl, xr
+    ChiR_x = 1.d0/(xr-xl)
+  end function ChiR_x
+
+  ! FEM output evaluation routines: value and derivative
+  double precision function Eval(ul,ur,xl,xr,x)
+    double precision :: ul, ur, xl, xr, x
+    Eval = ul*ChiL(xl,xr,x) + ur*ChiR(xl,xr,x)
+  end function Eval
+
+  double precision function Eval_x(ul,ur,xl,xr)
+    double precision :: ul, ur, xl, xr
+    Eval_x = ul*ChiL_x(xl,xr) + ur*ChiR_x(xl,xr)
+  end function Eval_x
+
+end module FEM
+
+
+! quadrature data
+module Quadrature
+  
+contains
+
+  ! nodes
+  double precision function X1(xl,xr)
+    double precision :: xl, xr
+    X1 = 0.5d0*(xl+xr) - 0.5d0*(xr-xl)*0.774596669241483377035853079956d0
+  end function X1
+
+  double precision function X2(xl,xr)
+    double precision :: xl, xr
+    X2 = 0.5d0*(xl+xr)
+  end function X2
+
+  double precision function X3(xl,xr)
+    double precision :: xl, xr
+    X3 = 0.5d0*(xl+xr) + 0.5d0*(xr-xl)*0.774596669241483377035853079956d0
+  end function X3
+
+  ! quadrature 
+  double precision function Quad(f1,f2,f3,xl,xr)
+    real*8 :: f1, f2, f3, xl, xr
+    real*8, parameter :: wt1=0.55555555555555555555555555555556d0
+    real*8, parameter :: wt2=0.88888888888888888888888888888889d0
+    real*8, parameter :: wt3=0.55555555555555555555555555555556d0
+    Quad = 0.5d0*(xr-xl)*(wt1*f1 + wt2*f2 + wt3*f3)
+  end function Quad
+
+end module Quadrature
+!-----------------------------------------------------------------
+
+
+
+
+!-----------------------------------------------------------------
+! Main driver program
+!-----------------------------------------------------------------
+program driver
+  use UserData
+
+  ! Declarations
+  implicit none
+
+  ! general problem variables
+  real*8, parameter :: T0=0.d0, Tf=10.d0
+  real*8    :: dTout, Tout, Tcur, rtol, atol, pi, h, z, rout(6)
+  integer   :: i, it, Nt, ier, idef, ineq, nnz, ordering, sparsetype
+  integer*8 :: NEQ, iout(29)
+  real*8, allocatable :: y(:,:), umask(:,:), vmask(:,:), wmask(:,:)
+
+  ! dummy real/integer parameters to pass through to supplied functions
+  integer*8 :: ipar
+  real*8    :: rpar
+
+  !-----------------------
+
+  ! set problem parameters (in UserData structure)
+  N = 201                 ! number of intervals
+  a = 0.6d0               ! constant forcing on u
+  b = 2.d0                ! steady-state value of w
+  du = 2.5d-2             ! diffusion coeff for u
+  dv = 2.5d-2             ! diffusion coeff for v
+  dw = 2.5d-2             ! diffusion coeff for w
+  ep = 1.d-5              ! stiffness parameter
+
+  ! set overall problem size, allocate solution/mask/temporary arrays
+  NEQ = 3*N
+  allocate(y(3,N), umask(3,N), vmask(3,N), wmask(3,N))
+
+  ! allocate and set up spatial mesh; this [arbitrarily] clusters 
+  ! more intervals near the end points of the interval
+  allocate(x(N))          ! mesh node locations
+  pi = 4.d0*atan(1.d0)
+  h = 10.d0/(N-1)
+  do i=1,N
+     z = -5.d0 + h*(i-1)
+     x(i) = 0.5d0/atan(5.d0)*atan(z) + 0.5d0
+  enddo
+
+  ! output mesh to disk
+  open(200, file='bruss_FEM_mesh.txt')
+  do i=1,N
+     write(200,*) x(i)
+  enddo
+  close(200)
+
+  ! time-stepping information
+  dTout = (Tf-T0)/10.d0
+  Nt = Tf/dTout + 0.5
+
+  ! set initial conditions
+  do i=1,N
+     y(1,i) =  a  + 0.1d0*sin(pi*x(i))   ! u0
+     y(2,i) = b/a + 0.1d0*sin(pi*x(i))   ! v0
+     y(3,i) =  b  + 0.1d0*sin(pi*x(i))   ! w0
+  enddo
+
+  ! set mask values for each solution component
+  umask = 0.d0
+  vmask = 0.d0
+  wmask = 0.d0
+  do i=1,N
+     umask(1,i) = 1.d0
+     vmask(2,i) = 1.d0
+     wmask(3,i) = 1.d0
+  enddo
+
+  ! set tolerances according to problem specifications
+  atol = 1.d-11
+  rtol = 1.d-6
+  
+  ! initialize vector module
+  call FNVInitS(4, NEQ, ier)
+
+  ! initialize ARKode solver
+  ipar = 0
+  rpar = 0.0
+  iout = 0
+  rout = 0.0
+  call FARKMalloc(T0, y, 0, 1, rtol, atol, &
+                  iout, rout, ipar, rpar, ier)
+
+  ! set optional inputs
+  call FARKSetIin('IMPLICIT', 1, ier)
+  call FARKSetIin('MAX_NSTEPS', 1000, ier)
+  call FARKSetResTolerance(1, atol, ier)
+
+  ! specify use of KLU linear solvers
+  ineq = NEQ       ! convert to 'normal' integer type
+  nnz = 15*NEQ     ! integer number of nonzeros           
+  ordering = 0     ! AMD
+  sparsetype = 1   ! CSR
+  call FARKKLU(ineq, nnz, sparsetype, ordering, ier)
+  call FARKSparseSetJac(ier)
+  call FARKMassKLU(ineq, nnz, sparsetype, ordering, ier)
+  call FARKSparseSetMass(ier)
+
+  ! Open output stream for results
+  open(501, file='bruss_FEM_u.txt')
+  open(502, file='bruss_FEM_v.txt')
+  open(503, file='bruss_FEM_w.txt')
+
+  ! output initial condition to disk
+  write(501,*) ( y(1,i), i=1,N )
+  write(502,*) ( y(2,i), i=1,N )
+  write(503,*) ( y(3,i), i=1,N )
+ 
+  ! output solver parameters to screen
+  call FARKWriteParameters(ier)
+
+  ! loop over time outputs
+  Tout = T0
+  Tcur = T0
+  print *, '        t         ||u||_rms    ||v||_rms    ||w||_rms'
+  print *, '  ----------------------------------------------------'
+  print '(3x,4(es12.5,1x))', Tcur, sqrt(sum(y*y*umask)/N), &
+       sqrt(sum(y*y*vmask)/N), sqrt(sum(y*y*wmask)/N)
+  do it = 1,Nt
+
+     ! set next output time
+     Tout = min(Tout + dTout, Tf)
+
+     ! set next output time
+     call FARKSetRin('STOP_TIME', Tout, ier)
+
+     ! call solver
+     call FARKode(Tout, Tcur, y, 1, ier)
+     if (ier < 0) then
+        write(0,*) 'Solver failure, stopping integration'
+        stop
+     end if
+
+     ! output current solution information
+     print '(3x,4(es12.5,1x))', Tcur, sqrt(sum(y*y*umask)/N), &
+          sqrt(sum(y*y*vmask)/N), sqrt(sum(y*y*wmask)/N)
+
+     ! output current results to disk
+     write(501,*) ( y(1,i), i=1,N )
+     write(502,*) ( y(2,i), i=1,N )
+     write(503,*) ( y(3,i), i=1,N )
+ 
+  end do
+  print *, '  ----------------------------------------------------'
+
+  ! close solution output files
+  close(501)
+  close(502)
+  close(503)
+
+  ! output solver statistics
+  print *, '  '
+  print *, 'Final Solver Statistics:'
+  print *, '   Internal solver steps = ', iout(3),' (attempted =', iout(6), ')'
+  print *, '   Total RHS evals:  Fe = ', iout(7),'  Fi = ', iout(8)
+  print *, '   Total linear solver setups = ', iout(9)
+  print *, '   Total RHS evals for setting up the linear system = ', iout(17)
+  print *, '   Total number of Jacobian evaluations = ', iout(18)
+  print *, '   Total number of nonlinear iterations = ', iout(11)
+  print *, '   Total number of nonlinear solver convergence failures = ',iout(12)
+  print *, '   Total number of error test failures = ', iout(10)
+  print *, '   Total number of mass matrix evaluations = ', iout(26)
+  print *, '  '
+
+  ! clean up
+  deallocate(y, umask, vmask, wmask, x)
+  call FARKFree()
+
+end program driver
+!-----------------------------------------------------------------
+
+
+
+
+!-----------------------------------------------------------------
+! User-supplied subroutines for FARKODE interface
+!-----------------------------------------------------------------
+
+
+subroutine FARKIFun(t, y, ydot, ipar, rpar, ier)
+!-----------------------------------------------------------------
+! Right-hand side of the ODE system
+!-----------------------------------------------------------------
+  use UserData
+  use FEM
+  use Quadrature
+
+  ! Declarations
+  implicit none
+
+  ! Arguments
+  real*8,  intent(in)   :: t, rpar(1)
+  integer*8, intent(in) :: ipar(1)
+  integer, intent(out)  :: ier
+  real*8,  intent(in)   :: y(3,N)
+  real*8,  intent(out)  :: ydot(3,N)
+
+  ! Local data
+  integer :: ix
+  logical :: left, right
+  real*8  :: ul, ur, vl, vr, wl, wr, xl, xr, u, v, w, f1, f2, f3
+
+  ! clear out rhs
+  ydot = 0.d0
+
+  ! iterate over intervals, filling in rhs function
+  do ix=1,N-1
+
+     ! set booleans to determine whether equations exist on the left/right */
+     left  = .true.
+     right = .true.
+     if (ix==1)      left  = .false.
+     if (ix==(N-1))  right = .false.
+
+     ! set nodal value shortcuts (interval index aligns with left node)
+     ul = y(1,ix)
+     vl = y(2,ix)
+     wl = y(3,ix)
+     ur = y(1,ix+1)
+     vr = y(2,ix+1)
+     wr = y(3,ix+1)
+
+     ! set mesh shortcuts
+     xl = x(ix)
+     xr = x(ix+1)
+
+     !    left test function
+     if (left) then
+
+        ! u -- reaction
+        u = Eval(ul, ur, xl, xr, X1(xl,xr))
+        v = Eval(vl, vr, xl, xr, X1(xl,xr))
+        w = Eval(wl, wr, xl, xr, X1(xl,xr))
+        f1 = (a - (w+1.d0)*u + v*u*u) * ChiL(xl,xr,X1(xl,xr))
+        u = Eval(ul, ur, xl, xr, X2(xl,xr))
+        v = Eval(vl, vr, xl, xr, X2(xl,xr))
+        w = Eval(wl, wr, xl, xr, X2(xl,xr))
+        f2 = (a - (w+1.d0)*u + v*u*u) * ChiL(xl,xr,X2(xl,xr))
+        u = Eval(ul, ur, xl, xr, X3(xl,xr))
+        v = Eval(vl, vr, xl, xr, X3(xl,xr))
+        w = Eval(wl, wr, xl, xr, X3(xl,xr))
+        f3 = (a - (w+1.d0)*u + v*u*u) * ChiL(xl,xr,X3(xl,xr))
+        ydot(1,ix) = ydot(1,ix) + Quad(f1,f2,f3,xl,xr)
+
+        ! u -- diffusion
+        f1 = -du * Eval_x(ul,ur,xl,xr) * ChiL_x(xl,xr)
+        ydot(1,ix) = ydot(1,ix) + Quad(f1,f1,f1,xl,xr)
+
+        ! v -- reaction
+        u = Eval(ul, ur, xl, xr, X1(xl,xr))
+        v = Eval(vl, vr, xl, xr, X1(xl,xr))
+        w = Eval(wl, wr, xl, xr, X1(xl,xr))
+        f1 = (w*u - v*u*u) * ChiL(xl,xr,X1(xl,xr))
+        u = Eval(ul, ur, xl, xr, X2(xl,xr))
+        v = Eval(vl, vr, xl, xr, X2(xl,xr))
+        w = Eval(wl, wr, xl, xr, X2(xl,xr))
+        f2 = (w*u - v*u*u) * ChiL(xl,xr,X2(xl,xr))
+        u = Eval(ul, ur, xl, xr, X3(xl,xr))
+        v = Eval(vl, vr, xl, xr, X3(xl,xr))
+        w = Eval(wl, wr, xl, xr, X3(xl,xr))
+        f3 = (w*u - v*u*u) * ChiL(xl,xr,X3(xl,xr))
+        ydot(2,ix) = ydot(2,ix) + Quad(f1,f2,f3,xl,xr)
+      
+        ! v -- diffusion
+        f1 = -dv * Eval_x(vl,vr,xl,xr) * ChiL_x(xl,xr)
+        ydot(2,ix) = ydot(2,ix) + Quad(f1,f1,f1,xl,xr)
+      
+        ! w -- reaction
+        u = Eval(ul, ur, xl, xr, X1(xl,xr))
+        v = Eval(vl, vr, xl, xr, X1(xl,xr))
+        w = Eval(wl, wr, xl, xr, X1(xl,xr))
+        f1 = ((b-w)/ep - w*u) * ChiL(xl,xr,X1(xl,xr))
+        u = Eval(ul, ur, xl, xr, X2(xl,xr))
+        v = Eval(vl, vr, xl, xr, X2(xl,xr))
+        w = Eval(wl, wr, xl, xr, X2(xl,xr))
+        f2 = ((b-w)/ep - w*u) * ChiL(xl,xr,X2(xl,xr))
+        u = Eval(ul, ur, xl, xr, X3(xl,xr))
+        v = Eval(vl, vr, xl, xr, X3(xl,xr))
+        w = Eval(wl, wr, xl, xr, X3(xl,xr))
+        f3 = ((b-w)/ep - w*u) * ChiL(xl,xr,X3(xl,xr))
+        ydot(3,ix) = ydot(3,ix) + Quad(f1,f2,f3,xl,xr)
+
+        ! w -- diffusion
+        f1 = -dw * Eval_x(wl,wr,xl,xr) * ChiL_x(xl,xr)
+        ydot(3,ix) = ydot(3,ix) + Quad(f1,f1,f1,xl,xr)
+
+     end if
+
+     !    right test function 
+     if (right) then
+
+        ! u -- reaction
+        u = Eval(ul, ur, xl, xr, X1(xl,xr))
+        v = Eval(vl, vr, xl, xr, X1(xl,xr))
+        w = Eval(wl, wr, xl, xr, X1(xl,xr))
+        f1 = (a - (w+1.d0)*u + v*u*u) * ChiR(xl,xr,X1(xl,xr))
+        u = Eval(ul, ur, xl, xr, X2(xl,xr))
+        v = Eval(vl, vr, xl, xr, X2(xl,xr))
+        w = Eval(wl, wr, xl, xr, X2(xl,xr))
+        f2 = (a - (w+1.d0)*u + v*u*u) * ChiR(xl,xr,X2(xl,xr))
+        u = Eval(ul, ur, xl, xr, X3(xl,xr))
+        v = Eval(vl, vr, xl, xr, X3(xl,xr))
+        w = Eval(wl, wr, xl, xr, X3(xl,xr))
+        f3 = (a - (w+1.d0)*u + v*u*u) * ChiR(xl,xr,X3(xl,xr))
+        ydot(1,ix+1) = ydot(1,ix+1) + Quad(f1,f2,f3,xl,xr)
+
+        ! u -- diffusion
+        f1 = -du * Eval_x(ul,ur,xl,xr) * ChiR_x(xl,xr)
+        ydot(1,ix+1) = ydot(1,ix+1) + Quad(f1,f1,f1,xl,xr)
+
+        ! v -- reaction
+        u = Eval(ul, ur, xl, xr, X1(xl,xr))
+        v = Eval(vl, vr, xl, xr, X1(xl,xr))
+        w = Eval(wl, wr, xl, xr, X1(xl,xr))
+        f1 = (w*u - v*u*u) * ChiR(xl,xr,X1(xl,xr))
+        u = Eval(ul, ur, xl, xr, X2(xl,xr))
+        v = Eval(vl, vr, xl, xr, X2(xl,xr))
+        w = Eval(wl, wr, xl, xr, X2(xl,xr))
+        f2 = (w*u - v*u*u) * ChiR(xl,xr,X2(xl,xr))
+        u = Eval(ul, ur, xl, xr, X3(xl,xr))
+        v = Eval(vl, vr, xl, xr, X3(xl,xr))
+        w = Eval(wl, wr, xl, xr, X3(xl,xr))
+        f3 = (w*u - v*u*u) * ChiR(xl,xr,X3(xl,xr))
+        ydot(2,ix+1) = ydot(2,ix+1) + Quad(f1,f2,f3,xl,xr)
+
+        ! v -- diffusion
+        f1 = -dv * Eval_x(vl,vr,xl,xr) * ChiR_x(xl,xr)
+        ydot(2,ix+1) = ydot(2,ix+1) + Quad(f1,f1,f1,xl,xr)
+
+        ! w -- reaction
+        u = Eval(ul, ur, xl, xr, X1(xl,xr))
+        v = Eval(vl, vr, xl, xr, X1(xl,xr))
+        w = Eval(wl, wr, xl, xr, X1(xl,xr))
+        f1 = ((b-w)/ep - w*u) * ChiR(xl,xr,X1(xl,xr))
+        u = Eval(ul, ur, xl, xr, X2(xl,xr))
+        v = Eval(vl, vr, xl, xr, X2(xl,xr))
+        w = Eval(wl, wr, xl, xr, X2(xl,xr))
+        f2 = ((b-w)/ep - w*u) * ChiR(xl,xr,X2(xl,xr))
+        u = Eval(ul, ur, xl, xr, X3(xl,xr))
+        v = Eval(vl, vr, xl, xr, X3(xl,xr))
+        w = Eval(wl, wr, xl, xr, X3(xl,xr))
+        f3 = ((b-w)/ep - w*u) * ChiR(xl,xr,X3(xl,xr))
+        ydot(3,ix+1) = ydot(3,ix+1) + Quad(f1,f2,f3,xl,xr)
+
+        ! w -- diffusion
+        f1 = -dw * Eval_x(wl,wr,xl,xr) * ChiR_x(xl,xr)
+        ydot(3,ix+1) = ydot(3,ix+1) + Quad(f1,f1,f1,xl,xr)
+
+     endif
+
+  enddo
+  ier = 0
+
+  return
+
+end subroutine farkifun
+!-----------------------------------------------------------------
+
+
+
+subroutine farkefun(t, y, ydot, ipar, rpar, ier)
+!-----------------------------------------------------------------
+! (unused) Explicit portion of the ODE right-hand function
+!-----------------------------------------------------------------
+  use UserData
+
+  ! Declarations
+  implicit none
+
+  ! Arguments
+  real*8,  intent(in)   :: t, rpar(1)
+  integer*8, intent(in) :: ipar(1)
+  integer, intent(out)  :: ier
+  real*8,  intent(in)   :: y(3,N)
+  real*8,  intent(out)  :: ydot(3,N)
+
+  ! return with success (since fully implicit)
+  ydot = 0.d0
+  ier = 0
+  
+end subroutine farkefun
+!-----------------------------------------------------------------
+
+
+
+subroutine farkspjac(t, y, fy, neq, nnz, Jdata, Jcolvals, &
+                     Jrowptrs, h, ipar, rpar, wk1, wk2, wk3, ier)
+!-----------------------------------------------------------------
+! Jacobian computation routine -- CSR format
+!-----------------------------------------------------------------
+  use UserData
+  use Quadrature
+  use FEM
+
+  ! Declarations
+  implicit none
+
+  ! Arguments
+  real*8,    intent(in)  :: t, h, rpar(1)
+  real*8,    intent(in), dimension(3,N) :: y, fy, wk1, wk2, wk3
+  integer,   intent(in)  :: neq, nnz
+  integer*8, intent(in)  :: ipar(1)
+  real*8,    intent(out) :: Jdata(nnz)
+  integer,   intent(out) :: Jcolvals(nnz), Jrowptrs(neq+1), ier
+
+  ! Local data
+  integer :: ix, nz
+  real*8  :: ul, uc, ur, vl, vc, vr, wl, wc, wr, xl, xc, xr
+  real*8  :: u1, u2, u3, v1, v2, v3, w1, w2, w3
+  real*8  :: f1, f2, f3, df1, df2, df3, dQdf1, dQdf2, dQdf3
+  real*8  :: ChiL1, ChiL2, ChiL3, ChiR1, ChiR2, ChiR3
+  real*8, dimension(3,-1:1) :: Ju, Jv, Jw
+
+  ! check that vector/matrix dimensions match up
+  if ((3*N /= neq) .or. (nnz < 27*(N-2))) then
+     ier = 1
+     return
+  endif
+
+  ! clear out Jacobian matrix data
+  Jdata = 0.d0
+  nz = 0
+
+  ! Dirichlet boundary at left
+  Jrowptrs(idx(1,1)+1) = nz
+  Jrowptrs(idx(1,2)+1) = nz
+  Jrowptrs(idx(1,3)+1) = nz
+ 
+  ! iterate through nodes, filling in matrix by rows
+  do ix=2,N-1
+
+     ! set nodal value shortcuts (interval index aligns with left node)
+     xl = x(ix-1)
+     ul = y(1,ix-1)
+     vl = y(2,ix-1)
+     wl = y(3,ix-1)
+     xc = x(ix)
+     uc = y(1,ix)
+     vc = y(2,ix)
+     wc = y(3,ix)
+     xr = x(ix+1)
+     ur = y(1,ix+1)
+     vr = y(2,ix+1)
+     wr = y(3,ix+1)
+
+     ! compute entries of all Jacobian rows at node ix
+     Ju = 0.d0
+     Jv = 0.d0
+     Jw = 0.d0
+
+     ! first compute dependence on values to left and center
+     
+     !    evaluate relevant variables in left subinterval
+     u1 = Eval(ul, uc, xl, xc, X1(xl,xc))
+     v1 = Eval(vl, vc, xl, xc, X1(xl,xc))
+     w1 = Eval(wl, wc, xl, xc, X1(xl,xc))
+     u2 = Eval(ul, uc, xl, xc, X2(xl,xc))
+     v2 = Eval(vl, vc, xl, xc, X2(xl,xc))
+     w2 = Eval(wl, wc, xl, xc, X2(xl,xc))
+     u3 = Eval(ul, uc, xl, xc, X3(xl,xc))
+     v3 = Eval(vl, vc, xl, xc, X3(xl,xc))
+     w3 = Eval(wl, wc, xl, xc, X3(xl,xc))
+
+     dQdf1 = Quad(1.d0, 0.d0, 0.d0, xl, xc)
+     dQdf2 = Quad(0.d0, 1.d0, 0.d0, xl, xc)
+     dQdf3 = Quad(0.d0, 0.d0, 1.d0, xl, xc)
+
+     ChiL1 = ChiL(xl, xc, X1(xl,xc))
+     ChiL2 = ChiL(xl, xc, X2(xl,xc))
+     ChiL3 = ChiL(xl, xc, X3(xl,xc))
+     ChiR1 = ChiR(xl, xc, X1(xl,xc))
+     ChiR2 = ChiR(xl, xc, X2(xl,xc))
+     ChiR3 = ChiR(xl, xc, X3(xl,xc))
+
+
+     !    compute diffusion Jacobian components
+
+     !    L_u = -du * u_x * ChiR_x
+     !     dL_u/dul
+     Ju(1,-1) = (-du) * Quad(1.d0,1.d0,1.d0,xl,xc) * ChiL_x(xl,xc) * ChiR_x(xl,xc)
+     !     dL_u/duc
+     Ju(1,0)  = (-du) * Quad(1.d0,1.d0,1.d0,xl,xc) * ChiR_x(xl,xc) * ChiR_x(xl,xc)
+
+     !    L_v = -dv * v_x * ChiR_x
+     !     dL_v/dvl
+     Jv(2,-1) = (-dv) * Quad(1.d0,1.d0,1.d0,xl,xc) * ChiL_x(xl,xc) * ChiR_x(xl,xc)
+     !     dL_v/dvc
+     Jv(2,0)  = (-dv) * Quad(1.d0,1.d0,1.d0,xl,xc) * ChiR_x(xl,xc) * ChiR_x(xl,xc)
+
+     !    L_w =  -dw * w_x * ChiR_x
+     !     dL_w/dwl
+     Jw(3,-1) = (-dw) * Quad(1.d0,1.d0,1.d0,xl,xc) * ChiL_x(xl,xc) * ChiR_x(xl,xc)
+     !     dL_w/dwc
+     Jw(3,0)  = (-dw) * Quad(1.d0,1.d0,1.d0,xl,xc) * ChiR_x(xl,xc) * ChiR_x(xl,xc)
+
+
+     !    compute reaction Jacobian components
+
+     !    R_u = (a - (w+1.d0)*u + v*u*u) 
+     !     dR_u/dul 
+     df1 = (-(w1+1.d0) + 2.d0*v1*u1) * ChiL1 * ChiR1
+     df2 = (-(w2+1.d0) + 2.d0*v2*u2) * ChiL2 * ChiR2
+     df3 = (-(w3+1.d0) + 2.d0*v3*u3) * ChiL3 * ChiR3
+     Ju(1,-1) = Ju(1,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/duc
+     df1 = (-(w1+1.d0) + 2.d0*v1*u1) * ChiR1 * ChiR1
+     df2 = (-(w2+1.d0) + 2.d0*v2*u2) * ChiR2 * ChiR2
+     df3 = (-(w3+1.d0) + 2.d0*v3*u3) * ChiR3 * ChiR3
+     Ju(1,0) = Ju(1,0)+ dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dvl 
+     df1 = (u1*u1) * ChiL1 * ChiR1
+     df2 = (u2*u2) * ChiL2 * ChiR2
+     df3 = (u3*u3) * ChiL3 * ChiR3
+     Ju(2,-1) = Ju(2,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dvc
+     df1 = (u1*u1) * ChiR1 * ChiR1
+     df2 = (u2*u2) * ChiR2 * ChiR2
+     df3 = (u3*u3) * ChiR3 * ChiR3
+     Ju(2,0) = Ju(2,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dwl 
+     df1 = (-u1) * ChiL1 * ChiR1
+     df2 = (-u2) * ChiL2 * ChiR2
+     df3 = (-u3) * ChiL3 * ChiR3
+     Ju(3,-1) = Ju(3,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dwc
+     df1 = (-u1) * ChiR1 * ChiR1
+     df2 = (-u2) * ChiR2 * ChiR2
+     df3 = (-u3) * ChiR3 * ChiR3
+     Ju(3,0) = Ju(3,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+
+     !    R_v = (w*u - v*u*u) 
+     !     dR_v/dul 
+     df1 = (w1 - 2.d0*v1*u1) * ChiL1 * ChiR1
+     df2 = (w2 - 2.d0*v2*u2) * ChiL2 * ChiR2
+     df3 = (w3 - 2.d0*v3*u3) * ChiL3 * ChiR3
+     Jv(1,-1) = Jv(1,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/duc
+     df1 = (w1 - 2.d0*v1*u1) * ChiR1 * ChiR1
+     df2 = (w2 - 2.d0*v2*u2) * ChiR2 * ChiR2
+     df3 = (w3 - 2.d0*v3*u3) * ChiR3 * ChiR3
+     Jv(1,0) = Jv(1,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dvl 
+     df1 = (-u1*u1) * ChiL1 * ChiR1
+     df2 = (-u2*u2) * ChiL2 * ChiR2
+     df3 = (-u3*u3) * ChiL3 * ChiR3
+     Jv(2,-1) = Jv(2,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dvc
+     df1 = (-u1*u1) * ChiR1 * ChiR1
+     df2 = (-u2*u2) * ChiR2 * ChiR2
+     df3 = (-u3*u3) * ChiR3 * ChiR3
+     Jv(2,0) = Jv(2,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dwl 
+     df1 = (u1) * ChiL1 * ChiR1
+     df2 = (u2) * ChiL2 * ChiR2
+     df3 = (u3) * ChiL3 * ChiR3
+     Jv(3,-1) = Jv(3,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dwc 
+     df1 = (u1) * ChiR1 * ChiR1
+     df2 = (u2) * ChiR2 * ChiR2
+     df3 = (u3) * ChiR3 * ChiR3
+     Jv(3,0) = Jv(3,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+
+     !    R_w = ((b-w)/ep - w*u) 
+     !     dR_w/dul 
+     df1 = (-w1) * ChiL1 * ChiR1
+     df2 = (-w2) * ChiL2 * ChiR2
+     df3 = (-w3) * ChiL3 * ChiR3
+     Jw(1,-1) = Jw(1,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_w/duc
+     df1 = (-w1) * ChiR1 * ChiR1
+     df2 = (-w2) * ChiR2 * ChiR2
+     df3 = (-w3) * ChiR3 * ChiR3
+     Jw(1,0) = Jw(1,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_w/dwl 
+     df1 = (-1.d0/ep - u1) * ChiL1 * ChiR1
+     df2 = (-1.d0/ep - u2) * ChiL2 * ChiR2
+     df3 = (-1.d0/ep - u3) * ChiL3 * ChiR3
+     Jw(3,-1) = Jw(3,-1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_w/dwc
+     df1 = (-1.d0/ep - u1) * ChiR1 * ChiR1
+     df2 = (-1.d0/ep - u2) * ChiR2 * ChiR2
+     df3 = (-1.d0/ep - u3) * ChiR3 * ChiR3
+     Jw(3,0) = Jw(3,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+
+     ! second compute dependence on values to center and right
+
+     !    evaluate relevant variables in right subinterval
+     u1 = Eval(uc, ur, xc, xr, X1(xc,xr))
+     v1 = Eval(vc, vr, xc, xr, X1(xc,xr))
+     w1 = Eval(wc, wr, xc, xr, X1(xc,xr))
+     u2 = Eval(uc, ur, xc, xr, X2(xc,xr))
+     v2 = Eval(vc, vr, xc, xr, X2(xc,xr))
+     w2 = Eval(wc, wr, xc, xr, X2(xc,xr))
+     u3 = Eval(uc, ur, xc, xr, X3(xc,xr))
+     v3 = Eval(vc, vr, xc, xr, X3(xc,xr))
+     w3 = Eval(wc, wr, xc, xr, X3(xc,xr))
+
+     dQdf1 = Quad(1.d0, 0.d0, 0.d0, xc, xr)
+     dQdf2 = Quad(0.d0, 1.d0, 0.d0, xc, xr)
+     dQdf3 = Quad(0.d0, 0.d0, 1.d0, xc, xr)
+
+     ChiL1 = ChiL(xc, xr, X1(xc,xr))
+     ChiL2 = ChiL(xc, xr, X2(xc,xr))
+     ChiL3 = ChiL(xc, xr, X3(xc,xr))
+     ChiR1 = ChiR(xc, xr, X1(xc,xr))
+     ChiR2 = ChiR(xc, xr, X2(xc,xr))
+     ChiR3 = ChiR(xc, xr, X3(xc,xr))
+
+
+     !    compute diffusion Jacobian components
+
+     !    L_u = -du * u_x * ChiL_x
+     !     dL_u/duc
+     Ju(1,0) = Ju(1,0) + (-du) * Quad(1.d0,1.d0,1.d0,xc,xr) * ChiL_x(xc,xr) * ChiL_x(xc,xr)
+
+     !     dL_u/dur
+     Ju(1,1) = Ju(1,1) + (-du) * Quad(1.d0,1.d0,1.d0,xc,xr) * ChiL_x(xc,xr) * ChiR_x(xc,xr)
+
+     !    L_v = -dv * v_x * ChiL_x
+     !     dL_v/dvc
+     Jv(2,0) = Jv(2,0) + (-dv) * Quad(1.d0,1.d0,1.d0,xc,xr) * ChiL_x(xc,xr) * ChiL_x(xc,xr)
+
+     !     dL_v/dvr
+     Jv(2,1) = Jv(2,1) + (-dv) * Quad(1.d0,1.d0,1.d0,xc,xr) * ChiL_x(xc,xr) * ChiR_x(xc,xr)
+
+     !    L_w =  -dw * w_x * ChiL_x
+     !     dL_w/dwc
+     Jw(3,0) = Jw(3,0) + (-dw) * Quad(1.d0,1.d0,1.d0,xc,xr) * ChiL_x(xc,xr) * ChiL_x(xc,xr)
+
+     !     dL_w/dwr
+     Jw(3,1) = Jw(3,1) + (-dw) * Quad(1.d0,1.d0,1.d0,xc,xr) * ChiL_x(xc,xr) * ChiR_x(xc,xr)
+
+
+     !    compute reaction Jacobian components
+
+     !    R_u = (a - (w+1.d0)*u + v*u*u) 
+     !     dR_u/duc
+     df1 = (-(w1+1.d0) + 2.d0*v1*u1) * ChiL1 * ChiL1
+     df2 = (-(w2+1.d0) + 2.d0*v2*u2) * ChiL2 * ChiL2
+     df3 = (-(w3+1.d0) + 2.d0*v3*u3) * ChiL3 * ChiL3
+     Ju(1,0) = Ju(1,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dur 
+     df1 = (-(w1+1.d0) + 2.d0*v1*u1) * ChiL1 * ChiR1
+     df2 = (-(w2+1.d0) + 2.d0*v2*u2) * ChiL2 * ChiR2
+     df3 = (-(w3+1.d0) + 2.d0*v3*u3) * ChiL3 * ChiR3
+     Ju(1,1) = Ju(1,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dvc
+     df1 = (u1*u1) * ChiL1 * ChiL1
+     df2 = (u2*u2) * ChiL2 * ChiL2
+     df3 = (u3*u3) * ChiL3 * ChiL3
+     Ju(2,0) = Ju(2,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dvr 
+     df1 = (u1*u1) * ChiL1 * ChiR1
+     df2 = (u2*u2) * ChiL2 * ChiR2
+     df3 = (u3*u3) * ChiL3 * ChiR3
+     Ju(2,1) = Ju(2,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dwc
+     df1 = (-u1) * ChiL1 * ChiL1
+     df2 = (-u2) * ChiL2 * ChiL2
+     df3 = (-u3) * ChiL3 * ChiL3
+     Ju(3,0) = Ju(3,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_u/dwr 
+     df1 = (-u1) * ChiL1 * ChiR1
+     df2 = (-u2) * ChiL2 * ChiR2
+     df3 = (-u3) * ChiL3 * ChiR3
+     Ju(3,1) = Ju(3,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+
+     !    R_v = (w*u - v*u*u) 
+     !     dR_v/duc
+     df1 = (w1 - 2.d0*v1*u1) * ChiL1 * ChiL1
+     df2 = (w2 - 2.d0*v2*u2) * ChiL2 * ChiL2
+     df3 = (w3 - 2.d0*v3*u3) * ChiL3 * ChiL3
+     Jv(1,0) = Jv(1,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dur 
+     df1 = (w1 - 2.d0*v1*u1) * ChiL1 * ChiR1
+     df2 = (w2 - 2.d0*v2*u2) * ChiL2 * ChiR2
+     df3 = (w3 - 2.d0*v3*u3) * ChiL3 * ChiR3
+     Jv(1,1) = Jv(1,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dvc
+     df1 = (-u1*u1) * ChiL1 * ChiL1
+     df2 = (-u2*u2) * ChiL2 * ChiL2
+     df3 = (-u3*u3) * ChiL3 * ChiL3
+     Jv(2,0) = Jv(2,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dvr 
+     df1 = (-u1*u1) * ChiL1 * ChiR1
+     df2 = (-u2*u2) * ChiL2 * ChiR2
+     df3 = (-u3*u3) * ChiL3 * ChiR3
+     Jv(2,1) = Jv(2,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dwc
+     df1 = (u1) * ChiL1 * ChiL1
+     df2 = (u2) * ChiL2 * ChiL2
+     df3 = (u3) * ChiL3 * ChiL3
+     Jv(3,0) = Jv(3,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_v/dwr 
+     df1 = (u1) * ChiL1 * ChiR1
+     df2 = (u2) * ChiL2 * ChiR2
+     df3 = (u3) * ChiL3 * ChiR3
+     Jv(3,1) = Jv(3,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+
+     !    R_w = ((b-w)/ep - w*u) 
+     !     dR_w/duc
+     df1 = (-w1) * ChiL1 * ChiL1
+     df2 = (-w2) * ChiL2 * ChiL2
+     df3 = (-w3) * ChiL3 * ChiL3
+     Jw(1,0) = Jw(1,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_w/dur 
+     df1 = (-w1) * ChiL1 * ChiR1
+     df2 = (-w2) * ChiL2 * ChiR2
+     df3 = (-w3) * ChiL3 * ChiR3
+     Jw(1,1) = Jw(1,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_w/dwc
+     df1 = (-1.d0/ep - u1) * ChiL1 * ChiL1
+     df2 = (-1.d0/ep - u2) * ChiL2 * ChiL2
+     df3 = (-1.d0/ep - u3) * ChiL3 * ChiL3
+     Jw(3,0) = Jw(3,0) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+     !     dR_w/dwr 
+     df1 = (-1.d0/ep - u1) * ChiL1 * ChiR1
+     df2 = (-1.d0/ep - u2) * ChiL2 * ChiR2
+     df3 = (-1.d0/ep - u3) * ChiL3 * ChiR3
+     Jw(3,1) = Jw(3,1) + dQdf1*df1 + dQdf2*df2 + dQdf3*df3
+
+
+     ! insert Jacobian entries into CSR matrix structure
+
+     !   Ju row
+     Jrowptrs(idx(ix,1)+1) = nz
+
+     Jdata(nz+1:nz+3) = (/ Ju(1,-1), Ju(2,-1), Ju(3,-1) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix-1,1), idx(ix-1,2), idx(ix-1,3) /)
+     nz = nz+3
+
+     Jdata(nz+1:nz+3) = (/ Ju(1,0), Ju(2,0), Ju(3,0) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix,1), idx(ix,2), idx(ix,3) /)
+     nz = nz+3
+
+     Jdata(nz+1:nz+3) = (/ Ju(1,1), Ju(2,1), Ju(3,1) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix+1,1), idx(ix+1,2), idx(ix+1,3) /)
+     nz = nz+3
+
+     !   Jv row
+     Jrowptrs(idx(ix,2)+1) = nz
+
+     Jdata(nz+1:nz+3) = (/ Jv(1,-1), Jv(2,-1), Jv(3,-1) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix-1,1), idx(ix-1,2), idx(ix-1,3) /)
+     nz = nz+3
+
+     Jdata(nz+1:nz+3) = (/ Jv(1,0), Jv(2,0), Jv(3,0) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix,1), idx(ix,2), idx(ix,3) /)
+     nz = nz+3
+
+     Jdata(nz+1:nz+3) = (/ Jv(1,1), Jv(2,1), Jv(3,1) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix+1,1), idx(ix+1,2), idx(ix+1,3) /)
+     nz = nz+3
+
+     !   Jw row
+     Jrowptrs(idx(ix,3)+1) = nz
+
+     Jdata(nz+1:nz+3) = (/ Jw(1,-1), Jw(2,-1), Jw(3,-1) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix-1,1), idx(ix-1,2), idx(ix-1,3) /)
+     nz = nz+3
+
+     Jdata(nz+1:nz+3) = (/ Jw(1,0), Jw(2,0), Jw(3,0) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix,1), idx(ix,2), idx(ix,3) /)
+     nz = nz+3
+
+     Jdata(nz+1:nz+3) = (/ Jw(1,1), Jw(2,1), Jw(3,1) /)
+     Jcolvals(nz+1:nz+3) = (/ idx(ix+1,1), idx(ix+1,2), idx(ix+1,3) /)
+     nz = nz+3
+
+
+  enddo
+
+  ! Dirichlet boundary at right
+  Jrowptrs(idx(N,1)+1) = nz
+  Jrowptrs(idx(N,2)+1) = nz
+  Jrowptrs(idx(N,3)+1) = nz
+ 
+  ! signal end of data in CSR matrix
+  Jrowptrs(idx(N,3)+2) = nz
+
+  ier = 0
+  return
+
+end subroutine farkspjac
+!-----------------------------------------------------------------
+
+
+
+subroutine farkspmass(t, neq, nnz, Mdata, Mcolvals, Mrowptrs, &
+                      ipar, rpar, wk1, wk2, wk3, ier)
+!-----------------------------------------------------------------
+! Mass matrix computation routine
+!-----------------------------------------------------------------
+  use UserData
+  use Quadrature
+  use FEM
+
+  ! Declarations
+  implicit none
+
+  ! Arguments
+  real*8,    intent(in)  :: t, rpar(1)
+  real*8,    intent(in), dimension(3,N) :: wk1, wk2, wk3
+  integer,   intent(in)  :: neq, nnz
+  integer*8, intent(in)  :: ipar(1)
+  real*8,    intent(out) :: Mdata(nnz)
+  integer,   intent(out) :: Mcolvals(nnz), Mrowptrs(neq+1), ier
+
+  ! Local data
+  integer :: ix, nz
+  real*8  :: xl, xc, xr, Ml, Mc, Mr, ChiL1, ChiL2, ChiL3, ChiR1, ChiR2, ChiR3
+  logical :: left, right
+
+  ! check that vector/matrix dimensions match up
+  if ((3*N /= neq) .or. (nnz /= 15*neq)) then
+     ier = 1
+     return
+  endif
+
+  ! clear out Jacobian matrix data
+  Mdata = 0.d0
+
+  ! iterate through nodes, filling in matrix by rows
+  nz = 0
+  do ix=1,N
+
+     ! set booleans to determine whether intervals exist on the left/right */
+     left  = .true.
+     right = .true.
+     if (ix==1)  left  = .false.
+     if (ix==N)  right = .false.
+
+     ! set nodal value shortcuts (interval index aligns with left node)
+     if (left) then
+        xl = x(ix-1)
+     endif
+     xc = x(ix)
+     if (right) then
+        xr = x(ix+1)
+     endif
+
+     ! compute entries of all mass matrix rows at node ix
+     Ml = 0.d0
+     Mc = 0.d0
+     Mr = 0.d0
+
+     ! first compute dependence on values to left and center
+     if (left) then
+
+        ChiL1 = ChiL(xl, xc, X1(xl,xc))
+        ChiL2 = ChiL(xl, xc, X2(xl,xc))
+        ChiL3 = ChiL(xl, xc, X3(xl,xc))
+        ChiR1 = ChiR(xl, xc, X1(xl,xc))
+        ChiR2 = ChiR(xl, xc, X2(xl,xc))
+        ChiR3 = ChiR(xl, xc, X3(xl,xc))
+
+        Ml = Ml + Quad(ChiL1*ChiR1, ChiL2*ChiR2, ChiL3*ChiR3, xl, xc)
+        Mc = Mc + Quad(ChiR1*ChiR1, ChiR2*ChiR2, ChiR3*ChiR3, xl, xc)
+
+     endif
+
+     ! second compute dependence on values to center and right
+     if (right) then
+
+        ChiL1 = ChiL(xc, xr, X1(xc,xr))
+        ChiL2 = ChiL(xc, xr, X2(xc,xr))
+        ChiL3 = ChiL(xc, xr, X3(xc,xr))
+        ChiR1 = ChiR(xc, xr, X1(xc,xr))
+        ChiR2 = ChiR(xc, xr, X2(xc,xr))
+        ChiR3 = ChiR(xc, xr, X3(xc,xr))
+
+        Mc = Mc + Quad(ChiL1*ChiL1, ChiL2*ChiL2, ChiL3*ChiL3, xc, xr)
+        Mr = Mr + Quad(ChiL1*ChiR1, ChiL2*ChiR2, ChiL3*ChiR3, xc, xr)
+
+     endif
+
+
+     ! insert mass matrix entries into CSR matrix structure
+
+     !   u row
+     Mrowptrs(idx(ix,1)+1) = nz
+     if (left) then
+        nz = nz+1
+        Mdata(nz) = Ml
+        Mcolvals(nz) = idx(ix-1,1)
+     endif
+     nz = nz+1
+     Mdata(nz) = Mc
+     Mcolvals(nz) = idx(ix,1)
+     if (right) then
+        nz = nz+1
+        Mdata(nz) = Mr
+        Mcolvals(nz) = idx(ix+1,1)
+     endif
+
+     !   v row
+     Mrowptrs(idx(ix,2)+1) = nz
+     if (left) then
+        nz = nz+1
+        Mdata(nz) = Ml
+        Mcolvals(nz) = idx(ix-1,2)
+     endif
+     nz = nz+1
+     Mdata(nz) = Mc
+     Mcolvals(nz) = idx(ix,2)
+     if (right) then
+        nz = nz+1
+        Mdata(nz) = Mr
+        Mcolvals(nz) = idx(ix+1,2)
+     endif
+
+     !   w row
+     Mrowptrs(idx(ix,3)+1) = nz
+     if (left) then
+        nz = nz+1
+        Mdata(nz) = Ml
+        Mcolvals(nz) = idx(ix-1,3)
+     endif
+     nz = nz+1
+     Mdata(nz) = Mc
+     Mcolvals(nz) = idx(ix,3)
+     if (right) then
+        nz = nz+1
+        Mdata(nz) = Mr
+        Mcolvals(nz) = idx(ix+1,3)
+     endif
+
+  enddo
+
+  ! signal end of data in CSR matrix
+  Mrowptrs(idx(N,3)+2) = nz
+
+  ier = 0
+  return
+
+end subroutine farkspmass
+!-----------------------------------------------------------------
diff --git a/examples/arkode/F90_serial/ark_bruss1D_FEM_klu.out b/examples/arkode/F90_serial/ark_bruss1D_FEM_klu.out
new file mode 100644
index 0000000..bfa0ac3
--- /dev/null
+++ b/examples/arkode/F90_serial/ark_bruss1D_FEM_klu.out
@@ -0,0 +1,56 @@
+ARKode solver parameters:
+  Method order 4
+  Dense output order 3
+  Implicit integrator
+  Time step adaptivity method 0
+     Safety factor = 0.96
+     Bias factor = 1.5
+     Growth factor = 20
+     Step growth lower bound = 1
+     Step growth upper bound = 1.5
+     k1 = 0.58
+     k2 = 0.21
+     k3 = 0.1
+  Solver relative tolerance = 1e-06
+  Solver absolute tolerance = 1e-11
+  Absolute residual tolerance = 1e-11
+  Maximum number of error test failures = 7
+  Maximum number of convergence test failures = 10
+  Maximum step increase (first step) = 10000
+  Step reduction factor on multiple error fails = 0.3
+  Minimum error fails before above factor is used = 2
+  Step reduction factor on nonlinear convergence failure = 0.25
+  Implicit predictor method = 0
+  Implicit solver tolerance coefficient = 0.1
+  Maximum number of nonlinear corrections = 3
+  Nonlinear convergence rate constant = 0.3
+  Nonlinear divergence tolerance = 2.3
+  Gamma factor LSetup tolerance = 0.2
+  Number of steps between LSetup calls = 20
+
+         t         ||u||_rms    ||v||_rms    ||w||_rms
+   ----------------------------------------------------
+    0.00000E+00  6.32978E-01  3.36571E+00  2.03247E+00
+    1.00000E+00  6.97285E-01  3.23962E+00  1.99999E+00
+    2.00000E+00  7.89501E-01  3.05139E+00  1.99999E+00
+    3.00000E+00  7.83681E-01  2.93001E+00  1.99999E+00
+    4.00000E+00  6.48122E-01  3.00833E+00  1.99999E+00
+    5.00000E+00  5.52223E-01  3.17028E+00  1.99999E+00
+    6.00000E+00  5.22111E-01  3.30889E+00  1.99999E+00
+    7.00000E+00  5.20869E-01  3.40614E+00  1.99999E+00
+    8.00000E+00  5.30276E-01  3.46669E+00  1.99999E+00
+    9.00000E+00  5.45196E-01  3.49456E+00  1.99999E+00
+    1.00000E+01  5.65426E-01  3.49094E+00  1.99999E+00
+   ----------------------------------------------------
+   
+ Final Solver Statistics:
+    Internal solver steps =                   104  (attempted =                  104 )
+    Total RHS evals:  Fe =                     0   Fi =                  1733
+    Total linear solver setups =                    48
+    Total RHS evals for setting up the linear system =                     0
+    Total number of Jacobian evaluations =                    11
+    Total number of nonlinear iterations =                  1209
+    Total number of nonlinear solver convergence failures =                     0
+    Total number of error test failures =                     0
+    Total number of mass matrix evaluations =                   157
+   
diff --git a/examples/arkode/F90_serial/plot_brusselator1D_FEM.py b/examples/arkode/F90_serial/plot_brusselator1D_FEM.py
new file mode 100755
index 0000000..47ad96e
--- /dev/null
+++ b/examples/arkode/F90_serial/plot_brusselator1D_FEM.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+# ------------------------------------------------------------
+# Programmer(s):  Daniel R. Reynolds @ SMU
+# ------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ------------------------------------------------------------
+# matplotlib-based plotting script for brusselator1D.c example
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load mesh data file
+mesh = np.loadtxt('bruss_FEM_mesh.txt', dtype=np.double)
+
+# load solution data files
+udata = np.loadtxt('bruss_FEM_u.txt', dtype=np.double)
+vdata = np.loadtxt('bruss_FEM_v.txt', dtype=np.double)
+wdata = np.loadtxt('bruss_FEM_w.txt', dtype=np.double)
+
+# determine number of time steps, mesh size
+nt,nx = np.shape(udata)
+
+# determine min/max values
+umin = 0.9*udata.min()
+umax = 1.1*udata.max()
+vmin = 0.9*vdata.min()
+vmax = 1.1*vdata.max()
+wmin = 0.9*wdata.min()
+wmax = 1.1*wdata.max()
+minval = np.array([umin, vmin, wmin]).min()
+maxval = np.array([umax, vmax, wmax]).max()
+
+# plot the mesh
+plt.figure(1)
+plt.plot(mesh,0.0*mesh,'o')
+plt.xlabel('x')
+plt.title('FEM mesh')
+plt.savefig('brusselator1D_FEM_mesh.png')
+
+# generate plots of results
+for tstep in range(nt):
+
+    # set string constants for output plots, current time, mesh size
+    pname = 'brusselator1D_FEM.' + repr(tstep).zfill(3) + '.png'
+    tstr  = repr(tstep)
+    nxstr = repr(nx)
+
+    # plot current solution and save to disk
+    plt.figure(1)
+    plt.plot(mesh,udata[tstep,:],label="u")
+    plt.plot(mesh,vdata[tstep,:],label="v")
+    plt.plot(mesh,wdata[tstep,:],label="w")
+    plt.xlabel('x')
+    plt.ylabel('solution')
+    plt.title('Solutions at output ' + tstr + ', mesh = ' + nxstr)
+    plt.axis((0.0, 1.0, minval, maxval))
+    plt.grid()
+    plt.legend(loc='upper right', shadow=True)
+    plt.savefig(pname)
+    plt.close()
+
+
+##### end of script #####
diff --git a/examples/arkode/F90_serial/plot_sol.py b/examples/arkode/F90_serial/plot_sol.py
new file mode 100755
index 0000000..554881c
--- /dev/null
+++ b/examples/arkode/F90_serial/plot_sol.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------
+# Programmer(s): Daniel R. Reynolds @ SMU
+# ----------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ----------------------------------------------------------------
+# matplotlib-based plotting script for ODE examples
+
+# imports
+import sys
+import pylab as plt
+import numpy as np
+
+# load solution data file
+data = np.loadtxt('solution.txt', dtype=np.double)
+
+# determine number of time steps, number of fields
+nt,nv = np.shape(data)
+
+# extract time array
+times = data[:,0]
+
+# parse comment line to determine solution names
+f = open('solution.txt', 'r')
+commentline = f.readline()
+commentsplit = commentline.split()
+names = commentsplit[2:]
+
+# create plot
+plt.figure()
+
+# add curves to figure
+for i in range(nv-1):
+    plt.plot(times,data[:,i+1],label=names[i])
+plt.xlabel('t')
+if (nv > 2):
+    plt.ylabel('solutions')
+else:
+    plt.ylabel('solution')
+plt.legend(loc='upper right', shadow=True)
+plt.grid()
+plt.savefig('solution.png')
+
+
+
+
+##### end of script #####
diff --git a/examples/cvode/C_openmp/CMakeLists.txt b/examples/cvode/C_openmp/CMakeLists.txt
new file mode 100644
index 0000000..ba4e164
--- /dev/null
+++ b/examples/cvode/C_openmp/CMakeLists.txt
@@ -0,0 +1,128 @@
+# ---------------------------------------------------------------
+# Programmer: Ting Yan @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for CVODE OpenMP examples
+
+# Only include tests if OpenMP is enabled
+IF(OPENMP_FOUND)
+
+# Add variable CVODE_examples_OMP with the names of the openmp CVODE examples
+SET(CVODE_examples_OMP
+  cvAdvDiff_bnd_omp
+  )
+
+ENDIF(OPENMP_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(CVODE_LIB sundials_cvode_static)
+  SET(NVECOMP_LIB sundials_nvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(CVODE_LIB sundials_cvode_shared)
+  SET(NVECOMP_LIB sundials_nvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${CVODE_LIB} ${NVECOMP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# update the compilation flags to include OpenMP support
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+
+# Add the build and install targets for each CVODE example
+FOREACH(example ${CVODE_examples_OMP})
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} TEST_ARGS 4)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/C_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${CVODE_examples_OMP})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/C_openmp)
+
+  # Install the extra files
+  FOREACH(extrafile ${CVODE_extras_OMP})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/C_openmp)
+  ENDFOREACH(extrafile ${CVODE_extras_OMP})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "CVODE")
+  SET(SOLVER_LIB "sundials_cvode")
+  LIST2STRING(CVODE_examples_OMP EXAMPLES)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/cvode/C_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/cvode/C_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/C_openmp 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/cvode/C_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/cvode/C_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/C_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/cvode/C_openmp/README b/examples/cvode/C_openmp/README
new file mode 100644
index 0000000..d372835
--- /dev/null
+++ b/examples/cvode/C_openmp/README
@@ -0,0 +1,49 @@
+List of C_openmp CVODE examples
+
+  cvAdvDiff_bnd_omp: banded example using OpenMP
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c b/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c
new file mode 100644
index 0000000..8e90c57
--- /dev/null
+++ b/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.c
@@ -0,0 +1,458 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *     Based on cvAdvDiff_bnd.c and parallelized with OpenMP
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * The following is a simple example problem with a banded Jacobian,
+ * with the program for its solution by CVODE.
+ * The problem is the semi-discrete form of the advection-diffusion
+ * equation in 2-D:
+ *   du/dt = d^2 u / dx^2 + .5 du/dx + d^2 u / dy^2
+ * on the rectangle 0 <= x <= 2, 0 <= y <= 1, and the time
+ * interval 0 <= t <= 1. Homogeneous Dirichlet boundary conditions
+ * are posed, and the initial condition is
+ *   u(x,y,t=0) = x(2-x)y(1-y)exp(5xy).
+ * The PDE is discretized on a uniform MX+2 by MY+2 grid with
+ * central differencing, and with boundary values eliminated,
+ * leaving an ODE system of size NEQ = MX*MY.
+ * This program solves the problem with the BDF method, Newton
+ * iteration with the CVBAND band linear solver, and a user-supplied
+ * Jacobian routine.
+ * It uses scalar relative and absolute tolerances.
+ * Output is printed at t = .1, .2, ..., 1.
+ * Run statistics (optional outputs) are printed at the end.
+ *
+ * Optionally, we can set the number of threads from environment 
+ * variable or command line. To check the current value for number
+ * of threads from environment:
+ *      % echo $OMP_NUM_THREADS
+ *
+ * Execution:
+ *
+ * If the user want to use the default value or the number of threads 
+ * from environment value:
+ *      % ./cvAdvDiff_bnd_omp 
+ * If the user want to specify the number of threads to use
+ *      % ./cvAdvDiff_bnd_omp num_threads
+ * where num_threads is the number of threads the user want to use 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+/* Header files with a description of contents used in cvbanx.c */
+
+#include <cvode/cvode.h>             /* prototypes for CVODE fcts., consts. */
+#include <cvode/cvode_band.h>        /* prototype for CVBand */
+#include <nvector/nvector_openmp.h>  /* serial N_Vector types, fcts., macros */
+#include <sundials/sundials_band.h>  /* definitions of type DlsMat and macros */
+#include <sundials/sundials_types.h> /* definition of type realtype */
+#include <sundials/sundials_math.h>  /* definition of ABS and EXP */
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+/* Problem Constants */
+
+#define XMAX  RCONST(2.0)    /* domain boundaries         */
+#define YMAX  RCONST(1.0)
+#define MX    10             /* mesh dimensions           */
+#define MY    5
+#define NEQ   MX*MY          /* number of equations       */
+#define ATOL  RCONST(1.0e-5) /* scalar absolute tolerance */
+#define T0    RCONST(0.0)    /* initial time              */
+#define T1    RCONST(0.1)    /* first output time         */
+#define DTOUT RCONST(0.1)    /* output time increment     */
+#define NOUT  10             /* number of output times    */
+
+#define ZERO RCONST(0.0)
+#define HALF RCONST(0.5)
+#define ONE  RCONST(1.0)
+#define TWO  RCONST(2.0)
+#define FIVE RCONST(5.0)
+
+/* User-defined vector access macro IJth */
+
+/* IJth is defined in order to isolate the translation from the
+   mathematical 2-dimensional structure of the dependent variable vector
+   to the underlying 1-dimensional storage. 
+   IJth(vdata,i,j) references the element in the vdata array for
+   u at mesh point (i,j), where 1 <= i <= MX, 1 <= j <= MY.
+   The vdata array is obtained via the macro call vdata = NV_DATA_S(v),
+   where v is an N_Vector. 
+   The variables are ordered by the y index j, then by the x index i. */
+
+#define IJth(vdata,i,j) (vdata[(j-1) + (i-1)*MY])
+
+/* Type : UserData (contains grid constants) */
+
+typedef struct {
+  realtype dx, dy, hdcoef, hacoef, vdcoef;
+  int nthreads;
+} *UserData;
+
+/* Private Helper Functions */
+
+static void SetIC(N_Vector u, UserData data);
+static void PrintHeader(realtype reltol, realtype abstol, realtype umax);
+static void PrintOutput(realtype t, realtype umax, long int nst);
+static void PrintFinalStats(void *cvode_mem);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
+static int Jac(long int N, long int mu, long int ml,
+               realtype t, N_Vector u, N_Vector fu, 
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/*
+ *-------------------------------
+ * Main Program
+ *-------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  realtype dx, dy, reltol, abstol, t, tout, umax;
+  N_Vector u;
+  UserData data;
+  void *cvode_mem;
+  int iout, flag;
+  long int nst;
+  int num_threads;
+
+  u = NULL;
+  data = NULL;
+  cvode_mem = NULL;
+
+  /* Set the number of threads to use */
+  num_threads = 1;     /* default value */
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();  /* Overwrite with OMP_NUM_THREADS environment variable */
+#endif
+  if (argc > 1)        /* overwrithe with command line value, if supplied */
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* Create a serial vector */
+
+  u = N_VNew_OpenMP(NEQ, num_threads);  /* Allocate u vector */
+  if(check_flag((void*)u, "N_VNew_OpenMP", 0)) return(1);
+
+  reltol = ZERO;  /* Set the tolerances */
+  abstol = ATOL;
+
+  data = (UserData) malloc(sizeof *data);  /* Allocate data memory */
+  if(check_flag((void *)data, "malloc", 2)) return(1);
+  dx = data->dx = XMAX/(MX+1);  /* Set grid coefficients in data */
+  dy = data->dy = YMAX/(MY+1);
+  data->hdcoef = ONE/(dx*dx);
+  data->hacoef = HALF/(TWO*dx);
+  data->vdcoef = ONE/(dy*dy);
+  data->nthreads = num_threads;
+
+  SetIC(u, data);  /* Initialize u vector */
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if(check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in u'=f(t,u), the inital time T0, and
+   * the initial dependent variable vector u. */
+  flag = CVodeInit(cvode_mem, f, T0, u);
+  if(check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeSStolerances to specify the scalar relative tolerance
+   * and scalar absolute tolerance */
+  flag = CVodeSStolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSStolerances", 1)) return(1);
+
+  /* Set the pointer to user-defined data */
+  flag = CVodeSetUserData(cvode_mem, data);
+  if(check_flag(&flag, "CVodeSetUserData", 1)) return(1);
+
+  /* Call CVBand to specify the CVBAND band linear solver */
+  flag = CVBand(cvode_mem, NEQ, MY, MY);
+  if(check_flag(&flag, "CVBand", 1)) return(1);
+
+  /* Set the user-supplied Jacobian routine Jac */
+  flag = CVDlsSetBandJacFn(cvode_mem, Jac);
+  if(check_flag(&flag, "CVDlsSetBandJacFn", 1)) return(1);
+
+  /* In loop over output points: call CVode, print results, test for errors */
+
+  umax = N_VMaxNorm(u);
+  PrintHeader(reltol, abstol, umax);
+  for(iout=1, tout=T1; iout <= NOUT; iout++, tout += DTOUT) {
+    flag = CVode(cvode_mem, tout, u, &t, CV_NORMAL);
+    if(check_flag(&flag, "CVode", 1)) break;
+    umax = N_VMaxNorm(u);
+    flag = CVodeGetNumSteps(cvode_mem, &nst);
+    check_flag(&flag, "CVodeGetNumSteps", 1);
+    PrintOutput(t, umax, nst);
+  }
+ 
+  PrintFinalStats(cvode_mem);  /* Print some final statistics   */
+  printf("num_threads = %i\n\n", num_threads);
+   
+
+  N_VDestroy_OpenMP(u);   /* Free the u vector */
+  CVodeFree(&cvode_mem);  /* Free the integrator memory */
+  free(data);             /* Free the user data */
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Functions called by the solver
+ *-------------------------------
+ */
+
+/* f routine. Compute f(t,u). */
+
+static int f(realtype t, N_Vector u,N_Vector udot, void *user_data)
+{
+  realtype uij, udn, uup, ult, urt, hordc, horac, verdc, hdiff, hadv, vdiff;
+  realtype *udata, *dudata;
+  int i, j;
+  UserData data;
+
+  udata = NV_DATA_OMP(u);
+  dudata = NV_DATA_OMP(udot);
+
+  /* Extract needed constants from data */
+
+  data = (UserData) user_data;
+  hordc = data->hdcoef;
+  horac = data->hacoef;
+  verdc = data->vdcoef;
+
+  /* Loop over all grid points. */
+#pragma omp parallel for default(shared) private(j, i, uij, udn, uup, ult, urt, hdiff, hadv, vdiff) num_threads(data->nthreads)
+  for (j=1; j <= MY; j++) {
+
+    for (i=1; i <= MX; i++) {
+
+      /* Extract u at x_i, y_j and four neighboring points */
+
+      uij = IJth(udata, i, j);
+      udn = (j == 1)  ? ZERO : IJth(udata, i, j-1);
+      uup = (j == MY) ? ZERO : IJth(udata, i, j+1);
+      ult = (i == 1)  ? ZERO : IJth(udata, i-1, j);
+      urt = (i == MX) ? ZERO : IJth(udata, i+1, j);
+
+      /* Set diffusion and advection terms and load into udot */
+
+      hdiff = hordc*(ult - TWO*uij + urt);
+      hadv = horac*(urt - ult);
+      vdiff = verdc*(uup - TWO*uij + udn);
+      IJth(dudata, i, j) = hdiff + hadv + vdiff;
+    }
+  }
+
+  return(0);
+}
+
+/* Jacobian routine. Compute J(t,u). */
+
+static int Jac(long int N, long int mu, long int ml,
+               realtype t, N_Vector u, N_Vector fu, 
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  long int i, j, k;
+  realtype *kthCol, hordc, horac, verdc;
+  UserData data;
+  
+  /*
+    The components of f = udot that depend on u(i,j) are
+    f(i,j), f(i-1,j), f(i+1,j), f(i,j-1), f(i,j+1), with
+      df(i,j)/du(i,j) = -2 (1/dx^2 + 1/dy^2)
+      df(i-1,j)/du(i,j) = 1/dx^2 + .25/dx  (if i > 1)
+      df(i+1,j)/du(i,j) = 1/dx^2 - .25/dx  (if i < MX)
+      df(i,j-1)/du(i,j) = 1/dy^2           (if j > 1)
+      df(i,j+1)/du(i,j) = 1/dy^2           (if j < MY)
+  */
+
+  data = (UserData) user_data;
+  hordc = data->hdcoef;
+  horac = data->hacoef;
+  verdc = data->vdcoef;
+
+#pragma omp parallel for collapse(2) default(shared) private(j, u, k, kthCol) num_threads(data->nthreads) 
+  for (j=1; j <= MY; j++) {
+    for (i=1; i <= MX; i++) {
+      k = j-1 + (i-1)*MY;
+      kthCol = BAND_COL(J,k);
+
+      /* set the kth column of J */
+
+      BAND_COL_ELEM(kthCol,k,k) = -TWO*(verdc+hordc);
+      if (i != 1)  BAND_COL_ELEM(kthCol,k-MY,k) = hordc + horac;
+      if (i != MX) BAND_COL_ELEM(kthCol,k+MY,k) = hordc - horac;
+      if (j != 1)  BAND_COL_ELEM(kthCol,k-1,k)  = verdc;
+      if (j != MY) BAND_COL_ELEM(kthCol,k+1,k)  = verdc;
+    }
+  }
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Private helper functions
+ *-------------------------------
+ */
+
+/* Set initial conditions in u vector */
+
+static void SetIC(N_Vector u, UserData data)
+{
+  int i, j;
+  realtype x, y, dx, dy;
+  realtype *udata;
+
+  /* Extract needed constants from data */
+
+  dx = data->dx;
+  dy = data->dy;
+
+  /* Set pointer to data array in vector u. */
+
+  udata = NV_DATA_OMP(u);
+
+  /* Load initial profile into u vector */
+#pragma omp parallel for default(shared) private(j, i, y, x)  
+  for (j=1; j <= MY; j++) {
+    y = j*dy;
+    for (i=1; i <= MX; i++) {
+      x = i*dx;
+      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*SUNRexp(FIVE*x*y);
+    }
+  }  
+}
+
+/* Print first lines of output (problem description) */
+
+static void PrintHeader(realtype reltol, realtype abstol, realtype umax)
+{
+  printf("\n2-D Advection-Diffusion Equation\n");
+  printf("Mesh dimensions = %d X %d\n", MX, MY);
+  printf("Total system size = %d\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerance parameters: reltol = %Lg   abstol = %Lg\n\n",
+         reltol, abstol);
+  printf("At t = %Lg      max.norm(u) =%14.6Le \n", T0, umax);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters: reltol = %g   abstol = %g\n\n",
+         reltol, abstol);
+  printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
+#else
+  printf("Tolerance parameters: reltol = %g   abstol = %g\n\n", reltol, abstol);
+  printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
+#endif
+
+  return;
+}
+
+/* Print current value */
+
+static void PrintOutput(realtype t, realtype umax, long int nst)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %4.2Lf   max.norm(u) =%14.6Le   nst = %4ld\n", t, umax, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
+#else
+  printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
+#endif
+
+  return;
+}
+
+/* Get and print some final statistics */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  int flag;
+  long int nst, nfe, nsetups, netf, nni, ncfn, nje, nfeLS;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  flag = CVDlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVDlsGetNumJacEvals", 1);
+  flag = CVDlsGetNumRhsEvals(cvode_mem, &nfeLS);
+  check_flag(&flag, "CVDlsGetNumRhsEvals", 1);
+
+  printf("\nFinal Statistics:\n");
+  printf("nst = %-6ld nfe  = %-6ld nsetups = %-6ld nfeLS = %-6ld nje = %ld\n",
+	 nst, nfe, nsetups, nfeLS, nje);
+  printf("nni = %-6ld ncfn = %-6ld netf = %ld\n",
+	 nni, ncfn, netf);
+
+  return;
+}
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+              funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.out b/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.out
new file mode 100644
index 0000000..9ae3816
--- /dev/null
+++ b/examples/cvode/C_openmp/cvAdvDiff_bnd_omp.out
@@ -0,0 +1,23 @@
+
+2-D Advection-Diffusion Equation
+Mesh dimensions = 10 X 5
+Total system size = 50
+Tolerance parameters: reltol = 0   abstol = 1e-05
+
+At t = 0      max.norm(u) =  8.954716e+01 
+At t = 0.10   max.norm(u) =  4.132889e+00   nst =   85
+At t = 0.20   max.norm(u) =  1.039294e+00   nst =  103
+At t = 0.30   max.norm(u) =  2.979829e-01   nst =  113
+At t = 0.40   max.norm(u) =  8.765774e-02   nst =  120
+At t = 0.50   max.norm(u) =  2.625637e-02   nst =  126
+At t = 0.60   max.norm(u) =  7.830425e-03   nst =  130
+At t = 0.70   max.norm(u) =  2.329387e-03   nst =  134
+At t = 0.80   max.norm(u) =  6.953434e-04   nst =  137
+At t = 0.90   max.norm(u) =  2.115983e-04   nst =  140
+At t = 1.00   max.norm(u) =  6.556853e-05   nst =  142
+
+Final Statistics:
+nst = 142    nfe  = 174    nsetups = 23     nfeLS = 0      nje = 3
+nni = 170    ncfn = 0      netf = 3
+num_threads = 4
+
diff --git a/examples/cvode/fcmix_parallel/CMakeLists.txt b/examples/cvode/fcmix_parallel/CMakeLists.txt
index 9a28aae..a7f83d6 100644
--- a/examples/cvode/fcmix_parallel/CMakeLists.txt
+++ b/examples/cvode/fcmix_parallel/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.5 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4957 $
+# $Date: 2016-09-23 12:21:47 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the FCVODE parallel examples
 
@@ -15,9 +20,9 @@
 # Add variable FCVODE_examples with the names of the parallel CVODE examples
 
 SET(FCVODE_examples
-  fcvDiag_non_p
-  fcvDiag_kry_bbd_p
-  fcvDiag_kry_p
+  "fcvDiag_non_p\;1\;2"
+  "fcvDiag_kry_bbd_p\;1\;2"
+  "fcvDiag_kry_p\;1\;2"
   )
 
 # Check whether we use MPI compiler scripts.
@@ -53,14 +58,31 @@ SET(FCVODE_LIB sundials_fcvode_static)
 
 SET(SUNDIALS_LIBS ${FCVODE_LIB} ${CVODE_LIB} ${FNVECP_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(HYPRE_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${HYPRE_LIBRARIES})
+ENDIF(HYPRE_FOUND)
+
 # Add the build and install targets for each CVODE example
 
-FOREACH(example ${FCVODE_examples})
+FOREACH(example_tuple ${FCVODE_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
   ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPIF77)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -68,7 +90,7 @@ FOREACH(example ${FCVODE_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/fcmix_parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${FCVODE_examples})
+ENDFOREACH(example_tuple ${FCVODE_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -79,8 +101,11 @@ IF(EXAMPLES_INSTALL)
   SET(SOLVER "CVODE")
   SET(SOLVER_LIB "sundials_cvode")
   SET(SOLVER_FLIB "sundials_fcvode")
-  LIST2STRING(FCVODE_examples EXAMPLES)
-
+  FOREACH(example_tuple ${FCVODE_examples})
+    list(GET example_tuple 0 example)
+    LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${FCVODE_examples})
+  
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
   # be used as a template for the user's own programs.
diff --git a/examples/cvode/fcmix_parallel/Makefile.in b/examples/cvode/fcmix_parallel/Makefile.in
deleted file mode 100644
index 835777b..0000000
--- a/examples/cvode/fcmix_parallel/Makefile.in
+++ /dev/null
@@ -1,116 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.11 $
-# $Date: 2009/03/11 23:20:14 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FCVODE parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-FFLAGS       = @FFLAGS@
-F77_LDFLAGS  = @F77_LDFLAGS@
-F77_LIBS     = @F77_LIBS@
-
-MPIF77       = @MPIF77@
-MPI_INC_DIR  = @MPI_INC_DIR@
-MPI_FLAGS    = @MPI_FLAGS@
-MPIF77_LNKR  = @MPIF77_LNKR@
-MPI_LIB_DIR  = @MPI_LIB_DIR@
-MPI_LIBS     = @MPI_LIBS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_LIBS = $(top_builddir)/src/cvode/fcmix/libsundials_fcvode.la     \
-                $(top_builddir)/src/cvode/libsundials_cvode.la            \
-                $(top_builddir)/src/nvec_par/libsundials_fnvecparallel.la \
-                $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-fortran-update = ${SHELL} ${top_builddir}/bin/fortran-update.sh
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = fcvDiag_non_p \
-	   fcvDiag_kry_bbd_p \
-	   fcvDiag_kry_p
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${MPIF77} ${MPI_FLAGS} -I${MPI_INC_DIR} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${MPIF77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${MPI_FLAGS} ${F77_LDFLAGS} ${SUNDIALS_LIBS} -L${MPI_LIB_DIR} ${MPI_LIBS} ${F77_LIBS} $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/cvode/fcmix_parallel
-	$(INSTALL_FILE) Makefile_ex  $(EXS_INSTDIR)/cvode/fcmix_parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_parallel/README  $(EXS_INSTDIR)/cvode/fcmix_parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_parallel/$${i}.f   $(EXS_INSTDIR)/cvode/fcmix_parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_parallel/$${i}.out $(EXS_INSTDIR)/cvode/fcmix_parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/cvode/fcmix_parallel/Makefile
-	rm -f $(EXS_INSTDIR)/cvode/fcmix_parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/cvode/fcmix_parallel/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/cvode/fcmix_parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode/fcmix_parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f *-updated.f
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/cvode/fcmix_parallel/README b/examples/cvode/fcmix_parallel/README
index 9fa0772..91a3525 100644
--- a/examples/cvode/fcmix_parallel/README
+++ b/examples/cvode/fcmix_parallel/README
@@ -4,14 +4,48 @@ List of parallel CVODE FCMIX examples
   fcvDiag_kry_bbd_p : diagonal ODE example - stiff case (BDF/SPGMR/FCVBBD)
   fcvDiag_kry_p     : diagonal ODE example - stiff case (BDF/SPGMR)
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvode/fcmix_parallel/fcvDiag_kry_bbd_p.f b/examples/cvode/fcmix_parallel/fcvDiag_kry_bbd_p.f
index 3d9f384..59a6168 100644
--- a/examples/cvode/fcmix_parallel/fcvDiag_kry_bbd_p.f
+++ b/examples/cvode/fcmix_parallel/fcvDiag_kry_bbd_p.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2009/03/11 23:18:28 $
+C     $Revision: 4074 $
+C     $Date: 2014-04-23 14:13:52 -0700 (Wed, 23 Apr 2014) $
 C     ----------------------------------------------------------------
 C     Diagonal ODE example.  Stiff case, with diagonal preconditioner.
 C     Uses FCVODE interfaces and FCVBBD interfaces.
@@ -13,17 +13,19 @@ C     Include MPI-Fortran header file for MPI_COMM_WORLD, MPI types.
 C
       INCLUDE "mpif.h"
 C
-      INTEGER*4 NLOCAL
+C The following declaration specification should match C type long int.
+      INTEGER*8 NLOCAL, NEQ, IOUT(25), IPAR(2), MUDQ, MLDQ, MU, ML
       PARAMETER (NLOCAL=10)   
 C
       INTEGER NOUT, LNST, LNFE, LNSETUP, LNNI, LNCF, LNETF, LNPE
       INTEGER LNLI, LNPS, LNCFL, MYPE, IER, NPES, METH, ITMETH
       INTEGER LLENRW, LLENIW, LLENRWLS, LLENIWLS
       INTEGER IATOL, ITASK, IPRE, IGS, JOUT
-      INTEGER*4 IOUT(25), IPAR(2)
-      INTEGER*4 NEQ, I, MUDQ, MLDQ, MU, ML, NETF
-      INTEGER*4 NST, NFE, NPSET, NPE, NPS, NNI, NLI, NCFN, NCFL, NGEBBD
-      INTEGER*4 LENRW, LENIW, LENRWLS, LENIWLS, LENRWBBD, LENIWBBD
+      INTEGER I, NETF
+C The following declaration specification should match C type long int.
+      INTEGER*8 LENRWBBD, LENIWBBD, NGEBBD
+      INTEGER NST, NFE, NPSET, NPE, NPS, NNI, NLI, NCFN, NCFL
+      INTEGER LENRW, LENIW, LENRWLS, LENIWLS
       DOUBLE PRECISION Y(1024), ROUT(10), RPAR(1)
       DOUBLE PRECISION ALPHA, TOUT, ERMAX, AVDIM
       DOUBLE PRECISION ATOL, ERRI, RTOL, GERMAX, DTOUT, T
@@ -264,11 +266,10 @@ C
 C     Routine for right-hand side function f
       IMPLICIT NONE
 C
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER, MYPE, I, NLOCAL
       DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
-C
-      INTEGER MYPE
-      INTEGER*4 I, NLOCAL
       DOUBLE PRECISION ALPHA
 C     
       NLOCAL = IPAR(1)
@@ -290,7 +291,9 @@ C
 C     Routine to define local approximate function g, here the same as f. 
       IMPLICIT NONE
 C
-      INTEGER*4 NLOC, IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 NLOC, IPAR(*)
+      INTEGER IER
       DOUBLE PRECISION T, YLOC(*), GLOC(*), RPAR(*)
 C     
       CALL FCVFUN(T, YLOC, GLOC, IPAR, RPAR, IER)
diff --git a/examples/cvode/fcmix_parallel/fcvDiag_kry_p.f b/examples/cvode/fcmix_parallel/fcvDiag_kry_p.f
index 35e7143..7decedc 100644
--- a/examples/cvode/fcmix_parallel/fcvDiag_kry_p.f
+++ b/examples/cvode/fcmix_parallel/fcvDiag_kry_p.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2009/03/11 23:17:13 $
+C     $Revision: 4074 $
+C     $Date: 2014-04-23 14:13:52 -0700 (Wed, 23 Apr 2014) $
 C     ----------------------------------------------------------------
 C     Diagonal ODE example. Stiff case, with BDF/SPGMR, diagonal
 C     preconditioner. Solved with preconditioning on left, then with
@@ -13,15 +13,15 @@ C
 C
       INCLUDE "mpif.h"
 C
-      INTEGER*4 NLOCAL
+C The following declaration specification should match C type long int.
+      INTEGER*8 NLOCAL, NEQ, IOUT(25), IPAR(2)
       PARAMETER (NLOCAL=10)
 C
       INTEGER LNST, LNFE, LNSETUP, LNNI, LNCF, LNETF, LNPE, LNLI, LNPS
       INTEGER LNCFL, NOUT, MYPE, NPES, IER, METH, ITMETH, IATOL
       INTEGER ITASK, IPRE, IGS, JOUT
-      INTEGER*4 IOUT(25), IPAR(2)
-      INTEGER*4 NEQ, I, NST, NFE, NPSET, NPE, NPS, NNI, NLI
-      INTEGER*4 NCFL, NETF, NCFN
+      INTEGER I, NST, NFE, NPSET, NPE, NPS, NNI, NLI
+      INTEGER NCFL, NETF, NCFN
       DOUBLE PRECISION Y(1024), ROUT(10), RPAR(1)
       DOUBLE PRECISION ATOL, DTOUT, T, ALPHA, RTOL, TOUT, ERMAX, ERRI
       DOUBLE PRECISION GERMAX, AVDIM
@@ -278,10 +278,10 @@ C
 C     Routine for right-hand side function f
       IMPLICIT NONE
 C
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER, I, MYPE, NLOCAL
       DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
-C
-      INTEGER*4 I, MYPE, NLOCAL
       DOUBLE PRECISION ALPHA
 C
       NLOCAL = IPAR(1)
@@ -309,13 +309,12 @@ C     The vector r is copied to z, and the inverse of P (restricted to the
 C     local vector segment) is applied to the vector z.
       IMPLICIT NONE
 C
-      INTEGER IER, LR
-      INTEGER*4 IPAR(*)
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER, LR, I, MYPE, NLOCAL, ISTART, IBASE 
       DOUBLE PRECISION T, Y(*), FY(*), R(*), Z(*)
       DOUBLE PRECISION GAMMA, DELTA, RPAR(*)
       DOUBLE PRECISION VTEMP(*)
-C
-      INTEGER*4 I, MYPE, NLOCAL, ISTART, IBASE
       DOUBLE PRECISION PSUBI, ALPHA
 C
       NLOCAL = IPAR(1)
@@ -340,7 +339,7 @@ C     ------------------------------------------------------------------------
 C
       SUBROUTINE FCVPSET(T, Y, FY, JOK, JCUR, GAMMA, H,
      &                   IPAR, RPAR, V1, V2, V3, IER)
-C     Empty function. Not needed for the preconditioner, but required
-C     by the  FCVODE module.
+C     Empty subroutine. Not needed for the preconditioner, but required
+C     by the FCVODE module.
       RETURN
       END
diff --git a/examples/cvode/fcmix_parallel/fcvDiag_non_p.f b/examples/cvode/fcmix_parallel/fcvDiag_non_p.f
index 21492e2..59fdf85 100644
--- a/examples/cvode/fcmix_parallel/fcvDiag_non_p.f
+++ b/examples/cvode/fcmix_parallel/fcvDiag_non_p.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2009/03/11 23:16:06 $
+C     $Revision: 4074 $
+C     $Date: 2014-04-23 14:13:52 -0700 (Wed, 23 Apr 2014) $
 C     ----------------------------------------------------------------
 C     Diagonal ODE example. Nonstiff case: alpha = 10/NEQ.
 C     ----------------------------------------------------------------
@@ -11,13 +11,13 @@ C
 C
       INCLUDE "mpif.h"
 C
-      INTEGER*4 NLOCAL
+C The following declaration specification should match C type long int.
+      INTEGER*8 NLOCAL, NEQ, IOUT(25), IPAR(2)
       PARAMETER (NLOCAL=2)
 C
       INTEGER IER, MYPE, NPES, NOUT, LNST, LNFE, LNNI, LNCF, LNETF
       INTEGER METH, ITMETH, IATOL, ITASK, JOUT
-      INTEGER*4 NEQ, I, NST, NFE, NNI, NCFN, NETF
-      INTEGER*4 IOUT(25), IPAR(2)
+      INTEGER I, NST, NFE, NNI, NCFN, NETF
       DOUBLE PRECISION Y(128), ROUT(10), RPAR(1)
       DOUBLE PRECISION ATOL, RTOL, DTOUT, T, ALPHA, TOUT
       DOUBLE PRECISION ERMAX, ERRI, GERMAX
@@ -170,11 +170,10 @@ C     Routine for right-hand side function f
 C
       IMPLICIT NONE
 C
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER, MYPE, NLOCAL, I
       DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
-C
-      INTEGER MYPE
-      INTEGER*4 NLOCAL, I
       DOUBLE PRECISION ALPHA
 C
       NLOCAL = IPAR(1)
diff --git a/examples/cvode/fcmix_serial/CMakeLists.txt b/examples/cvode/fcmix_serial/CMakeLists.txt
index b91c508..cde8e0a 100644
--- a/examples/cvode/fcmix_serial/CMakeLists.txt
+++ b/examples/cvode/fcmix_serial/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.5 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4957 $
+# $Date: 2016-09-23 12:21:47 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the FCVODE serial examples
 
@@ -21,6 +26,14 @@ SET(FCVODE_examples
   fcvRoberts_dns
   )
 
+SET(FCVODE_examples_KLU
+  fcvRoberts_klu
+  )
+
+SET(FCVODE_examples_SUPERLUMT
+  fcvRoberts_sps
+  )
+
 # Add variable fcvode_bl_examples with the names of the serial FCVODE examples
 # that use Lapack
 
@@ -49,14 +62,27 @@ SET(FCVODE_LIB sundials_fcvode_static)
 
 SET(SUNDIALS_LIBS ${FCVODE_LIB} ${CVODE_LIB} ${FNVECS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(HYPRE_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${HYPRE_LIBRARIES})
+ENDIF(HYPRE_FOUND)
+
 # Add the build and install targets for each FCVODE example
 
 FOREACH(example ${FCVODE_examples})
   ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/fcmix_serial)
@@ -68,6 +94,8 @@ ENDFOREACH(example ${FCVODE_examples})
 IF(LAPACK_FOUND)
   FOREACH(example ${FCVODE_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     IF(EXAMPLES_INSTALL)
       INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/fcmix_serial)
@@ -75,6 +103,34 @@ IF(LAPACK_FOUND)
   ENDFOREACH(example ${FCVODE_examples_BL})
 ENDIF(LAPACK_FOUND)
 
+# If KLU support is enabled, add the build and install targets for
+# the examples using KLU
+IF(KLU_FOUND)
+  FOREACH(example ${FCVODE_examples_KLU})
+    ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/fcmix_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${FCVODE_examples_KLU})
+ENDIF(KLU_FOUND)
+
+# If SUPERLUMT support is enabled, add the build and install targets for
+# the examples using SUPERLUMT
+IF(SUPERLUMT_FOUND)
+  FOREACH(example ${FCVODE_examples_SUPERLUMT})
+    ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/fcmix_serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${FCVODE_examples_SUPERLUMT})
+ENDIF(SUPERLUMT_FOUND)
+
 IF(EXAMPLES_INSTALL)
 
   # Install the README file
@@ -90,7 +146,15 @@ IF(EXAMPLES_INSTALL)
   ELSE(LAPACK_FOUND)
     SET(EXAMPLES_BL "")
   ENDIF(LAPACK_FOUND)
-
+  
+  IF(KLU_FOUND)
+    LIST2STRING(FCVODE_examples_KLU EXAMPLES)
+  ENDIF(KLU_FOUND)
+  
+  IF(SUPERLUMT_FOUND)
+    LIST2STRING(FCVODE_examples_SUPERLUMT EXAMPLES)
+  ENDIF(SUPERLUMT_FOUND)
+  
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
   # be used as a template for the user's own programs.
diff --git a/examples/cvode/fcmix_serial/Makefile.in b/examples/cvode/fcmix_serial/Makefile.in
deleted file mode 100644
index abce19d..0000000
--- a/examples/cvode/fcmix_serial/Makefile.in
+++ /dev/null
@@ -1,137 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.11 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FCVODE serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-F77          = @F77@
-FFLAGS       = @FFLAGS@
-F77_LNKR     = @F77_LNKR@
-F77_LDFLAGS  = @F77_LDFLAGS@
-F77_LIBS     = @F77_LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_LIBS = $(top_builddir)/src/cvode/fcmix/libsundials_fcvode.la       \
-                $(top_builddir)/src/cvode/libsundials_cvode.la              \
-                $(top_builddir)/src/nvec_ser/libsundials_fnvecserial.la     \
-                $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-fortran-update = ${SHELL} ${top_builddir}/bin/fortran-update.sh
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = fcvAdvDiff_bnd \
-	   fcvDiurnal_kry_bp \
-	   fcvDiurnal_kry \
-	   fcvRoberts_dns
-
-EXAMPLES_BL = fcvRoberts_dnsL
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${F77} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${F77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${F77_LDFLAGS} ${SUNDIALS_LIBS} ${F77_LIBS} ${BLAS_LAPACK_LIBS} ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${F77} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${F77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${F77_LDFLAGS} ${SUNDIALS_LIBS} ${F77_LIBS} ${BLAS_LAPACK_LIBS} ; \
-	done ; \
-	fi
-
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/cvode/fcmix_serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/cvode/fcmix_serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_serial/README $(EXS_INSTDIR)/cvode/fcmix_serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_serial/$${i}.f   $(EXS_INSTDIR)/cvode/fcmix_serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_serial/$${i}.out $(EXS_INSTDIR)/cvode/fcmix_serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_serial/$${i}.f   $(EXS_INSTDIR)/cvode/fcmix_serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/fcmix_serial/$${i}.out $(EXS_INSTDIR)/cvode/fcmix_serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/cvode/fcmix_serial/Makefile
-	rm -f $(EXS_INSTDIR)/cvode/fcmix_serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/cvode/fcmix_serial/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/cvode/fcmix_serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/cvode/fcmix_serial/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/cvode/fcmix_serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode/fcmix_serial
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f *-updated.f
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/cvode/fcmix_serial/README b/examples/cvode/fcmix_serial/README
index 9eda1c6..26be76c 100644
--- a/examples/cvode/fcmix_serial/README
+++ b/examples/cvode/fcmix_serial/README
@@ -6,13 +6,48 @@ List of serial CVODE FCMIX examples
   fcvRoberts_dns     : chemical kinetics example (BDF/DENSE)
   fcvRoberts_dnsL    : chemical kinetics example (BDF/DENSE lapack)
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvode/fcmix_serial/fcvAdvDiff_bnd.f b/examples/cvode/fcmix_serial/fcvAdvDiff_bnd.f
index 6824c63..dd4ac45 100644
--- a/examples/cvode/fcmix_serial/fcvAdvDiff_bnd.f
+++ b/examples/cvode/fcmix_serial/fcvAdvDiff_bnd.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2007/10/25 20:03:27 $
+C     $Revision: 4294 $
+C     $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
 C     ----------------------------------------------------------------
 C     FCVODE Example Problem: Advection-diffusion, banded user
 C     Jacobian.
@@ -25,25 +25,26 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-      INTEGER*4 MX, MY, NEQ
+      INTEGER MX, MY, MXMY
       PARAMETER (MX=10, MY=5)
-      PARAMETER (NEQ=MX*MY)
+      PARAMETER (MXMY=MX*MY)
 C     
       DOUBLE PRECISION XMAX, YMAX
       DATA XMAX/2.0D0/, YMAX/1.0D0/
 C
       INTEGER LNST, LNFE, LNSETUP, LNNI, LNCF, LNETF, LNJE
       INTEGER IER, METH, ITMETH, IATOL, ITASK, JOUT
-      INTEGER*4 IOUT(25), IPAR(2)
-      INTEGER*4 MU, ML
+C The following declaration specification should match C type long int.
+      INTEGER*8 NEQ, IOUT(25), IPAR(2), MU, ML
       DOUBLE PRECISION RTOL, ATOL, T0, T, TOUT, DTOUT, UNORM 
-      DOUBLE PRECISION U(NEQ), ROUT(10), RPAR(5)
+      DOUBLE PRECISION U(MXMY), ROUT(10), RPAR(5)
 C
       DATA LNST/3/, LNFE/4/, LNETF/5/,  LNCF/6/, LNNI/7/, LNSETUP/8/, 
      1     LNJE/17/
 C
       CALL INITBX(XMAX, YMAX, MX, MY, U, IPAR, RPAR)
-C     
+C
+      NEQ = MX*MY
       T0 = 0.0D0
       METH = 2
       ITMETH = 2
@@ -129,10 +130,12 @@ C     ----------------------------------------------------------------
 C Load IPAR and RPAR with problem constants and U0 with initial values
       IMPLICIT NONE
 C
-      INTEGER*4 MX, MY, IPAR(*)
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER MX, MY
       DOUBLE PRECISION XMAX, YMAX, U0(MY,MX), RPAR(*)
 C
-      INTEGER*4 I, J
+      INTEGER I, J
       DOUBLE PRECISION DX, DY, X, Y, HDCOEF, HACOEF, VDCOEF
 C
 C Problem constants
@@ -167,7 +170,7 @@ C
 C Compute max-norm of array U
       IMPLICIT NONE
 C
-      INTEGER*4 I, N
+      INTEGER*8 I, N
       DOUBLE PRECISION U(*), UNORM, TEMP
 C
       TEMP = 0.0D0
@@ -185,13 +188,15 @@ C Right-hand side routine
       IMPLICIT NONE
 C
       DOUBLE PRECISION T, U(*), UDOT(*), RPAR(*)
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER
 C
-      INTEGER*4 I, MX, IOFF, MY, J, IJ
+      INTEGER I, MX, IOFF, MY, J, IJ
       DOUBLE PRECISION UIJ, UDN, UUP, ULT, URT, HDIFF, HADV, VDIFF
       DOUBLE PRECISION DX, DY, HDCOEF, HACOEF, VDCOEF
 C
-C Exract constants from IPAR and RPAR
+C Extract constants from IPAR and RPAR
       MX     = IPAR(1)
       MY     = IPAR(2)
       DX     = RPAR(1)
@@ -237,16 +242,17 @@ C     ----------------------------------------------------------------
 C Load banded Jacobian
       IMPLICIT NONE
 C
-      INTEGER N, MU, ML, MDIM
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 N, MU, ML, MDIM, IPAR(*)
+      INTEGER IER
       DOUBLE PRECISION T, U(*), FU(*), BJAC(MDIM,*), H, RPAR(*)
       DOUBLE PRECISION V1(*), V2(*), V3(*)
 C
-      INTEGER*4 MBAND, MX, MY
-      INTEGER*4 I, J, K, IOFF, MU1, MU2
+      INTEGER MBAND, MX, MY
+      INTEGER I, J, K, IOFF, MU1, MU2
       DOUBLE PRECISION DX, DY, HDCOEF, HACOEF, VDCOEF
 C
-C Exract constants from IPAR and RPAR
+C Extract constants from IPAR and RPAR
       MX     = IPAR(1)
       MY     = IPAR(2)
       DX     = RPAR(1)
diff --git a/examples/cvode/fcmix_serial/fcvDiurnal_kry.f b/examples/cvode/fcmix_serial/fcvDiurnal_kry.f
index 00c6d8e..e823741 100644
--- a/examples/cvode/fcmix_serial/fcvDiurnal_kry.f
+++ b/examples/cvode/fcmix_serial/fcvDiurnal_kry.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2007/10/25 20:03:27 $
+C     $Revision: 4838 $
+C     $Date: 2016-08-03 10:10:51 -0700 (Wed, 03 Aug 2016) $
 C     ----------------------------------------------------------------
 C     FCVODE Example Problem: 2D kinetics-transport, precond. Krylov
 C     solver. 
@@ -26,8 +26,9 @@ C     The problem is solved with CVODE, with the BDF/GMRES method and
 C     the block-diagonal part of the Jacobian as a left
 C     preconditioner.
 C     
-C     Note: this program requires the dense linear solver routines
-C     DGEFA and DGESL from LINPACK, and BLAS routines DCOPY and DSCAL.
+C     Note: this program includes modified (64-bit integer) versions 
+C     of the dense linear solver routines DGEFA and DGESL from LINPACK, 
+C     and BLAS routines DCOPY and DSCAL.
 C     
 C     The second and third dimensions of U here must match the values
 C     of MX and MY, for consistency with the output statements
@@ -36,18 +37,18 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-      INTEGER*4 MX, MY, NEQ
+      INTEGER MX, MY
       PARAMETER (MX=10, MY=10)
-      PARAMETER (NEQ=2*MX*MY)
-      INTEGER*4 LENIPAR, LENRPAR
+      INTEGER LENIPAR, LENRPAR
       PARAMETER (LENIPAR=6+2*MX*MY, LENRPAR=12+8*MX*MY)
 C
       INTEGER METH,ITMETH,IATOL,ITASK,IER,LNCFL,LNPS
       INTEGER LNST,LNFE,LNSETUP,LNNI,LNCF,LQ,LH,LNPE,LNLI,LNETF
       INTEGER JOUT,JPRETYPE,IGSTYPE,MAXL
-      INTEGER*4 IOUT(25),IPAR(LENIPAR)
-      INTEGER*4 NST,NFE,NPSET,NPE,NPS,NNI,NETF
-      INTEGER*4 NLI,NCFN,NCFL
+C The following declaration specification should match C type long int.
+      INTEGER*8 NEQ, IOUT(25), IPAR(LENIPAR)
+      INTEGER NST,NFE,NPSET,NPE,NPS,NNI,NETF
+      INTEGER NLI,NCFN,NCFL
       DOUBLE PRECISION ATOL,AVDIM,T,TOUT,TWOHR,RTOL,FLOOR,DELT
       DOUBLE PRECISION U(2,MX,MY),ROUT(10),RPAR(LENRPAR)
 C
@@ -61,6 +62,7 @@ C     Load problem constants into IPAR, RPAR, and set initial values
       CALL INITKX(MX, MY, U, IPAR, RPAR)
 C
 C     Set other input arguments.
+      NEQ = 2*MX*MY
       T = 0.0D0
       METH = 2
       ITMETH = 2
@@ -163,10 +165,12 @@ C     Routine to set problem constants and initial values
 C
       IMPLICIT NONE
 C
-      INTEGER*4 MX, MY, IPAR(*)
+      INTEGER MX, MY
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
       DOUBLE PRECISION RPAR(*)
 C
-      INTEGER*4 MM, JY, JX, P_IPP, P_BD, P_P
+      INTEGER MM, JY, JX, P_IPP, P_BD, P_P
       DOUBLE PRECISION U0
       DIMENSION U0(2,MX,MY)
       DOUBLE PRECISION Q1, Q2, Q3, Q4, A3, A4, OM, C3, DY, HDCO
@@ -180,6 +184,8 @@ C     Problem constants
       MM = MX * MY
       Q1 = 1.63D-16
       Q2 = 4.66D-16
+      Q3 = 0.0D0
+      Q4 = 0.0D0
       A3 = 22.62D0
       A4 = 7.601D0
       OM = PI / HALFDA
@@ -242,10 +248,12 @@ C
       IMPLICIT NONE
 C
       DOUBLE PRECISION T, U(2,*), UDOT(2,*), RPAR(*)
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER
 C
       INTEGER ILEFT, IRIGHT
-      INTEGER*4 JX, JY, MX, MY, MM, IBLOK0, IBLOK, IDN, IUP
+      INTEGER JX, JY, MX, MY, MM, IBLOK0, IBLOK, IDN, IUP
       DOUBLE PRECISION Q1, Q2, Q3, Q4, A3, A4, OM, C3, DY, HDCO
       DOUBLE PRECISION VDCO, HACO
       DOUBLE PRECISION C1, C2, C1DN, C2DN, C1UP, C2UP, C1LT, C2LT
@@ -347,10 +355,11 @@ C
 C
       INTEGER IER, JOK, JCUR
       DOUBLE PRECISION T, U(2,*), FU(*), GAMMA, H
-      INTEGER*4 IPAR(*)
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
       DOUBLE PRECISION RPAR(*), V1(*), V2(*), V3(*)
 C
-      INTEGER*4 MX, MY, MM, P_IPP, P_BD, P_P
+      INTEGER MX, MY, MM, P_IPP, P_BD, P_P
       DOUBLE PRECISION Q1, Q2, Q3, Q4, C3, DY, HDCO, VDCO
 C
       IER = 0
@@ -408,12 +417,13 @@ C
       IMPLICIT NONE
 C
       INTEGER IER, LR
-      INTEGER*4 IPAR(*)
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
       DOUBLE PRECISION T, U(*), FU(*), R(*), Z(2,*)
       DOUBLE PRECISION GAMMA, DELTA, RPAR(*)
       DOUBLE PRECISION VTEMP(*)
 C
-      INTEGER*4 MM, P_IPP, P_P
+      INTEGER MM, P_IPP, P_P
 C
       IER = 0
 C
@@ -442,11 +452,11 @@ C     Routine to compute diagonal Jacobian blocks
 C
       IMPLICIT NONE
 C
-      INTEGER*4 MX, MY, MM
+      INTEGER MX, MY, MM
       DOUBLE PRECISION U(2,*), BD(2,2,MM)
       DOUBLE PRECISION Q1, Q2, Q3, Q4, C3, DY, HDCO, VDCO
 C
-      INTEGER*4 JY, JX, IBLOK, IBLOK0
+      INTEGER JY, JX, IBLOK, IBLOK0
       DOUBLE PRECISION C1, C2, CYDN, CYUP, DIAG, YDN, YUP
 C
       DO JY = 1, MY
@@ -478,10 +488,11 @@ C
       IMPLICIT NONE
 C
       INTEGER IER
-      INTEGER*4 MM, IPP(2,MM)
+      INTEGER MM
+      INTEGER*8 IPP(2,MM)
       DOUBLE PRECISION P(2,2,MM)
 C
-      INTEGER*4 I
+      INTEGER I
 C
 C     Add identity matrix and do LU decompositions on blocks, in place.
       DO I = 1, MM
@@ -501,10 +512,11 @@ C     Routine for backsolve
 C
       IMPLICIT NONE
 C
-      INTEGER*4 MM, IPP(2,MM)
+      INTEGER MM
+      INTEGER*8 IPP(2,MM)
       DOUBLE PRECISION P(2,2,MM), Z(2,MM)
 C      
-      INTEGER*4 I
+      INTEGER I
 C
       DO I = 1, MM
          CALL DGESL(P(1,1,I), 2, 2, IPP(1,I), Z(1,I), 0)
@@ -520,7 +532,8 @@ c
       implicit none
 c
       integer info, idamax, j, k, kp1, l, nm1, n
-      integer*4 lda, ipvt(1)
+      integer*4 lda
+      integer*8 ipvt(1)
       double precision a(lda,1), t
 c
 c     dgefa factors a double precision matrix by gaussian elimination.
@@ -626,7 +639,7 @@ c
       implicit none
 c
       integer lda, n, job, k, kb, l, nm1
-      integer*4 ipvt(1)
+      integer*8 ipvt(1)
       double precision a(lda,1), b(1), ddot, t
 c
 c     dgesl solves the double precision system
diff --git a/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.f b/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.f
index 77fc17f..dd5b57b 100644
--- a/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.f
+++ b/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2007/10/25 20:03:27 $
+C     $Revision: 4294 $
+C     $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
 C     ----------------------------------------------------------------
 C     FCVODE Example Problem: 2D kinetics-transport, 
 C     precond. Krylov solver. 
@@ -32,18 +32,20 @@ C     ----------------------------------------------------------------
 C
       IMPLICIT NONE
 C
-      INTEGER*4 MX, MY, NEQ
+      INTEGER MX, MY
       PARAMETER (MX=10, MY=10)
-      PARAMETER (NEQ=2*MX*MY)
 C
       INTEGER LNST, LNFE, LNSETUP, LNNI, LNCF, LNPE, LNLI, LNPS
       INTEGER LNCFL, LH, LQ, METH, ITMETH, IATOL, ITASK
       INTEGER LNETF, IER, MAXL, JPRETYPE, IGSTYPE, JOUT
       INTEGER LLENRW, LLENIW, LLENRWLS, LLENIWLS
-      INTEGER*4 IOUT(25), IPAR(4)
-      INTEGER*4 NST, NFE, NPSET, NPE, NPS, NNI
-      INTEGER*4 NLI, NCFN, NCFL, NETF, MU, ML
-      INTEGER*4 LENRW, LENIW, LENRWLS, LENIWLS, LENRWBP, LENIWBP, NFEBP
+C The following declaration specification should match C type long int.
+      INTEGER*8 NEQ, IOUT(25), IPAR(4)
+      INTEGER NST, NFE, NPSET, NPE, NPS, NNI
+      INTEGER NLI, NCFN, NCFL, NETF
+      INTEGER LENRW, LENIW, LENRWLS, LENIWLS
+C The following declaration specification should match C type long int.
+      INTEGER*8 MU, ML, LENRWBP, LENIWBP, NFEBP
       DOUBLE PRECISION ATOL, AVDIM, DELT, FLOOR, RTOL, T, TOUT, TWOHR
       DOUBLE PRECISION ROUT(10), U(2,MX,MY), RPAR(12)
 C
@@ -58,6 +60,7 @@ C Load IPAR, RPAR, and initial values
       CALL INITKX(MX, MY, U, IPAR, RPAR)
 C
 C     Set other input arguments.
+      NEQ = 2*MX*MY
       T = 0.0D0
       METH = 2
       ITMETH = 2
@@ -161,12 +164,12 @@ C     Print final statistics.
      &   ' number of conv. failures.. nonlinear =', I3,
      &   ' linear = ', I3/
      &   ' number of error test failures = ', I3/
-     &   ' main solver real/int workspace sizes   = ',2I5/
+     &   ' main solver real/int workspace sizes   = ',2I7/
      &   ' linear solver real/int workspace sizes = ',2I5)
       CALL FCVBPOPT(LENRWBP, LENIWBP, NFEBP)
       WRITE(6,82) LENRWBP, LENIWBP, NFEBP
  82   FORMAT('In CVBANDPRE:'/
-     &        ' real/int workspace sizes = ', 2I5/
+     &        ' real/int workspace sizes = ', 2I7/
      &        ' number of f evaluations  = ', I5)
 C     
       CALL FCVFREE
@@ -181,10 +184,12 @@ C Routine to set problem constants and initial values
 C
       IMPLICIT NONE
 C
-      INTEGER*4 MX, MY, IPAR(*)
+      INTEGER MX, MY
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
       DOUBLE PRECISION RPAR(*)
 C
-      INTEGER*4 MM, JY, JX, NEQ
+      INTEGER MM, JY, JX, NEQ
       DOUBLE PRECISION U0
       DIMENSION U0(2,MX,MY)
       DOUBLE PRECISION Q1, Q2, Q3, Q4, A3, A4, OM, C3, DY, HDCO
@@ -199,6 +204,8 @@ C Problem constants
       NEQ = 2 * MM
       Q1 = 1.63D-16
       Q2 = 4.66D-16
+      Q3 = 0.D0
+      Q4 = 0.D0
       A3 = 22.62D0
       A4 = 7.601D0
       OM = PI / HALFDA
@@ -250,11 +257,13 @@ C     ----------------------------------------------------------------
 C     Routine for right-hand side function f
       IMPLICIT NONE
 C
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER
       DOUBLE PRECISION T, U(2,*), UDOT(2,*), RPAR(*)
 C
       INTEGER ILEFT, IRIGHT
-      INTEGER*4 MX, MY, MM, JY, JX, IBLOK0, IDN, IUP, IBLOK
+      INTEGER MX, MY, MM, JY, JX, IBLOK0, IDN, IUP, IBLOK
       DOUBLE PRECISION Q1,Q2,Q3,Q4, A3, A4, OM, C3, DY, HDCO, VDCO, HACO
       DOUBLE PRECISION C1, C2, C1DN, C2DN, C1UP, C2UP, C1LT, C2LT
       DOUBLE PRECISION C1RT, C2RT, CYDN, CYUP, HORD1, HORD2, HORAD1
diff --git a/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.out b/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.out
index f03ea46..63aa199 100644
--- a/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.out
+++ b/examples/cvode/fcmix_serial/fcvDiurnal_kry_bp.out
@@ -15,54 +15,54 @@ Krylov example problem:
   c1 (bot.left/middle/top rt.) =   0.266497E+08  0.103640E+08  0.293077E+08
   c2 (bot.left/middle/top rt.) =   0.299279E+12  0.102815E+12  0.331344E+12
 
- t =   0.288000E+05     no. steps =   291   order =   4   stepsize =   0.113513E+03
-  c1 (bot.left/middle/top rt.) =   0.870208E+07  0.129196E+08  0.965001E+07
-  c2 (bot.left/middle/top rt.) =   0.338035E+12  0.502927E+12  0.375095E+12
+ t =   0.288000E+05     no. steps =   298   order =   3   stepsize =   0.132506E+03
+  c1 (bot.left/middle/top rt.) =   0.870208E+07  0.129196E+08  0.965000E+07
+  c2 (bot.left/middle/top rt.) =   0.338035E+12  0.502926E+12  0.375095E+12
 
- t =   0.360000E+05     no. steps =   331   order =   4   stepsize =   0.885814E+02
+ t =   0.360000E+05     no. steps =   341   order =   4   stepsize =   0.631280E+02
   c1 (bot.left/middle/top rt.) =   0.140403E+05  0.202899E+05  0.156090E+05
-  c2 (bot.left/middle/top rt.) =   0.338677E+12  0.489432E+12  0.376516E+12
+  c2 (bot.left/middle/top rt.) =   0.338677E+12  0.489433E+12  0.376516E+12
 
- t =   0.432000E+05     no. steps =   402   order =   4   stepsize =   0.415260E+03
-  c1 (bot.left/middle/top rt.) =  -0.576856E-08  0.342117E-08 -0.386627E-08
-  c2 (bot.left/middle/top rt.) =   0.338232E+12  0.135500E+12  0.380352E+12
+ t =   0.432000E+05     no. steps =   402   order =   4   stepsize =   0.448032E+03
+  c1 (bot.left/middle/top rt.) =   0.191468E-06 -0.613018E-05  0.439513E-06
+  c2 (bot.left/middle/top rt.) =   0.338232E+12  0.135498E+12  0.380352E+12
 
- t =   0.504000E+05     no. steps =   415   order =   5   stepsize =   0.457901E+03
-  c1 (bot.left/middle/top rt.) =  -0.497941E-17 -0.719339E-14 -0.265325E-14
-  c2 (bot.left/middle/top rt.) =   0.335816E+12  0.493026E+12  0.386444E+12
+ t =   0.504000E+05     no. steps =   422   order =   4   stepsize =   0.317295E+03
+  c1 (bot.left/middle/top rt.) =  -0.774603E-10 -0.307315E-07 -0.351244E-10
+  c2 (bot.left/middle/top rt.) =   0.335816E+12  0.493029E+12  0.386444E+12
 
- t =   0.576000E+05     no. steps =   430   order =   4   stepsize =   0.219223E+03
-  c1 (bot.left/middle/top rt.) =   0.161106E-16  0.458698E-15 -0.470389E-17
-  c2 (bot.left/middle/top rt.) =   0.332031E+12  0.964973E+12  0.390899E+12
+ t =   0.576000E+05     no. steps =   436   order =   5   stepsize =   0.358251E+03
+  c1 (bot.left/middle/top rt.) =   0.180088E-10  0.717698E-08  0.858836E-11
+  c2 (bot.left/middle/top rt.) =   0.332031E+12  0.964978E+12  0.390899E+12
 
- t =   0.648000E+05     no. steps =   444   order =   4   stepsize =   0.579451E+03
-  c1 (bot.left/middle/top rt.) =   0.950457E-15  0.115369E-13 -0.231605E-15
-  c2 (bot.left/middle/top rt.) =   0.331302E+12  0.892177E+12  0.396342E+12
+ t =   0.648000E+05     no. steps =   449   order =   5   stepsize =   0.594794E+03
+  c1 (bot.left/middle/top rt.) =  -0.284457E-13 -0.106311E-10 -0.138218E-13
+  c2 (bot.left/middle/top rt.) =   0.331302E+12  0.892183E+12  0.396341E+12
 
- t =   0.720000E+05     no. steps =   457   order =   4   stepsize =   0.579451E+03
-  c1 (bot.left/middle/top rt.) =   0.390973E-15 -0.484816E-13  0.254545E-14
-  c2 (bot.left/middle/top rt.) =   0.332972E+12  0.618613E+12  0.403884E+12
+ t =   0.720000E+05     no. steps =   461   order =   5   stepsize =   0.594794E+03
+  c1 (bot.left/middle/top rt.) =   0.271046E-15  0.101114E-12  0.130660E-15
+  c2 (bot.left/middle/top rt.) =   0.332972E+12  0.618623E+12  0.403884E+12
 
- t =   0.792000E+05     no. steps =   469   order =   4   stepsize =   0.579451E+03
-  c1 (bot.left/middle/top rt.) =  -0.290314E-14  0.215229E-12  0.355073E-15
-  c2 (bot.left/middle/top rt.) =   0.333440E+12  0.666885E+12  0.412026E+12
+ t =   0.792000E+05     no. steps =   473   order =   5   stepsize =   0.594794E+03
+  c1 (bot.left/middle/top rt.) =   0.569757E-15  0.205829E-12  0.268970E-15
+  c2 (bot.left/middle/top rt.) =   0.333441E+12  0.666892E+12  0.412025E+12
 
- t =   0.864000E+05     no. steps =   481   order =   4   stepsize =   0.579451E+03
-  c1 (bot.left/middle/top rt.) =   0.235825E-22  0.231595E-17 -0.600745E-15
-  c2 (bot.left/middle/top rt.) =   0.335178E+12  0.910810E+12  0.416250E+12
+ t =   0.864000E+05     no. steps =   485   order =   5   stepsize =   0.594794E+03
+  c1 (bot.left/middle/top rt.) =   0.270665E-15  0.189895E-16  0.215568E-14
+  c2 (bot.left/middle/top rt.) =   0.335178E+12  0.910637E+12  0.416250E+12
 
 
 Final statistics:
 
- number of steps        =   481     number of f evals.     =   620
- number of prec. setups =    88
- number of prec. evals. =     9     number of prec. solves =  1096
- number of nonl. iters. =   616     number of lin. iters.  =   561
- average Krylov subspace dimension (NLI/NNI) =   0.910714E+00
+ number of steps        =   485     number of f evals.     =   617
+ number of prec. setups =    85
+ number of prec. evals. =     9     number of prec. solves =  1134
+ number of nonl. iters. =   613     number of lin. iters.  =   597
+ average Krylov subspace dimension (NLI/NNI) =   0.973899E+00
  number of conv. failures.. nonlinear =  0 linear =   0
  number of error test failures =  28
- main solver real/int workspace sizes   =  2089   50
+ main solver real/int workspace sizes   =    2089     50
  linear solver real/int workspace sizes =  2046   10
 In CVBANDPRE:
- real/int workspace sizes =  2400  200
+ real/int workspace sizes =    2400    200
  number of f evaluations  =    45
diff --git a/examples/cvode/fcmix_serial/fcvRoberts_dns.f b/examples/cvode/fcmix_serial/fcvRoberts_dns.f
index d317b84..e8d8baa 100644
--- a/examples/cvode/fcmix_serial/fcvRoberts_dns.f
+++ b/examples/cvode/fcmix_serial/fcvRoberts_dns.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2007/10/25 20:03:27 $
+C     $Revision: 4885 $
+C     $Date: 2016-09-02 08:29:03 -0700 (Fri, 02 Sep 2016) $
 C     ----------------------------------------------------------------
 C     FCVODE Example Problem: Robertson kinetics, dense user Jacobian.
 C
@@ -34,8 +34,8 @@ C
       INTEGER LNST, LNFE, LNSETUP, LNNI, LNCF, LNETF, LNJE, LNGE
       INTEGER METH, ITMETH, ITOL, ITASK, JOUT, NOUT, IERROOT
       INTEGER INFO(2)
-      INTEGER*4 IOUT(25), IPAR
-      INTEGER*4 NEQ
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR, NEQ, IOUT(25)
       DOUBLE PRECISION RTOL, T, T0, TOUT
       DOUBLE PRECISION Y(3), ATOL(3), ROUT(10), RPAR
 C
@@ -117,7 +117,7 @@ C
         IF (IER .EQ. 2) THEN
            CALL FCVROOTINFO(2, INFO, IERROOT)
            IF (IERROOT .LT. 0) THEN
-              WRITE(6,65) IER
+              WRITE(6,65) IERROOT
  65           FORMAT(///' SUNDIALS_ERROR: FCVROOTINFO returned IER = ',
      1              I5)
               CALL FCVROOTFREE
@@ -168,7 +168,9 @@ C     ----------------------------------------------------------------
 C Fortran routine for right-hand side function.
       IMPLICIT NONE
 C
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER
       DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
 C
       YDOT(1) = -0.04D0 * Y(1) + 1.0D4 * Y(2) * Y(3)
@@ -187,7 +189,9 @@ C Fortran routine for root finding
       IMPLICIT NONE
 C
       DOUBLE PRECISION T, Y(*), G(*), RPAR(*)
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER
 C
       G(1) = Y(1) - 1.0D-4
       G(2) = Y(3) - 1.0D-2
@@ -204,7 +208,9 @@ C     ----------------------------------------------------------------
 C Fortran routine for dense user-supplied Jacobian.
       IMPLICIT NONE
 C
-      INTEGER*4 N, IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 N, IPAR(*)
+      INTEGER IER
       DOUBLE PRECISION T, Y(*), FY(*), JAC(N,*), H, RPAR(*)
       DOUBLE PRECISION V1(*), V2(*), V3(*)
 C
diff --git a/examples/cvode/fcmix_serial/fcvRoberts_dnsL.f b/examples/cvode/fcmix_serial/fcvRoberts_dnsL.f
index cf66916..d7f665d 100644
--- a/examples/cvode/fcmix_serial/fcvRoberts_dnsL.f
+++ b/examples/cvode/fcmix_serial/fcvRoberts_dnsL.f
@@ -1,6 +1,6 @@
 C     ----------------------------------------------------------------
-C     $Revision: 1.1 $
-C     $Date: 2007/10/25 20:03:27 $
+C     $Revision: 4885 $
+C     $Date: 2016-09-02 08:29:03 -0700 (Fri, 02 Sep 2016) $
 C     ----------------------------------------------------------------
 C     FCVODE Example Problem: Robertson kinetics, Lapack linear solver
 C                             with dense user Jacobian.
@@ -35,8 +35,10 @@ C
       INTEGER LNST, LNFE, LNSETUP, LNNI, LNCF, LNETF, LNJE, LNGE
       INTEGER METH, ITMETH, ITOL, ITASK, JOUT, NOUT, IERROOT
       INTEGER INFO(2)
-      INTEGER*4 IOUT(25), IPAR
-      INTEGER NEQ
+C The following declaration specification should match C type long int.
+      INTEGER*8 NEQ, IOUT(25), IPAR
+C The following declaration specification should match C type int.
+      INTEGER*4 NEQL
       DOUBLE PRECISION RTOL, T, T0, TOUT
       DOUBLE PRECISION Y(3), ATOL(3), ROUT(10), RPAR
 C
@@ -44,6 +46,7 @@ C
      1     LNGE/12/, LNJE/17/
 C
       NEQ = 3
+      NEQL = NEQ
       T0 = 0.0D0
       Y(1) = 1.0D0
       Y(2) = 0.0D0
@@ -89,7 +92,7 @@ C
          STOP
       ENDIF
 C
-      CALL FCVLAPACKDENSE(NEQ, IER)
+      CALL FCVLAPACKDENSE(NEQL, IER)
       IF (IER .NE. 0) THEN
         WRITE(6,40) IER
  40     FORMAT(///' SUNDIALS_ERROR: FCVLAPACKDENSE returned IER = ', I5)
@@ -118,7 +121,7 @@ C
         IF (IER .EQ. 2) THEN
            CALL FCVROOTINFO(2, INFO, IERROOT)
            IF (IERROOT .LT. 0) THEN
-              WRITE(6,65) IER
+              WRITE(6,65) IERROOT
  65           FORMAT(///' SUNDIALS_ERROR: FCVROOTINFO returned IER = ',
      1              I5)
               CALL FCVROOTFREE
@@ -169,7 +172,9 @@ C     ----------------------------------------------------------------
 C Fortran routine for right-hand side function.
       IMPLICIT NONE
 C
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER
       DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
 C
       YDOT(1) = -0.04D0 * Y(1) + 1.0D4 * Y(2) * Y(3)
@@ -188,7 +193,9 @@ C Fortran routine for root finding
       IMPLICIT NONE
 C
       DOUBLE PRECISION T, Y(*), G(*), RPAR(*)
-      INTEGER*4 IPAR(*), IER
+C The following declaration specification should match C type long int.
+      INTEGER*8 IPAR(*)
+      INTEGER IER
 C
       G(1) = Y(1) - 1.0D-4
       G(2) = Y(3) - 1.0D-2
@@ -205,8 +212,9 @@ C     ----------------------------------------------------------------
 C Fortran routine for dense user-supplied Jacobian.
       IMPLICIT NONE
 C
-      INTEGER N, IER
-      INTEGER*4 IPAR(*)
+C The following declaration specification should match C type long int.
+      INTEGER*8 N, IPAR(*)
+      INTEGER IER
       DOUBLE PRECISION T, Y(*), FY(*), JAC(N,*), H, RPAR(*)
       DOUBLE PRECISION V1(*), V2(*), V3(*)
 C
diff --git a/examples/cvode/fcmix_serial/fcvRoberts_klu.f b/examples/cvode/fcmix_serial/fcvRoberts_klu.f
new file mode 100644
index 0000000..51a0961
--- /dev/null
+++ b/examples/cvode/fcmix_serial/fcvRoberts_klu.f
@@ -0,0 +1,324 @@
+!     ----------------------------------------------------------------
+!     Programmer(s): Ting Yan @ SMU
+!          Based on cvRoberts_klu.c and modified to Fortran 77
+!     ----------------------------------------------------------------
+!     Copyright (c) 2016, Southern Methodist University.
+!     All rights reserved.
+!     For details, see the LICENSE file.
+!     ----------------------------------------------------------------
+!     $Revision: $
+!     $Date: $
+!     ----------------------------------------------------------------
+!     FCVODE Example Problem: Robertson kinetics
+!
+!     The following is a simple example problem, with the coding
+!     needed for its solution by CVODE. The problem is from chemical
+!     kinetics, and consists of the following three rate equations:
+!
+!     dy1/dt = -.04*y1 + 1.e4*y2*y3
+!     dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+!     dy3/dt = 3.e7*y2**2
+!
+!     on the interval from t = 0.0 to t = 4.e10, with initial
+!     conditions:
+!
+!     y1 = 1.0, y2 = y3 = 0.
+!
+!     The problem is stiff. While integrating the system, we also
+!     use the root finding feature to find the points at which
+!     y1 = 1.e-4 or at which y3 = 0.01. The following coding solves
+!     this problem with CVODE, using the Fortran/C interface routine
+!     package. This solution uses the BDF method, Newton iteration with
+!     the the FCVKLU sparse direct linear solver,and a user-supplied
+!     Jacobian routine.
+!     It uses a scalar relative tolerance and a vector absolute
+!     tolerance. Output is printed in decades from t = .4 to t = 4.e10.
+!     Run statistics (optional outputs) are printed at the end.
+!     ----------------------------------------------------------------
+!
+      IMPLICIT NONE
+!
+      INTEGER IER, I, IERROOT
+      INTEGER LNST, LNFE, LNSETUP, LNNI, LNCF, LNETF, LNJE, LNGE
+      INTEGER METH, ITMETH, ITOL, ITASK, JOUT, NOUT
+      INTEGER INFO(2)
+!     The following declaration specification should match C type
+      INTEGER*8 IPAR, NEQ, IOUT(22), IVAL, MXNLI, MXETF
+      INTEGER INEQ, NNZ, SPARSETYPE, ORDERING
+      DOUBLE PRECISION RTOL, T, T0, TOUT, H0, NLCONV
+      DOUBLE PRECISION Y(3), ATOL(3), ROUT(6), RPAR
+!
+      DATA LNST/3/, LNFE/4/, LNETF/5/, LNCF/6/, LNNI/7/, LNSETUP/8/
+      DATA LNGE/12/, LNJE/17/
+
+!     Problem constant
+      NEQ = 3                   ! number of equations
+      Y(1) = 1.0D0              ! initial y components
+      Y(2) = 0.0D0
+      Y(3) = 0.0D0
+      METH = 2                  ! basic integration method, 2 for BDF
+      ITMETH = 2                ! nonlinear iteration method, 2 for Newton iteration
+      ITOL = 2                  ! type for absolute tolerance, 2 for array
+      RTOL = 1.0D-4             ! scalar relative tolerance
+      ATOL(1) = 1.0D-6          ! vector absolute tolerance components
+      ATOL(2) = 1.0D-12
+      ATOL(3) = 1.0D-4
+      T0 = 0.0D0                ! initial time
+      TOUT = 0.4D0              ! first output time
+      ITASK = 1                 ! Using in call FCVODE, 1 for normal mode
+      JOUT = 0
+      NOUT = 12                 ! number of output times
+!     
+      WRITE(6, 10) NEQ
+ 10   FORMAT('Klu example problem:'//
+     1     'Robertson kinetics, NEQ = ', I2//)
+
+!
+      
+!     Create serial vector of length NEQ for I.C.
+      CALL FNVINITS(1, NEQ, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 20) IER
+ 20      FORMAT(///' SUNDIALS_ERROR: FNVINITS returned IER = ', I5)
+         STOP
+      ENDIF
+!     
+
+!     Call FCVMALLOC to create the solver memory and specify the 
+!     Backward Differentiation Formula and the use of a Newton iteration
+      CALL FCVMALLOC(T0, Y, METH, ITMETH, ITOL, RTOL, ATOL,
+     1               IOUT, ROUT, IPAR, RPAR, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 30) IER
+ 30      FORMAT(///' SUNDIALS_ERROR: FCVMALLOC returned IER = ', I5)
+         STOP
+      ENDIF
+!
+!     Set the FCVODE input
+      IVAL = 1000         ! max no. of internal steps before t_out
+      CALL FCVSETIIN('MAX_NSTEPS', IVAL, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 31) IER
+ 31      FORMAT(///' SUNDIALS_ERROR: FCVSETIIN returned IER = ', I5)
+         STOP
+      ENDIF
+
+      MXETF = 20          ! max no. of error test failures
+      CALL FCVSETIIN('MAX_ERRFAIL', MXETF, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 31) IER
+         STOP
+      ENDIF
+      
+      H0 = 1.0D-4 * RTOL  ! initial step size
+      CALL FCVSETRIN('INIT_STEP', H0, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 32) IER
+ 32      FORMAT(///' SUNDIALS_ERROR: FCVSETRIN returned IER = ', I5)
+         STOP
+      ENDIF
+      
+      NLCONV = 1.0D-4     ! coefficient in the nonlinear convergence test
+      CALL FCVSETRIN('NLCONV_COEF', NLCONV, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 32) IER
+         STOP
+      ENDIF
+!
+
+!     Call FCVROOTINIT to specify the root function g with 2 components
+      CALL FCVROOTINIT(2, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 45) IER
+ 45      FORMAT(///' SUNDIALS_ERROR: FCVROOTINIT returned IER = ' I5)
+         CALL FCVFREE
+         STOP
+      ENDIF
+!
+      
+!     Call FCVKLU to specify the FCVKLU sparse direct linear solver
+      INEQ = NEQ              ! convert to 'normal' integer type
+      NNZ = INEQ * INEQ       ! maximum number of nonzeros in the Jac matrix
+      SPARSETYPE = 0          ! CSC 
+      ORDERING = 1            ! matrix ordering desired, 1=COLAMD
+      CALL FCVKLU(INEQ, NNZ, SPARSETYPE, ORDERING, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 40) IER
+ 40      FORMAT(///' SUNDIALS_ERROR: FCVKLU returned IER = ', I5)
+         CALL FCVFREE
+         STOP
+      ENDIF
+
+      CALL FCVSPARSESETJAC(IER)
+!     
+
+!     In loop, call FCVODE, print results, and test for error.
+      DO WHILE(JOUT .LT. NOUT)
+!
+         CALL FCVODE(TOUT, T, Y, ITASK, IER)
+!     
+         WRITE(6, 50) T, Y(1), Y(2), Y(3)
+ 50      FORMAT('At t = ', E12.4, '   y = ', 3E14.6)
+!     
+         IF(IER .LT. 0) THEN
+            WRITE(6, 60) IER, IOUT(15)
+ 60         FORMAT(///' SUNDIALS_ERROR: FCVODE returned IER =  ', I5, /,
+     1             '                 Linear Solver returned IER = ', I5)
+            CALL FCVROOTFREE
+            CALL FCVFREE
+            STOP
+         ENDIF
+!
+         IF(IER .EQ. 2) THEN
+            CALL FCVROOTINFO(2, INFO, IERROOT)
+            IF (IERROOT .LT. 0) THEN
+               WRITE(6, 65) IERROOT
+ 65            FORMAT(///' SUNDIALS_ERROR: FCVROOTINFO returned IER = ',
+     1                I5)
+               CALL FCVROOTFREE
+               CALL FCVFREE
+               STOP
+            ENDIF
+            WRITE(6, 70) (INFO(I), I = 1, 2)
+ 70         FORMAT(5X, 'rootfound = ', 2I3)
+         ENDIF
+!
+         IF (IER .EQ. 0) THEN
+            TOUT = TOUT * 10.0D0
+            JOUT = JOUT + 1
+         ENDIF
+!
+      ENDDO
+
+!     Obtain a derivative of the solution
+      CAlL FCVDKY(T, 1, Y, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 80) IER
+ 80      FORMAT(///' SUNDIALS_ERROR: FCVDKY returned IER = ' I4)
+         CALL FCVROOTFREE
+         CALL FCVFREE
+         STOP
+      ENDIF
+      WRITE(6, 85) Y(1), Y(2), Y(3)
+ 85   FORMAT(/'Final value of ydot = ', 3E14.6)
+
+!     Print out the statistic information
+      WRITE(6, 90) IOUT(LNST), IOUT(LNFE), IOUT(LNJE), IOUT(LNSETUP),
+     1             IOUT(LNNI), IOUT(LNCF), IOUT(LNETF), IOUT(LNGE)
+ 90   FORMAT(//'Final statistics:'//
+     1       ' No. steps = ', I4, '    No. f-s = ', I4
+     2       '   No. J-s = ', I4, '    No. LU-s = ', I4/ 
+     3       ' No. nonlinear iterations = ', I4/
+     4       ' No. nonlinear convergence failures = ', I4/
+     5       ' No. error test failures = ', I4/
+     6       ' No. root function evals = ', I4)
+!
+      CALL FCVROOTFREE
+      CALL FCVFREE
+!
+      STOP
+      END
+
+!     ----------------------------------------------------------------
+      
+      SUBROUTINE FCVFUN(T, Y, YDOT, IPAR, RPAR, IER)
+!     Fortran routine for right-hand side function      
+      IMPLICIT NONE
+      
+!     The following declaration specification should match C type long int
+      INTEGER*8 IPAR(*)
+      INTEGER IER
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(*)
+      DOUBLE PRECISION Y1, Y2, Y3
+
+      Y1 = Y(1)
+      Y2 = Y(2)
+      Y3 = Y(3)
+      
+      YDOT(1) = -0.04D0 * Y1 + 1.0D4 * Y2 * Y3
+      YDOT(3) = 3.0D7 * Y2 * Y2
+      YDOT(2) = -YDOT(1) - YDOT(3)
+!
+      IER = 0
+!
+      RETURN
+      END
+
+!     ----------------------------------------------------------------
+      
+      SUBROUTINE FCVROOTFN(T, Y, G, IPAR, RPAR, IER)
+! Fortran routine for root finding
+      IMPLICIT NONE
+
+!     The following declaration specification should match C type long int
+      INTEGER*8 IPAR(*)
+      INTEGER IER
+      DOUBLE PRECISION T, Y(*), G(*), RPAR(*)
+      DOUBLE PRECISION Y1, Y3
+      
+      Y1 = Y(1)
+      Y3 = Y(3)
+
+      G(1) = Y1 - 1.0D-4
+      G(2) = Y3 - 1.0D-2
+!
+      IER = 0
+!
+      RETURN
+      END
+
+!     ----------------------------------------------------------------
+      
+      SUBROUTINE FCVSPJAC(T, Y, FY, N, NNZ, JDATA, JRVALS,
+     1     JCPTRS, H, IPAR, RPAR, WK1, WK2, WK3, IER)
+!     Fortran routine for user-supplied CSC format KLU Jacobian
+      IMPLICIT NONE
+
+!     The following declaration specification should match C type long int
+      INTEGER*8  IPAR(*)
+      INTEGER N, NNZ, IER
+      INTEGER JRVALS(NNZ), JCPTRS(N+1)
+      DOUBLE PRECISION T, Y(*), FY(*), H, RPAR(*)
+      DOUBLE PRECISION JDATA(NNZ)
+      DOUBLE PRECISION WK1(*), WK2(*), WK3(*)
+      
+      ! Local data     
+      DOUBLE PRECISION Y1, Y2, Y3
+
+      Y1 = Y(1)
+      Y2 = Y(2)
+      Y3 = Y(3)
+
+      JCPTRS(1) = 0
+      JCPTRS(2) = 3
+      JCPTRS(3) = 6
+      JCPTRS(4) = 9
+
+      JDATA(1) = -0.04D0
+      JRVALS(1) = 0
+      JDATA(2) = 0.04D0
+      JRVALS(2) = 1
+      JDATA(3) = 0.0D0
+      JRVALS(3) = 2
+
+      JDATA(4) = 1.0D4 * Y3
+      JRVALS(4) = 0
+      JDATA(5) = -1.0D4 * Y3 - 6.0D7 * Y2
+      JRVALS(5) = 1
+      JDATA(6) = 6.0D7 * Y2
+      JRVALS(6) = 2
+      
+      JDATA(7) = 1.0D4 * Y2
+      JRVALS(7) = 0
+      JDATA(8) = -1.0D4 * Y2
+      JRVALS(8) = 1
+      JDATA(9) = 0.0D0
+      JRVALS(9) = 2
+
+      IER = 0
+!
+      RETURN
+      END
+
+
+!     ------End file------------------
diff --git a/examples/cvode/fcmix_serial/fcvRoberts_klu.out b/examples/cvode/fcmix_serial/fcvRoberts_klu.out
new file mode 100644
index 0000000..d894e0e
--- /dev/null
+++ b/examples/cvode/fcmix_serial/fcvRoberts_klu.out
@@ -0,0 +1,32 @@
+Klu example problem:
+
+Robertson kinetics, NEQ =  3
+
+
+At t =   0.2636E+00   y =   0.989965E+00  0.347052E-04  0.100000E-01
+     rootfound =   0  1
+At t =   0.4000E+00   y =   0.985144E+00  0.338588E-04  0.148222E-01
+At t =   0.4000E+01   y =   0.905426E+00  0.223942E-04  0.945515E-01
+At t =   0.4000E+02   y =   0.715830E+00  0.918572E-05  0.284160E+00
+At t =   0.4000E+03   y =   0.450560E+00  0.322342E-05  0.549437E+00
+At t =   0.4000E+04   y =   0.183240E+00  0.894461E-06  0.816759E+00
+At t =   0.4000E+05   y =   0.389806E-01  0.162165E-06  0.961019E+00
+At t =   0.4000E+06   y =   0.493776E-02  0.198479E-07  0.995062E+00
+At t =   0.4000E+07   y =   0.515949E-03  0.206485E-08  0.999484E+00
+At t =   0.2082E+08   y =   0.100000E-03  0.400040E-09  0.999900E+00
+     rootfound =  -1  0
+At t =   0.4000E+08   y =   0.514789E-04  0.205926E-09  0.999949E+00
+At t =   0.4000E+09   y =   0.542638E-05  0.217056E-10  0.999995E+00
+At t =   0.4000E+10   y =   0.464797E-06  0.185919E-11  0.100000E+01
+At t =   0.4000E+11   y =   0.486207E-07  0.194483E-12  0.100000E+01
+
+Final value of ydot =  -0.876832E-18 -0.350733E-23  0.876835E-18
+
+
+Final statistics:
+
+ No. steps =  317    No. f-s =  941   No. J-s =   40    No. LU-s =  117
+ No. nonlinear iterations =  940
+ No. nonlinear convergence failures =    2
+ No. error test failures =   11
+ No. root function evals =  356
diff --git a/examples/cvode/fcmix_serial/fcvRoberts_sps.f b/examples/cvode/fcmix_serial/fcvRoberts_sps.f
new file mode 100644
index 0000000..31623dd
--- /dev/null
+++ b/examples/cvode/fcmix_serial/fcvRoberts_sps.f
@@ -0,0 +1,306 @@
+!     ----------------------------------------------------------------
+!     Programmer(s): Ting Yan @ SMU
+!          Based on cvRoberts_sps.c and modified to Fortran 77
+!     ----------------------------------------------------------------
+!     Copyright (c) 2016, Southern Methodist University.
+!     All rights reserved.
+!     For details, see the LICENSE file.
+!     ----------------------------------------------------------------
+!     $Revision: $
+!     $Date: $
+!     ----------------------------------------------------------------
+!     FCVODE Example Problem: Robertson kinetics
+!
+!     The following is a simple example problem, with the coding
+!     needed for its solution by CVODE. The problem is from chemical
+!     kinetics, and consists of the following three rate equations:
+!
+!     dy1/dt = -.04*y1 + 1.e4*y2*y3
+!     dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+!     dy3/dt = 3.e7*y2**2
+!
+!     on the interval from t = 0.0 to t = 4.e10, with initial
+!     conditions:
+!
+!     y1 = 1.0, y2 = y3 = 0.
+!
+!     The problem is stiff. While integrating the system, we also
+!     use the root finding feature to find the points at which
+!     y1 = 1.e-4 or at which y3 = 0.01. The following coding solves
+!     this problem with CVODE, using the Fortran/C interface routine
+!     package. This solution uses the BDF method, Newton iteration with
+!     the the FCVSUPERLUMT sparse direct linear solver,and a user-supplied
+!     Jacobian routine.
+!     It uses a scalar relative tolerance and a vector absolute
+!     tolerance. Output is printed in decades from t = .4 to t = 4.e10.
+!     Run statistics (optional outputs) are printed at the end.
+!     ----------------------------------------------------------------
+!
+      IMPLICIT NONE
+!
+      INTEGER IER, I, IERROOT
+      INTEGER LNST, LNFE, LNSETUP, LNNI, LNCF, LNETF, LNJE, LNGE
+      INTEGER METH, ITMETH, ITOL, ITASK, JOUT, NOUT
+      INTEGER INFO(2)
+!     The following declaration specification should match C type
+      INTEGER*8 IPAR, NEQ, IOUT(25), IVAL, MXNLI, MXETF
+      INTEGER INEQ, NNZ, NTHREADS, ORDERING
+      DOUBLE PRECISION RTOL, T, T0, TOUT, H0, NLCONV
+      DOUBLE PRECISION Y(3), ATOL(3), ROUT(10), RPAR
+!
+      DATA LNST/3/, LNFE/4/, LNETF/5/, LNCF/6/, LNNI/7/, LNSETUP/8/
+      DATA LNGE/12/, LNJE/17/
+
+!     Problem constant
+      NEQ = 3                  ! number of equations
+      Y(1) = 1.0D0             ! initial y components
+      Y(2) = 0.0D0
+      Y(3) = 0.0D0
+      METH = 2                 ! basic integration method, 2 for BDF
+      ITMETH =2                ! nonlinear iteration method, 2 for Newton iteration
+      ITOL = 2                 ! type for absolute tolerance, 2 for array
+      RTOL = 1.0D-4            ! scalar relative tolerance
+      ATOL(1) = 1.0D-8         ! vector absolute tolerance components
+      ATOL(2) = 1.0D-14
+      ATOL(3) = 1.0D-6
+      T0 = 0.0D0               ! initial time
+      TOUT = 0.4D0             ! first output time
+      ITASK = 1                ! Using in call FCVODE, 1 for normal mode
+      JOUT = 0
+      NOUT = 12                ! number of output times 
+!
+      WRITE(6, 10) NEQ
+ 10   FORMAT('Superlu_mt example problem:'//
+     1       'Robertson kinetics, NEQ = ', I2//)
+
+!
+!     Create serial vector of length NEQ for I.C.
+      CALL FNVINITS(1, NEQ, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 20) IER
+ 20      FORMAT(///' SUNDIALS_ERROR: FNVINITS returned IER = ', I5)
+         STOP
+      ENDIF
+!
+
+!     Call FCVMALLOC to create the solver memory and specify the 
+!     Backward Differentiation Formula and the use of a Newton iteration
+      CALL FCVMALLOC(T0, Y, METH, ITMETH, ITOL, RTOL, ATOL,
+     1               IOUT, ROUT, IPAR, RPAR, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 30) IER
+ 30      FORMAT(///' SUNDIALS_ERROR: FCVMALLOC returned IER = ', I5)
+         STOP
+      ENDIF
+!
+!     Set the FCVODE input
+      IVAL = 900000           ! max no. of internal steps before t_out
+      CALL FCVSETIIN('MAX_NSTEPS', IVAL, IER)
+
+      MXNLI = 8
+      CALL FCVSETIIN('MAX_NITERS', MXNLI, IER)
+
+      MXETF = 20
+      CALL FCVSETIIN('MAX_ERRFAIL', MXETF, IER)
+      
+      H0 = 1.0D-4 * RTOL
+      CALL FCVSETRIN('INIT_STEP', H0, IER)
+
+      NLCONV = 1.0D-7
+      CALL FCVSETRIN('NLCONV_COEF', NLCONV, IER)
+
+
+!     Call FCVROOTINIT to specify the root function g with 2 components
+      CALL FCVROOTINIT(2, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 45) IER
+ 45      FORMAT(///' SUNDIALS_ERROR: FCVROOTINIT returned IER = ' I5)
+         CALL FCVROOTFREE
+         STOP
+      ENDIF
+!
+
+!     Call FCVSUPERLUMT to specify the FCVKLU sparse direct linear solver
+      NTHREADS = 1        ! number of threads to use in factorization
+      INEQ = NEQ          ! covert to 'normal' integer type
+      NNZ = INEQ * INEQ   ! maximum number of nonzeros in the sparse Jac
+      ORDERING = 3        ! matrix ordering desired, 3=COLAMD 
+      CALL FCVSUPERLUMT(NTHREADS, INEQ, NNZ, ORDERING, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 40) IER
+ 40      FORMAT(///' SUNDIALS_ERROR: FCVKLU returned IER = ', I5)
+         CALL FCVFREE
+         STOP
+      ENDIF
+
+      CALL FCVSPARSESETJAC(IER)
+!
+
+!     In loop, call FCVODE, print results, and test for error.
+      DO WHILE(JOUT .LT. NOUT)
+!
+         CALL FCVODE(TOUT, T, Y, ITASK, IER)
+!     
+         WRITE(6, 50) T, Y(1), Y(2), Y(3)
+ 50      FORMAT('At t = ', E12.4, '   y = ', 3E14.6)
+!
+         IF(IER .LT. 0) THEN
+            WRITE(6, 60) IER, IOUT(15)
+ 60         FORMAT(///' SUNDIALS_ERROR: FCVODE returned IER = ', I5, /,
+     1             '                 Linear Solver returned IER = ', I5)
+            CALL FCVROOTFREE
+            CALL FCVFREE
+            STOP
+         ENDIF
+!
+         IF(IER .EQ. 2) THEN
+            CALL FCVROOTINFO(2, INFO, IERROOT)
+            IF (IERROOT .LT. 0) THEN
+               WRITE(6, 65) IERROOT
+ 65            FORMAT(///' SUNDIALS_ERROR: FCVROOTINFO returned IER = ',
+     1                I5)
+               CALL FCVROOTFREE
+               CALL FCVFREE
+               STOP
+            ENDIF
+            WRITE(6, 70) (INFO(I), I = 1, 2)
+ 70         FORMAT(5X, 'Above is a root, INFO() = ', 2I3)
+         ENDIF
+!
+         IF (IER .EQ. 0) THEN
+            TOUT = TOUT * 10.0D0
+            JOUT = JOUT + 1
+         ENDIF
+!
+      ENDDO
+
+!     Print out the derivatives at point the last step taken
+      CALL FCVDKY(T, 1, Y, IER)
+      IF (IER .NE. 0) THEN
+         WRITE(6, 80) IER
+ 80      FORMAT(///' SUNDIALS_ERROR: FCVDKY returned IER = ' I4)
+         CALL FCVROOTFREE
+         CALL FCVFREE
+         STOP
+      ENDIF
+      WRITE(6, 85) Y(1), Y(2), Y(3)
+ 85   FORMAT(/'Final value of ydot = ', 3E14.6)
+!
+
+!     Print out statistic information
+      WRITE(6, 90) IOUT(LNST), IOUT(LNFE), IOUT(LNJE), IOUT(LNSETUP),
+     1             IOUT(LNNI), IOUT(LNCF), IOUT(LNETF), IOUT(LNGE)
+ 90   FORMAT(//'Final statistics:'//
+     1       ' No. steps = ', I4, '    No. f-s = ', I4
+     2       '   No. J-s = ', I4, '    No. LU-s = ', I4/ 
+     3       ' No. nonlinear iterations = ', I4/
+     4       ' No. nonlinear convergence failures = ', I4/
+     5       ' No. error test failures = ', I4/
+     6       ' No. root function evals = ', I4)
+!
+      CALL FCVROOTFREE
+      CALL FCVFREE
+!
+      STOP
+      END
+
+!     ----------------------------------------------------------------
+      
+      SUBROUTINE FCVFUN(T, Y, YDOT, IPAR, RPAR, IER)
+! Fortran routine for right-hand side function       
+      IMPLICIT NONE
+!
+!     The following declaration specification should match C type long int
+      INTEGER*8 IPAR(1)
+      INTEGER IER
+      DOUBLE PRECISION T, Y(*), YDOT(*), RPAR(1)
+      DOUBLE PRECISION Y1, Y2, Y3
+
+      Y1 = Y(1)
+      Y2 = Y(2)
+      Y3 = Y(3)
+      
+      YDOT(1) = -0.04D0 * Y1 + 1.0D4 * Y2 * Y3
+      YDOT(3) = 3.0D7 * Y2 * Y2
+      YDOT(2) = -YDOT(1) - YDOT(3)
+!
+      IER = 0
+!
+      RETURN
+      END
+
+!     ----------------------------------------------------------------
+      
+      SUBROUTINE FCVROOTFN(T, Y, G, IPAR, RPAR, IER)
+! Fortran routine for root finding
+      IMPLICIT NONE
+
+!     The following declaration specification should match C type long int
+      INTEGER*8 IPAR(*)
+      INTEGER IER
+      DOUBLE PRECISION T, Y(*), G(*), RPAR(*)
+      DOUBLE PRECISION Y1, Y3
+      
+      Y1 = Y(1)
+      Y3 = Y(3)
+
+      G(1) = Y1 - 1.0D-4
+      G(2) = Y3 - 1.0D-2
+!
+      IER = 0
+!
+      RETURN
+      END
+
+!     ----------------------------------------------------------------
+      
+      SUBROUTINE FCVSPJAC(T, Y, FY, N, NNZ, JDATA, JRVALS,
+     1                    JCPTRS, H, IPAR, RPAR, WK1, WK2, WK3, IER)
+! Fortran routine for user-supplied CSC format KLU Jacobian 
+      IMPLICIT NONE
+
+!     The following declaration specification should match C type
+      INTEGER*8 IPAR(*)
+      INTEGER N, NNZ, IER
+      INTEGER JRVALS(NNZ), JCPTRS(N+1)
+      DOUBLE PRECISION T, Y(*), FY(*), H, RPAR(*)
+      DOUBLE PRECISION JDATA(NNZ)
+      DOUBLE PRECISION WK1(*), WK2(*), WK3(*)
+      
+      ! Local data     
+      DOUBLE PRECISION Y1, Y2, Y3
+
+      Y1 = Y(1)
+      Y2 = Y(2)
+      Y3 = Y(3)
+
+      JCPTRS(1) = 0
+      JCPTRS(2) = 3
+      JCPTRS(3) = 6
+      JCPTRS(4) = 9
+
+      JDATA(1) = -0.04D0
+      JRVALS(1) = 0
+      JDATA(2) = 0.04D0
+      JRVALS(2) = 1
+      JDATA(3) = 0.0D0
+      JRVALS(3) = 2
+
+      JDATA(4) = 1.0D4 * Y3
+      JRVALS(4) = 0
+      JDATA(5) = -1.0D4 * Y3 - 6.0D7 * Y2
+      JRVALS(5) = 1
+      JDATA(6) = 6.0D7 * Y2
+      JRVALS(6) = 2
+      
+      JDATA(7) = 1.0D4 * Y2
+      JRVALS(7) = 0
+      JDATA(8) = -1.0D4 * Y2
+      JRVALS(8) = 1
+      JDATA(9) = 0.0D0
+      JRVALS(9) = 2
+!
+      IER = 0
+!
+      RETURN
+      END
diff --git a/examples/cvode/fcmix_serial/fcvRoberts_sps.out b/examples/cvode/fcmix_serial/fcvRoberts_sps.out
new file mode 100644
index 0000000..0b88034
--- /dev/null
+++ b/examples/cvode/fcmix_serial/fcvRoberts_sps.out
@@ -0,0 +1,32 @@
+Superlu_mt example problem:
+
+Robertson kinetics, NEQ =  3
+
+
+At t =   0.2640E+00   y =   0.989965E+00  0.347056E-04  0.100000E-01
+     Above is a root, INFO() =   0  1
+At t =   0.4000E+00   y =   0.985172E+00  0.338640E-04  0.147938E-01
+At t =   0.4000E+01   y =   0.905507E+00  0.224034E-04  0.944710E-01
+At t =   0.4000E+02   y =   0.715840E+00  0.918606E-05  0.284150E+00
+At t =   0.4000E+03   y =   0.450575E+00  0.322362E-05  0.549422E+00
+At t =   0.4000E+04   y =   0.183242E+00  0.894472E-06  0.816757E+00
+At t =   0.4000E+05   y =   0.389931E-01  0.162219E-06  0.961007E+00
+At t =   0.4000E+06   y =   0.493709E-02  0.198451E-07  0.995063E+00
+At t =   0.4000E+07   y =   0.516765E-03  0.206812E-08  0.999483E+00
+At t =   0.2078E+08   y =   0.100000E-03  0.400040E-09  0.999900E+00
+     Above is a root, INFO() =  -1  0
+At t =   0.4000E+08   y =   0.519865E-04  0.207957E-09  0.999948E+00
+At t =   0.4000E+09   y =   0.519161E-05  0.207666E-10  0.999995E+00
+At t =   0.4000E+10   y =   0.520292E-06  0.208117E-11  0.999999E+00
+At t =   0.4000E+11   y =   0.590048E-07  0.236019E-12  0.100000E+01
+
+Final value of ydot =  -0.166627E-17 -0.666508E-23  0.166628E-17
+
+
+Final statistics:
+
+ No. steps =  364    No. f-s = 2056   No. J-s =   18    No. LU-s =   98
+ No. nonlinear iterations = 2055
+ No. nonlinear convergence failures =    0
+ No. error test failures =   13
+ No. root function evals =  394
diff --git a/examples/cvode/parallel/CMakeLists.txt b/examples/cvode/parallel/CMakeLists.txt
index 1e7a123..b44b707 100644
--- a/examples/cvode/parallel/CMakeLists.txt
+++ b/examples/cvode/parallel/CMakeLists.txt
@@ -1,23 +1,29 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4957 $
+# $Date: 2016-09-23 12:21:47 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for CVODE parallel examples
 
 
 # Add variable CVODE_examples with the names of the parallel CVODE examples
-
+# "name\;nodes\;tasks"
 SET(CVODE_examples
-  cvAdvDiff_non_p
-  cvDiurnal_kry_bbd_p
-  cvDiurnal_kry_p
+  "cvAdvDiff_diag_p\;2\;4"
+  "cvAdvDiff_non_p\;2\;2"
+  "cvDiurnal_kry_bbd_p\;2\;4"
+  "cvDiurnal_kry_p\;2\;4"
   )
 
 # Check whether we use MPI compiler scripts.
@@ -47,14 +53,31 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${CVODE_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(HYPRE_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${HYPRE_LIBRARIES})
+ENDIF(HYPRE_FOUND)
+
 # Add the build and install targets for each CVODE example
 
-FOREACH(example ${CVODE_examples})
+FOREACH(example_tuple ${CVODE_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
   ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPICC)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -62,7 +85,7 @@ FOREACH(example ${CVODE_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${CVODE_examples})
+ENDFOREACH(example_tuple ${CVODE_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -72,7 +95,10 @@ IF(EXAMPLES_INSTALL)
   # Prepare substitution variables for Makefile and/or CMakeLists templates
   SET(SOLVER "CVODE")
   SET(SOLVER_LIB "sundials_cvode")
-  LIST2STRING(CVODE_examples EXAMPLES)
+  FOREACH(example_tuple ${CVODE_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${CVODE_examples})
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/cvode/parallel/Makefile.in b/examples/cvode/parallel/Makefile.in
deleted file mode 100644
index 20668fa..0000000
--- a/examples/cvode/parallel/Makefile.in
+++ /dev/null
@@ -1,113 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for CVODE parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP         = @CPP@
-CPPFLAGS    = @CPPFLAGS@
-CC          = @CC@
-CFLAGS      = @CFLAGS@
-LDFLAGS     = @LDFLAGS@
-LIBS        = @LIBS@
-MPICC       = @MPICC@
-MPI_INC_DIR = @MPI_INC_DIR@
-MPI_LIB_DIR = @MPI_LIB_DIR@
-MPI_LIBS    = @MPI_LIBS@
-MPI_FLAGS   = @MPI_FLAGS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/cvode/libsundials_cvode.la $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-
-EXAMPLES = cvAdvDiff_non_p \
-	   cvDiurnal_kry_bbd_p \
-	   cvDiurnal_kry_p
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(MPICC) $(CPPFLAGS) $(MPI_FLAGS) $(SUNDIALS_INCS) -I$(MPI_INC_DIR) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(MPICC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}$(OBJ_EXT) $(MPI_FLAGS) $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) -L$(MPI_LIB_DIR) $(MPI_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/cvode/parallel
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/cvode/parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/cvode/parallel/README $(EXS_INSTDIR)/cvode/parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/parallel/$${i}.c   $(EXS_INSTDIR)/cvode/parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/parallel/$${i}.out $(EXS_INSTDIR)/cvode/parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/cvode/parallel/Makefile
-	rm -f $(EXS_INSTDIR)/cvode/parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/cvode/parallel/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/cvode/parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode/parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/cvode/parallel/README b/examples/cvode/parallel/README
index 3a41723..0f42964 100644
--- a/examples/cvode/parallel/README
+++ b/examples/cvode/parallel/README
@@ -1,17 +1,52 @@
 List of parallel CVODE examples
 
   cvAdvDiff_non_p       : 1-D advection-diffusion (nonstiff)
+  cvAdvDiff_diag_p      : 1-D advection-diffusion with Adams and diagonal linear solver
   cvDiurnal_kry_bbd_p   : 2-D 2-species diurnal advection-diffusion with BBD preconditioner
   cvDiurnal_kry_p       : 2-D 2-species diurnal advection-diffusion
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvode/parallel/cvAdvDiff_diag_p.c b/examples/cvode/parallel/cvAdvDiff_diag_p.c
new file mode 100644
index 0000000..b431d9a
--- /dev/null
+++ b/examples/cvode/parallel/cvAdvDiff_diag_p.c
@@ -0,0 +1,367 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, George Byrne,
+ *                and Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * The following is a simple example problem, with the program for
+ * its solution by CVODE. The problem is the semi-discrete
+ * form of the advection-diffusion equation in 1-D:
+ *   du/dt = d^2 u / dx^2 + .5 du/dx
+ * on the interval 0 <= x <= 2, and the time interval 0 <= t <= 5.
+ * Homogeneous Dirichlet boundary conditions are posed, and the
+ * initial condition is the following:
+ *   u(x,t=0) = x(2-x)exp(2x) .
+ * The PDE is discretized on a uniform grid of size MX+2 with
+ * central differencing, and with boundary values eliminated,
+ * leaving an ODE system of size NEQ = MX.
+ * This program solves the problem with the ADAMS integration method, 
+ * and with Newton iteration using diagonal approximate Jacobians.
+ * It uses scalar relative and absolute tolerances.
+ * Output is printed at t = .5, 1.0, ..., 5.
+ * Run statistics (optional outputs) are printed at the end.
+ *
+ * This version uses MPI for user routines.
+ * Execute with Number of Processors = N,  with 1 <= N <= MX.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <cvode/cvode.h>              /* prototypes for CVODE fcts. */
+#include <cvode/cvode_diag.h>         /* prototypes for CVODE diagonal solver */
+#include <nvector/nvector_parallel.h> /* definition of N_Vector and macros */
+#include <sundials/sundials_types.h>  /* definition of realtype */
+#include <sundials/sundials_math.h>   /* definition of EXP */
+
+#include <mpi.h>                      /* MPI constants and types */
+
+/* Problem Constants */
+
+#define ZERO  RCONST(0.0)
+
+#define XMAX  RCONST(2.0)    /* domain boundary           */
+#define MX    10             /* mesh dimension            */
+#define NEQ   MX             /* number of equations       */
+#define ATOL  RCONST(1.0e-5) /* scalar absolute tolerance */
+#define T0    ZERO           /* initial time              */
+#define T1    RCONST(0.5)    /* first output time         */
+#define DTOUT RCONST(0.5)    /* output time increment     */
+#define NOUT  10             /* number of output times    */
+
+/* Type : UserData 
+   contains grid constants, parallel machine parameters, work array. */
+
+typedef struct {
+  realtype dx, hdcoef, hacoef;
+  int npes, my_pe;
+  MPI_Comm comm;
+  realtype z[100];
+} *UserData;
+
+/* Private Helper Functions */
+
+static void SetIC(N_Vector u, realtype dx, long int my_length,
+                  long int my_base);
+
+static void PrintIntro(int npes);
+
+static void PrintData(realtype t, realtype umax, long int nst);
+
+static void PrintFinalStats(void *cvode_mem);
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
+
+/***************************** Main Program ******************************/
+
+int main(int argc, char *argv[])
+{
+  realtype dx, reltol, abstol, t, tout, umax;
+  N_Vector u;
+  UserData data;
+  void *cvode_mem;
+  int iout, flag, my_pe, npes;
+  long int local_N, nperpe, nrem, my_base, nst;
+
+  MPI_Comm comm;
+
+  u = NULL;
+  data = NULL;
+  cvode_mem = NULL;
+
+  /* Get processor number, total number of pe's, and my_pe. */
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &npes);
+  MPI_Comm_rank(comm, &my_pe);
+
+  /* Set local vector length. */
+  nperpe = NEQ/npes;
+  nrem = NEQ - npes*nperpe;
+  local_N = (my_pe < nrem) ? nperpe+1 : nperpe;
+  my_base = (my_pe < nrem) ? my_pe*local_N : my_pe*nperpe + nrem;
+
+  data = (UserData) malloc(sizeof *data);  /* Allocate data memory */
+  if(check_flag((void *)data, "malloc", 2, my_pe)) MPI_Abort(comm, 1);
+
+  data->comm = comm;
+  data->npes = npes;
+  data->my_pe = my_pe;
+
+  u = N_VNew_Parallel(comm, local_N, NEQ);  /* Allocate u vector */
+  if(check_flag((void *)u, "N_VNew", 0, my_pe)) MPI_Abort(comm, 1);
+
+  reltol = ZERO;  /* Set the tolerances */
+  abstol = ATOL;
+
+  dx = data->dx = XMAX/((realtype)(MX+1));  /* Set grid coefficients in data */
+  data->hdcoef = RCONST(1.0)/(dx*dx);
+  data->hacoef = RCONST(0.5)/(RCONST(2.0)*dx);
+
+  SetIC(u, dx, local_N, my_base);  /* Initialize u vector */
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Adams-Moulton LMM and the use of a functional iteration */
+  cvode_mem = CVodeCreate(CV_ADAMS, CV_NEWTON);
+  if(check_flag((void *)cvode_mem, "CVodeCreate", 0, my_pe)) MPI_Abort(comm, 1);
+
+  flag = CVodeSetUserData(cvode_mem, data);
+  if(check_flag(&flag, "CVodeSetUserData", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in u'=f(t,u), the inital time T0, and
+   * the initial dependent variable vector u. */
+  flag = CVodeInit(cvode_mem, f, T0, u);
+  if(check_flag(&flag, "CVodeInit", 1, my_pe)) return(1);
+
+  /* Call CVodeSStolerances to specify the scalar relative tolerance
+   * and scalar absolute tolerances */
+  flag = CVodeSStolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSStolerances", 1, my_pe)) return(1);
+
+  flag = CVDiag(cvode_mem);
+  if (check_flag(&flag, "CVDiag", 1, my_pe)) return(1);
+
+  if (my_pe == 0) PrintIntro(npes);
+
+  umax = N_VMaxNorm(u);
+
+  if (my_pe == 0) {
+    t = T0;
+    PrintData(t, umax, 0);
+  }
+
+  /* In loop over output points, call CVode, print results, test for error */
+
+  for (iout=1, tout=T1; iout <= NOUT; iout++, tout += DTOUT) {
+    flag = CVode(cvode_mem, tout, u, &t, CV_NORMAL);
+    if(check_flag(&flag, "CVode", 1, my_pe)) break;
+    umax = N_VMaxNorm(u);
+    flag = CVodeGetNumSteps(cvode_mem, &nst);
+    check_flag(&flag, "CVodeGetNumSteps", 1, my_pe);
+    if (my_pe == 0) PrintData(t, umax, nst);
+  }
+
+  if (my_pe == 0) 
+    PrintFinalStats(cvode_mem);  /* Print some final statistics */
+
+  N_VDestroy_Parallel(u);        /* Free the u vector */
+  CVodeFree(&cvode_mem);         /* Free the integrator memory */
+  free(data);                    /* Free user data */
+
+  MPI_Finalize();
+
+  return(0);
+}
+
+/************************ Private Helper Functions ***********************/
+
+/* Set initial conditions in u vector */
+
+static void SetIC(N_Vector u, realtype dx, long int my_length,
+                  long int my_base)
+{
+  int i;
+  long int iglobal;
+  realtype x;
+  realtype *udata;
+
+  /* Set pointer to data array and get local length of u. */
+  udata = N_VGetArrayPointer_Parallel(u);
+  my_length = N_VGetLocalLength_Parallel(u);
+
+  /* Load initial profile into u vector */
+  for (i=1; i<=my_length; i++) {
+    iglobal = my_base + i;
+    x = iglobal*dx;
+    udata[i-1] = x*(XMAX - x)*SUNRexp(RCONST(2.0)*x);
+  }  
+}
+
+/* Print problem introduction */
+
+static void PrintIntro(int npes)
+{
+  printf("\n 1-D advection-diffusion equation, mesh size =%3d \n", MX);
+  printf("\n Number of PEs = %3d \n", npes);
+  printf("\n Diagonal linear solver CVDiag \n\n");
+
+  return;
+}
+
+/* Print data */
+
+static void PrintData(realtype t, realtype umax, long int nst)
+{
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %4.2Lf  max.norm(u) =%14.6Le  nst =%4ld \n", t, umax, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
+#else
+  printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
+#endif
+
+  return;
+}
+
+/* Print some final statistics located in the iopt array */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  long int nst, nfe, nni, ncfn, netf;
+  int flag;
+  
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1, 0);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1, 0);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1, 0);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1, 0);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1, 0);
+
+  printf("\nFinal Statistics: \n\n");
+  printf("nst = %-6ld  nfe  = %-6ld  ", nst, nfe);
+  printf("nni = %-6ld  ncfn = %-6ld  netf = %ld\n \n", nni, ncfn, netf);
+}
+
+/***************** Function Called by the Solver ***********************/
+
+/* f routine. Compute f(t,u). */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
+{
+  realtype ui, ult, urt, hordc, horac, hdiff, hadv;
+  realtype *udata, *dudata, *z;
+  int i;
+  int npes, my_pe, my_length, my_pe_m1, my_pe_p1, last_pe, my_last;
+  UserData data;
+  MPI_Status status;
+  MPI_Comm comm;
+
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
+
+  /* Extract needed problem constants from data */
+  data = (UserData) user_data;
+  hordc = data->hdcoef;
+  horac = data->hacoef;
+
+  /* Extract parameters for parallel computation. */
+  comm = data->comm;
+  npes = data->npes;           /* Number of processes. */ 
+  my_pe = data->my_pe;         /* Current process number. */
+  my_length = N_VGetLocalLength_Parallel(u); /* Number of local elements of u. */ 
+  z = data->z;
+
+  /* Compute related parameters. */
+  my_pe_m1 = my_pe - 1;
+  my_pe_p1 = my_pe + 1;
+  last_pe = npes - 1;
+  my_last = my_length - 1;
+
+  /* Store local segment of u in the working array z. */
+   for (i = 1; i <= my_length; i++)
+     z[i] = udata[i - 1];
+
+  /* Pass needed data to processes before and after current process. */
+   if (my_pe != 0)
+     MPI_Send(&z[1], 1, PVEC_REAL_MPI_TYPE, my_pe_m1, 0, comm);
+   if (my_pe != last_pe)
+     MPI_Send(&z[my_length], 1, PVEC_REAL_MPI_TYPE, my_pe_p1, 0, comm);   
+
+  /* Receive needed data from processes before and after current process. */
+   if (my_pe != 0)
+     MPI_Recv(&z[0], 1, PVEC_REAL_MPI_TYPE, my_pe_m1, 0, comm, &status);
+   else z[0] = ZERO;
+   if (my_pe != last_pe)
+     MPI_Recv(&z[my_length+1], 1, PVEC_REAL_MPI_TYPE, my_pe_p1, 0, comm,
+              &status);   
+   else z[my_length + 1] = ZERO;
+
+  /* Loop over all grid points in current process. */
+  for (i=1; i<=my_length; i++) {
+
+    /* Extract u at x_i and two neighboring points */
+    ui = z[i];
+    ult = z[i-1];
+    urt = z[i+1];
+
+    /* Set diffusion and advection terms and load into udot */
+    hdiff = hordc*(ult - RCONST(2.0)*ui + urt);
+    hadv = horac*(urt - ult);
+    dudata[i-1] = hdiff + hadv;
+  }
+
+  return(0);
+}
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed with flag = %d\n\n",
+              id, funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvode/parallel/cvAdvDiff_diag_p.out b/examples/cvode/parallel/cvAdvDiff_diag_p.out
new file mode 100644
index 0000000..ba98e12
--- /dev/null
+++ b/examples/cvode/parallel/cvAdvDiff_diag_p.out
@@ -0,0 +1,23 @@
+
+ 1-D advection-diffusion equation, mesh size = 10 
+
+ Number of PEs =   4 
+
+ Diagonal linear solver CVDiag 
+
+At t = 0.00  max.norm(u) =  1.569909e+01  nst =   0 
+At t = 0.50  max.norm(u) =  3.052962e+00  nst = 143 
+At t = 1.00  max.norm(u) =  8.747271e-01  nst = 202 
+At t = 1.50  max.norm(u) =  2.494167e-01  nst = 282 
+At t = 2.00  max.norm(u) =  7.082911e-02  nst = 327 
+At t = 2.50  max.norm(u) =  2.042025e-02  nst = 377 
+At t = 3.00  max.norm(u) =  5.964897e-03  nst = 418 
+At t = 3.50  max.norm(u) =  1.962584e-03  nst = 445 
+At t = 4.00  max.norm(u) =  5.827188e-04  nst = 464 
+At t = 4.50  max.norm(u) =  1.501144e-04  nst = 480 
+At t = 5.00  max.norm(u) =  4.800542e-05  nst = 497 
+
+Final Statistics: 
+
+nst = 497     nfe  = 967     nni = 963     ncfn = 26      netf = 24
+ 
diff --git a/examples/cvode/parallel/cvAdvDiff_non_p.c b/examples/cvode/parallel/cvAdvDiff_non_p.c
index f123ebf..647db70 100644
--- a/examples/cvode/parallel/cvAdvDiff_non_p.c
+++ b/examples/cvode/parallel/cvAdvDiff_non_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2007/10/25 20:03:28 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, George Byrne,
  *                and Radu Serban @ LLNL
@@ -81,7 +81,7 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /***************************** Main Program ******************************/
 
@@ -195,14 +195,14 @@ static void SetIC(N_Vector u, realtype dx, long int my_length,
   realtype *udata;
 
   /* Set pointer to data array and get local length of u. */
-  udata = NV_DATA_P(u);
-  my_length = NV_LOCLENGTH_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
+  my_length = N_VGetLocalLength_Parallel(u);
 
   /* Load initial profile into u vector */
   for (i=1; i<=my_length; i++) {
     iglobal = my_base + i;
     x = iglobal*dx;
-    udata[i-1] = x*(XMAX - x)*EXP(RCONST(2.0)*x);
+    udata[i-1] = x*(XMAX - x)*SUNRexp(RCONST(2.0)*x);
   }  
 }
 
@@ -224,7 +224,7 @@ static void PrintData(realtype t, realtype umax, long int nst)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %4.2Lf  max.norm(u) =%14.6Le  nst =%4ld \n", t, umax, nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %4.2f  max.norm(u) =%14.6le  nst =%4ld \n", t, umax, nst);
+  printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
 #else
   printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
 #endif
@@ -269,8 +269,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   MPI_Status status;
   MPI_Comm comm;
 
-  udata = NV_DATA_P(u);
-  dudata = NV_DATA_P(udot);
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
 
   /* Extract needed problem constants from data */
   data = (UserData) user_data;
@@ -281,7 +281,7 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   comm = data->comm;
   npes = data->npes;           /* Number of processes. */ 
   my_pe = data->my_pe;         /* Current process number. */
-  my_length = NV_LOCLENGTH_P(u); /* Number of local elements of u. */ 
+  my_length = N_VGetLocalLength_Parallel(u); /* Number of local elements of u. */ 
   z = data->z;
 
   /* Compute related parameters. */
@@ -334,7 +334,7 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c b/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c
index 5d39061..e5a00b6 100644
--- a/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c
+++ b/examples/cvode/parallel/cvDiurnal_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/14 21:31:59 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): S. D. Cohen, A. C. Hindmarsh, M. R. Wittman, and
  *                Radu Serban  @ LLNL
@@ -60,7 +60,7 @@
 #include <cvode/cvode_bbdpre.h>       /* prototypes for CVBBDPRE module */
 #include <nvector/nvector_parallel.h> /* def. of N_Vector, macro NV_DATA_P */
 #include <sundials/sundials_types.h>  /* definitions of realtype, booleantype */
-#include <sundials/sundials_math.h>   /* definition of macros SQR and EXP */
+#include <sundials/sundials_math.h>   /* definition of macros SUNSQR and EXP */
 
 #include <mpi.h>                      /* MPI constants and types */
 
@@ -156,7 +156,7 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /***************************** Main Program ******************************/
 
@@ -309,9 +309,9 @@ static void InitUserData(int my_pe, long int local_N, MPI_Comm comm,
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/((realtype)(MX-1));
   data->dy = (YMAX-YMIN)/((realtype)(MY-1));
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(RCONST(2.0)*data->dx);
-  data->vdco = (RCONST(1.0)/SQR(data->dy))*KV0;
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
 
   /* Set machine-related constants */
   data->comm = comm;
@@ -339,7 +339,7 @@ static void SetInitialProfiles(N_Vector u, UserData data)
 
   /* Set pointer to data array in vector u */
 
-  uarray = NV_DATA_P(u);
+  uarray = N_VGetArrayPointer_Parallel(u);
 
   /* Get mesh spacings, and subgrid indices for this PE */
 
@@ -356,13 +356,13 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   for (ly = 0; ly < MYSUB; ly++) {
     jy = ly + isuby*MYSUB;
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - ymid));
-    cy = RCONST(1.0) - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
     for (lx = 0; lx < MXSUB; lx++) {
       jx = lx + isubx*MXSUB;
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - xmid));
-      cx = RCONST(1.0) - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
       uarray[offset  ] = C1_SCALE*cx*cy; 
       uarray[offset+1] = C2_SCALE*cx*cy;
       offset = offset + 2;
@@ -397,7 +397,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
   MPI_Status status;
 
   npelast = NPEX*NPEY - 1;
-  uarray = NV_DATA_P(u);
+  uarray = N_VGetArrayPointer_Parallel(u);
 
   /* Send c1,c2 at top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -428,10 +428,10 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
     printf("At bottom left:  c1, c2 = %12.3Le %12.3Le \n", uarray[0], uarray[1]);
     printf("At top right:    c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+    printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
-    printf("At bottom left:  c1, c2 = %12.3le %12.3le \n", uarray[0], uarray[1]);
-    printf("At top right:    c1, c2 = %12.3le %12.3le \n\n", tempu[0], tempu[1]);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", uarray[0], uarray[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
 #else
     printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
@@ -657,7 +657,7 @@ static void fucomm(realtype t, N_Vector u, void *user_data)
   MPI_Request request[4];
 
   data = (UserData) user_data;
-  uarray = NV_DATA_P(u);
+  uarray = N_VGetArrayPointer_Parallel(u);
 
   /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
 
@@ -722,8 +722,8 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
   UserData data;
   realtype *uarray, *duarray;
 
-  uarray = NV_DATA_P(u);
-  duarray = NV_DATA_P(udot);
+  uarray = N_VGetArrayPointer_Parallel(u);
+  duarray = N_VGetArrayPointer_Parallel(udot);
 
   /* Get subgrid indices, array sizes, extended work array uext */
 
@@ -787,8 +787,8 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
 
   s = sin((data->om)*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    q4coef = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
   } else {
     q3 = ZERO;
     q4coef = ZERO;
@@ -806,8 +806,8 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     for (lx = 0; lx < MXSUB; lx++) {
 
       jx = lx + isubx*MXSUB;
@@ -863,7 +863,7 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvode/parallel/cvDiurnal_kry_p.c b/examples/cvode/parallel/cvDiurnal_kry_p.c
index c76c77a..0211ac8 100644
--- a/examples/cvode/parallel/cvDiurnal_kry_p.c
+++ b/examples/cvode/parallel/cvDiurnal_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:52:20 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): S. D. Cohen, A. C. Hindmarsh, M. R. Wittman, and
  *                Radu Serban  @ LLNL
@@ -57,7 +57,7 @@
 #include <nvector/nvector_parallel.h>  /* def. of N_Vector, macro NV_DATA_P  */
 #include <sundials/sundials_dense.h>   /* prototypes for small dense fcts. */
 #include <sundials/sundials_types.h>   /* definitions of realtype, booleantype */
-#include <sundials/sundials_math.h>    /* definition of macros SQR and EXP */
+#include <sundials/sundials_math.h>    /* definition of macros SUNSQR and EXP */
 
 #include <mpi.h>                       /* MPI constants and types */
 
@@ -95,7 +95,7 @@
 #define MX           (NPEX*MXSUB)   /* MX = number of x mesh points */
 #define MY           (NPEY*MYSUB)   /* MY = number of y mesh points */
                                     /* Spatial mesh is MX by MY */
-/* CVodeMalloc Constants */
+/* CVodeInit Constants */
 
 #define RTOL    RCONST(1.0e-5)    /* scalar relative tolerance */
 #define FLOOR   RCONST(100.0)     /* value of C1 or C2 at which tolerances */
@@ -176,7 +176,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 
 /***************************** Main Program ******************************/
@@ -294,9 +294,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/((realtype)(MX-1));
   data->dy = (YMAX-YMIN)/((realtype)(MY-1));
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(RCONST(2.0)*data->dx);
-  data->vdco = (RCONST(1.0)/SQR(data->dy))*KV0;
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
 
   /* Set machine-related constants */
   data->comm = comm;
@@ -349,7 +349,7 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   realtype *udata;
 
   /* Set pointer to data array in vector u */
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Get mesh spacings, and subgrid indices for this PE */
   dx = data->dx;         dy = data->dy;
@@ -364,13 +364,13 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   for (ly = 0; ly < MYSUB; ly++) {
     jy = ly + isuby*MYSUB;
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - ymid));
-    cy = RCONST(1.0) - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
     for (lx = 0; lx < MXSUB; lx++) {
       jx = lx + isubx*MXSUB;
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - xmid));
-      cx = RCONST(1.0) - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
       udata[offset  ] = C1_SCALE*cx*cy; 
       udata[offset+1] = C2_SCALE*cx*cy;
       offset = offset + 2;
@@ -390,7 +390,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
   MPI_Status status;
 
   npelast = NPEX*NPEY - 1;
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Send c1,c2 at top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -422,10 +422,10 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
     printf("At bottom left:  c1, c2 = %12.3Le %12.3Le \n", udata[0], udata[1]);
     printf("At top right:    c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+    printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
-    printf("At bottom left:  c1, c2 = %12.3le %12.3le \n", udata[0], udata[1]);
-    printf("At top right:    c1, c2 = %12.3le %12.3le \n\n", tempu[0], tempu[1]);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
 #else
     printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
@@ -635,7 +635,7 @@ static void ucomm(realtype t, N_Vector u, UserData data)
   long int nvmxsub, nvmysub;
   MPI_Request request[4];
 
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
   comm = data->comm;  my_pe = data->my_pe;
@@ -727,8 +727,8 @@ static void fcalc(realtype t, realtype udata[],
   data block for use by preconditioner evaluation routine */
   s = sin((data->om)*t);
   if (s > RCONST(0.0)) {
-    q3 = EXP(-A3/s);
-    q4coef = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
   } else {
     q3 = RCONST(0.0);
     q4coef = RCONST(0.0);
@@ -743,8 +743,8 @@ static void fcalc(realtype t, realtype udata[],
     /* Set vertical diffusion coefficients at jy +- 1/2 */
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     for (lx = 0; lx < MXSUB; lx++) {
 
       jx = lx + isubx*MXSUB;
@@ -797,8 +797,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   realtype *udata, *dudata;
   UserData data;
 
-  udata = NV_DATA_P(u);
-  dudata = NV_DATA_P(udot);
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
   data = (UserData) user_data;
 
   /* Call ucomm to do inter-processor communication */
@@ -830,7 +830,7 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
   isubx = data->isubx;   isuby = data->isuby;
   nvmxsub = data->nvmxsub;
 
@@ -861,8 +861,8 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
       jy = ly + isuby*MYSUB;
       ydn = YMIN + (jy - RCONST(0.5))*dely;
       yup = ydn + dely;
-      cydn = verdco*EXP(RCONST(0.2)*ydn);
-      cyup = verdco*EXP(RCONST(0.2)*yup);
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
       diag = -(cydn + cyup + RCONST(2.0)*hordco);
       for (lx = 0; lx < MXSUB; lx++) {
         jx = lx + isubx*MXSUB;
@@ -924,7 +924,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
   N_VScale(RCONST(1.0), r, z);
 
   nvmxsub = data->nvmxsub;
-  zdata = NV_DATA_P(z);
+  zdata = N_VGetArrayPointer_Parallel(z);
 
   for (lx = 0; lx < MXSUB; lx++) {
     for (ly = 0; ly < MYSUB; ly++) {
@@ -947,7 +947,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvode/parhyp/CMakeLists.txt b/examples/cvode/parhyp/CMakeLists.txt
new file mode 100644
index 0000000..a07c51c
--- /dev/null
+++ b/examples/cvode/parhyp/CMakeLists.txt
@@ -0,0 +1,140 @@
+# ---------------------------------------------------------------
+# $Revision: 4341 $
+# $Date: 2015-02-03 10:53:47 -0800 (Tue, 03 Feb 2015) $
+# ---------------------------------------------------------------
+# Programmer:  Radu Serban @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for CVODE parhyp examples
+
+
+# Add variable CVODE_examples with the names of the parhyp CVODE examples
+# "name\;nodes\;tasks"
+SET(CVODE_examples
+  "cvAdvDiff_non_ph\;2\;2"
+#  "cvDiurnal_kry_bbd_ph\;2\;4"
+#  "cvHeat2D_ph\;2\;2"
+  )
+
+# Check whether we use MPI compiler scripts.
+# If yes, then change the C compiler to the MPICC script.
+# If not, then add the MPI include directory for MPI headers.
+
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICC)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(CVODE_LIB sundials_cvode_static)
+  SET(NVECP_LIB sundials_nvecparhyp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(CVODE_LIB sundials_cvode_shared)
+  SET(NVECP_LIB sundials_nvecparhyp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${CVODE_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
+SET(HYPRE_LIBS ${HYPRE_LIBRARIES})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(HYPRE_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${HYPRE_LIBRARIES})
+ENDIF(HYPRE_FOUND)
+
+# Add the build and install targets for each CVODE example
+
+FOREACH(example_tuple ${CVODE_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(NOT MPI_MPICC)
+    TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
+  ENDIF(NOT MPI_MPICC)
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/parhyp)
+    #INSTALL(FILES vis.c DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/parhyp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example_tuple ${CVODE_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/parhyp)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "CVODE")
+  SET(SOLVER_LIB "sundials_cvode")
+  FOREACH(example_tuple ${CVODE_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${CVODE_examples})
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parhyp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/cvode/parhyp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/cvode/parhyp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/parhyp 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parhyp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/cvode/parhyp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/cvode/parhyp/Makefile_ex
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/parhyp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/cvode/parhyp/README b/examples/cvode/parhyp/README
new file mode 100644
index 0000000..0f42964
--- /dev/null
+++ b/examples/cvode/parhyp/README
@@ -0,0 +1,52 @@
+List of parallel CVODE examples
+
+  cvAdvDiff_non_p       : 1-D advection-diffusion (nonstiff)
+  cvAdvDiff_diag_p      : 1-D advection-diffusion with Adams and diagonal linear solver
+  cvDiurnal_kry_bbd_p   : 2-D 2-species diurnal advection-diffusion with BBD preconditioner
+  cvDiurnal_kry_p       : 2-D 2-species diurnal advection-diffusion
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvode/parhyp/cvAdvDiff_non_ph.c b/examples/cvode/parhyp/cvAdvDiff_non_ph.c
new file mode 100644
index 0000000..ab72743
--- /dev/null
+++ b/examples/cvode/parhyp/cvAdvDiff_non_ph.c
@@ -0,0 +1,396 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * -----------------------------------------------------------------
+ * Programmer(s): Jean M. Sexton @ SMU
+ *                Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * Based on work by Scott D. Cohen, Alan C. Hindmarsh, George Byrne,
+ *                  and Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * The following is a simple example problem, with the program for
+ * its solution by CVODE. The problem is the semi-discrete
+ * form of the advection-diffusion equation in 1-D:
+ *   du/dt = d^2 u / dx^2 + .5 du/dx
+ * on the interval 0 <= x <= 2, and the time interval 0 <= t <= 5.
+ * Homogeneous Dirichlet boundary conditions are posed, and the
+ * initial condition is the following:
+ *   u(x,t=0) = x(2-x)exp(2x) .
+ * The PDE is discretized on a uniform grid of size MX+2 with
+ * central differencing, and with boundary values eliminated,
+ * leaving an ODE system of size NEQ = MX.
+ * This program solves the problem with the option for nonstiff
+ * systems: ADAMS method and functional iteration.
+ * It uses scalar relative and absolute tolerances.
+ * Output is printed at t = .5, 1.0, ..., 5.
+ * Run statistics (optional outputs) are printed at the end.
+ *
+ * This example uses Hypre vector with "IJ" interface and MPI 
+ * parallelization. User is expected to be familiar with the Hypre 
+ * library. 
+ * 
+ * Execute with Number of Processors = N,  with 1 <= N <= MX.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <cvode/cvode.h>              /* prototypes for CVODE fcts. */
+#include <sundials/sundials_types.h>  /* definition of realtype */
+#include <sundials/sundials_math.h>   /* definition of EXP */
+#include <nvector/nvector_parhyp.h>   /* nvector implementation */
+
+#include <HYPRE.h>
+#include <HYPRE_IJ_mv.h>
+
+#include <mpi.h>                      /* MPI constants and types */
+
+/* Problem Constants */
+
+#define ZERO  RCONST(0.0)
+
+#define XMAX  RCONST(2.0)    /* domain boundary           */
+#define MX    10             /* mesh dimension            */
+#define NEQ   MX             /* number of equations       */
+#define ATOL  RCONST(1.0e-5) /* scalar absolute tolerance */
+#define T0    ZERO           /* initial time              */
+#define T1    RCONST(0.5)    /* first output time         */
+#define DTOUT RCONST(0.5)    /* output time increment     */
+#define NOUT  10             /* number of output times    */
+
+/* Type : UserData 
+   contains grid constants, parhyp machine parameters, work array. */
+
+typedef struct {
+  realtype dx, hdcoef, hacoef;
+  int npes, my_pe;
+  MPI_Comm comm;
+  realtype z[100];
+} *UserData;
+
+/* Private Helper Functions */
+
+static void SetIC(HYPRE_IJVector Uij, realtype dx, long int my_length,
+                  long int my_base);
+
+static void PrintIntro(int npes);
+
+static void PrintData(realtype t, realtype umax, long int nst);
+
+static void PrintFinalStats(void *cvode_mem);
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
+
+/***************************** Main Program ******************************/
+
+int main(int argc, char *argv[])
+{
+  realtype dx, reltol, abstol, t, tout, umax;
+  N_Vector u;
+  UserData data;
+  void *cvode_mem;
+  int iout, flag, my_pe, npes;
+  long int nst;
+  HYPRE_Int local_N, nperpe, nrem, my_base;
+  HYPRE_ParVector Upar; /* Declare HYPRE parallel vector */
+  HYPRE_IJVector  Uij;  /* Declare "IJ" interface to HYPRE vector */
+
+  MPI_Comm comm;
+
+  u = NULL;
+  data = NULL;
+  cvode_mem = NULL;
+
+  /* Get processor number, total number of pe's, and my_pe. */
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &npes);
+  MPI_Comm_rank(comm, &my_pe);
+
+  /* Set partitioning. */
+  nperpe = NEQ/npes;
+  nrem = NEQ - npes*nperpe;
+  local_N = (my_pe < nrem) ? nperpe+1 : nperpe;
+  my_base = (my_pe < nrem) ? my_pe*local_N : my_pe*nperpe + nrem;
+  
+  /* Allocate hypre vector */
+  HYPRE_IJVectorCreate(comm, my_base, my_base + local_N - 1, &Uij);
+  HYPRE_IJVectorSetObjectType(Uij, HYPRE_PARCSR);
+  HYPRE_IJVectorInitialize(Uij);
+
+  /* Allocate user defined data */
+  data = (UserData) malloc(sizeof *data);  /* Allocate data memory */
+  if(check_flag((void *)data, "malloc", 2, my_pe)) MPI_Abort(comm, 1);
+
+  data->comm = comm;
+  data->npes = npes;
+  data->my_pe = my_pe;
+
+  reltol = ZERO;  /* Set the tolerances */
+  abstol = ATOL;
+
+  dx = data->dx = XMAX/((realtype)(MX+1));  /* Set grid coefficients in data */
+  data->hdcoef = RCONST(1.0)/(dx*dx);
+  data->hacoef = RCONST(0.5)/(RCONST(2.0)*dx);
+
+  /* Initialize solutin vector. */
+  SetIC(Uij, dx, local_N, my_base);
+  HYPRE_IJVectorAssemble(Uij);
+  HYPRE_IJVectorGetObject(Uij, (void**) &Upar);
+
+  u = N_VMake_ParHyp(Upar);  /* Create wrapper u around hypre vector */
+  if(check_flag((void *)u, "N_VNew", 0, my_pe)) MPI_Abort(comm, 1);
+  
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Adams-Moulton LMM and the use of a functional iteration */
+  cvode_mem = CVodeCreate(CV_ADAMS, CV_FUNCTIONAL);
+  if(check_flag((void *)cvode_mem, "CVodeCreate", 0, my_pe)) MPI_Abort(comm, 1);
+
+  flag = CVodeSetUserData(cvode_mem, data);
+  if(check_flag(&flag, "CVodeSetUserData", 1, my_pe)) MPI_Abort(comm, 1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in u'=f(t,u), the inital time T0, and
+   * the initial dependent variable vector u. */
+  flag = CVodeInit(cvode_mem, f, T0, u);
+  if(check_flag(&flag, "CVodeInit", 1, my_pe)) return(1);
+
+  /* Call CVodeSStolerances to specify the scalar relative tolerance
+   * and scalar absolute tolerances */
+  flag = CVodeSStolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSStolerances", 1, my_pe)) return(1);
+
+  if (my_pe == 0) PrintIntro(npes);
+
+  umax = N_VMaxNorm(u);
+
+  if (my_pe == 0) {
+    t = T0;
+    PrintData(t, umax, 0);
+  }
+
+  /* In loop over output points, call CVode, print results, test for error */
+
+  for (iout=1, tout=T1; iout <= NOUT; iout++, tout += DTOUT) {
+    flag = CVode(cvode_mem, tout, u, &t, CV_NORMAL);
+    if(check_flag(&flag, "CVode", 1, my_pe)) break;
+    umax = N_VMaxNorm(u);
+    flag = CVodeGetNumSteps(cvode_mem, &nst);
+    check_flag(&flag, "CVodeGetNumSteps", 1, my_pe);
+    if (my_pe == 0) PrintData(t, umax, nst);
+  }
+
+  if (my_pe == 0) 
+    PrintFinalStats(cvode_mem);  /* Print some final statistics */
+
+  N_VDestroy(u);              /* Free hypre vector wrapper */
+  HYPRE_IJVectorDestroy(Uij); /* Free the underlying hypre vector */
+  CVodeFree(&cvode_mem);      /* Free the integrator memory */
+  free(data);                 /* Free user data */
+
+  MPI_Finalize();
+
+  return(0);
+}
+
+/************************ Private Helper Functions ***********************/
+
+/* Set initial conditions in u vector */
+
+static void SetIC(HYPRE_IJVector Uij, realtype dx, long int my_length,
+                  long int my_base)
+{
+  int i;
+  HYPRE_Int *iglobal;
+  realtype x;
+  realtype *udata;
+
+  /* Set pointer to data array and get local length of u. */
+  udata   = (realtype*) malloc(my_length*sizeof(realtype));
+  iglobal = (HYPRE_Int*) malloc(my_length*sizeof(HYPRE_Int));
+
+  /* Load initial profile into u vector */
+  for (i = 0; i < my_length; i++) {
+    iglobal[i] = my_base + i;
+    x = (iglobal[i] + 1)*dx;
+    udata[i] = x*(XMAX - x)*SUNRexp(RCONST(2.0)*x);
+  }
+  HYPRE_IJVectorSetValues(Uij, my_length, iglobal, udata);
+  free(iglobal);
+  free(udata);
+}
+
+/* Print problem introduction */
+
+static void PrintIntro(int npes)
+{
+  printf("\n 1-D advection-diffusion equation, mesh size =%3d \n", MX);
+  printf("\n Number of PEs = %3d \n\n", npes);
+
+  return;
+}
+
+/* Print data */
+
+static void PrintData(realtype t, realtype umax, long int nst)
+{
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %4.2Lf  max.norm(u) =%14.6Le  nst =%4ld \n", t, umax, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
+#else
+  printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
+#endif
+
+  return;
+}
+
+/* Print some final statistics located in the iopt array */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  long int nst, nfe, nni, ncfn, netf;
+  int flag;
+  
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1, 0);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1, 0);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1, 0);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1, 0);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1, 0);
+
+  printf("\nFinal Statistics: \n\n");
+  printf("nst = %-6ld  nfe  = %-6ld  ", nst, nfe);
+  printf("nni = %-6ld  ncfn = %-6ld  netf = %ld\n \n", nni, ncfn, netf);
+}
+
+/***************** Function Called by the Solver ***********************/
+
+/* f routine. Compute f(t,u). */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
+{
+  realtype ui, ult, urt, hordc, horac, hdiff, hadv;
+  realtype *udata, *udotdata, *z;
+  int i;
+  int npes, my_pe, my_length, my_pe_m1, my_pe_p1, last_pe;
+  UserData data;
+  MPI_Status status;
+  MPI_Comm comm;
+  HYPRE_ParVector uhyp;
+  HYPRE_ParVector udothyp;
+
+  /* Extract hypre vectors */  
+  uhyp  = N_VGetVector_ParHyp(u);
+  udothyp  = N_VGetVector_ParHyp(udot);
+  
+  /* Access hypre vectors local data */
+  udata = hypre_VectorData(hypre_ParVectorLocalVector(uhyp));
+  udotdata = hypre_VectorData(hypre_ParVectorLocalVector(udothyp));
+
+  /* Extract needed problem constants from data */
+  data = (UserData) user_data;
+  hordc = data->hdcoef;
+  horac = data->hacoef;
+
+  /* Extract parameters for parhyp computation. */
+  comm = data->comm;
+  npes = data->npes;                           /* Number of processes    */ 
+  my_pe = data->my_pe;                         /* Current process number */
+  my_length =  hypre_ParVectorLastIndex(uhyp)  /* Local length of uhyp   */
+             - hypre_ParVectorFirstIndex(uhyp) + 1;  
+  z = data->z;
+
+  /* Compute related parameters. */
+  my_pe_m1 = my_pe - 1;
+  my_pe_p1 = my_pe + 1;
+  last_pe = npes - 1;
+
+  /* Store local segment of u in the working array z. */
+  for (i = 1; i <= my_length; i++)
+    z[i] = udata[i - 1];
+
+  /* Pass needed data to processes before and after current process. */
+  if (my_pe != 0)
+    MPI_Send(&z[1], 1, PVEC_REAL_MPI_TYPE, my_pe_m1, 0, comm);
+  if (my_pe != last_pe)
+    MPI_Send(&z[my_length], 1, PVEC_REAL_MPI_TYPE, my_pe_p1, 0, comm);   
+
+  /* Receive needed data from processes before and after current process. */
+  if (my_pe != 0)
+    MPI_Recv(&z[0], 1, PVEC_REAL_MPI_TYPE, my_pe_m1, 0, comm, &status);
+  else 
+    z[0] = ZERO;
+  if (my_pe != last_pe)
+    MPI_Recv(&z[my_length+1], 1, PVEC_REAL_MPI_TYPE, my_pe_p1, 0, comm,
+             &status);   
+  else 
+    z[my_length + 1] = ZERO;
+
+  /* Loop over all grid points in current process. */
+  for (i=1; i<=my_length; i++) {
+
+    /* Extract u at x_i and two neighboring points */
+    ui = z[i];
+    ult = z[i-1];
+    urt = z[i+1];
+
+    /* Set diffusion and advection terms and load into udot */
+    hdiff = hordc*(ult - RCONST(2.0)*ui + urt);
+    hadv = horac*(urt - ult);
+    udotdata[i-1] = hdiff + hadv;
+  }
+
+  return(0);
+}
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR(%d): %s() failed with flag = %d\n\n",
+              id, funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR(%d): %s() failed - returned NULL pointer\n\n",
+            id, funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvode/parhyp/cvAdvDiff_non_ph.out b/examples/cvode/parhyp/cvAdvDiff_non_ph.out
new file mode 100644
index 0000000..58432f6
--- /dev/null
+++ b/examples/cvode/parhyp/cvAdvDiff_non_ph.out
@@ -0,0 +1,21 @@
+
+ 1-D advection-diffusion equation, mesh size = 10 
+
+ Number of PEs =   2 
+
+At t = 0.00  max.norm(u) =  1.569909e+01  nst =   0 
+At t = 0.50  max.norm(u) =  3.052881e+00  nst = 113 
+At t = 1.00  max.norm(u) =  8.753188e-01  nst = 191 
+At t = 1.50  max.norm(u) =  2.494926e-01  nst = 265 
+At t = 2.00  max.norm(u) =  7.109437e-02  nst = 332 
+At t = 2.50  max.norm(u) =  2.026176e-02  nst = 405 
+At t = 3.00  max.norm(u) =  5.769193e-03  nst = 468 
+At t = 3.50  max.norm(u) =  1.651582e-03  nst = 541 
+At t = 4.00  max.norm(u) =  4.764197e-04  nst = 623 
+At t = 4.50  max.norm(u) =  1.370219e-04  nst = 704 
+At t = 5.00  max.norm(u) =  3.990405e-05  nst = 785 
+
+Final Statistics: 
+
+nst = 785     nfe  = 1442    nni = 1438    ncfn = 140     netf = 5
+ 
diff --git a/examples/cvode/serial/CMakeLists.txt b/examples/cvode/serial/CMakeLists.txt
index 6c539b8..1e04c45 100644
--- a/examples/cvode/serial/CMakeLists.txt
+++ b/examples/cvode/serial/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.5 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4957 $
+# $Date: 2016-09-23 12:21:47 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for CVODE serial examples
 
@@ -24,6 +29,14 @@ SET(CVODE_examples
   cvRoberts_dns_uw
   )
 
+SET(CVODE_examples_KLU
+  cvRoberts_klu
+  )
+
+SET(CVODE_examples_SUPERLUMT
+  cvRoberts_sps
+  )
+
 # Add variable CVODE_examples_BL with the names of the serial CVODE examples
 # that use Lapack
 
@@ -47,14 +60,27 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${CVODE_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(HYPRE_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${HYPRE_LIBRARIES})
+ENDIF(HYPRE_FOUND)
+
 # Add the build and install targets for each CVODE example
 
 FOREACH(example ${CVODE_examples})
   ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/serial)
@@ -62,10 +88,11 @@ FOREACH(example ${CVODE_examples})
 ENDFOREACH(example ${CVODE_examples})
 
 # Add the build and install targets for each Lapack CVODE example (if needed)
-
 IF(LAPACK_FOUND)
   FOREACH(example ${CVODE_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     IF(EXAMPLES_INSTALL)
       INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/serial)
@@ -73,6 +100,34 @@ IF(LAPACK_FOUND)
   ENDFOREACH(example ${CVODE_examples_BL})
 ENDIF(LAPACK_FOUND)
 
+# If KLU support is enabled, add the build and install targets for
+# the examples using KLU
+IF(KLU_FOUND)
+  FOREACH(example ${CVODE_examples_KLU})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${CVODE_examples_KLU})
+ENDIF(KLU_FOUND)
+
+# If SUPERLUMT support is enabled, add the build and install targets for
+# the examples using SUPERLUMT
+IF(SUPERLUMT_FOUND)
+  FOREACH(example ${CVODE_examples_SUPERLUMT})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvode/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${CVODE_examples_SUPERLUMT})
+ENDIF(SUPERLUMT_FOUND)
+
 IF(EXAMPLES_INSTALL)
 
   # Install the README file
@@ -82,12 +137,24 @@ IF(EXAMPLES_INSTALL)
   SET(SOLVER "CVODE")
   SET(SOLVER_LIB "sundials_cvode")
   LIST2STRING(CVODE_examples EXAMPLES)
+
   IF(LAPACK_FOUND)
     LIST2STRING(CVODE_examples_BL EXAMPLES_BL)
   ELSE(LAPACK_FOUND)
     SET(EXAMPLES_BL "")
   ENDIF(LAPACK_FOUND)
 
+  IF(KLU_FOUND)
+    LIST2STRING(CVODE_examples_KLU EXAMPLES)
+  ENDIF(KLU_FOUND)
+
+  IF(SUPERLUMT_FOUND)
+    LIST2STRING(CVODE_examples_SUPERLUMT EXAMPLES)
+  ENDIF(SUPERLUMT_FOUND)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
   # be used as a template for the user's own programs.
diff --git a/examples/cvode/serial/Makefile.in b/examples/cvode/serial/Makefile.in
deleted file mode 100644
index 2b1b71f..0000000
--- a/examples/cvode/serial/Makefile.in
+++ /dev/null
@@ -1,139 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for CVODE serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-SHARED_LIBS  = @SHARED_LIBS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/cvode/libsundials_cvode.la            \
-	        $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = cvAdvDiff_bnd \
-	   cvDirectDemo_ls \
-	   cvDiurnal_kry_bp \
-	   cvDiurnal_kry \
-	   cvKrylovDemo_ls \
-	   cvKrylovDemo_prec \
-	   cvRoberts_dns \
-	   cvRoberts_dns_uw 
-
-EXAMPLES_BL = cvAdvDiff_bndL \
-	      cvRoberts_dnsL
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done ; \
-	fi
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/cvode/serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/cvode/serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/cvode/serial/README $(EXS_INSTDIR)/cvode/serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/serial/$${i}.c   $(EXS_INSTDIR)/cvode/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/serial/$${i}.out $(EXS_INSTDIR)/cvode/serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/serial/$${i}.c   $(EXS_INSTDIR)/cvode/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvode/serial/$${i}.out $(EXS_INSTDIR)/cvode/serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/cvode/serial/Makefile
-	rm -f $(EXS_INSTDIR)/cvode/serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/cvode/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/cvode/serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/cvode/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/cvode/serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode/serial
-	$(rminstalldirs) $(EXS_INSTDIR)/cvode
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	${SHELL} ./config.status --recheck ; \
-	cd ${abs_builddir}
diff --git a/examples/cvode/serial/README b/examples/cvode/serial/README
index 7423632..c5a0ee2 100644
--- a/examples/cvode/serial/README
+++ b/examples/cvode/serial/README
@@ -10,16 +10,52 @@ List of serial CVODE examples
   cvRoberts_dns      : dense example
   cvRoberts_dnsL     : dense example (Lapack)
   cvRoberts_dns_uw   : dense example with user ewt function
+  cvRoberts_klu      : dense example with KLU sparse linear solver
+  cvRoberts_sps      : dense example with SuperLUMT sparse linear solver
 
-Sample results:
 
-  SUNDIALS was built with the following options:
 
-  ./configure CC=gcc F77=g77 CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --with-blas-lapack-libs="-L/home/radu/apps/lib -lSimTKlapack" --enable-examples 
+The following CMake command was used to configure SUNDIALS:
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  The SimTKlapack library provides ATLAS-tunned Blas and Lapack functions
\ No newline at end of file
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvode/serial/cvAdvDiff_bnd.c b/examples/cvode/serial/cvAdvDiff_bnd.c
index e9e249f..eec9cdb 100644
--- a/examples/cvode/serial/cvAdvDiff_bnd.c
+++ b/examples/cvode/serial/cvAdvDiff_bnd.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -68,7 +68,7 @@
    to the underlying 1-dimensional storage. 
    IJth(vdata,i,j) references the element in the vdata array for
    u at mesh point (i,j), where 1 <= i <= MX, 1 <= j <= MY.
-   The vdata array is obtained via the macro call vdata = NV_DATA_S(v),
+   The vdata array is obtained via the macro call vdata = N_VGetArrayPointer_Serial(v),
    where v is an N_Vector. 
    The variables are ordered by the y index j, then by the x index i. */
 
@@ -89,7 +89,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -201,8 +201,8 @@ static int f(realtype t, N_Vector u,N_Vector udot, void *user_data)
   int i, j;
   UserData data;
 
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Extract needed constants from data */
 
@@ -302,7 +302,7 @@ static void SetIC(N_Vector u, UserData data)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profile into u vector */
   
@@ -310,7 +310,7 @@ static void SetIC(N_Vector u, UserData data)
     y = j*dy;
     for (i=1; i <= MX; i++) {
       x = i*dx;
-      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*EXP(FIVE*x*y);
+      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*SUNRexp(FIVE*x*y);
     }
   }  
 }
@@ -327,9 +327,9 @@ static void PrintHeader(realtype reltol, realtype abstol, realtype umax)
          reltol, abstol);
   printf("At t = %Lg      max.norm(u) =%14.6Le \n", T0, umax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters: reltol = %lg   abstol = %lg\n\n",
+  printf("Tolerance parameters: reltol = %g   abstol = %g\n\n",
          reltol, abstol);
-  printf("At t = %lg      max.norm(u) =%14.6le \n", T0, umax);
+  printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
 #else
   printf("Tolerance parameters: reltol = %g   abstol = %g\n\n", reltol, abstol);
   printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
@@ -345,7 +345,7 @@ static void PrintOutput(realtype t, realtype umax, long int nst)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %4.2Lf   max.norm(u) =%14.6Le   nst = %4ld\n", t, umax, nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %4.2f   max.norm(u) =%14.6le   nst = %4ld\n", t, umax, nst);
+  printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
 #else
   printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
 #endif
@@ -395,7 +395,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvode/serial/cvAdvDiff_bndL.c b/examples/cvode/serial/cvAdvDiff_bndL.c
index 35dfb86..c9c0625 100644
--- a/examples/cvode/serial/cvAdvDiff_bndL.c
+++ b/examples/cvode/serial/cvAdvDiff_bndL.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -65,7 +65,7 @@
    to the underlying 1-dimensional storage. 
    IJth(vdata,i,j) references the element in the vdata array for
    u at mesh point (i,j), where 1 <= i <= MX, 1 <= j <= MY.
-   The vdata array is obtained via the macro call vdata = NV_DATA_S(v),
+   The vdata array is obtained via the macro call vdata = N_VGetArrayPointer_Serial(v),
    where v is an N_Vector. 
    The variables are ordered by the y index j, then by the x index i. */
 
@@ -86,7 +86,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -197,8 +197,8 @@ static int f(realtype t, N_Vector u,N_Vector udot, void *user_data)
   int i, j;
   UserData data;
 
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Extract needed constants from data */
 
@@ -299,7 +299,7 @@ static void SetIC(N_Vector u, UserData data)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profile into u vector */
   
@@ -307,7 +307,7 @@ static void SetIC(N_Vector u, UserData data)
     y = j*dy;
     for (i=1; i <= MX; i++) {
       x = i*dx;
-      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*EXP(FIVE*x*y);
+      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*SUNRexp(FIVE*x*y);
     }
   }  
 }
@@ -390,7 +390,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvode/serial/cvDirectDemo_ls.c b/examples/cvode/serial/cvDirectDemo_ls.c
index 756e854..f64e1ee 100644
--- a/examples/cvode/serial/cvDirectDemo_ls.c
+++ b/examples/cvode/serial/cvDirectDemo_ls.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -30,22 +30,23 @@
  * called for each of the remaining seven runs.
  *
  * Notes: This program demonstrates the usage of the sequential
- * macros NV_Ith_S, NV_DATA_S, DENSE_ELEM, BAND_COL, and
+ * macros NV_Ith_S, DENSE_ELEM, BAND_COL, and
  * BAND_COL_ELEM. The NV_Ith_S macro is used to reference the
  * components of an N_Vector. It works for any size N=NEQ, but
  * due to efficiency concerns it should only by used when the
  * problem size is small. The Problem 1 right hand side and
- * Jacobian functions f1 and Jac1 both use NV_Ith_S. The NV_DATA_S
- * macro gives the user access to the memory used for the component
- * storage of an N_Vector. In the sequential case, the user may
- * assume that this is one contiguous array of reals. The NV_DATA_S
- * macro gives a more efficient means (than the NV_Ith_S macro) to
+ * Jacobian functions f1 and Jac1 both use NV_Ith_S. The 
+ * N_VGetArrayPointer_Serial function gives the user access to the 
+ * memory used for the component storage of an N_Vector. In the 
+ * sequential case, the user may assume that this is one contiguous 
+ * array of reals. The N_VGetArrayPointer_Serial function
+ * gives a more efficient means (than the NV_Ith_S macro) to
  * access the components of an N_Vector and should be used when the
  * problem size is large. The Problem 2 right hand side function f2
- * uses the NV_DATA_S macro. The DENSE_ELEM macro used in Jac1
- * gives access to an element of a dense matrix of type DlsMat.
- * It should be used only when the problem size is small (the size
- * of a DlsMat is NEQ x NEQ) due to efficiency concerns. For
+ * uses the N_VGetArrayPointer_Serial function. The DENSE_ELEM macro 
+ * used in Jac1 gives access to an element of a dense matrix of type 
+ * DlsMat. It should be used only when the problem size is small (the 
+ * size of a DlsMat is NEQ x NEQ) due to efficiency concerns. For
  * larger problem sizes, the macro DENSE_COL can be used in order
  * to work directly with a column of a DlsMat. The BAND_COL and
  * BAND_COL_ELEM allow efficient columnwise access to the elements
@@ -64,7 +65,7 @@
 #include <cvode/cvode_diag.h>        /* use CVDIAG linear solver */
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS, SQR, and EXP*/
+#include <sundials/sundials_math.h>  /* contains the macros ABS, SUNSQR, and EXP*/
 
 /* Shared Problem Constants */
 
@@ -137,7 +138,7 @@ static int Jac2(long int N, long int mu, long int ml,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Implementation */
 
@@ -208,7 +209,7 @@ static int Problem1(void)
         break;
       }
       if (iout%2 == 0) {
-        er = ABS(NV_Ith_S(y,0)) / abstol;
+        er = SUNRabs(NV_Ith_S(y,0)) / abstol;
         if (er > ero) ero = er;
         if (er > P1_TOL_FACTOR) {
           nerr++;
@@ -261,7 +262,7 @@ static int Problem1(void)
         break;
       }
       if (iout%2 == 0) {
-        er = ABS(NV_Ith_S(y,0)) / abstol;
+        er = SUNRabs(NV_Ith_S(y,0)) / abstol;
         if (er > ero) ero = er;
         if (er > P1_TOL_FACTOR) {
           nerr++;
@@ -289,7 +290,7 @@ static void PrintIntro1(void)
   printf(" neq = %d,  reltol = %.2Lg,  abstol = %.2Lg",
 	 P1_NEQ, RTOL, ATOL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf(" neq = %d,  reltol = %.2lg,  abstol = %.2lg",
+  printf(" neq = %d,  reltol = %.2g,  abstol = %.2g",
 	 P1_NEQ, RTOL, ATOL);
 #else
   printf(" neq = %d,  reltol = %.2g,  abstol = %.2g",
@@ -309,7 +310,7 @@ static void PrintOutput1(realtype t, realtype y0, realtype y1, int qu, realtype
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%10.5Lf    %12.5Le   %12.5Le   %2d    %6.4Le\n", t, y0, y1, qu, hu);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%10.5f    %12.5le   %12.5le   %2d    %6.4le\n", t, y0, y1, qu, hu);
+  printf("%10.5f    %12.5e   %12.5e   %2d    %6.4e\n", t, y0, y1, qu, hu);
 #else
   printf("%10.5f    %12.5e   %12.5e   %2d    %6.4e\n", t, y0, y1, qu, hu);
 #endif
@@ -325,7 +326,7 @@ static int f1(realtype t, N_Vector y, N_Vector ydot, void *user_data)
   y1 = NV_Ith_S(y,1);
 
   NV_Ith_S(ydot,0) = y1;
-  NV_Ith_S(ydot,1) = (ONE - SQR(y0))* P1_ETA * y1 - y0;
+  NV_Ith_S(ydot,1) = (ONE - SUNSQR(y0))* P1_ETA * y1 - y0;
 
   return(0);
 } 
@@ -342,7 +343,7 @@ static int Jac1(long int N, realtype tn,
 
   DENSE_ELEM(J,0,1) = ONE;
   DENSE_ELEM(J,1,0) = -TWO * P1_ETA * y0 * y1 - ONE;
-  DENSE_ELEM(J,1,1) = P1_ETA * (ONE - SQR(y0));
+  DENSE_ELEM(J,1,1) = P1_ETA * (ONE - SUNSQR(y0));
 
   return(0);
 }
@@ -485,11 +486,10 @@ static void PrintIntro2(void)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf(" itol = %s, reltol = %.2Lg, abstol = %.2Lg", "CV_SS", RTOL, ATOL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf(" itol = %s, reltol = %.2lg, abstol = %.2lg", "CV_SS", RTOL, ATOL);
+  printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL);
 #else
   printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL);
 #endif
-  printf("\n      t        max.err      qu     hu \n");
 }
 
 static void PrintHeader2(void)
@@ -504,7 +504,7 @@ static void PrintOutput2(realtype t, realtype erm, int qu, realtype hu)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%10.3Lf  %12.4Le   %2d   %12.4Le\n", t, erm, qu, hu);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%10.3f  %12.4le   %2d   %12.4le\n", t, erm, qu, hu);
+  printf("%10.3f  %12.4e   %2d   %12.4e\n", t, erm, qu, hu);
 #else
   printf("%10.3f  %12.4e   %2d   %12.4e\n", t, erm, qu, hu);
 #endif
@@ -517,8 +517,8 @@ static int f2(realtype t, N_Vector y, N_Vector ydot, void *user_data)
   long int i, j, k;
   realtype d, *ydata, *dydata;
   
-  ydata = NV_DATA_S(y);
-  dydata = NV_DATA_S(ydot);
+  ydata = N_VGetArrayPointer_Serial(y);
+  dydata = N_VGetArrayPointer_Serial(ydot);
 
   /*
      Excluding boundaries, 
@@ -584,15 +584,15 @@ static realtype MaxError(N_Vector y, realtype t)
   
   if (t == ZERO) return(ZERO);
 
-  ydata = NV_DATA_S(y);
-  if (t <= THIRTY) ex = EXP(-TWO*t); 
+  ydata = N_VGetArrayPointer_Serial(y);
+  if (t <= THIRTY) ex = SUNRexp(-TWO*t);
   
   for (j = 0; j < P2_MESHY; j++) {
     ifact_inv = ONE;
     for (i = 0; i < P2_MESHX; i++) {
       k = i + j * P2_MESHX;
-      yt = RPowerI(t,i+j) * ex * ifact_inv * jfact_inv;
-      er = ABS(ydata[k] - yt);
+      yt = SUNRpowerI(t,i+j) * ex * ifact_inv * jfact_inv;
+      er = SUNRabs(ydata[k] - yt);
       if (er > maxError) maxError = er;
       ifact_inv /= (i+1);
     }
@@ -664,7 +664,7 @@ static void PrintErrOutput(realtype tol_factor)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("\n\n Error exceeds %Lg * tolerance \n\n", tol_factor);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("\n\n Error exceeds %lg * tolerance \n\n", tol_factor);
+  printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor);
 #else
   printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor);
 #endif
@@ -761,7 +761,7 @@ static void PrintErrInfo(int nerr)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvode/serial/cvDirectDemo_ls.out b/examples/cvode/serial/cvDirectDemo_ls.out
index 517e697..7c8b837 100644
--- a/examples/cvode/serial/cvDirectDemo_ls.out
+++ b/examples/cvode/serial/cvDirectDemo_ls.out
@@ -3,7 +3,7 @@ Demonstration program for CVODE package - direct linear solvers
 
 Problem 1: Van der Pol oscillator
  xdotdot - 3*(1 - x^2)*xdot + x = 0, x(0) = 2, xdot(0) = 0
- neq = 2,  itol = CV_SS,  reltol = 0,  abstol = 1e-06
+ neq = 2,  reltol = 0,  abstol = 1e-06
 
 -------------------------------------------------------------
 
@@ -249,8 +249,6 @@ triangular matrix derived from 2-D advection PDE
 
  neq = 25, ml = 5, mu = 0
  itol = CV_SS, reltol = 0, abstol = 1e-06
-      t        max.err      qu     hu 
-
 
 -------------------------------------------------------------
 
diff --git a/examples/cvode/serial/cvDiurnal_kry.c b/examples/cvode/serial/cvDiurnal_kry.c
index 4075d25..4dd127a 100644
--- a/examples/cvode/serial/cvDiurnal_kry.c
+++ b/examples/cvode/serial/cvDiurnal_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4848 $
+ * $Date: 2016-08-03 15:51:16 -0700 (Wed, 03 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -41,7 +41,7 @@
 #include <nvector/nvector_serial.h>   /* serial N_Vector types, fct., macros */
 #include <sundials/sundials_dense.h>  /* use generic dense solver in precond. */
 #include <sundials/sundials_types.h>  /* definition of realtype */
-#include <sundials/sundials_math.h>   /* contains the macros ABS, SQR, EXP */
+#include <sundials/sundials_math.h>   /* contains the macros ABS, SUNSQR, EXP */
 
 /* Problem Constants */
 
@@ -98,7 +98,7 @@
    IJKth(vdata,i,j,k) references the element in the vdata array for
    species i at mesh point (j,k), where 1 <= i <= NUM_SPECIES,
    0 <= j <= MX-1, 0 <= k <= MY-1. The vdata array is obtained via
-   the macro call vdata = NV_DATA_S(v), where v is an N_Vector. 
+   the macro call vdata = N_VGetArrayPointer_Serial(v), where v is an N_Vector. 
    For each mesh point (j,k), the elements for species i and i+1 are
    contiguous within vdata.
 
@@ -127,7 +127,7 @@ static void FreeUserData(UserData data);
 static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy);
 static void PrintOutput(void *cvode_mem, N_Vector u, realtype t);
 static void PrintFinalStats(void *cvode_mem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -205,10 +205,6 @@ int main()
   flag = CVSpilsSetJacTimesVecFn(cvode_mem, jtv);
   if(check_flag(&flag, "CVSpilsSetJacTimesVecFn", 1)) return(1);
 
-  /* Set modified Gram-Schmidt orthogonalization */
-  flag = CVSpilsSetGSType(cvode_mem, MODIFIED_GS);
-  if(check_flag(&flag, "CVSpilsSetGSType", 1)) return(1);
-
   /* Set the preconditioner solve and setup functions */
   flag = CVSpilsSetPreconditioner(cvode_mem, Precond, PSolve);
   if(check_flag(&flag, "CVSpilsSetPreconditioner", 1)) return(1);
@@ -264,9 +260,9 @@ static void InitUserData(UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/(MX-1);
   data->dy = (YMAX-YMIN)/(MY-1);
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(TWO*data->dx);
-  data->vdco = (ONE/SQR(data->dy))*KV0;
+  data->vdco = (ONE/SUNSQR(data->dy))*KV0;
 }
 
 /* Free data memory */
@@ -296,18 +292,18 @@ static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profiles of c1 and c2 into u vector */
 
   for (jy=0; jy < MY; jy++) {
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - YMID));
-    cy = ONE - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - YMID));
+    cy = ONE - cy + RCONST(0.5)*SUNSQR(cy);
     for (jx=0; jx < MX; jx++) {
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - XMID));
-      cx = ONE - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - XMID));
+      cx = ONE - cx + RCONST(0.5)*SUNSQR(cx);
       IJKth(udata,1,jx,jy) = C1_SCALE*cx*cy; 
       IJKth(udata,2,jx,jy) = C2_SCALE*cx*cy;
     }
@@ -323,7 +319,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   realtype hu, *udata;
   int mxh = MX/2 - 1, myh = MY/2 - 1, mx1 = MX - 1, my1 = MY - 1;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -340,11 +336,11 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   printf("c2 (bot.left/middle/top rt.) = %12.3Le  %12.3Le  %12.3Le\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+  printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
          t, nst, qu, hu);
-  printf("c1 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n",
+  printf("c1 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n",
          IJKth(udata,1,0,0), IJKth(udata,1,mxh,myh), IJKth(udata,1,mx1,my1));
-  printf("c2 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n\n",
+  printf("c2 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #else
   printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
@@ -413,7 +409,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
@@ -459,15 +455,15 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   UserData data;
 
   data = (UserData) user_data;
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    data->q4 = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
       q3 = ZERO;
       data->q4 = ZERO;
@@ -489,8 +485,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
     for (jx=0; jx < MX; jx++) {
@@ -557,15 +553,15 @@ static int jtv(N_Vector v, N_Vector Jv, realtype t,
 
   data = (UserData) user_data;
 
-  udata = NV_DATA_S(u);
-  vdata = NV_DATA_S(v);
-  Jvdata = NV_DATA_S(Jv);
+  udata = N_VGetArrayPointer_Serial(u);
+  vdata = N_VGetArrayPointer_Serial(v);
+  Jvdata = N_VGetArrayPointer_Serial(Jv);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    data->q4 = EXP(-A4/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
     data->q4 = ZERO;
   }
@@ -587,8 +583,8 @@ static int jtv(N_Vector v, N_Vector Jv, realtype t,
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
 
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
 
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
@@ -631,38 +627,48 @@ static int jtv(N_Vector v, N_Vector Jv, realtype t,
 
       /* Set kinetic rate terms. */
 
-      //rkin1 = -Q1*C3 * c1 - Q2 * c1*c2 + q4coef * c2  + TWO*C3*q3;
-      //rkin2 =  Q1*C3 * c1 - Q2 * c1*c2 - q4coef * c2;
+      /* 
+	 rkin1 = -Q1*C3 * c1 - Q2 * c1*c2 + q4coef * c2  + TWO*C3*q3;
+         rkin2 =  Q1*C3 * c1 - Q2 * c1*c2 - q4coef * c2; 
+      */
 
       Jv1 += -(Q1*C3 + Q2*c2) * v1  +  (q4coef - Q2*c1) * v2;
       Jv2 +=  (Q1*C3 - Q2*c2) * v1  -  (q4coef + Q2*c1) * v2;
 
       /* Set vertical diffusion terms. */
 
-      //vertd1 = -(cyup+cydn) * c1 + cyup * c1up + cydn * c1dn;
-      //vertd2 = -(cyup+cydn) * c2 + cyup * c2up + cydn * c2dn;
+      /* 
+	 vertd1 = -(cyup+cydn) * c1 + cyup * c1up + cydn * c1dn;
+	 vertd2 = -(cyup+cydn) * c2 + cyup * c2up + cydn * c2dn;
+      */
 
       Jv1 += -(cyup+cydn) * v1  +  cyup * v1up  +  cydn * v1dn;
       Jv2 += -(cyup+cydn) * v2  +  cyup * v2up  +  cydn * v2dn;
 
       /* Set horizontal diffusion and advection terms. */
 
-      //hord1 = hordco*(c1rt - TWO*c1 + c1lt);
-      //hord2 = hordco*(c2rt - TWO*c2 + c2lt);
+      /* 
+	 hord1 = hordco*(c1rt - TWO*c1 + c1lt);
+	 hord2 = hordco*(c2rt - TWO*c2 + c2lt);
+      */
 
       Jv1 += hordco*(v1rt - TWO*v1 + v1lt);
       Jv2 += hordco*(v2rt - TWO*v2 + v2lt);
 
-      //horad1 = horaco*(c1rt - c1lt);
-      //horad2 = horaco*(c2rt - c2lt);
+      /* 
+	 horad1 = horaco*(c1rt - c1lt);
+	 horad2 = horaco*(c2rt - c2lt);
+      */
 
       Jv1 += horaco*(v1rt - v1lt);
       Jv2 += horaco*(v2rt - v2lt);
 
       /* Load two components of J*v */
 
-      //IJKth(dudata, 1, jx, jy) = vertd1 + hord1 + horad1 + rkin1; 
-      //IJKth(dudata, 2, jx, jy) = vertd2 + hord2 + horad2 + rkin2;
+      /* 
+	 IJKth(dudata, 1, jx, jy) = vertd1 + hord1 + horad1 + rkin1; 
+	 IJKth(dudata, 2, jx, jy) = vertd2 + hord2 + horad2 + rkin2;
+      */
 
       IJKth(Jvdata, 1, jx, jy) = Jv1;
       IJKth(Jvdata, 2, jx, jy) = Jv2;
@@ -696,7 +702,7 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
   
   if (jok) {
     
@@ -726,8 +732,8 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
     for (jy=0; jy < MY; jy++) {
       ydn = YMIN + (jy - RCONST(0.5))*dely;
       yup = ydn + dely;
-      cydn = verdco*EXP(RCONST(0.2)*ydn);
-      cyup = verdco*EXP(RCONST(0.2)*yup);
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
       diag = -(cydn + cyup + TWO*hordco);
       for (jx=0; jx < MX; jx++) {
         c1 = IJKth(udata,1,jx,jy);
@@ -783,7 +789,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
   data = (UserData) user_data;
   P = data->P;
   pivot = data->pivot;
-  zdata = NV_DATA_S(z);
+  zdata = N_VGetArrayPointer_Serial(z);
   
   N_VScale(ONE, r, z);
   
diff --git a/examples/cvode/serial/cvDiurnal_kry_bp.c b/examples/cvode/serial/cvDiurnal_kry_bp.c
index d847dc4..25643dd 100644
--- a/examples/cvode/serial/cvDiurnal_kry_bp.c
+++ b/examples/cvode/serial/cvDiurnal_kry_bp.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @LLNL
@@ -40,7 +40,7 @@
 #include <cvode/cvode_bandpre.h>     /* prototypes & constants for CVBANDPRE module */
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS, SQR, and EXP */
+#include <sundials/sundials_math.h>  /* contains the macros ABS, SUNSQR, and EXP */
 
 /* Problem Constants */
 
@@ -97,7 +97,7 @@
    IJKth(vdata,i,j,k) references the element in the vdata array for
    species i at mesh point (j,k), where 1 <= i <= NUM_SPECIES,
    0 <= j <= MX-1, 0 <= k <= MY-1. The vdata array is obtained via
-   the macro call vdata = NV_DATA_S(v), where v is an N_Vector. 
+   the macro call vdata = N_VGetArrayPointer_Serial(v), where v is an N_Vector. 
    For each mesh point (j,k), the elements for species i and i+1 are
    contiguous within vdata.
 
@@ -125,7 +125,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t);
 static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Function Called by the Solver */
 
@@ -206,8 +206,11 @@ int main()
       if(check_flag(&flag, "CVodeReInit", 1)) return(1);
 
       flag = CVSpilsSetPrecType(cvode_mem, PREC_RIGHT);
-      check_flag(&flag, "CVSpilsSetPrecType", 1);
-      
+      if(check_flag(&flag, "CVSpilsSetPrecType", 1)) return(1);
+
+      flag = CVBandPrecInit(cvode_mem, NEQ, mu, ml);
+      if(check_flag(&flag, "CVBandPrecInit", 0)) return(1);
+
       printf("\n\n-------------------------------------------------------");
       printf("------------\n");
     }
@@ -253,9 +256,9 @@ static void InitUserData(UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/(MX-1);
   data->dy = (YMAX-YMIN)/(MY-1);
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(TWO*data->dx);
-  data->vdco = (ONE/SQR(data->dy))*KV0;
+  data->vdco = (ONE/SUNSQR(data->dy))*KV0;
 }
 
 /* Set initial conditions in u */
@@ -268,18 +271,18 @@ static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profiles of c1 and c2 into u vector */
 
   for (jy = 0; jy < MY; jy++) {
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - YMID));
-    cy = ONE - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - YMID));
+    cy = ONE - cy + RCONST(0.5)*SUNSQR(cy);
     for (jx = 0; jx < MX; jx++) {
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - XMID));
-      cx = ONE - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - XMID));
+      cx = ONE - cx + RCONST(0.5)*SUNSQR(cx);
       IJKth(udata,1,jx,jy) = C1_SCALE*cx*cy; 
       IJKth(udata,2,jx,jy) = C2_SCALE*cx*cy;
     }
@@ -290,7 +293,7 @@ static void PrintIntro(long int mu, long int ml)
 {
   printf("2-species diurnal advection-diffusion problem, %d by %d mesh\n",
          MX, MY);
-  printf("SPGMR solver; band preconditioner; mu = %d, ml = %d\n\n",
+  printf("SPGMR solver; band preconditioner; mu = %ld, ml = %ld\n\n",
          mu, ml);
 
   return;
@@ -305,7 +308,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u,realtype t)
   realtype hu, *udata;
   int mxh = MX/2 - 1, myh = MY/2 - 1, mx1 = MX - 1, my1 = MY - 1;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -322,11 +325,11 @@ static void PrintOutput(void *cvode_mem, N_Vector u,realtype t)
   printf("c2 (bot.left/middle/top rt.) = %12.3Le  %12.3Le  %12.3Le\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+  printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
          t, nst, qu, hu);
-  printf("c1 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n",
+  printf("c1 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n",
          IJKth(udata,1,0,0), IJKth(udata,1,mxh,myh), IJKth(udata,1,mx1,my1));
-  printf("c2 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n\n",
+  printf("c2 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #else
   printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
@@ -404,7 +407,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
@@ -450,15 +453,15 @@ static int f(realtype t, N_Vector u, N_Vector udot,void *user_data)
   UserData data;
 
   data = (UserData) user_data;
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    data->q4 = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
     q3 = ZERO;
     data->q4 = ZERO;
@@ -480,8 +483,8 @@ static int f(realtype t, N_Vector u, N_Vector udot,void *user_data)
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
     for (jx = 0; jx < MX; jx++) {
diff --git a/examples/cvode/serial/cvDiurnal_kry_bp.out b/examples/cvode/serial/cvDiurnal_kry_bp.out
index 8de1c7b..2cb79d3 100644
--- a/examples/cvode/serial/cvDiurnal_kry_bp.out
+++ b/examples/cvode/serial/cvDiurnal_kry_bp.out
@@ -17,41 +17,41 @@ t = 2.16e+04   no. steps = 246   order = 5   stepsize = 2.78e+02
 c1 (bot.left/middle/top rt.) =    2.665e+07     1.036e+07     2.931e+07
 c2 (bot.left/middle/top rt.) =    2.993e+11     1.028e+11     3.313e+11
 
-t = 2.88e+04   no. steps = 291   order = 4   stepsize = 1.14e+02
+t = 2.88e+04   no. steps = 288   order = 4   stepsize = 1.14e+02
 c1 (bot.left/middle/top rt.) =    8.702e+06     1.292e+07     9.650e+06
 c2 (bot.left/middle/top rt.) =    3.380e+11     5.029e+11     3.751e+11
 
-t = 3.60e+04   no. steps = 331   order = 4   stepsize = 8.86e+01
+t = 3.60e+04   no. steps = 329   order = 4   stepsize = 9.61e+01
 c1 (bot.left/middle/top rt.) =    1.404e+04     2.029e+04     1.561e+04
 c2 (bot.left/middle/top rt.) =    3.387e+11     4.894e+11     3.765e+11
 
-t = 4.32e+04   no. steps = 402   order = 4   stepsize = 4.15e+02
-c1 (bot.left/middle/top rt.) =   -5.769e-09     3.421e-09    -3.866e-09
+t = 4.32e+04   no. steps = 401   order = 4   stepsize = 3.13e+02
+c1 (bot.left/middle/top rt.) =   -9.450e-09     3.907e-09    -1.083e-08
 c2 (bot.left/middle/top rt.) =    3.382e+11     1.355e+11     3.804e+11
 
-t = 5.04e+04   no. steps = 415   order = 5   stepsize = 4.58e+02
-c1 (bot.left/middle/top rt.) =   -4.979e-18    -7.193e-15    -2.653e-15
+t = 5.04e+04   no. steps = 416   order = 4   stepsize = 3.68e+02
+c1 (bot.left/middle/top rt.) =    1.195e-10     4.155e-08     2.046e-10
 c2 (bot.left/middle/top rt.) =    3.358e+11     4.930e+11     3.864e+11
 
-t = 5.76e+04   no. steps = 430   order = 4   stepsize = 2.19e+02
-c1 (bot.left/middle/top rt.) =    1.611e-17     4.587e-16    -4.704e-18
+t = 5.76e+04   no. steps = 430   order = 5   stepsize = 3.78e+02
+c1 (bot.left/middle/top rt.) =   -5.093e-11    -2.114e-08     2.070e-10
 c2 (bot.left/middle/top rt.) =    3.320e+11     9.650e+11     3.909e+11
 
-t = 6.48e+04   no. steps = 444   order = 4   stepsize = 5.79e+02
-c1 (bot.left/middle/top rt.) =    9.505e-16     1.154e-14    -2.316e-16
+t = 6.48e+04   no. steps = 438   order = 5   stepsize = 8.51e+02
+c1 (bot.left/middle/top rt.) =   -4.172e-14    -6.618e-11     6.513e-13
 c2 (bot.left/middle/top rt.) =    3.313e+11     8.922e+11     3.963e+11
 
-t = 7.20e+04   no. steps = 457   order = 4   stepsize = 5.79e+02
-c1 (bot.left/middle/top rt.) =    3.910e-16    -4.848e-14     2.545e-15
+t = 7.20e+04   no. steps = 447   order = 5   stepsize = 8.51e+02
+c1 (bot.left/middle/top rt.) =   -7.090e-20     2.812e-17     1.620e-21
 c2 (bot.left/middle/top rt.) =    3.330e+11     6.186e+11     4.039e+11
 
-t = 7.92e+04   no. steps = 469   order = 4   stepsize = 5.79e+02
-c1 (bot.left/middle/top rt.) =   -2.903e-15     2.152e-13     3.551e-16
-c2 (bot.left/middle/top rt.) =    3.334e+11     6.669e+11     4.120e+11
+t = 7.92e+04   no. steps = 455   order = 5   stepsize = 8.51e+02
+c1 (bot.left/middle/top rt.) =   -7.186e-20    -1.098e-16    -7.199e-22
+c2 (bot.left/middle/top rt.) =    3.334e+11     6.670e+11     4.120e+11
 
-t = 8.64e+04   no. steps = 481   order = 4   stepsize = 5.79e+02
-c1 (bot.left/middle/top rt.) =    2.358e-23     2.316e-18    -6.007e-16
-c2 (bot.left/middle/top rt.) =    3.352e+11     9.108e+11     4.162e+11
+t = 8.64e+04   no. steps = 464   order = 5   stepsize = 8.51e+02
+c1 (bot.left/middle/top rt.) =   -5.534e-20     1.005e-16     1.567e-21
+c2 (bot.left/middle/top rt.) =    3.352e+11     9.106e+11     4.162e+11
 
 
 Final Statistics.. 
@@ -59,12 +59,12 @@ Final Statistics..
 lenrw   =  2089     leniw   =    50
 lenrwls =  2046     leniwls =    10
 lenrwbp =  2400     leniwbp =   200
-nst     =   481
-nfe     =   620     nfetot  =  1226
-nfeLS   =   561     nfeBP   =    45
-nni     =   616     nli     =   561
-nsetups =    88     netf    =    28
-npe     =     9     nps     =  1096
+nst     =   464
+nfe     =   618     nfetot  =  1197
+nfeLS   =   539     nfeBP   =    40
+nni     =   614     nli     =   539
+nsetups =    90     netf    =    34
+npe     =     8     nps     =  1077
 ncfn    =     0     ncfl    =     0
 
 
@@ -86,41 +86,41 @@ t = 2.16e+04   no. steps = 279   order = 5   stepsize = 3.58e+02
 c1 (bot.left/middle/top rt.) =    2.665e+07     1.036e+07     2.931e+07
 c2 (bot.left/middle/top rt.) =    2.993e+11     1.028e+11     3.313e+11
 
-t = 2.88e+04   no. steps = 301   order = 5   stepsize = 2.40e+02
+t = 2.88e+04   no. steps = 301   order = 5   stepsize = 2.33e+02
 c1 (bot.left/middle/top rt.) =    8.702e+06     1.292e+07     9.650e+06
 c2 (bot.left/middle/top rt.) =    3.380e+11     5.029e+11     3.751e+11
 
-t = 3.60e+04   no. steps = 330   order = 5   stepsize = 1.31e+02
+t = 3.60e+04   no. steps = 330   order = 5   stepsize = 9.92e+01
 c1 (bot.left/middle/top rt.) =    1.404e+04     2.029e+04     1.561e+04
 c2 (bot.left/middle/top rt.) =    3.387e+11     4.894e+11     3.765e+11
 
-t = 4.32e+04   no. steps = 381   order = 4   stepsize = 3.91e+02
-c1 (bot.left/middle/top rt.) =    3.125e-10     2.750e-10     3.496e-10
+t = 4.32e+04   no. steps = 382   order = 4   stepsize = 4.44e+02
+c1 (bot.left/middle/top rt.) =   -8.802e-11    -3.760e-09    -4.964e-11
 c2 (bot.left/middle/top rt.) =    3.382e+11     1.355e+11     3.804e+11
 
-t = 5.04e+04   no. steps = 395   order = 5   stepsize = 4.06e+02
-c1 (bot.left/middle/top rt.) =   -3.259e-14    -1.715e-12    -6.477e-14
+t = 5.04e+04   no. steps = 403   order = 5   stepsize = 2.59e+02
+c1 (bot.left/middle/top rt.) =    7.139e-09    -2.417e-05     1.332e-07
 c2 (bot.left/middle/top rt.) =    3.358e+11     4.930e+11     3.864e+11
 
-t = 5.76e+04   no. steps = 408   order = 5   stepsize = 4.57e+02
-c1 (bot.left/middle/top rt.) =    2.382e-14     5.871e-12     6.950e-14
+t = 5.76e+04   no. steps = 418   order = 5   stepsize = 4.03e+02
+c1 (bot.left/middle/top rt.) =    2.831e-11     9.701e-10     2.116e-11
 c2 (bot.left/middle/top rt.) =    3.320e+11     9.650e+11     3.909e+11
 
-t = 6.48e+04   no. steps = 420   order = 5   stepsize = 7.04e+02
-c1 (bot.left/middle/top rt.) =    1.493e-18     1.862e-17    -7.080e-16
+t = 6.48e+04   no. steps = 430   order = 5   stepsize = 6.39e+02
+c1 (bot.left/middle/top rt.) =   -2.128e-19    -7.024e-17     3.263e-16
 c2 (bot.left/middle/top rt.) =    3.313e+11     8.922e+11     3.963e+11
 
-t = 7.20e+04   no. steps = 430   order = 5   stepsize = 7.04e+02
-c1 (bot.left/middle/top rt.) =   -1.345e-20     1.847e-18    -6.157e-16
+t = 7.20e+04   no. steps = 442   order = 5   stepsize = 6.39e+02
+c1 (bot.left/middle/top rt.) =    1.300e-20    -4.501e-19    -8.828e-17
 c2 (bot.left/middle/top rt.) =    3.330e+11     6.186e+11     4.039e+11
 
-t = 7.92e+04   no. steps = 440   order = 5   stepsize = 7.04e+02
-c1 (bot.left/middle/top rt.) =    3.617e-20    -3.355e-18    -7.407e-16
+t = 7.92e+04   no. steps = 453   order = 5   stepsize = 6.39e+02
+c1 (bot.left/middle/top rt.) =   -6.029e-20    -4.677e-18     3.192e-16
 c2 (bot.left/middle/top rt.) =    3.334e+11     6.669e+11     4.120e+11
 
-t = 8.64e+04   no. steps = 450   order = 5   stepsize = 7.04e+02
-c1 (bot.left/middle/top rt.) =   -5.505e-20     3.704e-18    -2.929e-15
-c2 (bot.left/middle/top rt.) =    3.352e+11     9.106e+11     4.163e+11
+t = 8.64e+04   no. steps = 464   order = 5   stepsize = 6.39e+02
+c1 (bot.left/middle/top rt.) =    4.164e-20     4.512e-18     7.737e-16
+c2 (bot.left/middle/top rt.) =    3.352e+11     9.107e+11     4.163e+11
 
 
 Final Statistics.. 
@@ -128,11 +128,11 @@ Final Statistics..
 lenrw   =  2089     leniw   =    50
 lenrwls =  2046     leniwls =    10
 lenrwbp =  2400     leniwbp =   200
-nst     =   450
-nfe     =   564     nfetot  =  1319
-nfeLS   =   670     nfeBP   =    85
-nni     =   560     nli     =   670
-nsetups =    71     netf    =    21
+nst     =   464
+nfe     =   582     nfetot  =  1277
+nfeLS   =   655     nfeBP   =    40
+nni     =   578     nli     =   655
+nsetups =    78     netf    =    23
 npe     =     8     nps     =  1140
 ncfn    =     0     ncfl    =     0
 
diff --git a/examples/cvode/serial/cvKrylovDemo_ls.c b/examples/cvode/serial/cvKrylovDemo_ls.c
index 12fe020..c1a99ed 100644
--- a/examples/cvode/serial/cvKrylovDemo_ls.c
+++ b/examples/cvode/serial/cvKrylovDemo_ls.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4848 $
+ * $Date: 2016-08-03 15:51:16 -0700 (Wed, 03 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -46,7 +46,7 @@
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_dense.h> /* use generic DENSE solver in preconditioning */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS, SQR, and EXP */
+#include <sundials/sundials_math.h>  /* contains the macros ABS, SUNSQR, and EXP */
 
 /* Problem Constants */
 
@@ -109,7 +109,7 @@
    IJKth(vdata,i,j,k) references the element in the vdata array for
    species i at mesh point (j,k), where 1 <= i <= NUM_SPECIES,
    0 <= j <= MX-1, 0 <= k <= MY-1. The vdata array is obtained via
-   the macro call vdata = NV_DATA_S(v), where v is an N_Vector. 
+   the macro call vdata = N_VGetArrayPointer_Serial(v), where v is an N_Vector. 
    For each mesh point (j,k), the elements for species i and i+1 are
    contiguous within vdata.
 
@@ -138,7 +138,7 @@ static void FreeUserData(UserData data);
 static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy);
 static void PrintOutput(void *cvode_mem, N_Vector u, realtype t);
 static void PrintFinalStats(void *cvode_mem, int linsolver);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -235,12 +235,6 @@ int main(void)
       flag = CVSpgmr(cvode_mem, PREC_LEFT, 0);
       if(check_flag(&flag, "CVSpgmr", 1)) return(1);
 
-      /* Set modified Gram-Schmidt orthogonalization, preconditioner 
-	 setup and solve routines Precond and PSolve, and the pointer 
-	 to the user-defined block data */
-      flag = CVSpilsSetGSType(cvode_mem, MODIFIED_GS);
-      if(check_flag(&flag, "CVSpilsSetGSType", 1)) return(1);
-
       break;
 
     /* (b) SPBCG */
@@ -334,9 +328,9 @@ static void InitUserData(UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/(MX-1);
   data->dy = (YMAX-YMIN)/(MY-1);
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(TWO*data->dx);
-  data->vdco = (ONE/SQR(data->dy))*KV0;
+  data->vdco = (ONE/SUNSQR(data->dy))*KV0;
 }
 
 /* Free data memory */
@@ -366,18 +360,18 @@ static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profiles of c1 and c2 into u vector */
 
   for (jy=0; jy < MY; jy++) {
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - YMID));
-    cy = ONE - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - YMID));
+    cy = ONE - cy + RCONST(0.5)*SUNSQR(cy);
     for (jx=0; jx < MX; jx++) {
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - XMID));
-      cx = ONE - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - XMID));
+      cx = ONE - cx + RCONST(0.5)*SUNSQR(cx);
       IJKth(udata,1,jx,jy) = C1_SCALE*cx*cy; 
       IJKth(udata,2,jx,jy) = C2_SCALE*cx*cy;
     }
@@ -393,7 +387,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   realtype hu, *udata;
   int mxh = MX/2 - 1, myh = MY/2 - 1, mx1 = MX - 1, my1 = MY - 1;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -410,11 +404,11 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   printf("c2 (bot.left/middle/top rt.) = %12.3Le  %12.3Le  %12.3Le\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+  printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
          t, nst, qu, hu);
-  printf("c1 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n",
+  printf("c1 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n",
          IJKth(udata,1,0,0), IJKth(udata,1,mxh,myh), IJKth(udata,1,mx1,my1));
-  printf("c2 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n\n",
+  printf("c2 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #else
   printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
@@ -486,7 +480,7 @@ static void PrintFinalStats(void *cvode_mem, int linsolver)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
@@ -532,15 +526,15 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   UserData data;
 
   data = (UserData) user_data;
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    data->q4 = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
       q3 = ZERO;
       data->q4 = ZERO;
@@ -562,8 +556,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
     for (jx=0; jx < MX; jx++) {
@@ -631,7 +625,7 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
   
   if (jok) {
     
@@ -661,8 +655,8 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
     for (jy=0; jy < MY; jy++) {
       ydn = YMIN + (jy - RCONST(0.5))*dely;
       yup = ydn + dely;
-      cydn = verdco*EXP(RCONST(0.2)*ydn);
-      cyup = verdco*EXP(RCONST(0.2)*yup);
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
       diag = -(cydn + cyup + TWO*hordco);
       for (jx=0; jx < MX; jx++) {
         c1 = IJKth(udata,1,jx,jy);
@@ -718,7 +712,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
   data = (UserData) user_data;
   P = data->P;
   pivot = data->pivot;
-  zdata = NV_DATA_S(z);
+  zdata = N_VGetArrayPointer_Serial(z);
   
   N_VScale(ONE, r, z);
   
diff --git a/examples/cvode/serial/cvKrylovDemo_prec.c b/examples/cvode/serial/cvKrylovDemo_prec.c
index 19ee71e..aaa7976 100644
--- a/examples/cvode/serial/cvKrylovDemo_prec.c
+++ b/examples/cvode/serial/cvKrylovDemo_prec.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -78,8 +78,8 @@
  * destroyMat and destroyArray.
  *
  * Note: This program assumes the sequential implementation for the
- * type N_Vector and uses the NV_DATA_S macro to gain access to the
- * contiguous array of components of an N_Vector.
+ * type N_Vector and uses the N_VGetArrayPointer_Serial function to 
+ * gain access to the contiguous array of components of an N_Vector.
  * --------------------------------------------------------------------
  * Reference: Peter N. Brown and Alan C. Hindmarsh, Reduced Storage
  * Matrix Methods in Stiff ODE Systems, J. Appl. Math. & Comp., 31
@@ -97,7 +97,7 @@
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_dense.h> /* use generic DENSE solver in preconditioning */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS and SQR */
+#include <sundials/sundials_math.h>  /* contains the macros ABS and SUNSQR */
 
 /* Constants */
 
@@ -214,7 +214,7 @@ static int PSolve(realtype tn, N_Vector c, N_Vector fc,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Implementation */
 
@@ -369,8 +369,8 @@ static void InitUserData(WebData wdata)
   dx = wdata->dx = DX;
   dy = wdata->dy = DY;
   for (i = 0; i < ns; i++) {
-    cox[i] = diff[i]/SQR(dx);
-    coy[i] = diff[i]/SQR(dy);
+    cox[i] = diff[i]/SUNSQR(dx);
+    coy[i] = diff[i]/SUNSQR(dy);
   }
 
   /* Set remaining method parameters */
@@ -379,7 +379,7 @@ static void InitUserData(WebData wdata)
   wdata->mq = MQ;
   wdata->mx = MX;
   wdata->my = MY;
-  wdata->srur = SQRT(UNIT_ROUNDOFF);
+  wdata->srur = SUNRsqrt(UNIT_ROUNDOFF);
   wdata->mxmp = MXMP;
   wdata->ngrp = NGRP;
   wdata->ngx = NGX;
@@ -422,21 +422,21 @@ static void CInit(N_Vector c, WebData wdata)
   int jx, jy, ns, mxns, ioff, iyoff, i, ici;
   realtype argx, argy, x, y, dx, dy, x_factor, y_factor, *cdata;
   
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
   ns = wdata->ns;
   mxns = wdata->mxns;
   dx = wdata->dx;
   dy = wdata->dy;
 
-  x_factor = RCONST(4.0)/SQR(AX);
-  y_factor = RCONST(4.0)/SQR(AY);
+  x_factor = RCONST(4.0)/SUNSQR(AX);
+  y_factor = RCONST(4.0)/SUNSQR(AY);
   for (jy = 0; jy < MY; jy++) {
     y = jy*dy;
-    argy = SQR(y_factor*y*(AY-y)); 
+    argy = SUNSQR(y_factor*y*(AY-y));
     iyoff = mxns*jy;
     for (jx = 0; jx < MX; jx++) {
       x = jx*dx;
-      argx = SQR(x_factor*x*(AX-x));
+      argx = SUNSQR(x_factor*x*(AX-x));
       ioff = iyoff + ns*jx;
       for (i = 1; i <= ns; i++) {
         ici = ioff + i-1;
@@ -459,12 +459,12 @@ static void PrintIntro(void)
          DPREY, DPRED);
   printf("Rate parameter alpha = %.2Lg\n\n", ALPH);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Matrix parameters: a = %.2lg   e = %.2lg   g = %.2lg\n",
+  printf("Matrix parameters: a = %.2g   e = %.2g   g = %.2g\n",
          AA, EE, GG);
-  printf("b parameter = %.2lg\n", BB);
-  printf("Diffusion coefficients: Dprey = %.2lg   Dpred = %.2lg\n",
+  printf("b parameter = %.2g\n", BB);
+  printf("Diffusion coefficients: Dprey = %.2g   Dpred = %.2g\n",
          DPREY, DPRED);
-  printf("Rate parameter alpha = %.2lg\n\n", ALPH);
+  printf("Rate parameter alpha = %.2g\n\n", ALPH);
 #else
   printf("Matrix parameters: a = %.2g   e = %.2g   g = %.2g\n",
          AA, EE, GG);
@@ -479,7 +479,7 @@ static void PrintIntro(void)
   printf("Tolerances: reltol = %.2Lg, abstol = %.2Lg \n\n",
          RTOL, ATOL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerances: reltol = %.2lg, abstol = %.2lg \n\n",
+  printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n",
          RTOL, ATOL);
 #else
   printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n",
@@ -514,11 +514,11 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, realtype t)
   int i, jx ,jy;
   realtype *cdata;
   
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("c values at t = %Lg:\n\n", t);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("c values at t = %lg:\n\n", t);
+  printf("c values at t = %g:\n\n", t);
 #else
   printf("c values at t = %g:\n\n", t);
 #endif
@@ -529,7 +529,7 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, realtype t)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
         printf("%-10.6Lg", cdata[(i-1) + jx*ns + jy*mxns]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-        printf("%-10.6lg", cdata[(i-1) + jx*ns + jy*mxns]);
+        printf("%-10.6g", cdata[(i-1) + jx*ns + jy*mxns]);
 #else
         printf("%-10.6g", cdata[(i-1) + jx*ns + jy*mxns]);
 #endif
@@ -561,8 +561,8 @@ static void PrintOutput(void *cvode_mem, realtype t)
   printf("t = %10.2Le  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
   printf("  qu = %d  hu = %11.2Le\n\n", qu, hu);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %10.2le  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
-  printf("  qu = %d  hu = %11.2le\n\n", qu, hu);
+  printf("t = %10.2e  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
+  printf("  qu = %d  hu = %11.2e\n\n", qu, hu);
 #else
   printf("t = %10.2e  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
   printf("  qu = %d  hu = %11.2e\n\n", qu, hu);
@@ -661,8 +661,8 @@ static int f(realtype t, N_Vector c, N_Vector cdot,void *user_data)
   WebData wdata;
   
   wdata = (WebData) user_data;
-  cdata = NV_DATA_S(c);
-  cdotdata = NV_DATA_S(cdot);
+  cdata = N_VGetArrayPointer_Serial(c);
+  cdotdata = N_VGetArrayPointer_Serial(cdot);
   
   mxns = wdata->mxns;
   ns = wdata->ns;
@@ -763,11 +763,11 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
   
   wdata = (WebData) user_data;
   cvode_mem = wdata->cvode_mem;
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
   rewt = wdata->rewt;
   flag = CVodeGetErrWeights(cvode_mem, rewt);
   if(check_flag(&flag, "CVodeGetErrWeights", 1)) return(1);
-  rewtdata = NV_DATA_S(rewt);
+  rewtdata = N_VGetArrayPointer_Serial(rewt);
 
   uround = UNIT_ROUNDOFF;
 
@@ -787,10 +787,10 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
      Here, fsave contains the base value of the rate vector and 
      r0 is a minimum increment factor for the difference quotient. */
   
-  f1 = NV_DATA_S(vtemp1);
+  f1 = N_VGetArrayPointer_Serial(vtemp1);
   
   fac = N_VWrmsNorm (fc, rewt);
-  r0 = RCONST(1000.0)*ABS(gamma)*uround*NEQ*fac;
+  r0 = RCONST(1000.0)*SUNRabs(gamma)*uround*NEQ*fac;
   if (r0 == ZERO) r0 = ONE;
   
   for (igy = 0; igy < ngy; igy++) {
@@ -805,7 +805,7 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
         /* Generate the jth column as a difference quotient */
         jj = if0 + j; 
         save = cdata[jj];
-        r = MAX(srur*ABS(save),r0/rewtdata[jj]);
+        r = SUNMAX(srur*SUNRabs(save),r0/rewtdata[jj]);
         cdata[jj] += r;
         fac = -gamma/r;
         fblock (t, cdata, jx, jy, f1, wdata);
@@ -893,7 +893,7 @@ static int PSolve(realtype tn, N_Vector c, N_Vector fc,
     for (jx = 0; jx < mx; jx++) {
       igx = jigx[jx];
       ig = igx + igy*ngx;
-      denseGETRS(P[ig], mp, pivot[ig], &(NV_DATA_S(z)[iv]));
+      denseGETRS(P[ig], mp, pivot[ig], &(N_VGetArrayPointer_Serial(z)[iv]));
       iv += mp;
     }
   }
@@ -917,8 +917,8 @@ static void GSIter(realtype gamma, N_Vector z, N_Vector x, WebData wdata)
   realtype beta[NS], beta2[NS], cof1[NS], gam[NS], gam2[NS];
   realtype temp, *cox, *coy, *xd, *zd;
   
-  xd = NV_DATA_S(x);
-  zd = NV_DATA_S(z);
+  xd = N_VGetArrayPointer_Serial(x);
+  zd = N_VGetArrayPointer_Serial(z);
   ns = wdata->ns;
   mx = wdata->mx;
   my = wdata->my;
@@ -1114,7 +1114,7 @@ static void v_zero(realtype u[], int n)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvode/serial/cvRoberts_dns.c b/examples/cvode/serial/cvRoberts_dns.c
index 8ee57fd..c63433b 100644
--- a/examples/cvode/serial/cvRoberts_dns.c
+++ b/examples/cvode/serial/cvRoberts_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -94,7 +94,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 
 /*
@@ -270,7 +270,7 @@ static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %0.4le      y =%14.6le  %14.6le  %14.6le\n", t, y1, y2, y3);
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #else
   printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #endif
@@ -332,7 +332,7 @@ static void PrintFinalStats(void *cvode_mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvode/serial/cvRoberts_dnsL.c b/examples/cvode/serial/cvRoberts_dnsL.c
index f4379f2..c378baf 100644
--- a/examples/cvode/serial/cvRoberts_dnsL.c
+++ b/examples/cvode/serial/cvRoberts_dnsL.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4878 $
+ * $Date: 2016-08-31 15:17:31 -0700 (Wed, 31 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -93,7 +93,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 
 /*
@@ -186,8 +186,9 @@ int main()
   /* Print some final statistics */
   PrintFinalStats(cvode_mem);
 
-  /* Free y vector */
+  /* Free y vector and abstol vectors */
   N_VDestroy_Serial(y);
+  N_VDestroy_Serial(abstol);
 
   /* Free integrator memory */
   CVodeFree(&cvode_mem);
@@ -335,7 +336,7 @@ static void PrintFinalStats(void *cvode_mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvode/serial/cvRoberts_dns_uw.c b/examples/cvode/serial/cvRoberts_dns_uw.c
index 64f49c3..71921e5 100644
--- a/examples/cvode/serial/cvRoberts_dns_uw.c
+++ b/examples/cvode/serial/cvRoberts_dns_uw.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:51:32 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -98,7 +98,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 
 /*
@@ -268,7 +268,7 @@ static int ewt(N_Vector y, N_Vector w, void *user_data)
 
   for (i=1; i<=3; i++) {
     yy = Ith(y,i);
-    ww = rtol * ABS(yy) + atol[i-1];  
+    ww = rtol * SUNRabs(yy) + atol[i-1];
     if (ww <= 0.0) return (-1);
     Ith(w,i) = 1.0/ww;
   }
@@ -287,7 +287,7 @@ static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %0.4le      y =%14.6le  %14.6le  %14.6le\n", t, y1, y2, y3);
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #else
   printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #endif
@@ -349,7 +349,7 @@ static void PrintFinalStats(void *cvode_mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvode/serial/cvRoberts_klu.c b/examples/cvode/serial/cvRoberts_klu.c
new file mode 100644
index 0000000..3292397
--- /dev/null
+++ b/examples/cvode/serial/cvRoberts_klu.c
@@ -0,0 +1,382 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward.
+ *      Based on cvRoberts_dns.c and modified to use KLU.
+ * -----------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODE. The problem is from
+ * chemical kinetics, and consists of the following three rate
+ * equations:         
+ *    dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *    dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
+ *    dy3/dt = 3.e7*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01. This program solves the problem with the BDF method,
+ * Newton iteration with the CVKLU sparse direct linear solver, and a
+ * user-supplied Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance. Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+
+/* Header files with a description of contents used */
+
+#include <cvode/cvode.h>             /* prototypes for CVODE fcts., consts. */
+#include <nvector/nvector_serial.h>  /* serial N_Vector types, fcts., macros */
+#include <cvode/cvode_klu.h>         /* prototype for CVKLU */
+#include <sundials/sundials_sparse.h> /* definitions SlsMat */
+#include <sundials/sundials_types.h> /* definition of type realtype */
+
+/* User-defined vector and matrix accessor macro: Ith */
+
+/* These macros are defined in order to write code which exactly matches
+   the mathematical problem description given above.
+
+   Ith(v,i) references the ith component of the vector v, where i is in
+   the range [1..NEQ] and NEQ is defined below. The Ith macro is defined
+   using the N_VIth macro in nvector.h. N_VIth numbers the components of
+   a vector starting from 0.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* Ith numbers components 1..NEQ */
+
+
+/* Problem Constants */
+
+#define ZERO  RCONST(0.0)
+
+#define NEQ   3                /* number of equations  */
+#define Y1    RCONST(1.0)      /* initial y components */
+#define Y2    RCONST(0.0)
+#define Y3    RCONST(0.0)
+#define RTOL  RCONST(1.0e-4)   /* scalar relative tolerance            */
+#define ATOL1 RCONST(1.0e-8)   /* vector absolute tolerance components */
+#define ATOL2 RCONST(1.0e-14)
+#define ATOL3 RCONST(1.0e-6)
+#define T0    RCONST(0.0)      /* initial time           */
+#define T1    RCONST(0.4)      /* first output time      */
+#define TMULT RCONST(10.0)     /* output time factor     */
+#define NOUT  12               /* number of output times */
+
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data);
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private functions to output results */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3);
+static void PrintRootInfo(int root_f1, int root_f2);
+
+/* Private function to print final statistics */
+
+static void PrintFinalStats(void *cvode_mem);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+
+/*
+ *-------------------------------
+ * Main Program
+ *-------------------------------
+ */
+
+int main()
+{
+  realtype reltol, t, tout;
+  N_Vector y, abstol;
+  void *cvode_mem;
+  int flag, flagr, iout, nnz;
+  int rootsfound[2];
+
+  y = abstol = NULL;
+  cvode_mem = NULL;
+
+  /* Create serial vector of length NEQ for I.C. and abstol */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+  abstol = N_VNew_Serial(NEQ); 
+  if (check_flag((void *)abstol, "N_VNew_Serial", 0)) return(1);
+
+  /* Initialize y */
+  Ith(y,1) = Y1;
+  Ith(y,2) = Y2;
+  Ith(y,3) = Y3;
+
+  /* Set the scalar relative tolerance */
+  reltol = RTOL;
+  /* Set the vector absolute tolerance */
+  Ith(abstol,1) = ATOL1;
+  Ith(abstol,2) = ATOL2;
+  Ith(abstol,3) = ATOL3;
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+  
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in y'=f(t,y), the inital time T0, and
+   * the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeSVtolerances to specify the scalar relative tolerance
+   * and vector absolute tolerances */
+  flag = CVodeSVtolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSVtolerances", 1)) return(1);
+
+  /* Call CVodeRootInit to specify the root function g with 2 components */
+  flag = CVodeRootInit(cvode_mem, 2, g);
+  if (check_flag(&flag, "CVodeRootInit", 1)) return(1);
+
+  /* Call CVKLU to specify the CVKLU sparse direct linear solver */
+  nnz = NEQ * NEQ;
+  flag = CVKLU(cvode_mem, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "CVKLU", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call CVode, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached.  */
+  printf(" \n3-species kinetics problem\n\n");
+
+  iout = 0;  tout = T1;
+  while(1) {
+    flag = CVode(cvode_mem, tout, y, &t, CV_NORMAL);
+    PrintOutput(t, Ith(y,1), Ith(y,2), Ith(y,3));
+
+    if (flag == CV_ROOT_RETURN) {
+      flagr = CVodeGetRootInfo(cvode_mem, rootsfound);
+      if (check_flag(&flagr, "CVodeGetRootInfo", 1)) return(1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (check_flag(&flag, "CVode", 1)) break;
+    if (flag == CV_SUCCESS) {
+      iout++;
+      tout *= TMULT;
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  /* Print some final statistics */
+  PrintFinalStats(cvode_mem);
+
+  /* Free y and abstol vectors */
+  N_VDestroy_Serial(y);
+  N_VDestroy_Serial(abstol);
+
+  /* Free integrator memory */
+  CVodeFree(&cvode_mem);
+
+  return(0);
+}
+
+
+/*
+ *-------------------------------
+ * Functions called by the solver
+ *-------------------------------
+ */
+
+/*
+ * f routine. Compute function f(t,y). 
+ */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+
+  yd1 = Ith(ydot,1) = RCONST(-0.04)*y1 + RCONST(1.0e4)*y2*y3;
+  yd3 = Ith(ydot,3) = RCONST(3.0e7)*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+/*
+ * g routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data)
+{
+  realtype y1, y3;
+
+  y1 = Ith(y,1); y3 = Ith(y,3);
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Jacobian routine. Compute J(t,y) = df/dy. *
+ */
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  
+  yval = N_VGetArrayPointer_Serial(y);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data    = JacMat->data;
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = RCONST(-0.04);
+  rowvals[0] = 0;
+  data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  data[2] = ZERO;
+  rowvals[2] = 2;
+
+  data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]);
+  rowvals[4] = 1;
+  data[5] = RCONST(6.0e7)*yval[1];
+  rowvals[5] = 2;
+
+  data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  data[8] = ZERO;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Private helper functions
+ *-------------------------------
+ */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#else
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#endif
+
+  return;
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+
+  return;
+}
+
+/* 
+ * Get and print some final statistics
+ */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  long int nst, nfe, nsetups, nje, nni, ncfn, netf, nge;
+  int flag;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  flag = CVSlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVSlsGetNumJacEvals", 1);
+
+  flag = CVodeGetNumGEvals(cvode_mem, &nge);
+  check_flag(&flag, "CVodeGetNumGEvals", 1);
+
+  printf("\nFinal Statistics:\n");
+  printf("nst = %-6ld nfe  = %-6ld nsetups = %-6ld nje = %ld\n",
+	 nst, nfe, nsetups, nje);
+  printf("nni = %-6ld ncfn = %-6ld netf = %-6ld    nge = %ld\n \n",
+	 nni, ncfn, netf, nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvode/serial/cvRoberts_klu.out b/examples/cvode/serial/cvRoberts_klu.out
new file mode 100644
index 0000000..776406f
--- /dev/null
+++ b/examples/cvode/serial/cvRoberts_klu.out
@@ -0,0 +1,24 @@
+ 
+3-species kinetics problem
+
+At t = 2.6391e-01      y =  9.899653e-01    3.470564e-05    1.000000e-02
+    rootsfound[] =   0   1
+At t = 4.0000e-01      y =  9.851640e-01    3.386245e-05    1.480209e-02
+At t = 4.0000e+00      y =  9.055156e-01    2.240441e-05    9.446197e-02
+At t = 4.0000e+01      y =  7.158508e-01    9.186546e-06    2.841400e-01
+At t = 4.0000e+02      y =  4.505784e-01    3.223707e-06    5.494184e-01
+At t = 4.0000e+03      y =  1.832290e-01    8.944054e-07    8.167701e-01
+At t = 4.0000e+04      y =  3.898012e-02    1.621625e-07    9.610197e-01
+At t = 4.0000e+05      y =  4.936714e-03    1.984363e-08    9.950633e-01
+At t = 4.0000e+06      y =  5.164962e-04    2.067039e-09    9.994835e-01
+At t = 2.0784e+07      y =  1.000000e-04    4.000395e-10    9.999000e-01
+    rootsfound[] =  -1   0
+At t = 4.0000e+07      y =  5.202874e-05    2.081257e-10    9.999480e-01
+At t = 4.0000e+08      y =  5.206719e-06    2.082698e-11    9.999948e-01
+At t = 4.0000e+09      y =  5.208794e-07    2.083519e-12    9.999995e-01
+At t = 4.0000e+10      y =  5.244455e-08    2.097782e-13    9.999999e-01
+
+Final Statistics:
+nst = 430    nfe  = 574    nsetups = 98     nje = 78
+nni = 570    ncfn = 0      netf = 23        nge = 466
+ 
diff --git a/examples/cvode/serial/cvRoberts_sps.c b/examples/cvode/serial/cvRoberts_sps.c
new file mode 100644
index 0000000..d26954c
--- /dev/null
+++ b/examples/cvode/serial/cvRoberts_sps.c
@@ -0,0 +1,378 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward.
+ *      Based on cvRoberts_dns.c and modified to use SUPERLU_MT.
+ * -----------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODE. The problem is from
+ * chemical kinetics, and consists of the following three rate
+ * equations:         
+ *    dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *    dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
+ *    dy3/dt = 3.e7*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01. This program solves the problem with the BDF method,
+ * Newton iteration with the CVSUPERLUMT sparse direct linear solver, and a
+ * user-supplied Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance. Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+
+/* Header files with a description of contents used */
+
+#include <cvode/cvode.h>             /* prototypes for CVODE fcts., consts. */
+#include <nvector/nvector_serial.h>  /* serial N_Vector types, fcts., macros */
+#include <cvode/cvode_superlumt.h>   /* prototype for CVSUPERLUMT */
+#include <sundials/sundials_sparse.h> /* definitions SlsMat */
+#include <sundials/sundials_types.h> /* definition of type realtype */
+
+/* User-defined vector and matrix accessor macro: Ith */
+
+/* These macros are defined in order to write code which exactly matches
+   the mathematical problem description given above.
+
+   Ith(v,i) references the ith component of the vector v, where i is in
+   the range [1..NEQ] and NEQ is defined below. The Ith macro is defined
+   using the N_VIth macro in nvector.h. N_VIth numbers the components of
+   a vector starting from 0.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* Ith numbers components 1..NEQ */
+
+
+/* Problem Constants */
+
+#define ZERO  RCONST(0.0)
+
+#define NEQ   3                /* number of equations  */
+#define Y1    RCONST(1.0)      /* initial y components */
+#define Y2    RCONST(0.0)
+#define Y3    RCONST(0.0)
+#define RTOL  RCONST(1.0e-4)   /* scalar relative tolerance            */
+#define ATOL1 RCONST(1.0e-8)   /* vector absolute tolerance components */
+#define ATOL2 RCONST(1.0e-14)
+#define ATOL3 RCONST(1.0e-6)
+#define T0    RCONST(0.0)      /* initial time           */
+#define T1    RCONST(0.4)      /* first output time      */
+#define TMULT RCONST(10.0)     /* output time factor     */
+#define NOUT  12               /* number of output times */
+
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data);
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private functions to output results */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3);
+static void PrintRootInfo(int root_f1, int root_f2);
+
+/* Private function to print final statistics */
+
+static void PrintFinalStats(void *cvode_mem);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+
+/*
+ *-------------------------------
+ * Main Program
+ *-------------------------------
+ */
+
+int main()
+{
+  realtype reltol, t, tout;
+  N_Vector y, abstol;
+  void *cvode_mem;
+  int flag, flagr, iout, nnz;
+  int rootsfound[2];
+
+  y = abstol = NULL;
+  cvode_mem = NULL;
+
+  /* Create serial vector of length NEQ for I.C. and abstol */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+  abstol = N_VNew_Serial(NEQ); 
+  if (check_flag((void *)abstol, "N_VNew_Serial", 0)) return(1);
+
+  /* Initialize y */
+  Ith(y,1) = Y1;
+  Ith(y,2) = Y2;
+  Ith(y,3) = Y3;
+
+  /* Set the scalar relative tolerance */
+  reltol = RTOL;
+  /* Set the vector absolute tolerance */
+  Ith(abstol,1) = ATOL1;
+  Ith(abstol,2) = ATOL2;
+  Ith(abstol,3) = ATOL3;
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+  
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in y'=f(t,y), the inital time T0, and
+   * the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeSVtolerances to specify the scalar relative tolerance
+   * and vector absolute tolerances */
+  flag = CVodeSVtolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSVtolerances", 1)) return(1);
+
+  /* Call CVodeRootInit to specify the root function g with 2 components */
+  flag = CVodeRootInit(cvode_mem, 2, g);
+  if (check_flag(&flag, "CVodeRootInit", 1)) return(1);
+
+  /* Call CVSuperLUMT to specify the CVSuperLUMT sparse direct linear solver */
+  nnz = NEQ * NEQ;
+  flag = CVSuperLUMT(cvode_mem, 1, NEQ, nnz);
+  if (check_flag(&flag, "CVSuperLUMT", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call CVode, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached.  */
+  printf(" \n3-species kinetics problem\n\n");
+
+  iout = 0;  tout = T1;
+  while(1) {
+    flag = CVode(cvode_mem, tout, y, &t, CV_NORMAL);
+    PrintOutput(t, Ith(y,1), Ith(y,2), Ith(y,3));
+
+    if (flag == CV_ROOT_RETURN) {
+      flagr = CVodeGetRootInfo(cvode_mem, rootsfound);
+      if (check_flag(&flagr, "CVodeGetRootInfo", 1)) return(1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (check_flag(&flag, "CVode", 1)) break;
+    if (flag == CV_SUCCESS) {
+      iout++;
+      tout *= TMULT;
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  /* Print some final statistics */
+  PrintFinalStats(cvode_mem);
+
+  /* Free y and abstol vectors */
+  N_VDestroy_Serial(y);
+  N_VDestroy_Serial(abstol);
+
+  /* Free integrator memory */
+  CVodeFree(&cvode_mem);
+
+  return(0);
+}
+
+
+/*
+ *-------------------------------
+ * Functions called by the solver
+ *-------------------------------
+ */
+
+/*
+ * f routine. Compute function f(t,y). 
+ */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+
+  yd1 = Ith(ydot,1) = RCONST(-0.04)*y1 + RCONST(1.0e4)*y2*y3;
+  yd3 = Ith(ydot,3) = RCONST(3.0e7)*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+/*
+ * g routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data)
+{
+  realtype y1, y3;
+
+  y1 = Ith(y,1); y3 = Ith(y,3);
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Jacobian routine. Compute J(t,y) = df/dy. *
+ */
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int *colptrs = *JacMat->colptrs;
+  int *rowvals = *JacMat->rowvals;
+
+  yval = N_VGetArrayPointer_Serial(y);
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  JacMat->data[0] = RCONST(-0.04);
+  rowvals[0] = 0;
+  JacMat->data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  JacMat->data[2] = ZERO;
+  rowvals[2] = 2;
+
+  JacMat->data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  JacMat->data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]);
+  rowvals[4] = 1;
+  JacMat->data[5] = RCONST(6.0e7)*yval[1];
+  rowvals[5] = 2;
+
+  JacMat->data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  JacMat->data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  JacMat->data[8] = ZERO;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Private helper functions
+ *-------------------------------
+ */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#else
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#endif
+
+  return;
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+
+  return;
+}
+
+/* 
+ * Get and print some final statistics
+ */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  long int nst, nfe, nsetups, nje, nni, ncfn, netf, nge;
+  int flag;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  flag = CVSlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVSlsGetNumJacEvals", 1);
+
+  flag = CVodeGetNumGEvals(cvode_mem, &nge);
+  check_flag(&flag, "CVodeGetNumGEvals", 1);
+
+  printf("\nFinal Statistics:\n");
+  printf("nst = %-6ld nfe  = %-6ld nsetups = %-6ld nje = %ld\n",
+	 nst, nfe, nsetups, nje);
+  printf("nni = %-6ld ncfn = %-6ld netf = %-6ld    nge = %ld\n \n",
+	 nni, ncfn, netf, nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvode/serial/cvRoberts_sps.out b/examples/cvode/serial/cvRoberts_sps.out
new file mode 100644
index 0000000..b92bc8e
--- /dev/null
+++ b/examples/cvode/serial/cvRoberts_sps.out
@@ -0,0 +1,24 @@
+ 
+3-species kinetics problem
+
+At t = 2.6391e-01      y =  9.899653e-01    3.470564e-05    1.000000e-02
+    rootsfound[] =   0   1
+At t = 4.0000e-01      y =  9.851641e-01    3.386242e-05    1.480205e-02
+At t = 4.0000e+00      y =  9.055097e-01    2.240338e-05    9.446793e-02
+At t = 4.0000e+01      y =  7.158017e-01    9.185037e-06    2.841892e-01
+At t = 4.0000e+02      y =  4.505360e-01    3.223271e-06    5.494608e-01
+At t = 4.0000e+03      y =  1.832299e-01    8.944378e-07    8.167692e-01
+At t = 4.0000e+04      y =  3.898902e-02    1.622006e-07    9.610108e-01
+At t = 4.0000e+05      y =  4.936383e-03    1.984224e-08    9.950636e-01
+At t = 4.0000e+06      y =  5.168093e-04    2.068293e-09    9.994832e-01
+At t = 2.0790e+07      y =  1.000000e-04    4.000397e-10    9.999000e-01
+    rootsfound[] =  -1   0
+At t = 4.0000e+07      y =  5.202440e-05    2.081083e-10    9.999480e-01
+At t = 4.0000e+08      y =  5.201061e-06    2.080435e-11    9.999948e-01
+At t = 4.0000e+09      y =  5.258603e-07    2.103442e-12    9.999995e-01
+At t = 4.0000e+10      y =  6.934511e-08    2.773804e-13    9.999999e-01
+
+Final Statistics:
+nst = 542    nfe  = 755    nsetups = 107    nje = 11
+nni = 751    ncfn = 0      netf = 22        nge = 570
+ 
diff --git a/examples/cvodes/C_openmp/CMakeLists.txt b/examples/cvodes/C_openmp/CMakeLists.txt
new file mode 100644
index 0000000..6c0c90e
--- /dev/null
+++ b/examples/cvodes/C_openmp/CMakeLists.txt
@@ -0,0 +1,128 @@
+# ---------------------------------------------------------------
+# Programmer:  Ting Yan @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for CVODES OpenMP examples
+
+# Only include tests if OpenMP is enabled
+IF(OPENMP_FOUND)
+
+# Add variable CVODES_examples_OMP with the names of the openmp CVODES examples
+SET(CVODES_examples_OMP
+  cvsAdvDiff_bnd_omp
+  )
+
+ENDIF(OPENMP_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(CVODES_LIB sundials_cvodes_static)
+  SET(NVECOMP_LIB sundials_nvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(CVODES_LIB sundials_cvodes_shared)
+  SET(NVECOMP_LIB sundials_nvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${CVODES_LIB} ${NVECOMP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# update the compilation flags to include OpenMP support
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+
+# Add the build and install targets for each CVODES example
+FOREACH(example ${CVODES_examples_OMP})
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} TEST_ARGS 4)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/C_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${CVODES_examples_OMP})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/C_openmp)
+
+  # Install the extra files
+  FOREACH(extrafile ${CVODES_extras_OMP})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/C_openmp)
+  ENDFOREACH(extrafile ${CVODES_extras_OMP})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "CVODES")
+  SET(SOLVER_LIB "sundials_cvodes")
+  LIST2STRING(CVODES_examples_OMP EXAMPLES)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/cvodes/C_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/cvodes/C_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/C_openmp 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/cvodes/C_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/cvodes/C_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/C_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/cvodes/C_openmp/README b/examples/cvodes/C_openmp/README
new file mode 100644
index 0000000..884a0bf
--- /dev/null
+++ b/examples/cvodes/C_openmp/README
@@ -0,0 +1,49 @@
+List of C_openmp CVODES examples
+
+  cvsAdvDiff_bnd_omp: banded example using OpenMP
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c b/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c
new file mode 100644
index 0000000..8f4f1fa
--- /dev/null
+++ b/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.c
@@ -0,0 +1,458 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *     Based on cvsAdvDiff_bnd.c and parallelized with OpenMP
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * The following is a simple example problem with a banded Jacobian,
+ * with the program for its solution by CVODES.
+ * The problem is the semi-discrete form of the advection-diffusion
+ * equation in 2-D:
+ *   du/dt = d^2 u / dx^2 + .5 du/dx + d^2 u / dy^2
+ * on the rectangle 0 <= x <= 2, 0 <= y <= 1, and the time
+ * interval 0 <= t <= 1. Homogeneous Dirichlet boundary conditions
+ * are posed, and the initial condition is
+ *   u(x,y,t=0) = x(2-x)y(1-y)exp(5xy).
+ * The PDE is discretized on a uniform MX+2 by MY+2 grid with
+ * central differencing, and with boundary values eliminated,
+ * leaving an ODE system of size NEQ = MX*MY.
+ * This program solves the problem with the BDF method, Newton
+ * iteration with the CVBAND band linear solver, and a user-supplied
+ * Jacobian routine.
+ * It uses scalar relative and absolute tolerances.
+ * Output is printed at t = .1, .2, ..., 1.
+ * Run statistics (optional outputs) are printed at the end.
+ *
+ * Optionally, we can set the number of threads from environment 
+ * variable or command line. To check the current value for number
+ * of threads from environment:
+ *      % echo $OMP_NUM_THREADS
+ *
+ * Execution:
+ *
+ * If the user want to use the default value or the number of threads 
+ * from environment value:
+ *      % ./cvsAdvDiff_bnd_omp 
+ * If the user want to specify the number of threads to use
+ *      % ./cvsAdvDiff_bnd_omp num_threads
+ * where num_threads is the number of threads the user want to use 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+/* Header files with a description of contents used in cvbanx.c */
+
+#include <cvodes/cvodes.h>             /* prototypes for CVODE fcts., consts. */
+#include <cvodes/cvodes_band.h>        /* prototype for CVBand */
+#include <nvector/nvector_openmp.h>  /* serial N_Vector types, fcts., macros */
+#include <sundials/sundials_band.h>  /* definitions of type DlsMat and macros */
+#include <sundials/sundials_types.h> /* definition of type realtype */
+#include <sundials/sundials_math.h>  /* definition of ABS and EXP */
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+/* Problem Constants */
+
+#define XMAX  RCONST(2.0)    /* domain boundaries         */
+#define YMAX  RCONST(1.0)
+#define MX    10             /* mesh dimensions           */
+#define MY    5
+#define NEQ   MX*MY          /* number of equations       */
+#define ATOL  RCONST(1.0e-5) /* scalar absolute tolerance */
+#define T0    RCONST(0.0)    /* initial time              */
+#define T1    RCONST(0.1)    /* first output time         */
+#define DTOUT RCONST(0.1)    /* output time increment     */
+#define NOUT  10             /* number of output times    */
+
+#define ZERO RCONST(0.0)
+#define HALF RCONST(0.5)
+#define ONE  RCONST(1.0)
+#define TWO  RCONST(2.0)
+#define FIVE RCONST(5.0)
+
+/* User-defined vector access macro IJth */
+
+/* IJth is defined in order to isolate the translation from the
+   mathematical 2-dimensional structure of the dependent variable vector
+   to the underlying 1-dimensional storage. 
+   IJth(vdata,i,j) references the element in the vdata array for
+   u at mesh point (i,j), where 1 <= i <= MX, 1 <= j <= MY.
+   The vdata array is obtained via the macro call vdata = NV_DATA_S(v),
+   where v is an N_Vector. 
+   The variables are ordered by the y index j, then by the x index i. */
+
+#define IJth(vdata,i,j) (vdata[(j-1) + (i-1)*MY])
+
+/* Type : UserData (contains grid constants) */
+
+typedef struct {
+  realtype dx, dy, hdcoef, hacoef, vdcoef;
+  int nthreads;
+} *UserData;
+
+/* Private Helper Functions */
+
+static void SetIC(N_Vector u, UserData data);
+static void PrintHeader(realtype reltol, realtype abstol, realtype umax);
+static void PrintOutput(realtype t, realtype umax, long int nst);
+static void PrintFinalStats(void *cvode_mem);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
+static int Jac(long int N, long int mu, long int ml,
+               realtype t, N_Vector u, N_Vector fu, 
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/*
+ *-------------------------------
+ * Main Program
+ *-------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  realtype dx, dy, reltol, abstol, t, tout, umax;
+  N_Vector u;
+  UserData data;
+  void *cvode_mem;
+  int iout, flag;
+  long int nst;
+  int num_threads;
+
+  u = NULL;
+  data = NULL;
+  cvode_mem = NULL;
+
+  /* Set the number of threads to use */
+  num_threads = 1;     /* default value */
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();  /* Overwrite with OMP_NUM_THREADS environment variable */
+#endif
+  if (argc > 1)        /* overwrithe with command line value, if supplied */
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* Create a serial vector */
+
+  u = N_VNew_OpenMP(NEQ, num_threads);  /* Allocate u vector */
+  if(check_flag((void*)u, "N_VNew_OpenMP", 0)) return(1);
+
+  reltol = ZERO;  /* Set the tolerances */
+  abstol = ATOL;
+
+  data = (UserData) malloc(sizeof *data);  /* Allocate data memory */
+  if(check_flag((void *)data, "malloc", 2)) return(1);
+  dx = data->dx = XMAX/(MX+1);  /* Set grid coefficients in data */
+  dy = data->dy = YMAX/(MY+1);
+  data->hdcoef = ONE/(dx*dx);
+  data->hacoef = HALF/(TWO*dx);
+  data->vdcoef = ONE/(dy*dy);
+  data->nthreads = num_threads;
+
+  SetIC(u, data);  /* Initialize u vector */
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if(check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in u'=f(t,u), the inital time T0, and
+   * the initial dependent variable vector u. */
+  flag = CVodeInit(cvode_mem, f, T0, u);
+  if(check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeSStolerances to specify the scalar relative tolerance
+   * and scalar absolute tolerance */
+  flag = CVodeSStolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSStolerances", 1)) return(1);
+
+  /* Set the pointer to user-defined data */
+  flag = CVodeSetUserData(cvode_mem, data);
+  if(check_flag(&flag, "CVodeSetUserData", 1)) return(1);
+
+  /* Call CVBand to specify the CVBAND band linear solver */
+  flag = CVBand(cvode_mem, NEQ, MY, MY);
+  if(check_flag(&flag, "CVBand", 1)) return(1);
+
+  /* Set the user-supplied Jacobian routine Jac */
+  flag = CVDlsSetBandJacFn(cvode_mem, Jac);
+  if(check_flag(&flag, "CVDlsSetBandJacFn", 1)) return(1);
+
+  /* In loop over output points: call CVode, print results, test for errors */
+
+  umax = N_VMaxNorm(u);
+  PrintHeader(reltol, abstol, umax);
+  for(iout=1, tout=T1; iout <= NOUT; iout++, tout += DTOUT) {
+    flag = CVode(cvode_mem, tout, u, &t, CV_NORMAL);
+    if(check_flag(&flag, "CVode", 1)) break;
+    umax = N_VMaxNorm(u);
+    flag = CVodeGetNumSteps(cvode_mem, &nst);
+    check_flag(&flag, "CVodeGetNumSteps", 1);
+    PrintOutput(t, umax, nst);
+  }
+ 
+  PrintFinalStats(cvode_mem);  /* Print some final statistics   */
+  printf("num_threads = %i\n\n", num_threads);
+   
+
+  N_VDestroy_OpenMP(u);   /* Free the u vector */
+  CVodeFree(&cvode_mem);  /* Free the integrator memory */
+  free(data);             /* Free the user data */
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Functions called by the solver
+ *-------------------------------
+ */
+
+/* f routine. Compute f(t,u). */
+
+static int f(realtype t, N_Vector u,N_Vector udot, void *user_data)
+{
+  realtype uij, udn, uup, ult, urt, hordc, horac, verdc, hdiff, hadv, vdiff;
+  realtype *udata, *dudata;
+  int i, j;
+  UserData data;
+
+  udata = NV_DATA_OMP(u);
+  dudata = NV_DATA_OMP(udot);
+
+  /* Extract needed constants from data */
+
+  data = (UserData) user_data;
+  hordc = data->hdcoef;
+  horac = data->hacoef;
+  verdc = data->vdcoef;
+
+  /* Loop over all grid points. */
+#pragma omp parallel for default(shared) private(j, i, uij, udn, uup, ult, urt, hdiff, hadv, vdiff) num_threads(data->nthreads)
+  for (j=1; j <= MY; j++) {
+
+    for (i=1; i <= MX; i++) {
+
+      /* Extract u at x_i, y_j and four neighboring points */
+
+      uij = IJth(udata, i, j);
+      udn = (j == 1)  ? ZERO : IJth(udata, i, j-1);
+      uup = (j == MY) ? ZERO : IJth(udata, i, j+1);
+      ult = (i == 1)  ? ZERO : IJth(udata, i-1, j);
+      urt = (i == MX) ? ZERO : IJth(udata, i+1, j);
+
+      /* Set diffusion and advection terms and load into udot */
+
+      hdiff = hordc*(ult - TWO*uij + urt);
+      hadv = horac*(urt - ult);
+      vdiff = verdc*(uup - TWO*uij + udn);
+      IJth(dudata, i, j) = hdiff + hadv + vdiff;
+    }
+  }
+
+  return(0);
+}
+
+/* Jacobian routine. Compute J(t,u). */
+
+static int Jac(long int N, long int mu, long int ml,
+               realtype t, N_Vector u, N_Vector fu, 
+               DlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  long int i, j, k;
+  realtype *kthCol, hordc, horac, verdc;
+  UserData data;
+  
+  /*
+    The components of f = udot that depend on u(i,j) are
+    f(i,j), f(i-1,j), f(i+1,j), f(i,j-1), f(i,j+1), with
+      df(i,j)/du(i,j) = -2 (1/dx^2 + 1/dy^2)
+      df(i-1,j)/du(i,j) = 1/dx^2 + .25/dx  (if i > 1)
+      df(i+1,j)/du(i,j) = 1/dx^2 - .25/dx  (if i < MX)
+      df(i,j-1)/du(i,j) = 1/dy^2           (if j > 1)
+      df(i,j+1)/du(i,j) = 1/dy^2           (if j < MY)
+  */
+
+  data = (UserData) user_data;
+  hordc = data->hdcoef;
+  horac = data->hacoef;
+  verdc = data->vdcoef;
+
+#pragma omp parallel for collapse(2) default(shared) private(j, u, k, kthCol) num_threads(data->nthreads) 
+  for (j=1; j <= MY; j++) {
+    for (i=1; i <= MX; i++) {
+      k = j-1 + (i-1)*MY;
+      kthCol = BAND_COL(J,k);
+
+      /* set the kth column of J */
+
+      BAND_COL_ELEM(kthCol,k,k) = -TWO*(verdc+hordc);
+      if (i != 1)  BAND_COL_ELEM(kthCol,k-MY,k) = hordc + horac;
+      if (i != MX) BAND_COL_ELEM(kthCol,k+MY,k) = hordc - horac;
+      if (j != 1)  BAND_COL_ELEM(kthCol,k-1,k)  = verdc;
+      if (j != MY) BAND_COL_ELEM(kthCol,k+1,k)  = verdc;
+    }
+  }
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Private helper functions
+ *-------------------------------
+ */
+
+/* Set initial conditions in u vector */
+
+static void SetIC(N_Vector u, UserData data)
+{
+  int i, j;
+  realtype x, y, dx, dy;
+  realtype *udata;
+
+  /* Extract needed constants from data */
+
+  dx = data->dx;
+  dy = data->dy;
+
+  /* Set pointer to data array in vector u. */
+
+  udata = NV_DATA_OMP(u);
+
+  /* Load initial profile into u vector */
+#pragma omp parallel for default(shared) private(j, i, y, x)  
+  for (j=1; j <= MY; j++) {
+    y = j*dy;
+    for (i=1; i <= MX; i++) {
+      x = i*dx;
+      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*SUNRexp(FIVE*x*y);
+    }
+  }  
+}
+
+/* Print first lines of output (problem description) */
+
+static void PrintHeader(realtype reltol, realtype abstol, realtype umax)
+{
+  printf("\n2-D Advection-Diffusion Equation\n");
+  printf("Mesh dimensions = %d X %d\n", MX, MY);
+  printf("Total system size = %d\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerance parameters: reltol = %Lg   abstol = %Lg\n\n",
+         reltol, abstol);
+  printf("At t = %Lg      max.norm(u) =%14.6Le \n", T0, umax);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters: reltol = %g   abstol = %g\n\n",
+         reltol, abstol);
+  printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
+#else
+  printf("Tolerance parameters: reltol = %g   abstol = %g\n\n", reltol, abstol);
+  printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
+#endif
+
+  return;
+}
+
+/* Print current value */
+
+static void PrintOutput(realtype t, realtype umax, long int nst)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %4.2Lf   max.norm(u) =%14.6Le   nst = %4ld\n", t, umax, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
+#else
+  printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
+#endif
+
+  return;
+}
+
+/* Get and print some final statistics */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  int flag;
+  long int nst, nfe, nsetups, netf, nni, ncfn, nje, nfeLS;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  flag = CVDlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVDlsGetNumJacEvals", 1);
+  flag = CVDlsGetNumRhsEvals(cvode_mem, &nfeLS);
+  check_flag(&flag, "CVDlsGetNumRhsEvals", 1);
+
+  printf("\nFinal Statistics:\n");
+  printf("nst = %-6ld nfe  = %-6ld nsetups = %-6ld nfeLS = %-6ld nje = %ld\n",
+	 nst, nfe, nsetups, nfeLS, nje);
+  printf("nni = %-6ld ncfn = %-6ld netf = %ld\n",
+	 nni, ncfn, netf);
+
+  return;
+}
+
+/* Check function return value...
+     opt == 0 means SUNDIALS function allocates memory so check if
+              returned NULL pointer
+     opt == 1 means SUNDIALS function returns a flag so check if
+              flag >= 0
+     opt == 2 means function allocates memory so check if returned
+              NULL pointer */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+              funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.out b/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.out
new file mode 100644
index 0000000..9ae3816
--- /dev/null
+++ b/examples/cvodes/C_openmp/cvsAdvDiff_bnd_omp.out
@@ -0,0 +1,23 @@
+
+2-D Advection-Diffusion Equation
+Mesh dimensions = 10 X 5
+Total system size = 50
+Tolerance parameters: reltol = 0   abstol = 1e-05
+
+At t = 0      max.norm(u) =  8.954716e+01 
+At t = 0.10   max.norm(u) =  4.132889e+00   nst =   85
+At t = 0.20   max.norm(u) =  1.039294e+00   nst =  103
+At t = 0.30   max.norm(u) =  2.979829e-01   nst =  113
+At t = 0.40   max.norm(u) =  8.765774e-02   nst =  120
+At t = 0.50   max.norm(u) =  2.625637e-02   nst =  126
+At t = 0.60   max.norm(u) =  7.830425e-03   nst =  130
+At t = 0.70   max.norm(u) =  2.329387e-03   nst =  134
+At t = 0.80   max.norm(u) =  6.953434e-04   nst =  137
+At t = 0.90   max.norm(u) =  2.115983e-04   nst =  140
+At t = 1.00   max.norm(u) =  6.556853e-05   nst =  142
+
+Final Statistics:
+nst = 142    nfe  = 174    nsetups = 23     nfeLS = 0      nje = 3
+nni = 170    ncfn = 0      netf = 3
+num_threads = 4
+
diff --git a/examples/cvodes/parallel/CMakeLists.txt b/examples/cvodes/parallel/CMakeLists.txt
index 1c0e1a0..78ea644 100644
--- a/examples/cvodes/parallel/CMakeLists.txt
+++ b/examples/cvodes/parallel/CMakeLists.txt
@@ -1,27 +1,34 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4942 $
+# $Date: 2016-09-21 17:50:22 -0700 (Wed, 21 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the CVODES parallel examples
 
 
 # Add variable CVODES_examples with the names of the parallel CVODES examples
-
+# "name\;nodes\;tasks"
 SET(CVODES_examples
-  cvsAdvDiff_ASAp_non_p
-  cvsAdvDiff_FSA_non_p
-  cvsAdvDiff_non_p
-  cvsAtmDisp_ASAi_kry_bbd_p
-  cvsDiurnal_FSA_kry_p
-  cvsDiurnal_kry_bbd_p
-  cvsDiurnal_kry_p
+  "cvsAdvDiff_ASAp_non_p\;2\;2"
+  "cvsAdvDiff_FSA_non_p\;2\;2\;-sensi stg t"
+  "cvsAdvDiff_FSA_non_p\;2\;2\;-sensi sim t"
+  "cvsAdvDiff_non_p\;2\;2"
+  "cvsAtmDisp_ASAi_kry_bbd_p\;2\;8"
+  "cvsDiurnal_FSA_kry_p\;2\;4\;-sensi stg t"
+  "cvsDiurnal_FSA_kry_p\;2\;4\;-sensi sim t"
+  "cvsDiurnal_kry_bbd_p\;2\;4"
+  "cvsDiurnal_kry_p\;2\;4"
   )
 
 # Check whether we use MPI compiler scripts.
@@ -51,14 +58,46 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${CVODES_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
 # Add the build and install targets for each CVODES example
 
-FOREACH(example ${CVODES_examples})
-  ADD_EXECUTABLE(${example} ${example}.c)
+# SGS is there a way to query CMAKE variable to get added executables 
+# rather than keeping our own list?
+SET(ADDED_EXECUTABLES "")
+FOREACH(example_tuple ${CVODES_examples})
+  # first item is example
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+
+  # Only need to add the executable once
+  LIST(FIND ADDED_EXECUTABLES ${example} index)
+  IF(index EQUAL -1)
+    LIST(APPEND ADDED_EXECUTABLES ${example})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  ENDIF(index EQUAL -1)
+
+  # Optional 4th element is test arguments
+  LIST(LENGTH example_tuple n)
+  IF(n EQUAL 4)
+    LIST(GET example_tuple 3 test_args)
+    STRING(REGEX REPLACE " " "_" test_name ${example}_${test_args})
+    SUNDIALS_ADD_TEST(${test_name} ${example} MPI_NPROCS ${number_of_tasks} TEST_ARGS ${test_args})
+  ELSE()
+    SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  ENDIF()
+
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPICC)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -67,7 +106,7 @@ FOREACH(example ${CVODES_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example_out} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${CVODES_examples})
+ENDFOREACH(example_tuple ${CVODES_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -77,7 +116,14 @@ IF(EXAMPLES_INSTALL)
   # Prepare substitution variables for Makefile and/or CMakeLists templates
   SET(SOLVER "CVODES")
   SET(SOLVER_LIB "sundials_cvodes")
-  LIST2STRING(CVODES_examples EXAMPLES)
+  FOREACH(example_tuple ${CVODES_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${CVODES_examples})
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+  list(REMOVE_DUPLICATES EXAMPLES)
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/cvodes/parallel/Makefile.in b/examples/cvodes/parallel/Makefile.in
deleted file mode 100644
index 8cbd3d7..0000000
--- a/examples/cvodes/parallel/Makefile.in
+++ /dev/null
@@ -1,116 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for CVODES parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP         = @CPP@
-CPPFLAGS    = @CPPFLAGS@
-CC          = @CC@
-CFLAGS      = @CFLAGS@
-LDFLAGS     = @LDFLAGS@
-LIBS        = @LIBS@
-MPICC       = @MPICC@
-MPI_INC_DIR = @MPI_INC_DIR@
-MPI_LIB_DIR = @MPI_LIB_DIR@
-MPI_LIBS    = @MPI_LIBS@
-MPI_FLAGS   = @MPI_FLAGS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/cvodes/libsundials_cvodes.la $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = cvsAdvDiff_ASAp_non_p \
-	   cvsAdvDiff_FSA_non_p \
-	   cvsAdvDiff_non_p \
-	   cvsAtmDisp_ASAi_kry_bbd_p \
-	   cvsDiurnal_FSA_kry_p \
-	   cvsDiurnal_kry_bbd_p \
-	   cvsDiurnal_kry_p
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(MPICC) $(CPPFLAGS) $(MPI_FLAGS) $(SUNDIALS_INCS) -I$(MPI_INC_DIR) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(MPICC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}$(OBJ_EXT) $(MPI_FLAGS) $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) -L$(MPI_LIB_DIR) $(MPI_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/cvodes/parallel
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/cvodes/parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/cvodes/parallel/README $(EXS_INSTDIR)/cvodes/parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvodes/parallel/$${i}.c   $(EXS_INSTDIR)/cvodes/parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvodes/parallel/$${i}.out $(EXS_INSTDIR)/cvodes/parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/cvodes/parallel/Makefile
-	rm -f $(EXS_INSTDIR)/cvodes/parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/cvodes/parallel/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/cvodes/parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/cvodes/parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/cvodes
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/cvodes/parallel/README b/examples/cvodes/parallel/README
index 573f2e7..3d032b5 100644
--- a/examples/cvodes/parallel/README
+++ b/examples/cvodes/parallel/README
@@ -21,14 +21,48 @@ List of parallel CVODES examples
   cvsAtmDisp_ASAi_kry_bbd_p  : 2-D (or 3-D) advection-diffusion-reaction PDE
                                BDF/SPGMR/BBD
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c b/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c
index 399a6f6..314f883 100644
--- a/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c
+++ b/examples/cvodes/parallel/cvsAdvDiff_ASAp_non_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2007/10/25 20:03:30 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -97,7 +97,7 @@ static void SetICback(N_Vector uB, long int my_base);
 static realtype Xintgr(realtype *z, long int l, realtype dx);
 static realtype Compute_g(N_Vector u, UserData data);
 static void PrintOutput(realtype g_val, N_Vector uB, UserData data);
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -320,9 +320,9 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   last_pe = npes - 1;
 
   /* Obtain local arrays */
-  udata = NV_DATA_P(u);
-  dudata = NV_DATA_P(udot);
-  my_length = NV_LOCLENGTH_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
+  my_length = N_VGetLocalLength_Parallel(u);
   my_last = my_length - 1;
 
   /* Pass needed data to processes before and after current process. */
@@ -385,8 +385,8 @@ static int fB(realtype t, N_Vector u,
   if (my_pe == npes) { /* This process performs the quadratures */
 
     /* Obtain local arrays */
-    duBdata = NV_DATA_P(uBdot);
-    my_length = NV_LOCLENGTH_P(uB);
+    duBdata = N_VGetArrayPointer_Parallel(uBdot);
+    my_length = N_VGetLocalLength_Parallel(uB);
 
     /* Loop over all other processes and load right hand side of quadrature eqs. */
     duBdata[0] = ZERO;
@@ -408,10 +408,10 @@ static int fB(realtype t, N_Vector u,
     z2    = data->z2;
 
     /* Obtain local arrays */
-    uBdata = NV_DATA_P(uB);
-    duBdata = NV_DATA_P(uBdot);
-    udata = NV_DATA_P(u);
-    my_length = NV_LOCLENGTH_P(uB);
+    uBdata = N_VGetArrayPointer_Parallel(uB);
+    duBdata = N_VGetArrayPointer_Parallel(uBdot);
+    udata = N_VGetArrayPointer_Parallel(u);
+    my_length = N_VGetLocalLength_Parallel(uB);
 
     /* Compute related parameters. */
     my_pe_m1 = my_pe - 1;
@@ -508,14 +508,14 @@ static void SetIC(N_Vector u, realtype dx, long int my_length, long int my_base)
   realtype *udata;
 
   /* Set pointer to data array and get local length of u */
-  udata = NV_DATA_P(u);
-  my_length = NV_LOCLENGTH_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
+  my_length = N_VGetLocalLength_Parallel(u);
 
   /* Load initial profile into u vector */
   for (i=1; i<=my_length; i++) {
     iglobal = my_base + i;
     x = iglobal*dx;
-    udata[i-1] = x*(XMAX - x)*EXP(TWO*x);
+    udata[i-1] = x*(XMAX - x)*SUNRexp(TWO*x);
   }  
 }
 
@@ -530,8 +530,8 @@ static void SetICback(N_Vector uB, long int my_base)
   long int my_length;
 
   /* Set pointer to data array and get local length of uB */
-  uBdata = NV_DATA_P(uB);
-  my_length = NV_LOCLENGTH_P(uB);
+  uBdata = N_VGetArrayPointer_Parallel(uB);
+  my_length = N_VGetLocalLength_Parallel(uB);
 
   /* Set adjoint states to 1.0 and quadrature variables to 0.0 */
   if (my_base == -1) for (i=0; i<my_length; i++) uBdata[i] = ZERO;
@@ -582,8 +582,8 @@ static realtype Compute_g(N_Vector u, UserData data)
     }
     return(intgr);
   } else {              /* Compute local portion of the integral */
-    udata = NV_DATA_P(u);
-    my_length = NV_LOCLENGTH_P(u);
+    udata = N_VGetArrayPointer_Parallel(u);
+    my_length = N_VGetLocalLength_Parallel(u);
     my_intgr = Xintgr(udata, my_length, dx);
     MPI_Send(&my_intgr, 1, PVEC_REAL_MPI_TYPE, npes, 0, comm);
     return(my_intgr);
@@ -610,7 +610,7 @@ static void PrintOutput(realtype g_val, N_Vector uB, UserData data)
   nperpe = data->nperpe;
   nrem = data->nrem;
 
-  uBdata = NV_DATA_P(uB);
+  uBdata = N_VGetArrayPointer_Parallel(uB);
 
   if (my_pe == npes) {
 
@@ -618,8 +618,8 @@ static void PrintOutput(realtype g_val, N_Vector uB, UserData data)
     printf("\ng(tf) = %8Le\n\n", g_val);
     printf("dgdp(tf)\n  [ 1]: %8Le\n  [ 2]: %8Le\n\n", -uBdata[0], -uBdata[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("\ng(tf) = %8le\n\n", g_val);
-    printf("dgdp(tf)\n  [ 1]: %8le\n  [ 2]: %8le\n\n", -uBdata[0], -uBdata[1]);
+    printf("\ng(tf) = %8e\n\n", g_val);
+    printf("dgdp(tf)\n  [ 1]: %8e\n  [ 2]: %8e\n\n", -uBdata[0], -uBdata[1]);
 #else
     printf("\ng(tf) = %8e\n\n", g_val);
     printf("dgdp(tf)\n  [ 1]: %8e\n  [ 2]: %8e\n\n", -uBdata[0], -uBdata[1]);
@@ -642,7 +642,7 @@ static void PrintOutput(realtype g_val, N_Vector uB, UserData data)
       printf("  [%2ld]: %8Le\n", i+1, mu[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
     for (i=0; i<NEQ; i++)
-      printf("  [%2ld]: %8le\n", i+1, mu[i]);
+      printf("  [%2ld]: %8e\n", i+1, mu[i]);
 #else
     for (i=0; i<NEQ; i++)
       printf("  [%2ld]: %8e\n", i+1, mu[i]);
@@ -668,7 +668,7 @@ static void PrintOutput(realtype g_val, N_Vector uB, UserData data)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c b/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c
index 1591740..9026bad 100644
--- a/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c
+++ b/examples/cvodes/parallel/cvsAdvDiff_FSA_non_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2007/10/25 20:03:30 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, George D. Byrne,
  *                and Radu Serban @ LLNL
@@ -100,7 +100,7 @@ static void SetIC(N_Vector u, realtype dx, long int my_length, long int my_base)
 static void PrintOutput(void *cvode_mem, int my_pe, realtype t, N_Vector u);
 static void PrintOutputS(int my_pe, N_Vector *uS);
 static void PrintFinalStats(void *cvode_mem, booleantype sensi); 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -300,8 +300,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   MPI_Status status;
   MPI_Comm comm;
 
-  udata = NV_DATA_P(u);
-  dudata = NV_DATA_P(udot);
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
 
   /* Extract needed problem constants from data */
   data  = (UserData) user_data;
@@ -313,7 +313,7 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   comm = data->comm;
   npes = data->npes;           /* Number of processes. */ 
   my_pe = data->my_pe;         /* Current process number. */
-  my_length = NV_LOCLENGTH_P(u); /* Number of local elements of u. */ 
+  my_length = N_VGetLocalLength_Parallel(u); /* Number of local elements of u. */ 
   z = data->z;
 
   /* Compute related parameters. */
@@ -432,14 +432,14 @@ static void SetIC(N_Vector u, realtype dx, long int my_length,
   realtype *udata;
 
   /* Set pointer to data array and get local length of u. */
-  udata = NV_DATA_P(u);
-  my_length = NV_LOCLENGTH_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
+  my_length = N_VGetLocalLength_Parallel(u);
 
   /* Load initial profile into u vector */
   for (i=1; i<=my_length; i++) {
     iglobal = my_base + i;
     x = iglobal*dx;
-    udata[i-1] = x*(XMAX - x)*EXP(2.0*x);
+    udata[i-1] = x*(XMAX - x)*SUNRexp(2.0*x);
   }  
 }
 
@@ -467,7 +467,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%8.3Le %2d  %8.3Le %5ld\n", t,qu,hu,nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.3le %2d  %8.3le %5ld\n", t,qu,hu,nst);
+    printf("%8.3e %2d  %8.3e %5ld\n", t,qu,hu,nst);
 #else
     printf("%8.3e %2d  %8.3e %5ld\n", t,qu,hu,nst);
 #endif
@@ -477,7 +477,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le \n", umax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le \n", umax);
+    printf("%12.4e \n", umax);
 #else
     printf("%12.4e \n", umax);
 #endif
@@ -500,7 +500,7 @@ static void PrintOutputS(int my_pe, N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le \n", smax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le \n", smax);
+    printf("%12.4e \n", smax);
 #else
     printf("%12.4e \n", smax);
 #endif
@@ -512,7 +512,7 @@ static void PrintOutputS(int my_pe, N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le \n", smax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le \n", smax);
+    printf("%12.4e \n", smax);
 #else
     printf("%12.4e \n", smax);
 #endif
@@ -584,7 +584,7 @@ static void PrintFinalStats(void *cvode_mem, booleantype sensi)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvodes/parallel/cvsAdvDiff_non_p.c b/examples/cvodes/parallel/cvsAdvDiff_non_p.c
index 12e8704..6ae6042 100644
--- a/examples/cvodes/parallel/cvsAdvDiff_non_p.c
+++ b/examples/cvodes/parallel/cvsAdvDiff_non_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2007/10/25 20:03:30 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, George Byrne,
  *                and Radu Serban @ LLNL
@@ -81,7 +81,7 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /***************************** Main Program ******************************/
 
@@ -195,14 +195,14 @@ static void SetIC(N_Vector u, realtype dx, long int my_length,
   realtype *udata;
 
   /* Set pointer to data array and get local length of u. */
-  udata = NV_DATA_P(u);
-  my_length = NV_LOCLENGTH_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
+  my_length = N_VGetLocalLength_Parallel(u);
 
   /* Load initial profile into u vector */
   for (i=1; i<=my_length; i++) {
     iglobal = my_base + i;
     x = iglobal*dx;
-    udata[i-1] = x*(XMAX - x)*EXP(RCONST(2.0)*x);
+    udata[i-1] = x*(XMAX - x)*SUNRexp(RCONST(2.0)*x);
   }  
 }
 
@@ -224,7 +224,7 @@ static void PrintData(realtype t, realtype umax, long int nst)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %4.2Lf  max.norm(u) =%14.6Le  nst =%4ld \n", t, umax, nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %4.2f  max.norm(u) =%14.6le  nst =%4ld \n", t, umax, nst);
+  printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
 #else
   printf("At t = %4.2f  max.norm(u) =%14.6e  nst =%4ld \n", t, umax, nst);
 #endif
@@ -269,8 +269,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   MPI_Status status;
   MPI_Comm comm;
 
-  udata = NV_DATA_P(u);
-  dudata = NV_DATA_P(udot);
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
 
   /* Extract needed problem constants from data */
   data = (UserData) user_data;
@@ -281,7 +281,7 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   comm = data->comm;
   npes = data->npes;           /* Number of processes. */ 
   my_pe = data->my_pe;         /* Current process number. */
-  my_length = NV_LOCLENGTH_P(u); /* Number of local elements of u. */ 
+  my_length = N_VGetLocalLength_Parallel(u); /* Number of local elements of u. */ 
   z = data->z;
 
   /* Compute related parameters. */
@@ -334,7 +334,7 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c b/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c
index c19d02f..58cbf00 100644
--- a/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c
+++ b/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.c
@@ -1,9 +1,10 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/14 22:15:31 $
+ * $Revision: 4809 $
+ * $Date: 2016-07-18 11:16:25 -0700 (Mon, 18 Jul 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Lukas Jager and Radu Serban @ LLNL
+ *                Updated by Daniel R. Reynolds @ SMU
  * -----------------------------------------------------------------
  * Parallel Krylov adjoint sensitivity example problem.
  * -----------------------------------------------------------------
@@ -39,19 +40,19 @@
 
 #define XMIN RCONST(0.0)
 #define XMAX RCONST(20.0)
-#define MX   20    /* no. of divisions in x dir. */
+#define MX   80    /* no. of divisions in x dir. */
 #define NPX  2     /* no. of procs. in x dir.    */
 
 #define YMIN RCONST(0.0)
 #define YMAX RCONST(20.0)
-#define MY   40    /* no. of divisions in y dir. */
-#define NPY  2     /* no. of procs. in y dir.    */
+#define MY   80    /* no. of divisions in y dir. */
+#define NPY  4     /* no. of procs. in y dir.    */
 
 #ifdef USE3D
 #define ZMIN RCONST(0.0)
 #define ZMAX RCONST(20.0)
-#define MZ   20    /* no. of divisions in z dir. */
-#define NPZ  1     /* no. of procs. in z dir.    */
+#define MZ   40    /* no. of divisions in z dir. */
+#define NPZ  2     /* no. of procs. in z dir.    */
 #endif
 
 /* Parameters for source Gaussians */
@@ -78,7 +79,7 @@
 
 #define DIFF_COEF RCONST(1.0)
 #define V_MAX     RCONST(1.0)
-#define L         (YMAX-YMIN)/RCONST(2.0)
+#define L         ((YMAX-YMIN)/RCONST(2.0))
 #define V_COEFF   V_MAX/L/L
 
 /* Initial and final times */
@@ -304,12 +305,12 @@ int main(int argc, char *argv[])
 
    /* Extract quadratures */
   flag = CVodeGetQuad(cvode_mem, &tret, q);
-  qdata = NV_DATA_P(q);
+  qdata = N_VGetArrayPointer_Parallel(q);
   MPI_Allreduce(&qdata[0], &G, 1, PVEC_REAL_MPI_TYPE, MPI_SUM, comm);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   if (myId == 0) printf("  G = %Le\n",G);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  if (myId == 0) printf("  G = %le\n",G);
+  if (myId == 0) printf("  G = %e\n",G);
 #else
   if (myId == 0) printf("  G = %e\n",G);
 #endif
@@ -521,7 +522,7 @@ static void SetSource(ProblemData d)
   dx = d->dx;
 
 
-  pdata = NV_DATA_P(d->p);
+  pdata = N_VGetArrayPointer_Parallel(d->p);
 
   for(i[0]=0; i[0]<l_m[0]; i[0]++) {
     x[0] = xmin[0] + (m_start[0]+i[0]) * dx[0];
@@ -532,14 +533,14 @@ static void SetSource(ProblemData d)
         x[2] = xmin[2] + (m_start[2]+i[2]) * dx[2];
         
         g = G1_AMPL 
-          * EXP( -SQR(G1_X-x[0])/SQR(G1_SIGMA) ) 
-          * EXP( -SQR(G1_Y-x[1])/SQR(G1_SIGMA) )
-          * EXP( -SQR(G1_Z-x[2])/SQR(G1_SIGMA) ); 
+          * SUNRexp( -SUNSQR(G1_X-x[0])/SUNSQR(G1_SIGMA) )
+          * SUNRexp( -SUNSQR(G1_Y-x[1])/SUNSQR(G1_SIGMA) )
+          * SUNRexp( -SUNSQR(G1_Z-x[2])/SUNSQR(G1_SIGMA) );
         
         g += G2_AMPL 
-          * EXP( -SQR(G2_X-x[0])/SQR(G2_SIGMA) ) 
-          * EXP( -SQR(G2_Y-x[1])/SQR(G2_SIGMA) )
-          * EXP( -SQR(G2_Z-x[2])/SQR(G2_SIGMA) ); 
+          * SUNRexp( -SUNSQR(G2_X-x[0])/SUNSQR(G2_SIGMA) )
+          * SUNRexp( -SUNSQR(G2_Y-x[1])/SUNSQR(G2_SIGMA) )
+          * SUNRexp( -SUNSQR(G2_Z-x[2])/SUNSQR(G2_SIGMA) );
         
         if( g < G_MIN ) g = ZERO;
 
@@ -547,12 +548,12 @@ static void SetSource(ProblemData d)
       }
 #else
       g = G1_AMPL 
-        * EXP( -SQR(G1_X-x[0])/SQR(G1_SIGMA) ) 
-        * EXP( -SQR(G1_Y-x[1])/SQR(G1_SIGMA) ); 
+        * SUNRexp( -SUNSQR(G1_X-x[0])/SUNSQR(G1_SIGMA) )
+        * SUNRexp( -SUNSQR(G1_Y-x[1])/SUNSQR(G1_SIGMA) );
 
       g += G2_AMPL 
-        * EXP( -SQR(G2_X-x[0])/SQR(G2_SIGMA) ) 
-        * EXP( -SQR(G2_Y-x[1])/SQR(G2_SIGMA) ); 
+        * SUNRexp( -SUNSQR(G2_X-x[0])/SUNSQR(G2_SIGMA) )
+        * SUNRexp( -SUNSQR(G2_Y-x[1])/SUNSQR(G2_SIGMA) );
       
       if( g < G_MIN ) g = ZERO;
 
@@ -592,7 +593,7 @@ static void f_comm(long int N_local, realtype t, N_Vector y, void *user_data)
     l_m[dim] = d->l_m[dim];
   }
   yextdata = d->y_ext;
-  ydata    = NV_DATA_P(y);
+  ydata    = N_VGetArrayPointer_Parallel(y);
   
   /* Calculate required buffer size */
   FOR_DIM {
@@ -724,11 +725,11 @@ static int f_local(long int Nlocal, realtype t, N_Vector y,
   } 
 
   /* Get pointers to vector data */
-  dydata = NV_DATA_P(ydot);
-  pdata  = NV_DATA_P(d->p);
+  dydata = N_VGetArrayPointer_Parallel(ydot);
+  pdata  = N_VGetArrayPointer_Parallel(d->p);
 
   /* Copy local segment of y to y_ext */
-  Load_yext(NV_DATA_P(y), d);
+  Load_yext(N_VGetArrayPointer_Parallel(y), d);
   Ydata = d->y_ext;
 
   /* Velocity components in x1 and x2 directions (Poiseuille profile) */
@@ -774,7 +775,7 @@ static int f_local(long int Nlocal, realtype t, N_Vector y,
             cl[dim] = cr[dim];
 
           adv[dim]  = v[dim] * (cr[dim]-cl[dim]) / (TWO*dx[dim]);
-          diff[dim] = DIFF_COEF * (cr[dim]-TWO*c+cl[dim]) / SQR(dx[dim]);
+          diff[dim] = DIFF_COEF * (cr[dim]-TWO*c+cl[dim]) / SUNSQR(dx[dim]);
 
           IJth(dydata, i) += (diff[dim] - adv[dim]);
         } 
@@ -803,7 +804,7 @@ static int fQ(realtype t, N_Vector y, N_Vector qdot, void *user_data)
 
   d = (ProblemData) user_data;
 
-  dqdata = NV_DATA_P(qdot);
+  dqdata = N_VGetArrayPointer_Parallel(qdot);
 
   dqdata[0] = N_VDotProd_Parallel(y,y);
   dqdata[0] *= RCONST(0.5) * (d->dOmega);
@@ -863,11 +864,11 @@ static int fB_local(long int NlocalB, realtype t,
     nbr_right[dim] = d->nbr_right[dim];
   }
  
-  dyBdata = NV_DATA_P(dyB);
-  ydata   = NV_DATA_P(y);
+  dyBdata = N_VGetArrayPointer_Parallel(dyB);
+  ydata   = N_VGetArrayPointer_Parallel(y);
 
   /* Copy local segment of yB to y_ext */
-  Load_yext(NV_DATA_P(yB), d);
+  Load_yext(N_VGetArrayPointer_Parallel(yB), d);
   YBdata = d->y_ext;
 
   /* Velocity components in x1 and x2 directions (Poiseuille profile) */
@@ -915,7 +916,7 @@ static int fB_local(long int NlocalB, realtype t,
 	      cl[dim] = cr[dim]+(TWO*dx[dim]*v[dim]/DIFF_COEF)*c;
 		  
           adv[dim]  = v[dim] * (cr[dim]-cl[dim]) / (TWO*dx[dim]);
-          diff[dim] = DIFF_COEF * (cr[dim]-TWO*c+cl[dim]) / SQR(dx[dim]);
+          diff[dim] = DIFF_COEF * (cr[dim]-TWO*c+cl[dim]) / SUNSQR(dx[dim]);
           
           IJth(dyBdata, i) -= (diff[dim] + adv[dim]);
         } 
@@ -1072,11 +1073,63 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d)
   xmax = d->xmax;
   dx = d->dx;
 
-  qBdata = NV_DATA_P(qB);
-  pdata  = NV_DATA_P(d->p);
+  qBdata = N_VGetArrayPointer_Parallel(qB);
+  pdata  = N_VGetArrayPointer_Parallel(d->p);
 
   /* Write matlab files with solutions from each process */
 
+  /*   Allocate Matlab storage for data */
+
+  fprintf(fid,"x%d = zeros(%d,1); \n",  myId, l_m[0]);
+  fprintf(fid,"y%d = zeros(%d,1); \n",  myId, l_m[1]);
+#ifdef USE3D
+  fprintf(fid,"z%d = zeros(%d,1); \n",  myId, l_m[2]);
+  fprintf(fid,"p%d = zeros(%d,%d,%d); \n", myId, l_m[1], l_m[0], l_m[2]);
+  fprintf(fid,"g%d = zeros(%d,%d,%d); \n", myId, l_m[1], l_m[0], l_m[2]);
+#else
+  fprintf(fid,"p%d = zeros(%d,%d); \n", myId, l_m[1], l_m[0]);
+  fprintf(fid,"g%d = zeros(%d,%d); \n", myId, l_m[1], l_m[0]);
+#endif
+
+  /*   Write mesh information */
+
+  for(i[0]=0; i[0]<l_m[0]; i[0]++) {
+    x[0] = xmin[0] + (m_start[0]+i[0]) * dx[0];
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    fprintf(fid,"x%d(%d,1) = %Le; \n",  myId, i[0]+1, x[0]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    fprintf(fid,"x%d(%d,1) = %le; \n",  myId, i[0]+1, x[0]);
+#else
+    fprintf(fid,"x%d(%d,1) = %e; \n",  myId, i[0]+1, x[0]);
+#endif
+  }
+
+  for(i[1]=0; i[1]<l_m[1]; i[1]++) {
+    x[1] = xmin[1] + (m_start[1]+i[1]) * dx[1];
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    fprintf(fid,"y%d(%d,1) = %Le; \n",  myId, i[1]+1, x[1]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    fprintf(fid,"y%d(%d,1) = %le; \n",  myId, i[1]+1, x[1]);
+#else
+    fprintf(fid,"y%d(%d,1) = %e; \n",  myId, i[1]+1, x[1]);
+#endif
+  }
+
+#ifdef USE3D
+  for(i[2]=0; i[2]<l_m[2]; i[2]++) {
+    x[2] = xmin[2] + (m_start[2]+i[2]) * dx[2];
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    fprintf(fid,"z%d(%d,1) = %Le; \n",  myId, i[2]+1, x[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    fprintf(fid,"z%d(%d,1) = %le; \n",  myId, i[2]+1, x[2]);
+#else
+    fprintf(fid,"z%d(%d,1) = %e; \n",  myId, i[2]+1, x[2]);
+#endif
+  }
+#endif
+
+  /*   Write solution data */
+
   for(i[0]=0; i[0]<l_m[0]; i[0]++) {
     x[0] = xmin[0] + (m_start[0]+i[0]) * dx[0];
     for(i[1]=0; i[1]<l_m[1]; i[1]++) {
@@ -1087,21 +1140,12 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d)
         g = IJth(qBdata, i);
         p = IJth(pdata, i);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
-        fprintf(fid,"x%d(%d,1) = %Le; \n",  myId, i[0]+1,         x[0]);
-        fprintf(fid,"y%d(%d,1) = %Le; \n",  myId, i[1]+1,         x[1]);
-        fprintf(fid,"z%d(%d,1) = %Le; \n",  myId, i[2]+1,         x[2]);
         fprintf(fid,"p%d(%d,%d,%d) = %Le; \n", myId, i[1]+1, i[0]+1, i[2]+1, p);
         fprintf(fid,"g%d(%d,%d,%d) = %Le; \n", myId, i[1]+1, i[0]+1, i[2]+1, g);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-        fprintf(fid,"x%d(%d,1) = %le; \n",  myId, i[0]+1,         x[0]);
-        fprintf(fid,"y%d(%d,1) = %le; \n",  myId, i[1]+1,         x[1]);
-        fprintf(fid,"z%d(%d,1) = %le; \n",  myId, i[2]+1,         x[2]);
         fprintf(fid,"p%d(%d,%d,%d) = %le; \n", myId, i[1]+1, i[0]+1, i[2]+1, p);
         fprintf(fid,"g%d(%d,%d,%d) = %le; \n", myId, i[1]+1, i[0]+1, i[2]+1, g);
 #else
-        fprintf(fid,"x%d(%d,1) = %e; \n",  myId, i[0]+1,         x[0]);
-        fprintf(fid,"y%d(%d,1) = %e; \n",  myId, i[1]+1,         x[1]);
-        fprintf(fid,"z%d(%d,1) = %e; \n",  myId, i[2]+1,         x[2]);
         fprintf(fid,"p%d(%d,%d,%d) = %e; \n", myId, i[1]+1, i[0]+1, i[2]+1, p);
         fprintf(fid,"g%d(%d,%d,%d) = %e; \n", myId, i[1]+1, i[0]+1, i[2]+1, g);
 #endif
@@ -1110,18 +1154,12 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d)
       g = IJth(qBdata, i);
       p = IJth(pdata, i);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
-      fprintf(fid,"x%d(%d,1) = %Le; \n",  myId, i[0]+1,         x[0]);
-      fprintf(fid,"y%d(%d,1) = %Le; \n",  myId, i[1]+1,         x[1]);
       fprintf(fid,"p%d(%d,%d) = %Le; \n", myId, i[1]+1, i[0]+1, p);
       fprintf(fid,"g%d(%d,%d) = %Le; \n", myId, i[1]+1, i[0]+1, g);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      fprintf(fid,"x%d(%d,1) = %le; \n",  myId, i[0]+1,         x[0]);
-      fprintf(fid,"y%d(%d,1) = %le; \n",  myId, i[1]+1,         x[1]);
-      fprintf(fid,"p%d(%d,%d) = %le; \n", myId, i[1]+1, i[0]+1, p);
-      fprintf(fid,"g%d(%d,%d) = %le; \n", myId, i[1]+1, i[0]+1, g);
+      fprintf(fid,"p%d(%d,%d) = %e; \n", myId, i[1]+1, i[0]+1, p);
+      fprintf(fid,"g%d(%d,%d) = %e; \n", myId, i[1]+1, i[0]+1, g);
 #else
-      fprintf(fid,"x%d(%d,1) = %e; \n",  myId, i[0]+1,         x[0]);
-      fprintf(fid,"y%d(%d,1) = %e; \n",  myId, i[1]+1,         x[1]);
       fprintf(fid,"p%d(%d,%d) = %e; \n", myId, i[1]+1, i[0]+1, p);
       fprintf(fid,"g%d(%d,%d) = %e; \n", myId, i[1]+1, i[0]+1, g);
 #endif
@@ -1130,6 +1168,7 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d)
   }
   fclose(fid);
 
+
   /* Write matlab driver */
 
   if (myId == 0) {
@@ -1137,34 +1176,72 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d)
     fid = fopen("grad.m","w");
 
 #ifdef USE3D
-    fprintf(fid,"clear;\nfigure;\nhold on\n");
+    fprintf(fid,"clear;\n");
+    fprintf(fid,"figure(1);\nhold on\n");
+    fprintf(fid,"figure(2);\nhold on\n");
     fprintf(fid,"trans = 0.7;\n");
     fprintf(fid,"ecol  = 'none';\n");
+    fprintf(fid,"glev1 = 0.4;\n");
+    fprintf(fid,"glev2 = 0.25;\n");
+    fprintf(fid,"gcol1 = 'blue';\n");
+    fprintf(fid,"gcol2 = 'green';\n");
+    fprintf(fid,"gtrans = 0.5;\n");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     fprintf(fid,"xp=[%Lf %Lf];\n",G1_X,G2_X);
-    fprintf(fid,"yp=[%Lf %Lf];\n",G1_Y,G2_Y);
-    fprintf(fid,"zp=[%Lf %Lf];\n",G1_Z,G2_Z);
+    fprintf(fid,"yp=[%Lf];\n",G2_Y);
+    fprintf(fid,"zp=[%Lf];\n",G1_Z);
 #else
     fprintf(fid,"xp=[%f %f];\n",G1_X,G2_X);
-    fprintf(fid,"yp=[%f %f];\n",G1_Y,G2_Y);
-    fprintf(fid,"zp=[%f %f];\n",G1_Z,G2_Z);
+    fprintf(fid,"yp=[%f];\n",G2_Y);
+    fprintf(fid,"zp=[];\n");
 #endif
-    fprintf(fid,"ns = length(xp)*length(yp)*length(zp);\n");
-
     for (ip=0; ip<d->npes; ip++) {
       fprintf(fid,"\ngrad%03d;\n",ip);
+      fprintf(fid,"figure(1)\n");
       fprintf(fid,"[X,Y,Z]=meshgrid(x%d,y%d,z%d);\n",ip,ip,ip);
-      fprintf(fid,"s%d=slice(X,Y,Z,g%d,xp,yp,zp);\n",ip,ip);
-      fprintf(fid,"for i = 1:ns\n");
+      fprintf(fid,"s%d=slice(X,Y,Z,p%d,xp,yp,zp);\n",ip,ip);
+      fprintf(fid,"for i = 1:length(s%d)\n",ip);
       fprintf(fid,"  set(s%d(i),'FaceAlpha',trans);\n",ip);
       fprintf(fid,"  set(s%d(i),'EdgeColor',ecol);\n",ip);
       fprintf(fid,"end\n");
+
+      fprintf(fid,"\nfigure(2)\n");
+      fprintf(fid,"p=patch(isosurface(X,Y,Z,g%d,glev1));\n",ip);
+      fprintf(fid,"p.FaceColor = gcol1;\n");
+      fprintf(fid,"p.EdgeColor = ecol;\n");
+      fprintf(fid,"p=patch(isosurface(X,Y,Z,g%d,glev2));\n",ip);
+      fprintf(fid,"p.FaceColor = gcol2;\n");
+      fprintf(fid,"p.EdgeColor = ecol;\n");
+      fprintf(fid,"p.FaceAlpha = gtrans;\n");
+      fprintf(fid,"clear x%d y%d z%d p%d g%d;\n",ip,ip,ip,ip,ip);
     }
     
+    fprintf(fid,"\nfigure(1)\n");
     fprintf(fid,"view(3)\n");
-    fprintf(fid,"\nshading interp\naxis equal\n");
+    fprintf(fid,"shading interp\naxis equal\n");
+    fprintf(fid,"hold off\n");
+    fprintf(fid,"xlabel('x')\n");
+    fprintf(fid,"ylabel('y')\n");
+    fprintf(fid,"zlabel('z')\n");
+    fprintf(fid,"axis([%f, %f, %f, %f, %f, %f])\n",XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX);
+    fprintf(fid,"print('cvsadjkryx_p3Dcf','-depsc')\n");
+    fprintf(fid,"savefig('cvsadjkryx_p3Dcf.fig')\n");
+
+    fprintf(fid,"\nfigure(2)\n");
+    fprintf(fid,"view(3)\n");
+    fprintf(fid,"axis equal\n");
+    fprintf(fid,"hold off\n");
+    fprintf(fid,"xlabel('x')\n");
+    fprintf(fid,"ylabel('y')\n");
+    fprintf(fid,"zlabel('z')\n");
+    fprintf(fid,"axis([%f, %f, %f, %f, %f, %f])\n",XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX);
+    fprintf(fid,"camlight\n");
+    fprintf(fid,"lighting gouraud\n");
+    fprintf(fid,"print('cvsadjkryx_p3Dgrad','-depsc')\n");
+    fprintf(fid,"savefig('cvsadjkryx_p3Dgrad.fig')\n");
 #else
-    fprintf(fid,"clear;\nfigure;\n");
+    fprintf(fid,"clear;\n");
+    fprintf(fid,"figure('units','normalized','position',[.1 .1 .6 .4])\n");
     fprintf(fid,"trans = 0.7;\n");
     fprintf(fid,"ecol  = 'none';\n");
 
@@ -1172,24 +1249,43 @@ static void OutputGradient(int myId, N_Vector qB, ProblemData d)
 
       fprintf(fid,"\ngrad%03d;\n",ip);
 
-      fprintf(fid,"\nsubplot(1,2,1)\n");
-      fprintf(fid,"s=surf(x%d,y%d,g%d);\n",ip,ip,ip);
-      fprintf(fid,"set(s,'FaceAlpha',trans);\n");
-      fprintf(fid,"set(s,'EdgeColor',ecol);\n");
+      fprintf(fid,"\nax(1) = subplot(1,2,1);\n");
+      fprintf(fid,"s = surf(x%d,y%d,g%d);\n",ip,ip,ip);
+      fprintf(fid,"set(s, 'FaceAlpha', trans);\n");
+      fprintf(fid,"set(s, 'EdgeColor', ecol);\n");
       fprintf(fid,"hold on\n");
       fprintf(fid,"axis tight\n");
       fprintf(fid,"box on\n");
+      fprintf(fid,"colorbar('Position', [0.5 0.1 0.025 0.8])\n");
       
-      fprintf(fid,"\nsubplot(1,2,2)\n");
-      fprintf(fid,"s=surf(x%d,y%d,p%d);\n",ip,ip,ip);
-      fprintf(fid,"set(s,'CData',g%d);\n",ip);
-      fprintf(fid,"set(s,'FaceAlpha',trans);\n");
-      fprintf(fid,"set(s,'EdgeColor',ecol);\n");
+      fprintf(fid,"\nax(2) = subplot(1,2,2);\n");
+      fprintf(fid,"s = surf(x%d,y%d,p%d);\n",ip,ip,ip);
+      fprintf(fid,"set(s, 'CData', g%d);\n",ip);
+      fprintf(fid,"set(s, 'FaceAlpha', trans);\n");
+      fprintf(fid,"set(s, 'EdgeColor', ecol);\n");
       fprintf(fid,"hold on\n");
       fprintf(fid,"axis tight\n");
       fprintf(fid,"box on\n");
 
+      fprintf(fid,"clear x%d y%d p%d g%d;\n",ip,ip,ip,ip);
     }
+
+    fprintf(fid,"\nax(1) = subplot(1,2,1);\n");
+    fprintf(fid,"pos = get(ax(1), 'Position');\n");
+    fprintf(fid,"set(ax(1), 'Position', [pos(1)-0.02 pos(2) pos(3) pos(4)]);\n");
+    fprintf(fid,"xlabel('x'), ylabel('y')\n");
+    fprintf(fid,"hold off\n");
+
+    fprintf(fid,"\nax(2) = subplot(1,2,2);\n");
+    fprintf(fid,"pos = get(ax(2), 'Position');\n");
+    fprintf(fid,"set(ax(2), 'Position', [pos(1)+0.02 pos(2) pos(3) pos(4)]);\n");
+    fprintf(fid,"xlabel('x'), ylabel('y')\n");
+    fprintf(fid,"hold off\n");
+
+    fprintf(fid,"\nfig = gcf;\n");
+    fprintf(fid,"fig.PaperPositionMode = 'auto';\n");
+    fprintf(fid,"print('cvsadjkryx_p2D','-depsc','-r0')\n");
+    fprintf(fid,"savefig('cvsadjkryx_p2D.fig')\n");
 #endif
     fclose(fid);
   }
diff --git a/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.out b/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.out
index f393689..cdcb067 100644
--- a/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.out
+++ b/examples/cvodes/parallel/cvsAtmDisp_ASAi_kry_bbd_p.out
@@ -1,37 +1,36 @@
 
 Parallel Krylov adjoint sensitivity analysis example
-3D Advection diffusion PDE with homogeneous Neumann B.C.
+2D Advection diffusion PDE with homogeneous Neumann B.C.
 Computes gradient of G = int_t_Omega ( c_i^2 ) dt dOmega
 with respect to the source values at each grid point.
 
 Domain:
-   0.000000 < x < 20.000000   mx = 20  npe_x = 2 
-   0.000000 < y < 20.000000   my = 40  npe_y = 2 
-   0.000000 < z < 20.000000   mz = 20  npe_z = 1 
+   0.000000 < x < 20.000000   mx = 80  npe_x = 2 
+   0.000000 < y < 20.000000   my = 80  npe_y = 4 
 
-Begin forward integration... done.   G = 8.232843e+03
+Begin forward integration... done.   G = 4.791513e+03
 
 Final Statistics.. 
 
-lenrw   = 180946     leniw =    212
-llrw    = 180856     lliw  =     80
-nst     =    118
-nfe     =    125     nfel  =    141
-nni     =    121     nli   =    141
-nsetups =     17     netf  =      0
-npe     =      2     nps   =    234
+lenrw   =  65786     leniw =    372
+llrw    =  65656     lliw  =    160
+nst     =    174
+nfe     =    179     nfel  =    310
+nni     =    175     nli   =    310
+nsetups =     18     netf  =      0
+npe     =      4     nps   =    482
 ncfn    =      0     ncfl  =      0
 
 Begin backward integration... done.
 
 Final Statistics.. 
 
-lenrw   = 361716     leniw =    212
-llrw    = 180856     lliw  =     80
-nst     =     70
-nfe     =     80     nfel  =    133
-nni     =     76     nli   =    133
-nsetups =     15     netf  =      0
-npe     =      2     nps   =    204
+lenrw   = 131316     leniw =    372
+llrw    =  65656     lliw  =    160
+nst     =    118
+nfe     =    135     nfel  =    277
+nni     =    131     nli   =    277
+nsetups =     16     netf  =      0
+npe     =      3     nps   =    399
 ncfn    =      0     ncfl  =      0
 
diff --git a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c
index c9d27a7..fcb6787 100644
--- a/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c
+++ b/examples/cvodes/parallel/cvsDiurnal_FSA_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 23:00:48 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): S. D. Cohen, A. C. Hindmarsh, Radu Serban,
  *                and M. R. Wittman @ LLNL
@@ -191,7 +191,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
                         realtype t, N_Vector u);
 static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector *uS);
 static void PrintFinalStats(void *cvode_mem, booleantype sensi); 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -390,8 +390,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   realtype *udata, *dudata;
   UserData data;
 
-  udata = NV_DATA_P(u);
-  dudata = NV_DATA_P(udot);
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
   data = (UserData) user_data;
 
   /* Call ucomm to do inter-processor communicaiton */
@@ -426,7 +426,7 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
   isubx = data->isubx;   isuby = data->isuby;
   nvmxsub = data->nvmxsub;
 
@@ -461,8 +461,8 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
       jy = ly + isuby*MYSUB;
       ydn = YMIN + (jy - RCONST(0.5))*dely;
       yup = ydn + dely;
-      cydn = verdco*EXP(RCONST(0.2)*ydn);
-      cyup = verdco*EXP(RCONST(0.2)*yup);
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
       diag = -(cydn + cyup + RCONST(2.0)*hordco);
       for (lx = 0; lx < MXSUB; lx++) {
         jx = lx + isubx*MXSUB;
@@ -526,7 +526,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
   N_VScale(RCONST(1.0), r, z);
 
   nvmxsub = data->nvmxsub;
-  zdata = NV_DATA_P(z);
+  zdata = N_VGetArrayPointer_Parallel(z);
 
   for (lx = 0; lx < MXSUB; lx++) {
     for (ly = 0; ly < MYSUB; ly++) {
@@ -624,9 +624,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/((realtype)(MX-1));
   data->dy = (YMAX-YMIN)/((realtype)(MY-1));
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(RCONST(2.0)*data->dx);
-  data->vdco = (RCONST(1.0)/SQR(data->dy))*KV0;
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
 
   /* Set machine-related constants */
   data->comm = comm;
@@ -684,7 +684,7 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   realtype *udata;
 
   /* Set pointer to data array in vector u */
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Get mesh spacings, and subgrid indices for this PE */
   dx = data->dx;         dy = data->dy;
@@ -699,13 +699,13 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   for (ly = 0; ly < MYSUB; ly++) {
     jy = ly + isuby*MYSUB;
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - ymid));
-    cy = RCONST(1.0) - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
     for (lx = 0; lx < MXSUB; lx++) {
       jx = lx + isubx*MXSUB;
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - xmid));
-      cx = RCONST(1.0) - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
       udata[offset  ] = C1_SCALE*cx*cy; 
       udata[offset+1] = C2_SCALE*cx*cy;
       offset = offset + 2;
@@ -870,7 +870,7 @@ static void ucomm(realtype t, N_Vector u, UserData data)
   long int isubx, isuby, nvmxsub, nvmysub;
   MPI_Request request[4];
 
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
   comm = data->comm;  my_pe = data->my_pe;
@@ -973,8 +973,8 @@ static void fcalc(realtype t, realtype udata[], realtype dudata[], UserData data
   data block for use by preconditioner evaluation routine */
   s = sin((data->om)*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    q4coef = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
   } else {
     q3 = ZERO;
     q4coef = ZERO;
@@ -988,8 +988,8 @@ static void fcalc(realtype t, realtype udata[], realtype dudata[], UserData data
     /* Set vertical diffusion coefficients at jy +- 1/2 */
     ydn = YMIN + (jy - .5)*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     for (lx = 0; lx < MXSUB; lx++) {
       jx = lx + isubx*MXSUB;
 
@@ -1045,7 +1045,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
   MPI_Status status;
 
   npelast = NPEX*NPEY - 1;
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Send c at top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -1076,7 +1076,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%8.3Le %2d  %8.3Le %5ld\n", t,qu,hu,nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.3le %2d  %8.3le %5ld\n", t,qu,hu,nst);
+    printf("%8.3e %2d  %8.3e %5ld\n", t,qu,hu,nst);
 #else
     printf("%8.3e %2d  %8.3e %5ld\n", t,qu,hu,nst);
 #endif
@@ -1085,7 +1085,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le %12.4Le \n", udata[0], tempu[0]); 
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le %12.4le \n", udata[0], tempu[0]); 
+    printf("%12.4e %12.4e \n", udata[0], tempu[0]); 
 #else
     printf("%12.4e %12.4e \n", udata[0], tempu[0]); 
 #endif
@@ -1095,7 +1095,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le %12.4Le \n", udata[1], tempu[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le %12.4le \n", udata[1], tempu[1]);
+    printf("%12.4e %12.4e \n", udata[1], tempu[1]);
 #else
     printf("%12.4e %12.4e \n", udata[1], tempu[1]);
 #endif
@@ -1116,7 +1116,7 @@ static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector *uS)
 
   npelast = NPEX*NPEY - 1;
 
-  sdata = NV_DATA_P(uS[0]);
+  sdata = N_VGetArrayPointer_Parallel(uS[0]);
 
   /* Send s1 at top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -1139,7 +1139,7 @@ static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le %12.4Le \n", sdata[0], temps[0]); 
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le %12.4le \n", sdata[0], temps[0]); 
+    printf("%12.4e %12.4e \n", sdata[0], temps[0]); 
 #else
     printf("%12.4e %12.4e \n", sdata[0], temps[0]); 
 #endif
@@ -1147,13 +1147,13 @@ static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le %12.4Le \n", sdata[1], temps[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le %12.4le \n", sdata[1], temps[1]);
+    printf("%12.4e %12.4e \n", sdata[1], temps[1]);
 #else
     printf("%12.4e %12.4e \n", sdata[1], temps[1]);
 #endif
   }
 
-  sdata = NV_DATA_P(uS[1]);
+  sdata = N_VGetArrayPointer_Parallel(uS[1]);
 
   /* Send s2 at top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -1176,7 +1176,7 @@ static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le %12.4Le \n", sdata[0], temps[0]); 
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le %12.4le \n", sdata[0], temps[0]); 
+    printf("%12.4e %12.4e \n", sdata[0], temps[0]); 
 #else
     printf("%12.4e %12.4e \n", sdata[0], temps[0]); 
 #endif
@@ -1184,7 +1184,7 @@ static void PrintOutputS(int my_pe, MPI_Comm comm, N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%12.4Le %12.4Le \n", sdata[1], temps[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%12.4le %12.4le \n", sdata[1], temps[1]);
+    printf("%12.4e %12.4e \n", sdata[1], temps[1]);
 #else
     printf("%12.4e %12.4e \n", sdata[1], temps[1]);
 #endif
@@ -1255,7 +1255,7 @@ static void PrintFinalStats(void *cvode_mem, booleantype sensi)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c b/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c
index 93be293..c167b8c 100644
--- a/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c
+++ b/examples/cvodes/parallel/cvsDiurnal_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/14 22:15:31 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): S. D. Cohen, A. C. Hindmarsh, M. R. Wittman, and
  *                Radu Serban  @ LLNL
@@ -60,7 +60,7 @@
 #include <cvodes/cvodes_bbdpre.h>     /* prototypes for CVBBDPRE module */
 #include <nvector/nvector_parallel.h> /* definition N_Vector and macro NV_DATA_P */
 #include <sundials/sundials_types.h>  /* definitions of realtype, booleantype */
-#include <sundials/sundials_math.h>   /* definition of macros SQR and EXP */
+#include <sundials/sundials_math.h>   /* definition of macros SUNSQR and EXP */
 
 #include <mpi.h>                      /* MPI constants and types */
 
@@ -156,7 +156,7 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /***************************** Main Program ******************************/
 
@@ -309,9 +309,9 @@ static void InitUserData(int my_pe, long int local_N, MPI_Comm comm,
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/((realtype)(MX-1));
   data->dy = (YMAX-YMIN)/((realtype)(MY-1));
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(RCONST(2.0)*data->dx);
-  data->vdco = (RCONST(1.0)/SQR(data->dy))*KV0;
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
 
   /* Set machine-related constants */
   data->comm = comm;
@@ -339,7 +339,7 @@ static void SetInitialProfiles(N_Vector u, UserData data)
 
   /* Set pointer to data array in vector u */
 
-  uarray = NV_DATA_P(u);
+  uarray = N_VGetArrayPointer_Parallel(u);
 
   /* Get mesh spacings, and subgrid indices for this PE */
 
@@ -356,13 +356,13 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   for (ly = 0; ly < MYSUB; ly++) {
     jy = ly + isuby*MYSUB;
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - ymid));
-    cy = RCONST(1.0) - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
     for (lx = 0; lx < MXSUB; lx++) {
       jx = lx + isubx*MXSUB;
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - xmid));
-      cx = RCONST(1.0) - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
       uarray[offset  ] = C1_SCALE*cx*cy; 
       uarray[offset+1] = C2_SCALE*cx*cy;
       offset = offset + 2;
@@ -397,7 +397,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
   MPI_Status status;
 
   npelast = NPEX*NPEY - 1;
-  uarray = NV_DATA_P(u);
+  uarray = N_VGetArrayPointer_Parallel(u);
 
   /* Send c1,c2 at top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -428,10 +428,10 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
     printf("At bottom left:  c1, c2 = %12.3Le %12.3Le \n", uarray[0], uarray[1]);
     printf("At top right:    c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+    printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
-    printf("At bottom left:  c1, c2 = %12.3le %12.3le \n", uarray[0], uarray[1]);
-    printf("At top right:    c1, c2 = %12.3le %12.3le \n\n", tempu[0], tempu[1]);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", uarray[0], uarray[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
 #else
     printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
@@ -657,7 +657,7 @@ static void fucomm(realtype t, N_Vector u, void *user_data)
   MPI_Request request[4];
 
   data = (UserData) user_data;
-  uarray = NV_DATA_P(u);
+  uarray = N_VGetArrayPointer_Parallel(u);
 
   /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
 
@@ -722,8 +722,8 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
   UserData data;
   realtype *uarray, *duarray;
 
-  uarray = NV_DATA_P(u);
-  duarray = NV_DATA_P(udot);
+  uarray = N_VGetArrayPointer_Parallel(u);
+  duarray = N_VGetArrayPointer_Parallel(udot);
 
   /* Get subgrid indices, array sizes, extended work array uext */
 
@@ -787,8 +787,8 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
 
   s = sin((data->om)*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    q4coef = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
   } else {
     q3 = ZERO;
     q4coef = ZERO;
@@ -806,8 +806,8 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     for (lx = 0; lx < MXSUB; lx++) {
 
       jx = lx + isubx*MXSUB;
@@ -863,7 +863,7 @@ static int flocal(long int Nlocal, realtype t, N_Vector u,
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvodes/parallel/cvsDiurnal_kry_p.c b/examples/cvodes/parallel/cvsDiurnal_kry_p.c
index 3f6ce0a..d2a9ac1 100644
--- a/examples/cvodes/parallel/cvsDiurnal_kry_p.c
+++ b/examples/cvodes/parallel/cvsDiurnal_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 23:00:48 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): S. D. Cohen, A. C. Hindmarsh, M. R. Wittman, and
  *                Radu Serban  @ LLNL
@@ -57,7 +57,7 @@
 #include <nvector/nvector_parallel.h>  /* definition N_Vector and macro NV_DATA_P  */
 #include <sundials/sundials_dense.h>   /* prototypes for small dense matrix fcts. */
 #include <sundials/sundials_types.h>   /* definitions of realtype, booleantype */
-#include <sundials/sundials_math.h>    /* definition of macros SQR and EXP */
+#include <sundials/sundials_math.h>    /* definition of macros SUNSQR and EXP */
 
 #include <mpi.h>                       /* MPI constants and types */
 
@@ -95,7 +95,7 @@
 #define MX           (NPEX*MXSUB)   /* MX = number of x mesh points */
 #define MY           (NPEY*MYSUB)   /* MY = number of y mesh points */
                                     /* Spatial mesh is MX by MY */
-/* CVodeMalloc Constants */
+/* CVodeInit Constants */
 
 #define RTOL    RCONST(1.0e-5)    /* scalar relative tolerance */
 #define FLOOR   RCONST(100.0)     /* value of C1 or C2 at which tolerances */
@@ -176,7 +176,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 
 /***************************** Main Program ******************************/
@@ -294,9 +294,9 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/((realtype)(MX-1));
   data->dy = (YMAX-YMIN)/((realtype)(MY-1));
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(RCONST(2.0)*data->dx);
-  data->vdco = (RCONST(1.0)/SQR(data->dy))*KV0;
+  data->vdco = (RCONST(1.0)/SUNSQR(data->dy))*KV0;
 
   /* Set machine-related constants */
   data->comm = comm;
@@ -349,7 +349,7 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   realtype *udata;
 
   /* Set pointer to data array in vector u */
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Get mesh spacings, and subgrid indices for this PE */
   dx = data->dx;         dy = data->dy;
@@ -364,13 +364,13 @@ static void SetInitialProfiles(N_Vector u, UserData data)
   for (ly = 0; ly < MYSUB; ly++) {
     jy = ly + isuby*MYSUB;
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - ymid));
-    cy = RCONST(1.0) - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - ymid));
+    cy = RCONST(1.0) - cy + RCONST(0.5)*SUNSQR(cy);
     for (lx = 0; lx < MXSUB; lx++) {
       jx = lx + isubx*MXSUB;
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - xmid));
-      cx = RCONST(1.0) - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - xmid));
+      cx = RCONST(1.0) - cx + RCONST(0.5)*SUNSQR(cx);
       udata[offset  ] = C1_SCALE*cx*cy; 
       udata[offset+1] = C2_SCALE*cx*cy;
       offset = offset + 2;
@@ -390,7 +390,7 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
   MPI_Status status;
 
   npelast = NPEX*NPEY - 1;
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Send c1,c2 at top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -422,10 +422,10 @@ static void PrintOutput(void *cvode_mem, int my_pe, MPI_Comm comm,
     printf("At bottom left:  c1, c2 = %12.3Le %12.3Le \n", udata[0], udata[1]);
     printf("At top right:    c1, c2 = %12.3Le %12.3Le \n\n", tempu[0], tempu[1]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+    printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
-    printf("At bottom left:  c1, c2 = %12.3le %12.3le \n", udata[0], udata[1]);
-    printf("At top right:    c1, c2 = %12.3le %12.3le \n\n", tempu[0], tempu[1]);
+    printf("At bottom left:  c1, c2 = %12.3e %12.3e \n", udata[0], udata[1]);
+    printf("At top right:    c1, c2 = %12.3e %12.3e \n\n", tempu[0], tempu[1]);
 #else
     printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
            t, nst, qu, hu);
@@ -635,7 +635,7 @@ static void ucomm(realtype t, N_Vector u, UserData data)
   long int nvmxsub, nvmysub;
   MPI_Request request[4];
 
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
 
   /* Get comm, my_pe, subgrid indices, data sizes, extended array uext */
   comm = data->comm;  my_pe = data->my_pe;
@@ -727,8 +727,8 @@ static void fcalc(realtype t, realtype udata[],
   data block for use by preconditioner evaluation routine */
   s = sin((data->om)*t);
   if (s > RCONST(0.0)) {
-    q3 = EXP(-A3/s);
-    q4coef = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    q4coef = SUNRexp(-A4/s);
   } else {
     q3 = RCONST(0.0);
     q4coef = RCONST(0.0);
@@ -743,8 +743,8 @@ static void fcalc(realtype t, realtype udata[],
     /* Set vertical diffusion coefficients at jy +- 1/2 */
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     for (lx = 0; lx < MXSUB; lx++) {
 
       jx = lx + isubx*MXSUB;
@@ -797,8 +797,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   realtype *udata, *dudata;
   UserData data;
 
-  udata = NV_DATA_P(u);
-  dudata = NV_DATA_P(udot);
+  udata = N_VGetArrayPointer_Parallel(u);
+  dudata = N_VGetArrayPointer_Parallel(udot);
   data = (UserData) user_data;
 
   /* Call ucomm to do inter-processor communication */
@@ -830,7 +830,7 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  udata = NV_DATA_P(u);
+  udata = N_VGetArrayPointer_Parallel(u);
   isubx = data->isubx;   isuby = data->isuby;
   nvmxsub = data->nvmxsub;
 
@@ -861,8 +861,8 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
       jy = ly + isuby*MYSUB;
       ydn = YMIN + (jy - RCONST(0.5))*dely;
       yup = ydn + dely;
-      cydn = verdco*EXP(RCONST(0.2)*ydn);
-      cyup = verdco*EXP(RCONST(0.2)*yup);
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
       diag = -(cydn + cyup + RCONST(2.0)*hordco);
       for (lx = 0; lx < MXSUB; lx++) {
         jx = lx + isubx*MXSUB;
@@ -924,7 +924,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
   N_VScale(RCONST(1.0), r, z);
 
   nvmxsub = data->nvmxsub;
-  zdata = NV_DATA_P(z);
+  zdata = N_VGetArrayPointer_Parallel(z);
 
   for (lx = 0; lx < MXSUB; lx++) {
     for (ly = 0; ly < MYSUB; ly++) {
@@ -947,7 +947,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/CMakeLists.txt b/examples/cvodes/serial/CMakeLists.txt
index 1daa16c..ea409c7 100644
--- a/examples/cvodes/serial/CMakeLists.txt
+++ b/examples/cvodes/serial/CMakeLists.txt
@@ -1,46 +1,64 @@
 # ---------------------------------------------------------------
-# $Revision: 1.7 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4824 $
+# $Date: 2016-07-24 16:39:04 -0700 (Sun, 24 Jul 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for CVODES serial examples
 
-
 # Add variable CVODES_examples with the names of the serial CVODES examples
-
-SET(CVODES_examples
-  cvsAdvDiff_ASAi_bnd
-  cvsAdvDiff_bnd
-  cvsAdvDiff_FSA_non
-  cvsDirectDemo_ls
-  cvsDiurnal_FSA_kry
-  cvsDiurnal_kry_bp
-  cvsDiurnal_kry
-  cvsFoodWeb_ASAi_kry
-  cvsFoodWeb_ASAp_kry
-  cvsHessian_ASA_FSA
-  cvsKrylovDemo_ls
-  cvsKrylovDemo_prec
-  cvsRoberts_ASAi_dns
-  cvsRoberts_dns
-  cvsRoberts_dns_uw
-  cvsRoberts_FSA_dns
+# This is a list of tuples, first element is example name.
+# Optional second argument is test arguments
+SET(CVODES_examples 
+   cvsAdvDiff_ASAi_bnd
+   cvsAdvDiff_bnd
+  "cvsAdvDiff_FSA_non\;-sensi stg t"
+  "cvsAdvDiff_FSA_non\;-sensi sim t"
+   cvsDirectDemo_ls
+  "cvsDiurnal_FSA_kry\;-sensi stg t"
+  "cvsDiurnal_FSA_kry\;-sensi sim t"
+   cvsDiurnal_kry_bp
+   cvsDiurnal_kry
+   cvsFoodWeb_ASAi_kry
+   cvsFoodWeb_ASAp_kry
+   cvsHessian_ASA_FSA
+   cvsKrylovDemo_ls
+   cvsKrylovDemo_prec
+   cvsRoberts_ASAi_dns
+   cvsRoberts_dns
+   cvsRoberts_dns_uw
+   "cvsRoberts_FSA_dns\;-sensi stg1 t"
   )
 
 # Add variable CVODES_examples_BL with the names of the serial CVODES examples
 # that use Lapack
-
 SET(CVODES_examples_BL
   cvsAdvDiff_bndL
   cvsRoberts_dnsL
   )
 
+SET(CVODES_examples_KLU
+  cvsRoberts_klu
+  cvsRoberts_ASAi_klu
+  "cvsRoberts_FSA_klu\;-sensi stg1 t"
+  )
+ 
+SET(CVODES_examples_SUPERLUMT
+  cvsRoberts_sps
+  cvsRoberts_ASAi_sps
+  "cvsRoberts_FSA_sps\;-sensi stg1 t"
+  )
+
 # Specify libraries to link against (through the target that was used to 
 # generate them) based on the value of the variable LINK_LIBRARY_TYPE
 
@@ -56,20 +74,48 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${CVODES_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
 # Add the build and install targets for each CVODES example
 
-FOREACH(example ${CVODES_examples})
-  ADD_EXECUTABLE(${example} ${example}.c)
+# SGS is there a way to query CMAKE variable to get added executables 
+# rather than keeping our own list?
+SET(ADDED_EXECUTABLES "")
+FOREACH(example_tuple ${CVODES_examples})
+  LIST(GET example_tuple 0 example)
+
+  # Only need to add the executable once
+  LIST(FIND ADDED_EXECUTABLES ${example} index)
+  IF(index EQUAL -1)
+    LIST(APPEND ADDED_EXECUTABLES ${example})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  ENDIF(index EQUAL -1)
+
+  LIST(LENGTH example_tuple n)
+  IF(n EQUAL 2)
+    LIST(GET example_tuple 1 test_args)
+    STRING(REGEX REPLACE " " "_" test_name ${example}_${test_args})
+    SUNDIALS_ADD_TEST(${test_name} ${example} TEST_ARGS ${test_args})
+  ELSE()
+    SUNDIALS_ADD_TEST(${example} ${example})
+  ENDIF()
+
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   FILE(GLOB example_out ${example}.out*)
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example_out} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${CVODES_examples})
+ENDFOREACH(example_tuple ${CVODES_examples})
 
 # If Lapack support is enabled, add the build and install targets for
 # the examples using Lapack
@@ -77,6 +123,8 @@ ENDFOREACH(example ${CVODES_examples})
 IF(LAPACK_FOUND)
   FOREACH(example ${CVODES_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     FILE(GLOB example_out ${example}.out*)
     IF(EXAMPLES_INSTALL)
@@ -85,6 +133,70 @@ IF(LAPACK_FOUND)
   ENDFOREACH(example ${CVODES_examples_BL})
 ENDIF(LAPACK_FOUND)
 
+# If KLU support is enabled, add the build and install targets for
+# the examples using KLU
+IF(KLU_FOUND)
+  SET(ADDED_EXECUTABLES "")
+  FOREACH(example_tuple ${CVODES_examples_KLU})
+    LIST(GET example_tuple 0 example)
+  
+    # Only need to add the executable once
+    LIST(FIND ADDED_EXECUTABLES ${example} index)
+    IF(index EQUAL -1)
+      LIST(APPEND ADDED_EXECUTABLES ${example})
+      ADD_EXECUTABLE(${example} ${example}.c)
+      SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    ENDIF(index EQUAL -1)
+  
+    LIST(LENGTH example_tuple n)
+    IF(n EQUAL 2)
+      LIST(GET example_tuple 1 test_args)
+      STRING(REGEX REPLACE " " "_" test_name ${example}_${test_args})
+      SUNDIALS_ADD_TEST(${test_name} ${example} TEST_ARGS ${test_args})
+    ELSE()
+      SUNDIALS_ADD_TEST(${example} ${example})
+    ENDIF()
+  
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    FILE(GLOB example_out ${example}.out*)
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example_out} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example_tuple ${CVODES_examples_KLU})
+ENDIF(KLU_FOUND)
+
+# If SUPERLUMT support is enabled, add the build and install targets for
+# the examples using SUPERLUMT
+IF(SUPERLUMT_FOUND)
+  SET(ADDED_EXECUTABLES "")
+  FOREACH(example_tuple ${CVODES_examples_SUPERLUMT})
+    LIST(GET example_tuple 0 example)
+  
+    # Only need to add the executable once
+    LIST(FIND ADDED_EXECUTABLES ${example} index)
+    IF(index EQUAL -1)
+      LIST(APPEND ADDED_EXECUTABLES ${example})
+      ADD_EXECUTABLE(${example} ${example}.c)
+      SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    ENDIF(index EQUAL -1)
+  
+    LIST(LENGTH example_tuple n)
+    IF(n EQUAL 2)
+      LIST(GET example_tuple 1 test_args)
+      STRING(REGEX REPLACE " " "_" test_name ${example}_${test_args})
+      SUNDIALS_ADD_TEST(${test_name} ${example} TEST_ARGS ${test_args})
+    ELSE()
+      SUNDIALS_ADD_TEST(${example} ${example})
+    ENDIF()
+  
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    FILE(GLOB example_out ${example}.out*)
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example_out} DESTINATION ${EXAMPLES_INSTALL_PATH}/cvodes/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example_tuple ${CVODES_examples_SUPERLUMT})
+ENDIF(SUPERLUMT_FOUND)
+
 IF(EXAMPLES_INSTALL)
 
   # Install the README file
@@ -93,13 +205,35 @@ IF(EXAMPLES_INSTALL)
   # Prepare substitution variables for Makefile and/or CMakeLists templates
   SET(SOLVER "CVODES")
   SET(SOLVER_LIB "sundials_cvodes")
-  LIST2STRING(CVODES_examples EXAMPLES)
+  FOREACH(example_tuple ${CVODES_examples})
+    list(GET example_tuple 0 example)
+    LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${CVODES_examples})
+
   IF(LAPACK_FOUND)
     LIST2STRING(CVODES_examples_BL EXAMPLES_BL)
   ELSE(LAPACK_FOUND)
     SET(EXAMPLES_BL "")
   ENDIF(LAPACK_FOUND)
 
+  IF(KLU_FOUND)
+    FOREACH(example_tuple ${CVODES_examples_KLU})
+      list(GET example_tuple 0 example)
+      LIST2STRING(example EXAMPLES)
+    ENDFOREACH(example_tuple ${CVODES_examples_KLU})
+  ENDIF(KLU_FOUND)
+
+  IF(SUPERLUMT_FOUND)
+    FOREACH(example_tuple ${CVODES_examples_SUPERLUMT})
+      list(GET example_tuple 0 example)
+      LIST2STRING(example EXAMPLES)
+    ENDFOREACH(example_tuple ${CVODES_examples_SUPERLUMT})
+  ENDIF(SUPERLUMT_FOUND)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+  list(REMOVE_DUPLICATES EXAMPLES)
+
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
   # be used as a template for the user's own programs.
diff --git a/examples/cvodes/serial/Makefile.in b/examples/cvodes/serial/Makefile.in
deleted file mode 100644
index 10f65a4..0000000
--- a/examples/cvodes/serial/Makefile.in
+++ /dev/null
@@ -1,146 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for CVODES serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/cvodes/libsundials_cvodes.la          \
-	        $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = cvsAdvDiff_ASAi_bnd \
-	   cvsAdvDiff_bnd \
-	   cvsAdvDiff_FSA_non \
-	   cvsDirectDemo_ls \
-	   cvsDiurnal_FSA_kry \
-	   cvsDiurnal_kry_bp \
-	   cvsDiurnal_kry \
-	   cvsFoodWeb_ASAi_kry \
-	   cvsFoodWeb_ASAp_kry \
-	   cvsHessian_ASA_FSA \
-	   cvsKrylovDemo_ls \
-	   cvsKrylovDemo_prec \
-	   cvsRoberts_ASAi_dns \
-	   cvsRoberts_dns \
-	   cvsRoberts_dns_uw \
-	   cvsRoberts_FSA_dns 
-
-EXAMPLES_BL = cvsAdvDiff_bndL \
-	      cvsRoberts_dnsL
-
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done ; \
-	fi
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/cvodes/serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/cvodes/serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/cvodes/serial/README $(EXS_INSTDIR)/cvodes/serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvodes/serial/$${i}.c   $(EXS_INSTDIR)/cvodes/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvodes/serial/$${i}.out $(EXS_INSTDIR)/cvodes/serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvodes/serial/$${i}.c   $(EXS_INSTDIR)/cvodes/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/cvodes/serial/$${i}.out $(EXS_INSTDIR)/cvodes/serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/cvodes/serial/Makefile
-	rm -f $(EXS_INSTDIR)/cvodes/serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/cvodes/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/cvodes/serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/cvodes/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/cvodes/serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/cvodes/serial
-	$(rminstalldirs) $(EXS_INSTDIR)/cvodes
-
-clean:
-	rm -rf .libs
-	rm -f *.lo
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	${SHELL} ./config.status --recheck ; \
-	cd ${abs_builddir}
diff --git a/examples/cvodes/serial/README b/examples/cvodes/serial/README
index 99d10a8..92bdb82 100644
--- a/examples/cvodes/serial/README
+++ b/examples/cvodes/serial/README
@@ -12,6 +12,8 @@ List of serial CVODES examples
   cvsRoberts_dns        : dense example
   cvsRoberts_dnsL       : dense example (Lapack)
   cvsRoberts_dns_uw     : dense example with user ewt function
+  cvsRoberts_klu        : dense example with KLU sparse linear solver
+  cvsRoberts_sps        : dense example with SuperLUMT sparse linear solver
 
 (2) Forward sensitivity
 
@@ -30,15 +32,48 @@ List of serial CVODES examples
   cvsHessian_ASA_FSA    : ASA example for computing Hessian
   cvsRoberts_ASAi_dns   : chemical kinetics - adjoint sensitivity
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --with-blas-lapack-libs="-L/home/radu/apps/lib -lSimTKlapack" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
-
-  The SimTKlapack library provides ATLAS-tunned Blas and Lapack functions
\ No newline at end of file
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c b/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c
index 641ee83..b35e6d3 100644
--- a/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c
+++ b/examples/cvodes/serial/cvsAdvDiff_ASAi_bnd.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2011/11/23 23:53:02 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -110,7 +110,7 @@ static int JacB(long int NB, long int muB, long int mlB,
 
 static void SetIC(N_Vector u, UserData data);
 static void PrintOutput(N_Vector uB, UserData data);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -266,8 +266,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   int i, j;
   UserData data;
 
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Extract needed constants from data */
 
@@ -362,8 +362,8 @@ static int fB(realtype tB, N_Vector u, N_Vector uB, N_Vector uBdot,
   realtype hdiffB, hadvB, vdiffB;
   int i, j;
 
-  uBdata = NV_DATA_S(uB);
-  duBdata = NV_DATA_S(uBdot);
+  uBdata = N_VGetArrayPointer_Serial(uB);
+  duBdata = N_VGetArrayPointer_Serial(uBdot);
 
   /* Extract needed constants from data */
 
@@ -460,7 +460,7 @@ static void SetIC(N_Vector u, UserData data)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profile into u vector */
 
@@ -468,7 +468,7 @@ static void SetIC(N_Vector u, UserData data)
     y = j*dy;
     for (i=1; i <= MX; i++) {
       x = i*dx;
-      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*EXP(RCONST(5.0)*x*y);
+      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*SUNRexp(RCONST(5.0)*x*y);
     }
   }  
 
@@ -488,13 +488,13 @@ static void PrintOutput(N_Vector uB, UserData data)
   dx = data->dx;
   dy = data->dy;
 
-  uBdata = NV_DATA_S(uB);
+  uBdata = N_VGetArrayPointer_Serial(uB);
 
   uBmax = ZERO;
   for(j=1; j<= MY; j++) {
     for(i=1; i<=MX; i++) {
       uBij = IJth(uBdata, i, j);
-      if (ABS(uBij) > uBmax) {
+      if (SUNRabs(uBij) > uBmax) {
         uBmax = uBij;
         x = i*dx;
         y = j*dy;
@@ -506,7 +506,7 @@ static void PrintOutput(N_Vector uB, UserData data)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("  lambda max = %Le\n", uBmax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("  lambda max = %le\n", uBmax);
+  printf("  lambda max = %e\n", uBmax);
 #else
   printf("  lambda max = %e\n", uBmax);
 #endif
@@ -514,7 +514,7 @@ static void PrintOutput(N_Vector uB, UserData data)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("  x = %Le\n  y = %Le\n", x, y);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("  x = %le\n  y = %le\n", x, y);
+  printf("  x = %e\n  y = %e\n", x, y);
 #else
   printf("  x = %e\n  y = %e\n", x, y);
 #endif
@@ -531,7 +531,7 @@ static void PrintOutput(N_Vector uB, UserData data)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsAdvDiff_FSA_non.c b/examples/cvodes/serial/cvsAdvDiff_FSA_non.c
index 039e16e..1667246 100644
--- a/examples/cvodes/serial/cvsAdvDiff_FSA_non.c
+++ b/examples/cvodes/serial/cvsAdvDiff_FSA_non.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2008/12/31 00:04:42 $
+ * $Revision: 4956 $
+ * $Date: 2016-09-23 11:15:59 -0700 (Fri, 23 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, George D. Byrne,
  *              and Radu Serban @ LLNL
@@ -91,7 +91,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector u);
 static void PrintOutputS(N_Vector *uS);
 static void PrintFinalStats(void *cvode_mem, booleantype sensi);
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -231,6 +231,7 @@ int main(int argc, char *argv[])
     free(plist);
     free(pbar);
   }
+  free(data->p);
   free(data);
   CVodeFree(&cvode_mem);
 
@@ -255,8 +256,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   int i;
   UserData data;
 
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Extract needed problem constants from data */
   data = (UserData) user_data;
@@ -357,12 +358,12 @@ static void SetIC(N_Vector u, realtype dx)
   realtype *udata;
 
   /* Set pointer to data array and get local length of u. */
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profile into u vector */
   for (i=0; i<NEQ; i++) {
     x = (i+1)*dx;
-    udata[i] = x*(XMAX - x)*EXP(RCONST(2.0)*x);
+    udata[i] = x*(XMAX - x)*SUNRexp(RCONST(2.0)*x);
   }  
 }
 
@@ -386,7 +387,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%8.3Le %2d  %8.3Le %5ld\n", t, qu, hu ,nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%8.3le %2d  %8.3le %5ld\n", t, qu, hu ,nst);
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu ,nst);
 #else
   printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu ,nst);
 #endif
@@ -396,7 +397,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le \n", N_VMaxNorm(u));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le \n", N_VMaxNorm(u));
+  printf("%12.4e \n", N_VMaxNorm(u));
 #else
   printf("%12.4e \n", N_VMaxNorm(u));
 #endif
@@ -412,7 +413,7 @@ static void PrintOutputS(N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le \n", N_VMaxNorm(uS[0]));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le \n", N_VMaxNorm(uS[0]));
+  printf("%12.4e \n", N_VMaxNorm(uS[0]));
 #else
   printf("%12.4e \n", N_VMaxNorm(uS[0]));
 #endif
@@ -421,7 +422,7 @@ static void PrintOutputS(N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le \n", N_VMaxNorm(uS[1]));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le \n", N_VMaxNorm(uS[1]));
+  printf("%12.4e \n", N_VMaxNorm(uS[1]));
 #else
   printf("%12.4e \n", N_VMaxNorm(uS[1]));
 #endif
@@ -492,7 +493,7 @@ static void PrintFinalStats(void *cvode_mem, booleantype sensi)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsAdvDiff_bnd.c b/examples/cvodes/serial/cvsAdvDiff_bnd.c
index 2a8fba3..22c3a1f 100644
--- a/examples/cvodes/serial/cvsAdvDiff_bnd.c
+++ b/examples/cvodes/serial/cvsAdvDiff_bnd.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -68,7 +68,7 @@
    to the underlying 1-dimensional storage. 
    IJth(vdata,i,j) references the element in the vdata array for
    u at mesh point (i,j), where 1 <= i <= MX, 1 <= j <= MY.
-   The vdata array is obtained via the macro call vdata = NV_DATA_S(v),
+   The vdata array is obtained via the macro call vdata = N_VGetArrayPointer_Serial(v),
    where v is an N_Vector. 
    The variables are ordered by the y index j, then by the x index i. */
 
@@ -89,7 +89,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -201,8 +201,8 @@ static int f(realtype t, N_Vector u,N_Vector udot, void *user_data)
   int i, j;
   UserData data;
 
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Extract needed constants from data */
 
@@ -302,7 +302,7 @@ static void SetIC(N_Vector u, UserData data)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profile into u vector */
   
@@ -310,7 +310,7 @@ static void SetIC(N_Vector u, UserData data)
     y = j*dy;
     for (i=1; i <= MX; i++) {
       x = i*dx;
-      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*EXP(FIVE*x*y);
+      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*SUNRexp(FIVE*x*y);
     }
   }  
 }
@@ -326,8 +326,8 @@ static void PrintHeader(realtype reltol, realtype abstol, realtype umax)
   printf("Tolerance parameters: reltol = %Lg   abstol = %Lg\n\n", reltol, abstol);
   printf("At t = %Lg      max.norm(u) =%14.6Le \n", T0, umax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters: reltol = %lg   abstol = %lg\n\n", reltol, abstol);
-  printf("At t = %lg      max.norm(u) =%14.6le \n", T0, umax);
+  printf("Tolerance parameters: reltol = %g   abstol = %g\n\n", reltol, abstol);
+  printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
 #else
   printf("Tolerance parameters: reltol = %g   abstol = %g\n\n", reltol, abstol);
   printf("At t = %g      max.norm(u) =%14.6e \n", T0, umax);
@@ -343,7 +343,7 @@ static void PrintOutput(realtype t, realtype umax, long int nst)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %4.2Lf   max.norm(u) =%14.6Le   nst = %4ld\n", t, umax, nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %4.2f   max.norm(u) =%14.6le   nst = %4ld\n", t, umax, nst);
+  printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
 #else
   printf("At t = %4.2f   max.norm(u) =%14.6e   nst = %4ld\n", t, umax, nst);
 #endif
@@ -393,7 +393,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsAdvDiff_bndL.c b/examples/cvodes/serial/cvsAdvDiff_bndL.c
index a592980..c61c643 100644
--- a/examples/cvodes/serial/cvsAdvDiff_bndL.c
+++ b/examples/cvodes/serial/cvsAdvDiff_bndL.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -65,7 +65,7 @@
    to the underlying 1-dimensional storage. 
    IJth(vdata,i,j) references the element in the vdata array for
    u at mesh point (i,j), where 1 <= i <= MX, 1 <= j <= MY.
-   The vdata array is obtained via the macro call vdata = NV_DATA_S(v),
+   The vdata array is obtained via the macro call vdata = N_VGetArrayPointer_Serial(v),
    where v is an N_Vector. 
    The variables are ordered by the y index j, then by the x index i. */
 
@@ -86,7 +86,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -197,8 +197,8 @@ static int f(realtype t, N_Vector u,N_Vector udot, void *user_data)
   int i, j;
   UserData data;
 
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Extract needed constants from data */
 
@@ -299,7 +299,7 @@ static void SetIC(N_Vector u, UserData data)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profile into u vector */
   
@@ -307,7 +307,7 @@ static void SetIC(N_Vector u, UserData data)
     y = j*dy;
     for (i=1; i <= MX; i++) {
       x = i*dx;
-      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*EXP(FIVE*x*y);
+      IJth(udata,i,j) = x*(XMAX - x)*y*(YMAX - y)*SUNRexp(FIVE*x*y);
     }
   }  
 }
@@ -390,7 +390,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsDirectDemo_ls.c b/examples/cvodes/serial/cvsDirectDemo_ls.c
index 3de9d66..923e032 100644
--- a/examples/cvodes/serial/cvsDirectDemo_ls.c
+++ b/examples/cvodes/serial/cvsDirectDemo_ls.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -30,22 +30,23 @@
  * called for each of the remaining seven runs.
  *
  * Notes: This program demonstrates the usage of the sequential
- * macros NV_Ith_S, NV_DATA_S, DENSE_ELEM, BAND_COL, and
+ * macros NV_Ith_S, DENSE_ELEM, BAND_COL, and
  * BAND_COL_ELEM. The NV_Ith_S macro is used to reference the
  * components of an N_Vector. It works for any size N=NEQ, but
  * due to efficiency concerns it should only by used when the
  * problem size is small. The Problem 1 right hand side and
- * Jacobian functions f1 and Jac1 both use NV_Ith_S. The NV_DATA_S
- * macro gives the user access to the memory used for the component
- * storage of an N_Vector. In the sequential case, the user may
- * assume that this is one contiguous array of reals. The NV_DATA_S
- * macro gives a more efficient means (than the NV_Ith_S macro) to
+ * Jacobian functions f1 and Jac1 both use NV_Ith_S. The 
+ * N_VGetArrayPointer_Serial function gives the user access to the 
+ * memory used for the component storage of an N_Vector. In the 
+ * sequential case, the user may assume that this is one contiguous 
+ * array of reals. The N_VGetArrayPointer_Serial function
+ * gives a more efficient means (than the NV_Ith_S macro) to
  * access the components of an N_Vector and should be used when the
  * problem size is large. The Problem 2 right hand side function f2
- * uses the NV_DATA_S macro. The DENSE_ELEM macro used in Jac1
- * gives access to an element of a dense matrix of type DlsMat.
- * It should be used only when the problem size is small (the size
- * of a DlsMat is NEQ x NEQ) due to efficiency concerns. For
+ * uses the N_VGetArrayPointer_Serial function. The DENSE_ELEM macro 
+ * used in Jac1 gives access to an element of a dense matrix of type 
+ * DlsMat. It should be used only when the problem size is small (the 
+ * size of a DlsMat is NEQ x NEQ) due to efficiency concerns. For
  * larger problem sizes, the macro DENSE_COL can be used in order
  * to work directly with a column of a DlsMat. The BAND_COL and
  * BAND_COL_ELEM allow efficient columnwise access to the elements
@@ -64,7 +65,7 @@
 #include <cvodes/cvodes_diag.h>        /* use CVDIAG linear solver */
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS, SQR, and EXP*/
+#include <sundials/sundials_math.h>  /* contains the macros ABS, SUNSQR, and EXP*/
 
 /* Shared Problem Constants */
 
@@ -137,7 +138,7 @@ static int Jac2(long int N, long int mu, long int ml,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Implementation */
 
@@ -208,7 +209,7 @@ static int Problem1(void)
         break;
       }
       if (iout%2 == 0) {
-        er = ABS(NV_Ith_S(y,0)) / abstol;
+        er = SUNRabs(NV_Ith_S(y,0)) / abstol;
         if (er > ero) ero = er;
         if (er > P1_TOL_FACTOR) {
           nerr++;
@@ -261,7 +262,7 @@ static int Problem1(void)
         break;
       }
       if (iout%2 == 0) {
-        er = ABS(NV_Ith_S(y,0)) / abstol;
+        er = SUNRabs(NV_Ith_S(y,0)) / abstol;
         if (er > ero) ero = er;
         if (er > P1_TOL_FACTOR) {
           nerr++;
@@ -289,7 +290,7 @@ static void PrintIntro1(void)
   printf(" neq = %d,  reltol = %.2Lg,  abstol = %.2Lg",
 	 P1_NEQ, RTOL, ATOL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf(" neq = %d,  reltol = %.2lg,  abstol = %.2lg",
+  printf(" neq = %d,  reltol = %.2g,  abstol = %.2g",
 	 P1_NEQ, RTOL, ATOL);
 #else
   printf(" neq = %d,  reltol = %.2g,  abstol = %.2g",
@@ -309,7 +310,7 @@ static void PrintOutput1(realtype t, realtype y0, realtype y1, int qu, realtype
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%10.5Lf    %12.5Le   %12.5Le   %2d    %6.4Le\n", t, y0, y1, qu, hu);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%10.5f    %12.5le   %12.5le   %2d    %6.4le\n", t, y0, y1, qu, hu);
+  printf("%10.5f    %12.5e   %12.5e   %2d    %6.4e\n", t, y0, y1, qu, hu);
 #else
   printf("%10.5f    %12.5e   %12.5e   %2d    %6.4e\n", t, y0, y1, qu, hu);
 #endif
@@ -325,7 +326,7 @@ static int f1(realtype t, N_Vector y, N_Vector ydot, void *user_data)
   y1 = NV_Ith_S(y,1);
 
   NV_Ith_S(ydot,0) = y1;
-  NV_Ith_S(ydot,1) = (ONE - SQR(y0))* P1_ETA * y1 - y0;
+  NV_Ith_S(ydot,1) = (ONE - SUNSQR(y0))* P1_ETA * y1 - y0;
 
   return(0);
 } 
@@ -342,7 +343,7 @@ static int Jac1(long int N, realtype tn,
 
   DENSE_ELEM(J,0,1) = ONE;
   DENSE_ELEM(J,1,0) = -TWO * P1_ETA * y0 * y1 - ONE;
-  DENSE_ELEM(J,1,1) = P1_ETA * (ONE - SQR(y0));
+  DENSE_ELEM(J,1,1) = P1_ETA * (ONE - SUNSQR(y0));
 
   return(0);
 }
@@ -485,7 +486,7 @@ static void PrintIntro2(void)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf(" itol = %s, reltol = %.2Lg, abstol = %.2Lg", "CV_SS", RTOL, ATOL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf(" itol = %s, reltol = %.2lg, abstol = %.2lg", "CV_SS", RTOL, ATOL);
+  printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL);
 #else
   printf(" itol = %s, reltol = %.2g, abstol = %.2g", "CV_SS", RTOL, ATOL);
 #endif
@@ -504,7 +505,7 @@ static void PrintOutput2(realtype t, realtype erm, int qu, realtype hu)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%10.3Lf  %12.4Le   %2d   %12.4Le\n", t, erm, qu, hu);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%10.3f  %12.4le   %2d   %12.4le\n", t, erm, qu, hu);
+  printf("%10.3f  %12.4e   %2d   %12.4e\n", t, erm, qu, hu);
 #else
   printf("%10.3f  %12.4e   %2d   %12.4e\n", t, erm, qu, hu);
 #endif
@@ -517,8 +518,8 @@ static int f2(realtype t, N_Vector y, N_Vector ydot, void *user_data)
   long int i, j, k;
   realtype d, *ydata, *dydata;
   
-  ydata = NV_DATA_S(y);
-  dydata = NV_DATA_S(ydot);
+  ydata = N_VGetArrayPointer_Serial(y);
+  dydata = N_VGetArrayPointer_Serial(ydot);
 
   /*
      Excluding boundaries, 
@@ -584,15 +585,15 @@ static realtype MaxError(N_Vector y, realtype t)
   
   if (t == ZERO) return(ZERO);
 
-  ydata = NV_DATA_S(y);
-  if (t <= THIRTY) ex = EXP(-TWO*t); 
+  ydata = N_VGetArrayPointer_Serial(y);
+  if (t <= THIRTY) ex = SUNRexp(-TWO*t);
   
   for (j = 0; j < P2_MESHY; j++) {
     ifact_inv = ONE;
     for (i = 0; i < P2_MESHX; i++) {
       k = i + j * P2_MESHX;
-      yt = RPowerI(t,i+j) * ex * ifact_inv * jfact_inv;
-      er = ABS(ydata[k] - yt);
+      yt = SUNRpowerI(t,i+j) * ex * ifact_inv * jfact_inv;
+      er = SUNRabs(ydata[k] - yt);
       if (er > maxError) maxError = er;
       ifact_inv /= (i+1);
     }
@@ -664,7 +665,7 @@ static void PrintErrOutput(realtype tol_factor)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("\n\n Error exceeds %Lg * tolerance \n\n", tol_factor);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("\n\n Error exceeds %lg * tolerance \n\n", tol_factor);
+  printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor);
 #else
   printf("\n\n Error exceeds %g * tolerance \n\n", tol_factor);
 #endif
@@ -761,7 +762,7 @@ static void PrintErrInfo(int nerr)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsDiurnal_FSA_kry.c b/examples/cvodes/serial/cvsDiurnal_FSA_kry.c
index 1a4195d..c6b620c 100644
--- a/examples/cvodes/serial/cvsDiurnal_FSA_kry.c
+++ b/examples/cvodes/serial/cvsDiurnal_FSA_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen and Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -54,10 +54,10 @@
 
 #include <cvodes/cvodes.h>            /* main CVODES header file */
 #include <cvodes/cvodes_spgmr.h>      /* use CVSPGMR linear */
-#include <nvector/nvector_serial.h>   /* definitions N_Vector, macro NV_DATA_S */
+#include <nvector/nvector_serial.h>   /* definitions N_Vector */
 #include <sundials/sundials_dense.h>  /* use generic DENSE solver for prec. */
 #include <sundials/sundials_types.h>  /* definition of realtype */
-#include <sundials/sundials_math.h>   /* contains macros SQR and EXP */
+#include <sundials/sundials_math.h>   /* contains macros SUNSQR and EXP */
 
 /* Problem Constants */
 
@@ -108,7 +108,7 @@
    IJKth(vdata,i,j,k) references the element in the vdata array for
    species i at mesh point (j,k), where 1 <= i <= NUM_SPECIES,
    0 <= j <= MX-1, 0 <= k <= MZ-1. The vdata array is obtained via
-   the macro call vdata = NV_DATA_S(v), where v is an N_Vector. 
+   the macro call vdata = N_VGetArrayPointer_Serial(v), where v is an N_Vector. 
    For each mesh point (j,k), the elements for species i and i+1 are
    contiguous within vdata.
 
@@ -157,7 +157,7 @@ static void SetInitialProfiles(N_Vector y, realtype dx, realtype dz);
 static void PrintOutput(void *cvode_mem, realtype t, N_Vector y);
 static void PrintOutputS(N_Vector *uS);
 static void PrintFinalStats(void *cvode_mem, booleantype sensi);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -334,8 +334,8 @@ static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
   realtype Q1, Q2, C3, A3, A4, KH, VEL, KV0;
 
   data = (UserData) user_data;
-  ydata = NV_DATA_S(y);
-  dydata = NV_DATA_S(ydot);
+  ydata = N_VGetArrayPointer_Serial(y);
+  dydata = N_VGetArrayPointer_Serial(ydot);
 
   /* Load problem coefficients and parameters */
 
@@ -352,8 +352,8 @@ static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    data->q4 = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
     q3 = ZERO;
     data->q4 = ZERO;
@@ -375,8 +375,8 @@ static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
 
     zdn = ZMIN + (jz - RCONST(0.5))*delz;
     zup = zdn + delz;
-    czdn = verdco*EXP(RCONST(0.2)*zdn);
-    czup = verdco*EXP(RCONST(0.2)*zup);
+    czdn = verdco*SUNRexp(RCONST(0.2)*zdn);
+    czup = verdco*SUNRexp(RCONST(0.2)*zup);
     idn = (jz == 0) ? 1 : -1;
     iup = (jz == MZ-1) ? -1 : 1;
     for (jx=0; jx < MX; jx++) {
@@ -445,7 +445,7 @@ static int Precond(realtype tn, N_Vector y, N_Vector fy, booleantype jok,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  ydata = NV_DATA_S(y);
+  ydata = N_VGetArrayPointer_Serial(y);
 
   /* Load problem coefficients and parameters */
   Q1 = data->p[0];
@@ -485,8 +485,8 @@ static int Precond(realtype tn, N_Vector y, N_Vector fy, booleantype jok,
     for (jz=0; jz < MZ; jz++) {
       zdn = ZMIN + (jz - RCONST(0.5))*delz;
       zup = zdn + delz;
-      czdn = verdco*EXP(RCONST(0.2)*zdn);
-      czup = verdco*EXP(RCONST(0.2)*zup);
+      czdn = verdco*SUNRexp(RCONST(0.2)*zdn);
+      czup = verdco*SUNRexp(RCONST(0.2)*zup);
       diag = -(czdn + czup + RCONST(2.0)*hordco);
       for (jx=0; jx < MX; jx++) {
         c1 = IJKth(ydata,1,jx,jz);
@@ -544,7 +544,7 @@ static int PSolve(realtype tn, N_Vector y, N_Vector fy,
   data = (UserData) user_data;
   P = data->P;
   pivot = data->pivot;
-  zdata = NV_DATA_S(z);
+  zdata = N_VGetArrayPointer_Serial(z);
 
   N_VScale(ONE, r, z);
 
@@ -665,9 +665,9 @@ static void InitUserData(UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/(MX-1);
   data->dz = (ZMAX-ZMIN)/(MZ-1);
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(RCONST(2.0)*data->dx);
-  data->vdco = (ONE/SQR(data->dz))*KV0;
+  data->vdco = (ONE/SUNSQR(data->dz))*KV0;
 
   data->p[0] = Q1;
   data->p[1] = Q2;
@@ -712,18 +712,18 @@ static void SetInitialProfiles(N_Vector y, realtype dx, realtype dz)
 
   /* Set pointer to data array in vector y. */
 
-  ydata = NV_DATA_S(y);
+  ydata = N_VGetArrayPointer_Serial(y);
 
   /* Load initial profiles of c1 and c2 into y vector */
 
   for (jz=0; jz < MZ; jz++) {
     z = ZMIN + jz*dz;
-    cz = SQR(RCONST(0.1)*(z - ZMID));
-    cz = ONE - cz + RCONST(0.5)*SQR(cz);
+    cz = SUNSQR(RCONST(0.1)*(z - ZMID));
+    cz = ONE - cz + RCONST(0.5)*SUNSQR(cz);
     for (jx=0; jx < MX; jx++) {
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - XMID));
-      cx = ONE - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - XMID));
+      cx = ONE - cx + RCONST(0.5)*SUNSQR(cx);
       IJKth(ydata,1,jx,jz) = C1_SCALE*cx*cz; 
       IJKth(ydata,2,jx,jz) = C2_SCALE*cx*cz;
     }
@@ -741,7 +741,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector y)
   realtype hu;
   realtype *ydata;
 
-  ydata = NV_DATA_S(y);
+  ydata = N_VGetArrayPointer_Serial(y);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -753,7 +753,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector y)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%8.3Le %2d  %8.3Le %5ld\n", t,qu,hu,nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%8.3le %2d  %8.3le %5ld\n", t,qu,hu,nst);
+  printf("%8.3e %2d  %8.3e %5ld\n", t,qu,hu,nst);
 #else
   printf("%8.3e %2d  %8.3e %5ld\n", t,qu,hu,nst);
 #endif
@@ -762,7 +762,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector y)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le \n", IJKth(ydata,1,0,0), IJKth(ydata,1,MX-1,MZ-1)); 
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le \n", IJKth(ydata,1,0,0), IJKth(ydata,1,MX-1,MZ-1)); 
+  printf("%12.4e %12.4e \n", IJKth(ydata,1,0,0), IJKth(ydata,1,MX-1,MZ-1)); 
 #else
   printf("%12.4e %12.4e \n", IJKth(ydata,1,0,0), IJKth(ydata,1,MX-1,MZ-1)); 
 #endif
@@ -770,7 +770,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector y)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le \n", IJKth(ydata,2,0,0), IJKth(ydata,2,MX-1,MZ-1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le \n", IJKth(ydata,2,0,0), IJKth(ydata,2,MX-1,MZ-1));
+  printf("%12.4e %12.4e \n", IJKth(ydata,2,0,0), IJKth(ydata,2,MX-1,MZ-1));
 #else
   printf("%12.4e %12.4e \n", IJKth(ydata,2,0,0), IJKth(ydata,2,MX-1,MZ-1));
 #endif
@@ -784,14 +784,14 @@ static void PrintOutputS(N_Vector *uS)
 {
   realtype *sdata;
 
-  sdata = NV_DATA_S(uS[0]);
+  sdata = N_VGetArrayPointer_Serial(uS[0]);
 
   printf("                                ----------------------------------------\n"); 
   printf("                                Sensitivity 1  ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
+  printf("%12.4e %12.4e \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
 #else
   printf("%12.4e %12.4e \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
 #endif
@@ -799,19 +799,19 @@ static void PrintOutputS(N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
+  printf("%12.4e %12.4e \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
 #else
   printf("%12.4e %12.4e \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
 #endif
 
-  sdata = NV_DATA_S(uS[1]);
+  sdata = N_VGetArrayPointer_Serial(uS[1]);
 
   printf("                                ----------------------------------------\n"); 
   printf("                                Sensitivity 2  ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
+  printf("%12.4e %12.4e \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
 #else
   printf("%12.4e %12.4e \n", IJKth(sdata,1,0,0), IJKth(sdata,1,MX-1,MZ-1)); 
 #endif
@@ -819,7 +819,7 @@ static void PrintOutputS(N_Vector *uS)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
+  printf("%12.4e %12.4e \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
 #else
   printf("%12.4e %12.4e \n", IJKth(sdata,2,0,0), IJKth(sdata,2,MX-1,MZ-1));
 #endif
@@ -903,7 +903,7 @@ static void PrintFinalStats(void *cvode_mem, booleantype sensi)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsDiurnal_kry.c b/examples/cvodes/serial/cvsDiurnal_kry.c
index 60606b8..353f44d 100644
--- a/examples/cvodes/serial/cvsDiurnal_kry.c
+++ b/examples/cvodes/serial/cvsDiurnal_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4849 $
+ * $Date: 2016-08-03 16:00:06 -0700 (Wed, 03 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -41,7 +41,7 @@
 #include <nvector/nvector_serial.h>   /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_dense.h>  /* use generic DENSE solver in preconditioning */
 #include <sundials/sundials_types.h>  /* definition of realtype */
-#include <sundials/sundials_math.h>   /* contains the macros ABS, SQR, and EXP */
+#include <sundials/sundials_math.h>   /* contains the macros ABS, SUNSQR, and EXP */
 
 /* Problem Constants */
 
@@ -98,7 +98,7 @@
    IJKth(vdata,i,j,k) references the element in the vdata array for
    species i at mesh point (j,k), where 1 <= i <= NUM_SPECIES,
    0 <= j <= MX-1, 0 <= k <= MY-1. The vdata array is obtained via
-   the macro call vdata = NV_DATA_S(v), where v is an N_Vector. 
+   the macro call vdata = N_VGetArrayPointer_Serial(v), where v is an N_Vector. 
    For each mesh point (j,k), the elements for species i and i+1 are
    contiguous within vdata.
 
@@ -127,7 +127,7 @@ static void FreeUserData(UserData data);
 static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy);
 static void PrintOutput(void *cvode_mem, N_Vector u, realtype t);
 static void PrintFinalStats(void *cvode_mem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -205,10 +205,6 @@ int main()
   flag = CVSpilsSetJacTimesVecFn(cvode_mem, jtv);
   if(check_flag(&flag, "CVSpilsSetJacTimesVecFn", 1)) return(1);
 
-  /* Set modified Gram-Schmidt orthogonalization */
-  flag = CVSpilsSetGSType(cvode_mem, MODIFIED_GS);
-  if(check_flag(&flag, "CVSpilsSetGSType", 1)) return(1);
-
   /* Set the preconditioner solve and setup functions */
   flag = CVSpilsSetPreconditioner(cvode_mem, Precond, PSolve);
   if(check_flag(&flag, "CVSpilsSetPreconditioner", 1)) return(1);
@@ -264,9 +260,9 @@ static void InitUserData(UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/(MX-1);
   data->dy = (YMAX-YMIN)/(MY-1);
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(TWO*data->dx);
-  data->vdco = (ONE/SQR(data->dy))*KV0;
+  data->vdco = (ONE/SUNSQR(data->dy))*KV0;
 }
 
 /* Free data memory */
@@ -296,18 +292,18 @@ static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profiles of c1 and c2 into u vector */
 
   for (jy=0; jy < MY; jy++) {
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - YMID));
-    cy = ONE - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - YMID));
+    cy = ONE - cy + RCONST(0.5)*SUNSQR(cy);
     for (jx=0; jx < MX; jx++) {
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - XMID));
-      cx = ONE - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - XMID));
+      cx = ONE - cx + RCONST(0.5)*SUNSQR(cx);
       IJKth(udata,1,jx,jy) = C1_SCALE*cx*cy; 
       IJKth(udata,2,jx,jy) = C2_SCALE*cx*cy;
     }
@@ -323,7 +319,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   realtype hu, *udata;
   int mxh = MX/2 - 1, myh = MY/2 - 1, mx1 = MX - 1, my1 = MY - 1;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -340,11 +336,11 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   printf("c2 (bot.left/middle/top rt.) = %12.3Le  %12.3Le  %12.3Le\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+  printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
          t, nst, qu, hu);
-  printf("c1 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n",
+  printf("c1 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n",
          IJKth(udata,1,0,0), IJKth(udata,1,mxh,myh), IJKth(udata,1,mx1,my1));
-  printf("c2 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n\n",
+  printf("c2 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #else
   printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
@@ -413,7 +409,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
@@ -459,15 +455,15 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   UserData data;
 
   data = (UserData) user_data;
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    data->q4 = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
       q3 = ZERO;
       data->q4 = ZERO;
@@ -489,8 +485,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
     for (jx=0; jx < MX; jx++) {
@@ -557,15 +553,15 @@ static int jtv(N_Vector v, N_Vector Jv, realtype t,
 
   data = (UserData) user_data;
 
-  udata = NV_DATA_S(u);
-  vdata = NV_DATA_S(v);
-  Jvdata = NV_DATA_S(Jv);
+  udata = N_VGetArrayPointer_Serial(u);
+  vdata = N_VGetArrayPointer_Serial(v);
+  Jvdata = N_VGetArrayPointer_Serial(Jv);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    data->q4 = EXP(-A4/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
     data->q4 = ZERO;
   }
@@ -587,8 +583,8 @@ static int jtv(N_Vector v, N_Vector Jv, realtype t,
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
 
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
 
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
@@ -631,38 +627,48 @@ static int jtv(N_Vector v, N_Vector Jv, realtype t,
 
       /* Set kinetic rate terms. */
 
-      //rkin1 = -Q1*C3 * c1 - Q2 * c1*c2 + q4coef * c2  + TWO*C3*q3;
-      //rkin2 =  Q1*C3 * c1 - Q2 * c1*c2 - q4coef * c2;
+      /* 
+	 rkin1 = -Q1*C3 * c1 - Q2 * c1*c2 + q4coef * c2  + TWO*C3*q3;
+	 rkin2 =  Q1*C3 * c1 - Q2 * c1*c2 - q4coef * c2;
+      */
 
       Jv1 += -(Q1*C3 + Q2*c2) * v1  +  (q4coef - Q2*c1) * v2;
       Jv2 +=  (Q1*C3 - Q2*c2) * v1  -  (q4coef + Q2*c1) * v2;
 
       /* Set vertical diffusion terms. */
 
-      //vertd1 = -(cyup+cydn) * c1 + cyup * c1up + cydn * c1dn;
-      //vertd2 = -(cyup+cydn) * c2 + cyup * c2up + cydn * c2dn;
+      /* 
+	 vertd1 = -(cyup+cydn) * c1 + cyup * c1up + cydn * c1dn;
+	 vertd2 = -(cyup+cydn) * c2 + cyup * c2up + cydn * c2dn;
+      */
 
       Jv1 += -(cyup+cydn) * v1  +  cyup * v1up  +  cydn * v1dn;
       Jv2 += -(cyup+cydn) * v2  +  cyup * v2up  +  cydn * v2dn;
 
       /* Set horizontal diffusion and advection terms. */
 
-      //hord1 = hordco*(c1rt - TWO*c1 + c1lt);
-      //hord2 = hordco*(c2rt - TWO*c2 + c2lt);
+      /* 
+	 hord1 = hordco*(c1rt - TWO*c1 + c1lt);
+	 hord2 = hordco*(c2rt - TWO*c2 + c2lt);
+      */
 
       Jv1 += hordco*(v1rt - TWO*v1 + v1lt);
       Jv2 += hordco*(v2rt - TWO*v2 + v2lt);
 
-      //horad1 = horaco*(c1rt - c1lt);
-      //horad2 = horaco*(c2rt - c2lt);
+      /* 
+	 horad1 = horaco*(c1rt - c1lt);
+	 horad2 = horaco*(c2rt - c2lt);
+      */
 
       Jv1 += horaco*(v1rt - v1lt);
       Jv2 += horaco*(v2rt - v2lt);
 
       /* Load two components of J*v */
 
-      //IJKth(dudata, 1, jx, jy) = vertd1 + hord1 + horad1 + rkin1; 
-      //IJKth(dudata, 2, jx, jy) = vertd2 + hord2 + horad2 + rkin2;
+      /* 
+	 IJKth(dudata, 1, jx, jy) = vertd1 + hord1 + horad1 + rkin1; 
+	 IJKth(dudata, 2, jx, jy) = vertd2 + hord2 + horad2 + rkin2;
+      */
 
       IJKth(Jvdata, 1, jx, jy) = Jv1;
       IJKth(Jvdata, 2, jx, jy) = Jv2;
@@ -696,7 +702,7 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
   
   if (jok) {
     
@@ -726,8 +732,8 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
     for (jy=0; jy < MY; jy++) {
       ydn = YMIN + (jy - RCONST(0.5))*dely;
       yup = ydn + dely;
-      cydn = verdco*EXP(RCONST(0.2)*ydn);
-      cyup = verdco*EXP(RCONST(0.2)*yup);
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
       diag = -(cydn + cyup + TWO*hordco);
       for (jx=0; jx < MX; jx++) {
         c1 = IJKth(udata,1,jx,jy);
@@ -783,7 +789,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
   data = (UserData) user_data;
   P = data->P;
   pivot = data->pivot;
-  zdata = NV_DATA_S(z);
+  zdata = N_VGetArrayPointer_Serial(z);
   
   N_VScale(ONE, r, z);
   
diff --git a/examples/cvodes/serial/cvsDiurnal_kry_bp.c b/examples/cvodes/serial/cvsDiurnal_kry_bp.c
index 77fcec4..f7058f3 100644
--- a/examples/cvodes/serial/cvsDiurnal_kry_bp.c
+++ b/examples/cvodes/serial/cvsDiurnal_kry_bp.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @LLNL
@@ -40,7 +40,7 @@
 #include <cvodes/cvodes_bandpre.h>   /* prototypes & constants for CVBANDPRE module */
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS, SQR, and EXP */
+#include <sundials/sundials_math.h>  /* contains the macros ABS, SUNSQR, and EXP */
 
 /* Problem Constants */
 
@@ -97,7 +97,7 @@
    IJKth(vdata,i,j,k) references the element in the vdata array for
    species i at mesh point (j,k), where 1 <= i <= NUM_SPECIES,
    0 <= j <= MX-1, 0 <= k <= MY-1. The vdata array is obtained via
-   the macro call vdata = NV_DATA_S(v), where v is an N_Vector. 
+   the macro call vdata = N_VGetArrayPointer_Serial(v), where v is an N_Vector. 
    For each mesh point (j,k), the elements for species i and i+1 are
    contiguous within vdata.
 
@@ -125,7 +125,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t);
 static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Function Called by the Solver */
 
@@ -253,9 +253,9 @@ static void InitUserData(UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/(MX-1);
   data->dy = (YMAX-YMIN)/(MY-1);
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(TWO*data->dx);
-  data->vdco = (ONE/SQR(data->dy))*KV0;
+  data->vdco = (ONE/SUNSQR(data->dy))*KV0;
 }
 
 /* Set initial conditions in u */
@@ -268,18 +268,18 @@ static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profiles of c1 and c2 into u vector */
 
   for (jy = 0; jy < MY; jy++) {
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - YMID));
-    cy = ONE - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - YMID));
+    cy = ONE - cy + RCONST(0.5)*SUNSQR(cy);
     for (jx = 0; jx < MX; jx++) {
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - XMID));
-      cx = ONE - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - XMID));
+      cx = ONE - cx + RCONST(0.5)*SUNSQR(cx);
       IJKth(udata,1,jx,jy) = C1_SCALE*cx*cy; 
       IJKth(udata,2,jx,jy) = C2_SCALE*cx*cy;
     }
@@ -290,7 +290,7 @@ static void PrintIntro(long int mu, long int ml)
 {
   printf("2-species diurnal advection-diffusion problem, %d by %d mesh\n",
          MX, MY);
-  printf("SPGMR solver; band preconditioner; mu = %d, ml = %d\n\n",
+  printf("SPGMR solver; band preconditioner; mu = %ld, ml = %ld\n\n",
          mu, ml);
 
   return;
@@ -305,7 +305,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u,realtype t)
   realtype hu, *udata;
   int mxh = MX/2 - 1, myh = MY/2 - 1, mx1 = MX - 1, my1 = MY - 1;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -322,11 +322,11 @@ static void PrintOutput(void *cvode_mem, N_Vector u,realtype t)
   printf("c2 (bot.left/middle/top rt.) = %12.3Le  %12.3Le  %12.3Le\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+  printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
          t, nst, qu, hu);
-  printf("c1 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n",
+  printf("c1 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n",
          IJKth(udata,1,0,0), IJKth(udata,1,mxh,myh), IJKth(udata,1,mx1,my1));
-  printf("c2 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n\n",
+  printf("c2 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #else
   printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
@@ -404,7 +404,7 @@ static void PrintFinalStats(void *cvode_mem)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
@@ -450,15 +450,15 @@ static int f(realtype t, N_Vector u, N_Vector udot,void *user_data)
   UserData data;
 
   data = (UserData) user_data;
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    data->q4 = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
     q3 = ZERO;
     data->q4 = ZERO;
@@ -480,8 +480,8 @@ static int f(realtype t, N_Vector u, N_Vector udot,void *user_data)
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
     for (jx = 0; jx < MX; jx++) {
diff --git a/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c b/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c
index b665d1c..b371559 100644
--- a/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c
+++ b/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2011/11/23 23:53:02 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -208,7 +208,7 @@ static void fblock (realtype t, realtype cdata[], int jx, int jy, realtype cdotd
                     WebData wdata);
 static void GSIter(realtype gamma, N_Vector z, N_Vector x, WebData wdata);
 static realtype doubleIntgr(N_Vector c, int i, WebData wdata);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Small Vector Kernels */
 
@@ -257,7 +257,7 @@ int main(int argc, char *argv[])
   CInit(c, wdata);
 
   /* Call CVodeCreate/CVodeInit for forward run */
-  printf("\nCreate and allocate CVODE memory for forward run\n");
+  printf("\nCreate and allocate CVODES memory for forward run\n");
   cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
   if(check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
   wdata->cvode_mem = cvode_mem; /* Used in Precond */
@@ -291,10 +291,10 @@ int main(int argc, char *argv[])
 
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("\n   G = int_t int_x int_y c%d(t,x,y) dx dy dt = %Lf \n\n", 
-         ISPEC, NV_DATA_S(c)[NEQ]);
+         ISPEC, N_VGetArrayPointer_Serial(c)[NEQ]);
 #else
   printf("\n   G = int_t int_x int_y c%d(t,x,y) dx dy dt = %f \n\n", 
-         ISPEC, NV_DATA_S(c)[NEQ]);
+         ISPEC, N_VGetArrayPointer_Serial(c)[NEQ]);
 #endif
 
   /* Set-up backward problem */
@@ -368,8 +368,8 @@ static int f(realtype t, N_Vector c, N_Vector cdot, void *user_data)
   WebData wdata;
   
   wdata = (WebData) user_data;
-  cdata = NV_DATA_S(c);
-  cdotdata = NV_DATA_S(cdot);
+  cdata = N_VGetArrayPointer_Serial(c);
+  cdotdata = N_VGetArrayPointer_Serial(cdot);
   
   mxns = wdata->mxns;
   ns = wdata->ns;
@@ -451,8 +451,8 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
   flag = CVodeGetErrWeights(cvode_mem, rewt);
   if(check_flag(&flag, "CVodeGetErrWeights", 1)) return(1);
 
-  cdata = NV_DATA_S(c);
-  rewtdata = NV_DATA_S(rewt);
+  cdata = N_VGetArrayPointer_Serial(c);
+  rewtdata = N_VGetArrayPointer_Serial(rewt);
 
   uround = UNIT_ROUNDOFF;
 
@@ -472,11 +472,11 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
      Here, fsave contains the base value of the rate vector and 
      r0 is a minimum increment factor for the difference quotient. */
 
-  f1 = NV_DATA_S(vtemp1);
+  f1 = N_VGetArrayPointer_Serial(vtemp1);
 
   fac = N_VWrmsNorm (fc, rewt);
   N = NEQ+1;
-  r0 = RCONST(1000.0)*ABS(gamma)*uround*N*fac;
+  r0 = RCONST(1000.0)*SUNRabs(gamma)*uround*N*fac;
   if (r0 == ZERO) r0 = ONE;
 
   for (igy = 0; igy < ngy; igy++) {
@@ -491,7 +491,7 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
         /* Generate the jth column as a difference quotient */
         jj = if0 + j; 
         save = cdata[jj];
-        r = MAX(srur*ABS(save),r0/rewtdata[jj]);
+        r = SUNMAX(srur*SUNRabs(save),r0/rewtdata[jj]);
         cdata[jj] += r;
         fac = -gamma/r;
         fblock (t, cdata, jx, jy, f1, wdata);
@@ -562,13 +562,13 @@ static int PSolve(realtype t, N_Vector c, N_Vector fc,
     for (jx = 0; jx < mx; jx++) {
       igx = jigx[jx];
       ig = igx + igy*ngx;
-      denseGETRS(P[ig], mp, pivot[ig], &(NV_DATA_S(z)[iv]));
+      denseGETRS(P[ig], mp, pivot[ig], &(N_VGetArrayPointer_Serial(z)[iv]));
       iv += mp;
     }
   }
 
   /* Solve for the quadrature variable */
-  NV_DATA_S(z)[NEQ] = NV_DATA_S(r)[NEQ] + gamma*doubleIntgr(z,ISPEC,wdata);
+  N_VGetArrayPointer_Serial(z)[NEQ] = N_VGetArrayPointer_Serial(r)[NEQ] + gamma*doubleIntgr(z,ISPEC,wdata);
 
   return(0);
 }
@@ -591,9 +591,9 @@ static int fB(realtype t, N_Vector c, N_Vector cB,
   realtype gu[NS];
 
   wdata = (WebData) user_data;
-  cdata = NV_DATA_S(c);
-  cBdata = NV_DATA_S(cB);
-  cBdotdata = NV_DATA_S(cBdot);
+  cdata = N_VGetArrayPointer_Serial(c);
+  cBdata = N_VGetArrayPointer_Serial(cB);
+  cBdotdata = N_VGetArrayPointer_Serial(cBdot);
 
   mxns = wdata->mxns;
   ns = wdata->ns;
@@ -669,8 +669,8 @@ static int PrecondB(realtype t, N_Vector c,
   flag = CVodeGetErrWeights(cvode_mem, rewt);
   if(check_flag(&flag, "CVodeGetErrWeights", 1)) return(1);
 
-  cdata = NV_DATA_S(c);
-  rewtdata = NV_DATA_S(rewt);
+  cdata = N_VGetArrayPointer_Serial(c);
+  rewtdata = N_VGetArrayPointer_Serial(rewt);
 
   uround = UNIT_ROUNDOFF;
 
@@ -690,10 +690,10 @@ static int PrecondB(realtype t, N_Vector c,
      Here, fsave contains the base value of the rate vector and 
      r0 is a minimum increment factor for the difference quotient. */
 
-  f1 = NV_DATA_S(vtemp1);
+  f1 = N_VGetArrayPointer_Serial(vtemp1);
   fac = N_VWrmsNorm (fcB, rewt);
   N = NEQ;
-  r0 = RCONST(1000.0)*ABS(gamma)*uround*N*fac;
+  r0 = RCONST(1000.0)*SUNRabs(gamma)*uround*N*fac;
   if (r0 == ZERO) r0 = ONE;
 
   for (igy = 0; igy < ngy; igy++) {
@@ -708,7 +708,7 @@ static int PrecondB(realtype t, N_Vector c,
         /* Generate the jth column as a difference quotient */
         jj = if0 + j; 
         save = cdata[jj];
-        r = MAX(srur*ABS(save),r0/rewtdata[jj]);
+        r = SUNMAX(srur*SUNRabs(save),r0/rewtdata[jj]);
         cdata[jj] += r;
         fac = gamma/r;
         fblock (t, cdata, jx, jy, f1, wdata);
@@ -773,7 +773,7 @@ static int PSolveB(realtype t, N_Vector c,
     for (jx = 0; jx < mx; jx++) {
       igx = jigx[jx];
       ig = igx + igy*ngx;
-      denseGETRS(P[ig], mp, pivot[ig], &(NV_DATA_S(z)[iv]));
+      denseGETRS(P[ig], mp, pivot[ig], &(N_VGetArrayPointer_Serial(z)[iv]));
       iv += mp;
     }
   }
@@ -842,8 +842,8 @@ static void InitUserData(WebData wdata)
   dx = wdata->dx = DX;
   dy = wdata->dy = DY;
   for (i = 0; i < ns; i++) {
-    cox[i] = diff[i]/SQR(dx);
-    coy[i] = diff[i]/SQR(dy);
+    cox[i] = diff[i]/SUNSQR(dx);
+    coy[i] = diff[i]/SUNSQR(dy);
   }
 
   /* Set remaining method parameters */
@@ -852,7 +852,7 @@ static void InitUserData(WebData wdata)
   wdata->mq = MQ;
   wdata->mx = MX;
   wdata->my = MY;
-  wdata->srur = SQRT(UNIT_ROUNDOFF);
+  wdata->srur = SUNRsqrt(UNIT_ROUNDOFF);
   wdata->mxmp = MXMP;
   wdata->ngrp = NGRP;
   wdata->ngx = NGX;
@@ -899,21 +899,21 @@ static void CInit(N_Vector c, WebData wdata)
   int i, ici, ioff, iyoff, jx, jy, ns, mxns;
   realtype argx, argy, x, y, dx, dy, x_factor, y_factor, *cdata;
   
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
   ns = wdata->ns;
   mxns = wdata->mxns;
   dx = wdata->dx;
   dy = wdata->dy;
   
-  x_factor = RCONST(4.0)/SQR(AX);
-  y_factor = RCONST(4.0)/SQR(AY);
+  x_factor = RCONST(4.0)/SUNSQR(AX);
+  y_factor = RCONST(4.0)/SUNSQR(AY);
   for (jy = 0; jy < MY; jy++) {
     y = jy*dy;
-    argy = SQR(y_factor*y*(AY-y)); 
+    argy = SUNSQR(y_factor*y*(AY-y));
     iyoff = mxns*jy;
     for (jx = 0; jx < MX; jx++) {
       x = jx*dx;
-      argx = SQR(x_factor*x*(AX-x));
+      argx = SUNSQR(x_factor*x*(AX-x));
       ioff = iyoff + ns*jx;
       for (i = 1; i <= ns; i++) {
         ici = ioff + i-1;
@@ -1029,8 +1029,8 @@ static void GSIter(realtype gamma, N_Vector z, N_Vector x,
   realtype beta[NS], beta2[NS], cof1[NS], gam[NS], gam2[NS];
   realtype temp, *cox, *coy, *xd, *zd;
 
-  xd = NV_DATA_S(x);
-  zd = NV_DATA_S(z);
+  xd = N_VGetArrayPointer_Serial(x);
+  zd = N_VGetArrayPointer_Serial(z);
   ns = wdata->ns;
   mx = wdata->mx;
   my = wdata->my;
@@ -1211,7 +1211,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
 
   x = y = ZERO;
 
-  cdata = NV_DATA_S(cB);
+  cdata = N_VGetArrayPointer_Serial(cB);
 
   for (i=1; i <= ns; i++) {
 
@@ -1220,7 +1220,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
     for (jy=MY-1; jy >= 0; jy--) {
       for (jx=0; jx < MX; jx++) {
         cij = cdata[(i-1) + jx*ns + jy*mxns];
-        if (ABS(cij) > cmax) {
+        if (SUNRabs(cij) > cmax) {
           cmax = cij;
           x = jx * wdata->dx;
           y = jy * wdata->dy;
@@ -1232,7 +1232,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("  lambda max = %Le\n",cmax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("  lambda max = %le\n",cmax);
+    printf("  lambda max = %e\n",cmax);
 #else
     printf("  lambda max = %e\n",cmax);
 #endif
@@ -1240,7 +1240,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("  x = %Le\n  y = %Le\n", x, y);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("  x = %le\n  y = %le\n", x, y);
+    printf("  x = %e\n  y = %e\n", x, y);
 #else
     printf("  x = %e\n  y = %e\n", x, y);
 #endif
@@ -1261,7 +1261,7 @@ static realtype doubleIntgr(N_Vector c, int i, WebData wdata)
   realtype intgr_xy, intgr_x;
   int jx, jy;
 
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
 
   ns   = wdata->ns;
   mx   = wdata->mx;
@@ -1335,7 +1335,7 @@ static void FreeUserData(WebData wdata)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.out b/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.out
index 9855170..9d51c3e 100644
--- a/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.out
+++ b/examples/cvodes/serial/cvsFoodWeb_ASAi_kry.out
@@ -1,5 +1,5 @@
 
-Create and allocate CVODE memory for forward run
+Create and allocate CVODES memory for forward run
 
 Allocate global memory
 
diff --git a/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c b/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c
index a65c3e5..6d86f65 100644
--- a/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c
+++ b/examples/cvodes/serial/cvsFoodWeb_ASAp_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2011/11/23 23:53:02 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -202,7 +202,7 @@ static void fblock (realtype t, realtype cdata[], int jx, int jy, realtype cdotd
                     WebData wdata);
 static void GSIter(realtype gamma, N_Vector z, N_Vector x, WebData wdata);
 static realtype doubleIntgr(N_Vector c, int i, WebData wdata);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Small Vector Kernels */
 
@@ -359,8 +359,8 @@ static int f(realtype t, N_Vector c, N_Vector cdot, void *user_data)
   WebData wdata;
   
   wdata = (WebData) user_data;
-  cdata = NV_DATA_S(c);
-  cdotdata = NV_DATA_S(cdot);
+  cdata = N_VGetArrayPointer_Serial(c);
+  cdotdata = N_VGetArrayPointer_Serial(cdot);
   
   mxns = wdata->mxns;
   ns = wdata->ns;
@@ -436,8 +436,8 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
   flag = CVodeGetErrWeights(wdata->cvode_mem, rewt);
   if(check_flag(&flag, "CVodeGetErrWeights", 1)) return(1);
 
-  cdata = NV_DATA_S(c);
-  rewtdata = NV_DATA_S(rewt);
+  cdata = N_VGetArrayPointer_Serial(c);
+  rewtdata = N_VGetArrayPointer_Serial(rewt);
 
   uround = UNIT_ROUNDOFF;
 
@@ -457,10 +457,10 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
      Here, fsave contains the base value of the rate vector and 
      r0 is a minimum increment factor for the difference quotient. */
 
-  f1 = NV_DATA_S(vtemp1);
+  f1 = N_VGetArrayPointer_Serial(vtemp1);
 
   fac = N_VWrmsNorm (fc, rewt);
-  r0 = RCONST(1000.0)*ABS(gamma)*uround*NEQ*fac;
+  r0 = RCONST(1000.0)*SUNRabs(gamma)*uround*NEQ*fac;
   if (r0 == ZERO) r0 = ONE;
 
   for (igy = 0; igy < ngy; igy++) {
@@ -475,7 +475,7 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
         /* Generate the jth column as a difference quotient */
         jj = if0 + j; 
         save = cdata[jj];
-        r = MAX(srur*ABS(save),r0/rewtdata[jj]);
+        r = SUNMAX(srur*SUNRabs(save),r0/rewtdata[jj]);
         cdata[jj] += r;
         fac = -gamma/r;
         fblock (t, cdata, jx, jy, f1, wdata);
@@ -545,7 +545,7 @@ static int PSolve(realtype t, N_Vector c, N_Vector fc,
     for (jx = 0; jx < mx; jx++) {
       igx = jigx[jx];
       ig = igx + igy*ngx;
-      denseGETRS(P[ig], mp, pivot[ig], &(NV_DATA_S(z)[iv]));
+      denseGETRS(P[ig], mp, pivot[ig], &(N_VGetArrayPointer_Serial(z)[iv]));
       iv += mp;
     }
   }
@@ -569,9 +569,9 @@ static int fB(realtype t, N_Vector c, N_Vector cB,
   WebData wdata;
 
   wdata = (WebData) user_data;
-  cdata = NV_DATA_S(c);
-  cBdata = NV_DATA_S(cB);
-  cBdotdata = NV_DATA_S(cBdot);
+  cdata = N_VGetArrayPointer_Serial(c);
+  cBdata = N_VGetArrayPointer_Serial(cB);
+  cBdotdata = N_VGetArrayPointer_Serial(cBdot);
 
   mxns = wdata->mxns;
   ns = wdata->ns;
@@ -641,8 +641,8 @@ static int PrecondB(realtype t, N_Vector c,
   flag = CVodeGetErrWeights(cvode_mem, rewt);
   if(check_flag(&flag, "CVodeGetErrWeights", 1)) return(1);
 
-  cdata = NV_DATA_S(c);
-  rewtdata = NV_DATA_S(rewt);
+  cdata = N_VGetArrayPointer_Serial(c);
+  rewtdata = N_VGetArrayPointer_Serial(rewt);
 
   uround = UNIT_ROUNDOFF;
 
@@ -662,10 +662,10 @@ static int PrecondB(realtype t, N_Vector c,
      Here, fsave contains the base value of the rate vector and 
      r0 is a minimum increment factor for the difference quotient. */
 
-  f1 = NV_DATA_S(vtemp1);
+  f1 = N_VGetArrayPointer_Serial(vtemp1);
 
   fac = N_VWrmsNorm (fcB, rewt);
-  r0 = RCONST(1000.0)*ABS(gamma)*uround*NEQ*fac;
+  r0 = RCONST(1000.0)*SUNRabs(gamma)*uround*NEQ*fac;
   if (r0 == ZERO) r0 = ONE;
 
   for (igy = 0; igy < ngy; igy++) {
@@ -680,7 +680,7 @@ static int PrecondB(realtype t, N_Vector c,
         /* Generate the jth column as a difference quotient */
         jj = if0 + j; 
         save = cdata[jj];
-        r = MAX(srur*ABS(save),r0/rewtdata[jj]);
+        r = SUNMAX(srur*SUNRabs(save),r0/rewtdata[jj]);
         cdata[jj] += r;
         fac = gamma/r;
         fblock (t, cdata, jx, jy, f1, wdata);
@@ -745,7 +745,7 @@ static int PSolveB(realtype t, N_Vector c,
     for (jx = 0; jx < mx; jx++) {
       igx = jigx[jx];
       ig = igx + igy*ngx;
-      denseGETRS(P[ig], mp, pivot[ig], &(NV_DATA_S(z)[iv]));
+      denseGETRS(P[ig], mp, pivot[ig], &(N_VGetArrayPointer_Serial(z)[iv]));
       iv += mp;
     }
   }
@@ -815,8 +815,8 @@ static void InitUserData(WebData wdata)
   dx = wdata->dx = DX;
   dy = wdata->dy = DY;
   for (i = 0; i < ns; i++) {
-    cox[i] = diff[i]/SQR(dx);
-    coy[i] = diff[i]/SQR(dy);
+    cox[i] = diff[i]/SUNSQR(dx);
+    coy[i] = diff[i]/SUNSQR(dy);
   }
 
   /* Set remaining method parameters */
@@ -825,7 +825,7 @@ static void InitUserData(WebData wdata)
   wdata->mq = MQ;
   wdata->mx = MX;
   wdata->my = MY;
-  wdata->srur = SQRT(UNIT_ROUNDOFF);
+  wdata->srur = SUNRsqrt(UNIT_ROUNDOFF);
   wdata->mxmp = MXMP;
   wdata->ngrp = NGRP;
   wdata->ngx = NGX;
@@ -872,21 +872,21 @@ static void CInit(N_Vector c, WebData wdata)
   int i, ici, ioff, iyoff, jx, jy, ns, mxns;
   realtype argx, argy, x, y, dx, dy, x_factor, y_factor, *cdata;
   
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
   ns = wdata->ns;
   mxns = wdata->mxns;
   dx = wdata->dx;
   dy = wdata->dy;
   
-  x_factor = RCONST(4.0)/SQR(AX);
-  y_factor = RCONST(4.0)/SQR(AY);
+  x_factor = RCONST(4.0)/SUNSQR(AX);
+  y_factor = RCONST(4.0)/SUNSQR(AY);
   for (jy = 0; jy < MY; jy++) {
     y = jy*dy;
-    argy = SQR(y_factor*y*(AY-y)); 
+    argy = SUNSQR(y_factor*y*(AY-y));
     iyoff = mxns*jy;
     for (jx = 0; jx < MX; jx++) {
       x = jx*dx;
-      argx = SQR(x_factor*x*(AX-x));
+      argx = SUNSQR(x_factor*x*(AX-x));
       ioff = iyoff + ns*jx;
       for (i = 1; i <= ns; i++) {
         ici = ioff + i-1;
@@ -907,7 +907,7 @@ static void CbInit(N_Vector c, int is, WebData wdata)
 
   realtype gu[NS];
 
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
   ns = wdata->ns;
   mxns = wdata->mxns;
 
@@ -1025,8 +1025,8 @@ static void GSIter(realtype gamma, N_Vector z, N_Vector x, WebData wdata)
   realtype beta[NS], beta2[NS], cof1[NS], gam[NS], gam2[NS];
   realtype temp, *cox, *coy, *xd, *zd;
 
-  xd = NV_DATA_S(x);
-  zd = NV_DATA_S(z);
+  xd = N_VGetArrayPointer_Serial(x);
+  zd = N_VGetArrayPointer_Serial(z);
   ns = wdata->ns;
   mx = wdata->mx;
   my = wdata->my;
@@ -1207,7 +1207,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
 
   x = y = ZERO;
 
-  cdata = NV_DATA_S(cB);
+  cdata = N_VGetArrayPointer_Serial(cB);
 
   for (i=1; i <= ns; i++) {
 
@@ -1216,7 +1216,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
     for (jy=MY-1; jy >= 0; jy--) {
       for (jx=0; jx < MX; jx++) {
         cij = cdata[(i-1) + jx*ns + jy*mxns];
-        if (ABS(cij) > cmax) {
+        if (SUNRabs(cij) > cmax) {
           cmax = cij;
           x = jx * wdata->dx;
           y = jy * wdata->dy;
@@ -1228,7 +1228,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("  mu max = %Le\n",cmax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("  mu max = %le\n",cmax);
+    printf("  mu max = %e\n",cmax);
 #else
     printf("  mu max = %e\n",cmax);
 #endif
@@ -1236,7 +1236,7 @@ static void PrintOutput(N_Vector cB, int ns, int mxns, WebData wdata)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("  x = %Le\n  y = %Le\n", x, y);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("  x = %le\n  y = %le\n", x, y);
+    printf("  x = %e\n  y = %e\n", x, y);
 #else
     printf("  x = %e\n  y = %e\n", x, y);
 #endif
@@ -1257,7 +1257,7 @@ static realtype doubleIntgr(N_Vector c, int i, WebData wdata)
   realtype intgr_xy, intgr_x;
   int jx, jy;
 
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
 
   ns   = wdata->ns;
   mx   = wdata->mx;
@@ -1331,7 +1331,7 @@ static void FreeUserData(WebData wdata)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsHessian_ASA_FSA.c b/examples/cvodes/serial/cvsHessian_ASA_FSA.c
index 7145a4c..1372a2f 100644
--- a/examples/cvodes/serial/cvsHessian_ASA_FSA.c
+++ b/examples/cvodes/serial/cvsHessian_ASA_FSA.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4956 $
+ * $Date: 2016-09-23 11:15:59 -0700 (Fri, 23 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  *
  * Hessian through adjoint sensitivity example problem.
@@ -197,13 +202,13 @@ int main(int argc, char *argv[])
 
   printf("ncheck = %d\n", ncheck);
   printf("\n");
-  printf("     y:    %12.4le %12.4le %12.4le", Ith(y,1), Ith(y,2), Ith(y,3));
-  printf("     G:    %12.4le\n", Ith(yQ,1));
+  printf("     y:    %12.4e %12.4e %12.4e", Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("     G:    %12.4e\n", Ith(yQ,1));
   printf("\n");
-  printf("     yS1:  %12.4le %12.4le %12.4le\n", Ith(yS[0],1), Ith(yS[0],2), Ith(yS[0],3));
-  printf("     yS2:  %12.4le %12.4le %12.4le\n", Ith(yS[1],1), Ith(yS[1],2), Ith(yS[1],3));
+  printf("     yS1:  %12.4e %12.4e %12.4e\n", Ith(yS[0],1), Ith(yS[0],2), Ith(yS[0],3));
+  printf("     yS2:  %12.4e %12.4e %12.4e\n", Ith(yS[1],1), Ith(yS[1],2), Ith(yS[1],3));
   printf("\n");
-  printf("   dG/dp:  %12.4le %12.4le\n", Ith(yQS[0],1), Ith(yQS[1],1));
+  printf("   dG/dp:  %12.4e %12.4e\n", Ith(yQS[0],1), Ith(yQS[1],1));
   printf("\n");
 
   printf("Final Statistics for forward pb.\n");
@@ -220,7 +225,7 @@ int main(int argc, char *argv[])
   N_VConst(ZERO, yQB1);
 
   yB2 = N_VNew_Serial(2*Neq);
-  N_VConst(ZERO, yB1);
+  N_VConst(ZERO, yB2);
 
   yQB2 = N_VNew_Serial(Np2);
   N_VConst(ZERO, yQB2);
@@ -259,13 +264,13 @@ int main(int argc, char *argv[])
   flag = CVodeGetB(cvode_mem, indexB2, &time, yB2);
   flag = CVodeGetQuadB(cvode_mem, indexB2, &time, yQB2);
 
-  printf("   dG/dp:  %12.4le %12.4le   (from backward pb. 1)\n", -Ith(yQB1,1), -Ith(yQB1,2));
-  printf("           %12.4le %12.4le   (from backward pb. 2)\n", -Ith(yQB2,1), -Ith(yQB2,2));
+  printf("   dG/dp:  %12.4e %12.4e   (from backward pb. 1)\n", -Ith(yQB1,1), -Ith(yQB1,2));
+  printf("           %12.4e %12.4e   (from backward pb. 2)\n", -Ith(yQB2,1), -Ith(yQB2,2));
   printf("\n");
   printf("   H = d2G/dp2:\n");
   printf("        (1)            (2)\n");
-  printf("  %12.4le   %12.4le\n", -Ith(yQB1,3) , -Ith(yQB2,3));
-  printf("  %12.4le   %12.4le\n", -Ith(yQB1,4) , -Ith(yQB2,4));
+  printf("  %12.4e   %12.4e\n", -Ith(yQB1,3) , -Ith(yQB2,3));
+  printf("  %12.4e   %12.4e\n", -Ith(yQB1,4) , -Ith(yQB2,4));
   printf("\n");
 
   printf("Final Statistics for backward pb. 1\n");
@@ -307,8 +312,8 @@ int main(int argc, char *argv[])
   flag = CVode(cvode_mem, tf, y, &time, CV_NORMAL);
   flag = CVodeGetQuad(cvode_mem, &time, yQ);
   Gp = Ith(yQ,1);
-  printf("p1+  y:   %12.4le %12.4le %12.4le", Ith(y,1), Ith(y,2), Ith(y,3));
-  printf("     G:   %12.4le\n",Ith(yQ,1));
+  printf("p1+  y:   %12.4e %12.4e %12.4e", Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("     G:   %12.4e\n",Ith(yQ,1));
 
   data->p1 -= 2.0*dp;
 
@@ -319,8 +324,8 @@ int main(int argc, char *argv[])
   flag = CVode(cvode_mem, tf, y, &time, CV_NORMAL);
   flag = CVodeGetQuad(cvode_mem, &time, yQ);
   Gm = Ith(yQ,1);
-  printf("p1-  y:   %12.4le %12.4le %12.4le", Ith(y,1), Ith(y,2), Ith(y,3));
-  printf("     G:   %12.4le\n",Ith(yQ,1));
+  printf("p1-  y:   %12.4e %12.4e %12.4e", Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("     G:   %12.4e\n",Ith(yQ,1));
  
   data->p1 += dp;
 
@@ -338,8 +343,8 @@ int main(int argc, char *argv[])
   flag = CVode(cvode_mem, tf, y, &time, CV_NORMAL);
   flag = CVodeGetQuad(cvode_mem, &time, yQ);
   Gp = Ith(yQ,1);
-  printf("p2+  y:   %12.4le %12.4le %12.4le", Ith(y,1), Ith(y,2), Ith(y,3));
-  printf("     G:   %12.4le\n",Ith(yQ,1));
+  printf("p2+  y:   %12.4e %12.4e %12.4e", Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("     G:   %12.4e\n",Ith(yQ,1));
  
   data->p2 -= 2.0*dp;
 
@@ -350,8 +355,8 @@ int main(int argc, char *argv[])
   flag = CVode(cvode_mem, tf, y, &time, CV_NORMAL);
   flag = CVodeGetQuad(cvode_mem, &time, yQ);
   Gm = Ith(yQ,1);
-  printf("p2-  y:   %12.4le %12.4le %12.4le", Ith(y,1), Ith(y,2), Ith(y,3));
-  printf("     G:   %12.4le\n",Ith(yQ,1));
+  printf("p2-  y:   %12.4e %12.4e %12.4e", Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("     G:   %12.4e\n",Ith(yQ,1));
 
   data->p2 += dp;
 
@@ -362,12 +367,12 @@ int main(int argc, char *argv[])
 
   printf("\n");
 
-  printf("   dG/dp:  %12.4le %12.4le   (fwd FD)\n", grdG_fwd[0], grdG_fwd[1]);
-  printf("           %12.4le %12.4le   (bck FD)\n", grdG_bck[0], grdG_bck[1]);
-  printf("           %12.4le %12.4le   (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]);
+  printf("   dG/dp:  %12.4e %12.4e   (fwd FD)\n", grdG_fwd[0], grdG_fwd[1]);
+  printf("           %12.4e %12.4e   (bck FD)\n", grdG_bck[0], grdG_bck[1]);
+  printf("           %12.4e %12.4e   (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]);
   printf("\n");
-  printf("  H(1,1):  %12.4le\n", H11);
-  printf("  H(2,2):  %12.4le\n", H22);
+  printf("  H(1,1):  %12.4e\n", H11);
+  printf("  H(2,2):  %12.4e\n", H22);
 
 
   /* Free memory */
@@ -378,7 +383,7 @@ int main(int argc, char *argv[])
   N_VDestroy_Serial(yQ);
 
   N_VDestroyVectorArray_Serial(yS, Np);
-  N_VDestroyVectorArray_Serial(yQS, 1);
+  N_VDestroyVectorArray_Serial(yQS, Np);
 
   N_VDestroy_Serial(yB1);
   N_VDestroy_Serial(yQB1);
@@ -637,7 +642,7 @@ static int fB2(realtype t, N_Vector y, N_Vector *yS,
 
   Ith(yBdot,4) = 2.0*p1*y1 * m1     + l1 * 2.0*p1*s1              - s1;
   Ith(yBdot,5) = m2 + p2*p2*y3 * m3 + l3 * (2.0*p2*y3 + p2*p2*s3) - s2;
-  Ith(yBdot,6) = m1 + p2*p2*y2 * m3 + l3 * (2.0*p2*y3 + p2*p2*s2) - s3;
+  Ith(yBdot,6) = m1 + p2*p2*y2 * m3 + l3 * (2.0*p2*y2 + p2*p2*s2) - s3;
 
 
   return(0);
diff --git a/examples/cvodes/serial/cvsHessian_ASA_FSA.out b/examples/cvodes/serial/cvsHessian_ASA_FSA.out
index de73f5a..2c4f4e6 100644
--- a/examples/cvodes/serial/cvsHessian_ASA_FSA.out
+++ b/examples/cvodes/serial/cvsHessian_ASA_FSA.out
@@ -13,23 +13,23 @@ ncheck = 1
 
 Final Statistics for forward pb.
 --------------------------------
- Number steps:   142
+ Number steps:   143
 
  Function evaluations:
-  f:          165
-  fQ:         147
-  fS:         165
-  fQS:        147
+  f:          167
+  fQ:         149
+  fS:         167
+  fQS:        149
  Error test failures:
   netf:         1
   netfQ:        0
   netfS:        0
-  netfQS:       1
+  netfQS:       2
  Linear solver setups:
   nsetups:     27
   nsetupsS:     0
  Nonlinear iterations:
-  nni:        161
+  nni:        163
   nniS:         0
  Convergence failures:
   ncfn:         0
@@ -45,39 +45,39 @@ Backward integration ... (2 adjoint problems)
    H = d2G/dp2:
         (1)            (2)
     1.5628e-01    -7.8678e-02
-   -7.8678e-02     1.1093e-01
+   -7.8678e-02     8.9814e-02
 
 Final Statistics for backward pb. 1
 -----------------------------------
- Number steps:   100
+ Number steps:   102
 
  Function evaluations:
-  f:          127
-  fQ:         108
+  f:          132
+  fQ:         112
  Error test failures:
   netf:         1
-  netfQ:        4
+  netfQ:        6
  Linear solver setups:
-  nsetups:     22
+  nsetups:     25
  Nonlinear iterations:
-  nni:        123
+  nni:        128
  Convergence failures:
   ncfn:         0
 
 Final Statistics for backward pb. 2
 -----------------------------------
- Number steps:    85
+ Number steps:   115
 
  Function evaluations:
-  f:          109
-  fQ:          92
+  f:          154
+  fQ:         122
  Error test failures:
-  netf:         1
+  netf:         3
   netfQ:        3
  Linear solver setups:
-  nsetups:     18
+  nsetups:     23
  Nonlinear iterations:
-  nni:        105
+  nni:        150
  Convergence failures:
   ncfn:         0
 
@@ -92,9 +92,9 @@ p1-  y:     2.2900e-01   1.3534e-01   3.1472e-02     G:     5.3217e-01
 p2+  y:     2.2943e-01   1.3534e-01   3.0399e-02     G:     5.3106e-01
 p2-  y:     2.2516e-01   1.3534e-01   3.2577e-02     G:     5.3070e-01
 
-   dG/dp:   -1.2760e-01   1.8475e-02   (fwd FD)
+   dG/dp:   -1.2760e-01   1.8476e-02   (fwd FD)
             -1.2916e-01   1.7581e-02   (bck FD)
             -1.2838e-01   1.8028e-02   (cntr FD)
 
-  H(1,1):    1.5590e-01
-  H(2,2):    8.9446e-02
+  H(1,1):    1.5594e-01
+  H(2,2):    8.9483e-02
diff --git a/examples/cvodes/serial/cvsKrylovDemo_ls.c b/examples/cvodes/serial/cvsKrylovDemo_ls.c
index 6864513..ec6f764 100644
--- a/examples/cvodes/serial/cvsKrylovDemo_ls.c
+++ b/examples/cvodes/serial/cvsKrylovDemo_ls.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 22:57:59 $
+ * $Revision: 4849 $
+ * $Date: 2016-08-03 16:00:06 -0700 (Wed, 03 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -46,7 +46,7 @@
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_dense.h> /* use generic DENSE solver in preconditioning */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS, SQR, and EXP */
+#include <sundials/sundials_math.h>  /* contains the macros ABS, SUNSQR, and EXP */
 
 /* Problem Constants */
 
@@ -109,7 +109,7 @@
    IJKth(vdata,i,j,k) references the element in the vdata array for
    species i at mesh point (j,k), where 1 <= i <= NUM_SPECIES,
    0 <= j <= MX-1, 0 <= k <= MY-1. The vdata array is obtained via
-   the macro call vdata = NV_DATA_S(v), where v is an N_Vector. 
+   the macro call vdata = N_VGetArrayPointer_Serial(v), where v is an N_Vector. 
    For each mesh point (j,k), the elements for species i and i+1 are
    contiguous within vdata.
 
@@ -138,7 +138,7 @@ static void FreeUserData(UserData data);
 static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy);
 static void PrintOutput(void *cvode_mem, N_Vector u, realtype t);
 static void PrintFinalStats(void *cvode_mem, int linsolver);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Functions Called by the Solver */
 
@@ -235,12 +235,6 @@ int main(void)
       flag = CVSpgmr(cvode_mem, PREC_LEFT, 0);
       if(check_flag(&flag, "CVSpgmr", 1)) return(1);
 
-      /* Set modified Gram-Schmidt orthogonalization, preconditioner 
-	 setup and solve routines Precond and PSolve, and the pointer 
-	 to the user-defined block data */
-      flag = CVSpilsSetGSType(cvode_mem, MODIFIED_GS);
-      if(check_flag(&flag, "CVSpilsSetGSType", 1)) return(1);
-
       break;
 
     /* (b) SPBCG */
@@ -276,8 +270,7 @@ int main(void)
     }
 
 
-    /* Set preconditioner setup and solve routines Precond and PSolve,
-       and the pointer to the user-defined block data */
+    /* Set preconditioner setup and solve routines Precond and PSolve. */
     flag = CVSpilsSetPreconditioner(cvode_mem, Precond, PSolve);
     if(check_flag(&flag, "CVSpilsSetPreconditioner", 1)) return(1);
 
@@ -334,9 +327,9 @@ static void InitUserData(UserData data)
   data->om = PI/HALFDAY;
   data->dx = (XMAX-XMIN)/(MX-1);
   data->dy = (YMAX-YMIN)/(MY-1);
-  data->hdco = KH/SQR(data->dx);
+  data->hdco = KH/SUNSQR(data->dx);
   data->haco = VEL/(TWO*data->dx);
-  data->vdco = (ONE/SQR(data->dy))*KV0;
+  data->vdco = (ONE/SUNSQR(data->dy))*KV0;
 }
 
 /* Free data memory */
@@ -366,18 +359,18 @@ static void SetInitialProfiles(N_Vector u, realtype dx, realtype dy)
 
   /* Set pointer to data array in vector u. */
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   /* Load initial profiles of c1 and c2 into u vector */
 
   for (jy=0; jy < MY; jy++) {
     y = YMIN + jy*dy;
-    cy = SQR(RCONST(0.1)*(y - YMID));
-    cy = ONE - cy + RCONST(0.5)*SQR(cy);
+    cy = SUNSQR(RCONST(0.1)*(y - YMID));
+    cy = ONE - cy + RCONST(0.5)*SUNSQR(cy);
     for (jx=0; jx < MX; jx++) {
       x = XMIN + jx*dx;
-      cx = SQR(RCONST(0.1)*(x - XMID));
-      cx = ONE - cx + RCONST(0.5)*SQR(cx);
+      cx = SUNSQR(RCONST(0.1)*(x - XMID));
+      cx = ONE - cx + RCONST(0.5)*SUNSQR(cx);
       IJKth(udata,1,jx,jy) = C1_SCALE*cx*cy; 
       IJKth(udata,2,jx,jy) = C2_SCALE*cx*cy;
     }
@@ -393,7 +386,7 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   realtype hu, *udata;
   int mxh = MX/2 - 1, myh = MY/2 - 1, mx1 = MX - 1, my1 = MY - 1;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -410,11 +403,11 @@ static void PrintOutput(void *cvode_mem, N_Vector u, realtype t)
   printf("c2 (bot.left/middle/top rt.) = %12.3Le  %12.3Le  %12.3Le\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %.2le   no. steps = %ld   order = %d   stepsize = %.2le\n",
+  printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
          t, nst, qu, hu);
-  printf("c1 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n",
+  printf("c1 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n",
          IJKth(udata,1,0,0), IJKth(udata,1,mxh,myh), IJKth(udata,1,mx1,my1));
-  printf("c2 (bot.left/middle/top rt.) = %12.3le  %12.3le  %12.3le\n\n",
+  printf("c2 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n\n",
          IJKth(udata,2,0,0), IJKth(udata,2,mxh,myh), IJKth(udata,2,mx1,my1));
 #else
   printf("t = %.2e   no. steps = %ld   order = %d   stepsize = %.2e\n",
@@ -486,7 +479,7 @@ static void PrintFinalStats(void *cvode_mem, int linsolver)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
@@ -532,15 +525,15 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
   UserData data;
 
   data = (UserData) user_data;
-  udata = NV_DATA_S(u);
-  dudata = NV_DATA_S(udot);
+  udata = N_VGetArrayPointer_Serial(u);
+  dudata = N_VGetArrayPointer_Serial(udot);
 
   /* Set diurnal rate coefficients. */
 
   s = sin(data->om*t);
   if (s > ZERO) {
-    q3 = EXP(-A3/s);
-    data->q4 = EXP(-A4/s);
+    q3 = SUNRexp(-A3/s);
+    data->q4 = SUNRexp(-A4/s);
   } else {
       q3 = ZERO;
       data->q4 = ZERO;
@@ -562,8 +555,8 @@ static int f(realtype t, N_Vector u, N_Vector udot, void *user_data)
 
     ydn = YMIN + (jy - RCONST(0.5))*dely;
     yup = ydn + dely;
-    cydn = verdco*EXP(RCONST(0.2)*ydn);
-    cyup = verdco*EXP(RCONST(0.2)*yup);
+    cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+    cyup = verdco*SUNRexp(RCONST(0.2)*yup);
     idn = (jy == 0) ? 1 : -1;
     iup = (jy == MY-1) ? -1 : 1;
     for (jx=0; jx < MX; jx++) {
@@ -631,7 +624,7 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
   P = data->P;
   Jbd = data->Jbd;
   pivot = data->pivot;
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
   
   if (jok) {
     
@@ -661,8 +654,8 @@ static int Precond(realtype tn, N_Vector u, N_Vector fu,
     for (jy=0; jy < MY; jy++) {
       ydn = YMIN + (jy - RCONST(0.5))*dely;
       yup = ydn + dely;
-      cydn = verdco*EXP(RCONST(0.2)*ydn);
-      cyup = verdco*EXP(RCONST(0.2)*yup);
+      cydn = verdco*SUNRexp(RCONST(0.2)*ydn);
+      cyup = verdco*SUNRexp(RCONST(0.2)*yup);
       diag = -(cydn + cyup + TWO*hordco);
       for (jx=0; jx < MX; jx++) {
         c1 = IJKth(udata,1,jx,jy);
@@ -718,7 +711,7 @@ static int PSolve(realtype tn, N_Vector u, N_Vector fu,
   data = (UserData) user_data;
   P = data->P;
   pivot = data->pivot;
-  zdata = NV_DATA_S(z);
+  zdata = N_VGetArrayPointer_Serial(z);
   
   N_VScale(ONE, r, z);
   
diff --git a/examples/cvodes/serial/cvsKrylovDemo_prec.c b/examples/cvodes/serial/cvsKrylovDemo_prec.c
index 4cd2f16..a640118 100644
--- a/examples/cvodes/serial/cvsKrylovDemo_prec.c
+++ b/examples/cvodes/serial/cvsKrylovDemo_prec.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/30 00:22:20 $
+ * $Revision: 4868 $
+ * $Date: 2016-08-19 10:16:31 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -78,8 +78,8 @@
  * destroyMat and destroyArray.
  *
  * Note: This program assumes the sequential implementation for the
- * type N_Vector and uses the NV_DATA_S macro to gain access to the
- * contiguous array of components of an N_Vector.
+ * type N_Vector and uses the N_VGetArrayPointer_Serial function to 
+ * gain access to the contiguous array of components of an N_Vector.
  * --------------------------------------------------------------------
  * Reference: Peter N. Brown and Alan C. Hindmarsh, Reduced Storage
  * Matrix Methods in Stiff ODE Systems, J. Appl. Math. & Comp., 31
@@ -97,7 +97,7 @@
 #include <nvector/nvector_serial.h>  /* serial N_Vector types, fct. and macros */
 #include <sundials/sundials_dense.h> /* use generic DENSE solver in preconditioning */
 #include <sundials/sundials_types.h> /* definition of realtype */
-#include <sundials/sundials_math.h>  /* contains the macros ABS and SQR */
+#include <sundials/sundials_math.h>  /* contains the macros ABS and SUNSQR */
 
 /* Constants */
 
@@ -214,7 +214,7 @@ static int PSolve(realtype tn, N_Vector c, N_Vector fc,
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Implementation */
 
@@ -369,8 +369,8 @@ static void InitUserData(WebData wdata)
   dx = wdata->dx = DX;
   dy = wdata->dy = DY;
   for (i = 0; i < ns; i++) {
-    cox[i] = diff[i]/SQR(dx);
-    coy[i] = diff[i]/SQR(dy);
+    cox[i] = diff[i]/SUNSQR(dx);
+    coy[i] = diff[i]/SUNSQR(dy);
   }
 
   /* Set remaining method parameters */
@@ -379,7 +379,7 @@ static void InitUserData(WebData wdata)
   wdata->mq = MQ;
   wdata->mx = MX;
   wdata->my = MY;
-  wdata->srur = SQRT(UNIT_ROUNDOFF);
+  wdata->srur = SUNRsqrt(UNIT_ROUNDOFF);
   wdata->mxmp = MXMP;
   wdata->ngrp = NGRP;
   wdata->ngx = NGX;
@@ -422,21 +422,21 @@ static void CInit(N_Vector c, WebData wdata)
   int jx, jy, ns, mxns, ioff, iyoff, i, ici;
   realtype argx, argy, x, y, dx, dy, x_factor, y_factor, *cdata;
   
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
   ns = wdata->ns;
   mxns = wdata->mxns;
   dx = wdata->dx;
   dy = wdata->dy;
 
-  x_factor = RCONST(4.0)/SQR(AX);
-  y_factor = RCONST(4.0)/SQR(AY);
+  x_factor = RCONST(4.0)/SUNSQR(AX);
+  y_factor = RCONST(4.0)/SUNSQR(AY);
   for (jy = 0; jy < MY; jy++) {
     y = jy*dy;
-    argy = SQR(y_factor*y*(AY-y)); 
+    argy = SUNSQR(y_factor*y*(AY-y));
     iyoff = mxns*jy;
     for (jx = 0; jx < MX; jx++) {
       x = jx*dx;
-      argx = SQR(x_factor*x*(AX-x));
+      argx = SUNSQR(x_factor*x*(AX-x));
       ioff = iyoff + ns*jx;
       for (i = 1; i <= ns; i++) {
         ici = ioff + i-1;
@@ -459,12 +459,12 @@ static void PrintIntro(void)
          DPREY, DPRED);
   printf("Rate parameter alpha = %.2Lg\n\n", ALPH);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Matrix parameters: a = %.2lg   e = %.2lg   g = %.2lg\n",
+  printf("Matrix parameters: a = %.2g   e = %.2g   g = %.2g\n",
          AA, EE, GG);
-  printf("b parameter = %.2lg\n", BB);
-  printf("Diffusion coefficients: Dprey = %.2lg   Dpred = %.2lg\n",
+  printf("b parameter = %.2g\n", BB);
+  printf("Diffusion coefficients: Dprey = %.2g   Dpred = %.2g\n",
          DPREY, DPRED);
-  printf("Rate parameter alpha = %.2lg\n\n", ALPH);
+  printf("Rate parameter alpha = %.2g\n\n", ALPH);
 #else
   printf("Matrix parameters: a = %.2g   e = %.2g   g = %.2g\n",
          AA, EE, GG);
@@ -479,7 +479,7 @@ static void PrintIntro(void)
   printf("Tolerances: reltol = %.2Lg, abstol = %.2Lg \n\n",
          RTOL, ATOL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerances: reltol = %.2lg, abstol = %.2lg \n\n",
+  printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n",
          RTOL, ATOL);
 #else
   printf("Tolerances: reltol = %.2g, abstol = %.2g \n\n",
@@ -514,11 +514,11 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, realtype t)
   int i, jx ,jy;
   realtype *cdata;
   
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("c values at t = %Lg:\n\n", t);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("c values at t = %lg:\n\n", t);
+  printf("c values at t = %g:\n\n", t);
 #else
   printf("c values at t = %g:\n\n", t);
 #endif
@@ -529,7 +529,7 @@ static void PrintAllSpecies(N_Vector c, int ns, int mxns, realtype t)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
         printf("%-10.6Lg", cdata[(i-1) + jx*ns + jy*mxns]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-        printf("%-10.6lg", cdata[(i-1) + jx*ns + jy*mxns]);
+        printf("%-10.6g", cdata[(i-1) + jx*ns + jy*mxns]);
 #else
         printf("%-10.6g", cdata[(i-1) + jx*ns + jy*mxns]);
 #endif
@@ -561,8 +561,8 @@ static void PrintOutput(void *cvode_mem, realtype t)
   printf("t = %10.2Le  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
   printf("  qu = %d  hu = %11.2Le\n\n", qu, hu);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("t = %10.2le  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
-  printf("  qu = %d  hu = %11.2le\n\n", qu, hu);
+  printf("t = %10.2e  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
+  printf("  qu = %d  hu = %11.2e\n\n", qu, hu);
 #else
   printf("t = %10.2e  nst = %ld  nfe = %ld  nni = %ld", t, nst, nfe, nni);
   printf("  qu = %d  hu = %11.2e\n\n", qu, hu);
@@ -661,8 +661,8 @@ static int f(realtype t, N_Vector c, N_Vector cdot,void *user_data)
   WebData wdata;
   
   wdata = (WebData) user_data;
-  cdata = NV_DATA_S(c);
-  cdotdata = NV_DATA_S(cdot);
+  cdata = N_VGetArrayPointer_Serial(c);
+  cdotdata = N_VGetArrayPointer_Serial(cdot);
   
   mxns = wdata->mxns;
   ns = wdata->ns;
@@ -762,11 +762,11 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
   
   wdata = (WebData) user_data;
   cvode_mem = wdata->cvode_mem;
-  cdata = NV_DATA_S(c);
+  cdata = N_VGetArrayPointer_Serial(c);
   rewt = wdata->rewt;
   flag = CVodeGetErrWeights(cvode_mem, rewt);
   if(check_flag(&flag, "CVodeGetErrWeights", 1)) return(1);
-  rewtdata = NV_DATA_S(rewt);
+  rewtdata = N_VGetArrayPointer_Serial(rewt);
 
   uround = UNIT_ROUNDOFF;
 
@@ -786,10 +786,10 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
      Here, fsave contains the base value of the rate vector and 
      r0 is a minimum increment factor for the difference quotient. */
   
-  f1 = NV_DATA_S(vtemp1);
+  f1 = N_VGetArrayPointer_Serial(vtemp1);
   
   fac = N_VWrmsNorm (fc, rewt);
-  r0 = RCONST(1000.0)*ABS(gamma)*uround*NEQ*fac;
+  r0 = RCONST(1000.0)*SUNRabs(gamma)*uround*NEQ*fac;
   if (r0 == ZERO) r0 = ONE;
   
   for (igy = 0; igy < ngy; igy++) {
@@ -804,7 +804,7 @@ static int Precond(realtype t, N_Vector c, N_Vector fc,
         /* Generate the jth column as a difference quotient */
         jj = if0 + j; 
         save = cdata[jj];
-        r = MAX(srur*ABS(save),r0/rewtdata[jj]);
+        r = SUNMAX(srur*SUNRabs(save),r0/rewtdata[jj]);
         cdata[jj] += r;
         fac = -gamma/r;
         fblock (t, cdata, jx, jy, f1, wdata);
@@ -892,7 +892,7 @@ static int PSolve(realtype tn, N_Vector c, N_Vector fc,
     for (jx = 0; jx < mx; jx++) {
       igx = jigx[jx];
       ig = igx + igy*ngx;
-      denseGETRS(P[ig], mp, pivot[ig], &(NV_DATA_S(z)[iv]));
+      denseGETRS(P[ig], mp, pivot[ig], &(N_VGetArrayPointer_Serial(z)[iv]));
       iv += mp;
     }
   }
@@ -916,8 +916,8 @@ static void GSIter(realtype gamma, N_Vector z, N_Vector x, WebData wdata)
   realtype beta[NS], beta2[NS], cof1[NS], gam[NS], gam2[NS];
   realtype temp, *cox, *coy, *xd, *zd;
   
-  xd = NV_DATA_S(x);
-  zd = NV_DATA_S(z);
+  xd = N_VGetArrayPointer_Serial(x);
+  zd = N_VGetArrayPointer_Serial(z);
   ns = wdata->ns;
   mx = wdata->mx;
   my = wdata->my;
@@ -1113,7 +1113,7 @@ static void v_zero(realtype u[], int n)
      opt == 2 means function allocates memory so check if returned
               NULL pointer */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_dns.c b/examples/cvodes/serial/cvsRoberts_ASAi_dns.c
index 2fd7888..79a1896 100644
--- a/examples/cvodes/serial/cvsRoberts_ASAi_dns.c
+++ b/examples/cvodes/serial/cvsRoberts_ASAi_dns.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2011/11/23 23:53:02 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Adjoint sensitivity example problem.
  * The following is a simple example problem, with the coding
@@ -84,6 +89,7 @@
 
 #define TB1      RCONST(4e7)   /* starting point for adjoint problem   */
 #define TB2      RCONST(50.0)  /* starting point for adjoint problem   */
+#define TBout1   RCONST(40.0)  /* intermediate t for adjoint problem   */
 
 #define STEPS    150           /* number of steps between check points */
 
@@ -120,8 +126,10 @@ static int fQB(realtype t, N_Vector y, N_Vector yB,
 
 /* Prototypes of private functions */
 
-static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector qB);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static void PrintHead(realtype tB0);
+static void PrintOutput(realtype tfinal, N_Vector y, N_Vector yB, N_Vector qB);
+static void PrintOutput1(realtype time, realtype t, N_Vector y, N_Vector yB);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -247,7 +255,7 @@ int main(int argc, char *argv[])
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("G:          %12.4Le \n",Ith(q,1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("G:          %12.4le \n",Ith(q,1));
+  printf("G:          %12.4e \n",Ith(q,1));
 #else
   printf("G:          %12.4e \n",Ith(q,1));
 #endif
@@ -330,12 +338,28 @@ int main(int argc, char *argv[])
   if (check_flag(&flag, "CVodeSetQuadErrConB", 1)) return(1);
 
   /* Backward Integration */
-  printf("Backward integration ... ");
+
+  PrintHead(TB1);
+
+  /* First get results at t = TBout1 */
+
+  flag = CVodeB(cvode_mem, TBout1, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, TBout1, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput1(time, TBout1, y, yB);
+
+  /* Then at t = T0 */
 
   flag = CVodeB(cvode_mem, T0, CV_NORMAL);
   if (check_flag(&flag, "CVodeB", 1)) return(1);
   CVodeGetNumSteps(CVodeGetAdjCVodeBmem(cvode_mem, indexB), &nstB);
-  printf("done ( nst = %ld )\n", nstB);
+  printf("Done ( nst = %ld )\n", nstB);
 
   flag = CVodeGetB(cvode_mem, indexB, &time, yB);
   if (check_flag(&flag, "CVodeGetB", 1)) return(1);
@@ -343,7 +367,10 @@ int main(int argc, char *argv[])
   flag = CVodeGetQuadB(cvode_mem, indexB, &time, qB);
   if (check_flag(&flag, "CVodeGetQuadB", 1)) return(1);
 
-  PrintOutput(TB1, yB, qB);
+  flag = CVodeGetAdjY(cvode_mem, T0, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput(time, y, yB, qB);
 
   /* Reinitialize backward phase (new tB0) */
 
@@ -363,12 +390,27 @@ int main(int argc, char *argv[])
   flag = CVodeQuadReInitB(cvode_mem, indexB, qB); 
   if (check_flag(&flag, "CVodeQuadReInitB", 1)) return(1);
 
-  printf("Backward integration ... ");
+  PrintHead(TB2);
+
+  /* First get results at t = TBout1 */
+
+  flag = CVodeB(cvode_mem, TBout1, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, TBout1, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput1(time, TBout1, y, yB);
+
+  /* Then at t = T0 */
 
   flag = CVodeB(cvode_mem, T0, CV_NORMAL);
   if (check_flag(&flag, "CVodeB", 1)) return(1);
   CVodeGetNumSteps(CVodeGetAdjCVodeBmem(cvode_mem, indexB), &nstB);
-  printf("done ( nst = %ld )\n", nstB);
+  printf("Done ( nst = %ld )\n", nstB);
 
   flag = CVodeGetB(cvode_mem, indexB, &time, yB);
   if (check_flag(&flag, "CVodeGetB", 1)) return(1);
@@ -376,7 +418,10 @@ int main(int argc, char *argv[])
   flag = CVodeGetQuadB(cvode_mem, indexB, &time, qB);
   if (check_flag(&flag, "CVodeGetQuadB", 1)) return(1);
 
-  PrintOutput(TB2, yB, qB);
+  flag = CVodeGetAdjY(cvode_mem, T0, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput(time, y, yB, qB);
 
   /* Free memory */
   printf("Free memory\n\n");
@@ -472,7 +517,7 @@ static int ewt(N_Vector y, N_Vector w, void *user_data)
 
   for (i=1; i<=3; i++) {
     yy = Ith(y,i);
-    ww = rtol * ABS(yy) + atol[i-1];  
+    ww = rtol * SUNRabs(yy) + atol[i-1];
     if (ww <= 0.0) return (-1);
     Ith(w,i) = 1.0/ww;
   }
@@ -518,7 +563,7 @@ static int fB(realtype t, N_Vector y, N_Vector yB, N_Vector yBdot, void *user_da
 
 /* 
  * JacB routine. Compute JB(t,y,yB). 
-*/
+ */
 
 static int JacB(long int NB, realtype t,
                 N_Vector y, N_Vector yB, N_Vector fyB,
@@ -589,30 +634,83 @@ static int fQB(realtype t, N_Vector y, N_Vector yB,
  */
 
 /*
- * Print results after backward integration
+ * Print heading for backward integration
  */
 
-static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector qB)
+static void PrintHead(realtype tB0)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Backward integration from tB0 = %12.4Le\n\n",tB0);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Backward integration from tB0 = %12.4e\n\n",tB0);
+#else
+  printf("Backward integration from tB0 = %12.4e\n\n",tB0);
+#endif
+}
+
+/*
+ * Print intermediate results during backward integration
+ */
+
+static void PrintOutput1(realtype time, realtype t, N_Vector y, N_Vector yB)
 {
   printf("--------------------------------------------------------\n");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
-  printf("tB0:        %12.4Le\n",tfinal);
-  printf("dG/dp:      %12.4Le %12.4Le %12.4Le\n", 
-         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
-  printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", 
+  printf("returned t: %12.4Le\n",time);
+  printf("tout:       %12.4Le\n",t);
+  printf("lambda(t):  %12.4Le %12.4Le %12.4Le\n", 
          Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t):       %12.4Le %12.4Le %12.4Le\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("tB0:        %12.4le\n",tfinal);
-  printf("dG/dp:      %12.4le %12.4le %12.4le\n", 
-         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
-  printf("lambda(t0): %12.4le %12.4le %12.4le\n", 
+  printf("returned t: %12.4e\n",time);
+  printf("tout:       %12.4e\n",t);
+  printf("lambda(t):  %12.4e %12.4e %12.4e\n", 
          Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t):       %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
 #else
-  printf("tB0:        %12.4e\n",tfinal);
+  printf("returned t: %12.4e\n",time);
+  printf("tout:       %12.4e\n",t);
+  printf("lambda(t):  %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t)      : %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+#endif
+  printf("--------------------------------------------------------\n\n");
+}
+
+/*
+ * Print final results of backward integration
+ */
+
+static void PrintOutput(realtype tfinal, N_Vector y, N_Vector yB, N_Vector qB)
+{
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("returned t: %12.4Le\n",tfinal);
+  printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0):      %12.4Le %12.4Le %12.4Le\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4Le %12.4Le %12.4Le\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("returned t: %12.4e\n",tfinal);
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0):      %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
   printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
          -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#else
+  printf("returned t: %12.4e\n",tfinal);
   printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
          Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0)     : %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
 #endif
   printf("--------------------------------------------------------\n\n");
 }
@@ -627,7 +725,7 @@ static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector qB)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_dns.out b/examples/cvodes/serial/cvsRoberts_ASAi_dns.out
index 008a51c..dfe6540 100644
--- a/examples/cvodes/serial/cvsRoberts_ASAi_dns.out
+++ b/examples/cvodes/serial/cvsRoberts_ASAi_dns.out
@@ -12,27 +12,48 @@ Find dG/dp for
 
 
 Create and allocate CVODES memory for forward runs
-Forward integration ... done ( nst = 851 )
+Forward integration ... done ( nst = 830 )
 
 ncheck = 5
+
 --------------------------------------------------------
 G:            3.9983e+07 
 --------------------------------------------------------
 
 Create and allocate CVODES memory for backward run
-Backward integration ... done ( nst = 260 )
+Backward integration from tB0 =   4.0000e+07
+
+--------------------------------------------------------
+returned t:   4.0000e+01
+tout:         4.0000e+01
+lambda(t):    3.9967e+07   3.9967e+07   3.9967e+07
+y(t):         7.1583e-01   9.1856e-06   2.8416e-01
+--------------------------------------------------------
+
+Done ( nst = 267 )
 --------------------------------------------------------
-tB0:          4.0000e+07
-dG/dp:        7.6844e+05  -3.0691e+00   5.1152e-04
+returned t:   0.0000e+00
 lambda(t0):   3.9967e+07   3.9967e+07   3.9967e+07
+y(t0):        1.0000e+00   0.0000e+00   0.0000e+00
+dG/dp:        7.6836e+05  -3.0688e+00   5.1143e-04
 --------------------------------------------------------
 
 Re-initialize CVODES memory for backward run
-Backward integration ... done ( nst = 196 )
+Backward integration from tB0 =   5.0000e+01
+
+--------------------------------------------------------
+returned t:   4.0000e+01
+tout:         4.0000e+01
+lambda(t):    2.8959e-01   1.7624e+00   9.3567e+00
+y(t):         7.1583e-01   9.1856e-06   2.8416e-01
+--------------------------------------------------------
+
+Done ( nst = 158 )
 --------------------------------------------------------
-tB0:          5.0000e+01
-dG/dp:        1.7341e+02  -5.0590e-04   8.4320e-08
-lambda(t0):   8.4190e+00   1.6097e+01   1.6097e+01
+returned t:   0.0000e+00
+lambda(t0):   8.4191e+00   1.6097e+01   1.6097e+01
+y(t0):        1.0000e+00   0.0000e+00   0.0000e+00
+dG/dp:        1.7341e+02  -5.0591e-04   8.4323e-08
 --------------------------------------------------------
 
 Free memory
diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_klu.c b/examples/cvodes/serial/cvsRoberts_ASAi_klu.c
new file mode 100644
index 0000000..6ab9cf3
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_ASAi_klu.c
@@ -0,0 +1,825 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on cvsRoberts_ASAi_dns.c and modified to use KLU
+ * -----------------------------------------------------------------
+ * Adjoint sensitivity example problem:
+ *
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODES. The problem is from chemical
+ * kinetics, and consists of the following three rate equations.
+ *    dy1/dt = -p1*y1 + p2*y2*y3
+ *    dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
+ *    dy3/dt =  p3*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1.0, y2 = y3 = 0. The reaction rates are:
+ * p1=0.04, p2=1e4, and p3=3e7. The problem is stiff.
+ * This program solves the problem with the BDF method, Newton
+ * iteration with the CVODE KLU linear solver, and a user-supplied
+ * Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance.
+ * Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ * 
+ * Optionally, CVODES can compute sensitivities with respect to
+ * the problem parameters p1, p2, and p3 of the following quantity:
+ *   G = int_t0^t1 g(t,p,y) dt
+ * where
+ *   g(t,p,y) = y3
+ *        
+ * The gradient dG/dp is obtained as:
+ *   dG/dp = int_t0^t1 (g_p - lambda^T f_p ) dt - lambda^T(t0)*y0_p
+ *         = - xi^T(t0) - lambda^T(t0)*y0_p
+ * where lambda and xi are solutions of:
+ *   d(lambda)/dt = - (f_y)^T * lambda - (g_y)^T
+ *   lambda(t1) = 0
+ * and
+ *   d(xi)/dt = - (f_p)^T * lambda + (g_p)^T
+ *   xi(t1) = 0
+ * 
+ * During the backward integration, CVODES also evaluates G as
+ *   G = - phi(t0)
+ * where
+ *   d(phi)/dt = g(t,y,p)
+ *   phi(t1) = 0
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Header files with a description of contents used */
+#include <cvodes/cvodes.h>              /* prototypes for CVODES fcts. and consts. */
+#include <cvodes/cvodes_klu.h>          /* prototypes for CVKLU fcts. and constants */
+#include <sundials/sundials_sparse.h>   /* definitions SlsMat */
+#include <nvector/nvector_serial.h>     /* defs. of serial NVECTOR fcts. and macros */
+#include <sundials/sundials_types.h>    /* def. of type realtype */
+#include <sundials/sundials_math.h>     /* definition of ABS */
+
+/* Accessor macros */
+/* These macros are defined in order to write code with which exactly matched
+   the mathematical problem description given above.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component, i=1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ      3             /* number of equations                  */
+
+#define RTOL     RCONST(1e-6)  /* scalar relative tolerance            */
+
+#define ATOL1    RCONST(1e-8)  /* vector absolute tolerance components */
+#define ATOL2    RCONST(1e-14)
+#define ATOL3    RCONST(1e-6)
+
+#define ATOLl    RCONST(1e-8)  /* absolute tolerance for adjoint vars. */
+#define ATOLq    RCONST(1e-6)  /* absolute tolerance for quadratures   */
+
+#define T0       RCONST(0.0)   /* initial time                         */
+#define TOUT     RCONST(4e7)   /* final time                           */
+
+#define TB1      RCONST(4e7)   /* starting point for adjoint problem   */
+#define TB2      RCONST(50.0)  /* starting point for adjoint problem   */
+#define TBout1   RCONST(40.0)  /* intermediate t for adjoint problem   */
+
+#define STEPS    150           /* number of steps between check points */
+
+#define NP       3             /* number of problem parameters         */
+
+#define ZERO     RCONST(0.0)
+
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];
+} *UserData;
+
+/* Prototypes of user-supplied functions */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+static int fQ(realtype t, N_Vector y, N_Vector qdot, void *user_data);
+static int ewt(N_Vector y, N_Vector w, void *user_data);
+
+static int fB(realtype t, N_Vector y, 
+              N_Vector yB, N_Vector yBdot, void *user_dataB);
+static int JacB(realtype t,
+                N_Vector y, N_Vector yB, N_Vector fyB,
+                SlsMat JacMatB, void *user_dataB,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+static int fQB(realtype t, N_Vector y, N_Vector yB, 
+               N_Vector qBdot, void *user_dataB);
+
+
+/* Prototypes of private functions */
+
+static void PrintHead(realtype tB0);
+static void PrintOutput(realtype tfinal, N_Vector y, N_Vector yB, N_Vector qB);
+static void PrintOutput1(realtype time, realtype t, N_Vector y, N_Vector yB);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  UserData data;
+
+  void *cvode_mem;
+
+  realtype reltolQ, abstolQ;
+  N_Vector y, q;
+
+  int steps;
+
+  int indexB;
+
+  realtype reltolB, abstolB, abstolQB;
+  N_Vector yB, qB;
+
+  realtype time;
+  int flag, nnz, ncheck;
+
+  long int nst, nstB;
+
+  CVadjCheckPointRec *ckpnt;
+
+  data = NULL;
+  cvode_mem = NULL;
+  ckpnt = NULL;
+  y = yB = qB = NULL;
+
+  /* Print problem description */
+  printf("\nAdjoint Sensitivity Example for Chemical Kinetics\n");
+  printf("-------------------------------------------------\n\n");
+  printf("ODE: dy1/dt = -p1*y1 + p2*y2*y3\n");
+  printf("     dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2\n");
+  printf("     dy3/dt =  p3*(y2)^2\n\n");
+  printf("Find dG/dp for\n");
+  printf("     G = int_t0^tB0 g(t,p,y) dt\n");
+  printf("     g(t,p,y) = y3\n\n\n");
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.04);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+
+  /* Initialize y */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+  Ith(y,1) = RCONST(1.0);
+  Ith(y,2) = ZERO;
+  Ith(y,3) = ZERO;
+
+  /* Initialize q */
+  q = N_VNew_Serial(1);
+  if (check_flag((void *)q, "N_VNew_Serial", 0)) return(1);
+  Ith(q,1) = ZERO;
+
+  /* Set the scalar realtive and absolute tolerances reltolQ and abstolQ */
+  reltolQ = RTOL;
+  abstolQ = ATOLq;
+
+  /* Create and allocate CVODES memory for forward run */
+  printf("Create and allocate CVODES memory for forward runs\n");
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+     Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+     user's right hand side function in y'=f(t,y), the initial time T0, and
+     the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeWFtolerances to specify a user-supplied function ewt that sets
+     the multiplicative error weights W_i for use in the weighted RMS norm */
+  flag = CVodeWFtolerances(cvode_mem, ewt);
+  if (check_flag(&flag, "CVodeWFtolerances", 1)) return(1);
+
+  /* Attach user data */
+  flag = CVodeSetUserData(cvode_mem, data);
+  if (check_flag(&flag, "CVodeSetUserData", 1)) return(1);
+
+  /* Call CVKLU to specify the CVKLU sparse direct linear solver */
+  nnz = NEQ * NEQ;              /* max no. of nonzeros entries in the Jac */
+  flag = CVKLU(cvode_mem, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "CVKLU", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  /* Call CVodeQuadInit to allocate initernal memory and initialize
+     quadrature integration*/
+  flag = CVodeQuadInit(cvode_mem, fQ, q);
+  if (check_flag(&flag, "CVodeQuadInit", 1)) return(1);
+
+  /* Call CVodeSetQuadErrCon to specify whether or not the quadrature variables
+     are to be used in the step size control mechanism within CVODES. Call
+     CVodeQuadSStolerances or CVodeQuadSVtolerances to specify the integration
+     tolerances for the quadrature variables. */
+  flag = CVodeSetQuadErrCon(cvode_mem, TRUE);
+  if (check_flag(&flag, "CVodeSetQuadErrCon", 1)) return(1);
+
+  /* Call CVodeQuadSStolerances to specify scalar relative and absolute
+     tolerances. */
+  flag = CVodeQuadSStolerances(cvode_mem, reltolQ, abstolQ);
+  if (check_flag(&flag, "CVodeQuadSStolerances", 1)) return(1);
+
+  /* Allocate global memory */
+
+  /* Call CVodeAdjInit to update CVODES memory block by allocting the internal 
+     memory needed for backward integration.*/
+  steps = STEPS;             /* no. of integration steps between two
+                               consecutive ckeckpoints*/
+  flag = CVodeAdjInit(cvode_mem, steps, CV_HERMITE);
+  /*
+  flag = CVodeAdjInit(cvode_mem, steps, CV_POLYNOMIAL);
+  */
+  if (check_flag(&flag, "CVodeAdjInit", 1)) return(1);
+
+  /* Perform forward run */
+  printf("Forward integration ... ");
+
+  /* Call CVodeF to integrate the forward problem over an interval in time and
+     saves checkpointing data */
+  flag = CVodeF(cvode_mem, TOUT, y, &time, CV_NORMAL, &ncheck);
+  if (check_flag(&flag, "CVodeF", 1)) return(1);
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  if (check_flag(&flag, "CVodeGetNumSteps", 1)) return(1);
+
+  printf("done ( nst = %ld )\n",nst);
+  printf("\nncheck = %d\n\n", ncheck);
+
+  flag = CVodeGetQuad(cvode_mem, &time, q);
+  if (check_flag(&flag, "CVodeGetQuad", 1)) return(1);
+
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("G:          %12.4Le \n",Ith(q,1));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("G:          %12.4e \n",Ith(q,1));
+#else
+  printf("G:          %12.4e \n",Ith(q,1));
+#endif
+  printf("--------------------------------------------------------\n\n");
+
+  /* Test check point linked list 
+     (uncomment next block to print check point information) */
+  
+  /*
+  {
+    int i;
+    
+    printf("\nList of Check Points (ncheck = %d)\n\n", ncheck);
+    ckpnt = (CVadjCheckPointRec *) malloc ( (ncheck+1)*sizeof(CVadjCheckPointRec));
+    CVodeGetAdjCheckPointsInfo(cvode_mem, ckpnt);
+    for (i=0;i<=ncheck;i++) {
+      printf("Address:       %p\n",ckpnt[i].my_addr);
+      printf("Next:          %p\n",ckpnt[i].next_addr);
+      printf("Time interval: %le  %le\n",ckpnt[i].t0, ckpnt[i].t1);
+      printf("Step number:   %ld\n",ckpnt[i].nstep);
+      printf("Order:         %d\n",ckpnt[i].order);
+      printf("Step size:     %le\n",ckpnt[i].step);
+      printf("\n");
+    }
+    
+  }
+  */
+  
+  /* Initialize yB */
+  yB = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yB, "N_VNew_Serial", 0)) return(1);
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = ZERO;
+
+  /* Initialize qB */
+  qB = N_VNew_Serial(NP);
+  if (check_flag((void *)qB, "N_VNew", 0)) return(1);
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  /* Set the scalar relative tolerance reltolB */
+  reltolB = RTOL;               
+
+  /* Set the scalar absolute tolerance abstolB */
+  abstolB = ATOLl;
+
+  /* Set the scalar absolute tolerance abstolQB */
+  abstolQB = ATOLq;
+
+  /* Create and allocate CVODES memory for backward run */
+  printf("Create and allocate CVODES memory for backward run\n");
+
+  /* Call CVodeCreateB to specify the solution method for the backward 
+     problem. */
+  flag = CVodeCreateB(cvode_mem, CV_BDF, CV_NEWTON, &indexB);
+  if (check_flag(&flag, "CVodeCreateB", 1)) return(1);
+
+  /* Call CVodeInitB to allocate internal memory and initialize the 
+     backward problem. */
+  flag = CVodeInitB(cvode_mem, indexB, fB, TB1, yB);
+  if (check_flag(&flag, "CVodeInitB", 1)) return(1);
+
+  /* Set the scalar relative and absolute tolerances. */
+  flag = CVodeSStolerancesB(cvode_mem, indexB, reltolB, abstolB);
+  if (check_flag(&flag, "CVodeSStolerancesB", 1)) return(1);
+
+  /* Attach the user data for backward problem. */
+  flag = CVodeSetUserDataB(cvode_mem, indexB, data);
+  if (check_flag(&flag, "CVodeSetUserDataB", 1)) return(1);
+
+  /* Call CVKLUB to initialize the CVKLU sparse linear solver for the backward 
+     problem. */
+  flag = CVKLUB(cvode_mem, indexB, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "CVKLUB", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) for the backward problem */
+  flag = CVSlsSetSparseJacFnB(cvode_mem, indexB, JacB);
+  if (check_flag(&flag, "CVSlsSetSparseJacFnB", 1)) return(1);
+
+  /* Call CVodeQuadInitB to allocate internal memory and initialize backward
+     quadrature integration. */
+  flag = CVodeQuadInitB(cvode_mem, indexB, fQB, qB);
+  if (check_flag(&flag, "CVodeQuadInitB", 1)) return(1);
+
+  /* Call CVodeSetQuadErrCon to specify whether or not the quadrature variables
+     are to be used in the step size control mechanism within CVODES. Call
+     CVodeQuadSStolerances or CVodeQuadSVtolerances to specify the integration
+     tolerances for the quadrature variables. */
+  flag = CVodeSetQuadErrConB(cvode_mem, indexB, TRUE);
+  if (check_flag(&flag, "CVodeSetQuadErrConB", 1)) return(1);
+
+  /* Call CVodeQuadSStolerancesB to specify the scalar relative and absolute tolerances
+     for the backward problem. */
+  flag = CVodeQuadSStolerancesB(cvode_mem, indexB, reltolB, abstolQB);
+  if (check_flag(&flag, "CVodeQuadSStolerancesB", 1)) return(1);
+
+  /* Backward Integration */
+
+  PrintHead(TB1);
+
+  /* First get results at t = TBout1 */
+
+  /* Call CVodeB to integrate the backward ODE problem. */
+  flag = CVodeB(cvode_mem, TBout1, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+
+  /* Call CVodeGetB to get yB of the backward ODE problem. */
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  /* Call CVodeGetAdjY to get the interpolated value of the forward solution
+     y during a backward integration. */
+  flag = CVodeGetAdjY(cvode_mem, TBout1, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput1(time, TBout1, y, yB);
+
+  /* Then at t = T0 */
+
+  flag = CVodeB(cvode_mem, T0, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+  CVodeGetNumSteps(CVodeGetAdjCVodeBmem(cvode_mem, indexB), &nstB);
+  printf("Done ( nst = %ld )\n", nstB);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  /* Call CVodeGetQuadB to get the quadrature solution vector after a 
+     successful return from CVodeB. */
+  flag = CVodeGetQuadB(cvode_mem, indexB, &time, qB);
+  if (check_flag(&flag, "CVodeGetQuadB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, T0, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput(time, y, yB, qB);
+
+  /* Reinitialize backward phase (new tB0) */
+
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = ZERO;
+
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  printf("Re-initialize CVODES memory for backward run\n");
+
+  flag = CVodeReInitB(cvode_mem, indexB, TB2, yB);
+  if (check_flag(&flag, "CVodeReInitB", 1)) return(1);
+
+  flag = CVodeQuadReInitB(cvode_mem, indexB, qB); 
+  if (check_flag(&flag, "CVodeQuadReInitB", 1)) return(1);
+
+  PrintHead(TB2);
+
+  /* First get results at t = TBout1 */
+
+  flag = CVodeB(cvode_mem, TBout1, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, TBout1, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput1(time, TBout1, y, yB);
+
+  /* Then at t = T0 */
+
+  flag = CVodeB(cvode_mem, T0, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+  CVodeGetNumSteps(CVodeGetAdjCVodeBmem(cvode_mem, indexB), &nstB);
+  printf("Done ( nst = %ld )\n", nstB);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  flag = CVodeGetQuadB(cvode_mem, indexB, &time, qB);
+  if (check_flag(&flag, "CVodeGetQuadB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, T0, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput(time, y, yB, qB);
+
+  /* Free memory */
+  printf("Free memory\n\n");
+
+  CVodeFree(&cvode_mem);
+  N_VDestroy_Serial(y); 
+  N_VDestroy_Serial(q);
+  N_VDestroy_Serial(yB);
+  N_VDestroy_Serial(qB);
+
+  if (ckpnt != NULL) free(ckpnt);
+  free(data);
+
+  return(0);
+
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY CVODES
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * f routine. Compute f(t,y). 
+*/
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+  UserData data;
+  realtype p1, p2, p3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  yd1 = Ith(ydot,1) = -p1*y1 + p2*y2*y3;
+  yd3 = Ith(ydot,3) = p3*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+*/
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(y);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+  
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = -p1;                          rowvals[0] = 0;
+  data[1] = p1;                           rowvals[1] = 1;
+  data[2] = ZERO;                         rowvals[2] = 2;
+
+  data[3] = p2*yval[2];                   rowvals[3] = 0;
+  data[4] = -p2*yval[2]-2*p3*yval[1];     rowvals[4] = 1;
+  data[5] = 2*yval[1];                    rowvals[5] = 2;
+  
+  data[6] = p2*yval[1];                   rowvals[6] = 0;
+  data[7] = -p2*yval[1];                  rowvals[7] = 1;
+  data[8] = ZERO;                         rowvals[8] = 2;
+
+  return(0);
+}
+
+/* 
+ * fQ routine. Compute fQ(t,y). 
+*/
+
+static int fQ(realtype t, N_Vector y, N_Vector qdot, void *user_data)
+{
+  Ith(qdot,1) = Ith(y,3);  
+
+  return(0);
+}
+ 
+/*
+ * EwtSet function. Computes the error weights at the current solution.
+ */
+
+static int ewt(N_Vector y, N_Vector w, void *user_data)
+{
+  int i;
+  realtype yy, ww, rtol, atol[3];
+
+  rtol    = RTOL;
+  atol[0] = ATOL1;
+  atol[1] = ATOL2;
+  atol[2] = ATOL3;
+
+  for (i=1; i<=3; i++) {
+    yy = Ith(y,i);
+    ww = rtol * SUNRabs(yy) + atol[i-1];
+    if (ww <= 0.0) return (-1);
+    Ith(w,i) = 1.0/ww;
+  }
+
+  return(0);
+}
+
+/* 
+ * fB routine. Compute fB(t,y,yB). 
+*/
+
+static int fB(realtype t, N_Vector y, N_Vector yB, N_Vector yBdot, void *user_dataB)
+{
+  UserData data;
+  realtype y2, y3;
+  realtype p1, p2, p3;
+  realtype l1, l2, l3;
+  realtype l21, l32;
+  
+  data = (UserData) user_dataB;
+
+  /* The p vector */
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  /* The y vector */ 
+  y2 = Ith(y,2); y3 = Ith(y,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yB,1); l2 = Ith(yB,2); l3 = Ith(yB,3);
+
+  /* Temporary variables */
+  l21 = l2-l1;
+  l32 = l3-l2;
+
+  /* Load yBdot */
+  Ith(yBdot,1) = - p1*l21;
+  Ith(yBdot,2) = p2*y3*l21 - RCONST(2.0)*p3*y2*l32;
+  Ith(yBdot,3) = p2*y2*l21 - RCONST(1.0);
+
+  return(0);
+}
+
+/* 
+ * JacB routine. Compute JB(t,y,yB). 
+ */
+
+static int JacB(realtype t,
+                N_Vector y, N_Vector yB, N_Vector fyB,
+                SlsMat JacMatB, void *user_dataB,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  realtype *yvalB;
+  int* colptrsB;
+  int* rowvalsB;
+  realtype* dataB;
+  UserData userdata;
+  realtype p1, p2, p3;
+
+  yvalB = N_VGetArrayPointer_Serial(y);
+  colptrsB = (*JacMatB->colptrs);
+  rowvalsB = (*JacMatB->rowvals);
+  dataB = JacMatB->data;
+  userdata = (UserData) user_dataB;
+
+  /* The p vector */
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMatB);
+  
+  /* Load JB */
+  colptrsB[0] = 0;
+  colptrsB[1] = 3;
+  colptrsB[2] = 6;
+  colptrsB[3] = 9;
+
+  dataB[0] = p1;                           rowvalsB[0] = 0;
+  dataB[1] = -p2*yvalB[2];                 rowvalsB[1] = 1;
+  dataB[2] = -p2*yvalB[1];                 rowvalsB[2] = 2;
+
+  dataB[3] =-p1;                           rowvalsB[3] = 0;
+  dataB[4] = p2*yvalB[2]+2*p3*yvalB[1];    rowvalsB[4] = 1;
+  dataB[5] = p2*yvalB[1];                  rowvalsB[5] = 2;
+  
+  dataB[6] = ZERO;                         rowvalsB[6] = 0;
+  dataB[7] = RCONST(-2.0)*p3*yvalB[1];     rowvalsB[7] = 1;
+  dataB[8] = ZERO;                         rowvalsB[8] = 2;
+
+  return(0);
+}
+
+/*
+ * fQB routine. Compute integrand for quadratures 
+*/
+
+static int fQB(realtype t, N_Vector y, N_Vector yB, 
+               N_Vector qBdot, void *user_dataB)
+{
+  realtype y1, y2, y3;
+  realtype l1, l2, l3;
+  realtype l21, l32, y23;
+
+  /* The y vector */
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yB,1); l2 = Ith(yB,2); l3 = Ith(yB,3);
+
+  /* Temporary variables */
+  l21 = l2-l1;
+  l32 = l3-l2;
+  y23 = y2*y3;
+
+  Ith(qBdot,1) = y1*l21;
+  Ith(qBdot,2) = - y23*l21;
+  Ith(qBdot,3) = y2*y2*l32;
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Print heading for backward integration
+ */
+
+static void PrintHead(realtype tB0)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Backward integration from tB0 = %12.4Le\n\n",tB0);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Backward integration from tB0 = %12.4e\n\n",tB0);
+#else
+  printf("Backward integration from tB0 = %12.4e\n\n",tB0);
+#endif
+}
+
+/*
+ * Print intermediate results during backward integration
+ */
+
+static void PrintOutput1(realtype time, realtype t, N_Vector y, N_Vector yB)
+{
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("returned t: %12.4Le\n",time);
+  printf("tout:       %12.4Le\n",t);
+  printf("lambda(t):  %12.4Le %12.4Le %12.4Le\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t):       %12.4Le %12.4Le %12.4Le\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("returned t: %12.4e\n",time);
+  printf("tout:       %12.4e\n",t);
+  printf("lambda(t):  %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t):       %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+#else
+  printf("returned t: %12.4e\n",time);
+  printf("tout:       %12.4e\n",t);
+  printf("lambda(t):  %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t)      : %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+#endif
+  printf("--------------------------------------------------------\n\n");
+}
+
+/*
+ * Print final results of backward integration
+ */
+
+static void PrintOutput(realtype tfinal, N_Vector y, N_Vector yB, N_Vector qB)
+{
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("returned t: %12.4Le\n",tfinal);
+  printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0):      %12.4Le %12.4Le %12.4Le\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4Le %12.4Le %12.4Le\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("returned t: %12.4e\n",tfinal);
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0):      %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#else
+  printf("returned t: %12.4e\n",tfinal);
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0)     : %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#endif
+  printf("--------------------------------------------------------\n\n");
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_klu.out b/examples/cvodes/serial/cvsRoberts_ASAi_klu.out
new file mode 100644
index 0000000..fd7052d
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_ASAi_klu.out
@@ -0,0 +1,60 @@
+
+Adjoint Sensitivity Example for Chemical Kinetics
+-------------------------------------------------
+
+ODE: dy1/dt = -p1*y1 + p2*y2*y3
+     dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
+     dy3/dt =  p3*(y2)^2
+
+Find dG/dp for
+     G = int_t0^tB0 g(t,p,y) dt
+     g(t,p,y) = y3
+
+
+Create and allocate CVODES memory for forward runs
+Forward integration ... done ( nst = 847 )
+
+ncheck = 5
+
+--------------------------------------------------------
+G:            3.9982e+07 
+--------------------------------------------------------
+
+Create and allocate CVODES memory for backward run
+Backward integration from tB0 =   4.0000e+07
+
+--------------------------------------------------------
+returned t:   4.0000e+01
+tout:         4.0000e+01
+lambda(t):    3.9967e+07   3.9967e+07   3.9967e+07
+y(t):         7.1583e-01   9.1856e-06   2.8416e-01
+--------------------------------------------------------
+
+Done ( nst = 265 )
+--------------------------------------------------------
+returned t:   0.0000e+00
+lambda(t0):   3.9967e+07   3.9967e+07   3.9967e+07
+y(t0):        1.0000e+00   0.0000e+00   0.0000e+00
+dG/dp:        7.6837e+05  -3.0689e+00   5.1142e-04
+--------------------------------------------------------
+
+Re-initialize CVODES memory for backward run
+Backward integration from tB0 =   5.0000e+01
+
+--------------------------------------------------------
+returned t:   4.0000e+01
+tout:         4.0000e+01
+lambda(t):    2.8959e-01   1.7624e+00   9.3567e+00
+y(t):         7.1583e-01   9.1856e-06   2.8416e-01
+--------------------------------------------------------
+
+Done ( nst = 186 )
+--------------------------------------------------------
+returned t:   0.0000e+00
+lambda(t0):   8.4191e+00   1.6097e+01   1.6097e+01
+y(t0):        1.0000e+00   0.0000e+00   0.0000e+00
+dG/dp:        1.7341e+02  -5.0591e-04   8.4321e-08
+--------------------------------------------------------
+
+Free memory
+
diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_sps.c b/examples/cvodes/serial/cvsRoberts_ASAi_sps.c
new file mode 100644
index 0000000..8dce1df
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_ASAi_sps.c
@@ -0,0 +1,826 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on cvsRoberts_ASAi_dns.c and modified to use SuperLUMT
+ * -----------------------------------------------------------------
+ * Adjoint sensitivity example problem:
+ *
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODES. The problem is from chemical
+ * kinetics, and consists of the following three rate equations.
+ *    dy1/dt = -p1*y1 + p2*y2*y3
+ *    dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
+ *    dy3/dt =  p3*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1.0, y2 = y3 = 0. The reaction rates are:
+ * p1=0.04, p2=1e4, and p3=3e7. The problem is stiff.
+ * This program solves the problem with the BDF method, Newton
+ * iteration with the CVODE SuperLU_MT linear solver, and a 
+ * user-supplied Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance.
+ * Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ * 
+ * Optionally, CVODES can compute sensitivities with respect to
+ * the problem parameters p1, p2, and p3 of the following quantity:
+ *   G = int_t0^t1 g(t,p,y) dt
+ * where
+ *   g(t,p,y) = y3
+ *        
+ * The gradient dG/dp is obtained as:
+ *   dG/dp = int_t0^t1 (g_p - lambda^T f_p ) dt - lambda^T(t0)*y0_p
+ *         = - xi^T(t0) - lambda^T(t0)*y0_p
+ * where lambda and xi are solutions of:
+ *   d(lambda)/dt = - (f_y)^T * lambda - (g_y)^T
+ *   lambda(t1) = 0
+ * and
+ *   d(xi)/dt = - (f_p)^T * lambda + (g_p)^T
+ *   xi(t1) = 0
+ * 
+ * During the backward integration, CVODES also evaluates G as
+ *   G = - phi(t0)
+ * where
+ *   d(phi)/dt = g(t,y,p)
+ *   phi(t1) = 0
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Header files with a description of contents used */
+#include <cvodes/cvodes.h>              /* prototypes for CVODES fcts. and consts. */
+#include <cvodes/cvodes_superlumt.h>    /* prototypes for CVSUPERLUMT fcts. and constants */
+#include <sundials/sundials_sparse.h>   /* definitions SlsMat */
+#include <nvector/nvector_serial.h>     /* defs. of serial NVECTOR fcts. and macros */
+#include <sundials/sundials_types.h>    /* def. of type realtype */
+#include <sundials/sundials_math.h>     /* definition of ABS */
+
+/* Accessor macros */
+/* These macros are defined in order to write code with which exactly matched
+   the mathematical problem description given above.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component, i=1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ      3             /* number of equations                  */
+
+#define RTOL     RCONST(1e-6)  /* scalar relative tolerance            */
+
+#define ATOL1    RCONST(1e-8)  /* vector absolute tolerance components */
+#define ATOL2    RCONST(1e-14)
+#define ATOL3    RCONST(1e-6)
+
+#define ATOLl    RCONST(1e-8)  /* absolute tolerance for adjoint vars. */
+#define ATOLq    RCONST(1e-6)  /* absolute tolerance for quadratures   */
+
+#define T0       RCONST(0.0)   /* initial time                         */
+#define TOUT     RCONST(4e7)   /* final time                           */
+
+#define TB1      RCONST(4e7)   /* starting point for adjoint problem   */
+#define TB2      RCONST(50.0)  /* starting point for adjoint problem   */
+#define TBout1   RCONST(40.0)  /* intermediate t for adjoint problem   */
+
+#define STEPS    150           /* number of steps between check points */
+
+#define NP       3             /* number of problem parameters         */
+
+#define ZERO     RCONST(0.0)
+
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];
+} *UserData;
+
+/* Prototypes of user-supplied functions */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+static int fQ(realtype t, N_Vector y, N_Vector qdot, void *user_data);
+static int ewt(N_Vector y, N_Vector w, void *user_data);
+
+static int fB(realtype t, N_Vector y, 
+              N_Vector yB, N_Vector yBdot, void *user_dataB);
+static int JacB(realtype t,
+                N_Vector y, N_Vector yB, N_Vector fyB,
+                SlsMat JacMatB, void *user_dataB,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+static int fQB(realtype t, N_Vector y, N_Vector yB, 
+               N_Vector qBdot, void *user_dataB);
+
+
+/* Prototypes of private functions */
+
+static void PrintHead(realtype tB0);
+static void PrintOutput(realtype tfinal, N_Vector y, N_Vector yB, N_Vector qB);
+static void PrintOutput1(realtype time, realtype t, N_Vector y, N_Vector yB);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  UserData data;
+
+  void *cvode_mem;
+
+  realtype reltolQ, abstolQ;
+  N_Vector y, q;
+
+  int steps;
+
+  int indexB;
+
+  realtype reltolB, abstolB, abstolQB;
+  N_Vector yB, qB;
+
+  realtype time;
+  int flag, nthreads, nnz, ncheck;
+
+  long int nst, nstB;
+
+  CVadjCheckPointRec *ckpnt;
+
+  data = NULL;
+  cvode_mem = NULL;
+  ckpnt = NULL;
+  y = yB = qB = NULL;
+
+  /* Print problem description */
+  printf("\nAdjoint Sensitivity Example for Chemical Kinetics\n");
+  printf("-------------------------------------------------\n\n");
+  printf("ODE: dy1/dt = -p1*y1 + p2*y2*y3\n");
+  printf("     dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2\n");
+  printf("     dy3/dt =  p3*(y2)^2\n\n");
+  printf("Find dG/dp for\n");
+  printf("     G = int_t0^tB0 g(t,p,y) dt\n");
+  printf("     g(t,p,y) = y3\n\n\n");
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.04);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+
+  /* Initialize y */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+  Ith(y,1) = RCONST(1.0);
+  Ith(y,2) = ZERO;
+  Ith(y,3) = ZERO;
+
+  /* Initialize q */
+  q = N_VNew_Serial(1);
+  if (check_flag((void *)q, "N_VNew_Serial", 0)) return(1);
+  Ith(q,1) = ZERO;
+
+  /* Set the scalar realtive and absolute tolerances reltolQ and abstolQ */
+  reltolQ = RTOL;
+  abstolQ = ATOLq;
+
+  /* Create and allocate CVODES memory for forward run */
+  printf("Create and allocate CVODES memory for forward runs\n");
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+     Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+     user's right hand side function in y'=f(t,y), the initial time T0, and
+     the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeWFtolerances to specify a user-supplied function ewt that sets
+     the multiplicative error weights W_i for use in the weighted RMS norm */
+  flag = CVodeWFtolerances(cvode_mem, ewt);
+  if (check_flag(&flag, "CVodeWFtolerances", 1)) return(1);
+
+  /* Attach user data */
+  flag = CVodeSetUserData(cvode_mem, data);
+  if (check_flag(&flag, "CVodeSetUserData", 1)) return(1);
+
+  /* Call CVKLU to specify the CVKLU sparse direct linear solver */
+  nthreads = 1;                 /* no. of threads use when factoring the system */
+  nnz = NEQ * NEQ;              /* max no. of nonzeros entries in the Jac */
+  flag = CVSuperLUMT(cvode_mem, nthreads, NEQ, nnz);
+  if (check_flag(&flag, "CVSuperLUMT", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  /* Call CVodeQuadInit to allocate initernal memory and initialize
+     quadrature integration*/
+  flag = CVodeQuadInit(cvode_mem, fQ, q);
+  if (check_flag(&flag, "CVodeQuadInit", 1)) return(1);
+
+  /* Call CVodeSetQuadErrCon to specify whether or not the quadrature variables
+     are to be used in the step size control mechanism within CVODES. Call
+     CVodeQuadSStolerances or CVodeQuadSVtolerances to specify the integration
+     tolerances for the quadrature variables. */
+  flag = CVodeSetQuadErrCon(cvode_mem, TRUE);
+  if (check_flag(&flag, "CVodeSetQuadErrCon", 1)) return(1);
+
+  /* Call CVodeQuadSStolerances to specify scalar relative and absolute
+     tolerances. */
+  flag = CVodeQuadSStolerances(cvode_mem, reltolQ, abstolQ);
+  if (check_flag(&flag, "CVodeQuadSStolerances", 1)) return(1);
+
+  /* Allocate global memory */
+
+  /* Call CVodeAdjInit to update CVODES memory block by allocting the internal 
+     memory needed for backward integration.*/
+  steps = STEPS;             /* no. of integration steps between two
+                               consecutive ckeckpoints*/
+  flag = CVodeAdjInit(cvode_mem, steps, CV_HERMITE);
+  /*
+  flag = CVodeAdjInit(cvode_mem, steps, CV_POLYNOMIAL);
+  */
+  if (check_flag(&flag, "CVodeAdjInit", 1)) return(1);
+
+  /* Perform forward run */
+  printf("Forward integration ... ");
+
+  /* Call CVodeF to integrate the forward problem over an interval in time and
+     saves checkpointing data */
+  flag = CVodeF(cvode_mem, TOUT, y, &time, CV_NORMAL, &ncheck);
+  if (check_flag(&flag, "CVodeF", 1)) return(1);
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  if (check_flag(&flag, "CVodeGetNumSteps", 1)) return(1);
+
+  printf("done ( nst = %ld )\n",nst);
+  printf("\nncheck = %d\n\n", ncheck);
+
+  flag = CVodeGetQuad(cvode_mem, &time, q);
+  if (check_flag(&flag, "CVodeGetQuad", 1)) return(1);
+
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("G:          %12.4Le \n",Ith(q,1));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("G:          %12.4e \n",Ith(q,1));
+#else
+  printf("G:          %12.4e \n",Ith(q,1));
+#endif
+  printf("--------------------------------------------------------\n\n");
+
+  /* Test check point linked list 
+     (uncomment next block to print check point information) */
+  
+  /*
+  {
+    int i;
+    
+    printf("\nList of Check Points (ncheck = %d)\n\n", ncheck);
+    ckpnt = (CVadjCheckPointRec *) malloc ( (ncheck+1)*sizeof(CVadjCheckPointRec));
+    CVodeGetAdjCheckPointsInfo(cvode_mem, ckpnt);
+    for (i=0;i<=ncheck;i++) {
+      printf("Address:       %p\n",ckpnt[i].my_addr);
+      printf("Next:          %p\n",ckpnt[i].next_addr);
+      printf("Time interval: %le  %le\n",ckpnt[i].t0, ckpnt[i].t1);
+      printf("Step number:   %ld\n",ckpnt[i].nstep);
+      printf("Order:         %d\n",ckpnt[i].order);
+      printf("Step size:     %le\n",ckpnt[i].step);
+      printf("\n");
+    }
+    
+  }
+  */
+  
+  /* Initialize yB */
+  yB = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yB, "N_VNew_Serial", 0)) return(1);
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = ZERO;
+
+  /* Initialize qB */
+  qB = N_VNew_Serial(NP);
+  if (check_flag((void *)qB, "N_VNew", 0)) return(1);
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  /* Set the scalar relative tolerance reltolB */
+  reltolB = RTOL;               
+
+  /* Set the scalar absolute tolerance abstolB */
+  abstolB = ATOLl;
+
+  /* Set the scalar absolute tolerance abstolQB */
+  abstolQB = ATOLq;
+
+  /* Create and allocate CVODES memory for backward run */
+  printf("Create and allocate CVODES memory for backward run\n");
+
+  /* Call CVodeCreateB to specify the solution method for the backward 
+     problem. */
+  flag = CVodeCreateB(cvode_mem, CV_BDF, CV_NEWTON, &indexB);
+  if (check_flag(&flag, "CVodeCreateB", 1)) return(1);
+
+  /* Call CVodeInitB to allocate internal memory and initialize the 
+     backward problem. */
+  flag = CVodeInitB(cvode_mem, indexB, fB, TB1, yB);
+  if (check_flag(&flag, "CVodeInitB", 1)) return(1);
+
+  /* Set the scalar relative and absolute tolerances. */
+  flag = CVodeSStolerancesB(cvode_mem, indexB, reltolB, abstolB);
+  if (check_flag(&flag, "CVodeSStolerancesB", 1)) return(1);
+
+  /* Attach the user data for backward problem. */
+  flag = CVodeSetUserDataB(cvode_mem, indexB, data);
+  if (check_flag(&flag, "CVodeSetUserDataB", 1)) return(1);
+
+  /* Call CVKLUB to initialize the CVKLU sparse linear solver for the backward 
+     problem. */
+  flag = CVSuperLUMTB(cvode_mem, indexB, nthreads, NEQ, nnz);
+  if (check_flag(&flag, "CVSuperLUMTb", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) for the backward problem */
+  flag = CVSlsSetSparseJacFnB(cvode_mem, indexB, JacB);
+  if (check_flag(&flag, "CVSlsSetSparseJacFnB", 1)) return(1);
+
+  /* Call CVodeQuadInitB to allocate internal memory and initialize backward
+     quadrature integration. */
+  flag = CVodeQuadInitB(cvode_mem, indexB, fQB, qB);
+  if (check_flag(&flag, "CVodeQuadInitB", 1)) return(1);
+
+  /* Call CVodeSetQuadErrCon to specify whether or not the quadrature variables
+     are to be used in the step size control mechanism within CVODES. Call
+     CVodeQuadSStolerances or CVodeQuadSVtolerances to specify the integration
+     tolerances for the quadrature variables. */
+  flag = CVodeSetQuadErrConB(cvode_mem, indexB, TRUE);
+  if (check_flag(&flag, "CVodeSetQuadErrConB", 1)) return(1);
+
+  /* Call CVodeQuadSStolerancesB to specify the scalar relative and absolute tolerances
+     for the backward problem. */
+  flag = CVodeQuadSStolerancesB(cvode_mem, indexB, reltolB, abstolQB);
+  if (check_flag(&flag, "CVodeQuadSStolerancesB", 1)) return(1);
+
+  /* Backward Integration */
+
+  PrintHead(TB1);
+
+  /* First get results at t = TBout1 */
+
+  /* Call CVodeB to integrate the backward ODE problem. */
+  flag = CVodeB(cvode_mem, TBout1, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+
+  /* Call CVodeGetB to get yB of the backward ODE problem. */
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  /* Call CVodeGetAdjY to get the interpolated value of the forward solution
+     y during a backward integration. */
+  flag = CVodeGetAdjY(cvode_mem, TBout1, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput1(time, TBout1, y, yB);
+
+  /* Then at t = T0 */
+
+  flag = CVodeB(cvode_mem, T0, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+  CVodeGetNumSteps(CVodeGetAdjCVodeBmem(cvode_mem, indexB), &nstB);
+  printf("Done ( nst = %ld )\n", nstB);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  /* Call CVodeGetQuadB to get the quadrature solution vector after a 
+     successful return from CVodeB. */
+  flag = CVodeGetQuadB(cvode_mem, indexB, &time, qB);
+  if (check_flag(&flag, "CVodeGetQuadB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, T0, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput(time, y, yB, qB);
+
+  /* Reinitialize backward phase (new tB0) */
+
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = ZERO;
+
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  printf("Re-initialize CVODES memory for backward run\n");
+
+  flag = CVodeReInitB(cvode_mem, indexB, TB2, yB);
+  if (check_flag(&flag, "CVodeReInitB", 1)) return(1);
+
+  flag = CVodeQuadReInitB(cvode_mem, indexB, qB); 
+  if (check_flag(&flag, "CVodeQuadReInitB", 1)) return(1);
+
+  PrintHead(TB2);
+
+  /* First get results at t = TBout1 */
+
+  flag = CVodeB(cvode_mem, TBout1, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, TBout1, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput1(time, TBout1, y, yB);
+
+  /* Then at t = T0 */
+
+  flag = CVodeB(cvode_mem, T0, CV_NORMAL);
+  if (check_flag(&flag, "CVodeB", 1)) return(1);
+  CVodeGetNumSteps(CVodeGetAdjCVodeBmem(cvode_mem, indexB), &nstB);
+  printf("Done ( nst = %ld )\n", nstB);
+
+  flag = CVodeGetB(cvode_mem, indexB, &time, yB);
+  if (check_flag(&flag, "CVodeGetB", 1)) return(1);
+
+  flag = CVodeGetQuadB(cvode_mem, indexB, &time, qB);
+  if (check_flag(&flag, "CVodeGetQuadB", 1)) return(1);
+
+  flag = CVodeGetAdjY(cvode_mem, T0, y);
+  if (check_flag(&flag, "CVodeGetAdjY", 1)) return(1);
+
+  PrintOutput(time, y, yB, qB);
+
+  /* Free memory */
+  printf("Free memory\n\n");
+
+  CVodeFree(&cvode_mem);
+  N_VDestroy_Serial(y); 
+  N_VDestroy_Serial(q);
+  N_VDestroy_Serial(yB);
+  N_VDestroy_Serial(qB);
+
+  if (ckpnt != NULL) free(ckpnt);
+  free(data);
+
+  return(0);
+
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY CVODES
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * f routine. Compute f(t,y). 
+*/
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+  UserData data;
+  realtype p1, p2, p3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  yd1 = Ith(ydot,1) = -p1*y1 + p2*y2*y3;
+  yd3 = Ith(ydot,3) = p3*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+*/
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(y);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+  
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = -p1;                          rowvals[0] = 0;
+  data[1] = p1;                           rowvals[1] = 1;
+  data[2] = ZERO;                         rowvals[2] = 2;
+
+  data[3] = p2*yval[2];                   rowvals[3] = 0;
+  data[4] = -p2*yval[2]-2*p3*yval[1];     rowvals[4] = 1;
+  data[5] = 2*yval[1];                    rowvals[5] = 2;
+  
+  data[6] = p2*yval[1];                   rowvals[6] = 0;
+  data[7] = -p2*yval[1];                  rowvals[7] = 1;
+  data[8] = ZERO;                         rowvals[8] = 2;
+
+  return(0);
+}
+
+/* 
+ * fQ routine. Compute fQ(t,y). 
+*/
+
+static int fQ(realtype t, N_Vector y, N_Vector qdot, void *user_data)
+{
+  Ith(qdot,1) = Ith(y,3);  
+
+  return(0);
+}
+ 
+/*
+ * EwtSet function. Computes the error weights at the current solution.
+ */
+
+static int ewt(N_Vector y, N_Vector w, void *user_data)
+{
+  int i;
+  realtype yy, ww, rtol, atol[3];
+
+  rtol    = RTOL;
+  atol[0] = ATOL1;
+  atol[1] = ATOL2;
+  atol[2] = ATOL3;
+
+  for (i=1; i<=3; i++) {
+    yy = Ith(y,i);
+    ww = rtol * SUNRabs(yy) + atol[i-1];
+    if (ww <= 0.0) return (-1);
+    Ith(w,i) = 1.0/ww;
+  }
+
+  return(0);
+}
+
+/* 
+ * fB routine. Compute fB(t,y,yB). 
+*/
+
+static int fB(realtype t, N_Vector y, N_Vector yB, N_Vector yBdot, void *user_dataB)
+{
+  UserData data;
+  realtype y2, y3;
+  realtype p1, p2, p3;
+  realtype l1, l2, l3;
+  realtype l21, l32;
+  
+  data = (UserData) user_dataB;
+
+  /* The p vector */
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  /* The y vector */ 
+  y2 = Ith(y,2); y3 = Ith(y,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yB,1); l2 = Ith(yB,2); l3 = Ith(yB,3);
+
+  /* Temporary variables */
+  l21 = l2-l1;
+  l32 = l3-l2;
+
+  /* Load yBdot */
+  Ith(yBdot,1) = - p1*l21;
+  Ith(yBdot,2) = p2*y3*l21 - RCONST(2.0)*p3*y2*l32;
+  Ith(yBdot,3) = p2*y2*l21 - RCONST(1.0);
+
+  return(0);
+}
+
+/* 
+ * JacB routine. Compute JB(t,y,yB). 
+ */
+
+static int JacB(realtype t,
+                N_Vector y, N_Vector yB, N_Vector fyB,
+                SlsMat JacMatB, void *user_dataB,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  realtype *yvalB;
+  int* colptrsB;
+  int* rowvalsB;
+  realtype* dataB;
+  UserData userdata;
+  realtype p1, p2, p3;
+
+  yvalB = N_VGetArrayPointer_Serial(y);
+  colptrsB = (*JacMatB->colptrs);
+  rowvalsB = (*JacMatB->rowvals);
+  dataB = JacMatB->data;
+  userdata = (UserData) user_dataB;
+
+  /* The p vector */
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMatB);
+  
+  /* Load JB */
+  colptrsB[0] = 0;
+  colptrsB[1] = 3;
+  colptrsB[2] = 6;
+  colptrsB[3] = 9;
+
+  dataB[0] = p1;                           rowvalsB[0] = 0;
+  dataB[1] = -p2*yvalB[2];                 rowvalsB[1] = 1;
+  dataB[2] = -p2*yvalB[1];                 rowvalsB[2] = 2;
+
+  dataB[3] =-p1;                           rowvalsB[3] = 0;
+  dataB[4] = p2*yvalB[2]+2*p3*yvalB[1];    rowvalsB[4] = 1;
+  dataB[5] = p2*yvalB[1];                  rowvalsB[5] = 2;
+  
+  dataB[6] = ZERO;                         rowvalsB[6] = 0;
+  dataB[7] = RCONST(-2.0)*p3*yvalB[1];     rowvalsB[7] = 1;
+  dataB[8] = ZERO;                         rowvalsB[8] = 2;
+
+  return(0);
+}
+
+/*
+ * fQB routine. Compute integrand for quadratures 
+*/
+
+static int fQB(realtype t, N_Vector y, N_Vector yB, 
+               N_Vector qBdot, void *user_dataB)
+{
+  realtype y1, y2, y3;
+  realtype l1, l2, l3;
+  realtype l21, l32, y23;
+
+  /* The y vector */
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yB,1); l2 = Ith(yB,2); l3 = Ith(yB,3);
+
+  /* Temporary variables */
+  l21 = l2-l1;
+  l32 = l3-l2;
+  y23 = y2*y3;
+
+  Ith(qBdot,1) = y1*l21;
+  Ith(qBdot,2) = - y23*l21;
+  Ith(qBdot,3) = y2*y2*l32;
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Print heading for backward integration
+ */
+
+static void PrintHead(realtype tB0)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Backward integration from tB0 = %12.4Le\n\n",tB0);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Backward integration from tB0 = %12.4e\n\n",tB0);
+#else
+  printf("Backward integration from tB0 = %12.4e\n\n",tB0);
+#endif
+}
+
+/*
+ * Print intermediate results during backward integration
+ */
+
+static void PrintOutput1(realtype time, realtype t, N_Vector y, N_Vector yB)
+{
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("returned t: %12.4Le\n",time);
+  printf("tout:       %12.4Le\n",t);
+  printf("lambda(t):  %12.4Le %12.4Le %12.4Le\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t):       %12.4Le %12.4Le %12.4Le\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("returned t: %12.4e\n",time);
+  printf("tout:       %12.4e\n",t);
+  printf("lambda(t):  %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t):       %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+#else
+  printf("returned t: %12.4e\n",time);
+  printf("tout:       %12.4e\n",t);
+  printf("lambda(t):  %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t)      : %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+#endif
+  printf("--------------------------------------------------------\n\n");
+}
+
+/*
+ * Print final results of backward integration
+ */
+
+static void PrintOutput(realtype tfinal, N_Vector y, N_Vector yB, N_Vector qB)
+{
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("returned t: %12.4Le\n",tfinal);
+  printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0):      %12.4Le %12.4Le %12.4Le\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4Le %12.4Le %12.4Le\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("returned t: %12.4e\n",tfinal);
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0):      %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#else
+  printf("returned t: %12.4e\n",tfinal);
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+  printf("y(t0)     : %12.4e %12.4e %12.4e\n", 
+         Ith(y,1), Ith(y,2), Ith(y,3));
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+#endif
+  printf("--------------------------------------------------------\n\n");
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_sps.out b/examples/cvodes/serial/cvsRoberts_ASAi_sps.out
new file mode 100644
index 0000000..18fee9d
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_ASAi_sps.out
@@ -0,0 +1,60 @@
+
+Adjoint Sensitivity Example for Chemical Kinetics
+-------------------------------------------------
+
+ODE: dy1/dt = -p1*y1 + p2*y2*y3
+     dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
+     dy3/dt =  p3*(y2)^2
+
+Find dG/dp for
+     G = int_t0^tB0 g(t,p,y) dt
+     g(t,p,y) = y3
+
+
+Create and allocate CVODES memory for forward runs
+Forward integration ... done ( nst = 829 )
+
+ncheck = 5
+
+--------------------------------------------------------
+G:            3.9983e+07 
+--------------------------------------------------------
+
+Create and allocate CVODES memory for backward run
+Backward integration from tB0 =   4.0000e+07
+
+--------------------------------------------------------
+returned t:   4.0000e+01
+tout:         4.0000e+01
+lambda(t):    3.9967e+07   3.9967e+07   3.9967e+07
+y(t):         7.1583e-01   9.1856e-06   2.8416e-01
+--------------------------------------------------------
+
+Done ( nst = 214 )
+--------------------------------------------------------
+returned t:   0.0000e+00
+lambda(t0):   3.9967e+07   3.9967e+07   3.9967e+07
+y(t0):        1.0000e+00   0.0000e+00   0.0000e+00
+dG/dp:        7.6843e+05  -3.0691e+00   5.1149e-04
+--------------------------------------------------------
+
+Re-initialize CVODES memory for backward run
+Backward integration from tB0 =   5.0000e+01
+
+--------------------------------------------------------
+returned t:   4.0000e+01
+tout:         4.0000e+01
+lambda(t):    2.8959e-01   1.7624e+00   9.3567e+00
+y(t):         7.1583e-01   9.1856e-06   2.8416e-01
+--------------------------------------------------------
+
+Done ( nst = 202 )
+--------------------------------------------------------
+returned t:   0.0000e+00
+lambda(t0):   8.4190e+00   1.6097e+01   1.6097e+01
+y(t0):        1.0000e+00   0.0000e+00   0.0000e+00
+dG/dp:        1.7341e+02  -5.0590e-04   8.4320e-08
+--------------------------------------------------------
+
+Free memory
+
diff --git a/examples/cvodes/serial/cvsRoberts_FSA_dns.c b/examples/cvodes/serial/cvsRoberts_FSA_dns.c
index 27084ef..7d6aa08 100644
--- a/examples/cvodes/serial/cvsRoberts_FSA_dns.c
+++ b/examples/cvodes/serial/cvsRoberts_FSA_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:58:00 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, and
  *                Radu Serban @ LLNL
@@ -110,7 +110,7 @@ static void WrongArgs(char *name);
 static void PrintOutput(void *cvode_mem, realtype t, N_Vector u);
 static void PrintOutputS(N_Vector *uS);
 static void PrintFinalStats(void *cvode_mem, booleantype sensi);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -374,7 +374,7 @@ static int ewt(N_Vector y, N_Vector w, void *user_data)
 
   for (i=1; i<=3; i++) {
     yy = Ith(y,i);
-    ww = rtol * ABS(yy) + atol[i-1];  
+    ww = rtol * SUNRabs(yy) + atol[i-1];
     if (ww <= 0.0) return (-1);
     Ith(w,i) = 1.0/ww;
   }
@@ -451,7 +451,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector u)
   int qu, flag;
   realtype hu, *udata;
   
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = CVodeGetNumSteps(cvode_mem, &nst);
   check_flag(&flag, "CVodeGetNumSteps", 1);
@@ -463,7 +463,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%8.3Le %2d  %8.3Le %5ld\n", t, qu, hu, nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%8.3le %2d  %8.3le %5ld\n", t, qu, hu, nst);
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
 #else
   printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
 #endif
@@ -473,7 +473,7 @@ static void PrintOutput(void *cvode_mem, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", udata[0], udata[1], udata[2]);
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
 #endif
@@ -488,35 +488,35 @@ static void PrintOutputS(N_Vector *uS)
 {
   realtype *sdata;
 
-  sdata = NV_DATA_S(uS[0]);
+  sdata = N_VGetArrayPointer_Serial(uS[0]);
   printf("                  Sensitivity 1  ");
 
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
   
-  sdata = NV_DATA_S(uS[1]);
+  sdata = N_VGetArrayPointer_Serial(uS[1]);
   printf("                  Sensitivity 2  ");
 
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
 
-  sdata = NV_DATA_S(uS[2]);
+  sdata = N_VGetArrayPointer_Serial(uS[2]);
   printf("                  Sensitivity 3  ");
 
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
@@ -595,7 +595,7 @@ static void PrintFinalStats(void *cvode_mem, booleantype sensi)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsRoberts_FSA_klu.c b/examples/cvodes/serial/cvsRoberts_FSA_klu.c
new file mode 100644
index 0000000..cac5025
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_FSA_klu.c
@@ -0,0 +1,672 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date: $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on cvsRoberts_FSA_dns.c and modified to use KLU
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODES for Forward Sensitivity 
+ * Analysis. The problem is from chemical kinetics, and consists
+ * of the following three rate equations:
+ *    dy1/dt = -p1*y1 + p2*y2*y3
+ *    dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
+ *    dy3/dt =  p3*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions y1 = 1.0, y2 = y3 = 0. The reaction rates are: p1=0.04,
+ * p2=1e4, and p3=3e7. The problem is stiff.
+ * This program solves the problem with the BDF method, Newton
+ * iteration with the CVODES KLU linear solver, and a
+ * user-supplied Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance.
+ * Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ *
+ * Optionally, CVODES can compute sensitivities with respect to the
+ * problem parameters p1, p2, and p3.
+ * The sensitivity right hand side is given analytically through the
+ * user routine fS (of type SensRhs1Fn).
+ * Any of three sensitivity methods (SIMULTANEOUS, STAGGERED, and
+ * STAGGERED1) can be used and sensitivities may be included in the
+ * error test or not (error control set on TRUE or FALSE,
+ * respectively).
+ *
+ * Execution:
+ *
+ * If no sensitivities are desired:
+ *    % cvsRoberts_FSA_klu -nosensi
+ * If sensitivities are to be computed:
+ *    % cvsRoberts_FSA_klu -sensi sensi_meth err_con
+ * where sensi_meth is one of {sim, stg, stg1} and err_con is one of
+ * {t, f}.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Header files with a description of contents used */
+
+#include <cvodes/cvodes.h>             /* prototypes for CVODES fcts. and consts. */
+#include <cvodes/cvodes_klu.h>         /* prototypes for CVKLU fcts. and constants */
+#include <sundials/sundials_sparse.h>  /* definitions SlsMat */
+#include <nvector/nvector_serial.h>    /* defs. of serial NVECTOR fcts. and macros */
+#include <sundials/sundials_types.h>   /* def. of type realtype */
+#include <sundials/sundials_math.h>    /* definition of ABS */
+
+/* Accessor macros */
+/* These macros are defined in order to write code with which exactly matched
+   the mathematical problem description given above.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component i=1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ   3             /* number of equations  */
+#define Y1    RCONST(1.0)   /* initial y components */
+#define Y2    RCONST(0.0)
+#define Y3    RCONST(0.0)
+#define RTOL  RCONST(1e-4)  /* scalar relative tolerance */
+#define ATOL1 RCONST(1e-8)  /* vector absolute tolerance components */
+#define ATOL2 RCONST(1e-14)
+#define ATOL3 RCONST(1e-6)
+#define T0    RCONST(0.0)   /* initial time */
+#define T1    RCONST(0.4)   /* first output time */
+#define TMULT RCONST(10.0)  /* output time factor */
+#define NOUT  12            /* number of output times */
+
+#define NP    3             /* number of problem parameters */
+#define NS    3             /* number of sensitivities computed */
+
+#define ZERO  RCONST(0.0)
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];           /* problem parameters */
+} *UserData;
+
+/* Prototypes of functions by CVODES */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int fS(int Ns, realtype t, N_Vector y, N_Vector ydot, 
+              int iS, N_Vector yS, N_Vector ySdot, 
+              void *user_data, N_Vector tmp1, N_Vector tmp2);
+
+static int ewt(N_Vector y, N_Vector w, void *user_data);
+
+/* Prototypes of private functions */
+
+static void ProcessArgs(int argc, char *argv[],
+                        booleantype *sensi, int *sensi_meth, 
+                        booleantype *err_con);
+static void WrongArgs(char *name);
+static void PrintOutput(void *cvode_mem, realtype t, N_Vector u);
+static void PrintOutputS(N_Vector *uS);
+static void PrintFinalStats(void *cvode_mem, booleantype sensi);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  void *cvode_mem;
+  UserData data;
+  realtype t, tout;
+  N_Vector y;
+  int iout, flag, nnz;
+
+  realtype pbar[NS];
+  int is; 
+  N_Vector *yS;
+  booleantype sensi, err_con;
+  int sensi_meth;
+
+  cvode_mem = NULL;
+  data      = NULL;
+  y         = NULL;
+  yS        = NULL;
+
+  /* Process arguments */
+  ProcessArgs(argc, argv, &sensi, &sensi_meth, &err_con);
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.04);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+
+  /* Initial conditions */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+
+  Ith(y,1) = Y1;
+  Ith(y,2) = Y2;
+  Ith(y,3) = Y3;
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+     Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+     user's right hand side function in y'=f(t,y), the initial time T0, and
+     the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeWFtolerances to specify a user-supplied function ewt that sets
+     the multiplicative error weights W_i for use in the weighted RMS norm */
+  flag = CVodeWFtolerances(cvode_mem, ewt);
+  if (check_flag(&flag, "CVodeSetEwtFn", 1)) return(1);
+
+  /* Attach user data */
+  flag = CVodeSetUserData(cvode_mem, data);
+  if (check_flag(&flag, "CVodeSetUserData", 1)) return(1);
+
+  /* Call CVKLU to specify the CVKLU sparse direct linear solver */
+  nnz = NEQ * NEQ;              /* max no. of nonzeros entries in the Jac */
+  flag = CVKLU(cvode_mem, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "CVKLU", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  printf("\n3-species chemical kinetics problem\n");
+
+  /* Sensitivity-related settings */
+  if (sensi) {
+
+    /* Set parameter scaling factor */
+    pbar[0] = data->p[0];
+    pbar[1] = data->p[1];
+    pbar[2] = data->p[2];
+
+    /* Set sensitivity initial conditions */
+    yS = N_VCloneVectorArray_Serial(NS, y);
+    if (check_flag((void *)yS, "N_VCloneVectorArray_Serial", 0)) return(1);
+    for (is=0;is<NS;is++) N_VConst(ZERO, yS[is]);
+
+    /* Call CVodeSensInit1 to activate forward sensitivity computations
+       and allocate internal memory for COVEDS related to sensitivity
+       calculations. Computes the right-hand sides of the sensitivity
+       ODE, one at a time */
+    flag = CVodeSensInit1(cvode_mem, NS, sensi_meth, fS, yS);
+    if(check_flag(&flag, "CVodeSensInit", 1)) return(1);
+
+    /* Call CVodeSensEEtolerances to estimate tolerances for sensitivity 
+       variables based on the rolerances supplied for states variables and 
+       the scaling factor pbar */
+    flag = CVodeSensEEtolerances(cvode_mem);
+    if(check_flag(&flag, "CVodeSensEEtolerances", 1)) return(1);
+
+    /* Set sensitivity analysis optional inputs */
+    /* Call CVodeSetSensErrCon to specify the error control strategy for 
+       sensitivity variables */
+    flag = CVodeSetSensErrCon(cvode_mem, err_con);
+    if (check_flag(&flag, "CVodeSetSensErrCon", 1)) return(1);
+
+    /* Call CVodeSetSensParams to specify problem parameter information for 
+       sensitivity calculations */
+    flag = CVodeSetSensParams(cvode_mem, NULL, pbar, NULL);
+    if (check_flag(&flag, "CVodeSetSensParams", 1)) return(1);
+
+    printf("Sensitivity: YES ");
+    if(sensi_meth == CV_SIMULTANEOUS)   
+      printf("( SIMULTANEOUS +");
+    else 
+      if(sensi_meth == CV_STAGGERED) printf("( STAGGERED +");
+      else                           printf("( STAGGERED1 +");   
+    if(err_con) printf(" FULL ERROR CONTROL )");
+    else        printf(" PARTIAL ERROR CONTROL )");
+
+  } else {
+
+    printf("Sensitivity: NO ");
+
+  }
+  
+  /* In loop over output points, call CVode, print results, test for error */
+  
+  printf("\n\n");
+  printf("===========================================");
+  printf("============================\n");
+  printf("     T     Q       H      NST           y1");
+  printf("           y2           y3    \n");
+  printf("===========================================");
+  printf("============================\n");
+
+  for (iout=1, tout=T1; iout <= NOUT; iout++, tout *= TMULT) {
+
+    flag = CVode(cvode_mem, tout, y, &t, CV_NORMAL);
+    if (check_flag(&flag, "CVode", 1)) break;
+
+    PrintOutput(cvode_mem, t, y);
+
+    /* Call CVodeGetSens to get the sensitivity solution vector after a
+       successful return from CVode */
+    if (sensi) {
+      flag = CVodeGetSens(cvode_mem, &t, yS);
+      if (check_flag(&flag, "CVodeGetSens", 1)) break;
+      PrintOutputS(yS);
+    } 
+    printf("-----------------------------------------");
+    printf("------------------------------\n");
+
+  }
+
+  /* Print final statistics */
+  PrintFinalStats(cvode_mem, sensi);
+
+  /* Free memory */
+
+  N_VDestroy_Serial(y);                    /* Free y vector */
+  if (sensi) {
+    N_VDestroyVectorArray_Serial(yS, NS);  /* Free yS vector */
+  }
+  free(data);                              /* Free user data */
+  CVodeFree(&cvode_mem);                   /* Free CVODES memory */
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY CVODES
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * f routine. Compute f(t,y). 
+ */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+  UserData data;
+  realtype p1, p2, p3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  yd1 = Ith(ydot,1) = -p1*y1 + p2*y2*y3;
+  yd3 = Ith(ydot,3) = p3*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+ */
+
+static int Jac(realtype t,
+	       N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(y);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+  
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = -p1;                          rowvals[0] = 0;
+  data[1] = p1;                           rowvals[1] = 1;
+  data[2] = ZERO;                         rowvals[2] = 2;
+
+  data[3] = p2*yval[2];                   rowvals[3] = 0;
+  data[4] = -p2*yval[2]-2*p3*yval[1];     rowvals[4] = 1;
+  data[5] = 2*yval[1];                    rowvals[5] = 2;
+  
+  data[6] = p2*yval[1];                   rowvals[6] = 0;
+  data[7] = -p2*yval[1];                  rowvals[7] = 1;
+  data[8] = ZERO;                         rowvals[8] = 2;
+ 
+  return(0);
+}
+ 
+/* 
+ * fS routine. Compute sensitivity r.h.s. CVSensRhs1Fn is compatible with any
+ * valid value of the argument ism to CVodeSensInit and CVodeSensInit1
+ */
+
+static int fS(int Ns, realtype t, N_Vector y, N_Vector ydot, 
+              int iS, N_Vector yS, N_Vector ySdot, 
+              void *user_data, N_Vector tmp1, N_Vector tmp2)
+{
+  UserData data;
+  realtype p1, p2, p3;
+  realtype y1, y2, y3;
+  realtype s1, s2, s3;
+  realtype sd1, sd2, sd3;
+
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  y1 = Ith(y,1);  y2 = Ith(y,2);  y3 = Ith(y,3);
+  s1 = Ith(yS,1); s2 = Ith(yS,2); s3 = Ith(yS,3);
+
+  sd1 = -p1*s1 + p2*y3*s2 + p2*y2*s3;
+  sd3 = 2*p3*y2*s2;
+  sd2 = -sd1-sd3;
+
+  switch (iS) {
+  case 0:
+    sd1 += -y1;
+    sd2 +=  y1;
+    break;
+  case 1:
+    sd1 +=  y2*y3;
+    sd2 += -y2*y3;
+    break;
+  case 2:
+    sd2 += -y2*y2;
+    sd3 +=  y2*y2;
+    break;
+  }
+  
+  Ith(ySdot,1) = sd1;
+  Ith(ySdot,2) = sd2;
+  Ith(ySdot,3) = sd3;
+
+  return(0);
+}
+
+/*
+ * EwtSet function. Computes the error weights at the current solution.
+ */
+
+static int ewt(N_Vector y, N_Vector w, void *user_data)
+{
+  int i;
+  realtype yy, ww, rtol, atol[3];
+
+  rtol    = RTOL;
+  atol[0] = ATOL1;
+  atol[1] = ATOL2;
+  atol[2] = ATOL3;
+
+  for (i=1; i<=3; i++) {
+    yy = Ith(y,i);
+    ww = rtol * SUNRabs(yy) + atol[i-1];
+    if (ww <= 0.0) return (-1);
+    Ith(w,i) = 1.0/ww;
+  }
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Process and verify arguments to cvsfwddenx.
+ */
+
+static void ProcessArgs(int argc, char *argv[], 
+                        booleantype *sensi, int *sensi_meth, booleantype *err_con)
+{
+  *sensi = FALSE;
+  *sensi_meth = -1;
+  *err_con = FALSE;
+
+  if (argc < 2) WrongArgs(argv[0]);
+
+  if (strcmp(argv[1],"-nosensi") == 0)
+    *sensi = FALSE;
+  else if (strcmp(argv[1],"-sensi") == 0)
+    *sensi = TRUE;
+  else
+    WrongArgs(argv[0]);
+  
+  if (*sensi) {
+
+    if (argc != 4)
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[2],"sim") == 0)
+      *sensi_meth = CV_SIMULTANEOUS;
+    else if (strcmp(argv[2],"stg") == 0)
+      *sensi_meth = CV_STAGGERED;
+    else if (strcmp(argv[2],"stg1") == 0)
+      *sensi_meth = CV_STAGGERED1;
+    else 
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[3],"t") == 0)
+      *err_con = TRUE;
+    else if (strcmp(argv[3],"f") == 0)
+      *err_con = FALSE;
+    else
+      WrongArgs(argv[0]);
+  }
+
+}
+
+static void WrongArgs(char *name)
+{
+    printf("\nUsage: %s [-nosensi] [-sensi sensi_meth err_con]\n",name);
+    printf("         sensi_meth = sim, stg, or stg1\n");
+    printf("         err_con    = t or f\n");
+    
+    exit(0);
+}
+
+/*
+ * Print current t, step count, order, stepsize, and solution.
+ */
+
+static void PrintOutput(void *cvode_mem, realtype t, N_Vector u)
+{
+  long int nst;
+  int qu, flag;
+  realtype hu, *udata;
+  
+  udata = N_VGetArrayPointer_Serial(u);
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetLastOrder(cvode_mem, &qu);
+  check_flag(&flag, "CVodeGetLastOrder", 1);
+  flag = CVodeGetLastStep(cvode_mem, &hu);
+  check_flag(&flag, "CVodeGetLastStep", 1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%8.3Le %2d  %8.3Le %5ld\n", t, qu, hu, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#else
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#endif
+
+  printf("                  Solution       ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#endif
+
+}
+
+/* 
+ * Print sensitivities.
+*/
+
+static void PrintOutputS(N_Vector *uS)
+{
+  realtype *sdata;
+
+  sdata = N_VGetArrayPointer_Serial(uS[0]);
+  printf("                  Sensitivity 1  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  
+  sdata = N_VGetArrayPointer_Serial(uS[1]);
+  printf("                  Sensitivity 2  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+  sdata = N_VGetArrayPointer_Serial(uS[2]);
+  printf("                  Sensitivity 3  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+}
+
+/* 
+ * Print some final statistics from the CVODES memory.
+ */
+
+static void PrintFinalStats(void *cvode_mem, booleantype sensi)
+{
+  long int nst;
+  long int nfe, nsetups, nni, ncfn, netf;
+  long int nfSe, nfeS, nsetupsS, nniS, ncfnS, netfS;
+  long int nje;
+  int flag;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  if (sensi) {
+    flag = CVodeGetSensNumRhsEvals(cvode_mem, &nfSe);
+    check_flag(&flag, "CVodeGetSensNumRhsEvals", 1);
+    flag = CVodeGetNumRhsEvalsSens(cvode_mem, &nfeS);
+    check_flag(&flag, "CVodeGetNumRhsEvalsSens", 1);
+    flag = CVodeGetSensNumLinSolvSetups(cvode_mem, &nsetupsS);
+    check_flag(&flag, "CVodeGetSensNumLinSolvSetups", 1);
+    flag = CVodeGetSensNumErrTestFails(cvode_mem, &netfS);
+    check_flag(&flag, "CVodeGetSensNumErrTestFails", 1);
+    flag = CVodeGetSensNumNonlinSolvIters(cvode_mem, &nniS);
+    check_flag(&flag, "CVodeGetSensNumNonlinSolvIters", 1);
+    flag = CVodeGetSensNumNonlinSolvConvFails(cvode_mem, &ncfnS);
+    check_flag(&flag, "CVodeGetSensNumNonlinSolvConvFails", 1);
+  }
+
+  flag = CVSlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVDlsGetNumJacEvals", 1);
+
+  printf("\nFinal Statistics\n\n");
+  printf("nst     = %5ld\n\n", nst);
+  printf("nfe     = %5ld\n",   nfe);
+  printf("netf    = %5ld    nsetups  = %5ld\n", netf, nsetups);
+  printf("nni     = %5ld    ncfn     = %5ld\n", nni, ncfn);
+
+  if(sensi) {
+    printf("\n");
+    printf("nfSe    = %5ld    nfeS     = %5ld\n", nfSe, nfeS);
+    printf("netfs   = %5ld    nsetupsS = %5ld\n", netfS, nsetupsS);
+    printf("nniS    = %5ld    ncfnS    = %5ld\n", nniS, ncfnS);
+  }
+
+  printf("\n");
+  printf("nje    = %5ld\n", nje);
+
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvodes/serial/cvsRoberts_FSA_klu.out b/examples/cvodes/serial/cvsRoberts_FSA_klu.out
new file mode 100644
index 0000000..d14b7c5
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_FSA_klu.out
@@ -0,0 +1,93 @@
+
+3-species chemical kinetics problem
+Sensitivity: YES ( STAGGERED1 + FULL ERROR CONTROL )
+
+=======================================================================
+     T     Q       H      NST           y1           y2           y3    
+=======================================================================
+4.000e-01  3  5.292e-02   105
+                  Solution         9.8517e-01   3.3864e-05   1.4794e-02 
+                  Sensitivity 1   -3.5595e-01   3.9025e-04   3.5556e-01 
+                  Sensitivity 2    9.5428e-08  -2.1309e-10  -9.5216e-08 
+                  Sensitivity 3   -1.5833e-11  -5.2900e-13   1.6360e-11 
+-----------------------------------------------------------------------
+4.000e+00  4  2.108e-01   140
+                  Solution         9.0552e-01   2.2405e-05   9.4458e-02 
+                  Sensitivity 1   -1.8761e+00   1.7922e-04   1.8759e+00 
+                  Sensitivity 2    2.9614e-06  -5.8304e-10  -2.9609e-06 
+                  Sensitivity 3   -4.9334e-10  -2.7627e-13   4.9366e-10 
+-----------------------------------------------------------------------
+4.000e+01  3  1.956e+00   301
+                  Solution         7.1581e-01   9.1847e-06   2.8419e-01 
+                  Sensitivity 1   -4.2478e+00   4.5905e-05   4.2478e+00 
+                  Sensitivity 2    1.3732e-05  -2.3568e-10  -1.3732e-05 
+                  Sensitivity 3   -2.2887e-09  -1.1379e-13   2.2885e-09 
+-----------------------------------------------------------------------
+4.000e+02  3  1.291e+01   477
+                  Solution         4.5052e-01   3.2228e-06   5.4950e-01 
+                  Sensitivity 1   -5.9585e+00   3.5421e-06   5.9586e+00 
+                  Sensitivity 2    2.2738e-05  -2.2602e-11  -2.2739e-05 
+                  Sensitivity 3   -3.7899e-09  -4.9948e-14   3.7896e-09 
+-----------------------------------------------------------------------
+4.000e+03  2  1.534e+02   684
+                  Solution         1.8317e-01   8.9399e-07   8.1688e-01 
+                  Sensitivity 1   -4.7501e+00  -5.9960e-06   4.7503e+00 
+                  Sensitivity 2    1.8809e-05   2.3136e-11  -1.8811e-05 
+                  Sensitivity 3   -3.1351e-09  -1.8756e-14   3.1343e-09 
+-----------------------------------------------------------------------
+4.000e+04  3  1.457e+03   768
+                  Solution         3.8988e-02   1.6219e-07   9.6106e-01 
+                  Sensitivity 1   -1.5751e+00  -2.7622e-06   1.5752e+00 
+                  Sensitivity 2    6.2881e-06   1.1003e-11  -6.2904e-06 
+                  Sensitivity 3   -1.0481e-09  -4.5370e-15   1.0472e-09 
+-----------------------------------------------------------------------
+4.000e+05  5  2.201e+04   818
+                  Solution         4.9386e-03   1.9850e-08   9.9512e-01 
+                  Sensitivity 1   -2.3636e-01  -4.5845e-07   2.3630e-01 
+                  Sensitivity 2    9.4511e-07   1.8326e-12  -9.4684e-07 
+                  Sensitivity 3   -1.5757e-10  -6.3647e-16   1.5641e-10 
+-----------------------------------------------------------------------
+4.000e+06  4  1.656e+05   881
+                  Solution         5.1683e-04   2.0683e-09   9.9954e-01 
+                  Sensitivity 1   -2.5666e-02  -5.1058e-08   2.5621e-02 
+                  Sensitivity 2    1.0266e-07   2.0423e-13  -1.0447e-07 
+                  Sensitivity 3   -1.7114e-11  -6.8519e-17   1.5882e-11 
+-----------------------------------------------------------------------
+4.000e+07  4  1.537e+06   926
+                  Solution         5.2040e-05   2.0816e-10   1.0000e+00 
+                  Sensitivity 1   -2.5995e-03  -5.1947e-09   2.5517e-03 
+                  Sensitivity 2    1.0397e-08   2.0777e-14  -1.2198e-08 
+                  Sensitivity 3   -1.7333e-12  -6.9332e-18   4.9916e-13 
+-----------------------------------------------------------------------
+4.000e+08  4  2.510e+07   974
+                  Solution         5.2097e-06   2.0838e-11   1.0001e+00 
+                  Sensitivity 1   -2.6038e-04  -5.2053e-10   2.1191e-04 
+                  Sensitivity 2    1.0415e-09   2.0822e-15  -2.8384e-09 
+                  Sensitivity 3   -1.7365e-13  -6.9455e-19  -1.0608e-12 
+-----------------------------------------------------------------------
+4.000e+09  3  3.386e+08  1031
+                  Solution         5.2245e-07   2.0897e-12   1.0001e+00 
+                  Sensitivity 1   -2.5985e-05  -5.1694e-11  -2.2327e-05 
+                  Sensitivity 2    1.0386e-10   2.0645e-16  -1.8998e-09 
+                  Sensitivity 3   -1.7391e-14  -6.9557e-20  -1.2177e-12 
+-----------------------------------------------------------------------
+4.000e+10  4  1.149e+09  1059
+                  Solution         5.8778e-08   2.3510e-13   1.0001e+00 
+                  Sensitivity 1   -2.4981e-06  -4.1144e-12  -4.6026e-05 
+                  Sensitivity 2    1.1746e-11   2.3472e-17  -1.8018e-09 
+                  Sensitivity 3   -2.2674e-15  -9.0689e-21  -1.2348e-12 
+-----------------------------------------------------------------------
+
+Final Statistics
+
+nst     =  1059
+
+nfe     =  2521
+netf    =     0    nsetups  =   260
+nni     =  1335    ncfn     =     0
+
+nfSe    =  4365    nfeS     =     0
+netfs   =   123    nsetupsS =     0
+nniS    =  4353    ncfnS    =     0
+
+nje    =    19
diff --git a/examples/cvodes/serial/cvsRoberts_FSA_sps.c b/examples/cvodes/serial/cvsRoberts_FSA_sps.c
new file mode 100644
index 0000000..9644ead
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_FSA_sps.c
@@ -0,0 +1,673 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date: $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on cvsRoberts_FSA_dns.c and modified to use SUPERLU_MT
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODES for Forward Sensitivity 
+ * Analysis. The problem is from chemical kinetics, and consists
+ * of the following three rate equations:
+ *    dy1/dt = -p1*y1 + p2*y2*y3
+ *    dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
+ *    dy3/dt =  p3*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions y1 = 1.0, y2 = y3 = 0. The reaction rates are: p1=0.04,
+ * p2=1e4, and p3=3e7. The problem is stiff.
+ * This program solves the problem with the BDF method, Newton
+ * iteration with the CVODES SUPERLU_MT linear solver, and a
+ * user-supplied Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance.
+ * Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ *
+ * Optionally, CVODES can compute sensitivities with respect to the
+ * problem parameters p1, p2, and p3.
+ * The sensitivity right hand side is given analytically through the
+ * user routine fS (of type SensRhs1Fn).
+ * Any of three sensitivity methods (SIMULTANEOUS, STAGGERED, and
+ * STAGGERED1) can be used and sensitivities may be included in the
+ * error test or not (error control set on TRUE or FALSE,
+ * respectively).
+ *
+ * Execution:
+ *
+ * If no sensitivities are desired:
+ *    % cvsRoberts_FSA_sps -nosensi
+ * If sensitivities are to be computed:
+ *    % cvsRoberts_FSA_sps -sensi sensi_meth err_con
+ * where sensi_meth is one of {sim, stg, stg1} and err_con is one of
+ * {t, f}.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Header files with a description of contents used */
+
+#include <cvodes/cvodes.h>             /* prototypes for CVODES fcts. and consts. */
+#include <cvodes/cvodes_superlumt.h>   /* prototypes for CVSUPERLUMT fcts. and constants */
+#include <sundials/sundials_sparse.h>  /* definitions SlsMat */
+#include <nvector/nvector_serial.h>    /* defs. of serial NVECTOR fcts. and macros */
+#include <sundials/sundials_types.h>   /* def. of type realtype */
+#include <sundials/sundials_math.h>    /* definition of ABS */
+
+/* Accessor macros */
+/* These macros are defined in order to write code with which exactly matched
+   the mathematical problem description given above.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component i=1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ   3             /* number of equations  */
+#define Y1    RCONST(1.0)   /* initial y components */
+#define Y2    RCONST(0.0)
+#define Y3    RCONST(0.0)
+#define RTOL  RCONST(1e-4)  /* scalar relative tolerance */
+#define ATOL1 RCONST(1e-8)  /* vector absolute tolerance components */
+#define ATOL2 RCONST(1e-14)
+#define ATOL3 RCONST(1e-6)
+#define T0    RCONST(0.0)   /* initial time */
+#define T1    RCONST(0.4)   /* first output time */
+#define TMULT RCONST(10.0)  /* output time factor */
+#define NOUT  12            /* number of output times */
+
+#define NP    3             /* number of problem parameters */
+#define NS    3             /* number of sensitivities computed */
+
+#define ZERO  RCONST(0.0)
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];           /* problem parameters */
+} *UserData;
+
+/* Prototypes of functions by CVODES */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int fS(int Ns, realtype t, N_Vector y, N_Vector ydot, 
+              int iS, N_Vector yS, N_Vector ySdot, 
+              void *user_data, N_Vector tmp1, N_Vector tmp2);
+
+static int ewt(N_Vector y, N_Vector w, void *user_data);
+
+/* Prototypes of private functions */
+
+static void ProcessArgs(int argc, char *argv[],
+                        booleantype *sensi, int *sensi_meth, 
+                        booleantype *err_con);
+static void WrongArgs(char *name);
+static void PrintOutput(void *cvode_mem, realtype t, N_Vector u);
+static void PrintOutputS(N_Vector *uS);
+static void PrintFinalStats(void *cvode_mem, booleantype sensi);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  void *cvode_mem;
+  UserData data;
+  realtype t, tout;
+  N_Vector y;
+  int iout, flag, nthreads, nnz;
+
+  realtype pbar[NS];
+  int is; 
+  N_Vector *yS;
+  booleantype sensi, err_con;
+  int sensi_meth;
+
+  cvode_mem = NULL;
+  data      = NULL;
+  y         =  NULL;
+  yS        = NULL;
+
+  /* Process arguments */
+  ProcessArgs(argc, argv, &sensi, &sensi_meth, &err_con);
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.04);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+
+  /* Initial conditions */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+
+  Ith(y,1) = Y1;
+  Ith(y,2) = Y2;
+  Ith(y,3) = Y3;
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+     Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+
+  /* Call CVodeInit to initialize the integrator memory and specify the
+     user's right hand side function in y'=f(t,y), the initial time T0, and
+     the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeWFtolerances to specify a user-supplied function ewt that sets
+     the multiplicative error weights W_i for use in the weighted RMS norm */
+  flag = CVodeWFtolerances(cvode_mem, ewt);
+  if (check_flag(&flag, "CVodeSetEwtFn", 1)) return(1);
+
+  /* Attach user data */
+  flag = CVodeSetUserData(cvode_mem, data);
+  if (check_flag(&flag, "CVodeSetUserData", 1)) return(1);
+
+  /* Call CVKLU to specify the CVKLU sparse direct linear solver */
+  nthreads = 1;                 /* no. of threads to use when factoring the system*/
+  nnz = NEQ * NEQ;              /* max no. of nonzeros entries in the Jac */
+  flag = CVSuperLUMT(cvode_mem, nthreads, NEQ, nnz);
+  if (check_flag(&flag, "CVSuperLUMT", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  printf("\n3-species chemical kinetics problem\n");
+
+  /* Sensitivity-related settings */
+  if (sensi) {
+
+    /* Set parameter scaling factor */
+    pbar[0] = data->p[0];
+    pbar[1] = data->p[1];
+    pbar[2] = data->p[2];
+
+    /* Set sensitivity initial conditions */
+    yS = N_VCloneVectorArray_Serial(NS, y);
+    if (check_flag((void *)yS, "N_VCloneVectorArray_Serial", 0)) return(1);
+    for (is=0;is<NS;is++) N_VConst(ZERO, yS[is]);
+
+    /* Call CVodeSensInit1 to activate forward sensitivity computations
+       and allocate internal memory for COVEDS related to sensitivity
+       calculations. Computes the right-hand sides of the sensitivity
+       ODE, one at a time */
+    flag = CVodeSensInit1(cvode_mem, NS, sensi_meth, fS, yS);
+    if(check_flag(&flag, "CVodeSensInit", 1)) return(1);
+
+    /* Call CVodeSensEEtolerances to estimate tolerances for sensitivity 
+       variables based on the rolerances supplied for states variables and 
+       the scaling factor pbar */
+    flag = CVodeSensEEtolerances(cvode_mem);
+    if(check_flag(&flag, "CVodeSensEEtolerances", 1)) return(1);
+
+    /* Set sensitivity analysis optional inputs */
+    /* Call CVodeSetSensErrCon to specify the error control strategy for 
+       sensitivity variables */
+    flag = CVodeSetSensErrCon(cvode_mem, err_con);
+    if (check_flag(&flag, "CVodeSetSensErrCon", 1)) return(1);
+
+    /* Call CVodeSetSensParams to specify problem parameter information for 
+       sensitivity calculations */
+    flag = CVodeSetSensParams(cvode_mem, NULL, pbar, NULL);
+    if (check_flag(&flag, "CVodeSetSensParams", 1)) return(1);
+
+    printf("Sensitivity: YES ");
+    if(sensi_meth == CV_SIMULTANEOUS)   
+      printf("( SIMULTANEOUS +");
+    else 
+      if(sensi_meth == CV_STAGGERED) printf("( STAGGERED +");
+      else                           printf("( STAGGERED1 +");   
+    if(err_con) printf(" FULL ERROR CONTROL )");
+    else        printf(" PARTIAL ERROR CONTROL )");
+
+  } else {
+
+    printf("Sensitivity: NO ");
+
+  }
+  
+  /* In loop over output points, call CVode, print results, test for error */
+  
+  printf("\n\n");
+  printf("===========================================");
+  printf("============================\n");
+  printf("     T     Q       H      NST           y1");
+  printf("           y2           y3    \n");
+  printf("===========================================");
+  printf("============================\n");
+
+  for (iout=1, tout=T1; iout <= NOUT; iout++, tout *= TMULT) {
+
+    flag = CVode(cvode_mem, tout, y, &t, CV_NORMAL);
+    if (check_flag(&flag, "CVode", 1)) break;
+
+    PrintOutput(cvode_mem, t, y);
+
+    /* Call CVodeGetSens to get the sensitivity solution vector after a
+       successful return from CVode */
+    if (sensi) {
+      flag = CVodeGetSens(cvode_mem, &t, yS);
+      if (check_flag(&flag, "CVodeGetSens", 1)) break;
+      PrintOutputS(yS);
+    } 
+    printf("-----------------------------------------");
+    printf("------------------------------\n");
+
+  }
+
+  /* Print final statistics */
+  PrintFinalStats(cvode_mem, sensi);
+
+  /* Free memory */
+
+  N_VDestroy_Serial(y);                    /* Free y vector */
+  if (sensi) {
+    N_VDestroyVectorArray_Serial(yS, NS);  /* Free yS vector */
+  }
+  free(data);                              /* Free user data */
+  CVodeFree(&cvode_mem);                   /* Free CVODES memory */
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY CVODES
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * f routine. Compute f(t,y). 
+ */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+  UserData data;
+  realtype p1, p2, p3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  yd1 = Ith(ydot,1) = -p1*y1 + p2*y2*y3;
+  yd3 = Ith(ydot,3) = p3*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+ */
+
+static int Jac(realtype t,
+	       N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(y);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+  
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = -p1;                          rowvals[0] = 0;
+  data[1] = p1;                           rowvals[1] = 1;
+  data[2] = ZERO;                         rowvals[2] = 2;
+
+  data[3] = p2*yval[2];                   rowvals[3] = 0;
+  data[4] = -p2*yval[2]-2*p3*yval[1];     rowvals[4] = 1;
+  data[5] = 2*yval[1];                    rowvals[5] = 2;
+  
+  data[6] = p2*yval[1];                   rowvals[6] = 0;
+  data[7] = -p2*yval[1];                  rowvals[7] = 1;
+  data[8] = ZERO;                         rowvals[8] = 2;
+ 
+  return(0);
+}
+ 
+/* 
+ * fS routine. Compute sensitivity r.h.s. CVSensRhs1Fn is compatible with any
+ * valid value of the argument ism to CVodeSensInit and CVodeSensInit1
+ */
+
+static int fS(int Ns, realtype t, N_Vector y, N_Vector ydot, 
+              int iS, N_Vector yS, N_Vector ySdot, 
+              void *user_data, N_Vector tmp1, N_Vector tmp2)
+{
+  UserData data;
+  realtype p1, p2, p3;
+  realtype y1, y2, y3;
+  realtype s1, s2, s3;
+  realtype sd1, sd2, sd3;
+
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  y1 = Ith(y,1);  y2 = Ith(y,2);  y3 = Ith(y,3);
+  s1 = Ith(yS,1); s2 = Ith(yS,2); s3 = Ith(yS,3);
+
+  sd1 = -p1*s1 + p2*y3*s2 + p2*y2*s3;
+  sd3 = 2*p3*y2*s2;
+  sd2 = -sd1-sd3;
+
+  switch (iS) {
+  case 0:
+    sd1 += -y1;
+    sd2 +=  y1;
+    break;
+  case 1:
+    sd1 +=  y2*y3;
+    sd2 += -y2*y3;
+    break;
+  case 2:
+    sd2 += -y2*y2;
+    sd3 +=  y2*y2;
+    break;
+  }
+  
+  Ith(ySdot,1) = sd1;
+  Ith(ySdot,2) = sd2;
+  Ith(ySdot,3) = sd3;
+
+  return(0);
+}
+
+/*
+ * EwtSet function. Computes the error weights at the current solution.
+ */
+
+static int ewt(N_Vector y, N_Vector w, void *user_data)
+{
+  int i;
+  realtype yy, ww, rtol, atol[3];
+
+  rtol    = RTOL;
+  atol[0] = ATOL1;
+  atol[1] = ATOL2;
+  atol[2] = ATOL3;
+
+  for (i=1; i<=3; i++) {
+    yy = Ith(y,i);
+    ww = rtol * SUNRabs(yy) + atol[i-1];
+    if (ww <= 0.0) return (-1);
+    Ith(w,i) = 1.0/ww;
+  }
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Process and verify arguments to cvsfwddenx.
+ */
+
+static void ProcessArgs(int argc, char *argv[], 
+                        booleantype *sensi, int *sensi_meth, booleantype *err_con)
+{
+  *sensi = FALSE;
+  *sensi_meth = -1;
+  *err_con = FALSE;
+
+  if (argc < 2) WrongArgs(argv[0]);
+
+  if (strcmp(argv[1],"-nosensi") == 0)
+    *sensi = FALSE;
+  else if (strcmp(argv[1],"-sensi") == 0)
+    *sensi = TRUE;
+  else
+    WrongArgs(argv[0]);
+  
+  if (*sensi) {
+
+    if (argc != 4)
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[2],"sim") == 0)
+      *sensi_meth = CV_SIMULTANEOUS;
+    else if (strcmp(argv[2],"stg") == 0)
+      *sensi_meth = CV_STAGGERED;
+    else if (strcmp(argv[2],"stg1") == 0)
+      *sensi_meth = CV_STAGGERED1;
+    else 
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[3],"t") == 0)
+      *err_con = TRUE;
+    else if (strcmp(argv[3],"f") == 0)
+      *err_con = FALSE;
+    else
+      WrongArgs(argv[0]);
+  }
+
+}
+
+static void WrongArgs(char *name)
+{
+    printf("\nUsage: %s [-nosensi] [-sensi sensi_meth err_con]\n",name);
+    printf("         sensi_meth = sim, stg, or stg1\n");
+    printf("         err_con    = t or f\n");
+    
+    exit(0);
+}
+
+/*
+ * Print current t, step count, order, stepsize, and solution.
+ */
+
+static void PrintOutput(void *cvode_mem, realtype t, N_Vector u)
+{
+  long int nst;
+  int qu, flag;
+  realtype hu, *udata;
+  
+  udata = N_VGetArrayPointer_Serial(u);
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetLastOrder(cvode_mem, &qu);
+  check_flag(&flag, "CVodeGetLastOrder", 1);
+  flag = CVodeGetLastStep(cvode_mem, &hu);
+  check_flag(&flag, "CVodeGetLastStep", 1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%8.3Le %2d  %8.3Le %5ld\n", t, qu, hu, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#else
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#endif
+
+  printf("                  Solution       ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#endif
+
+}
+
+/* 
+ * Print sensitivities.
+*/
+
+static void PrintOutputS(N_Vector *uS)
+{
+  realtype *sdata;
+
+  sdata = N_VGetArrayPointer_Serial(uS[0]);
+  printf("                  Sensitivity 1  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  
+  sdata = N_VGetArrayPointer_Serial(uS[1]);
+  printf("                  Sensitivity 2  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+  sdata = N_VGetArrayPointer_Serial(uS[2]);
+  printf("                  Sensitivity 3  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+}
+
+/* 
+ * Print some final statistics from the CVODES memory.
+ */
+
+static void PrintFinalStats(void *cvode_mem, booleantype sensi)
+{
+  long int nst;
+  long int nfe, nsetups, nni, ncfn, netf;
+  long int nfSe, nfeS, nsetupsS, nniS, ncfnS, netfS;
+  long int nje;
+  int flag;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  if (sensi) {
+    flag = CVodeGetSensNumRhsEvals(cvode_mem, &nfSe);
+    check_flag(&flag, "CVodeGetSensNumRhsEvals", 1);
+    flag = CVodeGetNumRhsEvalsSens(cvode_mem, &nfeS);
+    check_flag(&flag, "CVodeGetNumRhsEvalsSens", 1);
+    flag = CVodeGetSensNumLinSolvSetups(cvode_mem, &nsetupsS);
+    check_flag(&flag, "CVodeGetSensNumLinSolvSetups", 1);
+    flag = CVodeGetSensNumErrTestFails(cvode_mem, &netfS);
+    check_flag(&flag, "CVodeGetSensNumErrTestFails", 1);
+    flag = CVodeGetSensNumNonlinSolvIters(cvode_mem, &nniS);
+    check_flag(&flag, "CVodeGetSensNumNonlinSolvIters", 1);
+    flag = CVodeGetSensNumNonlinSolvConvFails(cvode_mem, &ncfnS);
+    check_flag(&flag, "CVodeGetSensNumNonlinSolvConvFails", 1);
+  }
+
+  flag = CVSlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVDlsGetNumJacEvals", 1);
+
+  printf("\nFinal Statistics\n\n");
+  printf("nst     = %5ld\n\n", nst);
+  printf("nfe     = %5ld\n",   nfe);
+  printf("netf    = %5ld    nsetups  = %5ld\n", netf, nsetups);
+  printf("nni     = %5ld    ncfn     = %5ld\n", nni, ncfn);
+
+  if(sensi) {
+    printf("\n");
+    printf("nfSe    = %5ld    nfeS     = %5ld\n", nfSe, nfeS);
+    printf("netfs   = %5ld    nsetupsS = %5ld\n", netfS, nsetupsS);
+    printf("nniS    = %5ld    ncfnS    = %5ld\n", nniS, ncfnS);
+  }
+
+  printf("\n");
+  printf("nje    = %5ld\n", nje);
+
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvodes/serial/cvsRoberts_FSA_sps.out b/examples/cvodes/serial/cvsRoberts_FSA_sps.out
new file mode 100644
index 0000000..7dcd3b6
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_FSA_sps.out
@@ -0,0 +1,93 @@
+
+3-species chemical kinetics problem
+Sensitivity: YES ( STAGGERED1 + FULL ERROR CONTROL )
+
+=======================================================================
+     T     Q       H      NST           y1           y2           y3    
+=======================================================================
+4.000e-01  3  5.292e-02   105
+                  Solution         9.8517e-01   3.3864e-05   1.4794e-02 
+                  Sensitivity 1   -3.5595e-01   3.9025e-04   3.5556e-01 
+                  Sensitivity 2    9.5428e-08  -2.1309e-10  -9.5216e-08 
+                  Sensitivity 3   -1.5833e-11  -5.2900e-13   1.6360e-11 
+-----------------------------------------------------------------------
+4.000e+00  4  2.108e-01   140
+                  Solution         9.0552e-01   2.2405e-05   9.4458e-02 
+                  Sensitivity 1   -1.8761e+00   1.7922e-04   1.8759e+00 
+                  Sensitivity 2    2.9614e-06  -5.8304e-10  -2.9609e-06 
+                  Sensitivity 3   -4.9334e-10  -2.7627e-13   4.9366e-10 
+-----------------------------------------------------------------------
+4.000e+01  3  1.956e+00   301
+                  Solution         7.1581e-01   9.1847e-06   2.8419e-01 
+                  Sensitivity 1   -4.2478e+00   4.5905e-05   4.2478e+00 
+                  Sensitivity 2    1.3732e-05  -2.3568e-10  -1.3732e-05 
+                  Sensitivity 3   -2.2887e-09  -1.1379e-13   2.2885e-09 
+-----------------------------------------------------------------------
+4.000e+02  3  1.291e+01   477
+                  Solution         4.5052e-01   3.2228e-06   5.4950e-01 
+                  Sensitivity 1   -5.9585e+00   3.5421e-06   5.9586e+00 
+                  Sensitivity 2    2.2738e-05  -2.2602e-11  -2.2739e-05 
+                  Sensitivity 3   -3.7899e-09  -4.9948e-14   3.7896e-09 
+-----------------------------------------------------------------------
+4.000e+03  2  1.532e+02   684
+                  Solution         1.8317e-01   8.9399e-07   8.1688e-01 
+                  Sensitivity 1   -4.7501e+00  -5.9960e-06   4.7503e+00 
+                  Sensitivity 2    1.8809e-05   2.3136e-11  -1.8811e-05 
+                  Sensitivity 3   -3.1351e-09  -1.8756e-14   3.1343e-09 
+-----------------------------------------------------------------------
+4.000e+04  3  8.774e+02   776
+                  Solution         3.8987e-02   1.6218e-07   9.6106e-01 
+                  Sensitivity 1   -1.5751e+00  -2.7620e-06   1.5752e+00 
+                  Sensitivity 2    6.2880e-06   1.1004e-11  -6.2898e-06 
+                  Sensitivity 3   -1.0481e-09  -4.5369e-15   1.0472e-09 
+-----------------------------------------------------------------------
+4.000e+05  4  1.932e+04   832
+                  Solution         4.9390e-03   1.9852e-08   9.9512e-01 
+                  Sensitivity 1   -2.3635e-01  -4.5837e-07   2.3639e-01 
+                  Sensitivity 2    9.4501e-07   1.8321e-12  -9.4670e-07 
+                  Sensitivity 3   -1.5754e-10  -6.3632e-16   1.5652e-10 
+-----------------------------------------------------------------------
+4.000e+06  4  1.931e+05   876
+                  Solution         5.1691e-04   2.0686e-09   9.9954e-01 
+                  Sensitivity 1   -2.5669e-02  -5.1060e-08   2.5672e-02 
+                  Sensitivity 2    1.0267e-07   2.0423e-13  -1.0421e-07 
+                  Sensitivity 3   -1.7120e-11  -6.8545e-17   1.6048e-11 
+-----------------------------------------------------------------------
+4.000e+07  4  1.985e+06   927
+                  Solution         5.2046e-05   2.0818e-10   1.0000e+00 
+                  Sensitivity 1   -2.5993e-03  -5.1933e-09   2.5989e-03 
+                  Sensitivity 2    1.0397e-08   2.0773e-14  -1.1920e-08 
+                  Sensitivity 3   -1.7335e-12  -6.9340e-18   6.5497e-13 
+-----------------------------------------------------------------------
+4.000e+08  4  2.940e+07   973
+                  Solution         5.2089e-06   2.0835e-11   1.0001e+00 
+                  Sensitivity 1   -2.6037e-04  -5.2057e-10   2.5848e-04 
+                  Sensitivity 2    1.0413e-09   2.0816e-15  -2.5560e-09 
+                  Sensitivity 3   -1.7367e-13  -6.9463e-19  -9.0772e-13 
+-----------------------------------------------------------------------
+4.000e+09  4  2.960e+08  1028
+                  Solution         5.2133e-07   2.0852e-12   1.0001e+00 
+                  Sensitivity 1   -2.6097e-05  -5.2250e-11   2.3802e-05 
+                  Sensitivity 2    1.0436e-10   2.0890e-16  -1.6179e-09 
+                  Sensitivity 3   -1.7397e-14  -6.9582e-20  -1.0647e-12 
+-----------------------------------------------------------------------
+4.000e+10  2  3.390e+09  1051
+                  Solution         5.4134e-08   2.1652e-13   1.0001e+00 
+                  Sensitivity 1   -2.7033e-06  -5.3996e-12   6.0356e-07 
+                  Sensitivity 2    1.0723e-11   2.1239e-17  -1.5257e-09 
+                  Sensitivity 3   -1.8272e-15  -7.3081e-21  -1.0798e-12 
+-----------------------------------------------------------------------
+
+Final Statistics
+
+nst     =  1051
+
+nfe     =  2493
+netf    =     0    nsetups  =   261
+nni     =  1317    ncfn     =     0
+
+nfSe    =  4314    nfeS     =     0
+netfs   =   121    nsetupsS =     0
+nniS    =  4302    ncfnS    =     0
+
+nje    =    19
diff --git a/examples/cvodes/serial/cvsRoberts_dns.c b/examples/cvodes/serial/cvsRoberts_dns.c
index 94698ce..c5293bb 100644
--- a/examples/cvodes/serial/cvsRoberts_dns.c
+++ b/examples/cvodes/serial/cvsRoberts_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:58:00 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -94,7 +94,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 
 /*
@@ -269,7 +269,7 @@ static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %0.4le      y =%14.6le  %14.6le  %14.6le\n", t, y1, y2, y3);
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #else
   printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #endif
@@ -331,7 +331,7 @@ static void PrintFinalStats(void *cvode_mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsRoberts_dnsL.c b/examples/cvodes/serial/cvsRoberts_dnsL.c
index 8715cfd..d369f1b 100644
--- a/examples/cvodes/serial/cvsRoberts_dnsL.c
+++ b/examples/cvodes/serial/cvsRoberts_dnsL.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:58:00 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -93,7 +93,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 
 /*
@@ -335,7 +335,7 @@ static void PrintFinalStats(void *cvode_mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsRoberts_dns_uw.c b/examples/cvodes/serial/cvsRoberts_dns_uw.c
index 93651a4..c90efd5 100644
--- a/examples/cvodes/serial/cvsRoberts_dns_uw.c
+++ b/examples/cvodes/serial/cvsRoberts_dns_uw.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:58:00 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
@@ -98,7 +98,7 @@ static void PrintFinalStats(void *cvode_mem);
 
 /* Private function to check function return values */
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 
 /*
@@ -268,7 +268,7 @@ static int ewt(N_Vector y, N_Vector w, void *user_data)
 
   for (i=1; i<=3; i++) {
     yy = Ith(y,i);
-    ww = rtol * ABS(yy) + atol[i-1];  
+    ww = rtol * SUNRabs(yy) + atol[i-1];
     if (ww <= 0.0) return (-1);
     Ith(w,i) = 1.0/ww;
   }
@@ -287,7 +287,7 @@ static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At t = %0.4le      y =%14.6le  %14.6le  %14.6le\n", t, y1, y2, y3);
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #else
   printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
 #endif
@@ -349,7 +349,7 @@ static void PrintFinalStats(void *cvode_mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/cvodes/serial/cvsRoberts_klu.c b/examples/cvodes/serial/cvsRoberts_klu.c
new file mode 100644
index 0000000..0d1106c
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_klu.c
@@ -0,0 +1,382 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward.
+ *      Based on cvRoberts_dns.c and modified to use KLU.
+ * -----------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODE. The problem is from
+ * chemical kinetics, and consists of the following three rate
+ * equations:         
+ *    dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *    dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
+ *    dy3/dt = 3.e7*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01. This program solves the problem with the BDF method,
+ * Newton iteration with the CVKLU sparse direct linear solver, and a
+ * user-supplied Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance. Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+
+/* Header files with a description of contents used */
+
+#include <cvodes/cvodes.h>             /* prototypes for CVODE fcts., consts. */
+#include <nvector/nvector_serial.h>  /* serial N_Vector types, fcts., macros */
+#include <cvodes/cvodes_klu.h>         /* prototype for CVKLU */
+#include <sundials/sundials_sparse.h> /* definitions SlsMat */
+#include <sundials/sundials_types.h> /* definition of type realtype */
+
+/* User-defined vector and matrix accessor macro: Ith */
+
+/* These macros are defined in order to write code which exactly matches
+   the mathematical problem description given above.
+
+   Ith(v,i) references the ith component of the vector v, where i is in
+   the range [1..NEQ] and NEQ is defined below. The Ith macro is defined
+   using the N_VIth macro in nvector.h. N_VIth numbers the components of
+   a vector starting from 0.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* Ith numbers components 1..NEQ */
+
+
+/* Problem Constants */
+
+#define ZERO  RCONST(0.0)
+
+#define NEQ   3                /* number of equations  */
+#define Y1    RCONST(1.0)      /* initial y components */
+#define Y2    RCONST(0.0)
+#define Y3    RCONST(0.0)
+#define RTOL  RCONST(1.0e-4)   /* scalar relative tolerance            */
+#define ATOL1 RCONST(1.0e-8)   /* vector absolute tolerance components */
+#define ATOL2 RCONST(1.0e-14)
+#define ATOL3 RCONST(1.0e-6)
+#define T0    RCONST(0.0)      /* initial time           */
+#define T1    RCONST(0.4)      /* first output time      */
+#define TMULT RCONST(10.0)     /* output time factor     */
+#define NOUT  12               /* number of output times */
+
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data);
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private functions to output results */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3);
+static void PrintRootInfo(int root_f1, int root_f2);
+
+/* Private function to print final statistics */
+
+static void PrintFinalStats(void *cvode_mem);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+
+/*
+ *-------------------------------
+ * Main Program
+ *-------------------------------
+ */
+
+int main()
+{
+  realtype reltol, t, tout;
+  N_Vector y, abstol;
+  void *cvode_mem;
+  int flag, flagr, iout, nnz;
+  int rootsfound[2];
+
+  y = abstol = NULL;
+  cvode_mem = NULL;
+
+  /* Create serial vector of length NEQ for I.C. and abstol */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+  abstol = N_VNew_Serial(NEQ); 
+  if (check_flag((void *)abstol, "N_VNew_Serial", 0)) return(1);
+
+  /* Initialize y */
+  Ith(y,1) = Y1;
+  Ith(y,2) = Y2;
+  Ith(y,3) = Y3;
+
+  /* Set the scalar relative tolerance */
+  reltol = RTOL;
+  /* Set the vector absolute tolerance */
+  Ith(abstol,1) = ATOL1;
+  Ith(abstol,2) = ATOL2;
+  Ith(abstol,3) = ATOL3;
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+  
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in y'=f(t,y), the inital time T0, and
+   * the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeSVtolerances to specify the scalar relative tolerance
+   * and vector absolute tolerances */
+  flag = CVodeSVtolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSVtolerances", 1)) return(1);
+
+  /* Call CVodeRootInit to specify the root function g with 2 components */
+  flag = CVodeRootInit(cvode_mem, 2, g);
+  if (check_flag(&flag, "CVodeRootInit", 1)) return(1);
+
+  /* Call CVKLU to specify the CVKLU sparse direct linear solver */
+  nnz = NEQ * NEQ;
+  flag = CVKLU(cvode_mem, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "CVKLU", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call CVode, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached.  */
+  printf(" \n3-species kinetics problem\n\n");
+
+  iout = 0;  tout = T1;
+  while(1) {
+    flag = CVode(cvode_mem, tout, y, &t, CV_NORMAL);
+    PrintOutput(t, Ith(y,1), Ith(y,2), Ith(y,3));
+
+    if (flag == CV_ROOT_RETURN) {
+      flagr = CVodeGetRootInfo(cvode_mem, rootsfound);
+      if (check_flag(&flagr, "CVodeGetRootInfo", 1)) return(1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (check_flag(&flag, "CVode", 1)) break;
+    if (flag == CV_SUCCESS) {
+      iout++;
+      tout *= TMULT;
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  /* Print some final statistics */
+  PrintFinalStats(cvode_mem);
+
+  /* Free y and abstol vectors */
+  N_VDestroy_Serial(y);
+  N_VDestroy_Serial(abstol);
+
+  /* Free integrator memory */
+  CVodeFree(&cvode_mem);
+
+  return(0);
+}
+
+
+/*
+ *-------------------------------
+ * Functions called by the solver
+ *-------------------------------
+ */
+
+/*
+ * f routine. Compute function f(t,y). 
+ */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+
+  yd1 = Ith(ydot,1) = RCONST(-0.04)*y1 + RCONST(1.0e4)*y2*y3;
+  yd3 = Ith(ydot,3) = RCONST(3.0e7)*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+/*
+ * g routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data)
+{
+  realtype y1, y3;
+
+  y1 = Ith(y,1); y3 = Ith(y,3);
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Jacobian routine. Compute J(t,y) = df/dy. *
+ */
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  
+  yval = N_VGetArrayPointer_Serial(y);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data    = JacMat->data;
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = RCONST(-0.04);
+  rowvals[0] = 0;
+  data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  data[2] = ZERO;
+  rowvals[2] = 2;
+
+  data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]);
+  rowvals[4] = 1;
+  data[5] = RCONST(6.0e7)*yval[1];
+  rowvals[5] = 2;
+
+  data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  data[8] = ZERO;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Private helper functions
+ *-------------------------------
+ */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#else
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#endif
+
+  return;
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+
+  return;
+}
+
+/* 
+ * Get and print some final statistics
+ */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  long int nst, nfe, nsetups, nje, nni, ncfn, netf, nge;
+  int flag;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  flag = CVSlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVSlsGetNumJacEvals", 1);
+
+  flag = CVodeGetNumGEvals(cvode_mem, &nge);
+  check_flag(&flag, "CVodeGetNumGEvals", 1);
+
+  printf("\nFinal Statistics:\n");
+  printf("nst = %-6ld nfe  = %-6ld nsetups = %-6ld nje = %ld\n",
+	 nst, nfe, nsetups, nje);
+  printf("nni = %-6ld ncfn = %-6ld netf = %-6ld    nge = %ld\n \n",
+	 nni, ncfn, netf, nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvodes/serial/cvsRoberts_klu.out b/examples/cvodes/serial/cvsRoberts_klu.out
new file mode 100644
index 0000000..776406f
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_klu.out
@@ -0,0 +1,24 @@
+ 
+3-species kinetics problem
+
+At t = 2.6391e-01      y =  9.899653e-01    3.470564e-05    1.000000e-02
+    rootsfound[] =   0   1
+At t = 4.0000e-01      y =  9.851640e-01    3.386245e-05    1.480209e-02
+At t = 4.0000e+00      y =  9.055156e-01    2.240441e-05    9.446197e-02
+At t = 4.0000e+01      y =  7.158508e-01    9.186546e-06    2.841400e-01
+At t = 4.0000e+02      y =  4.505784e-01    3.223707e-06    5.494184e-01
+At t = 4.0000e+03      y =  1.832290e-01    8.944054e-07    8.167701e-01
+At t = 4.0000e+04      y =  3.898012e-02    1.621625e-07    9.610197e-01
+At t = 4.0000e+05      y =  4.936714e-03    1.984363e-08    9.950633e-01
+At t = 4.0000e+06      y =  5.164962e-04    2.067039e-09    9.994835e-01
+At t = 2.0784e+07      y =  1.000000e-04    4.000395e-10    9.999000e-01
+    rootsfound[] =  -1   0
+At t = 4.0000e+07      y =  5.202874e-05    2.081257e-10    9.999480e-01
+At t = 4.0000e+08      y =  5.206719e-06    2.082698e-11    9.999948e-01
+At t = 4.0000e+09      y =  5.208794e-07    2.083519e-12    9.999995e-01
+At t = 4.0000e+10      y =  5.244455e-08    2.097782e-13    9.999999e-01
+
+Final Statistics:
+nst = 430    nfe  = 574    nsetups = 98     nje = 78
+nni = 570    ncfn = 0      netf = 23        nge = 466
+ 
diff --git a/examples/cvodes/serial/cvsRoberts_sps.c b/examples/cvodes/serial/cvsRoberts_sps.c
new file mode 100644
index 0000000..46ef255
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_sps.c
@@ -0,0 +1,378 @@
+/*
+ * -----------------------------------------------------------------
+ * $Rev $
+ * $Date $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward.
+ *      Based on cvRoberts_dns.c and modified to use SUPERLU_MT.
+ * -----------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem, with the coding
+ * needed for its solution by CVODE. The problem is from
+ * chemical kinetics, and consists of the following three rate
+ * equations:         
+ *    dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *    dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
+ *    dy3/dt = 3.e7*(y2)^2
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01. This program solves the problem with the BDF method,
+ * Newton iteration with the CVSUPERLUMT sparse direct linear solver, and a
+ * user-supplied Jacobian routine.
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance. Output is printed in decades from t = .4 to t = 4.e10.
+ * Run statistics (optional outputs) are printed at the end.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+
+/* Header files with a description of contents used */
+
+#include <cvodes/cvodes.h>             /* prototypes for CVODE fcts., consts. */
+#include <nvector/nvector_serial.h>  /* serial N_Vector types, fcts., macros */
+#include <cvodes/cvodes_superlumt.h>   /* prototype for CVSUPERLUMT */
+#include <sundials/sundials_sparse.h> /* definitions SlsMat */
+#include <sundials/sundials_types.h> /* definition of type realtype */
+
+/* User-defined vector and matrix accessor macro: Ith */
+
+/* These macros are defined in order to write code which exactly matches
+   the mathematical problem description given above.
+
+   Ith(v,i) references the ith component of the vector v, where i is in
+   the range [1..NEQ] and NEQ is defined below. The Ith macro is defined
+   using the N_VIth macro in nvector.h. N_VIth numbers the components of
+   a vector starting from 0.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* Ith numbers components 1..NEQ */
+
+
+/* Problem Constants */
+
+#define ZERO  RCONST(0.0)
+
+#define NEQ   3                /* number of equations  */
+#define Y1    RCONST(1.0)      /* initial y components */
+#define Y2    RCONST(0.0)
+#define Y3    RCONST(0.0)
+#define RTOL  RCONST(1.0e-4)   /* scalar relative tolerance            */
+#define ATOL1 RCONST(1.0e-8)   /* vector absolute tolerance components */
+#define ATOL2 RCONST(1.0e-14)
+#define ATOL3 RCONST(1.0e-6)
+#define T0    RCONST(0.0)      /* initial time           */
+#define T1    RCONST(0.4)      /* first output time      */
+#define TMULT RCONST(10.0)     /* output time factor     */
+#define NOUT  12               /* number of output times */
+
+
+/* Functions Called by the Solver */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data);
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Private functions to output results */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3);
+static void PrintRootInfo(int root_f1, int root_f2);
+
+/* Private function to print final statistics */
+
+static void PrintFinalStats(void *cvode_mem);
+
+/* Private function to check function return values */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+
+/*
+ *-------------------------------
+ * Main Program
+ *-------------------------------
+ */
+
+int main()
+{
+  realtype reltol, t, tout;
+  N_Vector y, abstol;
+  void *cvode_mem;
+  int flag, flagr, iout, nnz;
+  int rootsfound[2];
+
+  y = abstol = NULL;
+  cvode_mem = NULL;
+
+  /* Create serial vector of length NEQ for I.C. and abstol */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+  abstol = N_VNew_Serial(NEQ); 
+  if (check_flag((void *)abstol, "N_VNew_Serial", 0)) return(1);
+
+  /* Initialize y */
+  Ith(y,1) = Y1;
+  Ith(y,2) = Y2;
+  Ith(y,3) = Y3;
+
+  /* Set the scalar relative tolerance */
+  reltol = RTOL;
+  /* Set the vector absolute tolerance */
+  Ith(abstol,1) = ATOL1;
+  Ith(abstol,2) = ATOL2;
+  Ith(abstol,3) = ATOL3;
+
+  /* Call CVodeCreate to create the solver memory and specify the 
+   * Backward Differentiation Formula and the use of a Newton iteration */
+  cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON);
+  if (check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1);
+  
+  /* Call CVodeInit to initialize the integrator memory and specify the
+   * user's right hand side function in y'=f(t,y), the inital time T0, and
+   * the initial dependent variable vector y. */
+  flag = CVodeInit(cvode_mem, f, T0, y);
+  if (check_flag(&flag, "CVodeInit", 1)) return(1);
+
+  /* Call CVodeSVtolerances to specify the scalar relative tolerance
+   * and vector absolute tolerances */
+  flag = CVodeSVtolerances(cvode_mem, reltol, abstol);
+  if (check_flag(&flag, "CVodeSVtolerances", 1)) return(1);
+
+  /* Call CVodeRootInit to specify the root function g with 2 components */
+  flag = CVodeRootInit(cvode_mem, 2, g);
+  if (check_flag(&flag, "CVodeRootInit", 1)) return(1);
+
+  /* Call CVSuperLUMT to specify the CVSuperLUMT sparse direct linear solver */
+  nnz = NEQ * NEQ;
+  flag = CVSuperLUMT(cvode_mem, 1, NEQ, nnz);
+  if (check_flag(&flag, "CVSuperLUMT", 1)) return(1);
+
+  /* Set the Jacobian routine to Jac (user-supplied) */
+  flag = CVSlsSetSparseJacFn(cvode_mem, Jac);
+  if (check_flag(&flag, "CVSlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call CVode, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached.  */
+  printf(" \n3-species kinetics problem\n\n");
+
+  iout = 0;  tout = T1;
+  while(1) {
+    flag = CVode(cvode_mem, tout, y, &t, CV_NORMAL);
+    PrintOutput(t, Ith(y,1), Ith(y,2), Ith(y,3));
+
+    if (flag == CV_ROOT_RETURN) {
+      flagr = CVodeGetRootInfo(cvode_mem, rootsfound);
+      if (check_flag(&flagr, "CVodeGetRootInfo", 1)) return(1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (check_flag(&flag, "CVode", 1)) break;
+    if (flag == CV_SUCCESS) {
+      iout++;
+      tout *= TMULT;
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  /* Print some final statistics */
+  PrintFinalStats(cvode_mem);
+
+  /* Free y and abstol vectors */
+  N_VDestroy_Serial(y);
+  N_VDestroy_Serial(abstol);
+
+  /* Free integrator memory */
+  CVodeFree(&cvode_mem);
+
+  return(0);
+}
+
+
+/*
+ *-------------------------------
+ * Functions called by the solver
+ *-------------------------------
+ */
+
+/*
+ * f routine. Compute function f(t,y). 
+ */
+
+static int f(realtype t, N_Vector y, N_Vector ydot, void *user_data)
+{
+  realtype y1, y2, y3, yd1, yd3;
+
+  y1 = Ith(y,1); y2 = Ith(y,2); y3 = Ith(y,3);
+
+  yd1 = Ith(ydot,1) = RCONST(-0.04)*y1 + RCONST(1.0e4)*y2*y3;
+  yd3 = Ith(ydot,3) = RCONST(3.0e7)*y2*y2;
+        Ith(ydot,2) = -yd1 - yd3;
+
+  return(0);
+}
+
+/*
+ * g routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int g(realtype t, N_Vector y, realtype *gout, void *user_data)
+{
+  realtype y1, y3;
+
+  y1 = Ith(y,1); y3 = Ith(y,3);
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Jacobian routine. Compute J(t,y) = df/dy. *
+ */
+
+static int Jac(realtype t,
+               N_Vector y, N_Vector fy, SlsMat JacMat, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int *colptrs = *JacMat->colptrs;
+  int *rowvals = *JacMat->rowvals;
+
+  yval = N_VGetArrayPointer_Serial(y);
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  JacMat->data[0] = RCONST(-0.04);
+  rowvals[0] = 0;
+  JacMat->data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  JacMat->data[2] = ZERO;
+  rowvals[2] = 2;
+
+  JacMat->data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  JacMat->data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]);
+  rowvals[4] = 1;
+  JacMat->data[5] = RCONST(6.0e7)*yval[1];
+  rowvals[5] = 2;
+
+  JacMat->data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  JacMat->data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  JacMat->data[8] = ZERO;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *-------------------------------
+ * Private helper functions
+ *-------------------------------
+ */
+
+static void PrintOutput(realtype t, realtype y1, realtype y2, realtype y3)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("At t = %0.4Le      y =%14.6Le  %14.6Le  %14.6Le\n", t, y1, y2, y3);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#else
+  printf("At t = %0.4e      y =%14.6e  %14.6e  %14.6e\n", t, y1, y2, y3);
+#endif
+
+  return;
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+
+  return;
+}
+
+/* 
+ * Get and print some final statistics
+ */
+
+static void PrintFinalStats(void *cvode_mem)
+{
+  long int nst, nfe, nsetups, nje, nni, ncfn, netf, nge;
+  int flag;
+
+  flag = CVodeGetNumSteps(cvode_mem, &nst);
+  check_flag(&flag, "CVodeGetNumSteps", 1);
+  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
+  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
+  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
+  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
+  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
+  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
+  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
+  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
+  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
+  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);
+
+  flag = CVSlsGetNumJacEvals(cvode_mem, &nje);
+  check_flag(&flag, "CVSlsGetNumJacEvals", 1);
+
+  flag = CVodeGetNumGEvals(cvode_mem, &nge);
+  check_flag(&flag, "CVodeGetNumGEvals", 1);
+
+  printf("\nFinal Statistics:\n");
+  printf("nst = %-6ld nfe  = %-6ld nsetups = %-6ld nje = %ld\n",
+	 nst, nfe, nsetups, nje);
+  printf("nni = %-6ld ncfn = %-6ld netf = %-6ld    nge = %ld\n \n",
+	 nni, ncfn, netf, nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/cvodes/serial/cvsRoberts_sps.out b/examples/cvodes/serial/cvsRoberts_sps.out
new file mode 100644
index 0000000..b92bc8e
--- /dev/null
+++ b/examples/cvodes/serial/cvsRoberts_sps.out
@@ -0,0 +1,24 @@
+ 
+3-species kinetics problem
+
+At t = 2.6391e-01      y =  9.899653e-01    3.470564e-05    1.000000e-02
+    rootsfound[] =   0   1
+At t = 4.0000e-01      y =  9.851641e-01    3.386242e-05    1.480205e-02
+At t = 4.0000e+00      y =  9.055097e-01    2.240338e-05    9.446793e-02
+At t = 4.0000e+01      y =  7.158017e-01    9.185037e-06    2.841892e-01
+At t = 4.0000e+02      y =  4.505360e-01    3.223271e-06    5.494608e-01
+At t = 4.0000e+03      y =  1.832299e-01    8.944378e-07    8.167692e-01
+At t = 4.0000e+04      y =  3.898902e-02    1.622006e-07    9.610108e-01
+At t = 4.0000e+05      y =  4.936383e-03    1.984224e-08    9.950636e-01
+At t = 4.0000e+06      y =  5.168093e-04    2.068293e-09    9.994832e-01
+At t = 2.0790e+07      y =  1.000000e-04    4.000397e-10    9.999000e-01
+    rootsfound[] =  -1   0
+At t = 4.0000e+07      y =  5.202440e-05    2.081083e-10    9.999480e-01
+At t = 4.0000e+08      y =  5.201061e-06    2.080435e-11    9.999948e-01
+At t = 4.0000e+09      y =  5.258603e-07    2.103442e-12    9.999995e-01
+At t = 4.0000e+10      y =  6.934511e-08    2.773804e-13    9.999999e-01
+
+Final Statistics:
+nst = 542    nfe  = 755    nsetups = 107    nje = 11
+nni = 751    ncfn = 0      netf = 22        nge = 570
+ 
diff --git a/examples/ida/C_openmp/CMakeLists.txt b/examples/ida/C_openmp/CMakeLists.txt
new file mode 100644
index 0000000..2ed6996
--- /dev/null
+++ b/examples/ida/C_openmp/CMakeLists.txt
@@ -0,0 +1,143 @@
+# ---------------------------------------------------------------
+# $Revision:  $
+# $Date:  $
+# ---------------------------------------------------------------
+# Programmer: Ting Yan @ SMU
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the IDA OpenMP examples
+
+
+# Only include tests if OpenMP is enabled
+IF(OPENMP_FOUND)
+  # Add variable ida_examples with the names of the openmp IDA examples
+  SET(IDA_examples
+    idaFoodWeb_bnd_omp
+    idaFoodWeb_kry_omp
+    )
+
+  SET(IDA_examples_BL
+  )
+ENDIF(OPENMP_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_static)
+  SET(NVECS_LIB sundials_nvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_shared)
+  SET(NVECS_LIB sundials_nvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${IDA_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(PETSC_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_FOUND)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+
+# Add the build and install targets for each IDA example
+
+FOREACH(example ${IDA_examples})
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} TEST_ARGS 4)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/C_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${IDA_examples})
+
+# If Lapack support is enabled, add the build and install targets for
+# the examples using Lapack
+
+IF(LAPACK_FOUND)
+  FOREACH(example ${IDA_examples_BL})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example} TEST_ARGS 4)
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/C_openmp)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${IDA_examples_BL})
+ENDIF(LAPACK_FOUND)
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/C_openmp)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "IDA")
+  SET(SOLVER_LIB "sundials_ida")
+  LIST2STRING(IDA_examples EXAMPLES)
+  IF(LAPACK_FOUND)
+    LIST2STRING(IDA_examples_BL EXAMPLES_BL)
+  ELSE(LAPACK_FOUND)
+    SET(EXAMPLES_BL "")
+  ENDIF(LAPACK_FOUND)
+  
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+  
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/C_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/ida/C_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/C_openmp 
+    )
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/C_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/ida/C_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/C_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/ida/C_openmp/README b/examples/ida/C_openmp/README
new file mode 100644
index 0000000..e2b5f94
--- /dev/null
+++ b/examples/ida/C_openmp/README
@@ -0,0 +1,50 @@
+List of C_openmp examples for IDAS
+
+  idaFoodWeb_bnd_omp   : 2-D food web system, banded Jacobian
+  idaFoodWeb_kry_omp   : 2-D food web system using Krylov solver
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/C_openmp/idaFoodWeb_bnd_omp.c b/examples/ida/C_openmp/idaFoodWeb_bnd_omp.c
new file mode 100644
index 0000000..5250a6d
--- /dev/null
+++ b/examples/ida/C_openmp/idaFoodWeb_bnd_omp.c
@@ -0,0 +1,705 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on idaFoodWeb_bnd.c and parallelized with OpenMP
+ * -----------------------------------------------------------------
+ * Example program for IDA: Food web problem.
+ *
+ * This example program (OpenMP version) uses the IDABAND linear 
+ * solver, and IDACalcIC for initial condition calculation.
+ *
+ * The mathematical problem solved in this example is a DAE system
+ * that arises from a system of partial differential equations after
+ * spatial discretization. The PDE system is a food web population
+ * model, with predator-prey interaction and diffusion on the unit
+ * square in two dimensions. The dependent variable vector is:
+ *
+ *         1   2         ns
+ *   c = (c , c ,  ..., c  ) , ns = 2 * np
+ *
+ * and the PDE's are as follows:
+ *
+ *     i             i      i
+ *   dc /dt = d(i)*(c    + c  )  +  R (x,y,c)   (i = 1,...,np)
+ *                   xx     yy       i
+ *
+ *              i      i
+ *   0 = d(i)*(c    + c  )  +  R (x,y,c)   (i = np+1,...,ns)
+ *              xx     yy       i
+ *
+ *   where the reaction terms R are:
+ *
+ *                   i             ns         j
+ *   R  (x,y,c)  =  c  * (b(i)  + sum a(i,j)*c )
+ *    i                           j=1
+ *
+ * The number of species is ns = 2 * np, with the first np being
+ * prey and the last np being predators. The coefficients a(i,j),
+ * b(i), d(i) are:
+ *
+ *  a(i,i) = -AA   (all i)
+ *  a(i,j) = -GG   (i <= np , j >  np)
+ *  a(i,j) =  EE   (i >  np, j <= np)
+ *  all other a(i,j) = 0
+ *  b(i) = BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i <= np)
+ *  b(i) =-BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i  > np)
+ *  d(i) = DPREY   (i <= np)
+ *  d(i) = DPRED   (i > np)
+ *
+ * The various scalar parameters required are set using '#define'
+ * statements or directly in routine InitUserData. In this program,
+ * np = 1, ns = 2. The boundary conditions are homogeneous Neumann:
+ * normal derivative = 0.
+ *
+ * A polynomial in x and y is used to set the initial values of the
+ * first np variables (the prey variables) at each x,y location,
+ * while initial values for the remaining (predator) variables are
+ * set to a flat value, which is corrected by IDACalcIC.
+ *
+ * The PDEs are discretized by central differencing on a MX by MY
+ * mesh.
+ *
+ * The DAE system is solved by IDA using the IDABAND linear solver.
+ * Output is printed at t = 0, .001, .01, .1, .4, .7, 1.
+ *
+ * Optionally, we can set the number of threads from environment 
+ * variable or command line. To check the current value for number
+ * of threads from environment:
+ *      % echo $OMP_NUM_THREADS
+ *
+ * Execution:
+ *
+ * If the user want to use the default value or the number of threads 
+ * from environment value:
+ *      % ./idaFoodWeb_bnd_omp 
+ * If the user want to specify the number of threads to use
+ *      % ./idaFoodWeb_bnd_omp num_threads
+ * where num_threads is the number of threads the user want to use 
+ *
+ * -----------------------------------------------------------------
+ * References:
+ * [1] Peter N. Brown and Alan C. Hindmarsh,
+ *     Reduced Storage Matrix Methods in Stiff ODE systems, Journal
+ *     of Applied Mathematics and Computation, Vol. 31 (May 1989),
+ *     pp. 40-91.
+ *
+ * [2] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Using Krylov Methods in the Solution of Large-Scale
+ *     Differential-Algebraic Systems, SIAM J. Sci. Comput., 15
+ *     (1994), pp. 1467-1488.
+ *
+ * [3] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Consistent Initial Condition Calculation for Differential-
+ *     Algebraic Systems, SIAM J. Sci. Comput., 19 (1998),
+ *     pp. 1495-1512.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <ida/ida.h>
+#include <ida/ida_band.h>
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_dense.h>
+#include <sundials/sundials_types.h>
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+/* Problem Constants. */
+
+#define NPREY       1              /* No. of prey (= no. of predators). */
+#define NUM_SPECIES 2*NPREY
+
+#define PI          RCONST(3.1415926535898)
+#define FOURPI      (RCONST(4.0)*PI)
+
+#define MX          20             /* MX = number of x mesh points      */
+#define MY          20             /* MY = number of y mesh points      */
+#define NSMX        (NUM_SPECIES * MX)
+#define NEQ         (NUM_SPECIES*MX*MY)
+#define AA          RCONST(1.0)    /* Coefficient in above eqns. for a  */
+#define EE          RCONST(10000.) /* Coefficient in above eqns. for a  */
+#define GG          RCONST(0.5e-6) /* Coefficient in above eqns. for a  */
+#define BB          RCONST(1.0)    /* Coefficient in above eqns. for b  */
+#define DPREY       RCONST(1.0)    /* Coefficient in above eqns. for d  */
+#define DPRED       RCONST(0.05)   /* Coefficient in above eqns. for d  */
+#define ALPHA       RCONST(50.)    /* Coefficient alpha in above eqns.  */
+#define BETA        RCONST(1000.)  /* Coefficient beta in above eqns.   */
+#define AX          RCONST(1.0)    /* Total range of x variable         */
+#define AY          RCONST(1.0)    /* Total range of y variable         */
+#define RTOL        RCONST(1.e-5)  /* Relative tolerance                */
+#define ATOL        RCONST(1.e-5)  /* Absolute tolerance                */
+#define NOUT        6              /* Number of output times            */
+#define TMULT       RCONST(10.0)   /* Multiplier for tout values        */
+#define TADD        RCONST(0.3)    /* Increment for tout values         */
+#define ZERO        RCONST(0.)     
+#define ONE         RCONST(1.0)    
+
+/* 
+ * User-defined vector and accessor macro: IJ_Vptr.
+ * IJ_Vptr is defined in order to express the underlying 3-D structure of 
+ * the dependent variable vector from its underlying 1-D storage (an N_Vector).
+ * IJ_Vptr(vv,i,j) returns a pointer to the location in vv corresponding to 
+ * species index is = 0, x-index ix = i, and y-index jy = j.                
+ */
+
+#define IJ_Vptr(vv,i,j) (&NV_Ith_OMP(vv, (i)*NUM_SPECIES + (j)*NSMX))
+
+/* Type: UserData.  Contains problem constants, etc. */
+
+typedef struct {
+  long int Neq, ns, np, mx, my;
+  realtype dx, dy, **acoef;
+  realtype cox[NUM_SPECIES], coy[NUM_SPECIES], bcoef[NUM_SPECIES];
+  N_Vector rates;
+  int nthreads;
+} *UserData;
+
+/* Prototypes for functions called by the IDA Solver. */
+
+static int resweb(realtype time, N_Vector cc, N_Vector cp, N_Vector resval, 
+                  void *user_data);
+
+/* Prototypes for private Helper Functions. */
+
+static void InitUserData(UserData webdata);
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata);
+static void PrintHeader(long int mu, long int ml, realtype rtol, realtype atol);
+static void PrintOutput(void *mem, N_Vector c, realtype t);
+static void PrintFinalStats(void *mem);
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate, UserData webdata);
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
+                     UserData webdata);
+static realtype dotprod(long int size, realtype *x1, realtype *x2);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{ 
+  void *mem;
+  UserData webdata;
+  N_Vector cc, cp, id;
+  int iout, retval;
+  long int mu, ml;
+  realtype rtol, atol, t0, tout, tret;
+  int num_threads;
+
+  mem = NULL;
+  webdata = NULL;
+  cc = cp = id = NULL;
+
+  /* Set the number of threads to use */
+  num_threads = 1;       /* default value */
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();  /* overwrite with OMP_NUM_THREADS enviroment variable */
+#endif
+  if (argc > 1)      /* overwrite with command line value, if supplied */
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* Allocate and initialize user data block webdata. */
+
+  webdata = (UserData) malloc(sizeof *webdata);
+  webdata->rates = N_VNew_OpenMP(NEQ, num_threads);
+  webdata->acoef = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+  webdata->nthreads = num_threads;
+
+  InitUserData(webdata);
+
+  /* Allocate N-vectors and initialize cc, cp, and id. */
+
+  cc  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cc, "N_VNew_OpenMP", 0)) return(1);
+
+  cp  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cp, "N_VNew_OpenMP", 0)) return(1);
+
+  id  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)id, "N_VNew_OpenMP", 0)) return(1);
+  
+  SetInitialProfiles(cc, cp, id, webdata);
+  
+  /* Set remaining inputs to IDAMalloc. */
+  
+  t0 = ZERO;
+  rtol = RTOL; 
+  atol = ATOL;
+
+  /* Call IDACreate and IDAMalloc to initialize IDA. */
+  
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+
+  retval = IDASetUserData(mem, webdata);
+  if(check_flag(&retval, "IDASetUserData", 1)) return(1);
+
+  retval = IDASetId(mem, id);
+  if(check_flag(&retval, "IDASetId", 1)) return(1);
+
+  retval = IDAInit(mem, resweb, t0, cc, cp);
+  if(check_flag(&retval, "IDAInit", 1)) return(1);
+
+  retval = IDASStolerances(mem, rtol, atol);
+  if(check_flag(&retval, "IDASStolerances", 1)) return(1);
+
+  /* Call IDABand to specify the IDA linear solver. */
+
+  mu = ml = NSMX;
+  retval = IDABand(mem, NEQ, mu, ml);
+  if(check_flag(&retval, "IDABand", 1)) return(1);
+
+  /* Call IDACalcIC (with default options) to correct the initial values. */
+
+  tout = RCONST(0.001);
+  retval = IDACalcIC(mem, IDA_YA_YDP_INIT, tout);
+  if(check_flag(&retval, "IDACalcIC", 1)) return(1);
+  
+  /* Print heading, basic parameters, and initial values. */
+
+  PrintHeader(mu, ml, rtol, atol);
+  PrintOutput(mem, cc, ZERO);
+  
+  /* Loop over iout, call IDASolve (normal mode), print selected output. */
+  
+  for (iout = 1; iout <= NOUT; iout++) {
+    
+    retval = IDASolve(mem, tout, &tret, cc, cp, IDA_NORMAL);
+    if(check_flag(&retval, "IDASolve", 1)) return(retval);
+    
+    PrintOutput(mem, cc, tret);
+    
+    if (iout < 3) tout *= TMULT; else tout += TADD;
+    
+  }
+  
+  /* Print final statistics and free memory. */  
+  
+  PrintFinalStats(mem);
+  printf("num_threads = %i\n\n", num_threads);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+
+  N_VDestroy_OpenMP(cc);
+  N_VDestroy_OpenMP(cp);
+  N_VDestroy_OpenMP(id);
+
+
+  destroyMat(webdata->acoef);
+  N_VDestroy_OpenMP(webdata->rates);
+  free(webdata);
+
+  return(0);
+}
+
+/* Define lines for readability in later routines */ 
+
+#define acoef  (webdata->acoef)
+#define bcoef  (webdata->bcoef)
+#define cox    (webdata->cox)
+#define coy    (webdata->coy)
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDA
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * resweb: System residual function for predator-prey system.
+ * This routine calls Fweb to get all the right-hand sides of the
+ * equations, then loads the residual vector accordingly,
+ * using cp in the case of prey species.                 
+ */
+
+static int resweb(realtype tt, N_Vector cc, N_Vector cp, 
+                  N_Vector res,  void *user_data)
+{
+  long int jx, jy, is, yloc, loc, np;
+  realtype *resv, *cpv;
+  UserData webdata;
+  
+  webdata = (UserData)user_data;
+  
+  cpv = NV_DATA_OMP(cp);
+  resv = NV_DATA_OMP(res);
+  np = webdata->np;
+  
+  /* Call Fweb to set res to vector of right-hand sides. */
+  Fweb(tt, cc, res, webdata);
+  
+  /* Loop over all grid points, setting residual values appropriately
+     for differential or algebraic components.                        */
+#pragma omp parallel for default(shared) private(jy, yloc, jx, loc, is) schedule(static) 
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np)
+          resv[loc+is] = cpv[loc+is] - resv[loc+is];
+        else
+          resv[loc+is] = -resv[loc+is];
+      }
+    }
+  }
+  
+  return(0);
+  
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * InitUserData: Load problem constants in webdata (of type UserData).   
+ */
+
+static void InitUserData(UserData webdata)
+{
+  int i, j, np;
+  realtype *a1,*a2, *a3, *a4, dx2, dy2;
+
+  webdata->mx = MX;
+  webdata->my = MY;
+  webdata->ns = NUM_SPECIES;
+  webdata->np = NPREY;
+  webdata->dx = AX/(MX-1);
+  webdata->dy = AY/(MY-1);
+  webdata->Neq= NEQ;
+  
+  /* Set up the coefficients a and b, and others found in the equations. */
+  np = webdata->np;
+  dx2 = (webdata->dx)*(webdata->dx); dy2 = (webdata->dy)*(webdata->dy);
+  
+  for (i = 0; i < np; i++) {
+    a1 = &(acoef[i][np]);
+    a2 = &(acoef[i+np][0]);
+    a3 = &(acoef[i][0]);
+    a4 = &(acoef[i+np][np]);
+    /*  Fill in the portion of acoef in the four quadrants, row by row. */
+    for (j = 0; j < np; j++) {
+      *a1++ =  -GG;
+      *a2++ =   EE;
+      *a3++ = ZERO;
+      *a4++ = ZERO;
+    }
+    
+    /* Reset the diagonal elements of acoef to -AA. */
+    acoef[i][i] = -AA; acoef[i+np][i+np] = -AA;
+    
+    /* Set coefficients for b and diffusion terms. */
+    bcoef[i] = BB; bcoef[i+np] = -BB;
+    cox[i] = DPREY/dx2; cox[i+np] = DPRED/dx2;
+    coy[i] = DPREY/dy2; coy[i+np] = DPRED/dy2;
+  }
+  
+}
+
+/* 
+ * SetInitialProfiles: Set initial conditions in cc, cp, and id.
+ * A polynomial profile is used for the prey cc values, and a constant
+ * (1.0e5) is loaded as the initial guess for the predator cc values.
+ * The id values are set to 1 for the prey and 0 for the predators.
+ * The prey cp values are set according to the given system, and
+ * the predator cp values are set to zero.                               
+ */
+
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata)
+{
+  long int loc, yloc, is, jx, jy, np;
+  realtype xx, yy, xyfactor;
+  realtype *ccv, *cpv, *idv;
+  
+  ccv = NV_DATA_OMP(cc);
+  cpv = NV_DATA_OMP(cp);
+  idv = NV_DATA_OMP(id);
+  np = webdata->np;
+  
+  /* Loop over grid, load cc values and id values. */
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * webdata->dy;
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * webdata->dx;
+      xyfactor = RCONST(16.0)*xx*(ONE-xx)*yy*(ONE-yy);
+      xyfactor *= xyfactor;
+      loc = yloc + NUM_SPECIES*jx;
+       
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np) {
+          ccv[loc+is] = RCONST(10.0) + (realtype)(is+1) * xyfactor;
+          idv[loc+is] = ONE;
+        }
+        else {
+	  ccv[loc+is] = RCONST(1.0e5);
+          idv[loc+is] = ZERO;
+        }
+      }
+    }
+  }
+  
+  /* Set c' for the prey by calling the function Fweb. */
+  Fweb(ZERO, cc, cp, webdata);
+  
+  /* Set c' for predators to 0. */
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = np; is < NUM_SPECIES; is++) {
+        cpv[loc+is] = ZERO;
+      }
+    }
+  }
+}
+
+/*
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(long int mu, long int ml, realtype rtol, realtype atol)
+{
+  printf("\nidaFoodWeb_bnd_omp: Predator-prey DAE OpenMP example problem for IDA \n\n");
+  printf("Number of species ns: %d", NUM_SPECIES);
+  printf("     Mesh dimensions: %d x %d", MX, MY);
+  printf("     System size: %d\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#endif
+  printf("Linear solver: IDABAND,  Band parameters mu = %ld, ml = %ld\n",mu,ml);
+  printf("CalcIC called to correct initial predator concentrations.\n\n");
+  printf("-----------------------------------------------------------\n");
+  printf("  t        bottom-left  top-right");
+  printf("    | nst  k      h\n");
+  printf("-----------------------------------------------------------\n\n");
+  
+}
+
+/* 
+ * PrintOutput: Print output values at output time t = tt.
+ * Selected run statistics are printed.  Then values of the concentrations
+ * are printed for the bottom left and top right grid points only.  
+ */
+
+static void PrintOutput(void *mem, N_Vector c, realtype t)
+{
+  int i, kused, flag;
+  long int nst;
+  realtype *c_bl, *c_tr, hused;
+
+  flag = IDAGetLastOrder(mem, &kused);
+  check_flag(&flag, "IDAGetLastOrder", 1);
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetLastStep(mem, &hused);
+  check_flag(&flag, "IDAGetLastStep", 1);
+  
+  c_bl = IJ_Vptr(c,0,0);
+  c_tr = IJ_Vptr(c,MX-1,MY-1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("%8.2Le %12.4Le %12.4Le   | %3ld  %1d %12.4Le\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4Le %12.4Le   |\n",c_bl[i],c_tr[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#else
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#endif
+
+  printf("\n");
+}
+
+/* 
+ * PrintFinalStats: Print final run data contained in iopt.              
+ */
+
+static void PrintFinalStats(void *mem)
+{ 
+  long int nst, nre, nreLS, nni, nje, netf, ncfn;
+  int flag;
+
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetNumNonlinSolvIters(mem, &nni);
+  check_flag(&flag, "IDAGetNumNonlinSolvIters", 1);
+  flag = IDAGetNumResEvals(mem, &nre);
+  check_flag(&flag, "IDAGetNumResEvals", 1);
+  flag = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&flag, "IDAGetNumErrTestFails", 1);
+  flag = IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  check_flag(&flag, "IDAGetNumNonlinSolvConvFails", 1);
+  flag = IDADlsGetNumJacEvals(mem, &nje);
+  check_flag(&flag, "IDADlsGetNumJacEvals", 1);
+  flag = IDADlsGetNumResEvals(mem, &nreLS);
+  check_flag(&flag, "IDADlsGetNumResEvals", 1);
+
+  printf("-----------------------------------------------------------\n");
+  printf("Final run statistics: \n\n");
+  printf("Number of steps                    = %ld\n", nst);
+  printf("Number of residual evaluations     = %ld\n", nre+nreLS);
+  printf("Number of Jacobian evaluations     = %ld\n", nje);
+  printf("Number of nonlinear iterations     = %ld\n", nni);
+  printf("Number of error test failures      = %ld\n", netf);
+  printf("Number of nonlinear conv. failures = %ld\n", ncfn);
+
+}
+
+/* 
+ * Fweb: Rate function for the food-web problem.                        
+ * This routine computes the right-hand sides of the system equations,   
+ * consisting of the diffusion term and interaction term.                
+ * The interaction term is computed by the function WebRates.            
+ */
+
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate,  
+                 UserData webdata)
+{ 
+  long int jx, jy, is, idyu, idyl, idxu, idxl;
+  realtype xx, yy, *cxy, *ratesxy, *cratexy, dcyli, dcyui, dcxli, dcxui;
+  
+  /* Loop over grid points, evaluate interaction vector (length ns),
+     form diffusion difference terms, and load crate.                    */
+  
+  for (jy = 0; jy < MY; jy++) {
+    yy = (webdata->dy) * jy ;
+    idyu = (jy!=MY-1) ? NSMX : -NSMX;
+    idyl = (jy!= 0  ) ? NSMX : -NSMX;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = (webdata->dx) * jx;
+      idxu = (jx!= MX-1) ?  NUM_SPECIES : -NUM_SPECIES;
+      idxl = (jx!=  0  ) ?  NUM_SPECIES : -NUM_SPECIES;
+      cxy = IJ_Vptr(cc,jx,jy);
+      ratesxy = IJ_Vptr(webdata->rates,jx,jy);
+      cratexy = IJ_Vptr(crate,jx,jy);
+      
+      /* Get interaction vector at this grid point. */
+      WebRates(xx, yy, cxy, ratesxy, webdata);
+      
+      /* Loop over species, do differencing, load crate segment. */
+#pragma omp parallel for default(shared) private(is, dcyli, dcyui, dcxli, dcxui) schedule(static)
+      for (is = 0; is < NUM_SPECIES; is++) {
+        
+        /* Differencing in y. */
+        dcyli = *(cxy+is) - *(cxy - idyl + is) ;
+        dcyui = *(cxy + idyu + is) - *(cxy+is);
+        
+        /* Differencing in x. */
+        dcxli = *(cxy+is) - *(cxy - idxl + is);
+        dcxui = *(cxy + idxu +is) - *(cxy+is);
+        
+        /* Compute the crate values at (xx,yy). */
+        cratexy[is] = coy[is] * (dcyui - dcyli) +
+          cox[is] * (dcxui - dcxli) + ratesxy[is];
+        
+      } /* End is loop */
+    } /* End of jx loop */
+  } /* End of jy loop */
+  
+}
+
+/* 
+ * WebRates: Evaluate reaction rates at a given spatial point.
+ * At a given (x,y), evaluate the array of ns reaction terms R.
+ */
+
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy,
+                     UserData webdata)
+{
+  int is;
+  realtype fac;
+  
+  for (is = 0; is < NUM_SPECIES; is++)
+    ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]);
+  
+  fac = ONE + ALPHA*xx*yy + BETA*sin(FOURPI*xx)*sin(FOURPI*yy);
+   
+  for (is = 0; is < NUM_SPECIES; is++)  
+    ratesxy[is] = cxy[is]*( bcoef[is]*fac + ratesxy[is] );
+  
+}
+
+/*
+ * dotprod: dot product routine for realtype arrays, for use by WebRates.    
+ */
+
+static realtype dotprod(long int size, realtype *x1, realtype *x2)
+{
+  long int i;
+  realtype *xx1, *xx2, temp = ZERO;
+  
+  xx1 = x1; xx2 = x2;
+  for (i = 0; i < size; i++) temp += (*xx1++) * (*xx2++);
+  return(temp);
+  
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  if (opt == 0 && flagvalue == NULL) {
+    /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1); 
+  }
+
+  return(0);
+}
diff --git a/examples/ida/C_openmp/idaFoodWeb_bnd_omp.out b/examples/ida/C_openmp/idaFoodWeb_bnd_omp.out
new file mode 100644
index 0000000..b7f432d
--- /dev/null
+++ b/examples/ida/C_openmp/idaFoodWeb_bnd_omp.out
@@ -0,0 +1,44 @@
+
+idaFoodWeb_bnd_omp: Predator-prey DAE OpenMP example problem for IDA 
+
+Number of species ns: 2     Mesh dimensions: 20 x 20     System size: 800
+Tolerance parameters:  rtol = 1e-05   atol = 1e-05
+Linear solver: IDABAND,  Band parameters mu = 40, ml = 40
+CalcIC called to correct initial predator concentrations.
+
+-----------------------------------------------------------
+  t        bottom-left  top-right    | nst  k      h
+-----------------------------------------------------------
+
+0.00e+00   1.0000e+01   1.0000e+01   |   0  0   1.6310e-08
+           1.0000e+05   1.0000e+05   |
+
+1.00e-03   1.0318e+01   1.0827e+01   |  32  4   1.0823e-04
+           1.0319e+05   1.0822e+05   |
+
+1.00e-02   1.6188e+02   1.9735e+02   | 127  4   1.4203e-04
+           1.6189e+06   1.9734e+06   |
+
+1.00e-01   2.4019e+02   2.7072e+02   | 235  1   3.9160e-02
+           2.4019e+06   2.7072e+06   |
+
+4.00e-01   2.4019e+02   2.7072e+02   | 238  1   3.1328e-01
+           2.4019e+06   2.7072e+06   |
+
+7.00e-01   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
+           2.4019e+06   2.7072e+06   |
+
+1.00e+00   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
+           2.4019e+06   2.7072e+06   |
+
+-----------------------------------------------------------
+Final run statistics: 
+
+Number of steps                    = 239
+Number of residual evaluations     = 3339
+Number of Jacobian evaluations     = 36
+Number of nonlinear iterations     = 421
+Number of error test failures      = 3
+Number of nonlinear conv. failures = 0
+num_threads = 4
+
diff --git a/examples/ida/C_openmp/idaFoodWeb_kry_omp.c b/examples/ida/C_openmp/idaFoodWeb_kry_omp.c
new file mode 100644
index 0000000..dfc4c27
--- /dev/null
+++ b/examples/ida/C_openmp/idaFoodWeb_kry_omp.c
@@ -0,0 +1,841 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ * -----------------------------------------------------------------
+ * Example program for IDA: Food web problem, OpenMP, GMRES, 
+ * user-supplied preconditioner
+ *
+ * This example program uses the IDASPGMR as the linear 
+ * solver, and IDACalcIC for initial condition calculation.
+ *
+ * The mathematical problem solved in this example is a DAE system
+ * that arises from a system of partial differential equations after
+ * spatial discretization. The PDE system is a food web population
+ * model, with predator-prey interaction and diffusion on the unit
+ * square in two dimensions. The dependent variable vector is:
+ *
+ *         1   2         ns
+ *   c = (c , c ,  ..., c  ) , ns = 2 * np
+ *
+ * and the PDE's are as follows:
+ *
+ *     i             i      i
+ *   dc /dt = d(i)*(c    + c  )  +  R (x,y,c)   (i = 1,...,np)
+ *                   xx     yy       i
+ *
+ *              i      i
+ *   0 = d(i)*(c    + c  )  +  R (x,y,c)   (i = np+1,...,ns)
+ *              xx     yy       i
+ *
+ *   where the reaction terms R are:
+ *
+ *                   i             ns         j
+ *   R  (x,y,c)  =  c  * (b(i)  + sum a(i,j)*c )
+ *    i                           j=1
+ *
+ * The number of species is ns = 2 * np, with the first np being
+ * prey and the last np being predators. The coefficients a(i,j),
+ * b(i), d(i) are:
+ *
+ *  a(i,i) = -AA   (all i)
+ *  a(i,j) = -GG   (i <= np , j >  np)
+ *  a(i,j) =  EE   (i >  np, j <= np)
+ *  all other a(i,j) = 0
+ *  b(i) = BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i <= np)
+ *  b(i) =-BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i  > np)
+ *  d(i) = DPREY   (i <= np)
+ *  d(i) = DPRED   (i > np)
+ *
+ * The various scalar parameters required are set using '#define'
+ * statements or directly in routine InitUserData. In this program,
+ * np = 1, ns = 2. The boundary conditions are homogeneous Neumann:
+ * normal derivative = 0.
+ *
+ * A polynomial in x and y is used to set the initial values of the
+ * first np variables (the prey variables) at each x,y location,
+ * while initial values for the remaining (predator) variables are
+ * set to a flat value, which is corrected by IDACalcIC.
+ *
+ * The PDEs are discretized by central differencing on a MX by MY
+ * mesh.
+ *
+ * The DAE system is solved by IDA using the IDABAND linear solver.
+ * Output is printed at t = 0, .001, .01, .1, .4, .7, 1.
+ *
+ * Optionally, we can set the number of threads from environment 
+ * variable or command line. To check the current value for number
+ * of threads from environment:
+ *      % echo $OMP_NUM_THREADS
+ *
+ * Execution:
+ *
+ * If the user want to use the default value or the number of threads 
+ * from environment value:
+ *      % ./idaFoodWeb_kry_omp 
+ * If the user want to specify the number of threads to use
+ *      % ./idaFoodWeb_kry_omp num_threads
+ * where num_threads is the number of threads the user want to use 
+ *
+ * -----------------------------------------------------------------
+ * References:
+ * [1] Peter N. Brown and Alan C. Hindmarsh,
+ *     Reduced Storage Matrix Methods in Stiff ODE systems, Journal
+ *     of Applied Mathematics and Computation, Vol. 31 (May 1989),
+ *     pp. 40-91.
+ *
+ * [2] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Using Krylov Methods in the Solution of Large-Scale
+ *     Differential-Algebraic Systems, SIAM J. Sci. Comput., 15
+ *     (1994), pp. 1467-1488.
+ *
+ * [3] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Consistent Initial Condition Calculation for Differential-
+ *     Algebraic Systems, SIAM J. Sci. Comput., 19 (1998),
+ *     pp. 1495-1512.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <ida/ida.h>
+#include <ida/ida_spgmr.h>
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_dense.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+/* Problem Constants. */
+
+#define NPREY       1              /* No. of prey (= no. of predators). */
+#define NUM_SPECIES 2*NPREY
+
+#define PI          RCONST(3.1415926535898)
+#define FOURPI      (RCONST(4.0)*PI)
+
+#define MX          20             /* MX = number of x mesh points      */
+#define MY          20             /* MY = number of y mesh points      */
+#define NSMX        (NUM_SPECIES * MX)
+#define NEQ         (NUM_SPECIES*MX*MY)
+#define AA          RCONST(1.0)    /* Coefficient in above eqns. for a  */
+#define EE          RCONST(10000.) /* Coefficient in above eqns. for a  */
+#define GG          RCONST(0.5e-6) /* Coefficient in above eqns. for a  */
+#define BB          RCONST(1.0)    /* Coefficient in above eqns. for b  */
+#define DPREY       RCONST(1.0)    /* Coefficient in above eqns. for d  */
+#define DPRED       RCONST(0.05)   /* Coefficient in above eqns. for d  */
+#define ALPHA       RCONST(50.)    /* Coefficient alpha in above eqns.  */
+#define BETA        RCONST(1000.)  /* Coefficient beta in above eqns.   */
+#define AX          RCONST(1.0)    /* Total range of x variable         */
+#define AY          RCONST(1.0)    /* Total range of y variable         */
+#define RTOL        RCONST(1.e-5)  /* Relative tolerance                */
+#define ATOL        RCONST(1.e-5)  /* Absolute tolerance                */
+#define NOUT        6              /* Number of output times            */
+#define TMULT       RCONST(10.0)   /* Multiplier for tout values        */
+#define TADD        RCONST(0.3)    /* Increment for tout values         */
+#define ZERO        RCONST(0.)     
+#define ONE         RCONST(1.0)    
+
+/* 
+ * User-defined vector and accessor macro: IJ_Vptr.
+ * IJ_Vptr is defined in order to express the underlying 3-D structure of 
+ * the dependent variable vector from its underlying 1-D storage (an N_Vector).
+ * IJ_Vptr(vv,i,j) returns a pointer to the location in vv corresponding to 
+ * species index is = 0, x-index ix = i, and y-index jy = j.                
+ */
+
+#define IJ_Vptr(vv,i,j) (&NV_Ith_OMP(vv, (i)*NUM_SPECIES + (j)*NSMX))
+
+/* Type: UserData.  Contains problem constants, etc. */
+
+typedef struct {
+  long int Neq, ns, np, mx, my;
+  realtype dx, dy, **acoef;
+  realtype cox[NUM_SPECIES], coy[NUM_SPECIES], bcoef[NUM_SPECIES];
+  realtype **PP[MX][MY];
+  long int *pivot[MX][MY];
+  N_Vector rates;
+  N_Vector ewt;
+  void *ida_mem;
+  int nthreads;
+} *UserData;
+
+/* Prototypes for functions called by the IDA Solver. */
+
+static int resweb(realtype time, N_Vector cc, N_Vector cp, N_Vector resval, 
+                  void *user_data);
+
+static int Precond(realtype tt,
+		   N_Vector cc, N_Vector cp, N_Vector rr, 
+		   realtype cj, void *user_data,
+		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int PSolve(realtype tt, 
+		  N_Vector cc, N_Vector cp, N_Vector rr,
+		  N_Vector rvec, N_Vector zvec,
+		  realtype cj, realtype delta, void *user_data,
+		  N_Vector tmp);
+
+/* Prototypes for private Helper Functions. */
+
+static void InitUserData(UserData webdata);
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata);
+static void PrintHeader(long int maxl, realtype rtol, realtype atol);
+static void PrintOutput(void *mem, N_Vector c, realtype t);
+static void PrintFinalStats(void *mem);
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate, UserData webdata);
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
+                     UserData webdata);
+static realtype dotprod(long int size, realtype *x1, realtype *x2);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{ 
+  void *mem;
+  UserData webdata;
+  N_Vector cc, cp, id;
+  int iout, jx, jy, flag;
+  long int maxl;
+  realtype rtol, atol, t0, tout, tret;
+  int num_threads;
+
+  mem = NULL;
+  webdata = NULL;
+  cc = cp = id = NULL;
+
+  /* Set the number of threads to use */
+  num_threads = 1;   /* default value */
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();    /* overwrite with OMP_NUM_THREADS */
+#endif
+  if (argc > 1)      /* overwrithe with command line value, if supplied */
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* Allocate and initialize user data block webdata. */
+
+  webdata = (UserData) malloc(sizeof *webdata);
+  webdata->rates = N_VNew_OpenMP(NEQ, num_threads);
+  webdata->acoef = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+  webdata->ewt = N_VNew_OpenMP(NEQ, num_threads);
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy < MY; jy++) {
+      (webdata->pivot)[jx][jy] = newLintArray(NUM_SPECIES);
+      (webdata->PP)[jx][jy] = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+    }
+  }
+  webdata->nthreads = num_threads;
+
+  InitUserData(webdata);
+
+  /* Allocate N-vectors and initialize cc, cp, and id. */
+
+  cc  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cc, "N_VNew_OpenMP", 0)) return(1);
+
+  cp  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cp, "N_VNew_OpenMP", 0)) return(1);
+
+  id  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)id, "N_VNew_OpenMP", 0)) return(1);
+  
+  SetInitialProfiles(cc, cp, id, webdata);
+  
+  /* Set remaining inputs to IDAMalloc. */
+  
+  t0 = ZERO;
+  rtol = RTOL; 
+  atol = ATOL;
+
+  /* Call IDACreate and IDAMalloc to initialize IDA. */
+  
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+
+  flag = IDASetUserData(mem, webdata);
+  if(check_flag(&flag, "IDASetUserData", 1)) return(1);
+
+  flag = IDASetId(mem, id);
+  if(check_flag(&flag, "IDASetId", 1)) return(1);
+
+  flag = IDAInit(mem, resweb, t0, cc, cp);
+  if(check_flag(&flag, "IDAInit", 1)) return(1);
+
+  flag = IDASStolerances(mem, rtol, atol);
+  if(check_flag(&flag, "IDASStolerances", 1)) return(1);
+
+  webdata->ida_mem = mem;
+
+  /* Call IDASpgmr to specify the IDA linear solver. */
+
+  maxl = 16;                    /* max dimension of the Krylov subspace */
+  flag = IDASpgmr(mem, maxl);
+  if(check_flag(&flag, "IDASpgmr", 1)) return(1);
+
+  flag = IDASpilsSetPreconditioner(mem, Precond, PSolve);
+  if(check_flag(&flag, "IDASpilsSetPreconditioner", 1)) return(1);
+
+  /* Call IDACalcIC (with default options) to correct the initial values. */
+
+  tout = RCONST(0.001);
+  flag = IDACalcIC(mem, IDA_YA_YDP_INIT, tout);
+  if(check_flag(&flag, "IDACalcIC", 1)) return(1);
+  
+  /* Print heading, basic parameters, and initial values. */
+
+  PrintHeader(maxl, rtol, atol);
+  PrintOutput(mem, cc, ZERO);
+  
+  /* Loop over iout, call IDASolve (normal mode), print selected output. */
+  
+  for (iout = 1; iout <= NOUT; iout++) {
+    
+    flag = IDASolve(mem, tout, &tret, cc, cp, IDA_NORMAL);
+    if(check_flag(&flag, "IDASolve", 1)) return(flag);
+    
+    PrintOutput(mem, cc, tret);
+    
+    if (iout < 3) tout *= TMULT; else tout += TADD;
+    
+  }
+  
+  /* Print final statistics and free memory. */  
+  
+  PrintFinalStats(mem);
+  printf("num_threads = %i\n\n", num_threads);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+
+  N_VDestroy_OpenMP(cc);
+  N_VDestroy_OpenMP(cp);
+  N_VDestroy_OpenMP(id);
+
+
+  destroyMat(webdata->acoef);
+  N_VDestroy_OpenMP(webdata->rates);
+  N_VDestroy_OpenMP(webdata->ewt);
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy < MY; jy ++) {
+      destroyArray((webdata->pivot)[jx][jy]);
+      destroyMat((webdata->PP)[jx][jy]);
+    }
+  }
+  free(webdata);
+
+  return(0);
+}
+
+/* Define lines for readability in later routines */ 
+
+#define acoef  (webdata->acoef)
+#define bcoef  (webdata->bcoef)
+#define cox    (webdata->cox)
+#define coy    (webdata->coy)
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDA
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * resweb: System residual function for predator-prey system.
+ * This routine calls Fweb to get all the right-hand sides of the
+ * equations, then loads the residual vector accordingly,
+ * using cp in the case of prey species.                 
+ */
+
+static int resweb(realtype tt, N_Vector cc, N_Vector cp, 
+                  N_Vector res,  void *user_data)
+{
+  long int jx, jy, is, yloc, loc, np;
+  realtype *resv, *cpv;
+  UserData webdata;
+  
+  webdata = (UserData)user_data;
+  
+  cpv = NV_DATA_OMP(cp);
+  resv = NV_DATA_OMP(res);
+  np = webdata->np;
+  
+  /* Call Fweb to set res to vector of right-hand sides. */
+  Fweb(tt, cc, res, webdata);
+  
+  /* Loop over all grid points, setting residual values appropriately
+     for differential or algebraic components.                        */
+#pragma omp parallel for default(shared) private(jy, jx, is, yloc, loc) schedule(static) num_threads(webdata->nthreads)  
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np)
+          resv[loc+is] = cpv[loc+is] - resv[loc+is];
+        else
+          resv[loc+is] = -resv[loc+is];
+      }
+    }
+  }
+  
+  return(0);
+  
+}
+
+
+static int Precond(realtype tt, 
+		   N_Vector cc, N_Vector cp, N_Vector rr, 
+		   realtype cj, void *user_data,
+		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  int flag;
+  realtype uround, xx, yy, del_x, del_y;
+  realtype **Pxy, *ratesxy, *Pxycol, *cxy, *cpxy, *ewtxy, cctmp;
+  realtype inc, fac, sqru, perturb_rates[NUM_SPECIES];
+  int is, js, jx, jy, ret;
+  void *mem;
+  N_Vector ewt;
+  realtype hh;
+  UserData webdata;
+
+  webdata = (UserData) user_data;
+  del_x = webdata->dx;
+  del_y = webdata->dy;
+
+  uround = UNIT_ROUNDOFF;
+  sqru = SUNRsqrt(uround);
+
+  mem = webdata->ida_mem;
+  ewt = webdata->ewt;
+  flag = IDAGetErrWeights(mem, ewt);
+  if(check_flag(&flag, "IDAGetErrWeights", 1)) return(1);
+  flag = IDAGetCurrentStep(mem, &hh);
+  if(check_flag(&flag, "IDAGetCurrentStep", 1)) return(1);
+
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * del_y;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * del_x;
+      Pxy = (webdata->PP)[jx][jy];
+      cxy = IJ_Vptr(cc, jx, jy);
+      cpxy = IJ_Vptr(cp, jx, jy);
+      ewtxy = IJ_Vptr(ewt, jx, jy);
+      ratesxy = IJ_Vptr((webdata->rates), jx, jy);
+
+      for (js = 0; js < NUM_SPECIES; js++) {
+	inc = sqru*(SUNMAX(SUNRabs(cxy[js]), SUNMAX(hh*SUNRabs(cpxy[js]), ONE/ewtxy[js])));
+	cctmp = cxy[js];
+	cxy[js] += inc;
+	fac = -ONE/inc;
+
+	WebRates(xx, yy, cxy, perturb_rates, webdata);
+
+	Pxycol = Pxy[js];
+	
+	for (is = 0; is < NUM_SPECIES; is++)
+	  Pxycol[is] = (perturb_rates[is] - ratesxy[is])*fac;
+
+	if (js < 1) Pxycol[js] += cj;
+	
+	cxy[js] = cctmp;
+      }
+
+      ret = denseGETRF(Pxy, NUM_SPECIES, NUM_SPECIES, (webdata->pivot)[jx][jy]);
+
+      if (ret != 0) return(1);
+    }
+  }
+
+  return(0);
+
+}
+
+
+static int PSolve(realtype tt, 
+		  N_Vector cc, N_Vector cp, N_Vector rr, 
+		  N_Vector rvec, N_Vector zvec,
+		  realtype cj, realtype dalta, 
+		  void *user_data, N_Vector tmp) 
+{
+  realtype **Pxy, *zxy;
+  long int *pivot;
+  int jx, jy;
+  UserData webdata;
+  
+  webdata = (UserData) user_data;
+
+  N_VScale(ONE, rvec, zvec);
+
+#pragma omp parallel for collapse(2) default(shared) private(jx, jy, zxy, Pxy, pivot) schedule(static) num_threads(webdata->nthreads)
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy <MY; jy++) {
+      
+      zxy = IJ_Vptr(zvec, jx, jy);
+      Pxy = (webdata->PP)[jx][jy];
+      pivot = (webdata->pivot)[jx][jy];
+      denseGETRS(Pxy, NUM_SPECIES, pivot, zxy);
+    }
+  }
+  
+  return(0);
+
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * InitUserData: Load problem constants in webdata (of type UserData).   
+ */
+
+static void InitUserData(UserData webdata)
+{
+  int i, j, np;
+  realtype *a1,*a2, *a3, *a4, dx2, dy2;
+
+  webdata->mx = MX;
+  webdata->my = MY;
+  webdata->ns = NUM_SPECIES;
+  webdata->np = NPREY;
+  webdata->dx = AX/(MX-1);
+  webdata->dy = AY/(MY-1);
+  webdata->Neq= NEQ;
+  
+  /* Set up the coefficients a and b, and others found in the equations. */
+  np = webdata->np;
+  dx2 = (webdata->dx)*(webdata->dx); dy2 = (webdata->dy)*(webdata->dy);
+  
+  for (i = 0; i < np; i++) {
+    a1 = &(acoef[i][np]);
+    a2 = &(acoef[i+np][0]);
+    a3 = &(acoef[i][0]);
+    a4 = &(acoef[i+np][np]);
+    /*  Fill in the portion of acoef in the four quadrants, row by row. */
+    for (j = 0; j < np; j++) {
+      *a1++ =  -GG;
+      *a2++ =   EE;
+      *a3++ = ZERO;
+      *a4++ = ZERO;
+    }
+    
+    /* Reset the diagonal elements of acoef to -AA. */
+    acoef[i][i] = -AA; acoef[i+np][i+np] = -AA;
+    
+    /* Set coefficients for b and diffusion terms. */
+    bcoef[i] = BB; bcoef[i+np] = -BB;
+    cox[i] = DPREY/dx2; cox[i+np] = DPRED/dx2;
+    coy[i] = DPREY/dy2; coy[i+np] = DPRED/dy2;
+  }
+  
+}
+
+/* 
+ * SetInitialProfiles: Set initial conditions in cc, cp, and id.
+ * A polynomial profile is used for the prey cc values, and a constant
+ * (1.0e5) is loaded as the initial guess for the predator cc values.
+ * The id values are set to 1 for the prey and 0 for the predators.
+ * The prey cp values are set according to the given system, and
+ * the predator cp values are set to zero.                               
+ */
+
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata)
+{
+  long int loc, yloc, is, jx, jy, np;
+  realtype xx, yy, xyfactor;
+  realtype *ccv, *cpv, *idv;
+  
+  ccv = NV_DATA_OMP(cc);
+  cpv = NV_DATA_OMP(cp);
+  idv = NV_DATA_OMP(id);
+  np = webdata->np;
+  
+  /* Loop over grid, load cc values and id values. */
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * webdata->dy;
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * webdata->dx;
+      xyfactor = RCONST(16.0)*xx*(ONE-xx)*yy*(ONE-yy);
+      xyfactor *= xyfactor;
+      loc = yloc + NUM_SPECIES*jx;
+       
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np) {
+          ccv[loc+is] = RCONST(10.0) + (realtype)(is+1) * xyfactor;
+          idv[loc+is] = ONE;
+        }
+        else {
+	  ccv[loc+is] = RCONST(1.0e5);
+          idv[loc+is] = ZERO;
+        }
+      }
+    }
+  }
+  
+  /* Set c' for the prey by calling the function Fweb. */
+  Fweb(ZERO, cc, cp, webdata);
+  
+  /* Set c' for predators to 0. */
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = np; is < NUM_SPECIES; is++) {
+        cpv[loc+is] = ZERO;
+      }
+    }
+  }
+}
+
+/*
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(long int maxl, realtype rtol, realtype atol)
+{
+  printf("\nidaFoodWeb_kry_omp: Predator-prey DAE OpenMP example problem using Krylov solver for IDA \n\n");
+  printf("Number of species ns: %d", NUM_SPECIES);
+  printf("     Mesh dimensions: %d x %d", MX, MY);
+  printf("     System size: %d\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#endif
+  printf("Linear solver: IDASpgmr,  Spgmr parameters maxl = %ld\n",maxl);
+  printf("CalcIC called to correct initial predator concentrations.\n\n");
+  printf("-----------------------------------------------------------\n");
+  printf("  t        bottom-left  top-right");
+  printf("    | nst  k      h\n");
+  printf("-----------------------------------------------------------\n\n");
+  
+}
+
+/* 
+ * PrintOutput: Print output values at output time t = tt.
+ * Selected run statistics are printed.  Then values of the concentrations
+ * are printed for the bottom left and top right grid points only.  
+ */
+
+static void PrintOutput(void *mem, N_Vector c, realtype t)
+{
+  int i, kused, flag;
+  long int nst;
+  realtype *c_bl, *c_tr, hused;
+
+  flag = IDAGetLastOrder(mem, &kused);
+  check_flag(&flag, "IDAGetLastOrder", 1);
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetLastStep(mem, &hused);
+  check_flag(&flag, "IDAGetLastStep", 1);
+  
+  c_bl = IJ_Vptr(c,0,0);
+  c_tr = IJ_Vptr(c,MX-1,MY-1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("%8.2Le %12.4Le %12.4Le   | %3ld  %1d %12.4Le\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4Le %12.4Le   |\n",c_bl[i],c_tr[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#else
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#endif
+
+  printf("\n");
+}
+
+/* 
+ * PrintFinalStats: Print final run data contained in iopt.              
+ */
+
+static void PrintFinalStats(void *mem)
+{ 
+  long int nst, nre, sli, netf, nps, npevals, nrevalsLS;
+  int flag;
+
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDASpilsGetNumLinIters(mem, &sli);
+  check_flag(&flag, "IDAGetNumNonlinSolvIters", 1);
+  flag = IDAGetNumResEvals(mem, &nre);
+  check_flag(&flag, "IDAGetNumResEvals", 1);
+  flag = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&flag, "IDAGetNumErrTestFails", 1);
+  flag = IDASpilsGetNumPrecSolves(mem, &nps);
+  check_flag(&flag, "IDAGetNumNonlinSolvConvFails", 1);
+  flag = IDASpilsGetNumPrecEvals(mem, &npevals);
+  check_flag(&flag, "IDADlsGetNumJacEvals", 1);
+  flag = IDASpilsGetNumResEvals(mem, &nrevalsLS);
+  check_flag(&flag, "IDADlsGetNumResEvals", 1);
+
+  printf("-----------------------------------------------------------\n");
+  printf("Final run statistics: \n\n");
+  printf("Number of steps                       = %ld\n", nst);
+  printf("Number of residual evaluations        = %ld\n", nre);
+  printf("Number of Preconditioner evaluations  = %ld\n", npevals);
+  printf("Number of linear iterations           = %ld\n", sli);
+  printf("Number of error test failures         = %ld\n", netf);
+  printf("Number of precond solve fun called    = %ld\n", nps);
+
+}
+
+/* 
+ * Fweb: Rate function for the food-web problem.                        
+ * This routine computes the right-hand sides of the system equations,   
+ * consisting of the diffusion term and interaction term.                
+ * The interaction term is computed by the function WebRates.            
+ */
+
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate,  
+                 UserData webdata)
+{ 
+  long int jx, jy, is, idyu, idyl, idxu, idxl;
+  realtype xx, yy, *cxy, *ratesxy, *cratexy, dcyli, dcyui, dcxli, dcxui;
+  
+  /* Loop over grid points, evaluate interaction vector (length ns),
+     form diffusion difference terms, and load crate.                    */
+  
+  for (jy = 0; jy < MY; jy++) {
+    yy = (webdata->dy) * jy ;
+    idyu = (jy!=MY-1) ? NSMX : -NSMX;
+    idyl = (jy!= 0  ) ? NSMX : -NSMX;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = (webdata->dx) * jx;
+      idxu = (jx!= MX-1) ?  NUM_SPECIES : -NUM_SPECIES;
+      idxl = (jx!=  0  ) ?  NUM_SPECIES : -NUM_SPECIES;
+      cxy = IJ_Vptr(cc,jx,jy);
+      ratesxy = IJ_Vptr(webdata->rates,jx,jy);
+      cratexy = IJ_Vptr(crate,jx,jy);
+      
+      /* Get interaction vector at this grid point. */
+      WebRates(xx, yy, cxy, ratesxy, webdata);
+      
+      /* Loop over species, do differencing, load crate segment. */
+#pragma omp parallel for default(shared) private(is, dcyli, dcyui, dcxli, dcxui) schedule(static) num_threads(webdata->nthreads)
+      for (is = 0; is < NUM_SPECIES; is++) {
+        
+        /* Differencing in y. */
+        dcyli = *(cxy+is) - *(cxy - idyl + is) ;
+        dcyui = *(cxy + idyu + is) - *(cxy+is);
+        
+        /* Differencing in x. */
+        dcxli = *(cxy+is) - *(cxy - idxl + is);
+        dcxui = *(cxy + idxu +is) - *(cxy+is);
+        
+        /* Compute the crate values at (xx,yy). */
+        cratexy[is] = coy[is] * (dcyui - dcyli) +
+          cox[is] * (dcxui - dcxli) + ratesxy[is];
+        
+      } /* End is loop */
+    } /* End of jx loop */
+  } /* End of jy loop */
+  
+}
+
+/* 
+ * WebRates: Evaluate reaction rates at a given spatial point.
+ * At a given (x,y), evaluate the array of ns reaction terms R.
+ */
+
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy,
+                     UserData webdata)
+{
+  int is;
+  realtype fac;
+  
+  for (is = 0; is < NUM_SPECIES; is++)
+    ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]);
+  
+  fac = ONE + ALPHA*xx*yy + BETA*sin(FOURPI*xx)*sin(FOURPI*yy);
+  
+  for (is = 0; is < NUM_SPECIES; is++)  
+    ratesxy[is] = cxy[is]*( bcoef[is]*fac + ratesxy[is] );
+  
+}
+
+/*
+ * dotprod: dot product routine for realtype arrays, for use by WebRates.    
+ */
+
+static realtype dotprod(long int size, realtype *x1, realtype *x2)
+{
+  long int i;
+  realtype *xx1, *xx2, temp = ZERO;
+  
+  xx1 = x1; xx2 = x2;
+  for (i = 0; i < size; i++) temp += (*xx1++) * (*xx2++);
+  return(temp);
+  
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  if (opt == 0 && flagvalue == NULL) {
+    /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1); 
+  }
+
+  return(0);
+}
diff --git a/examples/ida/C_openmp/idaFoodWeb_kry_omp.out b/examples/ida/C_openmp/idaFoodWeb_kry_omp.out
new file mode 100644
index 0000000..3d02611
--- /dev/null
+++ b/examples/ida/C_openmp/idaFoodWeb_kry_omp.out
@@ -0,0 +1,44 @@
+
+idaFoodWeb_kry_omp: Predator-prey DAE OpenMP example problem using Krylov solver for IDA 
+
+Number of species ns: 2     Mesh dimensions: 20 x 20     System size: 800
+Tolerance parameters:  rtol = 1e-05   atol = 1e-05
+Linear solver: IDASpgmr,  Spgmr parameters maxl = 16
+CalcIC called to correct initial predator concentrations.
+
+-----------------------------------------------------------
+  t        bottom-left  top-right    | nst  k      h
+-----------------------------------------------------------
+
+0.00e+00   1.0000e+01   1.0000e+01   |   0  0   1.6310e-08
+           1.0000e+05   1.0000e+05   |
+
+1.00e-03   1.0318e+01   1.0827e+01   |  33  4   9.7404e-05
+           1.0319e+05   1.0822e+05   |
+
+1.00e-02   1.6189e+02   1.9735e+02   |  86  4   1.7533e-04
+           1.6189e+06   1.9735e+06   |
+
+1.00e-01   2.4019e+02   2.7072e+02   | 163  1   4.0396e-02
+           2.4019e+06   2.7072e+06   |
+
+4.00e-01   2.4019e+02   2.7072e+02   | 166  1   3.2316e-01
+           2.4019e+06   2.7072e+06   |
+
+7.00e-01   2.4019e+02   2.7072e+02   | 167  1   6.4633e-01
+           2.4019e+06   2.7072e+06   |
+
+1.00e+00   2.4019e+02   2.7072e+02   | 167  1   6.4633e-01
+           2.4019e+06   2.7072e+06   |
+
+-----------------------------------------------------------
+Final run statistics: 
+
+Number of steps                       = 167
+Number of residual evaluations        = 208
+Number of Preconditioner evaluations  = 25
+Number of linear iterations           = 1040
+Number of error test failures         = 0
+Number of precond solve fun called    = 1248
+num_threads = 4
+
diff --git a/examples/ida/fcmix_openmp/CMakeLists.txt b/examples/ida/fcmix_openmp/CMakeLists.txt
new file mode 100644
index 0000000..92c4829
--- /dev/null
+++ b/examples/ida/fcmix_openmp/CMakeLists.txt
@@ -0,0 +1,150 @@
+# ---------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Radu Serban @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the FIDA opemp examples
+
+
+# Only include tests if OpenMP is enabled
+IF(OPENMP_FOUND)
+
+# Add variable ida_examples with the names of the openmp FIDA examples
+SET(FIDA_examples
+  fidaRoberts_dns_openmp
+  )
+
+# Add variable FIDA_examples_BL with the names of the openmp FIDA examples
+# that use Lapack
+
+SET(FIDA_examples_BL
+  )
+ENDIF(OPENMP_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_static)
+  SET(NVECS_LIB sundials_nvecopenmp_static)
+  SET(FNVECS_LIB sundials_fnvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_shared)
+  SET(NVECS_LIB sundials_nvecopenmp_shared)
+  SET(FNVECS_LIB sundials_fnvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Only static FCMIX libraries are available
+
+SET(FIDA_LIB sundials_fida_static)
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${FIDA_LIB} ${IDA_LIB} ${FNVECS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(PETSC_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_FOUND)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+
+# Add the build and install targets for each FIDA example
+
+FOREACH(example ${FIDA_examples})
+  ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${FIDA_examples})
+
+# If Lapack support is enabled, add the build and install targets for
+# the examples using Lapack
+
+IF(LAPACK_FOUND)
+  FOREACH(example ${FIDA_examples_BL})
+    ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_openmp)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${FIDA_examples_BL})
+ENDIF(LAPACK_FOUND)
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_openmp)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "IDA")
+  SET(SOLVER_LIB "sundials_ida")
+  SET(SOLVER_FLIB "sundials_fida")
+  LIST2STRING(FIDA_examples EXAMPLES)
+  IF(LAPACK_FOUND)
+    LIST2STRING(FIDA_examples_BL EXAMPLES_BL)
+  ELSE(LAPACK_FOUND)
+    SET(EXAMPLES_BL "")
+  ENDIF(LAPACK_FOUND)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/fcmix_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/ida/fcmix_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_openmp 
+    )
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/fcmix_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/ida/fcmix_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/ida/fcmix_openmp/README b/examples/ida/fcmix_openmp/README
new file mode 100644
index 0000000..dbbf3af
--- /dev/null
+++ b/examples/ida/fcmix_openmp/README
@@ -0,0 +1,49 @@
+List of OpenMP IDA FCMIX examples
+
+  fidaRoberts_dns_openmp : 3-species Robertson kinetics system with OpenMP
+  
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/fcmix_openmp/fidaRoberts_dns_openmp.f b/examples/ida/fcmix_openmp/fidaRoberts_dns_openmp.f
new file mode 100644
index 0000000..834309f
--- /dev/null
+++ b/examples/ida/fcmix_openmp/fidaRoberts_dns_openmp.f
@@ -0,0 +1,271 @@
+c     ----------------------------------------------------------------
+c     $Revision: 4392 $
+c     $Date: 2015-02-25 17:22:27 -0800 (Wed, 25 Feb 2015) $
+c     ----------------------------------------------------------------
+c     This simple example problem for FIDA, due to Robertson, is from 
+c     chemical kinetics, and consists of the following three equations:
+c
+c          dy1/dt = -.04*y1 + 1.e4*y2*y3
+c          dy2/dt =  .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+c             0   = y1 + y2 + y3 - 1
+c
+c     on the interval from t = 0.0 to t = 4.e10, with initial
+c     conditions: y1 = 1, y2 = y3 = 0.
+c
+c     While integrating the system, we also employ the rootfinding feature
+c     to find the points at which y1 = 1.e-4 or at which y3 = 0.01.
+c
+c     The problem is solved using a dense linear solver, with a
+c     user-supplied Jacobian. Output is printed at
+c     t = .4, 4, 40, ..., 4e10.
+c     ----------------------------------------------------------------
+c
+      program fidaRoberts_dns
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*8 neq
+      integer*8 iout(25), ipar
+      integer ier, ierroot, info(2)
+      double precision rout(10), rpar
+      integer iatol, nout, jout, itask
+      integer nst, kused, hused, i
+      double precision t0, t1, rtol, tout, tret
+      double precision y(3), yp(3), atol(3)
+c
+      data nst/3/, kused/9/, hused/2/
+
+      integer nthreads
+      nthreads = 4
+c
+c Initialize variables
+c
+      neq = 3
+      nout = 12
+      rtol = 1.0d-4
+      t0 = 0.0d0
+      t1 = 0.4d0
+      iatol = 2
+      itask = 1
+c
+      y(1) = 1.0d0
+      y(2) = 0.0d0
+      y(3) = 0.0d0
+c
+      yp(1) = -0.04d0
+      yp(2) = 0.04d0
+      yp(3) = 0.0d0
+c
+      atol(1) = 1.0d-6
+      atol(2) = 1.0d-10
+      atol(3) = 1.0d-6
+c
+c Initialize IDA vector environment
+c
+      call fnvinitomp(2, neq, nthreads, ier)
+      if (ier .ne. 0) then
+         write(6,10) ier
+ 10      format(///' SUNDIALS_ERROR: FNVINITS returned IER = ', i5)
+         stop
+      endif
+c
+      call fidamalloc(t0, y, yp, iatol, rtol, atol, 
+     &                iout, rout, ipar, rpar, ier)
+      if (ier .ne. 0) then
+         write(6,20) ier
+ 20      format(///' SUNDIALS_ERROR: FIDAMALLOC returned IER = ', i5)
+         stop
+      endif
+c
+c Initialize rootfinding problem
+
+      call fidarootinit(2, ier)
+      if (ier .ne. 0) then
+         write(6,25) ier
+ 25      format(///' SUNDIALS_ERROR: FIDAROOTINIT returned IER = ', i5)
+         call fidafree
+         stop
+      endif
+c
+c Attach dense linear solver
+c
+      call fidadense(neq, ier)
+      call fidadensesetjac(1, ier)
+c
+c Print header
+c
+      call prntintro(rtol, atol, y)
+c
+      tout = t1
+c
+c
+      jout = 1
+      do while(jout .le. nout)
+c
+        call fidasolve(tout, tret, y, yp, itask, ier)
+c
+        write(6,40) tret, (y(i), i = 1,3), iout(nst), iout(kused),
+     &              rout(hused)
+ 40     format(e10.4, 3(1x,e12.4), i5, i3, e12.4)
+c
+        if (ier .lt. 0) then
+           write(6,50) ier, iout(15)
+ 50        format(///' SUNDIALS_ERROR: FIDASOLVE returned IER = ',i5,/,
+     1            '                 Linear Solver returned IER = ',i5)
+           call fidarootfree
+           call fidafree
+           stop
+        endif
+c
+        if (ier .eq. 2) then
+          call fidarootinfo(2, info, ierroot)
+          if (ierroot .lt. 0) then
+            write(6,55) ier
+ 55         format(///' SUNDIALS_ERROR: FIDAROOTINFO returned IER = ',
+     1             i5)
+            call fidarootfree
+            call fidafree
+            stop
+          endif
+          write(6,60) (info(i), i = 1,2)
+ 60       format(5x, 'Above is a root, INFO() = ', 2i3)
+        endif                   
+c
+        if (ier .eq. 0) then
+           tout = tout * 10.0d0
+           jout = jout + 1
+        endif
+c
+      ENDDO
+c
+c Print final statistics
+c
+      call prntstats(iout)
+c
+c Free IDA memory
+c
+      call fidarootfree
+      call fidafree
+c
+      stop
+      end
+c
+c ==========
+c
+      subroutine fidaresfun(tres, y, yp, res, ipar, rpar, reserr)
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*4 ipar(*)
+      integer reserr
+      double precision tres, rpar(*)
+      double precision y(*), yp(*), res(*)
+c
+      res(1) = -0.04d0*y(1)+1.0d4*y(2)*y(3)
+      res(2) = -res(1)-3.0d7*y(2)*y(2)-yp(2)
+      res(1) = res(1)-yp(1)
+      res(3) = y(1)+y(2)+y(3)-1.0d0
+c
+      reserr = 0
+c
+      return
+      end
+c
+c ==========
+c
+      subroutine fidadjac(neq, t, y, yp, r, jac, cj, ewt, h,
+     1                    ipar, rpar, wk1, wk2, wk3, djacerr)
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*4 neq, ipar(*)
+      integer djacerr
+      double precision t, h, cj, rpar(*)
+      double precision y(*), yp(*), r(*), ewt(*), jac(neq,neq)
+      double precision wk1(*), wk2(*), wk3(*)
+c
+      jac(1,1) = -0.04d0-cj
+      jac(2,1) = 0.04d0
+      jac(3,1) = 1.0d0
+      jac(1,2) = 1.0d4*y(3)
+      jac(2,2) = -1.0d4*y(3)-6.0d7*y(2)-cj
+      jac(3,2) = 1.0d0
+      jac(1,3) = 1.0d4*y(2)
+      jac(2,3) = -1.0d4*y(2)
+      jac(3,3) = 1.0d0
+c
+      djacerr = 0
+
+      return
+      end
+c
+c ==========
+c
+      subroutine fidarootfn(t, y, yp, g, ipar, rpar, ier)
+c Fortran routine for rootfinding
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*4 ipar(*)
+      integer ier
+      double precision t, y(*), yp(*), g(*), rpar(*)
+c
+      g(1) = y(1) - 1.0d-4
+      g(2) = y(3) - 1.0d-2
+
+      ier = 0
+
+      return
+      end
+c
+c ==========
+c
+      subroutine prntintro(rtol, atol, y)
+c
+      implicit none
+c
+      integer i
+      double precision rtol, atol(*), y(*)
+c
+      write(6,60) rtol, (atol(i), i = 1,3), (y(i), i = 1,3)
+ 60   format(/'fidaRoberts_dns: Robertson kinetics DAE serial example',
+     &       'problem for IDA', /,'          Three equation chemical',
+     &       'kinetics problem.', //,
+     &       'Tolerance parameters:  rtol = ', e8.2,
+     &       '   atol = ', 3(1x,e8.2), /,
+     &       'Initial conditions y0 = (', 3(1x,e8.2), ')', //,
+     &       '  t            y1           y2           y3        nst',
+     &       '  k    h')
+c
+      return
+      end
+c
+c ==========
+c
+      subroutine prntstats(iout)
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*8 iout(25)
+      integer nst, reseval, jaceval, nni, ncf, netf, nge
+c
+      data nst/3/, reseval/4/, jaceval/17/, nni/7/, netf/5/,
+     &     ncf/6/, nge/12/
+c
+      write(6,70) iout(nst), iout(reseval), iout(jaceval),
+     &             iout(nni), iout(netf), iout(ncf), iout(nge)
+ 70   format(/'Final Run Statistics:', //,
+     &         'Number of steps                    = ', i3, /,
+     &         'Number of residual evaluations     = ', i3, /,
+     &         'Number of Jacobian evaluations     = ', i3, /,
+     &         'Number of nonlinear iterations     = ', i3, /,
+     &         'Number of error test failures      = ', i3, /,
+     &         'Number of nonlinear conv. failures = ', i3, /,
+     &         'Number of root function evals.     = ', i3)
+c
+      return
+      end
diff --git a/examples/ida/fcmix_openmp/fidaRoberts_dns_openmp.out b/examples/ida/fcmix_openmp/fidaRoberts_dns_openmp.out
new file mode 100644
index 0000000..7809e8a
--- /dev/null
+++ b/examples/ida/fcmix_openmp/fidaRoberts_dns_openmp.out
@@ -0,0 +1,34 @@
+
+fidaRoberts_dns: Robertson kinetics DAE serial exampleproblem for IDA
+          Three equation chemicalkinetics problem.
+
+Tolerance parameters:  rtol = 0.10E-03   atol =  0.10E-05 0.10E-09 0.10E-05
+Initial conditions y0 = ( 0.10E+01 0.00E+00 0.00E+00)
+
+  t            y1           y2           y3        nst  k    h
+0.2640E+00   0.9900E+00   0.3471E-04   0.1000E-01   75  2  0.5716E-01
+     Above is a root, INFO() =   0  1
+0.4000E+00   0.9852E+00   0.3386E-04   0.1480E-01   77  3  0.1143E+00
+0.4000E+01   0.9055E+00   0.2240E-04   0.9447E-01   91  4  0.3704E+00
+0.4000E+02   0.7158E+00   0.9185E-05   0.2842E+00  127  4  0.2963E+01
+0.4000E+03   0.4505E+00   0.3223E-05   0.5495E+00  177  3  0.1241E+02
+0.4000E+04   0.1832E+00   0.8940E-06   0.8168E+00  228  3  0.2765E+03
+0.4000E+05   0.3899E-01   0.1622E-06   0.9610E+00  278  5  0.2614E+04
+0.4000E+06   0.4939E-02   0.1985E-07   0.9951E+00  324  5  0.2770E+05
+0.4000E+07   0.5176E-03   0.2072E-08   0.9995E+00  355  4  0.3979E+06
+0.2075E+08   0.1000E-03   0.4000E-09   0.9999E+00  374  4  0.1592E+07
+     Above is a root, INFO() =  -1  0
+0.4000E+08   0.5191E-04   0.2076E-09   0.9999E+00  380  3  0.6366E+07
+0.4000E+09   0.5882E-05   0.2353E-10   0.1000E+01  394  1  0.9167E+08
+0.4000E+10   0.7054E-06   0.2822E-11   0.1000E+01  402  1  0.1467E+10
+0.4000E+11  -0.7300E-06  -0.2920E-11   0.1000E+01  407  1  0.2347E+11
+
+Final Run Statistics:
+
+Number of steps                    = 407
+Number of residual evaluations     = 557
+Number of Jacobian evaluations     =  65
+Number of nonlinear iterations     = 557
+Number of error test failures      =   6
+Number of nonlinear conv. failures =   0
+Number of root function evals.     = 445
diff --git a/examples/ida/fcmix_parallel/CMakeLists.txt b/examples/ida/fcmix_parallel/CMakeLists.txt
index 147c466..e3104a8 100644
--- a/examples/ida/fcmix_parallel/CMakeLists.txt
+++ b/examples/ida/fcmix_parallel/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the FIDA parallel examples
 
@@ -15,7 +20,7 @@
 # Add variable ida_examples with the names of the parallel IDA examples
 
 SET(FIDA_examples
-  fidaHeat2D_kry_bbd_p
+  "fidaHeat2D_kry_bbd_p\;1\;4"
   )
 
 # Check whether we use MPI compiler scripts.
@@ -51,14 +56,31 @@ SET(FIDA_LIB sundials_fida_static)
 
 SET(SUNDIALS_LIBS ${FIDA_LIB} ${IDA_LIB} ${FNVECP_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(PETSC_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_FOUND)
+
 # Add the build and install targets for each IDA example
 
-FOREACH(example ${FIDA_examples})
+FOREACH(example_tuple ${FIDA_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
   ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPIF77)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -66,7 +88,7 @@ FOREACH(example ${FIDA_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${FIDA_examples})
+ENDFOREACH(example_tuple ${FIDA_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -77,7 +99,10 @@ IF(EXAMPLES_INSTALL)
   SET(SOLVER "IDA")
   SET(SOLVER_LIB "sundials_ida")
   SET(SOLVER_FLIB "sundials_fida")
-  LIST2STRING(FIDA_examples EXAMPLES)
+  FOREACH(example_tuple ${FIDA_examples})
+    list(GET example_tuple 0 example)
+    LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${FIDA_examples})
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/ida/fcmix_parallel/Makefile.in b/examples/ida/fcmix_parallel/Makefile.in
deleted file mode 100644
index 827ea68..0000000
--- a/examples/ida/fcmix_parallel/Makefile.in
+++ /dev/null
@@ -1,114 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2005, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FIDA parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-FFLAGS       = @FFLAGS@
-F77_LDFLAGS  = @F77_LDFLAGS@
-F77_LIBS     = @F77_LIBS@
-
-MPIF77       = @MPIF77@
-MPI_INC_DIR  = @MPI_INC_DIR@
-MPI_FLAGS    = @MPI_FLAGS@
-MPIF77_LNKR  = @MPIF77_LNKR@
-MPI_LIB_DIR  = @MPI_LIB_DIR@
-MPI_LIBS     = @MPI_LIBS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_LIBS = $(top_builddir)/src/ida/fcmix/libsundials_fida.la         \
-                $(top_builddir)/src/ida/libsundials_ida.la                \
-                $(top_builddir)/src/nvec_par/libsundials_fnvecparallel.la \
-                $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-fortran-update = ${SHELL} ${top_builddir}/bin/fortran-update.sh
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = fidaHeat2D_kry_bbd_p
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${MPIF77} ${MPI_FLAGS} -I${MPI_INC_DIR} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${MPIF77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${MPI_FLAGS} ${F77_LDFLAGS} ${SUNDIALS_LIBS} -L${MPI_LIB_DIR} ${MPI_LIBS} ${F77_LIBS} $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/ida/fcmix_parallel
-	$(INSTALL_FILE) Makefile_ex  $(EXS_INSTDIR)/ida/fcmix_parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_parallel/README  $(EXS_INSTDIR)/ida/fcmix_parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_parallel/$${i}.f   $(EXS_INSTDIR)/ida/fcmix_parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_parallel/$${i}.out $(EXS_INSTDIR)/ida/fcmix_parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/ida/fcmix_parallel/Makefile
-	rm -f $(EXS_INSTDIR)/ida/fcmix_parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/ida/fcmix_parallel/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/ida/fcmix_parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/ida/fcmix_parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/ida
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f *-updated.f
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/ida/fcmix_parallel/README b/examples/ida/fcmix_parallel/README
index 1e3a43d..1c065c8 100644
--- a/examples/ida/fcmix_parallel/README
+++ b/examples/ida/fcmix_parallel/README
@@ -2,14 +2,48 @@ List of parallel IDA FCMIX examples
 
   fidaHeat2D_kry_bbd_p : 2D heat equation (SPGMR w/FIDABBD preconditioner)
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/fcmix_parallel/fidaHeat2D_kry_bbd_p.f b/examples/ida/fcmix_parallel/fidaHeat2D_kry_bbd_p.f
index 901e47e..00083ea 100644
--- a/examples/ida/fcmix_parallel/fidaHeat2D_kry_bbd_p.f
+++ b/examples/ida/fcmix_parallel/fidaHeat2D_kry_bbd_p.f
@@ -1,6 +1,6 @@
 c     ----------------------------------------------------------------
-c     $Revision: 1.3 $
-c     $Date: 2009/09/30 23:29:59 $
+c     $Revision: 4830 $
+c     $Date: 2016-07-27 17:50:35 -0700 (Wed, 27 Jul 2016) $
 c     ----------------------------------------------------------------
 c     Example problem for FIDA: 2D heat equation, parallel, GMRES,
 c     IDABBDPRE.
@@ -36,23 +36,24 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
-      integer*4 mudq, mldq, mukeep, mlkeep
-      integer*4 iout(25), ipar
-      double precision rout(10), rpar
+c The following declaration specification should match C type long int.
+      integer*8 mudq, mldq, mukeep, mlkeep, iout(25), ipar(1)
+      double precision rout(10), rpar(1)
       integer nout, ier
       parameter (nout = 11)
       integer npes, inopt, maxl, gstype, maxrs, itask, iatol
+      integer nlocalg
+      parameter (nlocalg = mxsubg*mysubg)
       double precision t0, t1, tout, tret, dqrely, eplifac, dqincfac
       double precision atol, rtol
       double precision constr(nlocalg), uu(nlocalg), up(nlocalg)
@@ -61,7 +62,7 @@ c
       data atol/1.0d-3/, rtol/0.0d0/
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
 c Initialize variables
@@ -273,25 +274,26 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub, ipar(*)
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy, rpar(*)
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
-      integer*4 i, iloc, j, jloc, offset, loc
-      integer*4 ixbegin, ixend, jybegin, jyend
+c The following declaration specification should match C type long int.
+      integer*8 ipar(*)
+      integer i, iloc, j, jloc, offset, loc
+      integer ixbegin, ixend, jybegin, jyend
       integer reserr
       double precision xfact, yfact
       double precision uu(*), up(*), id(*), res(*), constr(*)
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
 c Initialize variables
@@ -350,23 +352,24 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub, ipar(*)
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy, rpar(*)
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
+c The following declaration specification should match C type long int.
+      integer*8 ipar(*)
       integer reserr
       double precision tres
       double precision u(*), up(*), res(*)
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       call fidacommfn(nlocal, tres, u, up, ipar, rpar, reserr)
@@ -384,18 +387,18 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub, ipar(*)
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy, rpar(*)
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
-      integer*4 nloc
+c The following declaration specification should match C type long int.
+      integer*8 nloc, ipar(*)
       integer reserr
       double precision tres, u(*), up(*)
 c
@@ -403,7 +406,7 @@ c
       double precision buffer(2*mysub)
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       call brecvpost(request, mxsub, mysub, buffer)
@@ -421,27 +424,27 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub, ipar(*)
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy, rpar(*)
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
-      integer*4 nloc
+c The following declaration specification should match C type long int.
+      integer*8 nloc, ipar(*)
       integer reserr
       double precision tres, u(*), up(*), res(*)
 c
-      integer*4 i, lx, ly, offsetu, offsetue, locu, locue
-      integer*4 ixbegin, ixend, jybegin, jyend, mxsub2
+      integer i, lx, ly, offsetu, offsetue, locu, locue
+      integer ixbegin, ixend, jybegin, jyend, mxsub2
       double precision termx, termy, termctr
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       mxsub2 = mxsub+2
@@ -499,25 +502,24 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
-      integer*4 dsizex, dsizey
+      integer dsizex, dsizey
       double precision uarray(*)
 c
       integer ier, offsetu
       double precision bufleft(mysub), bufright(mysub)
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       if (jysub .ne. 0) then
@@ -560,26 +562,24 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
-      integer*4 dsizex, dsizey
+      integer dsizex, dsizey
       integer request(*)
       double precision buffer(*)
-c
       integer ier
-      integer*4 offsetue
+      integer offsetue
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       if (jysub .ne. 0) then
@@ -618,26 +618,24 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
       integer request(*)
-      integer*4 dsizex
+      integer dsizex
       double precision buffer(*)
-c
-      integer*4 ly, dsizex2, offsetue
+      integer ly, dsizex2, offsetue
       integer ier, status(mpi_status_size)
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       dsizex2 = dsizex+2
@@ -675,22 +673,22 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c  local variables
 c
-      integer*4 iout(*), lenrwbbd, leniwbbd, ngebbd
+c The following declaration specification should match C type long int.
+      integer*8 iout(*), lenrwbbd, leniwbbd, ngebbd
       double precision tret, umax, u(*), rout(*)
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       call maxnorm(u, umax)
@@ -716,23 +714,21 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy
       double precision uext((mxsubg+2)*(mysubg+2))
 c
 c local variables
 c
-      integer*4 i
-      integer ier
+      integer i, ier
       double precision temp, unorm, u(*)
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       temp = 0.0d0
@@ -755,12 +751,11 @@ c
 c
 c global variables
 c
-      integer*4 nlocal, neq, npex, npey, mxsub, mysub, mx, my
-      integer*4 ixsub, jysub
-      integer thispe
-      integer mxsubg, mysubg, nlocalg
+c The following declaration specification should match C type long int.
+      integer*8 nlocal, neq
+      integer npex, npey, mxsub, mysub, mx, my, ixsub, jysub
+      integer thispe, mxsubg, mysubg
       parameter (mxsubg = 5, mysubg = 5)
-      parameter (nlocalg = mxsubg*mysubg)
       double precision dx, dy, coeffx, coeffy, coeffxy
       double precision uext((mxsubg+2)*(mysubg+2))
 c
@@ -769,7 +764,7 @@ c
       double precision rtol, atol
 c
       common /pcom/ dx, dy, coeffx, coeffy, coeffxy, uext,
-     &              nlocal, neq, mx, my, mxsub, mysub, npey, npex,
+     &              nlocal, neq, mx, my, mxsub, mysub, npex, npey,
      &              ixsub, jysub, thispe
 c
       write(*,30) mx, my, neq, mxsub, mysub, npex, npey, rtol, atol
@@ -797,7 +792,8 @@ c
 c
 c local variables
 c
-      integer*4 mudq, mukeep
+c The following declaration specification should match C type long int.
+      integer*8 mudq, mukeep
       integer num
 c
       write(*,31) num, mudq, mukeep
@@ -819,7 +815,8 @@ c
 c
 c local variables
 c
-      integer*4 iout(*)
+c The following declaration specification should match C type long int.
+      integer*8 iout(*)
 c
       write(*,32) iout(5), iout(6), iout(21)
  32   format(/, 'Error test failures            =', i3, /,
diff --git a/examples/ida/fcmix_pthreads/CMakeLists.txt b/examples/ida/fcmix_pthreads/CMakeLists.txt
new file mode 100644
index 0000000..93a5696
--- /dev/null
+++ b/examples/ida/fcmix_pthreads/CMakeLists.txt
@@ -0,0 +1,146 @@
+# ---------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Radu Serban @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the FIDA opemp examples
+
+
+# Only include tests if Pthreads is enabled
+IF(PTHREADS_FOUND)
+
+# Add variable ida_examples with the names of the pthreads FIDA examples
+SET(FIDA_examples
+  fidaRoberts_dns_pthreads
+  )
+
+# Add variable FIDA_examples_BL with the names of the pthreads FIDA examples
+# that use Lapack
+
+SET(FIDA_examples_BL
+  )
+ENDIF(PTHREADS_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_static)
+  SET(NVECS_LIB sundials_nvecpthreads_static)
+  SET(FNVECS_LIB sundials_fnvecpthreads_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_shared)
+  SET(NVECS_LIB sundials_nvecpthreads_shared)
+  SET(FNVECS_LIB sundials_fnvecpthreads_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Only static FCMIX libraries are available
+
+SET(FIDA_LIB sundials_fida_static)
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${FIDA_LIB} ${IDA_LIB} ${FNVECS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(PETSC_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_FOUND)
+
+# Add the build and install targets for each FIDA example
+
+FOREACH(example ${FIDA_examples})
+  ADD_EXECUTABLE(${example} ${example}.f)
+  SUNDIALS_ADD_TEST(${example} ${example})
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_pthreads)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${FIDA_examples})
+
+# If Lapack support is enabled, add the build and install targets for
+# the examples using Lapack
+
+IF(LAPACK_FOUND)
+  FOREACH(example ${FIDA_examples_BL})
+    ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_pthreads)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${FIDA_examples_BL})
+ENDIF(LAPACK_FOUND)
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_pthreads)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "IDA")
+  SET(SOLVER_LIB "sundials_ida")
+  SET(SOLVER_FLIB "sundials_fida")
+  LIST2STRING(FIDA_examples EXAMPLES)
+  IF(LAPACK_FOUND)
+    LIST2STRING(FIDA_examples_BL EXAMPLES_BL)
+  ELSE(LAPACK_FOUND)
+    SET(EXAMPLES_BL "")
+  ENDIF(LAPACK_FOUND)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_pthreads_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/fcmix_pthreads/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/ida/fcmix_pthreads/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_pthreads 
+    )
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_pthreads_F77_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/fcmix_pthreads/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/ida/fcmix_pthreads/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_pthreads
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/ida/fcmix_pthreads/README b/examples/ida/fcmix_pthreads/README
new file mode 100644
index 0000000..8e3d451
--- /dev/null
+++ b/examples/ida/fcmix_pthreads/README
@@ -0,0 +1,50 @@
+List of Pthreads IDA FCMIX examples
+
+  fidaRoberts_dns_pthreads : 3-species Robertson kinetics system with Pthreads
+
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/fcmix_pthreads/fidaRoberts_dns_pthreads.f b/examples/ida/fcmix_pthreads/fidaRoberts_dns_pthreads.f
new file mode 100644
index 0000000..2c7c092
--- /dev/null
+++ b/examples/ida/fcmix_pthreads/fidaRoberts_dns_pthreads.f
@@ -0,0 +1,271 @@
+c     ----------------------------------------------------------------
+c     $Revision: 4392 $
+c     $Date: 2015-02-25 17:22:27 -0800 (Wed, 25 Feb 2015) $
+c     ----------------------------------------------------------------
+c     This simple example problem for FIDA, due to Robertson, is from 
+c     chemical kinetics, and consists of the following three equations:
+c
+c          dy1/dt = -.04*y1 + 1.e4*y2*y3
+c          dy2/dt =  .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+c             0   = y1 + y2 + y3 - 1
+c
+c     on the interval from t = 0.0 to t = 4.e10, with initial
+c     conditions: y1 = 1, y2 = y3 = 0.
+c
+c     While integrating the system, we also employ the rootfinding feature
+c     to find the points at which y1 = 1.e-4 or at which y3 = 0.01.
+c
+c     The problem is solved using a dense linear solver, with a
+c     user-supplied Jacobian. Output is printed at
+c     t = .4, 4, 40, ..., 4e10.
+c     ----------------------------------------------------------------
+c
+      program fidaRoberts_dns
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*8 neq
+      integer*8 iout(25), ipar
+      integer ier, ierroot, info(2)
+      double precision rout(10), rpar
+      integer iatol, nout, jout, itask
+      integer nst, kused, hused, i
+      double precision t0, t1, rtol, tout, tret
+      double precision y(3), yp(3), atol(3)
+c
+      data nst/3/, kused/9/, hused/2/
+
+      integer nthreads
+      nthreads = 4
+c
+c Initialize variables
+c
+      neq = 3
+      nout = 12
+      rtol = 1.0d-4
+      t0 = 0.0d0
+      t1 = 0.4d0
+      iatol = 2
+      itask = 1
+c
+      y(1) = 1.0d0
+      y(2) = 0.0d0
+      y(3) = 0.0d0
+c
+      yp(1) = -0.04d0
+      yp(2) = 0.04d0
+      yp(3) = 0.0d0
+c
+      atol(1) = 1.0d-6
+      atol(2) = 1.0d-10
+      atol(3) = 1.0d-6
+c
+c Initialize IDA vector environment
+c
+      call fnvinitpts(2, neq, nthreads, ier)
+      if (ier .ne. 0) then
+         write(6,10) ier
+ 10      format(///' SUNDIALS_ERROR: FNVINITS returned IER = ', i5)
+         stop
+      endif
+c
+      call fidamalloc(t0, y, yp, iatol, rtol, atol, 
+     &                iout, rout, ipar, rpar, ier)
+      if (ier .ne. 0) then
+         write(6,20) ier
+ 20      format(///' SUNDIALS_ERROR: FIDAMALLOC returned IER = ', i5)
+         stop
+      endif
+c
+c Initialize rootfinding problem
+
+      call fidarootinit(2, ier)
+      if (ier .ne. 0) then
+         write(6,25) ier
+ 25      format(///' SUNDIALS_ERROR: FIDAROOTINIT returned IER = ', i5)
+         call fidafree
+         stop
+      endif
+c
+c Attach dense linear solver
+c
+      call fidadense(neq, ier)
+      call fidadensesetjac(1, ier)
+c
+c Print header
+c
+      call prntintro(rtol, atol, y)
+c
+      tout = t1
+c
+c
+      jout = 1
+      do while(jout .le. nout)
+c
+        call fidasolve(tout, tret, y, yp, itask, ier)
+c
+        write(6,40) tret, (y(i), i = 1,3), iout(nst), iout(kused),
+     &              rout(hused)
+ 40     format(e10.4, 3(1x,e12.4), i5, i3, e12.4)
+c
+        if (ier .lt. 0) then
+           write(6,50) ier, iout(15)
+ 50        format(///' SUNDIALS_ERROR: FIDASOLVE returned IER = ',i5,/,
+     1            '                 Linear Solver returned IER = ',i5)
+           call fidarootfree
+           call fidafree
+           stop
+        endif
+c
+        if (ier .eq. 2) then
+          call fidarootinfo(2, info, ierroot)
+          if (ierroot .lt. 0) then
+            write(6,55) ier
+ 55         format(///' SUNDIALS_ERROR: FIDAROOTINFO returned IER = ',
+     1             i5)
+            call fidarootfree
+            call fidafree
+            stop
+          endif
+          write(6,60) (info(i), i = 1,2)
+ 60       format(5x, 'Above is a root, INFO() = ', 2i3)
+        endif                   
+c
+        if (ier .eq. 0) then
+           tout = tout * 10.0d0
+           jout = jout + 1
+        endif
+c
+      ENDDO
+c
+c Print final statistics
+c
+      call prntstats(iout)
+c
+c Free IDA memory
+c
+      call fidarootfree
+      call fidafree
+c
+      stop
+      end
+c
+c ==========
+c
+      subroutine fidaresfun(tres, y, yp, res, ipar, rpar, reserr)
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*4 ipar(*)
+      integer reserr
+      double precision tres, rpar(*)
+      double precision y(*), yp(*), res(*)
+c
+      res(1) = -0.04d0*y(1)+1.0d4*y(2)*y(3)
+      res(2) = -res(1)-3.0d7*y(2)*y(2)-yp(2)
+      res(1) = res(1)-yp(1)
+      res(3) = y(1)+y(2)+y(3)-1.0d0
+c
+      reserr = 0
+c
+      return
+      end
+c
+c ==========
+c
+      subroutine fidadjac(neq, t, y, yp, r, jac, cj, ewt, h,
+     1                    ipar, rpar, wk1, wk2, wk3, djacerr)
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*4 neq, ipar(*)
+      integer djacerr
+      double precision t, h, cj, rpar(*)
+      double precision y(*), yp(*), r(*), ewt(*), jac(neq,neq)
+      double precision wk1(*), wk2(*), wk3(*)
+c
+      jac(1,1) = -0.04d0-cj
+      jac(2,1) = 0.04d0
+      jac(3,1) = 1.0d0
+      jac(1,2) = 1.0d4*y(3)
+      jac(2,2) = -1.0d4*y(3)-6.0d7*y(2)-cj
+      jac(3,2) = 1.0d0
+      jac(1,3) = 1.0d4*y(2)
+      jac(2,3) = -1.0d4*y(2)
+      jac(3,3) = 1.0d0
+c
+      djacerr = 0
+
+      return
+      end
+c
+c ==========
+c
+      subroutine fidarootfn(t, y, yp, g, ipar, rpar, ier)
+c Fortran routine for rootfinding
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*4 ipar(*)
+      integer ier
+      double precision t, y(*), yp(*), g(*), rpar(*)
+c
+      g(1) = y(1) - 1.0d-4
+      g(2) = y(3) - 1.0d-2
+
+      ier = 0
+
+      return
+      end
+c
+c ==========
+c
+      subroutine prntintro(rtol, atol, y)
+c
+      implicit none
+c
+      integer i
+      double precision rtol, atol(*), y(*)
+c
+      write(6,60) rtol, (atol(i), i = 1,3), (y(i), i = 1,3)
+ 60   format(/'fidaRoberts_dns: Robertson kinetics DAE serial example',
+     &       'problem for IDA', /,'          Three equation chemical',
+     &       'kinetics problem.', //,
+     &       'Tolerance parameters:  rtol = ', e8.2,
+     &       '   atol = ', 3(1x,e8.2), /,
+     &       'Initial conditions y0 = (', 3(1x,e8.2), ')', //,
+     &       '  t            y1           y2           y3        nst',
+     &       '  k    h')
+c
+      return
+      end
+c
+c ==========
+c
+      subroutine prntstats(iout)
+c
+      implicit none
+c
+c The following declaration specification should match C type long int.
+      integer*8 iout(25)
+      integer nst, reseval, jaceval, nni, ncf, netf, nge
+c
+      data nst/3/, reseval/4/, jaceval/17/, nni/7/, netf/5/,
+     &     ncf/6/, nge/12/
+c
+      write(6,70) iout(nst), iout(reseval), iout(jaceval),
+     &             iout(nni), iout(netf), iout(ncf), iout(nge)
+ 70   format(/'Final Run Statistics:', //,
+     &         'Number of steps                    = ', i3, /,
+     &         'Number of residual evaluations     = ', i3, /,
+     &         'Number of Jacobian evaluations     = ', i3, /,
+     &         'Number of nonlinear iterations     = ', i3, /,
+     &         'Number of error test failures      = ', i3, /,
+     &         'Number of nonlinear conv. failures = ', i3, /,
+     &         'Number of root function evals.     = ', i3)
+c
+      return
+      end
diff --git a/examples/ida/fcmix_pthreads/fidaRoberts_dns_pthreads.out b/examples/ida/fcmix_pthreads/fidaRoberts_dns_pthreads.out
new file mode 100644
index 0000000..7809e8a
--- /dev/null
+++ b/examples/ida/fcmix_pthreads/fidaRoberts_dns_pthreads.out
@@ -0,0 +1,34 @@
+
+fidaRoberts_dns: Robertson kinetics DAE serial exampleproblem for IDA
+          Three equation chemicalkinetics problem.
+
+Tolerance parameters:  rtol = 0.10E-03   atol =  0.10E-05 0.10E-09 0.10E-05
+Initial conditions y0 = ( 0.10E+01 0.00E+00 0.00E+00)
+
+  t            y1           y2           y3        nst  k    h
+0.2640E+00   0.9900E+00   0.3471E-04   0.1000E-01   75  2  0.5716E-01
+     Above is a root, INFO() =   0  1
+0.4000E+00   0.9852E+00   0.3386E-04   0.1480E-01   77  3  0.1143E+00
+0.4000E+01   0.9055E+00   0.2240E-04   0.9447E-01   91  4  0.3704E+00
+0.4000E+02   0.7158E+00   0.9185E-05   0.2842E+00  127  4  0.2963E+01
+0.4000E+03   0.4505E+00   0.3223E-05   0.5495E+00  177  3  0.1241E+02
+0.4000E+04   0.1832E+00   0.8940E-06   0.8168E+00  228  3  0.2765E+03
+0.4000E+05   0.3899E-01   0.1622E-06   0.9610E+00  278  5  0.2614E+04
+0.4000E+06   0.4939E-02   0.1985E-07   0.9951E+00  324  5  0.2770E+05
+0.4000E+07   0.5176E-03   0.2072E-08   0.9995E+00  355  4  0.3979E+06
+0.2075E+08   0.1000E-03   0.4000E-09   0.9999E+00  374  4  0.1592E+07
+     Above is a root, INFO() =  -1  0
+0.4000E+08   0.5191E-04   0.2076E-09   0.9999E+00  380  3  0.6366E+07
+0.4000E+09   0.5882E-05   0.2353E-10   0.1000E+01  394  1  0.9167E+08
+0.4000E+10   0.7054E-06   0.2822E-11   0.1000E+01  402  1  0.1467E+10
+0.4000E+11  -0.7300E-06  -0.2920E-11   0.1000E+01  407  1  0.2347E+11
+
+Final Run Statistics:
+
+Number of steps                    = 407
+Number of residual evaluations     = 557
+Number of Jacobian evaluations     =  65
+Number of nonlinear iterations     = 557
+Number of error test failures      =   6
+Number of nonlinear conv. failures =   0
+Number of root function evals.     = 445
diff --git a/examples/ida/fcmix_serial/CMakeLists.txt b/examples/ida/fcmix_serial/CMakeLists.txt
index 96a083f..69d381e 100644
--- a/examples/ida/fcmix_serial/CMakeLists.txt
+++ b/examples/ida/fcmix_serial/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.5 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the FIDA serial examples
 
@@ -45,14 +50,27 @@ SET(FIDA_LIB sundials_fida_static)
 
 SET(SUNDIALS_LIBS ${FIDA_LIB} ${IDA_LIB} ${FNVECS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(PETSC_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_FOUND)
+
 # Add the build and install targets for each FIDA example
 
 FOREACH(example ${FIDA_examples})
   ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_serial)
@@ -65,6 +83,8 @@ ENDFOREACH(example ${FIDA_examples})
 IF(LAPACK_FOUND)
   FOREACH(example ${FIDA_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     IF(EXAMPLES_INSTALL)
       INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/fcmix_serial)
diff --git a/examples/ida/fcmix_serial/Makefile.in b/examples/ida/fcmix_serial/Makefile.in
deleted file mode 100644
index 1539d2d..0000000
--- a/examples/ida/fcmix_serial/Makefile.in
+++ /dev/null
@@ -1,134 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.10 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2005, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FIDA serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-F77          = @F77@
-FFLAGS       = @FFLAGS@
-F77_LNKR     = @F77_LNKR@
-F77_LDFLAGS  = @F77_LDFLAGS@
-F77_LIBS     = @F77_LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_LIBS = $(top_builddir)/src/ida/fcmix/libsundials_fida.la          \
-                $(top_builddir)/src/ida/libsundials_ida.la                 \
-                $(top_builddir)/src/nvec_ser/libsundials_fnvecserial.la    \
-                $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-fortran-update = ${SHELL} ${top_builddir}/bin/fortran-update.sh
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = fidaRoberts_dns
-
-EXAMPLES_BL =
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${F77} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${F77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${F77_LDFLAGS} ${SUNDIALS_LIBS} ${F77_LIBS} ${BLAS_LAPACK_LIBS} ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${F77} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${F77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${F77_LDFLAGS} ${SUNDIALS_LIBS} ${F77_LIBS} ${BLAS_LAPACK_LIBS} ; \
-	done ; \
-	fi
-
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/ida/fcmix_serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/ida/fcmix_serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_serial/README $(EXS_INSTDIR)/ida/fcmix_serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_serial/$${i}.f   $(EXS_INSTDIR)/ida/fcmix_serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_serial/$${i}.out $(EXS_INSTDIR)/ida/fcmix_serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_serial/$${i}.f   $(EXS_INSTDIR)/ida/fcmix_serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/fcmix_serial/$${i}.out $(EXS_INSTDIR)/ida/fcmix_serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/ida/fcmix_serial/Makefile
-	rm -f $(EXS_INSTDIR)/ida/fcmix_serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/ida/fcmix_serial/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/ida/fcmix_serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/ida/fcmix_serial/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/ida/fcmix_serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/ida/fcmix_serial
-	$(rminstalldirs) $(EXS_INSTDIR)/ida
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f *-updated.f
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/ida/fcmix_serial/README b/examples/ida/fcmix_serial/README
index cae0431..44b9491 100644
--- a/examples/ida/fcmix_serial/README
+++ b/examples/ida/fcmix_serial/README
@@ -2,13 +2,48 @@ List of serial IDA FCMIX examples
 
   fidaRoberts_dns : chemical kinetics example (DENSE)
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/fcmix_serial/fidaRoberts_dns.f b/examples/ida/fcmix_serial/fidaRoberts_dns.f
index 707852e..8ded4b3 100644
--- a/examples/ida/fcmix_serial/fidaRoberts_dns.f
+++ b/examples/ida/fcmix_serial/fidaRoberts_dns.f
@@ -1,6 +1,6 @@
 c     ----------------------------------------------------------------
-c     $Revision: 1.3 $
-c     $Date: 2010/12/01 23:04:14 $
+c     $Revision: 4885 $
+c     $Date: 2016-09-02 08:29:03 -0700 (Fri, 02 Sep 2016) $
 c     ----------------------------------------------------------------
 c     This simple example problem for FIDA, due to Robertson, is from 
 c     chemical kinetics, and consists of the following three equations:
@@ -24,13 +24,12 @@ c
 c
       implicit none
 c
+c The following declaration specification should match C type long int.
+      integer*8 neq, iout(25), ipar
       integer ier, ierroot, info(2)
-      integer*4 iout(25), ipar
       double precision rout(10), rpar
-c
       integer iatol, nout, jout, itask
-      integer nst, kused, hused
-      integer*4 neq, i
+      integer nst, kused, hused, i
       double precision t0, t1, rtol, tout, tret
       double precision y(3), yp(3), atol(3)
 c
@@ -118,7 +117,7 @@ c
         if (ier .eq. 2) then
           call fidarootinfo(2, info, ierroot)
           if (ierroot .lt. 0) then
-            write(6,55) ier
+            write(6,55) ierroot
  55         format(///' SUNDIALS_ERROR: FIDAROOTINFO returned IER = ',
      1             i5)
             call fidarootfree
@@ -154,8 +153,9 @@ c
 c
       implicit none
 c
+c The following declaration specification should match C type long int.
+      integer*8 ipar(*)
       integer reserr
-      integer*4 ipar(*)
       double precision tres, rpar(*)
       double precision y(*), yp(*), res(*)
 c
@@ -176,8 +176,8 @@ c
 c
       implicit none
 c
-      integer*4 neq
-      integer*4 ipar(*)
+c The following declaration specification should match C type long int.
+      integer*8 neq, ipar(*)
       integer djacerr
       double precision t, h, cj, rpar(*)
       double precision y(*), yp(*), r(*), ewt(*), jac(neq,neq)
@@ -204,7 +204,9 @@ c
 c Fortran routine for rootfinding
       implicit none
 c
-      INTEGER*4 ipar(*), ier
+c The following declaration specification should match C type long int.
+      integer*8 ipar(*)
+      integer ier
       double precision t, y(*), yp(*), g(*), rpar(*)
 c
       g(1) = y(1) - 1.0d-4
@@ -221,7 +223,7 @@ c
 c
       implicit none
 c
-      integer*4 i
+      integer i
       double precision rtol, atol(*), y(*)
 c
       write(6,60) rtol, (atol(i), i = 1,3), (y(i), i = 1,3)
@@ -243,7 +245,8 @@ c
 c
       implicit none
 c
-      integer*4 iout(25)
+c The following declaration specification should match C type long int.
+      integer*8 iout(25)
       integer nst, reseval, jaceval, nni, ncf, netf, nge
 c
       data nst/3/, reseval/4/, jaceval/17/, nni/7/, netf/5/,
diff --git a/examples/ida/parallel/CMakeLists.txt b/examples/ida/parallel/CMakeLists.txt
index 621642f..21b1e14 100644
--- a/examples/ida/parallel/CMakeLists.txt
+++ b/examples/ida/parallel/CMakeLists.txt
@@ -1,24 +1,29 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for IDA parallel examples
 
 
 # Add variable IDA_examples with the names of the parallel IDA examples
-
+# "name\;nodes\;tasks"
 SET(IDA_examples
-  idaFoodWeb_kry_bbd_p
-  idaFoodWeb_kry_p
-  idaHeat2D_kry_bbd_p
-  idaHeat2D_kry_p
+  "idaFoodWeb_kry_bbd_p\;1\;4"
+  "idaFoodWeb_kry_p\;1\;4"
+  "idaHeat2D_kry_bbd_p\;1\;4"
+  "idaHeat2D_kry_p\;1\;4"
   )
 
 # Check whether we use MPI compiler scripts.
@@ -48,14 +53,31 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${IDA_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(PETSC_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_FOUND)
+
 # Add the build and install targets for each IDA example
 
-FOREACH(example ${IDA_examples})
+FOREACH(example_tuple ${IDA_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
   ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPICC)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -63,7 +85,7 @@ FOREACH(example ${IDA_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${IDA_examples})
+ENDFOREACH(example_tuple ${IDA_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -73,7 +95,11 @@ IF(EXAMPLES_INSTALL)
   # Prepare substitution variables for Makefile and/or CMakeLists templates
   SET(SOLVER "IDA")
   SET(SOLVER_LIB "sundials_ida")
-  LIST2STRING(IDA_examples EXAMPLES)
+  FOREACH(example_tuple ${IDA_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${IDA_examples})
+  
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/ida/parallel/Makefile.in b/examples/ida/parallel/Makefile.in
deleted file mode 100644
index a1cce55..0000000
--- a/examples/ida/parallel/Makefile.in
+++ /dev/null
@@ -1,113 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for IDA parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP         = @CPP@
-CPPFLAGS    = @CPPFLAGS@
-CC          = @CC@
-CFLAGS      = @CFLAGS@
-LDFLAGS     = @LDFLAGS@
-LIBS        = @LIBS@
-MPICC       = @MPICC@
-MPI_INC_DIR = @MPI_INC_DIR@
-MPI_LIB_DIR = @MPI_LIB_DIR@
-MPI_LIBS    = @MPI_LIBS@
-MPI_FLAGS   = @MPI_FLAGS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/ida/libsundials_ida.la $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = idaFoodWeb_kry_bbd_p \
-	   idaFoodWeb_kry_p \
-	   idaHeat2D_kry_bbd_p \
-	   idaHeat2D_kry_p
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(MPICC) $(CPPFLAGS) $(MPI_FLAGS) $(SUNDIALS_INCS) -I$(MPI_INC_DIR) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(MPICC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}$(OBJ_EXT) $(MPI_FLAGS) $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) -L$(MPI_LIB_DIR) $(MPI_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/ida/parallel
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/ida/parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/ida/parallel/README $(EXS_INSTDIR)/ida/parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/parallel/$${i}.c   $(EXS_INSTDIR)/ida/parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/parallel/$${i}.out $(EXS_INSTDIR)/ida/parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/ida/parallel/Makefile
-	rm -f $(EXS_INSTDIR)/ida/parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/ida/parallel/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/ida/parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/ida/parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/ida
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/ida/parallel/README b/examples/ida/parallel/README
index 20d827e..08e1230 100644
--- a/examples/ida/parallel/README
+++ b/examples/ida/parallel/README
@@ -5,14 +5,48 @@ List of parallel IDA examples
   idaHeat2D_kry_bbd_p  : 2-D heat equation, BBD preconditioner
   idaHeat2D_kry_p      : 2-D heat equation, diagonal preconditioner
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c b/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c
index f048c63..9daab3d 100644
--- a/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c
+++ b/examples/ida/parallel/idaFoodWeb_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 23:03:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -218,7 +218,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype time,
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -514,19 +514,19 @@ static void PrintHeader(long int SystemSize, int maxl,
   printf("\nidaFoodWeb_kry_bbd_p: Predator-prey DAE parallel example problem for IDA \n\n");
   printf("Number of species ns: %d", NUM_SPECIES);
   printf("     Mesh dimensions: %d x %d", MX, MY);
-  printf("     Total system size: %d\n",SystemSize);
+  printf("     Total system size: %ld\n",SystemSize);
   printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB);
   printf("     Processor array: %d x %d\n", NPEX, NPEY);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
   printf("Linear solver: IDASPGMR     Max. Krylov dimension maxl: %d\n", maxl);
   printf("Preconditioner: band-block-diagonal (IDABBDPRE), with parameters\n");
-  printf("     mudq = %d,  mldq = %d,  mukeep = %d,  mlkeep = %d\n",
+  printf("     mudq = %ld,  mldq = %ld,  mukeep = %ld,  mlkeep = %ld\n",
          mudq, mldq, mukeep, mlkeep);
   printf("CalcIC called to correct initial predator concentrations \n\n");
   printf("-----------------------------------------------------------\n");
@@ -552,7 +552,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
 
   thispe = webdata->thispe; 
   npelast = webdata->npes - 1;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Send conc. at top right mesh point from PE npes-1 to PE 0. */
   if (thispe == npelast) {
@@ -583,10 +583,10 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
     for (i=1;i<NUM_SPECIES;i++)
       printf("         %12.4Le %12.4Le   |\n",cdata[i],clast[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
+    printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
     for (i=1;i<NUM_SPECIES;i++)
-      printf("         %12.4le %12.4le   |\n",cdata[i],clast[i]);
+      printf("         %12.4e %12.4e   |\n",cdata[i],clast[i]);
 #else
     printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
@@ -661,7 +661,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
@@ -747,7 +747,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
   
   webdata = (UserData) user_data;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Get comm, thispe, subgrid indices, data sizes, extended array cext. */
   
@@ -971,7 +971,7 @@ static int reslocal(long int Nlocal, realtype tt,
   
   /* Get data pointers, subgrid data, array sizes, work array cext. */
   
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Copy local segment of cc vector into the working extended array cext. */
   
diff --git a/examples/ida/parallel/idaFoodWeb_kry_p.c b/examples/ida/parallel/idaFoodWeb_kry_p.c
index 2940b05..64a56f8 100644
--- a/examples/ida/parallel/idaFoodWeb_kry_p.c
+++ b/examples/ida/parallel/idaFoodWeb_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 23:03:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -231,7 +231,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype time,
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -563,13 +563,13 @@ static void PrintHeader(long int SystemSize, int maxl,
   printf("\nidaFoodWeb_kry_p: Predator-prey DAE parallel example problem for IDA \n\n");
   printf("Number of species ns: %d", NUM_SPECIES);
   printf("     Mesh dimensions: %d x %d", MX, MY);
-  printf("     Total system size: %d\n",SystemSize);
+  printf("     Total system size: %ld\n",SystemSize);
   printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB);
   printf("     Processor array: %d x %d\n", NPEX, NPEY);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -601,7 +601,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
 
   thispe = webdata->thispe; 
   npelast = webdata->npes - 1;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Send conc. at top right mesh point from PE npes-1 to PE 0. */
   if (thispe == npelast) {
@@ -632,10 +632,10 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
     for (i=1;i<NUM_SPECIES;i++)
       printf("         %12.4Le %12.4Le   |\n",cdata[i],clast[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
+    printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
     for (i=1;i<NUM_SPECIES;i++)
-      printf("         %12.4le %12.4le   |\n",cdata[i],clast[i]);
+      printf("         %12.4e %12.4e   |\n",cdata[i],clast[i]);
 #else
     printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
@@ -705,7 +705,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
@@ -786,7 +786,7 @@ static int rescomm(N_Vector cc, N_Vector cp, void *user_data)
   MPI_Request request[4];
   
   webdata = (UserData) user_data;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Get comm, thispe, subgrid indices, data sizes, extended array cext. */
   comm = webdata->comm;     thispe = webdata->thispe;
@@ -998,7 +998,7 @@ static int reslocal(realtype tt, N_Vector cc, N_Vector cp, N_Vector res,
   webdata = (UserData) user_data;
   
   /* Get data pointers, subgrid data, array sizes, work array cext. */
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Copy local segment of cc vector into the working extended array cext. */
   locc = 0;
@@ -1139,7 +1139,7 @@ static int Precondbd(realtype tt, N_Vector cc,
 
   webdata = (UserData)user_data;
   uround = UNIT_ROUNDOFF;
-  sqru = SQRT(uround); 
+  sqru = SUNRsqrt(uround);
   thispe = webdata->thispe;
 
   mem = webdata->ida_mem;
@@ -1161,7 +1161,7 @@ static int Precondbd(realtype tt, N_Vector cc,
       ratesxy = IJ_Vptr(rates,ix,jy);
 
       for (js = 0; js < ns; js++) {
-        inc = sqru*(MAX(ABS(cxy[js]), MAX(hh*ABS(cpxy[js]), ONE/ewtxy[js])));
+        inc = sqru*(SUNMAX(SUNRabs(cxy[js]), SUNMAX(hh*SUNRabs(cpxy[js]), ONE/ewtxy[js])));
         cctemp = cxy[js];  /* Save the (js,ix,jy) element of cc. */
         cxy[js] += inc;    /* Perturb the (js,ix,jy) element of cc. */
         fac = -ONE/inc;
diff --git a/examples/ida/parallel/idaHeat2D_kry_bbd_p.c b/examples/ida/parallel/idaHeat2D_kry_bbd_p.c
index b65b333..36402f3 100644
--- a/examples/ida/parallel/idaHeat2D_kry_bbd_p.c
+++ b/examples/ida/parallel/idaHeat2D_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 23:03:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -113,7 +113,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu);
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -363,7 +363,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
 
   data = (UserData) user_data;
-  uarray = NV_DATA_P(uu);
+  uarray = N_VGetArrayPointer_Parallel(uu);
 
   /* Get comm, thispe, subgrid indices, data sizes, extended array uext. */
   comm = data->comm;  thispe = data->thispe;
@@ -405,9 +405,9 @@ static int reslocal(long int Nlocal, realtype tres,
 
   data = (UserData) user_data;
   uext = data->uext;
-  uuv = NV_DATA_P(uu);
-  upv = NV_DATA_P(up);
-  resv = NV_DATA_P(res);
+  uuv = N_VGetArrayPointer_Parallel(uu);
+  upv = N_VGetArrayPointer_Parallel(up);
+  resv = N_VGetArrayPointer_Parallel(res);
   ixsub = data->ixsub; jysub = data->jysub;
   mxsub = data->mxsub; mxsub2 = data->mxsub + 2;
   mysub = data->mysub; npex = data->npex; npey = data->npey;
@@ -646,8 +646,8 @@ static int SetInitialProfile(N_Vector uu, N_Vector up,  N_Vector id,
   
   /* Initialize uu. */ 
   
-  udata = NV_DATA_P(uu);
-  iddata = NV_DATA_P(id);
+  udata = N_VGetArrayPointer_Parallel(uu);
+  iddata = N_VGetArrayPointer_Parallel(id);
   
   /* Set mesh spacings and subgrid indices for this PE. */
   dx = data->dx;
@@ -704,14 +704,14 @@ static void PrintHeader(long int Neq, realtype rtol, realtype atol)
     printf("                Zero boundary conditions,");
     printf(" polynomial initial conditions.\n");
     printf("                Mesh dimensions: %d x %d", MX, MY);
-    printf("        Total system size: %d\n\n", Neq);
+    printf("        Total system size: %ld\n\n", Neq);
 
     printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB);
     printf("         Processor array: %d x %d\n", NPEX, NPEY);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+    printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
     printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -778,7 +778,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu)
     printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2Le  %3ld %3ld\n",
            t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2le  %3ld %3ld\n",
+    printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2e  %3ld %3ld\n",
            t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps);
 #else
     printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2e  %3ld %3ld\n",
@@ -815,7 +815,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/ida/parallel/idaHeat2D_kry_p.c b/examples/ida/parallel/idaHeat2D_kry_p.c
index ee99671..ab1394e 100644
--- a/examples/ida/parallel/idaHeat2D_kry_p.c
+++ b/examples/ida/parallel/idaHeat2D_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2009/09/30 23:28:00 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -118,7 +118,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu);
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -348,7 +348,7 @@ int PsetupHeat(realtype tt,
 
   data = (UserData) user_data;
 
-  ppv = NV_DATA_P(data->pp);
+  ppv = N_VGetArrayPointer_Parallel(data->pp);
   ixsub = data->ixsub;
   jysub = data->jysub;
   mxsub = data->mxsub;
@@ -426,7 +426,7 @@ static int rescomm(N_Vector uu, N_Vector up, void *user_data)
   MPI_Request request[4];
   
   data = (UserData) user_data;
-  uarray = NV_DATA_P(uu);
+  uarray = N_VGetArrayPointer_Parallel(uu);
   
   /* Get comm, thispe, subgrid indices, data sizes, extended array uext. */
   comm = data->comm;  thispe = data->thispe;
@@ -468,9 +468,9 @@ static int reslocal(realtype tt,
   
   data = (UserData) user_data;
   uext = data->uext;
-  uuv = NV_DATA_P(uu);
-  upv = NV_DATA_P(up);
-  resv = NV_DATA_P(rr);
+  uuv = N_VGetArrayPointer_Parallel(uu);
+  upv = N_VGetArrayPointer_Parallel(up);
+  resv = N_VGetArrayPointer_Parallel(rr);
   ixsub = data->ixsub; jysub = data->jysub;
   mxsub = data->mxsub; mxsub2 = data->mxsub + 2;
   mysub = data->mysub; npex = data->npex; npey = data->npey;
@@ -707,8 +707,8 @@ static int SetInitialProfile(N_Vector uu, N_Vector up,  N_Vector id,
   
   /* Initialize uu. */ 
 
-  udata = NV_DATA_P(uu);
-  iddata = NV_DATA_P(id);
+  udata = N_VGetArrayPointer_Parallel(uu);
+  iddata = N_VGetArrayPointer_Parallel(id);
   
   /* Set mesh spacings and subgrid indices for this PE. */
   dx = data->dx;
@@ -769,7 +769,7 @@ static void PrintHeader(long int Neq, realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -824,7 +824,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu)
     printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le  %3ld %3ld\n",
            t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)  
-    printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le  %3ld %3ld\n",
+    printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
            t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #else
     printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
@@ -861,7 +861,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/ida/petsc/CMakeLists.txt b/examples/ida/petsc/CMakeLists.txt
new file mode 100644
index 0000000..52e3a84
--- /dev/null
+++ b/examples/ida/petsc/CMakeLists.txt
@@ -0,0 +1,134 @@
+# ---------------------------------------------------------------
+# $Revision: 4137 $
+# $Date: 2014-06-15 12:26:15 -0700 (Sun, 15 Jun 2014) $
+# ---------------------------------------------------------------
+# Programmer:  Slaven Peles, Eddy Banks @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for IDA PETSc examples
+
+
+# Add variable IDA_examples with the names of the PETSc IDA examples
+# "name\;nodes\;tasks"
+SET(IDA_examples
+  #"idaHeat2D_jac_petsc\;1\;4"  # Not to be released in 2.7.0
+  "idaHeat2D_kry_petsc\;1\;4"
+  )
+
+# Check whether we use MPI compiler scripts.
+# If yes, then change the C compiler to the MPICC script.
+# If not, then add the MPI include directory for MPI headers.
+
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICC)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_static)
+  SET(NVECP_LIB sundials_nvecpetsc_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDA_LIB sundials_ida_shared)
+  SET(NVECP_LIB sundials_nvecpetsc_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${IDA_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS} ${PETSC_LIBRARIES})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# Add the build and install targets for each IDA example
+
+FOREACH(example_tuple ${IDA_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(NOT MPI_MPICC)
+    TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
+  ENDIF(NOT MPI_MPICC)
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/petsc)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example_tuple ${IDA_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/petsc)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "IDA")
+  SET(SOLVER_LIB "sundials_ida")
+  FOREACH(example_tuple ${IDA_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${IDA_examples})
+  
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_petsc_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/petsc/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/ida/petsc/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/petsc 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_petsc_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/ida/petsc/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/ida/petsc/Makefile_ex
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/petsc
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/ida/petsc/README b/examples/ida/petsc/README
new file mode 100644
index 0000000..a57edc0
--- /dev/null
+++ b/examples/ida/petsc/README
@@ -0,0 +1,50 @@
+List of PETSc IDA examples
+
+  idaHeat2D_kry_petsc  : 2-D heat equation, diagonal preconditioner
+  idaHeat2D_kry_bbd_petsc : Not supposed to work with PETSc vector
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/petsc/idaHeat2D_kry_petsc.c b/examples/ida/petsc/idaHeat2D_kry_petsc.c
new file mode 100644
index 0000000..f681a0f
--- /dev/null
+++ b/examples/ida/petsc/idaHeat2D_kry_petsc.c
@@ -0,0 +1,730 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4882 $
+ * $Date: 2016-09-01 16:05:08 -0700 (Thu, 01 Sep 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * Based on PETSc TS example 15 and a SUNDIALS example by 
+ * Allan Taylor, Alan Hindmarsh and Radu Serban
+ * -----------------------------------------------------------------
+ * Example problem for IDA: 2D heat equation, PETSc vector, GMRES.
+ *
+ * This example solves a discretized 2D heat equation problem.
+ * This version uses the Krylov solver IDASpgmr.
+ *
+ * The DAE system solved is a spatial discretization of the PDE
+ *          du/dt = d^2u/dx^2 + d^2u/dy^2
+ * on the unit square. The boundary condition is u = 0 on all edges.
+ * Initial conditions are given by u = 16 x (1 - x) y (1 - y).
+ * The PDE is treated with central differences on a uniform MX x MY
+ * grid. The values of u at the interior points satisfy ODEs, and
+ * equations u = 0 at the boundaries are appended, to form a DAE
+ * system of size N = MX * MY. Here MX = MY = 10.
+ *
+ * The system is actually implemented on submeshes, processor by
+ * processor, with an MXSUB by MYSUB mesh on each of NPEX * NPEY
+ * processors.
+ *
+ * The system is solved with IDA using the Krylov linear solver
+ * IDASPGMR. The preconditioner uses the diagonal elements of the
+ * Jacobian only. Routines for preconditioning, required by
+ * IDASPGMR, are supplied here. The constraints u >= 0 are posed
+ * for all components. Local error testing on the boundary values
+ * is suppressed. Output is taken at t = 0, .01, .02, .04,
+ * ..., 10.24.
+ * 
+ * The example uses PETSc vector and data management functions to 
+ * generate mesh and handle MPI communication.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <ida/ida.h>
+#include <ida/ida_spgmr.h>
+#include <nvector/nvector_petsc.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+#include <mpi.h>
+#include <petscdm.h>
+#include <petscdmda.h>
+
+#define ZERO  RCONST(0.0)
+#define ONE   RCONST(1.0)
+#define TWO   RCONST(2.0)
+
+#define NOUT         11             /* Number of output times */
+
+#define NPEX         2              /* No. PEs in x direction of PE array */
+#define NPEY         2              /* No. PEs in y direction of PE array */
+                                    /* Total no. PEs = NPEX*NPEY */
+#define MXSUB        5              /* No. x points per subgrid */
+#define MYSUB        5              /* No. y points per subgrid */
+
+#define MX           (NPEX*MXSUB)   /* MX = number of x mesh points */
+#define MY           (NPEY*MYSUB)   /* MY = number of y mesh points */
+                                    /* Spatial mesh is MX by MY */
+
+typedef struct {  
+  N_Vector pp;    /* vector of diagonal preconditioner elements */
+  DM       da;    /* PETSc data management object */
+} *UserData;
+
+/* User-supplied residual function */
+
+int resHeat(realtype tt, N_Vector uu, N_Vector up, N_Vector rr, void *user_data);
+
+/* User-supplied preconditioner routines */
+
+int PsetupHeat(realtype tt, 
+               N_Vector yy, N_Vector yp, N_Vector rr, 
+               realtype c_j, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+int PsolveHeat(realtype tt, 
+               N_Vector uu, N_Vector up, N_Vector rr, 
+               N_Vector rvec, N_Vector zvec,
+               realtype c_j, realtype delta, void *user_data, 
+               N_Vector tmp);
+
+/* Private function to check function return values */
+
+static int SetInitialProfile(N_Vector uu, N_Vector up, N_Vector id,
+                             N_Vector res, void *user_data);
+
+static void PrintHeader(long int Neq, realtype rtol, realtype atol);
+
+static void PrintOutput(int id, void *mem, realtype t, N_Vector uu);
+
+static void PrintFinalStats(void *mem);
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  MPI_Comm comm;
+  void *mem;
+  UserData data;
+  int iout, thispe, ier, npes;
+  long int Neq;
+  realtype rtol, atol, t0, t1, tout, tret;
+  N_Vector uu, up, constraints, id, res;
+  PetscErrorCode ierr;                  /* PETSc error code  */
+  Vec uvec;
+
+  mem = NULL;
+  data = NULL;
+  uu = up = constraints = id = res = NULL;
+
+  /* Get processor number and total number of pe's. */
+
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &npes);
+  MPI_Comm_rank(comm, &thispe);
+  
+  if (npes != NPEX*NPEY) {
+    if (thispe == 0)
+      fprintf(stderr, 
+              "\nMPI_ERROR(0): npes = %d is not equal to NPEX*NPEY = %d\n", 
+              npes,NPEX*NPEY);
+    MPI_Finalize();
+    return(1);
+  }
+  
+  /* Set global vector length Neq. */
+  Neq = MX * MY;
+  
+  /* Initialize PETSc */
+  ierr = PetscInitializeNoArguments();
+  CHKERRQ(ierr);
+
+  /* Allocate and initialize the data structure and N-vectors. */
+  data = (UserData) malloc(sizeof *data);
+  if(check_flag((void *)data, "malloc", 2, thispe)) 
+    MPI_Abort(comm, 1);
+  data->pp = NULL;
+  data->da = NULL;
+  
+  /* Create the object that will manage the communication of 2D data */
+  ierr = DMDACreate2d(comm, 
+                      DM_BOUNDARY_NONE,  /* NONE, PERIODIC, GHOSTED */
+                      DM_BOUNDARY_NONE,
+                      DMDA_STENCIL_STAR, /* STAR, BOX */
+                      MX,                
+                      MY,                
+                      NPEX,              /* Set numbers or use PETSC_DECIDE */
+                      NPEY,              
+                      1,                 /* degrees of freedom per node */
+                      1,                 /* stencil width */
+                      NULL,              /* number of nodes per cell in x */
+                      NULL,              /* number of nodes per cell in y */
+                      &(data->da));
+  CHKERRQ(ierr);
+
+  /* Create PETSc vector */
+  ierr = DMCreateGlobalVector(data->da, &uvec);
+  CHKERRQ(ierr);
+
+  /* Make N_Vector wrapper for uvec */
+  uu = N_VMake_Petsc(&uvec);
+  if(check_flag((void *)uu, "N_VNew_Petsc", 0, thispe)) 
+    MPI_Abort(comm, 1);
+
+  up = N_VClone(uu);
+  if(check_flag((void *)up, "N_VNew_Petsc", 0, thispe)) 
+    MPI_Abort(comm, 1);
+
+  res = N_VClone(uu);
+  if(check_flag((void *)res, "N_VNew_Petsc", 0, thispe)) 
+    MPI_Abort(comm, 1);
+
+  constraints = N_VClone(uu);
+  if(check_flag((void *)constraints, "N_VNew_Petsc", 0, thispe)) 
+    MPI_Abort(comm, 1);
+
+  id = N_VClone(uu);
+  if(check_flag((void *)id, "N_VNew_Petsc", 0, thispe)) 
+    MPI_Abort(comm, 1);
+
+  /* An N-vector to hold preconditioner. */
+  data->pp = N_VClone(uu); 
+  if(check_flag((void *)data->pp, "N_VNew_Petsc", 0, thispe)) 
+    MPI_Abort(comm, 1);
+
+  /* Initialize the uu, up, id, and res profiles. */
+
+  SetInitialProfile(uu, up, id, res, data);
+  
+  /* Set constraints to all 1's for nonnegative solution values. */
+
+  N_VConst(ONE, constraints);
+  
+  t0 = ZERO; t1 = RCONST(0.01);
+  
+  /* Scalar relative and absolute tolerance. */
+
+  rtol = ZERO;
+  atol = RCONST(1.0e-3);
+
+  /* Call IDACreate and IDAMalloc to initialize solution. */
+
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0, thispe)) MPI_Abort(comm, 1);
+
+  ier = IDASetUserData(mem, data);
+  if(check_flag(&ier, "IDASetUserData", 1, thispe)) MPI_Abort(comm, 1);
+
+  ier = IDASetSuppressAlg(mem, TRUE);
+  if(check_flag(&ier, "IDASetSuppressAlg", 1, thispe)) MPI_Abort(comm, 1);
+
+  ier = IDASetId(mem, id);
+  if(check_flag(&ier, "IDASetId", 1, thispe)) MPI_Abort(comm, 1);
+
+  ier = IDASetConstraints(mem, constraints);
+  if(check_flag(&ier, "IDASetConstraints", 1, thispe)) MPI_Abort(comm, 1);
+  N_VDestroy_Petsc(constraints);  
+
+  ier = IDAInit(mem, resHeat, t0, uu, up);
+  if(check_flag(&ier, "IDAInit", 1, thispe)) MPI_Abort(comm, 1);
+  
+  ier = IDASStolerances(mem, rtol, atol);
+  if(check_flag(&ier, "IDASStolerances", 1, thispe)) MPI_Abort(comm, 1);
+
+  /* Call IDASpgmr to specify the linear solver. */
+
+  ier = IDASpgmr(mem, 0);
+  if(check_flag(&ier, "IDASpgmr", 1, thispe)) MPI_Abort(comm, 1);
+
+  ier = IDASpilsSetPreconditioner(mem, PsetupHeat, PsolveHeat);
+  if(check_flag(&ier, "IDASpilsSetPreconditioner", 1, thispe)) MPI_Abort(comm, 1);
+
+  /* Print output heading (on processor 0 only) and intial solution  */
+  
+  if (thispe == 0) PrintHeader(Neq, rtol, atol);
+  PrintOutput(thispe, mem, t0, uu); 
+  
+  /* Loop over tout, call IDASolve, print output. */
+
+  for (tout = t1, iout = 1; iout <= NOUT; iout++, tout *= TWO) {
+
+    ier = IDASolve(mem, tout, &tret, uu, up, IDA_NORMAL);
+    if(check_flag(&ier, "IDASolve", 1, thispe)) MPI_Abort(comm, 1);
+
+    PrintOutput(thispe, mem, tret, uu);
+
+  }
+  
+  /* Print remaining counters. */
+
+  if (thispe == 0) PrintFinalStats(mem);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+
+  N_VDestroy_Petsc(id);
+  N_VDestroy_Petsc(res);
+  N_VDestroy_Petsc(up);
+  N_VDestroy_Petsc(uu);
+
+  N_VDestroy_Petsc(data->pp);
+  ierr = DMDestroy(&data->da);
+  CHKERRQ(ierr);
+  free(data);
+  
+  ierr = VecDestroy(&uvec);
+  CHKERRQ(ierr);
+
+  ierr = PetscFinalize();
+  CHKERRQ(ierr);
+
+  MPI_Finalize();
+
+  return(0);
+
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDA
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * resHeat: heat equation system residual function                       
+ * This uses 5-point central differencing on the interior points, and    
+ * includes algebraic equations for the boundary values.                 
+ * So for each interior point, the residual component has the form       
+ *    res_i = u'_i - (central difference)_i                              
+ * while for each boundary point, it is res_i = u_i. 
+ *                    
+ */
+
+int resHeat(realtype tt, 
+            N_Vector uu, N_Vector up, N_Vector rr, 
+            void *user_data)
+{
+  PetscErrorCode ierr;
+  UserData       data = (UserData) user_data;
+  DM             da   = (DM) data->da;
+  PetscInt       i, j, Mx, My, xs, ys, xm, ym;
+  PetscReal      hx, hy, sx, sy;
+  PetscScalar    u, uxx, uyy, **uarray, **f, **udot;
+  Vec localU;
+  Vec *U    = N_VGetVector_Petsc(uu);
+  Vec *Udot = N_VGetVector_Petsc(up);
+  Vec *F    = N_VGetVector_Petsc(rr);
+
+  PetscFunctionBeginUser;
+  ierr = DMGetLocalVector(da, &localU);
+  CHKERRQ(ierr);
+  ierr = DMDAGetInfo(da,
+                     PETSC_IGNORE,
+                     &Mx,          /* Get global grid x size */
+                     &My,          /* Get global grid y size */
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE);
+
+  hx = 1.0/(PetscReal)(Mx-1); sx = 1.0/(hx*hx);
+  hy = 1.0/(PetscReal)(My-1); sy = 1.0/(hy*hy);
+
+  /*
+     Scatter ghost points to local vector,using the 2-step process
+        DMGlobalToLocalBegin(),DMGlobalToLocalEnd().
+     By placing code between these two statements, computations can be
+     done while messages are in transition.
+  */
+  ierr = DMGlobalToLocalBegin(da, *U, INSERT_VALUES, localU);
+  CHKERRQ(ierr);
+  ierr = DMGlobalToLocalEnd(da, *U, INSERT_VALUES, localU);
+  CHKERRQ(ierr);
+
+  /* Get pointers to vector data */
+  ierr = DMDAVecGetArrayRead(da, localU, &uarray);
+  CHKERRQ(ierr);
+  ierr = DMDAVecGetArray(da, *F, &f);
+  CHKERRQ(ierr);
+  ierr = DMDAVecGetArray(da, *Udot, &udot);
+  CHKERRQ(ierr);
+
+  /* Get local grid boundaries */
+  ierr = DMDAGetCorners(da, &xs, &ys, NULL, &xm, &ym, NULL);
+  CHKERRQ(ierr);
+
+  /* Compute function over the locally owned part of the grid */
+  for (j=ys; j<ys+ym; j++) {
+    for (i=xs; i<xs+xm; i++) {
+      /* Boundary conditions */
+      if (i == 0 || j == 0 || i == Mx-1 || j == My-1) {
+        f[j][i] = uarray[j][i]; /* F = U */
+      } else { /* Interior */
+        u = uarray[j][i];
+        /* 5-point stencil */
+        uxx = (-2.0*u + uarray[j][i-1] + uarray[j][i+1]);
+        uyy = (-2.0*u + uarray[j-1][i] + uarray[j+1][i]);
+        f[j][i] = udot[j][i] - (uxx*sx + uyy*sy);
+      }
+    }
+  }
+
+  /* Restore vectors */
+  ierr = DMDAVecRestoreArrayRead(da, localU, &uarray);
+  CHKERRQ(ierr);
+  ierr = DMDAVecRestoreArray(da, *F, &f);
+  CHKERRQ(ierr);
+  ierr = DMDAVecRestoreArray(da, *Udot, &udot);
+  CHKERRQ(ierr);
+  ierr = DMRestoreLocalVector(da, &localU);
+  CHKERRQ(ierr);
+  
+  PetscFunctionReturn(0);
+}
+
+
+/*
+ * PsetupHeat: setup for diagonal preconditioner for heatsk.    
+ *                                                                 
+ * The optional user-supplied functions PsetupHeat and          
+ * PsolveHeat together must define the left preconditoner        
+ * matrix P approximating the system Jacobian matrix               
+ *                   J = dF/du + cj*dF/du'                         
+ * (where the DAE system is F(t,u,u') = 0), and solve the linear   
+ * systems P z = r.   This is done in this case by keeping only    
+ * the diagonal elements of the J matrix above, storing them as    
+ * inverses in a vector pp, when computed in PsetupHeat, for    
+ * subsequent use in PsolveHeat.                                 
+ *                                                                 
+ * In this instance, only cj and data (user data structure, with    
+ * pp etc.) are used from the PsetupHeat argument list.         
+ *
+ */
+
+int PsetupHeat(realtype tt, 
+               N_Vector yy, N_Vector yp, N_Vector rr, 
+               realtype c_j, void *user_data,
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  PetscErrorCode ierr;
+  PetscInt    i, j, Mx, My, xs, ys, xm, ym;
+  PetscReal   hx,hy,sx,sy;
+  PetscScalar pelinv;
+  PetscScalar **ppv;
+  UserData data = (UserData) user_data;
+  DM da = (DM) data->da;
+  Vec *ppvec = N_VGetVector_Petsc((data->pp));
+  
+  PetscFunctionBeginUser;
+  ierr = DMDAGetInfo(da,
+                     PETSC_IGNORE,
+                     &Mx,          /* Get global grid x size */
+                     &My,          /* Get global grid y size */
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE);
+  ierr = DMDAGetCorners(da, &xs, &ys, NULL, &xm, &ym, NULL);
+  CHKERRQ(ierr);
+
+  hx = 1.0/(PetscReal)(Mx-1); sx = 1.0/(hx*hx);
+  hy = 1.0/(PetscReal)(My-1); sy = 1.0/(hy*hy);
+  
+  pelinv = ONE/(2.0*(sx + sy) + c_j);
+
+  ierr = DMDAVecGetArray(da, *ppvec, &ppv);
+  CHKERRQ(ierr);
+
+  for (j=ys; j<ys+ym; j++) {
+    for (i=xs; i<xs+xm; i++) {
+      if (i == 0 || j == 0 || i == Mx-1 || j == My-1) {
+        ppv[j][i] = ONE;    /* Boundary */
+      } else {
+        ppv[j][i] = pelinv; /* Interior */
+      }
+    }
+  }
+
+  ierr = DMDAVecRestoreArray(da, *ppvec, &ppv);
+  CHKERRQ(ierr);
+  
+  PetscFunctionReturn(0);
+}
+
+
+/*
+ * PsolveHeat: solve preconditioner linear system.              
+ * This routine multiplies the input vector rvec by the vector pp 
+ * containing the inverse diagonal Jacobian elements (previously  
+ * computed in PsetupHeat), returning the result in zvec.      
+ */
+
+int PsolveHeat(realtype tt, 
+               N_Vector uu, N_Vector up, N_Vector rr, 
+               N_Vector rvec, N_Vector zvec,
+               realtype c_j, realtype delta, void *user_data, 
+               N_Vector tmp)
+{
+  UserData data;
+
+  data = (UserData) user_data;
+  
+  N_VProd(data->pp, rvec, zvec);
+
+  return(0);
+
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+
+/*
+ * SetInitialProfile sets the initial values for the problem. 
+ */
+
+static int SetInitialProfile(N_Vector uu, N_Vector up, N_Vector id,
+                             N_Vector res, void *user_data)
+{
+  UserData       data = (UserData) user_data;
+  DM             da   = data->da;
+  PetscErrorCode ierr;
+  PetscInt       i, j, xs, ys, xm, ym, Mx, My;
+  PetscScalar    **u;
+  PetscScalar    **iddat;
+  PetscReal      hx, hy, x, y;
+  Vec *U     = N_VGetVector_Petsc(uu);
+  Vec *idvec = N_VGetVector_Petsc(id);
+
+  PetscFunctionBeginUser;
+  ierr = DMDAGetInfo(da,
+                     PETSC_IGNORE,
+                     &Mx,
+                     &My,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE,
+                     PETSC_IGNORE);
+
+  hx = 1.0/(PetscReal)(Mx-1);
+  hy = 1.0/(PetscReal)(My-1);
+
+  /* Get pointers to vector data */
+  ierr = DMDAVecGetArray(da, *U, &u);
+  CHKERRQ(ierr);
+
+  /* Get pointers to differentiable variable IDs */
+  ierr = DMDAVecGetArray(da, *idvec, &iddat);
+  CHKERRQ(ierr);
+
+  /* Get local grid boundaries */
+  ierr = DMDAGetCorners(da,&xs,&ys,NULL,&xm,&ym,NULL);
+  CHKERRQ(ierr);
+
+  /* Compute function over the locally owned part of the grid */
+  for (j=ys; j<ys+ym; j++) {
+    y = j*hy;
+    for (i=xs; i<xs+xm; i++) {
+      x = i*hx;
+      u[j][i] = 16.0 * x*(1.0 - x) * y*(1.0 - y);
+      if (i == 0 || j == 0 || i == Mx-1 || j == My-1) {
+        iddat[j][i] = 0.0; /* algebraic variables on the boundary */
+      } else { 
+        iddat[j][i] = 1.0; /* differential variables in the interior */
+      }
+    }
+  }
+
+  /* Restore vectors */
+  ierr = DMDAVecRestoreArray(da, *U, &u);
+  CHKERRQ(ierr);
+
+   /* Restore vectors */
+  ierr = DMDAVecRestoreArray(da, *idvec, &iddat);
+  CHKERRQ(ierr);
+
+  /* Initialize up. */
+  N_VConst(ZERO, up);    /* Initially set up = 0. */
+  
+  /* resHeat sets res to negative of ODE RHS values at interior points. */
+  resHeat(ZERO, uu, up, res, data);
+  
+  /* Copy -res into up to get correct initial up values. */
+  N_VScale(-ONE, res, up);
+  
+  PetscFunctionReturn(0);
+}
+
+
+/*
+ * Print first lines of output and table heading
+ */
+
+static void PrintHeader(long int Neq, realtype rtol, realtype atol)
+{ 
+  printf("\nidaHeat2D_kry_petsc: Heat equation, parallel example problem for IDA\n");
+  printf("            Discretized heat equation on 2D unit square.\n");
+  printf("            Zero boundary conditions,");
+  printf(" polynomial initial conditions.\n");
+  printf("            Mesh dimensions: %d x %d", MX, MY);
+  printf("        Total system size: %ld\n\n", Neq);
+  printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB);
+  printf("        Processor array: %d x %d\n", NPEX, NPEY);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#endif
+  printf("Constraints set to force all solution components >= 0. \n");
+  printf("SUPPRESSALG = TRUE to suppress local error testing on ");
+  printf("all boundary components. \n");
+  printf("Linear solver: IDASPGMR  ");
+  printf("Preconditioner: diagonal elements only.\n"); 
+  printf("This example uses PETSc vector.\n");
+  
+  /* Print output table heading and initial line of table. */
+  printf("\n   Output Summary (umax = max-norm of solution) \n\n");
+  printf("  time     umax       k  nst  nni  nli   nre   nreLS    h      npe nps\n");
+  printf("----------------------------------------------------------------------\n");
+}
+
+/*
+ * PrintOutput: print max norm of solution and current solver statistics
+ */
+
+static void PrintOutput(int id, void *mem, realtype t, N_Vector uu)
+{
+  realtype hused, umax;
+  long int nst, nni, nje, nre, nreLS, nli, npe, nps;
+  int kused, ier;
+
+  umax = N_VMaxNorm(uu);
+
+  if (id == 0) {
+
+    ier = IDAGetLastOrder(mem, &kused);
+    check_flag(&ier, "IDAGetLastOrder", 1, id);
+    ier = IDAGetNumSteps(mem, &nst);
+    check_flag(&ier, "IDAGetNumSteps", 1, id);
+    ier = IDAGetNumNonlinSolvIters(mem, &nni);
+    check_flag(&ier, "IDAGetNumNonlinSolvIters", 1, id);
+    ier = IDAGetNumResEvals(mem, &nre);
+    check_flag(&ier, "IDAGetNumResEvals", 1, id);
+    ier = IDAGetLastStep(mem, &hused);
+    check_flag(&ier, "IDAGetLastStep", 1, id);
+    ier = IDASpilsGetNumJtimesEvals(mem, &nje);
+    check_flag(&ier, "IDASpilsGetNumJtimesEvals", 1, id);
+    ier = IDASpilsGetNumLinIters(mem, &nli);
+    check_flag(&ier, "IDASpilsGetNumLinIters", 1, id);
+    ier = IDASpilsGetNumResEvals(mem, &nreLS);
+    check_flag(&ier, "IDASpilsGetNumResEvals", 1, id);
+    ier = IDASpilsGetNumPrecEvals(mem, &npe);
+    check_flag(&ier, "IDASpilsGetPrecEvals", 1, id);
+    ier = IDASpilsGetNumPrecSolves(mem, &nps);
+    check_flag(&ier, "IDASpilsGetNumPrecSolves", 1, id);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)  
+    printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le  %3ld %3ld\n",
+           t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)  
+    printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
+           t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
+#else
+    printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
+           t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
+#endif
+
+  }
+}
+
+/*
+ * Print some final integrator statistics
+ */
+
+static void PrintFinalStats(void *mem)
+{
+  long int netf, ncfn, ncfl;
+
+  IDAGetNumErrTestFails(mem, &netf);
+  IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  IDASpilsGetNumConvFails(mem, &ncfl);
+
+  printf("\nError test failures            = %ld\n", netf);
+  printf("Nonlinear convergence failures = %ld\n", ncfn);
+  printf("Linear convergence failures    = %ld\n", ncfl);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
+{
+  int *errflag;
+
+  if (opt == 0 && flagvalue == NULL) {
+    /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR(%d): %s() failed - returned NULL pointer\n\n", 
+            id, funcname);
+    return(1); 
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR(%d): %s() failed with flag = %d\n\n", 
+              id, funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR(%d): %s() failed - returned NULL pointer\n\n", 
+            id, funcname);
+    return(1); 
+  }
+
+  return(0);
+}
diff --git a/examples/ida/petsc/idaHeat2D_kry_petsc.out b/examples/ida/petsc/idaHeat2D_kry_petsc.out
new file mode 100644
index 0000000..51bd511
--- /dev/null
+++ b/examples/ida/petsc/idaHeat2D_kry_petsc.out
@@ -0,0 +1,33 @@
+
+idaHeat2D_kry_petsc: Heat equation, parallel example problem for IDA
+            Discretized heat equation on 2D unit square.
+            Zero boundary conditions, polynomial initial conditions.
+            Mesh dimensions: 10 x 10        Total system size: 100
+
+Subgrid dimensions: 5 x 5        Processor array: 2 x 2
+Tolerance parameters:  rtol = 0   atol = 0.001
+Constraints set to force all solution components >= 0. 
+SUPPRESSALG = TRUE to suppress local error testing on all boundary components. 
+Linear solver: IDASPGMR  Preconditioner: diagonal elements only.
+This example uses PETSc vector.
+
+   Output Summary (umax = max-norm of solution) 
+
+  time     umax       k  nst  nni  nli   nre   nreLS    h      npe nps
+----------------------------------------------------------------------
+  0.00   9.75461e-01  0    0    0    0     0     0   0.00e+00    0   0
+  0.01   8.24106e-01  2   12   14    7    14     7   2.56e-03    8  21
+  0.02   6.88134e-01  3   15   18   12    18    12   5.12e-03    8  30
+  0.04   4.70711e-01  3   18   24   21    24    21   6.58e-03    9  45
+  0.08   2.16509e-01  3   22   29   30    29    30   1.32e-02    9  59
+  0.16   4.57687e-02  4   28   36   44    36    44   1.32e-02    9  80
+  0.32   2.09938e-03  4   35   44   67    44    67   2.63e-02   10 111
+  0.64   5.54028e-21  1   39   51   77    51    77   1.05e-01   12 128
+  1.28   0.00000e+00  1   41   53   77    53    77   4.21e-01   14 130
+  2.56   0.00000e+00  1   43   55   77    55    77   1.69e+00   16 132
+  5.12   0.00000e+00  1   44   56   77    56    77   3.37e+00   17 133
+ 10.24   0.00000e+00  1   45   57   77    57    77   6.74e+00   18 134
+
+Error test failures            = 1
+Nonlinear convergence failures = 0
+Linear convergence failures    = 0
diff --git a/examples/ida/serial/CMakeLists.txt b/examples/ida/serial/CMakeLists.txt
index 720f6ee..c0b73ad 100644
--- a/examples/ida/serial/CMakeLists.txt
+++ b/examples/ida/serial/CMakeLists.txt
@@ -1,15 +1,23 @@
 # ---------------------------------------------------------------
-# $Revision: 1.6 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for IDA serial examples
+#
+# CSW 4/19/2014
+#    Added SUPERLUMT logic.
 
 
 # Add variable IDA_examples with the names of the serial IDA examples
@@ -18,11 +26,22 @@ SET(IDA_examples
   idaFoodWeb_bnd
   idaHeat2D_bnd
   idaHeat2D_kry
+  idaFoodWeb_kry
   idaKrylovDemo_ls
   idaRoberts_dns
   idaSlCrank_dns
   )
 
+SET(IDA_examples_SUPERLUMT
+  idaRoberts_sps
+  #idaHeat2D_sps ... not ready yet ... incorrect answer.
+  )
+
+SET(IDA_examples_KLU
+  idaRoberts_klu
+  idaHeat2D_klu
+  )
+
 # Add variable IDA_examples_BL with the names of the serial IDA examples
 # that use Lapack
 
@@ -44,14 +63,27 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${IDA_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(PETSC_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_FOUND)
+
 # Add the build and install targets for each IDA example
 
 FOREACH(example ${IDA_examples})
   ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/serial)
@@ -64,6 +96,8 @@ ENDFOREACH(example ${IDA_examples})
 IF(LAPACK_FOUND)
   FOREACH(example ${IDA_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     IF(EXAMPLES_INSTALL)
       INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/serial)
@@ -71,6 +105,34 @@ IF(LAPACK_FOUND)
   ENDFOREACH(example ${IDA_examples_BL})
 ENDIF(LAPACK_FOUND)
 
+# If SUPERLUMT support is enabled, add the build and install targets for
+# the examples using SUPERLUMT
+IF(SUPERLUMT_FOUND)
+  FOREACH(example ${IDA_examples_SUPERLUMT})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${IDA_examples_SUPERLUMT})
+ENDIF(SUPERLUMT_FOUND)
+
+# If KLU support is enabled, add the build and install targets for
+# the examples using KLU
+IF(KLU_FOUND)
+  FOREACH(example ${IDA_examples_KLU})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/ida/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${IDA_examples_KLU})
+ENDIF(KLU_FOUND)
+
 IF(EXAMPLES_INSTALL)
 
   # Install the README file
@@ -80,12 +142,24 @@ IF(EXAMPLES_INSTALL)
   SET(SOLVER "IDA")
   SET(SOLVER_LIB "sundials_ida")
   LIST2STRING(IDA_examples EXAMPLES)
+
   IF(LAPACK_FOUND)
     LIST2STRING(IDA_examples_BL EXAMPLES_BL)
   ELSE(LAPACK_FOUND)
     SET(EXAMPLES_BL "")
   ENDIF(LAPACK_FOUND)
 
+  IF(KLU_FOUND)
+    LIST2STRING(IDA_examples_KLU EXAMPLES)
+  ENDIF(KLU_FOUND)
+
+  IF(SUPERLUMT_FOUND)
+    LIST2STRING(IDA_examples_SUPERLUMT EXAMPLES)
+  ENDIF(SUPERLUMT_FOUND)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
   # be used as a template for the user's own programs.
diff --git a/examples/ida/serial/Makefile.in b/examples/ida/serial/Makefile.in
deleted file mode 100644
index 597e735..0000000
--- a/examples/ida/serial/Makefile.in
+++ /dev/null
@@ -1,134 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.11 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for IDA serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/ida/libsundials_ida.la                \
-	        $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = idaFoodWeb_bnd \
-	   idaHeat2D_bnd \
-	   idaHeat2D_kry \
-	   idaKrylovDemo_ls \
-	   idaRoberts_dns \
-	   idaSlCrank_dns
-
-EXAMPLES_BL =
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done ; \
-	fi
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/ida/serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/ida/serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/ida/serial/README $(EXS_INSTDIR)/ida/serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/serial/$${i}.c   $(EXS_INSTDIR)/ida/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/serial/$${i}.out $(EXS_INSTDIR)/ida/serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/serial/$${i}.c   $(EXS_INSTDIR)/ida/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/ida/serial/$${i}.out $(EXS_INSTDIR)/ida/serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/ida/serial/Makefile
-	rm -f $(EXS_INSTDIR)/ida/serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/ida/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/ida/serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/ida/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/ida/serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/ida/serial
-	$(rminstalldirs) $(EXS_INSTDIR)/ida
-
-clean:
-	rm -rf .libs
-	rm -f *.lo
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	${SHELL} ./config.status --recheck ; \
-	cd ${abs_builddir}
diff --git a/examples/ida/serial/README b/examples/ida/serial/README
index c86d0b4..98bca6c 100644
--- a/examples/ida/serial/README
+++ b/examples/ida/serial/README
@@ -1,19 +1,57 @@
 List of serial IDA examples
 
   idaFoodWeb_bnd   : 2-D food web system, banded Jacobian
+  idaFoodWeb_kry   : 2-D food web system using Krylov solver
   idaHeat2D_bnd    : 2-D heat equation, banded Jacobian
   idaHeat2D_kry    : 2-D heat equation, diagonal preconditioner
   idaKrylovDemo_ls : demonstration program with 3 Krylov solvers
   idaRoberts_dns   : 3-species Robertson kinetics system
+  idaRoberts_klu   : Robertson system with KLU sparse linear solver
+  idaRoberts_sps   : Robertson system with SuperLUMT sparse linear solver
   idaSlCrank_dns   : slider-crank example (stabilized index-2 DAE)
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/ida/serial/idaFoodWeb_bnd.c b/examples/ida/serial/idaFoodWeb_bnd.c
index 35b83fe..9c4c5aa 100644
--- a/examples/ida/serial/idaFoodWeb_bnd.c
+++ b/examples/ida/serial/idaFoodWeb_bnd.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:25:59 $
+ * $Revision: 4853 $
+ * $Date: 2016-08-03 16:27:46 -0700 (Wed, 03 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -159,7 +159,7 @@ static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate, UserData webdata);
 static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
                      UserData webdata);
 static realtype dotprod(long int size, realtype *x1, realtype *x2);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -303,8 +303,8 @@ static int resweb(realtype tt, N_Vector cc, N_Vector cp,
   
   webdata = (UserData)user_data;
   
-  cpv = NV_DATA_S(cp);
-  resv = NV_DATA_S(res);
+  cpv = N_VGetArrayPointer_Serial(cp);
+  resv = N_VGetArrayPointer_Serial(res);
   np = webdata->np;
   
   /* Call Fweb to set res to vector of right-hand sides. */
@@ -394,12 +394,12 @@ static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
                                UserData webdata)
 {
   long int loc, yloc, is, jx, jy, np;
-  realtype xx, yy, xyfactor, fac;
+  realtype xx, yy, xyfactor;
   realtype *ccv, *cpv, *idv;
   
-  ccv = NV_DATA_S(cc);
-  cpv = NV_DATA_S(cp);
-  idv = NV_DATA_S(id);
+  ccv = N_VGetArrayPointer_Serial(cc);
+  cpv = N_VGetArrayPointer_Serial(cp);
+  idv = N_VGetArrayPointer_Serial(id);
   np = webdata->np;
   
   /* Loop over grid, load cc values and id values. */
@@ -411,11 +411,10 @@ static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
       xyfactor = RCONST(16.0)*xx*(ONE-xx)*yy*(ONE-yy);
       xyfactor *= xyfactor;
       loc = yloc + NUM_SPECIES*jx;
-      fac = ONE + ALPHA * xx * yy + BETA * sin(FOURPI*xx) * sin(FOURPI*yy);
-      
+       
       for (is = 0; is < NUM_SPECIES; is++) {
         if (is < np) {
-	    ccv[loc+is] = RCONST(10.0) + (realtype)(is+1) * xyfactor;
+          ccv[loc+is] = RCONST(10.0) + (realtype)(is+1) * xyfactor;
           idv[loc+is] = ONE;
         }
         else {
@@ -454,7 +453,7 @@ static void PrintHeader(long int mu, long int ml, realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -491,17 +490,17 @@ static void PrintOutput(void *mem, N_Vector c, realtype t)
 
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("%8.2Le %12.4Le %12.4Le   | %3ld  %1d %12.4Le\n", 
-         t, c_bl[0], c_tr[1], nst, kused, hused);
+         t, c_bl[0], c_tr[0], nst, kused, hused);
   for (i=1;i<NUM_SPECIES;i++)
     printf("         %12.4Le %12.4Le   |\n",c_bl[i],c_tr[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
-         t, c_bl[0], c_tr[1], nst, kused, hused);
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
   for (i=1;i<NUM_SPECIES;i++)
-    printf("         %12.4le %12.4le   |\n",c_bl[i],c_tr[i]);
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
 #else
   printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
-         t, c_bl[0], c_tr[1], nst, kused, hused);
+         t, c_bl[0], c_tr[0], nst, kused, hused);
   for (i=1;i<NUM_SPECIES;i++)
     printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
 #endif
@@ -643,7 +642,7 @@ static realtype dotprod(long int size, realtype *x1, realtype *x2)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/ida/serial/idaFoodWeb_bnd.out b/examples/ida/serial/idaFoodWeb_bnd.out
index 293c68d..f188bd8 100644
--- a/examples/ida/serial/idaFoodWeb_bnd.out
+++ b/examples/ida/serial/idaFoodWeb_bnd.out
@@ -10,25 +10,25 @@ CalcIC called to correct initial predator concentrations.
   t        bottom-left  top-right    | nst  k      h
 -----------------------------------------------------------
 
-0.00e+00   1.0000e+01   1.0000e+05   |   0  0   1.6310e-08
+0.00e+00   1.0000e+01   1.0000e+01   |   0  0   1.6310e-08
            1.0000e+05   1.0000e+05   |
 
-1.00e-03   1.0318e+01   1.0822e+05   |  32  4   1.0823e-04
+1.00e-03   1.0318e+01   1.0827e+01   |  32  4   1.0823e-04
            1.0319e+05   1.0822e+05   |
 
-1.00e-02   1.6188e+02   1.9734e+06   | 127  4   1.4203e-04
+1.00e-02   1.6188e+02   1.9735e+02   | 127  4   1.4203e-04
            1.6189e+06   1.9734e+06   |
 
-1.00e-01   2.4019e+02   2.7072e+06   | 235  1   3.9160e-02
+1.00e-01   2.4019e+02   2.7072e+02   | 235  1   3.9160e-02
            2.4019e+06   2.7072e+06   |
 
-4.00e-01   2.4019e+02   2.7072e+06   | 238  1   3.1328e-01
+4.00e-01   2.4019e+02   2.7072e+02   | 238  1   3.1328e-01
            2.4019e+06   2.7072e+06   |
 
-7.00e-01   2.4019e+02   2.7072e+06   | 239  1   6.2657e-01
+7.00e-01   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
            2.4019e+06   2.7072e+06   |
 
-1.00e+00   2.4019e+02   2.7072e+06   | 239  1   6.2657e-01
+1.00e+00   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
            2.4019e+06   2.7072e+06   |
 
 -----------------------------------------------------------
diff --git a/examples/ida/serial/idaFoodWeb_kry.c b/examples/ida/serial/idaFoodWeb_kry.c
new file mode 100644
index 0000000..11be4a6
--- /dev/null
+++ b/examples/ida/serial/idaFoodWeb_kry.c
@@ -0,0 +1,808 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ * -----------------------------------------------------------------
+ * Example program for IDA: Food web problem, OpenMP, GMRES, 
+ * user-supplied preconditioner
+ *
+ * This example program uses the IDASPGMR as the linear 
+ * solver, and IDACalcIC for initial condition calculation.
+ *
+ * The mathematical problem solved in this example is a DAE system
+ * that arises from a system of partial differential equations after
+ * spatial discretization. The PDE system is a food web population
+ * model, with predator-prey interaction and diffusion on the unit
+ * square in two dimensions. The dependent variable vector is:
+ *
+ *         1   2         ns
+ *   c = (c , c ,  ..., c  ) , ns = 2 * np
+ *
+ * and the PDE's are as follows:
+ *
+ *     i             i      i
+ *   dc /dt = d(i)*(c    + c  )  +  R (x,y,c)   (i = 1,...,np)
+ *                   xx     yy       i
+ *
+ *              i      i
+ *   0 = d(i)*(c    + c  )  +  R (x,y,c)   (i = np+1,...,ns)
+ *              xx     yy       i
+ *
+ *   where the reaction terms R are:
+ *
+ *                   i             ns         j
+ *   R  (x,y,c)  =  c  * (b(i)  + sum a(i,j)*c )
+ *    i                           j=1
+ *
+ * The number of species is ns = 2 * np, with the first np being
+ * prey and the last np being predators. The coefficients a(i,j),
+ * b(i), d(i) are:
+ *
+ *  a(i,i) = -AA   (all i)
+ *  a(i,j) = -GG   (i <= np , j >  np)
+ *  a(i,j) =  EE   (i >  np, j <= np)
+ *  all other a(i,j) = 0
+ *  b(i) = BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i <= np)
+ *  b(i) =-BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i  > np)
+ *  d(i) = DPREY   (i <= np)
+ *  d(i) = DPRED   (i > np)
+ *
+ * The various scalar parameters required are set using '#define'
+ * statements or directly in routine InitUserData. In this program,
+ * np = 1, ns = 2. The boundary conditions are homogeneous Neumann:
+ * normal derivative = 0.
+ *
+ * A polynomial in x and y is used to set the initial values of the
+ * first np variables (the prey variables) at each x,y location,
+ * while initial values for the remaining (predator) variables are
+ * set to a flat value, which is corrected by IDACalcIC.
+ *
+ * The PDEs are discretized by central differencing on a MX by MY
+ * mesh.
+ *
+ * The DAE system is solved by IDA using the IDABAND linear solver.
+ * Output is printed at t = 0, .001, .01, .1, .4, .7, 1.
+ * -----------------------------------------------------------------
+ * References:
+ * [1] Peter N. Brown and Alan C. Hindmarsh,
+ *     Reduced Storage Matrix Methods in Stiff ODE systems, Journal
+ *     of Applied Mathematics and Computation, Vol. 31 (May 1989),
+ *     pp. 40-91.
+ *
+ * [2] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Using Krylov Methods in the Solution of Large-Scale
+ *     Differential-Algebraic Systems, SIAM J. Sci. Comput., 15
+ *     (1994), pp. 1467-1488.
+ *
+ * [3] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Consistent Initial Condition Calculation for Differential-
+ *     Algebraic Systems, SIAM J. Sci. Comput., 19 (1998),
+ *     pp. 1495-1512.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <ida/ida.h>
+#include <ida/ida_spgmr.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_dense.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants. */
+
+#define NPREY       1              /* No. of prey (= no. of predators). */
+#define NUM_SPECIES 2*NPREY
+
+#define PI          RCONST(3.1415926535898)
+#define FOURPI      (RCONST(4.0)*PI)
+
+#define MX          20             /* MX = number of x mesh points      */
+#define MY          20             /* MY = number of y mesh points      */
+#define NSMX        (NUM_SPECIES * MX)
+#define NEQ         (NUM_SPECIES*MX*MY)
+#define AA          RCONST(1.0)    /* Coefficient in above eqns. for a  */
+#define EE          RCONST(10000.) /* Coefficient in above eqns. for a  */
+#define GG          RCONST(0.5e-6) /* Coefficient in above eqns. for a  */
+#define BB          RCONST(1.0)    /* Coefficient in above eqns. for b  */
+#define DPREY       RCONST(1.0)    /* Coefficient in above eqns. for d  */
+#define DPRED       RCONST(0.05)   /* Coefficient in above eqns. for d  */
+#define ALPHA       RCONST(50.)    /* Coefficient alpha in above eqns.  */
+#define BETA        RCONST(1000.)  /* Coefficient beta in above eqns.   */
+#define AX          RCONST(1.0)    /* Total range of x variable         */
+#define AY          RCONST(1.0)    /* Total range of y variable         */
+#define RTOL        RCONST(1.e-5)  /* Relative tolerance                */
+#define ATOL        RCONST(1.e-5)  /* Absolute tolerance                */
+#define NOUT        6              /* Number of output times            */
+#define TMULT       RCONST(10.0)   /* Multiplier for tout values        */
+#define TADD        RCONST(0.3)    /* Increment for tout values         */
+#define ZERO        RCONST(0.)     
+#define ONE         RCONST(1.0)    
+
+/* 
+ * User-defined vector and accessor macro: IJ_Vptr.
+ * IJ_Vptr is defined in order to express the underlying 3-D structure of 
+ * the dependent variable vector from its underlying 1-D storage (an N_Vector).
+ * IJ_Vptr(vv,i,j) returns a pointer to the location in vv corresponding to 
+ * species index is = 0, x-index ix = i, and y-index jy = j.                
+ */
+
+#define IJ_Vptr(vv,i,j) (&NV_Ith_S(vv, (i)*NUM_SPECIES + (j)*NSMX))
+
+/* Type: UserData.  Contains problem constants, etc. */
+
+typedef struct {
+  long int Neq, ns, np, mx, my;
+  realtype dx, dy, **acoef;
+  realtype cox[NUM_SPECIES], coy[NUM_SPECIES], bcoef[NUM_SPECIES];
+  realtype **PP[MX][MY];
+  long int *pivot[MX][MY];
+  N_Vector rates;
+  N_Vector ewt;
+  void *ida_mem;
+} *UserData;
+
+/* Prototypes for functions called by the IDA Solver. */
+
+static int resweb(realtype time, N_Vector cc, N_Vector cp, N_Vector resval, 
+                  void *user_data);
+
+static int Precond(realtype tt,
+		   N_Vector cc, N_Vector cp, N_Vector rr, 
+		   realtype cj, void *user_data,
+		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int PSolve(realtype tt, 
+		  N_Vector cc, N_Vector cp, N_Vector rr,
+		  N_Vector rvec, N_Vector zvec,
+		  realtype cj, realtype delta, void *user_data,
+		  N_Vector tmp);
+
+/* Prototypes for private Helper Functions. */
+
+static void InitUserData(UserData webdata);
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata);
+static void PrintHeader(long int maxl, realtype rtol, realtype atol);
+static void PrintOutput(void *mem, N_Vector c, realtype t);
+static void PrintFinalStats(void *mem);
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate, UserData webdata);
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
+                     UserData webdata);
+static realtype dotprod(long int size, realtype *x1, realtype *x2);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main()
+{ 
+  void *mem;
+  UserData webdata;
+  N_Vector cc, cp, id;
+  int iout, jx, jy, flag;
+  long int maxl;
+  realtype rtol, atol, t0, tout, tret;
+
+  mem = NULL;
+  webdata = NULL;
+  cc = cp = id = NULL;
+
+  /* Allocate and initialize user data block webdata. */
+
+  webdata = (UserData) malloc(sizeof *webdata);
+  webdata->rates = N_VNew_Serial(NEQ);
+  webdata->acoef = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+  webdata->ewt = N_VNew_Serial(NEQ);
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy < MY; jy++) {
+      (webdata->pivot)[jx][jy] = newLintArray(NUM_SPECIES);
+      (webdata->PP)[jx][jy] = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+    }
+  }
+
+  InitUserData(webdata);
+
+  /* Allocate N-vectors and initialize cc, cp, and id. */
+
+  cc  = N_VNew_Serial(NEQ);
+  if(check_flag((void *)cc, "N_VNew_Serial", 0)) return(1);
+
+  cp  = N_VNew_Serial(NEQ);
+  if(check_flag((void *)cp, "N_VNew_Serial", 0)) return(1);
+
+  id  = N_VNew_Serial(NEQ);
+  if(check_flag((void *)id, "N_VNew_Serial", 0)) return(1);
+  
+  SetInitialProfiles(cc, cp, id, webdata);
+  
+  /* Set remaining inputs to IDAMalloc. */
+  
+  t0 = ZERO;
+  rtol = RTOL; 
+  atol = ATOL;
+
+  /* Call IDACreate and IDAMalloc to initialize IDA. */
+  
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+
+  flag = IDASetUserData(mem, webdata);
+  if(check_flag(&flag, "IDASetUserData", 1)) return(1);
+
+  flag = IDASetId(mem, id);
+  if(check_flag(&flag, "IDASetId", 1)) return(1);
+
+  flag = IDAInit(mem, resweb, t0, cc, cp);
+  if(check_flag(&flag, "IDAInit", 1)) return(1);
+
+  flag = IDASStolerances(mem, rtol, atol);
+  if(check_flag(&flag, "IDASStolerances", 1)) return(1);
+
+  webdata->ida_mem = mem;
+
+  /* Call IDASpgmr to specify the IDA linear solver. */
+
+  maxl = 16;                    /* max dimension of the Krylov subspace */
+  flag = IDASpgmr(mem, maxl);
+  if(check_flag(&flag, "IDASpgmr", 1)) return(1);
+
+  flag = IDASpilsSetPreconditioner(mem, Precond, PSolve);
+  if(check_flag(&flag, "IDASpilsSetPreconditioner", 1)) return(1);
+
+  /* Call IDACalcIC (with default options) to correct the initial values. */
+
+  tout = RCONST(0.001);
+  flag = IDACalcIC(mem, IDA_YA_YDP_INIT, tout);
+  if(check_flag(&flag, "IDACalcIC", 1)) return(1);
+  
+  /* Print heading, basic parameters, and initial values. */
+
+  PrintHeader(maxl, rtol, atol);
+  PrintOutput(mem, cc, ZERO);
+  
+  /* Loop over iout, call IDASolve (normal mode), print selected output. */
+  
+  for (iout = 1; iout <= NOUT; iout++) {
+    
+    flag = IDASolve(mem, tout, &tret, cc, cp, IDA_NORMAL);
+    if(check_flag(&flag, "IDASolve", 1)) return(flag);
+    
+    PrintOutput(mem, cc, tret);
+    
+    if (iout < 3) tout *= TMULT; else tout += TADD;
+    
+  }
+  
+  /* Print final statistics and free memory. */  
+  
+  PrintFinalStats(mem);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+
+  N_VDestroy_Serial(cc);
+  N_VDestroy_Serial(cp);
+  N_VDestroy_Serial(id);
+
+
+  destroyMat(webdata->acoef);
+  N_VDestroy_Serial(webdata->rates);
+  N_VDestroy_Serial(webdata->ewt);
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy < MY; jy ++) {
+      destroyArray((webdata->pivot)[jx][jy]);
+      destroyMat((webdata->PP)[jx][jy]);
+    }
+  }
+  free(webdata);
+
+  return(0);
+}
+
+/* Define lines for readability in later routines */ 
+
+#define acoef  (webdata->acoef)
+#define bcoef  (webdata->bcoef)
+#define cox    (webdata->cox)
+#define coy    (webdata->coy)
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDA
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * resweb: System residual function for predator-prey system.
+ * This routine calls Fweb to get all the right-hand sides of the
+ * equations, then loads the residual vector accordingly,
+ * using cp in the case of prey species.                 
+ */
+
+static int resweb(realtype tt, N_Vector cc, N_Vector cp, 
+                  N_Vector res,  void *user_data)
+{
+  long int jx, jy, is, yloc, loc, np;
+  realtype *resv, *cpv;
+  UserData webdata;
+  
+  webdata = (UserData)user_data;
+  
+  cpv = NV_DATA_S(cp);
+  resv = NV_DATA_S(res);
+  np = webdata->np;
+  
+  /* Call Fweb to set res to vector of right-hand sides. */
+  Fweb(tt, cc, res, webdata);
+  
+  /* Loop over all grid points, setting residual values appropriately
+     for differential or algebraic components.                        */
+  
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np)
+          resv[loc+is] = cpv[loc+is] - resv[loc+is];
+        else
+          resv[loc+is] = -resv[loc+is];
+      }
+    }
+  }
+  
+  return(0);
+  
+}
+
+
+static int Precond(realtype tt, 
+		   N_Vector cc, N_Vector cp, N_Vector rr, 
+		   realtype cj, void *user_data,
+		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  int flag;
+  realtype uround, xx, yy, del_x, del_y;
+  realtype **Pxy, *ratesxy, *Pxycol, *cxy, *cpxy, *ewtxy, cctmp;
+  realtype inc, fac, sqru, perturb_rates[NUM_SPECIES];
+  int is, js, jx, jy, ret;
+  void *mem;
+  N_Vector ewt;
+  realtype hh;
+  UserData webdata;
+
+  webdata = (UserData) user_data;
+  del_x = webdata->dx;
+  del_y = webdata->dy;
+
+  uround = UNIT_ROUNDOFF;
+  sqru = SUNRsqrt(uround);
+
+  mem = webdata->ida_mem;
+  ewt = webdata->ewt;
+  flag = IDAGetErrWeights(mem, ewt);
+  if(check_flag(&flag, "IDAGetErrWeights", 1)) return(1);
+  flag = IDAGetCurrentStep(mem, &hh);
+  if(check_flag(&flag, "IDAGetCurrentStep", 1)) return(1);
+
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * del_y;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * del_x;
+      Pxy = (webdata->PP)[jx][jy];
+      cxy = IJ_Vptr(cc, jx, jy);
+      cpxy = IJ_Vptr(cp, jx, jy);
+      ewtxy = IJ_Vptr(ewt, jx, jy);
+      ratesxy = IJ_Vptr((webdata->rates), jx, jy);
+
+      for (js = 0; js < NUM_SPECIES; js++) {
+	inc = sqru*(SUNMAX(SUNRabs(cxy[js]), SUNMAX(hh*SUNRabs(cpxy[js]), ONE/ewtxy[js])));
+	cctmp = cxy[js];
+	cxy[js] += inc;
+	fac = -ONE/inc;
+
+	WebRates(xx, yy, cxy, perturb_rates, webdata);
+
+	Pxycol = Pxy[js];
+	
+	for (is = 0; is < NUM_SPECIES; is++)
+	  Pxycol[is] = (perturb_rates[is] - ratesxy[is])*fac;
+
+	if (js < 1) Pxycol[js] += cj;
+	
+	cxy[js] = cctmp;
+      }
+
+      ret = denseGETRF(Pxy, NUM_SPECIES, NUM_SPECIES, (webdata->pivot)[jx][jy]);
+
+      if (ret != 0) return(1);
+    }
+  }
+
+  return(0);
+
+}
+
+
+static int PSolve(realtype tt, 
+		  N_Vector cc, N_Vector cp, N_Vector rr, 
+		  N_Vector rvec, N_Vector zvec,
+		  realtype cj, realtype dalta, 
+		  void *user_data, N_Vector tmp) 
+{
+  realtype **Pxy, *zxy;
+  long int *pivot;
+  int jx, jy;
+  UserData webdata;
+  
+  webdata = (UserData) user_data;
+
+  N_VScale(ONE, rvec, zvec);
+
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy <MY; jy++) {
+      
+      zxy = IJ_Vptr(zvec, jx, jy);
+      Pxy = (webdata->PP)[jx][jy];
+      pivot = (webdata->pivot)[jx][jy];
+      denseGETRS(Pxy, NUM_SPECIES, pivot, zxy);
+    }
+  }
+  
+  return(0);
+
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * InitUserData: Load problem constants in webdata (of type UserData).   
+ */
+
+static void InitUserData(UserData webdata)
+{
+  int i, j, np;
+  realtype *a1,*a2, *a3, *a4, dx2, dy2;
+
+  webdata->mx = MX;
+  webdata->my = MY;
+  webdata->ns = NUM_SPECIES;
+  webdata->np = NPREY;
+  webdata->dx = AX/(MX-1);
+  webdata->dy = AY/(MY-1);
+  webdata->Neq= NEQ;
+  
+  /* Set up the coefficients a and b, and others found in the equations. */
+  np = webdata->np;
+  dx2 = (webdata->dx)*(webdata->dx); dy2 = (webdata->dy)*(webdata->dy);
+  
+  for (i = 0; i < np; i++) {
+    a1 = &(acoef[i][np]);
+    a2 = &(acoef[i+np][0]);
+    a3 = &(acoef[i][0]);
+    a4 = &(acoef[i+np][np]);
+    /*  Fill in the portion of acoef in the four quadrants, row by row. */
+    for (j = 0; j < np; j++) {
+      *a1++ =  -GG;
+      *a2++ =   EE;
+      *a3++ = ZERO;
+      *a4++ = ZERO;
+    }
+    
+    /* Reset the diagonal elements of acoef to -AA. */
+    acoef[i][i] = -AA; acoef[i+np][i+np] = -AA;
+    
+    /* Set coefficients for b and diffusion terms. */
+    bcoef[i] = BB; bcoef[i+np] = -BB;
+    cox[i] = DPREY/dx2; cox[i+np] = DPRED/dx2;
+    coy[i] = DPREY/dy2; coy[i+np] = DPRED/dy2;
+  }
+  
+}
+
+/* 
+ * SetInitialProfiles: Set initial conditions in cc, cp, and id.
+ * A polynomial profile is used for the prey cc values, and a constant
+ * (1.0e5) is loaded as the initial guess for the predator cc values.
+ * The id values are set to 1 for the prey and 0 for the predators.
+ * The prey cp values are set according to the given system, and
+ * the predator cp values are set to zero.                               
+ */
+
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata)
+{
+  long int loc, yloc, is, jx, jy, np;
+  realtype xx, yy, xyfactor;
+  realtype *ccv, *cpv, *idv;
+  
+  ccv = NV_DATA_S(cc);
+  cpv = NV_DATA_S(cp);
+  idv = NV_DATA_S(id);
+  np = webdata->np;
+  
+  /* Loop over grid, load cc values and id values. */
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * webdata->dy;
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * webdata->dx;
+      xyfactor = RCONST(16.0)*xx*(ONE-xx)*yy*(ONE-yy);
+      xyfactor *= xyfactor;
+      loc = yloc + NUM_SPECIES*jx;
+       
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np) {
+          ccv[loc+is] = RCONST(10.0) + (realtype)(is+1) * xyfactor;
+          idv[loc+is] = ONE;
+        }
+        else {
+	  ccv[loc+is] = RCONST(1.0e5);
+          idv[loc+is] = ZERO;
+        }
+      }
+    }
+  }
+  
+  /* Set c' for the prey by calling the function Fweb. */
+  Fweb(ZERO, cc, cp, webdata);
+  
+  /* Set c' for predators to 0. */
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = np; is < NUM_SPECIES; is++) {
+        cpv[loc+is] = ZERO;
+      }
+    }
+  }
+}
+
+/*
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(long int maxl, realtype rtol, realtype atol)
+{
+  printf("\nidaFoodWeb_kry: Predator-prey DAE serial example problem for IDA \n\n");
+  printf("Number of species ns: %d", NUM_SPECIES);
+  printf("     Mesh dimensions: %d x %d", MX, MY);
+  printf("     System size: %d\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#endif
+  printf("Linear solver: IDASpgmr,  Spgmr parameters maxl = %ld\n",maxl);
+  printf("CalcIC called to correct initial predator concentrations.\n\n");
+  printf("-----------------------------------------------------------\n");
+  printf("  t        bottom-left  top-right");
+  printf("    | nst  k      h\n");
+  printf("-----------------------------------------------------------\n\n");
+  
+}
+
+/* 
+ * PrintOutput: Print output values at output time t = tt.
+ * Selected run statistics are printed.  Then values of the concentrations
+ * are printed for the bottom left and top right grid points only.  
+ */
+
+static void PrintOutput(void *mem, N_Vector c, realtype t)
+{
+  int i, kused, flag;
+  long int nst;
+  realtype *c_bl, *c_tr, hused;
+
+  flag = IDAGetLastOrder(mem, &kused);
+  check_flag(&flag, "IDAGetLastOrder", 1);
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetLastStep(mem, &hused);
+  check_flag(&flag, "IDAGetLastStep", 1);
+  
+  c_bl = IJ_Vptr(c,0,0);
+  c_tr = IJ_Vptr(c,MX-1,MY-1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("%8.2Le %12.4Le %12.4Le   | %3ld  %1d %12.4Le\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4Le %12.4Le   |\n",c_bl[i],c_tr[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#else
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#endif
+
+  printf("\n");
+}
+
+/* 
+ * PrintFinalStats: Print final run data contained in iopt.              
+ */
+
+static void PrintFinalStats(void *mem)
+{ 
+  long int nst, nre, sli, netf, nps, npevals, nrevalsLS;
+  int flag;
+
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDASpilsGetNumLinIters(mem, &sli);
+  check_flag(&flag, "IDAGetNumNonlinSolvIters", 1);
+  flag = IDAGetNumResEvals(mem, &nre);
+  check_flag(&flag, "IDAGetNumResEvals", 1);
+  flag = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&flag, "IDAGetNumErrTestFails", 1);
+  flag = IDASpilsGetNumPrecSolves(mem, &nps);
+  check_flag(&flag, "IDAGetNumNonlinSolvConvFails", 1);
+  flag = IDASpilsGetNumPrecEvals(mem, &npevals);
+  check_flag(&flag, "IDADlsGetNumJacEvals", 1);
+  flag = IDASpilsGetNumResEvals(mem, &nrevalsLS);
+  check_flag(&flag, "IDADlsGetNumResEvals", 1);
+
+  printf("-----------------------------------------------------------\n");
+  printf("Final run statistics: \n\n");
+  printf("Number of steps                       = %ld\n", nst);
+  printf("Number of residual evaluations        = %ld\n", nre);
+  printf("Number of Preconditioner evaluations  = %ld\n", npevals);
+  printf("Number of linear iterations           = %ld\n", sli);
+  printf("Number of error test failures         = %ld\n", netf);
+  printf("Number of precond solve fun called    = %ld\n", nps);
+
+}
+
+/* 
+ * Fweb: Rate function for the food-web problem.                        
+ * This routine computes the right-hand sides of the system equations,   
+ * consisting of the diffusion term and interaction term.                
+ * The interaction term is computed by the function WebRates.            
+ */
+
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate,  
+                 UserData webdata)
+{ 
+  long int jx, jy, is, idyu, idyl, idxu, idxl;
+  realtype xx, yy, *cxy, *ratesxy, *cratexy, dcyli, dcyui, dcxli, dcxui;
+  
+  /* Loop over grid points, evaluate interaction vector (length ns),
+     form diffusion difference terms, and load crate.                    */
+  
+  for (jy = 0; jy < MY; jy++) {
+    yy = (webdata->dy) * jy ;
+    idyu = (jy!=MY-1) ? NSMX : -NSMX;
+    idyl = (jy!= 0  ) ? NSMX : -NSMX;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = (webdata->dx) * jx;
+      idxu = (jx!= MX-1) ?  NUM_SPECIES : -NUM_SPECIES;
+      idxl = (jx!=  0  ) ?  NUM_SPECIES : -NUM_SPECIES;
+      cxy = IJ_Vptr(cc,jx,jy);
+      ratesxy = IJ_Vptr(webdata->rates,jx,jy);
+      cratexy = IJ_Vptr(crate,jx,jy);
+      
+      /* Get interaction vector at this grid point. */
+      WebRates(xx, yy, cxy, ratesxy, webdata);
+      
+      /* Loop over species, do differencing, load crate segment. */
+      for (is = 0; is < NUM_SPECIES; is++) {
+        
+        /* Differencing in y. */
+        dcyli = *(cxy+is) - *(cxy - idyl + is) ;
+        dcyui = *(cxy + idyu + is) - *(cxy+is);
+        
+        /* Differencing in x. */
+        dcxli = *(cxy+is) - *(cxy - idxl + is);
+        dcxui = *(cxy + idxu +is) - *(cxy+is);
+        
+        /* Compute the crate values at (xx,yy). */
+        cratexy[is] = coy[is] * (dcyui - dcyli) +
+          cox[is] * (dcxui - dcxli) + ratesxy[is];
+        
+      } /* End is loop */
+    } /* End of jx loop */
+  } /* End of jy loop */
+  
+}
+
+/* 
+ * WebRates: Evaluate reaction rates at a given spatial point.
+ * At a given (x,y), evaluate the array of ns reaction terms R.
+ */
+
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy,
+                     UserData webdata)
+{
+  int is;
+  realtype fac;
+  
+  for (is = 0; is < NUM_SPECIES; is++)
+    ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]);
+  
+  fac = ONE + ALPHA*xx*yy + BETA*sin(FOURPI*xx)*sin(FOURPI*yy);
+  
+  for (is = 0; is < NUM_SPECIES; is++)  
+    ratesxy[is] = cxy[is]*( bcoef[is]*fac + ratesxy[is] );
+  
+}
+
+/*
+ * dotprod: dot product routine for realtype arrays, for use by WebRates.    
+ */
+
+static realtype dotprod(long int size, realtype *x1, realtype *x2)
+{
+  long int i;
+  realtype *xx1, *xx2, temp = ZERO;
+  
+  xx1 = x1; xx2 = x2;
+  for (i = 0; i < size; i++) temp += (*xx1++) * (*xx2++);
+  return(temp);
+  
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  if (opt == 0 && flagvalue == NULL) {
+    /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1); 
+  }
+
+  return(0);
+}
diff --git a/examples/ida/serial/idaFoodWeb_kry.out b/examples/ida/serial/idaFoodWeb_kry.out
new file mode 100644
index 0000000..09763cd
--- /dev/null
+++ b/examples/ida/serial/idaFoodWeb_kry.out
@@ -0,0 +1,42 @@
+
+idaFoodWeb_kry: Predator-prey DAE serial example problem for IDA 
+
+Number of species ns: 2     Mesh dimensions: 20 x 20     System size: 800
+Tolerance parameters:  rtol = 1e-05   atol = 1e-05
+Linear solver: IDASpgmr,  Spgmr parameters maxl = 16
+CalcIC called to correct initial predator concentrations.
+
+-----------------------------------------------------------
+  t        bottom-left  top-right    | nst  k      h
+-----------------------------------------------------------
+
+0.00e+00   1.0000e+01   1.0000e+01   |   0  0   1.6310e-08
+           1.0000e+05   1.0000e+05   |
+
+1.00e-03   1.0318e+01   1.0827e+01   |  33  4   9.7404e-05
+           1.0319e+05   1.0822e+05   |
+
+1.00e-02   1.6189e+02   1.9735e+02   |  86  4   1.7533e-04
+           1.6189e+06   1.9735e+06   |
+
+1.00e-01   2.4019e+02   2.7072e+02   | 167  1   4.4884e-02
+           2.4019e+06   2.7072e+06   |
+
+4.00e-01   2.4019e+02   2.7072e+02   | 169  1   1.7954e-01
+           2.4019e+06   2.7072e+06   |
+
+7.00e-01   2.4019e+02   2.7072e+02   | 170  1   3.5907e-01
+           2.4019e+06   2.7072e+06   |
+
+1.00e+00   2.4019e+02   2.7072e+02   | 171  1   7.1814e-01
+           2.4019e+06   2.7072e+06   |
+
+-----------------------------------------------------------
+Final run statistics: 
+
+Number of steps                       = 171
+Number of residual evaluations        = 212
+Number of Preconditioner evaluations  = 26
+Number of linear iterations           = 998
+Number of error test failures         = 0
+Number of precond solve fun called    = 1210
diff --git a/examples/ida/serial/idaHeat2D_bnd.c b/examples/ida/serial/idaHeat2D_bnd.c
index 7167d73..3828d2f 100644
--- a/examples/ida/serial/idaHeat2D_bnd.c
+++ b/examples/ida/serial/idaHeat2D_bnd.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:25:59 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -69,7 +69,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector u);
 static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up, 
                              N_Vector id, N_Vector res);
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -207,7 +207,7 @@ int heatres(realtype tres, N_Vector uu, N_Vector up, N_Vector resval,
   realtype *uv, *upv, *resv, coeff;
   UserData data;
   
-  uv = NV_DATA_S(uu); upv = NV_DATA_S(up); resv = NV_DATA_S(resval);
+  uv = N_VGetArrayPointer_Serial(uu); upv = N_VGetArrayPointer_Serial(up); resv = N_VGetArrayPointer_Serial(resval);
 
   data = (UserData)user_data;
   mm = data->mm;
@@ -249,9 +249,9 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
   mm = data->mm;
   mm1 = mm - 1;
   
-  udata = NV_DATA_S(uu);
-  updata = NV_DATA_S(up);
-  iddata = NV_DATA_S(id);
+  udata = N_VGetArrayPointer_Serial(uu);
+  updata = N_VGetArrayPointer_Serial(up);
+  iddata = N_VGetArrayPointer_Serial(id);
 
   /* Initialize id to 1's. */
   N_VConst(ONE, id);
@@ -305,7 +305,7 @@ static void PrintHeader(realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -315,7 +315,7 @@ static void PrintHeader(realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("IDACalcIC called with input boundary values = %Lg \n",BVAL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("IDACalcIC called with input boundary values = %lg \n",BVAL);
+  printf("IDACalcIC called with input boundary values = %g \n",BVAL);
 #else
   printf("IDACalcIC called with input boundary values = %g \n",BVAL);
 #endif
@@ -357,7 +357,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
   printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le \n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le \n",
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e \n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused);
 #else
   printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e \n",
@@ -376,7 +376,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/ida/serial/idaHeat2D_klu.c b/examples/ida/serial/idaHeat2D_klu.c
new file mode 100644
index 0000000..b63468b
--- /dev/null
+++ b/examples/ida/serial/idaHeat2D_klu.c
@@ -0,0 +1,747 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4853 $
+ * $Date: 2016-08-03 16:27:46 -0700 (Wed, 03 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Chris Nguyen @ LLNL
+ * -----------------------------------------------------------------
+ * Example problem for IDA: 2D heat equation, serial, sparse. 
+ * Based on idaHeat2D_bnd.c and idaRoberts_klu.c
+ *
+ * This example solves a discretized 2D heat equation problem.
+ * This version uses the band solver IDABand, and IDACalcIC.
+ *
+ * The DAE system solved is a spatial discretization of the PDE
+ *          du/dt = d^2u/dx^2 + d^2u/dy^2
+ * on the unit square. The boundary condition is u = 0 on all edges.
+ * Initial conditions are given by u = 16 x (1 - x) y (1 - y).
+ * The PDE is treated with central differences on a uniform MGRID x MGRID
+ * grid. The values of u at the interior points satisfy ODEs, and
+ * equations u = 0 at the boundaries are appended, to form a DAE
+ * system of size N = MGRID^2. Here MGRID = 10.
+ *
+ * The system is solved with IDA using the banded linear system
+ * solver and default difference-quotient Jacobian. 
+ * For purposes of illustration,
+ * IDACalcIC is called to compute correct values at the boundary,
+ * given incorrect values as input initial guesses. The constraints
+ * u >= 0 are posed for all components. Output is taken at
+ * t = 0, .01, .02, .04, ..., 10.24. (Output at t = 0 is for
+ * IDACalcIC cost statistics only.)
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <ida/ida.h>
+#include <ida/ida_klu.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_types.h>
+
+/* Problem Constants */
+#define NOUT  11
+#define MGRID 10
+#define NEQ   MGRID*MGRID
+#define ZERO  RCONST(0.0)
+#define ONE   RCONST(1.0)
+#define TWO   RCONST(2.0)
+#define BVAL  RCONST(0.0)
+#define TOTAL 4*MGRID+8*(MGRID-2)+(MGRID-4)*(MGRID+4*(MGRID-2)) /* total num of nonzero elements */
+
+/* Type: UserData */
+
+typedef struct {
+  long int mm;
+  realtype dx;
+  realtype coeff;
+} *UserData;
+
+/* Prototypes of functions called by IDA */
+
+int heatres(realtype tres, N_Vector uu, N_Vector up, 
+	    N_Vector resval, void *user_data);
+
+int jacHeat(realtype tt,  realtype cj, 
+	    N_Vector yy, N_Vector yp, N_Vector resvec,
+	    SlsMat JacMat, void *user_data,
+	    N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
+
+/* Exact same setup as jacHeat. Function needed for special case MGRID=3  */
+int jacHeat3(realtype tt,  realtype cj, 
+	    N_Vector yy, N_Vector yp, N_Vector resvec,
+	    SlsMat JacMat, void *user_data,
+	    N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
+
+/* Prototypes of private functions */
+
+static void PrintHeader(realtype rtol, realtype atol);
+static void PrintOutput(void *mem, realtype t, N_Vector u);
+static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up, 
+                             N_Vector id, N_Vector res);
+
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(void)
+{
+  void *mem;
+  UserData data;
+  N_Vector uu, up, constraints, id, res;  /* uu is u, up is du/dt */
+  int ier, iout;
+  long int netf, ncfn;
+  realtype rtol, atol, t0, t1, tout, tret;
+
+  int nnz; /* number of non-zeroes  */
+  
+  mem = NULL;
+  data = NULL;
+  uu = up = constraints = id = res = NULL;
+
+  /* Create vectors uu, up, res, constraints, id. */
+  uu = N_VNew_Serial(NEQ);
+  if(check_flag((void *)uu, "N_VNew_Serial", 0)) return(1);
+  up = N_VNew_Serial(NEQ);
+  if(check_flag((void *)up, "N_VNew_Serial", 0)) return(1);
+  res = N_VNew_Serial(NEQ);
+  if(check_flag((void *)res, "N_VNew_Serial", 0)) return(1);
+  constraints = N_VNew_Serial(NEQ);
+  if(check_flag((void *)constraints, "N_VNew_Serial", 0)) return(1);
+  id = N_VNew_Serial(NEQ); /* differentiate between algebraic and differential */
+  if(check_flag((void *)id, "N_VNew_Serial", 0)) return(1);
+
+  /* Create and load problem data block. */
+  data = (UserData) malloc(sizeof *data);
+  if(check_flag((void *)data, "malloc", 2)) return(1);
+  data->mm = MGRID;
+  data->dx = ONE/(MGRID - ONE);
+  data->coeff = ONE/( (data->dx) * (data->dx) );
+
+  /* Initialize uu, up, id. */
+  SetInitialProfile(data, uu, up, id, res);
+
+  /* Set constraints to all 1's for nonnegative solution values. */
+  N_VConst(ONE, constraints);
+
+  /* Set remaining input parameters. */
+  t0   = ZERO;
+  t1   = RCONST(0.01);
+  rtol = ZERO;
+  atol = RCONST(1.0e-8);
+
+  /* Call IDACreate and IDAMalloc to initialize solution */
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+
+  ier = IDASetUserData(mem, data);
+  if(check_flag(&ier, "IDASetUserData", 1)) return(1);
+
+  /* Sets up which components are algebraic or differential */
+  ier = IDASetId(mem, id); 
+  if(check_flag(&ier, "IDASetId", 1)) return(1);
+
+  ier = IDASetConstraints(mem, constraints);
+  if(check_flag(&ier, "IDASetConstraints", 1)) return(1);
+  N_VDestroy_Serial(constraints);
+
+  ier = IDAInit(mem, heatres, t0, uu, up);
+  if(check_flag(&ier, "IDAInit", 1)) return(1);
+
+  ier = IDASStolerances(mem, rtol, atol);
+  if(check_flag(&ier, "IDASStolerances", 1)) return(1);
+
+  /* Call IDAKLU and set up the linear solver  */
+  nnz = NEQ*NEQ;
+  ier = IDAKLU(mem, NEQ, nnz, CSC_MAT);
+  if(check_flag(&ier, "IDAKLU", 1)) return(1);
+  /* check size of Jacobian matrix  */
+  if(MGRID >= 4){
+    ier = IDASlsSetSparseJacFn(mem, jacHeat);
+  }
+  /* special case MGRID=3  */
+  else if(MGRID==3){
+    ier = IDASlsSetSparseJacFn(mem, jacHeat3);
+  }
+  /* MGRID<=2 is pure boundary points, nothing to solve  */
+  else{
+    printf("MGRID size is too small to run.\n");
+    return(1);
+  }
+  if(check_flag(&ier, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  /* Call IDACalcIC to correct the initial values. */
+  ier = IDACalcIC(mem, IDA_YA_YDP_INIT, t1);
+  if(check_flag(&ier, "IDACalcIC", 1)) return(1);
+
+  /* Print output heading. */
+  PrintHeader(rtol, atol);
+  
+  PrintOutput(mem, t0, uu);
+
+
+  /* Loop over output times, call IDASolve, and print results. */
+  
+  for (tout = t1, iout = 1; iout <= NOUT; iout++, tout *= TWO) {
+    
+    ier = IDASolve(mem, tout, &tret, uu, up, IDA_NORMAL);
+    if(check_flag(&ier, "IDASolve", 1)) return(1);
+
+    PrintOutput(mem, tret, uu);
+  
+  }
+  
+  /* Print remaining counters and free memory. */
+  ier = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&ier, "IDAGetNumErrTestFails", 1);
+  ier = IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  check_flag(&ier, "IDAGetNumNonlinSolvConvFails", 1);
+  printf("\n netf = %ld,   ncfn = %ld \n", netf, ncfn);
+
+  IDAFree(&mem);
+  N_VDestroy_Serial(uu);
+  N_VDestroy_Serial(up);
+  N_VDestroy_Serial(id);
+  N_VDestroy_Serial(res);
+  free(data);
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDA
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * heatres: heat equation system residual function                       
+ * This uses 5-point central differencing on the interior points, and    
+ * includes algebraic equations for the boundary values.                 
+ * So for each interior point, the residual component has the form       
+ *    res_i = u'_i - (central difference)_i                              
+ * while for each boundary point, it is res_i = u_i.                     
+ */
+
+int heatres(realtype tres, N_Vector uu, N_Vector up, N_Vector resval, 
+            void *user_data)
+{
+  long int mm, i, j, offset, loc;
+  realtype *uv, *upv, *resv, coeff;
+  UserData data;
+  
+  uv = N_VGetArrayPointer_Serial(uu); upv = N_VGetArrayPointer_Serial(up); resv = N_VGetArrayPointer_Serial(resval);
+
+  data = (UserData)user_data;
+  mm = data->mm;
+  coeff = data->coeff;
+  
+  /* Initialize resval to uu, to take care of boundary equations. */
+  N_VScale(ZERO, uu, resval);
+  
+  /* Loop over interior points; set res = up - (central difference). */
+  for (j = 1; j < mm-1; j++) {
+    offset = mm*j;
+    for (i = 1; i < mm-1; i++) {
+      loc = offset + i;
+      resv[loc] = upv[loc] - coeff * 
+	  (uv[loc-1] + uv[loc+1] + uv[loc-mm] + uv[loc+mm] - RCONST(4.0)*uv[loc]);
+    }
+  }
+  
+  return(0);
+
+}
+
+/* Jacobian matrix setup for MGRID=3  */
+int jacHeat3(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec,
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
+{
+  realtype dx =  ONE/(MGRID - ONE);
+  realtype beta = RCONST(4.0)/(dx*dx) + cj;
+  
+  int *colptrs   = (*JacMat->colptrs);
+  int *rowvals   = (*JacMat->rowvals);
+  realtype *data = JacMat->data;
+
+  SparseSetMatToZero(JacMat); /* initialize Jacobian matrix */
+
+  /*
+   * set up number of elements in each column 
+   */
+  colptrs[0]  = 0;
+  colptrs[1]  = 1;
+  colptrs[2]  = 3;
+  colptrs[3]  = 4;
+  colptrs[4]  = 6;
+  colptrs[5]  = 7;
+  colptrs[6]  = 9;
+  colptrs[7]  = 10;
+  colptrs[8]  = 12;
+  colptrs[9]  = 13;
+  
+  /*
+   * set up data and row values stored 
+   */
+
+  data[0] = ONE;
+  rowvals[0] = 0;  
+  data[1] = ONE;
+  rowvals[1] = 1;
+  data[2] = -ONE/(dx*dx);
+  rowvals[2] = 4;  
+  data[3] = ONE;
+  rowvals[3] = 2;
+  data[4] = ONE;
+  rowvals[4] = 3;
+  data[5] = -ONE/(dx*dx);
+  rowvals[5] = 4;  
+  data[6] = beta;
+  rowvals[6] = 4;
+  data[7] = -ONE/(dx*dx);
+  rowvals[7] = 4;
+  data[8] = ONE;
+  rowvals[8] = 5;
+  data[9] = ONE;
+  rowvals[9] = 6; 
+  data[10] = -ONE/(dx*dx);
+  rowvals[10] = 4;
+  data[11] = ONE;
+  rowvals[11] = 7;
+  data[12] = ONE;
+  rowvals[12] = 8;
+
+  return(0);
+}
+
+/* Jacobian matrix setup for MGRID>=4  */
+int jacHeat(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec,
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
+{
+  realtype *yval;
+  realtype dx =  ONE/(MGRID - ONE);
+  realtype beta = RCONST(4.0)/(dx*dx) + cj;
+  int i,j, repeat=0;
+
+  int *colptrs   = (*JacMat->colptrs);
+  int *rowvals   = (*JacMat->rowvals);
+  realtype *data = JacMat->data;
+
+  yval = N_VGetArrayPointer_Serial(yy);
+
+  SparseSetMatToZero(JacMat); /* initialize Jacobian matrix  */
+
+  /* 
+   *-----------------------------------------------
+   * set up number of elements in each column 
+   *-----------------------------------------------
+   */
+  
+  /**** first column block ****/
+  colptrs[0] = 0;
+  colptrs[1] = 1;
+  /* count by twos in the middle  */
+  for(i=2;i<MGRID;i++) colptrs[i] = (colptrs[i-1])+2;
+  colptrs[MGRID] = 2*MGRID-2;
+
+  /**** second column block ****/
+  colptrs[MGRID+1] = 2*MGRID;
+  colptrs[MGRID+2] = 2*MGRID+3;
+  /* count by fours in the middle */
+  for(i=0;i<MGRID-4;i++) colptrs[MGRID+3+i] = (colptrs[MGRID+3+i-1])+4;
+  colptrs[2*MGRID-1] = 2*MGRID+4*(MGRID-2)-2;
+  colptrs[2*MGRID] = 2*MGRID+4*(MGRID-2);
+  
+  /**** repeated (MGRID-4 times) middle column blocks ****/
+  for(i=0;i<MGRID-4;i++){
+    colptrs[2*MGRID+1+repeat]   = (colptrs[2*MGRID+1+repeat-1])+2;
+    colptrs[2*MGRID+1+repeat+1] = (colptrs[2*MGRID+1+repeat])+4;
+    
+    /* count by fives in the middle */
+    for(j=0;j<MGRID-4;j++) colptrs[2*MGRID+1+repeat+2+j] = 
+			  (colptrs[2*MGRID+1+repeat+1+j])+5;
+   
+    colptrs[2*MGRID+1+repeat+(MGRID-4)+2] = (colptrs[2*MGRID+1+repeat+(MGRID-4)+1])+4;
+    colptrs[2*MGRID+1+repeat+(MGRID-4)+3] = (colptrs[2*MGRID+1+repeat+(MGRID-4)+2])+2;  
+
+    repeat+=MGRID; /* shift that accounts for accumulated number of columns */
+  }
+  
+  /**** last-1 column block ****/
+  colptrs[MGRID*MGRID-2*MGRID+1] = TOTAL-2*MGRID-4*(MGRID-2)+2;
+  colptrs[MGRID*MGRID-2*MGRID+2] = TOTAL-2*MGRID-4*(MGRID-2)+5;
+  /* count by fours in the middle */
+  for(i=0;i<MGRID-4;i++) colptrs[MGRID*MGRID-2*MGRID+3+i] = 
+			(colptrs[MGRID*MGRID-2*MGRID+3+i-1])+4;
+  colptrs[MGRID*MGRID-MGRID-1] = TOTAL-2*MGRID;
+  colptrs[MGRID*MGRID-MGRID]   = TOTAL-2*MGRID+2;
+
+  /**** last column block ****/
+  colptrs[MGRID*MGRID-MGRID+1] = TOTAL-MGRID-(MGRID-2)+1;
+  /* count by twos in the middle */
+  for(i=0;i<MGRID-2;i++) colptrs[MGRID*MGRID-MGRID+2+i] = 
+			(colptrs[MGRID*MGRID-MGRID+2+i-1])+2;
+  colptrs[MGRID*MGRID-1] = TOTAL-1;
+  colptrs[MGRID*MGRID]   = TOTAL;
+  
+
+  /*
+   *-----------------------------------------------
+   * set up data stored
+   *-----------------------------------------------
+   */
+
+  /**** first column block ****/
+  data[0] = ONE;
+  /* alternating pattern in data, separate loop for each pattern  */
+  for(i=1;i<MGRID+(MGRID-2)  ;i+=2) data[i] = ONE;
+  for(i=2;i<MGRID+(MGRID-2)-1;i+=2) data[i] = -ONE/(dx*dx);
+
+  /**** second column block ****/
+  data[MGRID+MGRID-2] = ONE;
+  data[MGRID+MGRID-1] = -ONE/(dx*dx);
+  data[MGRID+MGRID]   = beta;
+  data[MGRID+MGRID+1] = -ONE/(dx*dx);
+  data[MGRID+MGRID+2] = -ONE/(dx*dx);
+  /* middle data elements */
+  for(i=0;i<(MGRID-4);i++) data[MGRID+MGRID+3+4*i] = -ONE/(dx*dx);
+  for(i=0;i<(MGRID-4);i++) data[MGRID+MGRID+4+4*i] = beta;
+  for(i=0;i<(MGRID-4);i++) data[MGRID+MGRID+5+4*i] = -ONE/(dx*dx);
+  for(i=0;i<(MGRID-4);i++) data[MGRID+MGRID+6+4*i] = -ONE/(dx*dx);
+  data[2*MGRID+4*(MGRID-2)-5] = -ONE/(dx*dx);
+  data[2*MGRID+4*(MGRID-2)-4] = beta;
+  data[2*MGRID+4*(MGRID-2)-3] = -ONE/(dx*dx);
+  data[2*MGRID+4*(MGRID-2)-2] = -ONE/(dx*dx);
+  data[2*MGRID+4*(MGRID-2)-1] = ONE;
+    
+  /**** repeated (MGRID-4 times) middle column blocks ****/
+  repeat=0;
+  for(i=0;i<MGRID-4;i++){
+    data[2*MGRID+4*(MGRID-2)+repeat]   = ONE;
+    data[2*MGRID+4*(MGRID-2)+repeat+1] = -ONE/(dx*dx);
+    
+    data[2*MGRID+4*(MGRID-2)+repeat+2] = -ONE/(dx*dx);
+    data[2*MGRID+4*(MGRID-2)+repeat+3] = beta;
+    data[2*MGRID+4*(MGRID-2)+repeat+4] = -ONE/(dx*dx);
+    data[2*MGRID+4*(MGRID-2)+repeat+5] = -ONE/(dx*dx);
+
+    /* 5 in 5*j chosen since there are 5 elements in each column */
+    /* this column loops MGRID-4 times within the outer loop */
+    for(j=0;j<MGRID-4;j++){
+      data[2*MGRID+4*(MGRID-2)+repeat+6+5*j]  = -ONE/(dx*dx);
+      data[2*MGRID+4*(MGRID-2)+repeat+7+5*j]  = -ONE/(dx*dx);
+      data[2*MGRID+4*(MGRID-2)+repeat+8+5*j]  = beta;
+      data[2*MGRID+4*(MGRID-2)+repeat+9+5*j]  = -ONE/(dx*dx);
+      data[2*MGRID+4*(MGRID-2)+repeat+10+5*j] = -ONE/(dx*dx);
+    }
+    
+    data[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+6] = -ONE/(dx*dx);
+    data[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+7] = -ONE/(dx*dx);
+    data[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+8] = beta;
+    data[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+9] = -ONE/(dx*dx);
+    
+    data[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+10] = -ONE/(dx*dx);
+    data[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+11] = ONE;
+    
+    repeat+=MGRID+4*(MGRID-2); /* shift that accounts for accumulated columns and elements */
+  }
+  
+  /**** last-1 column block ****/
+  data[TOTAL-6*(MGRID-2)-4] = ONE;
+  data[TOTAL-6*(MGRID-2)-3] = -ONE/(dx*dx);
+  data[TOTAL-6*(MGRID-2)-2] = -ONE/(dx*dx);
+  data[TOTAL-6*(MGRID-2)-1] = beta;
+  data[TOTAL-6*(MGRID-2)  ] = -ONE/(dx*dx);
+  /* middle data elements */
+  for(i=0;i<(MGRID-4);i++) data[TOTAL-6*(MGRID-2)+1+4*i] = -ONE/(dx*dx);
+  for(i=0;i<(MGRID-4);i++) data[TOTAL-6*(MGRID-2)+2+4*i] = -ONE/(dx*dx);
+  for(i=0;i<(MGRID-4);i++) data[TOTAL-6*(MGRID-2)+3+4*i] = beta;
+  for(i=0;i<(MGRID-4);i++) data[TOTAL-6*(MGRID-2)+4+4*i] = -ONE/(dx*dx);
+  data[TOTAL-2*(MGRID-2)-7] = -ONE/(dx*dx);
+  data[TOTAL-2*(MGRID-2)-6] = -ONE/(dx*dx);
+  data[TOTAL-2*(MGRID-2)-5] = beta;
+  data[TOTAL-2*(MGRID-2)-4] = -ONE/(dx*dx);
+  data[TOTAL-2*(MGRID-2)-3] = ONE;
+
+  /**** last column block ****/
+  data[TOTAL-2*(MGRID-2)-2] = ONE;
+  /* alternating pattern in data, separate loop for each pattern  */
+  for(i=TOTAL-2*(MGRID-2)-1;i<TOTAL-2;i+=2) data[i] = -ONE/(dx*dx);
+  for(i=TOTAL-2*(MGRID-2)  ;i<TOTAL-1;i+=2) data[i] = ONE;
+  data[TOTAL-1] = ONE;
+  
+  /*
+   *-----------------------------------------------
+   * row values 
+   *-----------------------------------------------
+   */
+
+  /**** first block ****/
+  rowvals[0] = 0;
+  /* alternating pattern in data, separate loop for each pattern */
+  for(i=1;i<MGRID+(MGRID-2)  ;i+=2) rowvals[i] = (i+1)/2;
+  for(i=2;i<MGRID+(MGRID-2)-1;i+=2) rowvals[i] = i/2+MGRID; /* i+1 unnecessary here */
+  
+  /**** second column block ****/
+  rowvals[MGRID+MGRID-2] = MGRID;
+  rowvals[MGRID+MGRID-1] = MGRID+1;
+  rowvals[MGRID+MGRID]   = MGRID+1;
+  rowvals[MGRID+MGRID+1] = MGRID+2;
+  rowvals[MGRID+MGRID+2] = 2*MGRID+1;
+  /* middle row values */
+  for(i=0;i<(MGRID-4);i++) rowvals[MGRID+MGRID+3+4*i] = MGRID+1+i;
+  for(i=0;i<(MGRID-4);i++) rowvals[MGRID+MGRID+4+4*i] = MGRID+2+i;
+  for(i=0;i<(MGRID-4);i++) rowvals[MGRID+MGRID+5+4*i] = MGRID+3+i;
+  for(i=0;i<(MGRID-4);i++) rowvals[MGRID+MGRID+6+4*i] = 2*MGRID+2+i;
+  rowvals[2*MGRID+4*(MGRID-2)-5] = MGRID+(MGRID-2)-1;
+  rowvals[2*MGRID+4*(MGRID-2)-4] = MGRID+(MGRID-2); /* starting from here, add two diag patterns */
+  rowvals[2*MGRID+4*(MGRID-2)-3] = 2*MGRID+(MGRID-2);
+  rowvals[2*MGRID+4*(MGRID-2)-2] = MGRID+(MGRID-2);
+  rowvals[2*MGRID+4*(MGRID-2)-1] = MGRID+(MGRID-2)+1;
+  
+  /**** repeated (MGRID-4 times) middle column blocks ****/
+  repeat=0;
+  for(i=0;i<MGRID-4;i++){
+    rowvals[2*MGRID+4*(MGRID-2)+repeat]   = MGRID+(MGRID-2)+2+MGRID*i;
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+1] = MGRID+(MGRID-2)+2+MGRID*i+1;
+    
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+2] = MGRID+(MGRID-2)+2+MGRID*i+1-MGRID;
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+3] = MGRID+(MGRID-2)+2+MGRID*i+1;
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+4] = MGRID+(MGRID-2)+2+MGRID*i+2; /* *this */
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+5] = MGRID+(MGRID-2)+2+MGRID*i+1+MGRID;
+    
+    /* 5 in 5*j chosen since there are 5 elements in each column */
+    /* column repeats MGRID-4 times within the outer loop */
+    for(j=0;j<MGRID-4;j++){
+      rowvals[2*MGRID+4*(MGRID-2)+repeat+6+5*j]  = MGRID+(MGRID-2)+2+MGRID*i+1-MGRID+1+j;
+      rowvals[2*MGRID+4*(MGRID-2)+repeat+7+5*j]  = MGRID+(MGRID-2)+2+MGRID*i+1+j;
+      rowvals[2*MGRID+4*(MGRID-2)+repeat+8+5*j]  = MGRID+(MGRID-2)+2+MGRID*i+2+j;
+      rowvals[2*MGRID+4*(MGRID-2)+repeat+9+5*j]  = MGRID+(MGRID-2)+2+MGRID*i+2+1+j;
+      rowvals[2*MGRID+4*(MGRID-2)+repeat+10+5*j] = MGRID+(MGRID-2)+2+MGRID*i+1+MGRID+1+j;
+    }
+    
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+6] = MGRID+(MGRID-2)+2+MGRID*i-2;
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+7] = MGRID+(MGRID-2)+2+MGRID*i-2+MGRID-1;
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+8] = MGRID+(MGRID-2)+2+MGRID*i-2+MGRID; /* *this+MGRID */
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+9] = MGRID+(MGRID-2)+2+MGRID*i-2+2*MGRID;
+
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+10] = MGRID+(MGRID-2)+2+MGRID*i-2+MGRID;
+    rowvals[2*MGRID+4*(MGRID-2)+repeat+(MGRID-4)*5+11] = MGRID+(MGRID-2)+2+MGRID*i-2+MGRID+1;
+    
+    repeat+=MGRID+4*(MGRID-2); /* shift that accounts for accumulated columns and elements */
+  }  
+
+  
+  /**** last-1 column block ****/
+  rowvals[TOTAL-6*(MGRID-2)-4] = MGRID*MGRID-1-2*(MGRID-1)-1;
+  rowvals[TOTAL-6*(MGRID-2)-3] = MGRID*MGRID-1-2*(MGRID-1); /* starting with this as base */
+  rowvals[TOTAL-6*(MGRID-2)-2] = MGRID*MGRID-1-2*(MGRID-1)-MGRID;
+  rowvals[TOTAL-6*(MGRID-2)-1] = MGRID*MGRID-1-2*(MGRID-1);
+  rowvals[TOTAL-6*(MGRID-2)  ] = MGRID*MGRID-1-2*(MGRID-1)+1;
+  /* middle row values */
+  for(i=0;i<(MGRID-4);i++) rowvals[TOTAL-6*(MGRID-2)+1+4*i] = MGRID*MGRID-1-2*(MGRID-1)-MGRID+1+i;
+  for(i=0;i<(MGRID-4);i++) rowvals[TOTAL-6*(MGRID-2)+2+4*i] = MGRID*MGRID-1-2*(MGRID-1)+i;
+  for(i=0;i<(MGRID-4);i++) rowvals[TOTAL-6*(MGRID-2)+3+4*i] = MGRID*MGRID-1-2*(MGRID-1)+1+i;/*copied above*/
+  for(i=0;i<(MGRID-4);i++) rowvals[TOTAL-6*(MGRID-2)+4+4*i] = MGRID*MGRID-1-2*(MGRID-1)+2+i;
+  rowvals[TOTAL-2*(MGRID-2)-7] = MGRID*MGRID-2*MGRID-2;
+  rowvals[TOTAL-2*(MGRID-2)-6] = MGRID*MGRID-MGRID-3;
+  rowvals[TOTAL-2*(MGRID-2)-5] = MGRID*MGRID-MGRID-2;
+  rowvals[TOTAL-2*(MGRID-2)-4] = MGRID*MGRID-MGRID-2;
+  rowvals[TOTAL-2*(MGRID-2)-3] = MGRID*MGRID-MGRID-1;
+
+  /* last column block */
+  rowvals[TOTAL-2*(MGRID-2)-2] = MGRID*MGRID-MGRID;
+  /* alternating pattern in data, separate loop for each pattern  */
+  for(i=0;i<(MGRID-2);i++) rowvals[TOTAL-2*(MGRID-2)-1+2*i] = MGRID*MGRID-2*MGRID+1+i;
+  for(i=0;i<(MGRID-2);i++) rowvals[TOTAL-2*(MGRID-2)  +2*i] = MGRID*MGRID-MGRID+1+i;  
+  rowvals[TOTAL-1] = MGRID*MGRID-1;
+
+  /*SparsePrintMat(JacMat);*/
+ 
+  return(0);
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * SetInitialProfile: routine to initialize u, up, and id vectors.       
+ */
+
+static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up, 
+                             N_Vector id, N_Vector res)
+{
+  realtype xfact, yfact, *udata, *updata, *iddata;
+  long int mm, mm1, i, j, offset, loc;
+  
+  mm = data->mm;
+  mm1 = mm - 1;
+  
+  udata = N_VGetArrayPointer_Serial(uu);
+  updata = N_VGetArrayPointer_Serial(up);
+  iddata = N_VGetArrayPointer_Serial(id);
+
+  /* Initialize id to 1's. */
+  N_VConst(ONE, id);
+
+  /* Initialize uu on all grid points. */ 
+  for (j = 0; j < mm; j++) {
+    yfact = data->dx * j;
+    offset = mm*j;
+    for (i = 0;i < mm; i++) {
+      xfact = data->dx * i;
+      loc = offset + i;
+      udata[loc] = RCONST(16.0) * xfact * (ONE - xfact) * yfact * (ONE - yfact);
+    }
+  }
+  
+  /* Initialize up vector to 0. */
+  N_VConst(ZERO, up);
+
+  /* heatres sets res to negative of ODE RHS values at interior points. */
+  heatres(ZERO, uu, up, res, data);
+  
+  /* Copy -res into up to get correct interior initial up values. */
+  N_VScale(-ONE, res, up);
+
+  /* Finally, set values of u, up, and id at boundary points. */
+  for (j = 0; j < mm; j++) {
+    offset = mm*j;
+    for (i = 0;i < mm; i++) {
+      loc = offset + i;
+      if (j == 0 || j == mm1 || i == 0 || i == mm1 ) {
+        udata[loc] = BVAL; updata[loc] = ZERO; iddata[loc] = ZERO; }
+    }
+  }
+  
+  return(0);
+
+}
+
+/* 
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(realtype rtol, realtype atol)
+{
+  printf("\nidaHeat2D_klu: Heat equation, serial example problem for IDA\n");
+  printf("          Discretized heat equation on 2D unit square.\n");
+  printf("          Zero boundary conditions,");
+  printf(" polynomial initial conditions.\n");
+  printf("          Mesh dimensions: %d x %d", MGRID, MGRID);
+  printf("        Total system size: %d\n\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#endif
+  printf("Constraints set to force all solution components >= 0. \n");
+  printf("Linear solver: IDAKLU, sparse direct solver \n");
+  printf("       difference quotient Jacobian\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("IDACalcIC called with input boundary values = %Lg \n",BVAL);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("IDACalcIC called with input boundary values = %g \n",BVAL);
+#else
+  printf("IDACalcIC called with input boundary values = %g \n",BVAL);
+#endif
+  /* Print output table heading and initial line of table. */
+  printf("\n   Output Summary (umax = max-norm of solution) \n\n");
+  printf("  time       umax     k  nst  nni  nje   nre     h       \n" );
+  printf(" .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . \n");
+}
+
+/*
+ * Print Output
+ */
+
+static void PrintOutput(void *mem, realtype t, N_Vector uu)
+{
+  int ier;
+  realtype umax, hused;
+  long int nst, nni, nje, nre;
+  int kused;
+
+  umax = N_VMaxNorm(uu);
+  
+  ier = IDAGetLastOrder(mem, &kused);
+  check_flag(&ier, "IDAGetLastOrder", 1);
+  ier = IDAGetNumSteps(mem, &nst);
+  check_flag(&ier, "IDAGetNumSteps", 1);
+  ier = IDAGetNumNonlinSolvIters(mem, &nni);
+  check_flag(&ier, "IDAGetNumNonlinSolvIters", 1);
+  ier = IDAGetNumResEvals(mem, &nre);
+  check_flag(&ier, "IDAGetNumResEvals", 1);
+  ier = IDAGetLastStep(mem, &hused);
+  check_flag(&ier, "IDAGetLastStep", 1);
+  ier = IDASlsGetNumJacEvals(mem, &nje);
+  check_flag(&ier, "IDASlsGetNumJacEvals", 1);
+
+ 
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %9.2Le \n",
+         t, umax, kused, nst, nni, nje, nre, hused);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %9.2e \n",
+         t, umax, kused, nst, nni, nje, nre, hused);
+#else
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %9.2e \n",
+         t, umax, kused, nst, nni, nje, nre, hused);
+#endif
+
+}
+
+/* 
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/ida/serial/idaHeat2D_klu.out b/examples/ida/serial/idaHeat2D_klu.out
new file mode 100644
index 0000000..ced958a
--- /dev/null
+++ b/examples/ida/serial/idaHeat2D_klu.out
@@ -0,0 +1,30 @@
+
+idaHeat2D_klu: Heat equation, serial example problem for IDA
+          Discretized heat equation on 2D unit square.
+          Zero boundary conditions, polynomial initial conditions.
+          Mesh dimensions: 10 x 10        Total system size: 100
+
+Tolerance parameters:  rtol = 0   atol = 1e-08
+Constraints set to force all solution components >= 0. 
+Linear solver: IDAKLU, sparse direct solver 
+       difference quotient Jacobian
+IDACalcIC called with input boundary values = 0 
+
+   Output Summary (umax = max-norm of solution) 
+
+  time       umax     k  nst  nni  nje   nre     h       
+ .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  . 
+  0.00   9.75461e-01  0    0    0    2     2   5.15e-10 
+  0.01   8.24056e-01  5   53   63   23    65   5.55e-04 
+  0.02   6.88097e-01  5   69   81   24    83   9.99e-04 
+  0.04   4.70961e-01  5   90  106   27   108   1.91e-03 
+  0.08   2.16312e-01  5  113  130   27   132   1.72e-03 
+  0.16   4.53210e-02  5  137  155   28   157   3.43e-03 
+  0.32   1.98864e-03  5  173  193   29   195   6.18e-03 
+  0.64   3.83238e-06  5  210  233   31   235   2.22e-02 
+  1.28   0.00000e+00  1  227  255   34   257   1.78e-01 
+  2.56   0.00000e+00  1  230  258   37   260   1.42e+00 
+  5.12   0.00000e+00  1  231  259   38   261   2.85e+00 
+ 10.24   0.00000e+00  1  232  260   39   262   5.69e+00 
+
+ netf = 2,   ncfn = 0 
diff --git a/examples/ida/serial/idaHeat2D_kry.c b/examples/ida/serial/idaHeat2D_kry.c
index 72cd9a2..2c765e7 100644
--- a/examples/ida/serial/idaHeat2D_kry.c
+++ b/examples/ida/serial/idaHeat2D_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:25:59 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -81,7 +81,7 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
                              N_Vector res);
 static void PrintHeader(realtype rtol, realtype atol);
 static void PrintOutput(void *mem, realtype t, N_Vector uu);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -293,9 +293,9 @@ int resHeat(realtype tt,
   realtype *uu_data, *up_data, *rr_data, coeff, dif1, dif2;
   UserData data;
   
-  uu_data = NV_DATA_S(uu); 
-  up_data = NV_DATA_S(up); 
-  rr_data = NV_DATA_S(rr);
+  uu_data = N_VGetArrayPointer_Serial(uu); 
+  up_data = N_VGetArrayPointer_Serial(up); 
+  rr_data = N_VGetArrayPointer_Serial(rr);
 
   data = (UserData) user_data;
   
@@ -347,7 +347,7 @@ int PsetupHeat(realtype tt,
   UserData data;
   
   data = (UserData) prec_data;
-  ppv = NV_DATA_S(data->pp);
+  ppv = N_VGetArrayPointer_Serial(data->pp);
   mm = data->mm;
 
   /* Initialize the entire vector to 1., then set the interior points to the
@@ -405,8 +405,8 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
 
   mm = data->mm;
 
-  udata = NV_DATA_S(uu);
-  updata = NV_DATA_S(up);
+  udata = N_VGetArrayPointer_Serial(uu);
+  updata = N_VGetArrayPointer_Serial(up);
 
   /* Initialize uu on all grid points. */ 
   mm1 = mm - 1;
@@ -456,7 +456,7 @@ static void PrintHeader(realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -501,7 +501,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
   printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le  %3ld %3ld\n",
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #else
   printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
@@ -519,7 +519,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/ida/serial/idaKrylovDemo_ls.c b/examples/ida/serial/idaKrylovDemo_ls.c
index 496b7f8..b967969 100644
--- a/examples/ida/serial/idaKrylovDemo_ls.c
+++ b/examples/ida/serial/idaKrylovDemo_ls.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:25:59 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -92,7 +92,7 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
                              N_Vector res);
 static void PrintHeader(realtype rtol, realtype atol, int linsolver);
 static void PrintOutput(void *mem, realtype t, N_Vector uu, int linsolver);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -310,9 +310,9 @@ int resHeat(realtype tt,
   realtype *uu_data, *up_data, *rr_data, coeff, dif1, dif2;
   UserData data;
   
-  uu_data = NV_DATA_S(uu); 
-  up_data = NV_DATA_S(up); 
-  rr_data = NV_DATA_S(rr);
+  uu_data = N_VGetArrayPointer_Serial(uu); 
+  up_data = N_VGetArrayPointer_Serial(up); 
+  rr_data = N_VGetArrayPointer_Serial(rr);
 
   data = (UserData) user_data;
   
@@ -364,7 +364,7 @@ int PsetupHeat(realtype tt,
   UserData data;
   
   data = (UserData) user_data;
-  ppv = NV_DATA_S(data->pp);
+  ppv = N_VGetArrayPointer_Serial(data->pp);
   mm = data->mm;
 
   /* Initialize the entire vector to 1., then set the interior points to the
@@ -422,8 +422,8 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
 
   mm = data->mm;
 
-  udata = NV_DATA_S(uu);
-  updata = NV_DATA_S(up);
+  udata = N_VGetArrayPointer_Serial(uu);
+  updata = N_VGetArrayPointer_Serial(up);
 
   /* Initialize uu on all grid points. */ 
   mm1 = mm - 1;
@@ -473,7 +473,7 @@ static void PrintHeader(realtype rtol, realtype atol, int linsolver)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -533,7 +533,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu, int linsolver)
   printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le  %3ld %3ld\n",
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #else
   printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
@@ -551,7 +551,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu, int linsolver)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/ida/serial/idaRoberts_dns.c b/examples/ida/serial/idaRoberts_dns.c
index 6cd1670..d657e5e 100644
--- a/examples/ida/serial/idaRoberts_dns.c
+++ b/examples/ida/serial/idaRoberts_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 23:02:23 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -41,8 +41,8 @@
 #define NEQ   3
 #define NOUT  12
 
-#define ZERO RCONST(0.0);
-#define ONE  RCONST(1.0);
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
 
 /* Macro to define dense matrix elements, indexed from 1. */
 
@@ -66,7 +66,7 @@ static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y);
 static void PrintOutput(void *mem, realtype t, N_Vector y);
 static void PrintRootInfo(int root_f1, int root_f2);
 static void PrintFinalStats(void *mem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -96,19 +96,19 @@ int main(void)
   if(check_flag((void *)avtol, "N_VNew_Serial", 0)) return(1);
 
   /* Create and initialize  y, y', and absolute tolerance vectors. */
-  yval  = NV_DATA_S(yy);
+  yval  = N_VGetArrayPointer_Serial(yy);
   yval[0] = ONE;
   yval[1] = ZERO;
   yval[2] = ZERO;
 
-  ypval = NV_DATA_S(yp);
+  ypval = N_VGetArrayPointer_Serial(yp);
   ypval[0]  = RCONST(-0.04);
   ypval[1]  = RCONST(0.04);
   ypval[2]  = ZERO;  
 
   rtol = RCONST(1.0e-4);
 
-  atval = NV_DATA_S(avtol);
+  atval = N_VGetArrayPointer_Serial(avtol);
   atval[0] = RCONST(1.0e-8);
   atval[1] = RCONST(1.0e-14);
   atval[2] = RCONST(1.0e-6);
@@ -193,9 +193,9 @@ int resrob(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data
 {
   realtype *yval, *ypval, *rval;
 
-  yval = NV_DATA_S(yy); 
-  ypval = NV_DATA_S(yp); 
-  rval = NV_DATA_S(rr);
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
 
   rval[0]  = RCONST(-0.04)*yval[0] + RCONST(1.0e4)*yval[1]*yval[2];
   rval[1]  = -rval[0] - RCONST(3.0e7)*yval[1]*yval[1] - ypval[1];
@@ -214,7 +214,7 @@ static int grob(realtype t, N_Vector yy, N_Vector yp, realtype *gout,
 {
   realtype *yval, y1, y3;
 
-  yval = NV_DATA_S(yy); 
+  yval = N_VGetArrayPointer_Serial(yy); 
   y1 = yval[0]; y3 = yval[2];
   gout[0] = y1 - RCONST(0.0001);
   gout[1] = y3 - RCONST(0.01);
@@ -233,7 +233,7 @@ int jacrob(long int Neq, realtype tt,  realtype cj,
 {
   realtype *yval;
   
-  yval = NV_DATA_S(yy);
+  yval = N_VGetArrayPointer_Serial(yy);
 
   IJth(JJ,1,1) = RCONST(-0.04) - cj;
   IJth(JJ,2,1) = RCONST(0.04);
@@ -262,8 +262,8 @@ static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
 {
   realtype *atval, *yval;
 
-  atval  = NV_DATA_S(avtol);
-  yval  = NV_DATA_S(y);
+  atval  = N_VGetArrayPointer_Serial(avtol);
+  yval  = N_VGetArrayPointer_Serial(y);
 
   printf("\nidaRoberts_dns: Robertson kinetics DAE serial example problem for IDA\n");
   printf("         Three equation chemical kinetics problem.\n\n");
@@ -274,9 +274,9 @@ static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
   printf("Initial conditions y0 = (%Lg %Lg %Lg)\n",
          yval[0], yval[1], yval[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg %lg %lg \n",
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
          rtol, atval[0],atval[1],atval[2]);
-  printf("Initial conditions y0 = (%lg %lg %lg)\n",
+  printf("Initial conditions y0 = (%g %g %g)\n",
          yval[0], yval[1], yval[2]);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
@@ -302,7 +302,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   long int nst;
   realtype hused;
 
-  yval  = NV_DATA_S(y);
+  yval  = N_VGetArrayPointer_Serial(y);
 
   retval = IDAGetLastOrder(mem, &kused);
   check_flag(&retval, "IDAGetLastOrder", 1);
@@ -314,7 +314,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld  %1d %12.4Le\n", 
          t, yval[0], yval[1], yval[2], nst, kused, hused);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%10.4le %12.4le %12.4le %12.4le | %3ld  %1d %12.4le\n", 
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
          t, yval[0], yval[1], yval[2], nst, kused, hused);
 #else
   printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
@@ -374,7 +374,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
   /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
diff --git a/examples/ida/serial/idaRoberts_klu.c b/examples/ida/serial/idaRoberts_klu.c
new file mode 100644
index 0000000..46c304c
--- /dev/null
+++ b/examples/ida/serial/idaRoberts_klu.c
@@ -0,0 +1,488 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL  (based on idaRoberts_dns.c)
+ * -----------------------------------------------------------------
+ * This simple example problem for IDA, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *      dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+ *         0   = y1 + y2 + y3 - 1
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.
+ *
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01.
+ *
+ * The problem is solved with IDA using IDAKLU for the linear
+ * solver, with a user-supplied Jacobian. Output is printed at
+ * t = .4, 4, 40, ..., 4e10.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ida/ida.h>
+#include <ida/ida_klu.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+#define NEQ   3
+#define NOUT  12
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* Prototypes of functions called by IDA */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, 
+           N_Vector resval, void *user_data);
+
+static int grob(realtype t, N_Vector yy, N_Vector yp,
+                realtype *gout, void *user_data);
+
+int jacrobCSC(realtype tt,  realtype cj, 
+              N_Vector yy, N_Vector yp, N_Vector resvec, 
+              SlsMat JacMat, void *user_data,
+              N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
+
+int jacrobCSR(realtype tt,  realtype cj, 
+              N_Vector yy, N_Vector yp, N_Vector resvec, 
+              SlsMat JacMat, void *user_data,
+              N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
+
+/* Prototypes of private functions */
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y);
+static void PrintOutput(void *mem, realtype t, N_Vector y);
+static void PrintRootInfo(int root_f1, int root_f2);
+static void PrintFinalStats(void *mem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * Main Program
+ *--------------------------------------------------------------------
+ */
+
+int main(void)
+{
+  void *mem;
+  N_Vector yy, yp, avtol;
+  realtype rtol, *yval, *ypval, *atval;
+  realtype t0, tout1, tout, tret;
+  int iout, retval, retvalr;
+  int rootsfound[2];
+
+  int nnz;
+
+  mem = NULL;
+  yy = yp = avtol = NULL;
+  yval = ypval = atval = NULL;
+
+  /* Allocate N-vectors. */
+  yy = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yy, "N_VNew_Serial", 0)) return(1);
+  yp = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+  avtol = N_VNew_Serial(NEQ);
+  if(check_flag((void *)avtol, "N_VNew_Serial", 0)) return(1);
+
+  /* Create and initialize  y, y', and absolute tolerance vectors. */
+  yval  = N_VGetArrayPointer_Serial(yy);
+  yval[0] = ONE;
+  yval[1] = ZERO;
+  yval[2] = ZERO;
+
+  ypval = N_VGetArrayPointer_Serial(yp);
+  ypval[0]  = RCONST(-0.04);
+  ypval[1]  = RCONST(0.04);
+  ypval[2]  = ZERO;  
+
+  rtol = RCONST(1.0e-4);
+
+  atval = N_VGetArrayPointer_Serial(avtol);
+  atval[0] = RCONST(1.0e-8);
+  atval[1] = RCONST(1.0e-6);
+  atval[2] = RCONST(1.0e-6);
+
+  /* Integration limits */
+  t0 = ZERO;
+  tout1 = RCONST(0.4);
+
+  PrintHeader(rtol, avtol, yy);
+
+  /* Call IDACreate and IDAMalloc to initialize IDA memory */
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+  retval = IDAInit(mem, resrob, t0, yy, yp);
+  if(check_flag(&retval, "IDAInit", 1)) return(1);
+  retval = IDASVtolerances(mem, rtol, avtol);
+  if(check_flag(&retval, "IDASVtolerances", 1)) return(1);
+
+  /* Free avtol */
+  N_VDestroy_Serial(avtol);
+
+  /* Call IDARootInit to specify the root function grob with 2 components */
+  retval = IDARootInit(mem, 2, grob);
+  if (check_flag(&retval, "IDARootInit", 1)) return(1);
+
+  /* Call IDAKLU and set up the linear solver. */
+  nnz = NEQ * NEQ;
+  retval = IDAKLU(mem, NEQ, nnz, CSR_MAT);
+  if(check_flag(&retval, "IDAKLU", 1)) return(1);
+  retval = IDASlsSetSparseJacFn(mem, jacrobCSR);
+  if(check_flag(&retval, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call IDASolve, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached. */
+  iout = 0; tout = tout1;
+  while(1) {
+
+    retval = IDASolve(mem, tout, &tret, yy, yp, IDA_NORMAL);
+
+    PrintOutput(mem,tret,yy);
+
+    if(check_flag(&retval, "IDASolve", 1)) return(1);
+
+    if (retval == IDA_ROOT_RETURN) {
+      retvalr = IDAGetRootInfo(mem, rootsfound);
+      check_flag(&retvalr, "IDAGetRootInfo", 1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (retval == IDA_SUCCESS) {
+      iout++;
+      tout *= RCONST(10.0);
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  PrintFinalStats(mem);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+  N_VDestroy_Serial(yy);
+  N_VDestroy_Serial(yp);
+
+  return(0);
+  
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Functions called by IDA
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Define the system residual function. 
+ */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data)
+{
+  realtype *yval, *ypval, *rval;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
+
+  rval[0]  = RCONST(-0.04)*yval[0] + RCONST(1.0e4)*yval[1]*yval[2];
+  rval[1]  = -rval[0] - RCONST(3.0e7)*yval[1]*yval[1] - ypval[1];
+  rval[0] -=  ypval[0];
+  rval[2]  =  yval[0] + yval[1] + yval[2] - ONE;
+
+  return(0);
+}
+
+/*
+ * Root function routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int grob(realtype t, N_Vector yy, N_Vector yp, realtype *gout,
+                void *user_data)
+{
+  realtype *yval, y1, y3;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  y1 = yval[0]; y3 = yval[2];
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Define the Jacobian function. 
+ */
+
+int jacrobCSC(realtype tt,  realtype cj, 
+              N_Vector yy, N_Vector yp, N_Vector resvec,
+              SlsMat JacMat, void *user_data,
+              N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  
+  yval = N_VGetArrayPointer_Serial(yy);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data    = JacMat->data;
+  
+  
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  /* column 0 */
+  data[0] = RCONST(-0.04) - cj;
+  rowvals[0] = 0;
+  data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  data[2] = ONE;
+  rowvals[2] = 2;
+
+  /* column 1 */
+  data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]) - cj;
+  rowvals[4] = 1;
+  data[5] = ONE;
+  rowvals[5] = 2;
+
+  /* column 2 */
+  data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  data[8] = ONE;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ * Define the Jacobian function, where Jacobian is CSR matrix. 
+ */
+int jacrobCSR(realtype tt,  realtype cj, 
+              N_Vector yy, N_Vector yp, N_Vector resvec,
+              SlsMat JacMat, void *user_data,
+              N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
+{
+  realtype *yval;
+  int* rowptrs;
+  int* colvals;
+  realtype* data;
+  
+  yval = N_VGetArrayPointer_Serial(yy);
+  rowptrs = (*JacMat->rowptrs);
+  colvals = (*JacMat->colvals);
+  data    = JacMat->data;
+  
+  
+  SparseSetMatToZero(JacMat);
+
+  rowptrs[0] = 0;
+  rowptrs[1] = 3;
+  rowptrs[2] = 6;
+  rowptrs[3] = 9;
+
+  /* row 0 */
+  data[0] = RCONST(-0.04) - cj;
+  colvals[0] = 0;
+  data[1] = RCONST(1.0e4)*yval[2];
+  colvals[1] = 1;
+  data[2] = RCONST(1.0e4)*yval[1];
+  colvals[2] = 2;
+
+  /* row 1 */
+  data[3] = RCONST(0.04);
+  colvals[3] = 0;
+  data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]) - cj;
+  colvals[4] = 1;
+  data[5] = RCONST(-1.0e4)*yval[1];
+  colvals[5] = 2;
+
+  /* row 2 */
+  data[6] = ONE;
+  colvals[6] = 0;
+  data[7] = ONE;
+  colvals[7] = 1;
+  data[8] = ONE;
+  colvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Private functions
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
+{
+  realtype *atval, *yval;
+
+  atval  = N_VGetArrayPointer_Serial(avtol);
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  printf("\nidaRoberts_klu: Robertson kinetics DAE serial example problem for IDA.\n");
+  printf("               Three equation chemical kinetics problem.\n\n");
+  printf("Linear solver: IDAKLU, with user-supplied Jacobian.\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg %Lg %Lg \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%Lg %Lg %Lg)\n",
+         yval[0], yval[1], yval[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#endif
+  printf("Constraints and id not used.\n\n");
+  printf("-----------------------------------------------------------------------\n");
+  printf("  t             y1           y2           y3");
+  printf("      | nst  k      h\n");
+  printf("-----------------------------------------------------------------------\n");
+}
+
+/*
+ * Print Output
+ */
+
+static void PrintOutput(void *mem, realtype t, N_Vector y)
+{
+  realtype *yval;
+  int retval, kused;
+  long int nst;
+  realtype hused;
+
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  retval = IDAGetLastOrder(mem, &kused);
+  check_flag(&retval, "IDAGetLastOrder", 1);
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetLastStep(mem, &hused);
+  check_flag(&retval, "IDAGetLastStep", 1);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld  %1d %12.4Le\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#else
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#endif
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+  return;
+}
+
+/*
+ * Print final integrator statistics
+ */
+
+static void PrintFinalStats(void *mem)
+{
+  int retval;
+  long int nst, nni, nje, nre, nreLS, netf, ncfn, nge;
+
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetNumResEvals(mem, &nre);
+  check_flag(&retval, "IDAGetNumResEvals", 1);
+  retval = IDASlsGetNumJacEvals(mem, &nje);
+  check_flag(&retval, "IDASlsGetNumJacEvals", 1);
+  retval = IDAGetNumNonlinSolvIters(mem, &nni);
+  check_flag(&retval, "IDAGetNumNonlinSolvIters", 1);
+  retval = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&retval, "IDAGetNumErrTestFails", 1);
+  retval = IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  check_flag(&retval, "IDAGetNumNonlinSolvConvFails", 1);
+  /*  
+      retval = IDASlsGetNumResEvals(mem, &nreLS);
+      check_flag(&retval, "IDASlsGetNumResEvals", 1);
+  */
+  nreLS = 0;
+  retval = IDAGetNumGEvals(mem, &nge);
+  check_flag(&retval, "IDAGetNumGEvals", 1);
+
+  printf("\nFinal Run Statistics: \n\n");
+  printf("Number of steps                    = %ld\n", nst);
+  printf("Number of residual evaluations     = %ld\n", nre+nreLS);
+  printf("Number of Jacobian evaluations     = %ld\n", nje);
+  printf("Number of nonlinear iterations     = %ld\n", nni);
+  printf("Number of error test failures      = %ld\n", netf);
+  printf("Number of nonlinear conv. failures = %ld\n", ncfn);
+  printf("Number of root fn. evaluations     = %ld\n", nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/ida/serial/idaRoberts_klu.out b/examples/ida/serial/idaRoberts_klu.out
new file mode 100644
index 0000000..7d56d20
--- /dev/null
+++ b/examples/ida/serial/idaRoberts_klu.out
@@ -0,0 +1,38 @@
+
+idaRoberts_klu: Robertson kinetics DAE serial example problem for IDA.
+               Three equation chemical kinetics problem.
+
+Linear solver: IDAKLU, with user-supplied Jacobian.
+Tolerance parameters:  rtol = 0.0001   atol = 1e-08 1e-06 1e-06 
+Initial conditions y0 = (1 0 0)
+Constraints and id not used.
+
+-----------------------------------------------------------------------
+  t             y1           y2           y3      | nst  k      h
+-----------------------------------------------------------------------
+2.6402e-01   9.8997e-01   3.4706e-05   1.0000e-02 |  27  2   4.4012e-02
+    rootsfound[] =   0   1
+4.0000e-01   9.8517e-01   3.3864e-05   1.4794e-02 |  29  3   8.8024e-02
+4.0000e+00   9.0553e-01   2.2406e-05   9.4452e-02 |  43  4   6.3377e-01
+4.0000e+01   7.1579e-01   9.1838e-06   2.8420e-01 |  68  4   3.1932e+00
+4.0000e+02   4.5044e-01   3.2218e-06   5.4956e-01 |  95  4   3.3201e+01
+4.0000e+03   1.8320e-01   8.9444e-07   8.1680e-01 | 126  3   3.1458e+02
+4.0000e+04   3.8992e-02   1.6221e-07   9.6101e-01 | 161  5   2.5058e+03
+4.0000e+05   4.9369e-03   1.9842e-08   9.9506e-01 | 202  3   2.6371e+04
+4.0000e+06   5.1693e-04   2.0688e-09   9.9948e-01 | 252  5   2.5583e+05
+2.0801e+07   1.0000e-04   4.0004e-10   9.9990e-01 | 291  4   1.1781e+06
+    rootsfound[] =  -1   0
+4.0000e+07   5.2043e-05   2.0818e-10   9.9995e-01 | 303  5   2.3562e+06
+4.0000e+08   5.2113e-06   2.0845e-11   9.9999e-01 | 336  4   3.7885e+07
+4.0000e+09   5.2515e-07   2.1006e-12   1.0000e+00 | 359  3   5.4083e+08
+4.0000e+10   5.1251e-08   2.0500e-13   1.0000e+00 | 375  3   8.6532e+09
+
+Final Run Statistics: 
+
+Number of steps                    = 375
+Number of residual evaluations     = 529
+Number of Jacobian evaluations     = 54
+Number of nonlinear iterations     = 529
+Number of error test failures      = 10
+Number of nonlinear conv. failures = 0
+Number of root fn. evaluations     = 417
diff --git a/examples/ida/serial/idaRoberts_sps.c b/examples/ida/serial/idaRoberts_sps.c
new file mode 100644
index 0000000..fc4579c
--- /dev/null
+++ b/examples/ida/serial/idaRoberts_sps.c
@@ -0,0 +1,421 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL  (based on idasRoberts_dns.c)
+ * -----------------------------------------------------------------
+ * This simple example problem for IDA, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *      dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+ *         0   = y1 + y2 + y3 - 1
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.
+ *
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01.
+ *
+ * The problem is solved with IDA using IDASUPERLUMT for the linear
+ * solver, with a user-supplied Jacobian. Output is printed at
+ * t = .4, 4, 40, ..., 4e10.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include <ida/ida.h>
+#include <ida/ida_superlumt.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+#define NEQ   3
+#define NOUT  12
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* Prototypes of functions called by IDA */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, 
+           N_Vector resval, void *user_data);
+
+static int grob(realtype t, N_Vector yy, N_Vector yp,
+                realtype *gout, void *user_data);
+
+int jacrob(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec, 
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
+
+/* Prototypes of private functions */
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y);
+static void PrintOutput(void *mem, realtype t, N_Vector y);
+static void PrintRootInfo(int root_f1, int root_f2);
+static void PrintFinalStats(void *mem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * Main Program
+ *--------------------------------------------------------------------
+ */
+
+int main(void)
+{
+  void *mem;
+  N_Vector yy, yp, avtol;
+  realtype rtol, *yval, *ypval, *atval;
+  realtype t0, tout1, tout, tret;
+  int iout, retval, retvalr;
+  int rootsfound[2];
+
+  int nnz;
+
+  mem = NULL;
+  yy = yp = avtol = NULL;
+  yval = ypval = atval = NULL;
+
+  /* Allocate N-vectors. */
+  yy = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yy, "N_VNew_Serial", 0)) return(1);
+  yp = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+  avtol = N_VNew_Serial(NEQ);
+  if(check_flag((void *)avtol, "N_VNew_Serial", 0)) return(1);
+
+  /* Create and initialize  y, y', and absolute tolerance vectors. */
+  yval  = N_VGetArrayPointer_Serial(yy);
+  yval[0] = ONE;
+  yval[1] = ZERO;
+  yval[2] = ZERO;
+
+  ypval = N_VGetArrayPointer_Serial(yp);
+  ypval[0]  = RCONST(-0.04);
+  ypval[1]  = RCONST(0.04);
+  ypval[2]  = ZERO;  
+
+  rtol = RCONST(1.0e-4);
+
+  atval = N_VGetArrayPointer_Serial(avtol);
+  atval[0] = RCONST(1.0e-8);
+  atval[1] = RCONST(1.0e-6);
+  atval[2] = RCONST(1.0e-6);
+
+  /* Integration limits */
+  t0 = ZERO;
+  tout1 = RCONST(0.4);
+
+  PrintHeader(rtol, avtol, yy);
+
+  /* Call IDACreate and IDAMalloc to initialize IDA memory */
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+  retval = IDAInit(mem, resrob, t0, yy, yp);
+  if(check_flag(&retval, "IDAInit", 1)) return(1);
+  retval = IDASVtolerances(mem, rtol, avtol);
+  if(check_flag(&retval, "IDASVtolerances", 1)) return(1);
+
+  /* Free avtol */
+  N_VDestroy_Serial(avtol);
+
+  /* Call IDARootInit to specify the root function grob with 2 components */
+  retval = IDARootInit(mem, 2, grob);
+  if (check_flag(&retval, "IDARootInit", 1)) return(1);
+
+  /* Call IDASuperLUMT and set up the linear solver. */
+  nnz = NEQ * NEQ;
+  retval = IDASuperLUMT(mem, 1, NEQ, nnz);
+  if(check_flag(&retval, "IDASuperLUMT", 1)) return(1);
+  retval = IDASlsSetSparseJacFn(mem, jacrob);
+  if(check_flag(&retval, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call IDASolve, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached. */
+
+  iout = 0; tout = tout1;
+  while(1) {
+
+    retval = IDASolve(mem, tout, &tret, yy, yp, IDA_NORMAL);
+
+    PrintOutput(mem,tret,yy);
+
+    if(check_flag(&retval, "IDASolve", 1)) return(1);
+
+    if (retval == IDA_ROOT_RETURN) {
+      retvalr = IDAGetRootInfo(mem, rootsfound);
+      check_flag(&retvalr, "IDAGetRootInfo", 1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (retval == IDA_SUCCESS) {
+      iout++;
+      tout *= RCONST(10.0);
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  PrintFinalStats(mem);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+  N_VDestroy_Serial(yy);
+  N_VDestroy_Serial(yp);
+
+  return(0);
+  
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Functions called by IDA
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Define the system residual function. 
+ */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data)
+{
+  realtype *yval, *ypval, *rval;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
+
+  rval[0]  = RCONST(-0.04)*yval[0] + RCONST(1.0e4)*yval[1]*yval[2];
+  rval[1]  = -rval[0] - RCONST(3.0e7)*yval[1]*yval[1] - ypval[1];
+  rval[0] -=  ypval[0];
+  rval[2]  =  yval[0] + yval[1] + yval[2] - ONE;
+
+  return(0);
+}
+
+/*
+ * Root function routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int grob(realtype t, N_Vector yy, N_Vector yp, realtype *gout,
+                void *user_data)
+{
+  realtype *yval, y1, y3;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  y1 = yval[0]; y3 = yval[2];
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Define the Jacobian function. 
+ */
+
+int jacrob(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec,
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
+{
+  realtype *yval;
+  int *colptrs = *JacMat->colptrs;
+  int *rowvals = *JacMat->rowvals;
+  
+  yval = N_VGetArrayPointer_Serial(yy);
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  JacMat->data[0] = RCONST(-0.04) - cj;
+  rowvals[0] = 0;
+  JacMat->data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  JacMat->data[2] = ONE;
+  rowvals[2] = 2;
+
+  JacMat->data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  JacMat->data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]) - cj;
+  rowvals[4] = 1;
+  JacMat->data[5] = ONE;
+  rowvals[5] = 2;
+
+  JacMat->data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  JacMat->data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  JacMat->data[8] = ONE;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Private functions
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
+{
+  realtype *atval, *yval;
+
+  atval  = N_VGetArrayPointer_Serial(avtol);
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  printf("\nidaRoberts_sps: Robertson kinetics DAE serial example problem for IDA.\n");
+  printf("               Three equation chemical kinetics problem.\n\n");
+  printf("Linear solver: IDASUPERLUMT, with user-supplied Jacobian.\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg %Lg %Lg \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%Lg %Lg %Lg)\n",
+         yval[0], yval[1], yval[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#endif
+  printf("Constraints and id not used.\n\n");
+  printf("-----------------------------------------------------------------------\n");
+  printf("  t             y1           y2           y3");
+  printf("      | nst  k      h\n");
+  printf("-----------------------------------------------------------------------\n");
+}
+
+/*
+ * Print Output
+ */
+
+static void PrintOutput(void *mem, realtype t, N_Vector y)
+{
+  realtype *yval;
+  int retval, kused;
+  long int nst;
+  realtype hused;
+
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  retval = IDAGetLastOrder(mem, &kused);
+  check_flag(&retval, "IDAGetLastOrder", 1);
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetLastStep(mem, &hused);
+  check_flag(&retval, "IDAGetLastStep", 1);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld  %1d %12.4Le\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#else
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#endif
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+  return;
+}
+
+/*
+ * Print final integrator statistics
+ */
+
+static void PrintFinalStats(void *mem)
+{
+  int retval;
+  long int nst, nni, nje, nre, nreLS, netf, ncfn, nge;
+
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetNumResEvals(mem, &nre);
+  check_flag(&retval, "IDAGetNumResEvals", 1);
+  retval = IDASlsGetNumJacEvals(mem, &nje);
+  check_flag(&retval, "IDASlsGetNumJacEvals", 1);
+  retval = IDAGetNumNonlinSolvIters(mem, &nni);
+  check_flag(&retval, "IDAGetNumNonlinSolvIters", 1);
+  retval = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&retval, "IDAGetNumErrTestFails", 1);
+  retval = IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  check_flag(&retval, "IDAGetNumNonlinSolvConvFails", 1);
+  /*  retval = IDASlsGetNumResEvals(mem, &nreLS); */
+  /*  check_flag(&retval, "IDASlsGetNumResEvals", 1); */
+  nreLS = 0;
+  retval = IDAGetNumGEvals(mem, &nge);
+  check_flag(&retval, "IDAGetNumGEvals", 1);
+
+  printf("\nFinal Run Statistics: \n\n");
+  printf("Number of steps                    = %ld\n", nst);
+  printf("Number of residual evaluations     = %ld\n", nre+nreLS);
+  printf("Number of Jacobian evaluations     = %ld\n", nje);
+  printf("Number of nonlinear iterations     = %ld\n", nni);
+  printf("Number of error test failures      = %ld\n", netf);
+  printf("Number of nonlinear conv. failures = %ld\n", ncfn);
+  printf("Number of root fn. evaluations     = %ld\n", nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/ida/serial/idaRoberts_sps.out b/examples/ida/serial/idaRoberts_sps.out
new file mode 100644
index 0000000..86a24d9
--- /dev/null
+++ b/examples/ida/serial/idaRoberts_sps.out
@@ -0,0 +1,38 @@
+
+idaRoberts_sps: Robertson kinetics DAE serial example problem for IDA.
+               Three equation chemical kinetics problem.
+
+Linear solver: IDASUPERLUMT, with user-supplied Jacobian.
+Tolerance parameters:  rtol = 0.0001   atol = 1e-08 1e-06 1e-06 
+Initial conditions y0 = (1 0 0)
+Constraints and id not used.
+
+-----------------------------------------------------------------------
+  t             y1           y2           y3      | nst  k      h
+-----------------------------------------------------------------------
+2.6402e-01   9.8997e-01   3.4706e-05   1.0000e-02 |  27  2   4.4012e-02
+    rootsfound[] =   0   1
+4.0000e-01   9.8517e-01   3.3864e-05   1.4794e-02 |  29  3   8.8024e-02
+4.0000e+00   9.0553e-01   2.2406e-05   9.4452e-02 |  43  4   6.3377e-01
+4.0000e+01   7.1579e-01   9.1838e-06   2.8420e-01 |  68  4   3.1932e+00
+4.0000e+02   4.5044e-01   3.2218e-06   5.4956e-01 |  95  4   3.3201e+01
+4.0000e+03   1.8320e-01   8.9444e-07   8.1680e-01 | 126  3   3.1458e+02
+4.0000e+04   3.8992e-02   1.6221e-07   9.6101e-01 | 161  5   2.5058e+03
+4.0000e+05   4.9369e-03   1.9842e-08   9.9506e-01 | 202  3   2.6371e+04
+4.0000e+06   5.1693e-04   2.0688e-09   9.9948e-01 | 252  5   2.5583e+05
+2.0801e+07   1.0000e-04   4.0004e-10   9.9990e-01 | 291  4   1.1781e+06
+    rootsfound[] =  -1   0
+4.0000e+07   5.2043e-05   2.0818e-10   9.9995e-01 | 303  5   2.3562e+06
+4.0000e+08   5.2113e-06   2.0845e-11   9.9999e-01 | 336  4   3.7885e+07
+4.0000e+09   5.2515e-07   2.1006e-12   1.0000e+00 | 359  3   5.4083e+08
+4.0000e+10   5.1251e-08   2.0500e-13   1.0000e+00 | 375  3   8.6532e+09
+
+Final Run Statistics: 
+
+Number of steps                    = 375
+Number of residual evaluations     = 529
+Number of Jacobian evaluations     = 54
+Number of nonlinear iterations     = 529
+Number of error test failures      = 10
+Number of nonlinear conv. failures = 0
+Number of root fn. evaluations     = 417
diff --git a/examples/ida/serial/idaSlCrank_dns.c b/examples/ida/serial/idaSlCrank_dns.c
index d379597..af3ad59 100644
--- a/examples/ida/serial/idaSlCrank_dns.c
+++ b/examples/ida/serial/idaSlCrank_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:25:59 $
+ * $Revision: 4809 $
+ * $Date: 2016-07-18 11:16:25 -0700 (Mon, 18 Jul 2016) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -145,6 +145,7 @@ int main(void)
   IDAFree(&mem);
   N_VDestroy_Serial(yy);
   N_VDestroy_Serial(yp);
+  N_VDestroy_Serial(id);
 
   return(0);
   
@@ -214,7 +215,7 @@ void force(N_Vector yy, realtype *Q, UserData data)
   c21 = c2*c1 + s2*s1;
 
   l2 = x*x - x*(c2+a*c1) + (ONE + a*a)/FOUR + a*c21/TWO;
-  l = RSqrt(l2);
+  l = SUNRsqrt(l2);
   ld = TWO*x*xd - xd*(c2+a*c1) + x*(s2*pd+a*s1*qd) - a*s21*(pd-qd)/TWO;
   ld /= TWO*l;
 
@@ -245,9 +246,9 @@ int ressc(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data)
   m2 = data->m2;
   J2 = data->J2;
 
-  yval = NV_DATA_S(yy); 
-  ypval = NV_DATA_S(yp); 
-  rval = NV_DATA_S(rr);
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
 
   q = yval[0];
   x = yval[1];
@@ -295,7 +296,7 @@ static void PrintHeader(realtype rtol, realtype atol, N_Vector y)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n",
          rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n",
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n",
          rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n",
@@ -314,13 +315,13 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   long int nst;
   realtype hused;
 
-  yval  = NV_DATA_S(y);
+  yval  = N_VGetArrayPointer_Serial(y);
 
   flag = IDAGetLastOrder(mem, &kused);
   flag = IDAGetNumSteps(mem, &nst);
   flag = IDAGetLastStep(mem, &hused);
 
-  printf("%10.4le %12.4le %12.4le %12.4le %3ld  %1d %12.4le\n", 
+  printf("%10.4e %12.4e %12.4e %12.4e %3ld  %1d %12.4e\n", 
          t, yval[0], yval[1], yval[2], nst, kused, hused);
 }
 
diff --git a/examples/idas/C_openmp/CMakeLists.txt b/examples/idas/C_openmp/CMakeLists.txt
new file mode 100644
index 0000000..845504e
--- /dev/null
+++ b/examples/idas/C_openmp/CMakeLists.txt
@@ -0,0 +1,129 @@
+# ---------------------------------------------------------------
+# Programmer:  Ting Yan @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for IDAS OpenMP examples
+
+# Only include tests if OpenMP is enabled
+IF(OPENMP_FOUND)
+  # Add variable IDAS_examples_OMP with the names of the openmp IDAS examples
+  SET(IDAS_examples_OMP
+    idasFoodWeb_bnd_omp
+    idasFoodWeb_kry_omp
+    )
+ENDIF(OPENMP_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDAS_LIB sundials_idas_static)
+  SET(NVECOMP_LIB sundials_nvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(IDAS_LIB sundials_idas_shared)
+  SET(NVECOMP_LIB sundials_nvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${IDAS_LIB} ${NVECOMP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# update the compilation flags to include OpenMP support
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+
+# Add the build and install targets for each IDAS example
+FOREACH(example ${IDAS_examples_OMP})
+  IF(NOT ${example} MATCHES "idasFoodWeb_kry_omp") # LEB NOTE: This goes away with TestRunner fix for OpenMP
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example} TEST_ARGS 4)
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  ENDIF()
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/C_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${IDAS_examples_OMP})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/C_openmp)
+
+  # Install the extra files
+  FOREACH(extrafile ${IDAS_extras_OMP})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/C_openmp)
+  ENDFOREACH(extrafile ${IDAS_extras_OMP})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "IDAS")
+  SET(SOLVER_LIB "sundials_idas")
+  LIST2STRING(IDAS_examples_OMP EXAMPLES)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/idas/C_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/idas/C_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/C_openmp 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/idas/C_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/idas/C_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/C_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/idas/C_openmp/README b/examples/idas/C_openmp/README
new file mode 100644
index 0000000..5adf53f
--- /dev/null
+++ b/examples/idas/C_openmp/README
@@ -0,0 +1,50 @@
+List of C_openmp examples for IDAS
+
+  idasFoodWeb_bnd_omp   : 2-D food web system, banded Jacobian
+  idasFoodWeb_kry_omp   : 2-D food web system using Krylov solver
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/idas/C_openmp/idasFoodWeb_bnd_omp.c b/examples/idas/C_openmp/idasFoodWeb_bnd_omp.c
new file mode 100644
index 0000000..dd9facc
--- /dev/null
+++ b/examples/idas/C_openmp/idasFoodWeb_bnd_omp.c
@@ -0,0 +1,705 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on idasFoodWeb_bnd.c and parallelized with OpenMP
+ * -----------------------------------------------------------------
+ * Example program for IDAS: Food web problem.
+ *
+ * This example program (OpenMP version) uses the IDABAND linear 
+ * solver, and IDACalcIC for initial condition calculation.
+ *
+ * The mathematical problem solved in this example is a DAE system
+ * that arises from a system of partial differential equations after
+ * spatial discretization. The PDE system is a food web population
+ * model, with predator-prey interaction and diffusion on the unit
+ * square in two dimensions. The dependent variable vector is:
+ *
+ *         1   2         ns
+ *   c = (c , c ,  ..., c  ) , ns = 2 * np
+ *
+ * and the PDE's are as follows:
+ *
+ *     i             i      i
+ *   dc /dt = d(i)*(c    + c  )  +  R (x,y,c)   (i = 1,...,np)
+ *                   xx     yy       i
+ *
+ *              i      i
+ *   0 = d(i)*(c    + c  )  +  R (x,y,c)   (i = np+1,...,ns)
+ *              xx     yy       i
+ *
+ *   where the reaction terms R are:
+ *
+ *                   i             ns         j
+ *   R  (x,y,c)  =  c  * (b(i)  + sum a(i,j)*c )
+ *    i                           j=1
+ *
+ * The number of species is ns = 2 * np, with the first np being
+ * prey and the last np being predators. The coefficients a(i,j),
+ * b(i), d(i) are:
+ *
+ *  a(i,i) = -AA   (all i)
+ *  a(i,j) = -GG   (i <= np , j >  np)
+ *  a(i,j) =  EE   (i >  np, j <= np)
+ *  all other a(i,j) = 0
+ *  b(i) = BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i <= np)
+ *  b(i) =-BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i  > np)
+ *  d(i) = DPREY   (i <= np)
+ *  d(i) = DPRED   (i > np)
+ *
+ * The various scalar parameters required are set using '#define'
+ * statements or directly in routine InitUserData. In this program,
+ * np = 1, ns = 2. The boundary conditions are homogeneous Neumann:
+ * normal derivative = 0.
+ *
+ * A polynomial in x and y is used to set the initial values of the
+ * first np variables (the prey variables) at each x,y location,
+ * while initial values for the remaining (predator) variables are
+ * set to a flat value, which is corrected by IDACalcIC.
+ *
+ * The PDEs are discretized by central differencing on a MX by MY
+ * mesh.
+ *
+ * The DAE system is solved by IDAS using the IDABAND linear solver.
+ * Output is printed at t = 0, .001, .01, .1, .4, .7, 1.
+ *
+ * Optionally, we can set the number of threads from environment 
+ * variable or command line. To check the current value for number
+ * of threads from environment:
+ *      % echo $OMP_NUM_THREADS
+ *
+ * Execution:
+ *
+ * If the user want to use the default value or the number of threads 
+ * from environment value:
+ *      % ./idasFoodWeb_bnd_omp 
+ * If the user want to specify the number of threads to use
+ *      % ./idasFoodWeb_bnd_omp num_threads
+ * where num_threads is the number of threads the user want to use 
+ *
+ * -----------------------------------------------------------------
+ * References:
+ * [1] Peter N. Brown and Alan C. Hindmarsh,
+ *     Reduced Storage Matrix Methods in Stiff ODE systems, Journal
+ *     of Applied Mathematics and Computation, Vol. 31 (May 1989),
+ *     pp. 40-91.
+ *
+ * [2] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Using Krylov Methods in the Solution of Large-Scale
+ *     Differential-Algebraic Systems, SIAM J. Sci. Comput., 15
+ *     (1994), pp. 1467-1488.
+ *
+ * [3] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Consistent Initial Condition Calculation for Differential-
+ *     Algebraic Systems, SIAM J. Sci. Comput., 19 (1998),
+ *     pp. 1495-1512.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <idas/idas.h>
+#include <idas/idas_band.h>
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_dense.h>
+#include <sundials/sundials_types.h>
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+/* Problem Constants. */
+
+#define NPREY       1              /* No. of prey (= no. of predators). */
+#define NUM_SPECIES 2*NPREY
+
+#define PI          RCONST(3.1415926535898)
+#define FOURPI      (RCONST(4.0)*PI)
+
+#define MX          20             /* MX = number of x mesh points      */
+#define MY          20             /* MY = number of y mesh points      */
+#define NSMX        (NUM_SPECIES * MX)
+#define NEQ         (NUM_SPECIES*MX*MY)
+#define AA          RCONST(1.0)    /* Coefficient in above eqns. for a  */
+#define EE          RCONST(10000.) /* Coefficient in above eqns. for a  */
+#define GG          RCONST(0.5e-6) /* Coefficient in above eqns. for a  */
+#define BB          RCONST(1.0)    /* Coefficient in above eqns. for b  */
+#define DPREY       RCONST(1.0)    /* Coefficient in above eqns. for d  */
+#define DPRED       RCONST(0.05)   /* Coefficient in above eqns. for d  */
+#define ALPHA       RCONST(50.)    /* Coefficient alpha in above eqns.  */
+#define BETA        RCONST(1000.)  /* Coefficient beta in above eqns.   */
+#define AX          RCONST(1.0)    /* Total range of x variable         */
+#define AY          RCONST(1.0)    /* Total range of y variable         */
+#define RTOL        RCONST(1.e-5)  /* Relative tolerance                */
+#define ATOL        RCONST(1.e-5)  /* Absolute tolerance                */
+#define NOUT        6              /* Number of output times            */
+#define TMULT       RCONST(10.0)   /* Multiplier for tout values        */
+#define TADD        RCONST(0.3)    /* Increment for tout values         */
+#define ZERO        RCONST(0.)     
+#define ONE         RCONST(1.0)    
+
+/* 
+ * User-defined vector and accessor macro: IJ_Vptr.
+ * IJ_Vptr is defined in order to express the underlying 3-D structure of 
+ * the dependent variable vector from its underlying 1-D storage (an N_Vector).
+ * IJ_Vptr(vv,i,j) returns a pointer to the location in vv corresponding to 
+ * species index is = 0, x-index ix = i, and y-index jy = j.                
+ */
+
+#define IJ_Vptr(vv,i,j) (&NV_Ith_OMP(vv, (i)*NUM_SPECIES + (j)*NSMX))
+
+/* Type: UserData.  Contains problem constants, etc. */
+
+typedef struct {
+  long int Neq, ns, np, mx, my;
+  realtype dx, dy, **acoef;
+  realtype cox[NUM_SPECIES], coy[NUM_SPECIES], bcoef[NUM_SPECIES];
+  N_Vector rates;
+  int nthreads;
+} *UserData;
+
+/* Prototypes for functions called by the IDA Solver. */
+
+static int resweb(realtype time, N_Vector cc, N_Vector cp, N_Vector resval, 
+                  void *user_data);
+
+/* Prototypes for private Helper Functions. */
+
+static void InitUserData(UserData webdata);
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata);
+static void PrintHeader(long int mu, long int ml, realtype rtol, realtype atol);
+static void PrintOutput(void *mem, N_Vector c, realtype t);
+static void PrintFinalStats(void *mem);
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate, UserData webdata);
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
+                     UserData webdata);
+static realtype dotprod(long int size, realtype *x1, realtype *x2);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{ 
+  void *mem;
+  UserData webdata;
+  N_Vector cc, cp, id;
+  int iout, retval;
+  long int mu, ml;
+  realtype rtol, atol, t0, tout, tret;
+  int num_threads;
+
+  mem = NULL;
+  webdata = NULL;
+  cc = cp = id = NULL;
+
+  /* Set the number of threads to use */
+  num_threads = 1;       /* default value */
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();  /* overwrite with OMP_NUM_THREADS enviroment variable */
+#endif
+  if (argc > 1)      /* overwrite with command line value, if supplied */
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* Allocate and initialize user data block webdata. */
+
+  webdata = (UserData) malloc(sizeof *webdata);
+  webdata->rates = N_VNew_OpenMP(NEQ, num_threads);
+  webdata->acoef = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+  webdata->nthreads = num_threads;
+
+  InitUserData(webdata);
+
+  /* Allocate N-vectors and initialize cc, cp, and id. */
+
+  cc  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cc, "N_VNew_OpenMP", 0)) return(1);
+
+  cp  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cp, "N_VNew_OpenMP", 0)) return(1);
+
+  id  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)id, "N_VNew_OpenMP", 0)) return(1);
+  
+  SetInitialProfiles(cc, cp, id, webdata);
+  
+  /* Set remaining inputs to IDAMalloc. */
+  
+  t0 = ZERO;
+  rtol = RTOL; 
+  atol = ATOL;
+
+  /* Call IDACreate and IDAMalloc to initialize IDA. */
+  
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+
+  retval = IDASetUserData(mem, webdata);
+  if(check_flag(&retval, "IDASetUserData", 1)) return(1);
+
+  retval = IDASetId(mem, id);
+  if(check_flag(&retval, "IDASetId", 1)) return(1);
+
+  retval = IDAInit(mem, resweb, t0, cc, cp);
+  if(check_flag(&retval, "IDAInit", 1)) return(1);
+
+  retval = IDASStolerances(mem, rtol, atol);
+  if(check_flag(&retval, "IDASStolerances", 1)) return(1);
+
+  /* Call IDABand to specify the IDA linear solver. */
+
+  mu = ml = NSMX;
+  retval = IDABand(mem, NEQ, mu, ml);
+  if(check_flag(&retval, "IDABand", 1)) return(1);
+
+  /* Call IDACalcIC (with default options) to correct the initial values. */
+
+  tout = RCONST(0.001);
+  retval = IDACalcIC(mem, IDA_YA_YDP_INIT, tout);
+  if(check_flag(&retval, "IDACalcIC", 1)) return(1);
+  
+  /* Print heading, basic parameters, and initial values. */
+
+  PrintHeader(mu, ml, rtol, atol);
+  PrintOutput(mem, cc, ZERO);
+  
+  /* Loop over iout, call IDASolve (normal mode), print selected output. */
+  
+  for (iout = 1; iout <= NOUT; iout++) {
+    
+    retval = IDASolve(mem, tout, &tret, cc, cp, IDA_NORMAL);
+    if(check_flag(&retval, "IDASolve", 1)) return(retval);
+    
+    PrintOutput(mem, cc, tret);
+    
+    if (iout < 3) tout *= TMULT; else tout += TADD;
+    
+  }
+  
+  /* Print final statistics and free memory. */  
+  
+  PrintFinalStats(mem);
+  printf("num_threads = %i\n\n", num_threads);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+
+  N_VDestroy_OpenMP(cc);
+  N_VDestroy_OpenMP(cp);
+  N_VDestroy_OpenMP(id);
+
+
+  destroyMat(webdata->acoef);
+  N_VDestroy_OpenMP(webdata->rates);
+  free(webdata);
+
+  return(0);
+}
+
+/* Define lines for readability in later routines */ 
+
+#define acoef  (webdata->acoef)
+#define bcoef  (webdata->bcoef)
+#define cox    (webdata->cox)
+#define coy    (webdata->coy)
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDA
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * resweb: System residual function for predator-prey system.
+ * This routine calls Fweb to get all the right-hand sides of the
+ * equations, then loads the residual vector accordingly,
+ * using cp in the case of prey species.                 
+ */
+
+static int resweb(realtype tt, N_Vector cc, N_Vector cp, 
+                  N_Vector res,  void *user_data)
+{
+  long int jx, jy, is, yloc, loc, np;
+  realtype *resv, *cpv;
+  UserData webdata;
+  
+  webdata = (UserData)user_data;
+  
+  cpv = NV_DATA_OMP(cp);
+  resv = NV_DATA_OMP(res);
+  np = webdata->np;
+  
+  /* Call Fweb to set res to vector of right-hand sides. */
+  Fweb(tt, cc, res, webdata);
+  
+  /* Loop over all grid points, setting residual values appropriately
+     for differential or algebraic components.                        */
+#pragma omp parallel for default(shared) private(jy, yloc, jx, loc, is) schedule(static) 
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np)
+          resv[loc+is] = cpv[loc+is] - resv[loc+is];
+        else
+          resv[loc+is] = -resv[loc+is];
+      }
+    }
+  }
+  
+  return(0);
+  
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * InitUserData: Load problem constants in webdata (of type UserData).   
+ */
+
+static void InitUserData(UserData webdata)
+{
+  int i, j, np;
+  realtype *a1,*a2, *a3, *a4, dx2, dy2;
+
+  webdata->mx = MX;
+  webdata->my = MY;
+  webdata->ns = NUM_SPECIES;
+  webdata->np = NPREY;
+  webdata->dx = AX/(MX-1);
+  webdata->dy = AY/(MY-1);
+  webdata->Neq= NEQ;
+  
+  /* Set up the coefficients a and b, and others found in the equations. */
+  np = webdata->np;
+  dx2 = (webdata->dx)*(webdata->dx); dy2 = (webdata->dy)*(webdata->dy);
+  
+  for (i = 0; i < np; i++) {
+    a1 = &(acoef[i][np]);
+    a2 = &(acoef[i+np][0]);
+    a3 = &(acoef[i][0]);
+    a4 = &(acoef[i+np][np]);
+    /*  Fill in the portion of acoef in the four quadrants, row by row. */
+    for (j = 0; j < np; j++) {
+      *a1++ =  -GG;
+      *a2++ =   EE;
+      *a3++ = ZERO;
+      *a4++ = ZERO;
+    }
+    
+    /* Reset the diagonal elements of acoef to -AA. */
+    acoef[i][i] = -AA; acoef[i+np][i+np] = -AA;
+    
+    /* Set coefficients for b and diffusion terms. */
+    bcoef[i] = BB; bcoef[i+np] = -BB;
+    cox[i] = DPREY/dx2; cox[i+np] = DPRED/dx2;
+    coy[i] = DPREY/dy2; coy[i+np] = DPRED/dy2;
+  }
+  
+}
+
+/* 
+ * SetInitialProfiles: Set initial conditions in cc, cp, and id.
+ * A polynomial profile is used for the prey cc values, and a constant
+ * (1.0e5) is loaded as the initial guess for the predator cc values.
+ * The id values are set to 1 for the prey and 0 for the predators.
+ * The prey cp values are set according to the given system, and
+ * the predator cp values are set to zero.                               
+ */
+
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata)
+{
+  long int loc, yloc, is, jx, jy, np;
+  realtype xx, yy, xyfactor;
+  realtype *ccv, *cpv, *idv;
+  
+  ccv = NV_DATA_OMP(cc);
+  cpv = NV_DATA_OMP(cp);
+  idv = NV_DATA_OMP(id);
+  np = webdata->np;
+  
+  /* Loop over grid, load cc values and id values. */
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * webdata->dy;
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * webdata->dx;
+      xyfactor = RCONST(16.0)*xx*(ONE-xx)*yy*(ONE-yy);
+      xyfactor *= xyfactor;
+      loc = yloc + NUM_SPECIES*jx;
+       
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np) {
+          ccv[loc+is] = RCONST(10.0) + (realtype)(is+1) * xyfactor;
+          idv[loc+is] = ONE;
+        }
+        else {
+	  ccv[loc+is] = RCONST(1.0e5);
+          idv[loc+is] = ZERO;
+        }
+      }
+    }
+  }
+  
+  /* Set c' for the prey by calling the function Fweb. */
+  Fweb(ZERO, cc, cp, webdata);
+  
+  /* Set c' for predators to 0. */
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = np; is < NUM_SPECIES; is++) {
+        cpv[loc+is] = ZERO;
+      }
+    }
+  }
+}
+
+/*
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(long int mu, long int ml, realtype rtol, realtype atol)
+{
+  printf("\nidasFoodWeb_bnd_omp: Predator-prey DAE OpenMP example problem for IDAS \n\n");
+  printf("Number of species ns: %d", NUM_SPECIES);
+  printf("     Mesh dimensions: %d x %d", MX, MY);
+  printf("     System size: %d\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#endif
+  printf("Linear solver: IDABAND,  Band parameters mu = %ld, ml = %ld\n",mu,ml);
+  printf("CalcIC called to correct initial predator concentrations.\n\n");
+  printf("-----------------------------------------------------------\n");
+  printf("  t        bottom-left  top-right");
+  printf("    | nst  k      h\n");
+  printf("-----------------------------------------------------------\n\n");
+  
+}
+
+/* 
+ * PrintOutput: Print output values at output time t = tt.
+ * Selected run statistics are printed.  Then values of the concentrations
+ * are printed for the bottom left and top right grid points only.  
+ */
+
+static void PrintOutput(void *mem, N_Vector c, realtype t)
+{
+  int i, kused, flag;
+  long int nst;
+  realtype *c_bl, *c_tr, hused;
+
+  flag = IDAGetLastOrder(mem, &kused);
+  check_flag(&flag, "IDAGetLastOrder", 1);
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetLastStep(mem, &hused);
+  check_flag(&flag, "IDAGetLastStep", 1);
+  
+  c_bl = IJ_Vptr(c,0,0);
+  c_tr = IJ_Vptr(c,MX-1,MY-1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("%8.2Le %12.4Le %12.4Le   | %3ld  %1d %12.4Le\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4Le %12.4Le   |\n",c_bl[i],c_tr[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#else
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#endif
+
+  printf("\n");
+}
+
+/* 
+ * PrintFinalStats: Print final run data contained in iopt.              
+ */
+
+static void PrintFinalStats(void *mem)
+{ 
+  long int nst, nre, nreLS, nni, nje, netf, ncfn;
+  int flag;
+
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetNumNonlinSolvIters(mem, &nni);
+  check_flag(&flag, "IDAGetNumNonlinSolvIters", 1);
+  flag = IDAGetNumResEvals(mem, &nre);
+  check_flag(&flag, "IDAGetNumResEvals", 1);
+  flag = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&flag, "IDAGetNumErrTestFails", 1);
+  flag = IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  check_flag(&flag, "IDAGetNumNonlinSolvConvFails", 1);
+  flag = IDADlsGetNumJacEvals(mem, &nje);
+  check_flag(&flag, "IDADlsGetNumJacEvals", 1);
+  flag = IDADlsGetNumResEvals(mem, &nreLS);
+  check_flag(&flag, "IDADlsGetNumResEvals", 1);
+
+  printf("-----------------------------------------------------------\n");
+  printf("Final run statistics: \n\n");
+  printf("Number of steps                    = %ld\n", nst);
+  printf("Number of residual evaluations     = %ld\n", nre+nreLS);
+  printf("Number of Jacobian evaluations     = %ld\n", nje);
+  printf("Number of nonlinear iterations     = %ld\n", nni);
+  printf("Number of error test failures      = %ld\n", netf);
+  printf("Number of nonlinear conv. failures = %ld\n", ncfn);
+
+}
+
+/* 
+ * Fweb: Rate function for the food-web problem.                        
+ * This routine computes the right-hand sides of the system equations,   
+ * consisting of the diffusion term and interaction term.                
+ * The interaction term is computed by the function WebRates.            
+ */
+
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate,  
+                 UserData webdata)
+{ 
+  long int jx, jy, is, idyu, idyl, idxu, idxl;
+  realtype xx, yy, *cxy, *ratesxy, *cratexy, dcyli, dcyui, dcxli, dcxui;
+  
+  /* Loop over grid points, evaluate interaction vector (length ns),
+     form diffusion difference terms, and load crate.                    */
+  
+  for (jy = 0; jy < MY; jy++) {
+    yy = (webdata->dy) * jy ;
+    idyu = (jy!=MY-1) ? NSMX : -NSMX;
+    idyl = (jy!= 0  ) ? NSMX : -NSMX;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = (webdata->dx) * jx;
+      idxu = (jx!= MX-1) ?  NUM_SPECIES : -NUM_SPECIES;
+      idxl = (jx!=  0  ) ?  NUM_SPECIES : -NUM_SPECIES;
+      cxy = IJ_Vptr(cc,jx,jy);
+      ratesxy = IJ_Vptr(webdata->rates,jx,jy);
+      cratexy = IJ_Vptr(crate,jx,jy);
+      
+      /* Get interaction vector at this grid point. */
+      WebRates(xx, yy, cxy, ratesxy, webdata);
+      
+      /* Loop over species, do differencing, load crate segment. */
+#pragma omp parallel for default(shared) private(is, dcyli, dcyui, dcxli, dcxui) schedule(static)
+      for (is = 0; is < NUM_SPECIES; is++) {
+        
+        /* Differencing in y. */
+        dcyli = *(cxy+is) - *(cxy - idyl + is) ;
+        dcyui = *(cxy + idyu + is) - *(cxy+is);
+        
+        /* Differencing in x. */
+        dcxli = *(cxy+is) - *(cxy - idxl + is);
+        dcxui = *(cxy + idxu +is) - *(cxy+is);
+        
+        /* Compute the crate values at (xx,yy). */
+        cratexy[is] = coy[is] * (dcyui - dcyli) +
+          cox[is] * (dcxui - dcxli) + ratesxy[is];
+        
+      } /* End is loop */
+    } /* End of jx loop */
+  } /* End of jy loop */
+  
+}
+
+/* 
+ * WebRates: Evaluate reaction rates at a given spatial point.
+ * At a given (x,y), evaluate the array of ns reaction terms R.
+ */
+
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy,
+                     UserData webdata)
+{
+  int is;
+  realtype fac;
+  
+  for (is = 0; is < NUM_SPECIES; is++)
+    ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]);
+  
+  fac = ONE + ALPHA*xx*yy + BETA*sin(FOURPI*xx)*sin(FOURPI*yy);
+   
+  for (is = 0; is < NUM_SPECIES; is++)  
+    ratesxy[is] = cxy[is]*( bcoef[is]*fac + ratesxy[is] );
+  
+}
+
+/*
+ * dotprod: dot product routine for realtype arrays, for use by WebRates.    
+ */
+
+static realtype dotprod(long int size, realtype *x1, realtype *x2)
+{
+  long int i;
+  realtype *xx1, *xx2, temp = ZERO;
+  
+  xx1 = x1; xx2 = x2;
+  for (i = 0; i < size; i++) temp += (*xx1++) * (*xx2++);
+  return(temp);
+  
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  if (opt == 0 && flagvalue == NULL) {
+    /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1); 
+  }
+
+  return(0);
+}
diff --git a/examples/idas/C_openmp/idasFoodWeb_bnd_omp.out b/examples/idas/C_openmp/idasFoodWeb_bnd_omp.out
new file mode 100644
index 0000000..2fe8ab1
--- /dev/null
+++ b/examples/idas/C_openmp/idasFoodWeb_bnd_omp.out
@@ -0,0 +1,44 @@
+
+idasFoodWeb_bnd_omp: Predator-prey DAE OpenMP example problem for IDAS 
+
+Number of species ns: 2     Mesh dimensions: 20 x 20     System size: 800
+Tolerance parameters:  rtol = 1e-05   atol = 1e-05
+Linear solver: IDABAND,  Band parameters mu = 40, ml = 40
+CalcIC called to correct initial predator concentrations.
+
+-----------------------------------------------------------
+  t        bottom-left  top-right    | nst  k      h
+-----------------------------------------------------------
+
+0.00e+00   1.0000e+01   1.0000e+01   |   0  0   1.6310e-08
+           1.0000e+05   1.0000e+05   |
+
+1.00e-03   1.0318e+01   1.0827e+01   |  32  4   1.0823e-04
+           1.0319e+05   1.0822e+05   |
+
+1.00e-02   1.6188e+02   1.9735e+02   | 127  4   1.4203e-04
+           1.6189e+06   1.9734e+06   |
+
+1.00e-01   2.4019e+02   2.7072e+02   | 235  1   3.9160e-02
+           2.4019e+06   2.7072e+06   |
+
+4.00e-01   2.4019e+02   2.7072e+02   | 238  1   3.1328e-01
+           2.4019e+06   2.7072e+06   |
+
+7.00e-01   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
+           2.4019e+06   2.7072e+06   |
+
+1.00e+00   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
+           2.4019e+06   2.7072e+06   |
+
+-----------------------------------------------------------
+Final run statistics: 
+
+Number of steps                    = 239
+Number of residual evaluations     = 3339
+Number of Jacobian evaluations     = 36
+Number of nonlinear iterations     = 421
+Number of error test failures      = 3
+Number of nonlinear conv. failures = 0
+num_threads = 4
+
diff --git a/examples/idas/C_openmp/idasFoodWeb_kry_omp.c b/examples/idas/C_openmp/idasFoodWeb_kry_omp.c
new file mode 100644
index 0000000..2365ca9
--- /dev/null
+++ b/examples/idas/C_openmp/idasFoodWeb_kry_omp.c
@@ -0,0 +1,841 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ * -----------------------------------------------------------------
+ * Example program for IDAS: Food web problem, OpenMP, GMRES, 
+ * user-supplied preconditioner
+ *
+ * This example program uses the IDASPGMR as the linear 
+ * solver, and IDACalcIC for initial condition calculation.
+ *
+ * The mathematical problem solved in this example is a DAE system
+ * that arises from a system of partial differential equations after
+ * spatial discretization. The PDE system is a food web population
+ * model, with predator-prey interaction and diffusion on the unit
+ * square in two dimensions. The dependent variable vector is:
+ *
+ *         1   2         ns
+ *   c = (c , c ,  ..., c  ) , ns = 2 * np
+ *
+ * and the PDE's are as follows:
+ *
+ *     i             i      i
+ *   dc /dt = d(i)*(c    + c  )  +  R (x,y,c)   (i = 1,...,np)
+ *                   xx     yy       i
+ *
+ *              i      i
+ *   0 = d(i)*(c    + c  )  +  R (x,y,c)   (i = np+1,...,ns)
+ *              xx     yy       i
+ *
+ *   where the reaction terms R are:
+ *
+ *                   i             ns         j
+ *   R  (x,y,c)  =  c  * (b(i)  + sum a(i,j)*c )
+ *    i                           j=1
+ *
+ * The number of species is ns = 2 * np, with the first np being
+ * prey and the last np being predators. The coefficients a(i,j),
+ * b(i), d(i) are:
+ *
+ *  a(i,i) = -AA   (all i)
+ *  a(i,j) = -GG   (i <= np , j >  np)
+ *  a(i,j) =  EE   (i >  np, j <= np)
+ *  all other a(i,j) = 0
+ *  b(i) = BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i <= np)
+ *  b(i) =-BB*(1+ alpha * x*y + beta*sin(4 pi x)*sin(4 pi y)) (i  > np)
+ *  d(i) = DPREY   (i <= np)
+ *  d(i) = DPRED   (i > np)
+ *
+ * The various scalar parameters required are set using '#define'
+ * statements or directly in routine InitUserData. In this program,
+ * np = 1, ns = 2. The boundary conditions are homogeneous Neumann:
+ * normal derivative = 0.
+ *
+ * A polynomial in x and y is used to set the initial values of the
+ * first np variables (the prey variables) at each x,y location,
+ * while initial values for the remaining (predator) variables are
+ * set to a flat value, which is corrected by IDACalcIC.
+ *
+ * The PDEs are discretized by central differencing on a MX by MY
+ * mesh.
+ *
+ * The DAE system is solved by IDAS using the IDABAND linear solver.
+ * Output is printed at t = 0, .001, .01, .1, .4, .7, 1.
+ *
+ * Optionally, we can set the number of threads from environment 
+ * variable or command line. To check the current value for number
+ * of threads from environment:
+ *      % echo $OMP_NUM_THREADS
+ *
+ * Execution:
+ *
+ * If the user want to use the default value or the number of threads 
+ * from environment value:
+ *      % ./idasFoodWeb_kry_omp 
+ * If the user want to specify the number of threads to use
+ *      % ./idasFoodWeb_kry_omp num_threads
+ * where num_threads is the number of threads the user want to use 
+ *
+ * -----------------------------------------------------------------
+ * References:
+ * [1] Peter N. Brown and Alan C. Hindmarsh,
+ *     Reduced Storage Matrix Methods in Stiff ODE systems, Journal
+ *     of Applied Mathematics and Computation, Vol. 31 (May 1989),
+ *     pp. 40-91.
+ *
+ * [2] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Using Krylov Methods in the Solution of Large-Scale
+ *     Differential-Algebraic Systems, SIAM J. Sci. Comput., 15
+ *     (1994), pp. 1467-1488.
+ *
+ * [3] Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold,
+ *     Consistent Initial Condition Calculation for Differential-
+ *     Algebraic Systems, SIAM J. Sci. Comput., 19 (1998),
+ *     pp. 1495-1512.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <idas/idas.h>
+#include <idas/idas_spgmr.h>
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_dense.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+/* Problem Constants. */
+
+#define NPREY       1              /* No. of prey (= no. of predators). */
+#define NUM_SPECIES 2*NPREY
+
+#define PI          RCONST(3.1415926535898)
+#define FOURPI      (RCONST(4.0)*PI)
+
+#define MX          20             /* MX = number of x mesh points      */
+#define MY          20             /* MY = number of y mesh points      */
+#define NSMX        (NUM_SPECIES * MX)
+#define NEQ         (NUM_SPECIES*MX*MY)
+#define AA          RCONST(1.0)    /* Coefficient in above eqns. for a  */
+#define EE          RCONST(10000.) /* Coefficient in above eqns. for a  */
+#define GG          RCONST(0.5e-6) /* Coefficient in above eqns. for a  */
+#define BB          RCONST(1.0)    /* Coefficient in above eqns. for b  */
+#define DPREY       RCONST(1.0)    /* Coefficient in above eqns. for d  */
+#define DPRED       RCONST(0.05)   /* Coefficient in above eqns. for d  */
+#define ALPHA       RCONST(50.)    /* Coefficient alpha in above eqns.  */
+#define BETA        RCONST(1000.)  /* Coefficient beta in above eqns.   */
+#define AX          RCONST(1.0)    /* Total range of x variable         */
+#define AY          RCONST(1.0)    /* Total range of y variable         */
+#define RTOL        RCONST(1.e-5)  /* Relative tolerance                */
+#define ATOL        RCONST(1.e-5)  /* Absolute tolerance                */
+#define NOUT        6              /* Number of output times            */
+#define TMULT       RCONST(10.0)   /* Multiplier for tout values        */
+#define TADD        RCONST(0.3)    /* Increment for tout values         */
+#define ZERO        RCONST(0.)     
+#define ONE         RCONST(1.0)    
+
+/* 
+ * User-defined vector and accessor macro: IJ_Vptr.
+ * IJ_Vptr is defined in order to express the underlying 3-D structure of 
+ * the dependent variable vector from its underlying 1-D storage (an N_Vector).
+ * IJ_Vptr(vv,i,j) returns a pointer to the location in vv corresponding to 
+ * species index is = 0, x-index ix = i, and y-index jy = j.                
+ */
+
+#define IJ_Vptr(vv,i,j) (&NV_Ith_OMP(vv, (i)*NUM_SPECIES + (j)*NSMX))
+
+/* Type: UserData.  Contains problem constants, etc. */
+
+typedef struct {
+  long int Neq, ns, np, mx, my;
+  realtype dx, dy, **acoef;
+  realtype cox[NUM_SPECIES], coy[NUM_SPECIES], bcoef[NUM_SPECIES];
+  realtype **PP[MX][MY];
+  long int *pivot[MX][MY];
+  N_Vector rates;
+  N_Vector ewt;
+  void *ida_mem;
+  int nthreads;
+} *UserData;
+
+/* Prototypes for functions called by the IDA Solver. */
+
+static int resweb(realtype time, N_Vector cc, N_Vector cp, N_Vector resval, 
+                  void *user_data);
+
+static int Precond(realtype tt,
+		   N_Vector cc, N_Vector cp, N_Vector rr, 
+		   realtype cj, void *user_data,
+		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int PSolve(realtype tt, 
+		  N_Vector cc, N_Vector cp, N_Vector rr,
+		  N_Vector rvec, N_Vector zvec,
+		  realtype cj, realtype delta, void *user_data,
+		  N_Vector tmp);
+
+/* Prototypes for private Helper Functions. */
+
+static void InitUserData(UserData webdata);
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata);
+static void PrintHeader(long int maxl, realtype rtol, realtype atol);
+static void PrintOutput(void *mem, N_Vector c, realtype t);
+static void PrintFinalStats(void *mem);
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate, UserData webdata);
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
+                     UserData webdata);
+static realtype dotprod(long int size, realtype *x1, realtype *x2);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{ 
+  void *mem;
+  UserData webdata;
+  N_Vector cc, cp, id;
+  int iout, jx, jy, flag;
+  long int maxl;
+  realtype rtol, atol, t0, tout, tret;
+  int num_threads;
+
+  mem = NULL;
+  webdata = NULL;
+  cc = cp = id = NULL;
+
+  /* Set the number of threads to use */
+  num_threads = 1;   /* default value */
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();    /* overwrite with OMP_NUM_THREADS */
+#endif
+  if (argc > 1)
+    num_threads = strtol(argv[1], NULL, 0);
+
+  /* Allocate and initialize user data block webdata. */
+
+  webdata = (UserData) malloc(sizeof *webdata);
+  webdata->rates = N_VNew_OpenMP(NEQ, num_threads);
+  webdata->acoef = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+  webdata->ewt = N_VNew_OpenMP(NEQ, num_threads);
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy < MY; jy++) {
+      (webdata->pivot)[jx][jy] = newLintArray(NUM_SPECIES);
+      (webdata->PP)[jx][jy] = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+    }
+  }
+  webdata->nthreads = num_threads;
+
+  InitUserData(webdata);
+
+  /* Allocate N-vectors and initialize cc, cp, and id. */
+
+  cc  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cc, "N_VNew_OpenMP", 0)) return(1);
+
+  cp  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)cp, "N_VNew_OpenMP", 0)) return(1);
+
+  id  = N_VNew_OpenMP(NEQ, num_threads);
+  if(check_flag((void *)id, "N_VNew_OpenMP", 0)) return(1);
+  
+  SetInitialProfiles(cc, cp, id, webdata);
+  
+  /* Set remaining inputs to IDAMalloc. */
+  
+  t0 = ZERO;
+  rtol = RTOL; 
+  atol = ATOL;
+
+  /* Call IDACreate and IDAMalloc to initialize IDA. */
+  
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+
+  flag = IDASetUserData(mem, webdata);
+  if(check_flag(&flag, "IDASetUserData", 1)) return(1);
+
+  flag = IDASetId(mem, id);
+  if(check_flag(&flag, "IDASetId", 1)) return(1);
+
+  flag = IDAInit(mem, resweb, t0, cc, cp);
+  if(check_flag(&flag, "IDAInit", 1)) return(1);
+
+  flag = IDASStolerances(mem, rtol, atol);
+  if(check_flag(&flag, "IDASStolerances", 1)) return(1);
+
+  webdata->ida_mem = mem;
+
+  /* Call IDASpgmr to specify the IDA linear solver. */
+
+  maxl = 16;                    /* max dimension of the Krylov subspace */
+  flag = IDASpgmr(mem, maxl);
+  if(check_flag(&flag, "IDASpgmr", 1)) return(1);
+
+  flag = IDASpilsSetPreconditioner(mem, Precond, PSolve);
+  if(check_flag(&flag, "IDASpilsSetPreconditioner", 1)) return(1);
+
+  /* Call IDACalcIC (with default options) to correct the initial values. */
+
+  tout = RCONST(0.001);
+  flag = IDACalcIC(mem, IDA_YA_YDP_INIT, tout);
+  if(check_flag(&flag, "IDACalcIC", 1)) return(1);
+  
+  /* Print heading, basic parameters, and initial values. */
+
+  PrintHeader(maxl, rtol, atol);
+  PrintOutput(mem, cc, ZERO);
+  
+  /* Loop over iout, call IDASolve (normal mode), print selected output. */
+  
+  for (iout = 1; iout <= NOUT; iout++) {
+    
+    flag = IDASolve(mem, tout, &tret, cc, cp, IDA_NORMAL);
+    if(check_flag(&flag, "IDASolve", 1)) return(flag);
+    
+    PrintOutput(mem, cc, tret);
+    
+    if (iout < 3) tout *= TMULT; else tout += TADD;
+    
+  }
+  
+  /* Print final statistics and free memory. */  
+  
+  PrintFinalStats(mem);
+  printf("num_threads = %i\n\n", num_threads);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+
+  N_VDestroy_OpenMP(cc);
+  N_VDestroy_OpenMP(cp);
+  N_VDestroy_OpenMP(id);
+
+
+  destroyMat(webdata->acoef);
+  N_VDestroy_OpenMP(webdata->rates);
+  N_VDestroy_OpenMP(webdata->ewt);
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy < MY; jy ++) {
+      destroyArray((webdata->pivot)[jx][jy]);
+      destroyMat((webdata->PP)[jx][jy]);
+    }
+  }
+  free(webdata);
+
+  return(0);
+}
+
+/* Define lines for readability in later routines */ 
+
+#define acoef  (webdata->acoef)
+#define bcoef  (webdata->bcoef)
+#define cox    (webdata->cox)
+#define coy    (webdata->coy)
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDA
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * resweb: System residual function for predator-prey system.
+ * This routine calls Fweb to get all the right-hand sides of the
+ * equations, then loads the residual vector accordingly,
+ * using cp in the case of prey species.                 
+ */
+
+static int resweb(realtype tt, N_Vector cc, N_Vector cp, 
+                  N_Vector res,  void *user_data)
+{
+  long int jx, jy, is, yloc, loc, np;
+  realtype *resv, *cpv;
+  UserData webdata;
+  
+  webdata = (UserData)user_data;
+  
+  cpv = NV_DATA_OMP(cp);
+  resv = NV_DATA_OMP(res);
+  np = webdata->np;
+  
+  /* Call Fweb to set res to vector of right-hand sides. */
+  Fweb(tt, cc, res, webdata);
+  
+  /* Loop over all grid points, setting residual values appropriately
+     for differential or algebraic components.                        */
+#pragma omp parallel for default(shared) private(jy, jx, is, yloc, loc) schedule(static) num_threads(webdata->nthreads)  
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np)
+          resv[loc+is] = cpv[loc+is] - resv[loc+is];
+        else
+          resv[loc+is] = -resv[loc+is];
+      }
+    }
+  }
+  
+  return(0);
+  
+}
+
+
+static int Precond(realtype tt, 
+		   N_Vector cc, N_Vector cp, N_Vector rr, 
+		   realtype cj, void *user_data,
+		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  int flag;
+  realtype uround, xx, yy, del_x, del_y;
+  realtype **Pxy, *ratesxy, *Pxycol, *cxy, *cpxy, *ewtxy, cctmp;
+  realtype inc, fac, sqru, perturb_rates[NUM_SPECIES];
+  int is, js, jx, jy, ret;
+  void *mem;
+  N_Vector ewt;
+  realtype hh;
+  UserData webdata;
+
+  webdata = (UserData) user_data;
+  del_x = webdata->dx;
+  del_y = webdata->dy;
+
+  uround = UNIT_ROUNDOFF;
+  sqru = SUNRsqrt(uround);
+
+  mem = webdata->ida_mem;
+  ewt = webdata->ewt;
+  flag = IDAGetErrWeights(mem, ewt);
+  if(check_flag(&flag, "IDAGetErrWeights", 1)) return(1);
+  flag = IDAGetCurrentStep(mem, &hh);
+  if(check_flag(&flag, "IDAGetCurrentStep", 1)) return(1);
+
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * del_y;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * del_x;
+      Pxy = (webdata->PP)[jx][jy];
+      cxy = IJ_Vptr(cc, jx, jy);
+      cpxy = IJ_Vptr(cp, jx, jy);
+      ewtxy = IJ_Vptr(ewt, jx, jy);
+      ratesxy = IJ_Vptr((webdata->rates), jx, jy);
+
+      for (js = 0; js < NUM_SPECIES; js++) {
+	inc = sqru*(SUNMAX(SUNRabs(cxy[js]), SUNMAX(hh*SUNRabs(cpxy[js]), ONE/ewtxy[js])));
+	cctmp = cxy[js];
+	cxy[js] += inc;
+	fac = -ONE/inc;
+
+	WebRates(xx, yy, cxy, perturb_rates, webdata);
+
+	Pxycol = Pxy[js];
+	
+	for (is = 0; is < NUM_SPECIES; is++)
+	  Pxycol[is] = (perturb_rates[is] - ratesxy[is])*fac;
+
+	if (js < 1) Pxycol[js] += cj;
+	
+	cxy[js] = cctmp;
+      }
+
+      ret = denseGETRF(Pxy, NUM_SPECIES, NUM_SPECIES, (webdata->pivot)[jx][jy]);
+
+      if (ret != 0) return(1);
+    }
+  }
+
+  return(0);
+
+}
+
+
+static int PSolve(realtype tt, 
+		  N_Vector cc, N_Vector cp, N_Vector rr, 
+		  N_Vector rvec, N_Vector zvec,
+		  realtype cj, realtype dalta, 
+		  void *user_data, N_Vector tmp) 
+{
+  realtype **Pxy, *zxy;
+  long int *pivot;
+  int jx, jy;
+  UserData webdata;
+  
+  webdata = (UserData) user_data;
+
+  N_VScale(ONE, rvec, zvec);
+
+#pragma omp parallel for collapse(2) default(shared) private(jx, jy, zxy, Pxy, pivot) schedule(static) num_threads(webdata->nthreads)
+  for (jx = 0; jx < MX; jx++) {
+    for (jy = 0; jy <MY; jy++) {
+      
+      zxy = IJ_Vptr(zvec, jx, jy);
+      Pxy = (webdata->PP)[jx][jy];
+      pivot = (webdata->pivot)[jx][jy];
+      denseGETRS(Pxy, NUM_SPECIES, pivot, zxy);
+    }
+  }
+  
+  return(0);
+
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * InitUserData: Load problem constants in webdata (of type UserData).   
+ */
+
+static void InitUserData(UserData webdata)
+{
+  int i, j, np;
+  realtype *a1,*a2, *a3, *a4, dx2, dy2;
+
+  webdata->mx = MX;
+  webdata->my = MY;
+  webdata->ns = NUM_SPECIES;
+  webdata->np = NPREY;
+  webdata->dx = AX/(MX-1);
+  webdata->dy = AY/(MY-1);
+  webdata->Neq= NEQ;
+  
+  /* Set up the coefficients a and b, and others found in the equations. */
+  np = webdata->np;
+  dx2 = (webdata->dx)*(webdata->dx); dy2 = (webdata->dy)*(webdata->dy);
+  
+  for (i = 0; i < np; i++) {
+    a1 = &(acoef[i][np]);
+    a2 = &(acoef[i+np][0]);
+    a3 = &(acoef[i][0]);
+    a4 = &(acoef[i+np][np]);
+    /*  Fill in the portion of acoef in the four quadrants, row by row. */
+    for (j = 0; j < np; j++) {
+      *a1++ =  -GG;
+      *a2++ =   EE;
+      *a3++ = ZERO;
+      *a4++ = ZERO;
+    }
+    
+    /* Reset the diagonal elements of acoef to -AA. */
+    acoef[i][i] = -AA; acoef[i+np][i+np] = -AA;
+    
+    /* Set coefficients for b and diffusion terms. */
+    bcoef[i] = BB; bcoef[i+np] = -BB;
+    cox[i] = DPREY/dx2; cox[i+np] = DPRED/dx2;
+    coy[i] = DPREY/dy2; coy[i+np] = DPRED/dy2;
+  }
+  
+}
+
+/* 
+ * SetInitialProfiles: Set initial conditions in cc, cp, and id.
+ * A polynomial profile is used for the prey cc values, and a constant
+ * (1.0e5) is loaded as the initial guess for the predator cc values.
+ * The id values are set to 1 for the prey and 0 for the predators.
+ * The prey cp values are set according to the given system, and
+ * the predator cp values are set to zero.                               
+ */
+
+static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
+                               UserData webdata)
+{
+  long int loc, yloc, is, jx, jy, np;
+  realtype xx, yy, xyfactor;
+  realtype *ccv, *cpv, *idv;
+  
+  ccv = NV_DATA_OMP(cc);
+  cpv = NV_DATA_OMP(cp);
+  idv = NV_DATA_OMP(id);
+  np = webdata->np;
+  
+  /* Loop over grid, load cc values and id values. */
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy * webdata->dy;
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx * webdata->dx;
+      xyfactor = RCONST(16.0)*xx*(ONE-xx)*yy*(ONE-yy);
+      xyfactor *= xyfactor;
+      loc = yloc + NUM_SPECIES*jx;
+       
+      for (is = 0; is < NUM_SPECIES; is++) {
+        if (is < np) {
+          ccv[loc+is] = RCONST(10.0) + (realtype)(is+1) * xyfactor;
+          idv[loc+is] = ONE;
+        }
+        else {
+	  ccv[loc+is] = RCONST(1.0e5);
+          idv[loc+is] = ZERO;
+        }
+      }
+    }
+  }
+  
+  /* Set c' for the prey by calling the function Fweb. */
+  Fweb(ZERO, cc, cp, webdata);
+  
+  /* Set c' for predators to 0. */
+  for (jy = 0; jy < MY; jy++) {
+    yloc = NSMX * jy;
+    for (jx = 0; jx < MX; jx++) {
+      loc = yloc + NUM_SPECIES * jx;
+      for (is = np; is < NUM_SPECIES; is++) {
+        cpv[loc+is] = ZERO;
+      }
+    }
+  }
+}
+
+/*
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(long int maxl, realtype rtol, realtype atol)
+{
+  printf("\nidasFoodWeb_kry_omp: Predator-prey DAE OpenMP example problem for IDAS \n\n");
+  printf("Number of species ns: %d", NUM_SPECIES);
+  printf("     Mesh dimensions: %d x %d", MX, MY);
+  printf("     System size: %d\n", NEQ);
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
+#endif
+  printf("Linear solver: IDASpgmr,  Spgmr parameters maxl = %ld\n",maxl);
+  printf("CalcIC called to correct initial predator concentrations.\n\n");
+  printf("-----------------------------------------------------------\n");
+  printf("  t        bottom-left  top-right");
+  printf("    | nst  k      h\n");
+  printf("-----------------------------------------------------------\n\n");
+  
+}
+
+/* 
+ * PrintOutput: Print output values at output time t = tt.
+ * Selected run statistics are printed.  Then values of the concentrations
+ * are printed for the bottom left and top right grid points only.  
+ */
+
+static void PrintOutput(void *mem, N_Vector c, realtype t)
+{
+  int i, kused, flag;
+  long int nst;
+  realtype *c_bl, *c_tr, hused;
+
+  flag = IDAGetLastOrder(mem, &kused);
+  check_flag(&flag, "IDAGetLastOrder", 1);
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetLastStep(mem, &hused);
+  check_flag(&flag, "IDAGetLastStep", 1);
+  
+  c_bl = IJ_Vptr(c,0,0);
+  c_tr = IJ_Vptr(c,MX-1,MY-1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("%8.2Le %12.4Le %12.4Le   | %3ld  %1d %12.4Le\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4Le %12.4Le   |\n",c_bl[i],c_tr[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION) 
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#else
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
+  for (i=1;i<NUM_SPECIES;i++)
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
+#endif
+
+  printf("\n");
+}
+
+/* 
+ * PrintFinalStats: Print final run data contained in iopt.              
+ */
+
+static void PrintFinalStats(void *mem)
+{ 
+  long int nst, nre, sli, netf, nps, npevals, nrevalsLS;
+  int flag;
+
+  flag = IDAGetNumSteps(mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDASpilsGetNumLinIters(mem, &sli);
+  check_flag(&flag, "IDAGetNumNonlinSolvIters", 1);
+  flag = IDAGetNumResEvals(mem, &nre);
+  check_flag(&flag, "IDAGetNumResEvals", 1);
+  flag = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&flag, "IDAGetNumErrTestFails", 1);
+  flag = IDASpilsGetNumPrecSolves(mem, &nps);
+  check_flag(&flag, "IDAGetNumNonlinSolvConvFails", 1);
+  flag = IDASpilsGetNumPrecEvals(mem, &npevals);
+  check_flag(&flag, "IDADlsGetNumJacEvals", 1);
+  flag = IDASpilsGetNumResEvals(mem, &nrevalsLS);
+  check_flag(&flag, "IDADlsGetNumResEvals", 1);
+
+  printf("-----------------------------------------------------------\n");
+  printf("Final run statistics: \n\n");
+  printf("Number of steps                       = %ld\n", nst);
+  printf("Number of residual evaluations        = %ld\n", nre);
+  printf("Number of Preconditioner evaluations  = %ld\n", npevals);
+  printf("Number of linear iterations           = %ld\n", sli);
+  printf("Number of error test failures         = %ld\n", netf);
+  printf("Number of precond solve fun called    = %ld\n", nps);
+
+}
+
+/* 
+ * Fweb: Rate function for the food-web problem.                        
+ * This routine computes the right-hand sides of the system equations,   
+ * consisting of the diffusion term and interaction term.                
+ * The interaction term is computed by the function WebRates.            
+ */
+
+static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate,  
+                 UserData webdata)
+{ 
+  long int jx, jy, is, idyu, idyl, idxu, idxl;
+  realtype xx, yy, *cxy, *ratesxy, *cratexy, dcyli, dcyui, dcxli, dcxui;
+  
+  /* Loop over grid points, evaluate interaction vector (length ns),
+     form diffusion difference terms, and load crate.                    */
+  
+  for (jy = 0; jy < MY; jy++) {
+    yy = (webdata->dy) * jy ;
+    idyu = (jy!=MY-1) ? NSMX : -NSMX;
+    idyl = (jy!= 0  ) ? NSMX : -NSMX;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = (webdata->dx) * jx;
+      idxu = (jx!= MX-1) ?  NUM_SPECIES : -NUM_SPECIES;
+      idxl = (jx!=  0  ) ?  NUM_SPECIES : -NUM_SPECIES;
+      cxy = IJ_Vptr(cc,jx,jy);
+      ratesxy = IJ_Vptr(webdata->rates,jx,jy);
+      cratexy = IJ_Vptr(crate,jx,jy);
+      
+      /* Get interaction vector at this grid point. */
+      WebRates(xx, yy, cxy, ratesxy, webdata);
+      
+      /* Loop over species, do differencing, load crate segment. */
+#pragma omp parallel for default(shared) private(is, dcyli, dcyui, dcxli, dcxui) schedule(static) num_threads(webdata->nthreads)
+      for (is = 0; is < NUM_SPECIES; is++) {
+        
+        /* Differencing in y. */
+        dcyli = *(cxy+is) - *(cxy - idyl + is) ;
+        dcyui = *(cxy + idyu + is) - *(cxy+is);
+        
+        /* Differencing in x. */
+        dcxli = *(cxy+is) - *(cxy - idxl + is);
+        dcxui = *(cxy + idxu +is) - *(cxy+is);
+        
+        /* Compute the crate values at (xx,yy). */
+        cratexy[is] = coy[is] * (dcyui - dcyli) +
+          cox[is] * (dcxui - dcxli) + ratesxy[is];
+        
+      } /* End is loop */
+    } /* End of jx loop */
+  } /* End of jy loop */
+  
+}
+
+/* 
+ * WebRates: Evaluate reaction rates at a given spatial point.
+ * At a given (x,y), evaluate the array of ns reaction terms R.
+ */
+
+static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy,
+                     UserData webdata)
+{
+  int is;
+  realtype fac;
+  
+  for (is = 0; is < NUM_SPECIES; is++)
+    ratesxy[is] = dotprod(NUM_SPECIES, cxy, acoef[is]);
+  
+  fac = ONE + ALPHA*xx*yy + BETA*sin(FOURPI*xx)*sin(FOURPI*yy);
+  
+  for (is = 0; is < NUM_SPECIES; is++)  
+    ratesxy[is] = cxy[is]*( bcoef[is]*fac + ratesxy[is] );
+  
+}
+
+/*
+ * dotprod: dot product routine for realtype arrays, for use by WebRates.    
+ */
+
+static realtype dotprod(long int size, realtype *x1, realtype *x2)
+{
+  long int i;
+  realtype *xx1, *xx2, temp = ZERO;
+  
+  xx1 = x1; xx2 = x2;
+  for (i = 0; i < size; i++) temp += (*xx1++) * (*xx2++);
+  return(temp);
+  
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  if (opt == 0 && flagvalue == NULL) {
+    /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1); 
+  }
+
+  return(0);
+}
diff --git a/examples/idas/C_openmp/idasFoodWeb_kry_omp.out b/examples/idas/C_openmp/idasFoodWeb_kry_omp.out
new file mode 100644
index 0000000..e99e4b5
--- /dev/null
+++ b/examples/idas/C_openmp/idasFoodWeb_kry_omp.out
@@ -0,0 +1,44 @@
+
+idasFoodWeb_kry_omp: Predator-prey DAE OpenMP example problem for IDAS 
+
+Number of species ns: 2     Mesh dimensions: 20 x 20     System size: 800
+Tolerance parameters:  rtol = 1e-05   atol = 1e-05
+Linear solver: IDASpgmr,  Spgmr parameters maxl = 16
+CalcIC called to correct initial predator concentrations.
+
+-----------------------------------------------------------
+  t        bottom-left  top-right    | nst  k      h
+-----------------------------------------------------------
+
+0.00e+00   1.0000e+01   1.0000e+01   |   0  0   1.6310e-08
+           1.0000e+05   1.0000e+05   |
+
+1.00e-03   1.0318e+01   1.0827e+01   |  33  4   9.7404e-05
+           1.0319e+05   1.0822e+05   |
+
+1.00e-02   1.6189e+02   1.9735e+02   |  86  4   1.7533e-04
+           1.6189e+06   1.9735e+06   |
+
+1.00e-01   2.4019e+02   2.7072e+02   | 163  1   4.0396e-02
+           2.4019e+06   2.7072e+06   |
+
+4.00e-01   2.4019e+02   2.7072e+02   | 166  1   3.2316e-01
+           2.4019e+06   2.7072e+06   |
+
+7.00e-01   2.4019e+02   2.7072e+02   | 167  1   6.4633e-01
+           2.4019e+06   2.7072e+06   |
+
+1.00e+00   2.4019e+02   2.7072e+02   | 167  1   6.4633e-01
+           2.4019e+06   2.7072e+06   |
+
+-----------------------------------------------------------
+Final run statistics: 
+
+Number of steps                       = 167
+Number of residual evaluations        = 208
+Number of Preconditioner evaluations  = 25
+Number of linear iterations           = 1040
+Number of error test failures         = 0
+Number of precond solve fun called    = 1248
+num_threads = 4
+
diff --git a/examples/idas/parallel/CMakeLists.txt b/examples/idas/parallel/CMakeLists.txt
index b5d7d86..24978c8 100644
--- a/examples/idas/parallel/CMakeLists.txt
+++ b/examples/idas/parallel/CMakeLists.txt
@@ -1,28 +1,34 @@
 # ---------------------------------------------------------------
-# $Revision: 1.5 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4137 $
+# $Date: 2014-06-15 12:26:15 -0700 (Sun, 15 Jun 2014) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for IDAS parallel examples
 
 
 # Add variable IDAS_examples with the names of the parallel IDAS examples
-
+# "name\;nodes\;tasks"
 SET(IDAS_examples
-  idasBruss_ASAp_kry_bbd_p
-  idasBruss_FSA_kry_bbd_p
-  idasBruss_kry_bbd_p
-  idasFoodWeb_kry_bbd_p
-  idasFoodWeb_kry_p
-  idasHeat2D_FSA_kry_bbd_p
-  idasHeat2D_kry_bbd_p
-  idasHeat2D_kry_p
+  "idasBruss_ASAp_kry_bbd_p\;1\;4"
+  "idasBruss_FSA_kry_bbd_p\;1\;4"
+  "idasBruss_kry_bbd_p\;1\;4"
+  "idasFoodWeb_kry_bbd_p\;1\;4"
+  "idasFoodWeb_kry_p\;1\;4"
+  "idasHeat2D_FSA_kry_bbd_p\;1\;4\;-sensi stg t"
+  "idasHeat2D_kry_bbd_p\;1\;4"
+  "idasHeat2D_kry_p\;1\;4"
+
   )
 
 # Check whether we use MPI compiler scripts.
@@ -52,14 +58,44 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${IDAS_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
 # Add the build and install targets for each IDAS example
 
-FOREACH(example ${IDAS_examples})
-  ADD_EXECUTABLE(${example} ${example}.c)
+SET(ADDED_EXECUTABLES "")
+FOREACH(example_tuple ${IDAS_examples})
+  # first item is example
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+
+  # Only need to add the executable once
+  LIST(FIND ADDED_EXECUTABLES ${example} index)
+  IF(index EQUAL -1)
+    LIST(APPEND ADDED_EXECUTABLES ${example})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  ENDIF(index EQUAL -1)
+
+  # Optional 4th element is test arguments
+  LIST(LENGTH example_tuple n)
+  IF(n EQUAL 4)
+    LIST(GET example_tuple 3 test_args)
+    STRING(REGEX REPLACE " " "_" test_name ${example}_${test_args})
+    SUNDIALS_ADD_TEST(${test_name} ${example} MPI_NPROCS ${number_of_tasks} TEST_ARGS ${test_args})
+  ELSE()
+    SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
+  ENDIF()
+
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPICC)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -67,7 +103,7 @@ FOREACH(example ${IDAS_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${IDAS_examples})
+ENDFOREACH(example_tuple ${IDAS_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -77,7 +113,10 @@ IF(EXAMPLES_INSTALL)
   # Prepare substitution variables for Makefile and/or CMakeLists templates
   SET(SOLVER "IDAS")
   SET(SOLVER_LIB "sundials_idas")
-  LIST2STRING(IDAS_examples EXAMPLES)
+  FOREACH(example_tuple ${IDAS_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${IDAS_examples})
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/idas/parallel/Makefile.in b/examples/idas/parallel/Makefile.in
deleted file mode 100644
index 1e4098b..0000000
--- a/examples/idas/parallel/Makefile.in
+++ /dev/null
@@ -1,117 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.11 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for IDA parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP         = @CPP@
-CPPFLAGS    = @CPPFLAGS@
-CC          = @CC@
-CFLAGS      = @CFLAGS@
-LDFLAGS     = @LDFLAGS@
-LIBS        = @LIBS@
-MPICC       = @MPICC@
-MPI_INC_DIR = @MPI_INC_DIR@
-MPI_LIB_DIR = @MPI_LIB_DIR@
-MPI_LIBS    = @MPI_LIBS@
-MPI_FLAGS   = @MPI_FLAGS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/idas/libsundials_idas.la $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = idasBruss_ASAp_kry_bbd_p \
-	   idasBruss_FSA_kry_bbd_p \
-	   idasBruss_kry_bbd_p \
-	   idasFoodWeb_kry_bbd_p \
-	   idasFoodWeb_kry_p \
-	   idasHeat2D_FSA_kry_bbd_p \
-	   idasHeat2D_kry_bbd_p \
-	   idasHeat2D_kry_p 
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(MPICC) $(CPPFLAGS) $(MPI_FLAGS) $(SUNDIALS_INCS) -I$(MPI_INC_DIR) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(MPICC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}$(OBJ_EXT) $(MPI_FLAGS) $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) -L$(MPI_LIB_DIR) $(MPI_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/idas/parallel
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/idas/parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/idas/parallel/README $(EXS_INSTDIR)/idas/parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/idas/parallel/$${i}.c   $(EXS_INSTDIR)/idas/parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/idas/parallel/$${i}.out $(EXS_INSTDIR)/idas/parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/idas/parallel/Makefile
-	rm -f $(EXS_INSTDIR)/idas/parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/idas/parallel/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/idas/parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/idas/parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/idas
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/idas/parallel/README b/examples/idas/parallel/README
index ad6dc83..661c144 100644
--- a/examples/idas/parallel/README
+++ b/examples/idas/parallel/README
@@ -9,14 +9,48 @@ List of parallel IDAS examples
   idasHeat2D_kry_bbd_p      : 2-D heat equation, BBD preconditioner
   idasHeat2D_kry_p          : 2-D heat equation, diagonal preconditioner
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c b/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c
index f2d162a..fe570fe 100644
--- a/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c
+++ b/examples/idas/parallel/idasBruss_ASAp_kry_bbd_p.c
@@ -199,7 +199,7 @@ static void PrintAdjSol(N_Vector uvB, N_Vector uvpB, UserData data);
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -326,7 +326,7 @@ int main(int argc, char *argv[])
   PrintOutput(mem, uv, tret, data, comm);
 
   /* Print each PE's portion of the solution in a separate file. */
-  //PrintSol(mem, uv, uvp, data, comm);
+  /* PrintSol(mem, uv, uvp, data, comm); */
 
   /* On PE 0, print final set of statistics. */  
   if (thispe == 0)  {
@@ -628,13 +628,13 @@ static void PrintHeader(int SystemSize, int maxl,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
   printf("Linear solver: IDASPGMR     Max. Krylov dimension maxl: %d\n", maxl);
   printf("Preconditioner: band-block-diagonal (IDABBDPRE), with parameters\n");
-  printf("     mudq = %d,  mldq = %d,  mukeep = %d,  mlkeep = %d\n",
+  printf("     mudq = %ld,  mldq = %ld,  mukeep = %ld,  mlkeep = %ld\n",
          mudq, mldq, mukeep, mlkeep);
 
   printf("-----------------------------------------------------------\n");
@@ -660,7 +660,7 @@ static void PrintOutput(void *mem, N_Vector uv, realtype tt,
 
   thispe = data->thispe; 
   npelast = data->npes - 1;
-  cdata = NV_DATA_P(uv);
+  cdata = N_VGetArrayPointer_Parallel(uv);
   
   /* Send conc. at top right mesh point from PE npes-1 to PE 0. */
   if (thispe == npelast) {
@@ -691,10 +691,10 @@ static void PrintOutput(void *mem, N_Vector uv, realtype tt,
     for (i=1;i<NUM_SPECIES;i++)
       printf("         %12.4Le %12.4Le   |\n",cdata[i],clast[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
+    printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
     for (i=1;i<NUM_SPECIES;i++)
-      printf("         %12.4le %12.4le   |\n",cdata[i],clast[i]);
+      printf("         %12.4e %12.4e   |\n",cdata[i],clast[i]);
 #else
     printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
@@ -749,7 +749,7 @@ static void PrintSol(void* mem, N_Vector uv, N_Vector uvp,
                (i)*NUM_SPECIES + (j)*NSMXSUB*npex);
         
       uvxy  = IJ_Vptr(uv, ix, jy);
-      //uvxy = (&NV_Ith_P(uv, (i)*NUM_SPECIES + (j)*NSMXSUB*npex ));
+      /* uvxy = (&NV_Ith_P(uv, (i)*NUM_SPECIES + (j)*NSMXSUB*npex )); */
       fprintf(fout, "%g\n%g\n", uvxy[0], uvxy[1]);
     }
   }    
@@ -858,7 +858,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
@@ -945,7 +945,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
   
   data = (UserData) user_data;
-  cdata = NV_DATA_P(uv);
+  cdata = N_VGetArrayPointer_Parallel(uv);
   
   /* Get comm, thispe, subgrid indices, data sizes, extended array cext. */
   
@@ -1162,7 +1162,7 @@ static int reslocal(long int Nlocal, realtype tt,
   data = (UserData) user_data;
 
   /* Get data pointers, subgrid data, array sizes, work array cext. */
-  uvdata = NV_DATA_P(uv);
+  uvdata = N_VGetArrayPointer_Parallel(uv);
 
   dx2 = dx * dx;
   dy2 = dy * dy;
@@ -1352,7 +1352,7 @@ static int resBlocal(long int Nlocal, realtype tt,
  
 
   /* Get data pointers, subgrid data, array sizes, work array cext. */
-  uvBdata = NV_DATA_P(uvB);
+  uvBdata = N_VGetArrayPointer_Parallel(uvB);
 
   dx2 = dx * dx;
   dy2 = dy * dy;
@@ -1432,7 +1432,7 @@ static int resBlocal(long int Nlocal, realtype tt,
         rrBxy[is] = uvpBxy[is] + eps[is]*( (dcxui-dcxli)/dx2 + (dcyui-dcyli)/dy2 );
       }
 
-      //now add rates
+      /* now add rates */
       rrBxy[0] += (uvBxy[0]-uvBxy[1])*(2*uvxy[0]*uvxy[1] - B) - uvBxy[0]; 
       rrBxy[1] += uvxy[0]*uvxy[0]*(uvBxy[0]-uvBxy[1]);
     }
diff --git a/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c b/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c
index 91b37c1..a52294b 100644
--- a/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c
+++ b/examples/idas/parallel/idasBruss_FSA_kry_bbd_p.c
@@ -168,7 +168,7 @@ static void PrintSol(void* mem, N_Vector uv, N_Vector uvp, UserData data,
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -513,13 +513,13 @@ static void PrintHeader(int SystemSize, int maxl,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
   printf("Linear solver: IDASPGMR     Max. Krylov dimension maxl: %d\n", maxl);
   printf("Preconditioner: band-block-diagonal (IDABBDPRE), with parameters\n");
-  printf("     mudq = %d,  mldq = %d,  mukeep = %d,  mlkeep = %d\n",
+  printf("     mudq = %ld,  mldq = %ld,  mukeep = %ld,  mlkeep = %ld\n",
          mudq, mldq, mukeep, mlkeep);
   printf("CalcIC called to correct initial concentrations \n\n");
   printf("-----------------------------------------------------------\n");
@@ -545,7 +545,7 @@ static void PrintOutput(void *mem, N_Vector uv, realtype tt,
 
   thispe = data->thispe; 
   npelast = data->npes - 1;
-  cdata = NV_DATA_P(uv);
+  cdata = N_VGetArrayPointer_Parallel(uv);
   
   /* Send conc. at top right mesh point from PE npes-1 to PE 0. */
   if (thispe == npelast) {
@@ -575,10 +575,10 @@ static void PrintOutput(void *mem, N_Vector uv, realtype tt,
     for (i=1;i<NUM_SPECIES;i++)
       printf("         %12.4Le %12.4Le   |\n",cdata[i],clast[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
+    printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
     for (i=1;i<NUM_SPECIES;i++)
-      printf("         %12.4le %12.4le   |\n",cdata[i],clast[i]);
+      printf("         %12.4e %12.4e   |\n",cdata[i],clast[i]);
 #else
     printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
@@ -688,7 +688,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
@@ -774,7 +774,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
   
   data = (UserData) user_data;
-  cdata = NV_DATA_P(uv);
+  cdata = N_VGetArrayPointer_Parallel(uv);
 
   /* Get comm, thispe, subgrid indices, data sizes, extended array cext. */  
   comm = data->comm;     
@@ -989,7 +989,7 @@ static int reslocal(long int Nlocal, realtype tt,
   data = (UserData) user_data;
 
   /* Get data pointers, subgrid data, array sizes, work array cext. */
-  uvdata = NV_DATA_P(uv);
+  uvdata = N_VGetArrayPointer_Parallel(uv);
 
   dx2 = dx * dx;
   dy2 = dy * dy;
@@ -1149,13 +1149,13 @@ static int integr(MPI_Comm comm, N_Vector uv, void *user_data, realtype *intval)
   data = (UserData) user_data;
 
   /* compute the integral on the (local) grid */
-  uvdata = NV_DATA_P(uv);
+  uvdata = N_VGetArrayPointer_Parallel(uv);
 
   *intval = 0;
 
   for (jy=1; jy<mysub; jy++)
     for (ix=1; ix<mxsub; ix++) 
-      //consider only u
+       /* consider only u */
       *intval += uvdata[ix*NUM_SPECIES + jy*NSMXSUB];
   *intval *= (dx*dy);
 
diff --git a/examples/idas/parallel/idasBruss_kry_bbd_p.c b/examples/idas/parallel/idasBruss_kry_bbd_p.c
index 79b5666..83ce142 100644
--- a/examples/idas/parallel/idasBruss_kry_bbd_p.c
+++ b/examples/idas/parallel/idasBruss_kry_bbd_p.c
@@ -155,7 +155,7 @@ static void PrintSol(void* mem, N_Vector uv, N_Vector uvp, UserData data,
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -458,13 +458,13 @@ static void PrintHeader(int SystemSize, int maxl,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
   printf("Linear solver: IDASPGMR     Max. Krylov dimension maxl: %d\n", maxl);
   printf("Preconditioner: band-block-diagonal (IDABBDPRE), with parameters\n");
-  printf("     mudq = %d,  mldq = %d,  mukeep = %d,  mlkeep = %d\n",
+  printf("     mudq = %ld,  mldq = %ld,  mukeep = %ld,  mlkeep = %ld\n",
          mudq, mldq, mukeep, mlkeep);
   printf("CalcIC called to correct initial guesses \n\n");
   printf("-----------------------------------------------------------\n");
@@ -490,7 +490,7 @@ static void PrintOutput(void *mem, N_Vector uv, realtype tt,
 
   thispe = data->thispe; 
   npelast = data->npes - 1;
-  cdata = NV_DATA_P(uv);
+  cdata = N_VGetArrayPointer_Parallel(uv);
   
   /* Send conc. at top right mesh point from PE npes-1 to PE 0. */
   if (thispe == npelast) {
@@ -520,10 +520,10 @@ static void PrintOutput(void *mem, N_Vector uv, realtype tt,
     for (i=1;i<NUM_SPECIES;i++)
       printf("         %12.4Le %12.4Le   |\n",cdata[i],clast[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
+    printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
     for (i=1;i<NUM_SPECIES;i++)
-      printf("         %12.4le %12.4le   |\n",cdata[i],clast[i]);
+      printf("         %12.4e %12.4e   |\n",cdata[i],clast[i]);
 #else
     printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
@@ -633,7 +633,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
@@ -719,7 +719,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
   
   data = (UserData) user_data;
-  cdata = NV_DATA_P(uv);
+  cdata = N_VGetArrayPointer_Parallel(uv);
 
   /* Get comm, thispe, subgrid indices, data sizes, extended array cext. */  
   comm = data->comm;     
@@ -934,7 +934,7 @@ static int reslocal(long int Nlocal, realtype tt,
   data = (UserData) user_data;
 
   /* Get data pointers, subgrid data, array sizes, work array cext. */
-  uvdata = NV_DATA_P(uv);
+  uvdata = N_VGetArrayPointer_Parallel(uv);
 
   dx2 = dx * dx;
   dy2 = dy * dy;
diff --git a/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c b/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c
index 2b7ee32..63473d4 100644
--- a/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c
+++ b/examples/idas/parallel/idasFoodWeb_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 23:06:37 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -218,7 +218,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype time,
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -519,7 +519,7 @@ static void PrintHeader(int SystemSize, int maxl,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -551,7 +551,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
 
   thispe = webdata->thispe; 
   npelast = webdata->npes - 1;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Send conc. at top right mesh point from PE npes-1 to PE 0. */
   if (thispe == npelast) {
@@ -582,10 +582,10 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
     for (i=1;i<NUM_SPECIES;i++)
       printf("         %12.4Le %12.4Le   |\n",cdata[i],clast[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
+    printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
     for (i=1;i<NUM_SPECIES;i++)
-      printf("         %12.4le %12.4le   |\n",cdata[i],clast[i]);
+      printf("         %12.4e %12.4e   |\n",cdata[i],clast[i]);
 #else
     printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
@@ -660,7 +660,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
@@ -746,7 +746,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
   
   webdata = (UserData) user_data;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Get comm, thispe, subgrid indices, data sizes, extended array cext. */
   
@@ -970,7 +970,7 @@ static int reslocal(long int Nlocal, realtype tt,
   
   /* Get data pointers, subgrid data, array sizes, work array cext. */
   
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Copy local segment of cc vector into the working extended array cext. */
   
diff --git a/examples/idas/parallel/idasFoodWeb_kry_p.c b/examples/idas/parallel/idasFoodWeb_kry_p.c
index 250a4cc..b8a962e 100644
--- a/examples/idas/parallel/idasFoodWeb_kry_p.c
+++ b/examples/idas/parallel/idasFoodWeb_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 23:06:38 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -231,7 +231,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype time,
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -563,13 +563,13 @@ static void PrintHeader(long int SystemSize, int maxl,
   printf("\nidasFoodWeb_kry_p: Predator-prey DAE parallel example problem for IDA \n\n");
   printf("Number of species ns: %d", NUM_SPECIES);
   printf("     Mesh dimensions: %d x %d", MX, MY);
-  printf("     Total system size: %d\n",SystemSize);
+  printf("     Total system size: %ld\n",SystemSize);
   printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB);
   printf("     Processor array: %d x %d\n", NPEX, NPEY);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -601,7 +601,7 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
 
   thispe = webdata->thispe; 
   npelast = webdata->npes - 1;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Send conc. at top right mesh point from PE npes-1 to PE 0. */
   if (thispe == npelast) {
@@ -632,10 +632,10 @@ static void PrintOutput(void *mem, N_Vector cc, realtype tt,
     for (i=1;i<NUM_SPECIES;i++)
       printf("         %12.4Le %12.4Le   |\n",cdata[i],clast[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
+    printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
     for (i=1;i<NUM_SPECIES;i++)
-      printf("         %12.4le %12.4le   |\n",cdata[i],clast[i]);
+      printf("         %12.4e %12.4e   |\n",cdata[i],clast[i]);
 #else
     printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
          tt, cdata[0], clast[0], nst, kused, hused);
@@ -705,7 +705,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
@@ -786,7 +786,7 @@ static int rescomm(N_Vector cc, N_Vector cp, void *user_data)
   MPI_Request request[4];
   
   webdata = (UserData) user_data;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Get comm, thispe, subgrid indices, data sizes, extended array cext. */
   comm = webdata->comm;     thispe = webdata->thispe;
@@ -998,7 +998,7 @@ static int reslocal(realtype tt, N_Vector cc, N_Vector cp, N_Vector res,
   webdata = (UserData) user_data;
   
   /* Get data pointers, subgrid data, array sizes, work array cext. */
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Copy local segment of cc vector into the working extended array cext. */
   locc = 0;
@@ -1139,7 +1139,7 @@ static int Precondbd(realtype tt, N_Vector cc,
 
   webdata = (UserData)user_data;
   uround = UNIT_ROUNDOFF;
-  sqru = SQRT(uround); 
+  sqru = SUNRsqrt(uround);
   thispe = webdata->thispe;
 
   mem = webdata->ida_mem;
@@ -1161,7 +1161,7 @@ static int Precondbd(realtype tt, N_Vector cc,
       ratesxy = IJ_Vptr(rates,ix,jy);
 
       for (js = 0; js < ns; js++) {
-        inc = sqru*(MAX(ABS(cxy[js]), MAX(hh*ABS(cpxy[js]), ONE/ewtxy[js])));
+        inc = sqru*(SUNMAX(SUNRabs(cxy[js]), SUNMAX(hh*SUNRabs(cpxy[js]), ONE/ewtxy[js])));
         cctemp = cxy[js];  /* Save the (js,ix,jy) element of cc. */
         cxy[js] += inc;    /* Perturb the (js,ix,jy) element of cc. */
         fac = -ONE/inc;
diff --git a/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c b/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c
index d2c882c..0ee8188 100644
--- a/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c
+++ b/examples/idas/parallel/idasHeat2D_FSA_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 23:06:38 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -113,7 +113,7 @@ static void PrintFinalStats(void *mem);
 static void ProcessArgs(int argc, char *argv[], int my_pe,
                         booleantype *sensi, int *sensi_meth, booleantype *err_con);
 static void WrongArgs(int my_pe, char *name);
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -405,7 +405,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
 
   data = (UserData) user_data;
-  uarray = NV_DATA_P(uu);
+  uarray = N_VGetArrayPointer_Parallel(uu);
 
   /* Get comm, thispe, subgrid indices, data sizes, extended array uext. */
   comm = data->comm;  thispe = data->thispe;
@@ -449,9 +449,9 @@ static int reslocal(long int Nlocal, realtype tres,
   data = (UserData) user_data;
 
   uext = data->uext;
-  uuv = NV_DATA_P(uu);
-  upv = NV_DATA_P(up);
-  resv = NV_DATA_P(res);
+  uuv = N_VGetArrayPointer_Parallel(uu);
+  upv = N_VGetArrayPointer_Parallel(up);
+  resv = N_VGetArrayPointer_Parallel(res);
   ixsub = data->ixsub; jysub = data->jysub;
   mxsub = data->mxsub; mxsub2 = data->mxsub + 2;
   mysub = data->mysub; npex = data->npex; npey = data->npey;
@@ -696,8 +696,8 @@ static int SetInitialProfile(N_Vector uu, N_Vector up,  N_Vector id,
   
   /* Initialize uu. */ 
   
-  udata = NV_DATA_P(uu);
-  iddata = NV_DATA_P(id);
+  udata = N_VGetArrayPointer_Parallel(uu);
+  iddata = N_VGetArrayPointer_Parallel(id);
   
   /* Set mesh spacings and subgrid indices for this PE. */
   dx = data->dx;
@@ -762,7 +762,7 @@ static void PrintHeader(int Neq, realtype rtol, realtype atol,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+    printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
     printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -837,7 +837,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu,
     printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2Le  %3ld %3ld\n",
            t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2le  %3ld %3ld\n",
+    printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2e  %3ld %3ld\n",
            t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps);
 #else
     printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2e  %3ld %3ld\n",
@@ -853,7 +853,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu,
 #if defined(SUNDIALS_EXTENDED_PRECISION)
         printf("       %13.5Le\n", umax);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-        printf("       %13.5le\n", umax);
+        printf("       %13.5e\n", umax);
 #else
         printf("       %13.5e\n", umax);
 #endif
@@ -944,7 +944,7 @@ static void WrongArgs(int my_pe, char *name)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/idas/parallel/idasHeat2D_kry_bbd_p.c b/examples/idas/parallel/idasHeat2D_kry_bbd_p.c
index a6145b7..66cdb60 100644
--- a/examples/idas/parallel/idasHeat2D_kry_bbd_p.c
+++ b/examples/idas/parallel/idasHeat2D_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 23:06:38 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -113,7 +113,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu);
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -363,7 +363,7 @@ static int rescomm(long int Nlocal, realtype tt,
   MPI_Request request[4];
 
   data = (UserData) user_data;
-  uarray = NV_DATA_P(uu);
+  uarray = N_VGetArrayPointer_Parallel(uu);
 
   /* Get comm, thispe, subgrid indices, data sizes, extended array uext. */
   comm = data->comm;  thispe = data->thispe;
@@ -405,9 +405,9 @@ static int reslocal(long int Nlocal, realtype tres,
 
   data = (UserData) user_data;
   uext = data->uext;
-  uuv = NV_DATA_P(uu);
-  upv = NV_DATA_P(up);
-  resv = NV_DATA_P(res);
+  uuv = N_VGetArrayPointer_Parallel(uu);
+  upv = N_VGetArrayPointer_Parallel(up);
+  resv = N_VGetArrayPointer_Parallel(res);
   ixsub = data->ixsub; jysub = data->jysub;
   mxsub = data->mxsub; mxsub2 = data->mxsub + 2;
   mysub = data->mysub; npex = data->npex; npey = data->npey;
@@ -646,8 +646,8 @@ static int SetInitialProfile(N_Vector uu, N_Vector up,  N_Vector id,
   
   /* Initialize uu. */ 
   
-  udata = NV_DATA_P(uu);
-  iddata = NV_DATA_P(id);
+  udata = N_VGetArrayPointer_Parallel(uu);
+  iddata = N_VGetArrayPointer_Parallel(id);
   
   /* Set mesh spacings and subgrid indices for this PE. */
   dx = data->dx;
@@ -704,14 +704,14 @@ static void PrintHeader(long int Neq, realtype rtol, realtype atol)
     printf("                  Zero boundary conditions,");
     printf(" polynomial initial conditions.\n");
     printf("                Mesh dimensions: %d x %d", MX, MY);
-    printf("        Total system size: %d\n\n", Neq);
+    printf("        Total system size: %ld\n\n", Neq);
 
     printf("Subgrid dimensions: %d x %d", MXSUB, MYSUB);
     printf("         Processor array: %d x %d\n", NPEX, NPEY);
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+    printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
     printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -778,7 +778,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu)
     printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2Le  %3ld %3ld\n",
            t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2le  %3ld %3ld\n",
+    printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2e  %3ld %3ld\n",
            t, umax, kused, nst, nni, nli, nre, nreLS, nge, hused, npe, nps);
 #else
     printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld %4ld %4ld %9.2e  %3ld %3ld\n",
@@ -815,7 +815,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/idas/parallel/idasHeat2D_kry_p.c b/examples/idas/parallel/idasHeat2D_kry_p.c
index 9aeb14a..68c9b3c 100644
--- a/examples/idas/parallel/idasHeat2D_kry_p.c
+++ b/examples/idas/parallel/idasHeat2D_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2007/10/25 20:03:38 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -118,7 +118,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu);
 
 static void PrintFinalStats(void *mem);
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -348,7 +348,7 @@ int PsetupHeat(realtype tt,
 
   data = (UserData) user_data;
 
-  ppv = NV_DATA_P(data->pp);
+  ppv = N_VGetArrayPointer_Parallel(data->pp);
   ixsub = data->ixsub;
   jysub = data->jysub;
   mxsub = data->mxsub;
@@ -426,7 +426,7 @@ static int rescomm(N_Vector uu, N_Vector up, void *user_data)
   MPI_Request request[4];
   
   data = (UserData) user_data;
-  uarray = NV_DATA_P(uu);
+  uarray = N_VGetArrayPointer_Parallel(uu);
   
   /* Get comm, thispe, subgrid indices, data sizes, extended array uext. */
   comm = data->comm;  thispe = data->thispe;
@@ -468,9 +468,9 @@ static int reslocal(realtype tt,
   
   data = (UserData) user_data;
   uext = data->uext;
-  uuv = NV_DATA_P(uu);
-  upv = NV_DATA_P(up);
-  resv = NV_DATA_P(rr);
+  uuv = N_VGetArrayPointer_Parallel(uu);
+  upv = N_VGetArrayPointer_Parallel(up);
+  resv = N_VGetArrayPointer_Parallel(rr);
   ixsub = data->ixsub; jysub = data->jysub;
   mxsub = data->mxsub; mxsub2 = data->mxsub + 2;
   mysub = data->mysub; npex = data->npex; npey = data->npey;
@@ -707,8 +707,8 @@ static int SetInitialProfile(N_Vector uu, N_Vector up,  N_Vector id,
   
   /* Initialize uu. */ 
 
-  udata = NV_DATA_P(uu);
-  iddata = NV_DATA_P(id);
+  udata = N_VGetArrayPointer_Parallel(uu);
+  iddata = N_VGetArrayPointer_Parallel(id);
   
   /* Set mesh spacings and subgrid indices for this PE. */
   dx = data->dx;
@@ -769,7 +769,7 @@ static void PrintHeader(long int Neq, realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -824,7 +824,7 @@ static void PrintOutput(int id, void *mem, realtype t, N_Vector uu)
     printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le  %3ld %3ld\n",
            t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)  
-    printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le  %3ld %3ld\n",
+    printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
            t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #else
     printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
@@ -861,7 +861,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/CMakeLists.txt b/examples/idas/serial/CMakeLists.txt
index 68502c0..267bfd7 100644
--- a/examples/idas/serial/CMakeLists.txt
+++ b/examples/idas/serial/CMakeLists.txt
@@ -1,15 +1,23 @@
 # ---------------------------------------------------------------
-# $Revision: 1.10 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4866 $
+# $Date: 2016-08-18 16:07:58 -0700 (Thu, 18 Aug 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for IDAS serial examples
+#
+# LEBanks 3/25/2013
+#    Added SUPERLUMT logic.
 
 
 # Add variable IDAS_examples with the names of the serial IDAS examples
@@ -24,7 +32,7 @@ SET(IDAS_examples
   idasKrylovDemo_ls
   idasRoberts_ASAi_dns
   idasRoberts_dns
-  idasRoberts_FSA_dns
+  "idasRoberts_FSA_dns\;-sensi stg t"
   idasSlCrank_dns
   idasSlCrank_FSA_dns
   )
@@ -34,6 +42,18 @@ SET(IDAS_examples
 
 SET(IDAS_examples_BL
   )
+  
+SET(IDAS_examples_SUPERLUMT
+  idasRoberts_sps
+  idasRoberts_ASAi_sps
+  "idasRoberts_FSA_sps\;-sensi stg t"
+  )
+
+SET(IDAS_examples_KLU
+  idasRoberts_klu
+  idasRoberts_ASAi_klu
+  "idasRoberts_FSA_klu\;-sensi stg t"
+  )
 
 # Specify libraries to link against (through the target that was used to 
 # generate them) based on the value of the variable LINK_LIBRARY_TYPE
@@ -50,26 +70,58 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${IDAS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(SUPERLUMT_FOUND)
+  # quote list to retain integrity
+  LIST(APPEND IDAS_examples "${IDAS_examples_SUPERLUMT}")
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND IDAS_examples "${IDAS_examples_KLU}")
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
 # Add the build and install targets for each IDAS example
 
-FOREACH(example ${IDAS_examples})
-  ADD_EXECUTABLE(${example} ${example}.c)
+# SGS is there a way to query CMAKE variable to get added executables 
+# rather than keeping our own list?
+SET(ADDED_EXECUTABLES "")
+FOREACH(example_tuple ${IDAS_examples})
+  LIST(GET example_tuple 0 example)
+
+  # Only need to add the executable once
+  LIST(FIND ADDED_EXECUTABLES ${example} index)
+  IF(index EQUAL -1)
+    LIST(APPEND ADDED_EXECUTABLES ${example})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  ENDIF(index EQUAL -1)
+
+  LIST(LENGTH example_tuple n)
+  IF(n EQUAL 2)
+    LIST(GET example_tuple 1 test_args)
+    STRING(REGEX REPLACE " " "_" test_name ${example}_${test_args})
+    SUNDIALS_ADD_TEST(${test_name} ${example} TEST_ARGS ${test_args})
+  ELSE()
+    SUNDIALS_ADD_TEST(${example} ${example})
+  ENDIF()
+
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/serial)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${IDAS_examples})
+ENDFOREACH(example_tuple ${IDAS_examples})
 
 # If Lapack support is enabled, add the build and install targets for
 # the examples using Lapack
-
 IF(LAPACK_FOUND)
   FOREACH(example ${IDAS_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.c)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     IF(EXAMPLES_INSTALL)
       INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/serial)
@@ -77,6 +129,34 @@ IF(LAPACK_FOUND)
   ENDFOREACH(example ${IDAS_examples_BL})
 ENDIF(LAPACK_FOUND)
 
+# If SUPERLUMT support is enabled, add the build and install targets for
+# the examples using SUPERLUMT
+#IF(SUPERLUMT_FOUND)
+#  FOREACH(example ${IDAS_examples_SUPERLUMT})
+#    ADD_EXECUTABLE(${example} ${example}.c)
+#    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+#    SUNDIALS_ADD_TEST(${example} ${example})
+#    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+#    IF(EXAMPLES_INSTALL)
+#      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/serial)
+#    ENDIF(EXAMPLES_INSTALL)
+#  ENDFOREACH(example ${IDAS_examples_SUPERLUMT})
+#ENDIF(SUPERLUMT_FOUND)
+
+# If KLU support is enabled, add the build and install targets for
+# the examples using KLU
+#IF(KLU_FOUND)
+#  FOREACH(example ${IDAS_examples_KLU})
+#    ADD_EXECUTABLE(${example} ${example}.c)
+#    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+#    SUNDIALS_ADD_TEST(${example} ${example})
+#    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+#    IF(EXAMPLES_INSTALL)
+#      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/idas/serial)
+#    ENDIF(EXAMPLES_INSTALL)
+#  ENDFOREACH(example ${IDAS_examples_KLU})
+#ENDIF(KLU_FOUND)
+
 IF(EXAMPLES_INSTALL)
 
   # Install the README file
@@ -85,13 +165,28 @@ IF(EXAMPLES_INSTALL)
   # Prepare substitution variables for Makefile and/or CMakeLists templates
   SET(SOLVER "IDAS")
   SET(SOLVER_LIB "sundials_idas")
-  LIST2STRING(IDAS_examples EXAMPLES)
+  FOREACH(example_tuple ${IDAS_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${IDAS_examples})
+
   IF(LAPACK_FOUND)
     LIST2STRING(IDAS_examples_BL EXAMPLES_BL)
   ELSE(LAPACK_FOUND)
     SET(EXAMPLES_BL "")
   ENDIF(LAPACK_FOUND)
 
+  IF(KLU_FOUND)
+    #LIST2STRING(IDAS_examples_KLU EXAMPLES)
+  ENDIF(KLU_FOUND)
+
+  IF(SUPERLUMT_FOUND)
+    #LIST2STRING(IDAS_examples_SUPERLUMT EXAMPLES)
+  ENDIF(SUPERLUMT_FOUND)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
   # be used as a template for the user's own programs.
diff --git a/examples/idas/serial/Makefile.in b/examples/idas/serial/Makefile.in
deleted file mode 100644
index aa67968..0000000
--- a/examples/idas/serial/Makefile.in
+++ /dev/null
@@ -1,142 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.16 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for IDAS serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/idas/libsundials_idas.la              \
-	        $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = idasAkzoNob_ASAi_dns \
-	   idasAkzoNob_dns \
-	   idasFoodWeb_bnd \
-	   idasHeat2D_bnd \
-	   idasHeat2D_kry \
-	   idasHessian_ASA_FSA \
-	   idasKrylovDemo_ls \
-	   idasRoberts_ASAi_dns \
-	   idasRoberts_dns \
-	   idasRoberts_FSA_dns \
-	   idasSlCrank_dns \
-	   idasSlCrank_FSA_dns
-
-EXAMPLES_BL = 
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done ; \
-	fi
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/idas/serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/idas/serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/idas/serial/README $(EXS_INSTDIR)/idas/serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/idas/serial/$${i}.c   $(EXS_INSTDIR)/idas/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/idas/serial/$${i}.out $(EXS_INSTDIR)/idas/serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/idas/serial/$${i}.c   $(EXS_INSTDIR)/idas/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/idas/serial/$${i}.out $(EXS_INSTDIR)/idas/serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/idas/serial/Makefile
-	rm -f $(EXS_INSTDIR)/idas/serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/idas/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/idas/serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/idas/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/idas/serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/idas/serial
-	$(rminstalldirs) $(EXS_INSTDIR)/idas
-
-clean:
-	rm -rf .libs
-	rm -f *.lo
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	${SHELL} ./config.status --recheck ; \
-	cd ${abs_builddir}
-
-
diff --git a/examples/idas/serial/README b/examples/idas/serial/README
index 07f5d18..b4a3169 100644
--- a/examples/idas/serial/README
+++ b/examples/idas/serial/README
@@ -8,19 +8,56 @@ List of serial IDAS examples
   idasHessian_ASA_FSA   : computation of Hessian for Robertson kinetics system
   idasKrylovDemo_ls     : demonstration program with 3 Krylov solvers
   idasRoberts_ASAi_dns  : adjoint sensitivity for Robertson kinetics system
-  idasRoberts_dns       : 3-species Robertson kinetics system  with a user-supplied Jacobian
+  idasRoberts_dns       : 3-species Robertson kinetics system with user Jacobian
+  idasRoberts_klu       : Robertson system with KLU sparse linear solver
+  idasRoberts_sps       : Robertson system with SuperLUMT sparse linear solver
   idasRoberts_FSA_dns   : forward sensitivity for Robertson kinetics system
   idasSlCrank_dns       : slider-crank simulation
   idasSlCrank_FSA_dns   : forward sensitivity for slider-crank
 
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/idas/serial/idasAkzoNob_ASAi_dns.c b/examples/idas/serial/idasAkzoNob_ASAi_dns.c
index 82b8a32..c05d1d6 100644
--- a/examples/idas/serial/idasAkzoNob_ASAi_dns.c
+++ b/examples/idas/serial/idasAkzoNob_ASAi_dns.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2008/04/17 20:12:55 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2007, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Adjoint sensitivity example problem
  *
@@ -62,7 +67,7 @@ typedef struct {
   realtype K, klA, Ks, pCO2, H;
 } *UserData;
 
-static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector res, void *userdata);
+static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector resval, void *userdata);
 
 static int resB(realtype tt, 
                 N_Vector yy, N_Vector yp,
@@ -73,7 +78,7 @@ static int rhsQ(realtype t, N_Vector yy, N_Vector yp,
               N_Vector qdot, void *user_data);
 
 static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 
 /* Main program */
@@ -247,7 +252,7 @@ int main()
 }
 
 
-static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector res, void *userdata)
+static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector resval, void *userdata)
 {
   UserData data;
   realtype k1, k2, k3, k4;
@@ -282,19 +287,19 @@ static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector res, void *userdat
   yd4 = Ith(yd,4);
   yd5 = Ith(yd,5);
 
-  r1 = k1 * RPowerI(y1,4) * RSqrt(y2);
+  r1 = k1 * SUNRpowerI(y1,4) * SUNRsqrt(y2);
   r2 = k2 * y3 * y4;
   r3 = k2/K * y1 * y5;
   r4 = k3 * y1 * y4 * y4;
-  r5 = k4 * y6 * y6 * RSqrt(y2);
+  r5 = k4 * y6 * y6 * SUNRsqrt(y2);
   Fin = klA * ( pCO2/H - y2 );
 
-  Ith(res,1) = yd1 + TWO*r1 - r2 + r3 + r4;
-  Ith(res,2) = yd2 + HALF*r1 + r4 + HALF*r5 - Fin;
-  Ith(res,3) = yd3 - r1 + r2 - r3;
-  Ith(res,4) = yd4 + r2 - r3 + TWO*r4;
-  Ith(res,5) = yd5 - r2 + r3 - r5;
-  Ith(res,6) = Ks*y1*y4 - y6;
+  Ith(resval,1) = yd1 + TWO*r1 - r2 + r3 + r4;
+  Ith(resval,2) = yd2 + HALF*r1 + r4 + HALF*r5 - Fin;
+  Ith(resval,3) = yd3 - r1 + r2 - r3;
+  Ith(resval,4) = yd4 + r2 - r3 + TWO*r4;
+  Ith(resval,5) = yd5 - r2 + r3 - r5;
+  Ith(resval,6) = Ks*y1*y4 - y6;
 
   return(0);
 }
@@ -413,7 +418,7 @@ static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasAkzoNob_dns.c b/examples/idas/serial/idasAkzoNob_dns.c
index 63174b9..f3cd5ac 100644
--- a/examples/idas/serial/idasAkzoNob_dns.c
+++ b/examples/idas/serial/idasAkzoNob_dns.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:33:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2007, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Adjoint sensitivity example problem
  *
@@ -59,7 +64,7 @@ typedef struct {
   realtype K, klA, Ks, pCO2, H;
 } *UserData;
 
-static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector res, void *userdata);
+static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector resval, void *userdata);
 
 static int rhsQ(realtype t, N_Vector yy, N_Vector yp, 
               N_Vector qdot, void *user_data);
@@ -67,7 +72,7 @@ static int rhsQ(realtype t, N_Vector yy, N_Vector yp,
 static void PrintHeader(realtype rtol, realtype avtol, N_Vector y);
 static void PrintOutput(void *mem, realtype t, N_Vector y);
 static void PrintFinalStats(void *mem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /* Main program */
 int main()
@@ -163,7 +168,7 @@ int main()
   PrintOutput(mem,0.0,yy);
 
   tout = T1; nout = 0;
-  incr = RPowerR(TF/T1,ONE/NF);
+  incr = SUNRpowerR(TF/T1,ONE/NF);
  
   /* FORWARD run. */
   while (1) {
@@ -198,7 +203,7 @@ int main()
 }
 
 
-static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector res, void *userdata)
+static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector resval, void *userdata)
 {
   UserData data;
   realtype k1, k2, k3, k4;
@@ -233,19 +238,19 @@ static int res(realtype t, N_Vector yy, N_Vector yd, N_Vector res, void *userdat
   yd4 = Ith(yd,4);
   yd5 = Ith(yd,5);
 
-  r1 = k1 * RPowerI(y1,4) * RSqrt(y2);
+  r1 = k1 * SUNRpowerI(y1,4) * SUNRsqrt(y2);
   r2 = k2 * y3 * y4;
   r3 = k2/K * y1 * y5;
   r4 = k3 * y1 * y4 * y4;
-  r5 = k4 * y6 * y6 * RSqrt(y2);
+  r5 = k4 * y6 * y6 * SUNRsqrt(y2);
   Fin = klA * ( pCO2/H - y2 );
 
-  Ith(res,1) = yd1 + TWO*r1 - r2 + r3 + r4;
-  Ith(res,2) = yd2 + HALF*r1 + r4 + HALF*r5 - Fin;
-  Ith(res,3) = yd3 - r1 + r2 - r3;
-  Ith(res,4) = yd4 + r2 - r3 + TWO*r4;
-  Ith(res,5) = yd5 - r2 + r3 - r5;
-  Ith(res,6) = Ks*y1*y4 - y6;
+  Ith(resval,1) = yd1 + TWO*r1 - r2 + r3 + r4;
+  Ith(resval,2) = yd2 + HALF*r1 + r4 + HALF*r5 - Fin;
+  Ith(resval,3) = yd3 - r1 + r2 - r3;
+  Ith(resval,4) = yd4 + r2 - r3 + TWO*r4;
+  Ith(resval,5) = yd5 - r2 + r3 - r5;
+  Ith(resval,6) = Ks*y1*y4 - y6;
 
   return(0);
 }
@@ -269,7 +274,7 @@ static void PrintHeader(realtype rtol, realtype avtol, N_Vector y)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n",
          rtol, avtol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n",
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n",
          rtol, avtol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n",
@@ -289,7 +294,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   long int nst;
   realtype hused;
 
-  yval  = NV_DATA_S(y);
+  yval  = N_VGetArrayPointer_Serial(y);
 
   retval = IDAGetLastOrder(mem, &kused);
   check_flag(&retval, "IDAGetLastOrder", 1);
@@ -301,7 +306,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   printf("%8.2Le %8.2Le %8.2Le %8.2Le %8.2Le %8.2Le %8.2Le | %3ld  %1d %8.2Le\n", 
          t, yval[0], yval[1], yval[2], yval[3], yval[4], yval[5], nst, kused, hused);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%8.2le %8.2le %8.2le %8.2le %8.2le %8.2le %8.2le | %3ld  %1d %8.2le\n", 
+  printf("%8.2e %8.2e %8.2e %8.2e %8.2e %8.2e %8.2e | %3ld  %1d %8.2e\n", 
          t, yval[0], yval[1], yval[2], yval[3], yval[4], yval[5], nst, kused, hused);
 #else
   printf("%8.2e %8.2e %8.2e %8.2e %8.2e %8.2e %8.2e | %3ld  %1d %8.2e\n", 
@@ -343,7 +348,7 @@ static void PrintFinalStats(void *mem)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasFoodWeb_bnd.c b/examples/idas/serial/idasFoodWeb_bnd.c
index 7a59c3a..329238c 100644
--- a/examples/idas/serial/idasFoodWeb_bnd.c
+++ b/examples/idas/serial/idasFoodWeb_bnd.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:33:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -159,7 +159,7 @@ static void Fweb(realtype tcalc, N_Vector cc, N_Vector crate, UserData webdata);
 static void WebRates(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
                      UserData webdata);
 static realtype dotprod(long int size, realtype *x1, realtype *x2);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -303,8 +303,8 @@ static int resweb(realtype tt, N_Vector cc, N_Vector cp,
   
   webdata = (UserData)user_data;
   
-  cpv = NV_DATA_S(cp);
-  resv = NV_DATA_S(res);
+  cpv = N_VGetArrayPointer_Serial(cp);
+  resv = N_VGetArrayPointer_Serial(res);
   np = webdata->np;
   
   /* Call Fweb to set res to vector of right-hand sides. */
@@ -397,9 +397,9 @@ static void SetInitialProfiles(N_Vector cc, N_Vector cp, N_Vector id,
   realtype xx, yy, xyfactor, fac;
   realtype *ccv, *cpv, *idv;
   
-  ccv = NV_DATA_S(cc);
-  cpv = NV_DATA_S(cp);
-  idv = NV_DATA_S(id);
+  ccv = N_VGetArrayPointer_Serial(cc);
+  cpv = N_VGetArrayPointer_Serial(cp);
+  idv = N_VGetArrayPointer_Serial(id);
   np = webdata->np;
   
   /* Loop over grid, load cc values and id values. */
@@ -454,7 +454,7 @@ static void PrintHeader(long int mu, long int ml, realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -491,17 +491,17 @@ static void PrintOutput(void *mem, N_Vector c, realtype t)
 
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("%8.2Le %12.4Le %12.4Le   | %3ld  %1d %12.4Le\n", 
-         t, c_bl[0], c_tr[1], nst, kused, hused);
+         t, c_bl[0], c_tr[0], nst, kused, hused);
   for (i=1;i<NUM_SPECIES;i++)
     printf("         %12.4Le %12.4Le   |\n",c_bl[i],c_tr[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("%8.2le %12.4le %12.4le   | %3ld  %1d %12.4le\n", 
-         t, c_bl[0], c_tr[1], nst, kused, hused);
+  printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
+         t, c_bl[0], c_tr[0], nst, kused, hused);
   for (i=1;i<NUM_SPECIES;i++)
-    printf("         %12.4le %12.4le   |\n",c_bl[i],c_tr[i]);
+    printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
 #else
   printf("%8.2e %12.4e %12.4e   | %3ld  %1d %12.4e\n", 
-         t, c_bl[0], c_tr[1], nst, kused, hused);
+         t, c_bl[0], c_tr[0], nst, kused, hused);
   for (i=1;i<NUM_SPECIES;i++)
     printf("         %12.4e %12.4e   |\n",c_bl[i],c_tr[i]);
 #endif
@@ -643,7 +643,7 @@ static realtype dotprod(long int size, realtype *x1, realtype *x2)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasFoodWeb_bnd.out b/examples/idas/serial/idasFoodWeb_bnd.out
index ed33113..b88210e 100644
--- a/examples/idas/serial/idasFoodWeb_bnd.out
+++ b/examples/idas/serial/idasFoodWeb_bnd.out
@@ -10,25 +10,25 @@ CalcIC called to correct initial predator concentrations.
   t        bottom-left  top-right    | nst  k      h
 -----------------------------------------------------------
 
-0.00e+00   1.0000e+01   1.0000e+05   |   0  0   1.6310e-08
+0.00e+00   1.0000e+01   1.0000e+01   |   0  0   1.6310e-08
            1.0000e+05   1.0000e+05   |
 
-1.00e-03   1.0318e+01   1.0822e+05   |  32  4   1.0823e-04
+1.00e-03   1.0318e+01   1.0827e+01   |  32  4   1.0823e-04
            1.0319e+05   1.0822e+05   |
 
-1.00e-02   1.6188e+02   1.9734e+06   | 127  4   1.4203e-04
+1.00e-02   1.6188e+02   1.9735e+02   | 127  4   1.4203e-04
            1.6189e+06   1.9734e+06   |
 
-1.00e-01   2.4019e+02   2.7072e+06   | 235  1   3.9160e-02
+1.00e-01   2.4019e+02   2.7072e+02   | 235  1   3.9160e-02
            2.4019e+06   2.7072e+06   |
 
-4.00e-01   2.4019e+02   2.7072e+06   | 238  1   3.1328e-01
+4.00e-01   2.4019e+02   2.7072e+02   | 238  1   3.1328e-01
            2.4019e+06   2.7072e+06   |
 
-7.00e-01   2.4019e+02   2.7072e+06   | 239  1   6.2657e-01
+7.00e-01   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
            2.4019e+06   2.7072e+06   |
 
-1.00e+00   2.4019e+02   2.7072e+06   | 239  1   6.2657e-01
+1.00e+00   2.4019e+02   2.7072e+02   | 239  1   6.2656e-01
            2.4019e+06   2.7072e+06   |
 
 -----------------------------------------------------------
diff --git a/examples/idas/serial/idasHeat2D_bnd.c b/examples/idas/serial/idasHeat2D_bnd.c
index c3f29c6..1373319 100644
--- a/examples/idas/serial/idasHeat2D_bnd.c
+++ b/examples/idas/serial/idasHeat2D_bnd.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:33:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -69,7 +69,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector u);
 static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up, 
                              N_Vector id, N_Vector res);
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -207,7 +207,7 @@ int heatres(realtype tres, N_Vector uu, N_Vector up, N_Vector resval,
   realtype *uv, *upv, *resv, coeff;
   UserData data;
   
-  uv = NV_DATA_S(uu); upv = NV_DATA_S(up); resv = NV_DATA_S(resval);
+  uv = N_VGetArrayPointer_Serial(uu); upv = N_VGetArrayPointer_Serial(up); resv = N_VGetArrayPointer_Serial(resval);
 
   data = (UserData)user_data;
   mm = data->mm;
@@ -249,9 +249,9 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
   mm = data->mm;
   mm1 = mm - 1;
   
-  udata = NV_DATA_S(uu);
-  updata = NV_DATA_S(up);
-  iddata = NV_DATA_S(id);
+  udata = N_VGetArrayPointer_Serial(uu);
+  updata = N_VGetArrayPointer_Serial(up);
+  iddata = N_VGetArrayPointer_Serial(id);
 
   /* Initialize id to 1's. */
   N_VConst(ONE, id);
@@ -305,7 +305,7 @@ static void PrintHeader(realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -315,7 +315,7 @@ static void PrintHeader(realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("IDACalcIC called with input boundary values = %Lg \n",BVAL);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("IDACalcIC called with input boundary values = %lg \n",BVAL);
+  printf("IDACalcIC called with input boundary values = %g \n",BVAL);
 #else
   printf("IDACalcIC called with input boundary values = %g \n",BVAL);
 #endif
@@ -357,7 +357,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
   printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le \n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le \n",
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e \n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused);
 #else
   printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e \n",
@@ -376,7 +376,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasHeat2D_kry.c b/examples/idas/serial/idasHeat2D_kry.c
index 986e0d9..5e0af54 100644
--- a/examples/idas/serial/idasHeat2D_kry.c
+++ b/examples/idas/serial/idasHeat2D_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:33:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -81,7 +81,7 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
                              N_Vector res);
 static void PrintHeader(realtype rtol, realtype atol);
 static void PrintOutput(void *mem, realtype t, N_Vector uu);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -293,9 +293,9 @@ int resHeat(realtype tt,
   realtype *uu_data, *up_data, *rr_data, coeff, dif1, dif2;
   UserData data;
   
-  uu_data = NV_DATA_S(uu); 
-  up_data = NV_DATA_S(up); 
-  rr_data = NV_DATA_S(rr);
+  uu_data = N_VGetArrayPointer_Serial(uu); 
+  up_data = N_VGetArrayPointer_Serial(up); 
+  rr_data = N_VGetArrayPointer_Serial(rr);
 
   data = (UserData) user_data;
   
@@ -347,7 +347,7 @@ int PsetupHeat(realtype tt,
   UserData data;
   
   data = (UserData) user_data;
-  ppv = NV_DATA_S(data->pp);
+  ppv = N_VGetArrayPointer_Serial(data->pp);
   mm = data->mm;
 
   /* Initialize the entire vector to 1., then set the interior points to the
@@ -405,8 +405,8 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
 
   mm = data->mm;
 
-  udata = NV_DATA_S(uu);
-  updata = NV_DATA_S(up);
+  udata = N_VGetArrayPointer_Serial(uu);
+  updata = N_VGetArrayPointer_Serial(up);
 
   /* Initialize uu on all grid points. */ 
   mm1 = mm - 1;
@@ -456,7 +456,7 @@ static void PrintHeader(realtype rtol, realtype atol)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -501,7 +501,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
   printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le  %3ld %3ld\n",
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #else
   printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
@@ -519,7 +519,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasHessian_ASA_FSA.c b/examples/idas/serial/idasHessian_ASA_FSA.c
index 85d3c37..40d9591 100644
--- a/examples/idas/serial/idasHessian_ASA_FSA.c
+++ b/examples/idas/serial/idasHessian_ASA_FSA.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2007/10/25 20:03:39 $
+ * $Revision: 4809 $
+ * $Date: 2016-07-18 11:16:25 -0700 (Mon, 18 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2007, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  *
  * Hessian using adjoint sensitivity example problem. 
@@ -93,7 +98,7 @@ static int resS(int Ns, realtype t,
 static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_data);
 
 static int rhsQS(int Ns, realtype t, N_Vector yy, N_Vector yp, 
-                 N_Vector *yyS, N_Vector *ypS, N_Vector rrQ, N_Vector *rhsQS,
+                 N_Vector *yyS, N_Vector *ypS, N_Vector rrQ, N_Vector *rhsvalQS,
                  void *user_data,  N_Vector yytmp, N_Vector yptmp, N_Vector tmpQS);
 
 static int resBS1(realtype tt, N_Vector yy, N_Vector yp, N_Vector *yyS, N_Vector *ypS,
@@ -194,14 +199,14 @@ int main(int argc, char *argv[])
 
   IDAGetQuad(ida_mem, &time, q);
   G = Ith(q,1);
-  printf("     G:    %12.4le\n", G);
+  printf("     G:    %12.4e\n", G);
 
   /* Sensitivities are needed for IC of backward problems. */
   IDAGetSensDky(ida_mem, tf, 0, yyS);
   IDAGetSensDky(ida_mem, tf, 1, ypS);
 
   IDAGetQuadSens(ida_mem, &time, qS);
-  printf("   dG/dp:  %12.4le %12.4le\n", Ith(qS[0],1), Ith(qS[1],1));
+  printf("   dG/dp:  %12.4e %12.4e\n", Ith(qS[0],1), Ith(qS[1],1));
   printf("\n");
   /******************************
   * BACKWARD PROBLEM #1
@@ -269,21 +274,23 @@ int main(int argc, char *argv[])
   flag = IDASolveB(ida_mem, ti, IDA_NORMAL);
 
   flag = IDAGetB(ida_mem, indexB1, &time, yyB1, ypB1);
-  //flag = IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB1), &nst);
-  //printf("at time=%g \tpb 1 Num steps:%d\n", time, nst); 
-  //flag = IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB2), &nst);
-  //printf("at time=%g \tpb 2 Num steps:%d\n\n", time, nst); 
+  /* 
+     flag = IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB1), &nst);
+     printf("at time=%g \tpb 1 Num steps:%d\n", time, nst); 
+     flag = IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB2), &nst);
+     printf("at time=%g \tpb 2 Num steps:%d\n\n", time, nst); 
+  */
 
   flag = IDAGetQuadB(ida_mem, indexB1, &time, qB1);
   flag = IDAGetQuadB(ida_mem, indexB2, &time, qB2);
-  printf("   dG/dp:  %12.4le %12.4le   (from backward pb. 1)\n", Ith(qB1,1), Ith(qB1,2));
-  printf("   dG/dp:  %12.4le %12.4le   (from backward pb. 2)\n", Ith(qB2,1), Ith(qB2,2));
+  printf("   dG/dp:  %12.4e %12.4e   (from backward pb. 1)\n", Ith(qB1,1), Ith(qB1,2));
+  printf("   dG/dp:  %12.4e %12.4e   (from backward pb. 2)\n", Ith(qB2,1), Ith(qB2,2));
 
   printf("\n");
   printf("   H = d2G/dp2:\n");
   printf("        (1)            (2)\n");
-  printf("  %12.4le  %12.4le\n", Ith(qB1,3), Ith(qB2,3));
-  printf("  %12.4le  %12.4le\n", Ith(qB1,4), Ith(qB2,4));
+  printf("  %12.4e  %12.4e\n", Ith(qB1,3), Ith(qB2,3));
+  printf("  %12.4e  %12.4e\n", Ith(qB1,4), Ith(qB2,4));
 
   IDAFree(&ida_mem);
 
@@ -395,12 +402,12 @@ int main(int argc, char *argv[])
 
 
   printf("\n");
-  printf("   dG/dp:  %12.4le  %12.4le   (fwd FD)\n",  grdG_fwd[0],  grdG_fwd[1]);
-  printf("           %12.4le  %12.4le   (bck FD)\n",  grdG_bck[0],  grdG_bck[1]);
-  printf("           %12.4le  %12.4le   (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]);
+  printf("   dG/dp:  %12.4e  %12.4e   (fwd FD)\n",  grdG_fwd[0],  grdG_fwd[1]);
+  printf("           %12.4e  %12.4e   (bck FD)\n",  grdG_bck[0],  grdG_bck[1]);
+  printf("           %12.4e  %12.4e   (cntr FD)\n", grdG_cntr[0], grdG_cntr[1]);
   printf("\n");
-  printf("  H(1,1):  %12.4le\n", H11);
-  printf("  H(2,2):  %12.4le\n", H22);
+  printf("  H(1,1):  %12.4e\n", H11);
+  printf("  H(2,2):  %12.4e\n", H22);
 
   IDAFree(&ida_mem);
 
@@ -434,7 +441,7 @@ static int res(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_
 
   y1  = Ith(yy,1); y2  = Ith(yy,2); y3  = Ith(yy,3); 
   yp1 = Ith(yp,1); yp2 = Ith(yp,2); yp3 = Ith(yp,3);
-  rval = NV_DATA_S(rr);
+  rval = N_VGetArrayPointer_Serial(rr);
 
   data = (UserData) user_data;
   p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
@@ -523,7 +530,7 @@ static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_
 static int rhsQS(int Ns, realtype t,
                  N_Vector yy, N_Vector yp, 
                  N_Vector *yyS, N_Vector *ypS, 
-                 N_Vector rrQ, N_Vector *rhsQS,
+                 N_Vector rrQ, N_Vector *rhsvalQS,
                  void *user_data,
                  N_Vector yytmp, N_Vector yptmp, N_Vector tmpQS)
 {
@@ -539,13 +546,13 @@ static int rhsQS(int Ns, realtype t,
   s1 = Ith(yyS[0],1);
   s2 = Ith(yyS[0],2);
   s3 = Ith(yyS[0],3);
-  Ith(rhsQS[0],1) = y1*s1 + y2*s2 + y3*s3;
+  Ith(rhsvalQS[0],1) = y1*s1 + y2*s2 + y3*s3;
 
   /* 2nd sensitivity RHS */
   s1 = Ith(yyS[1],1);
   s2 = Ith(yyS[1],2);
   s3 = Ith(yyS[1],3);
-  Ith(rhsQS[1],1) = y1*s1 + y2*s2 + y3*s3;
+  Ith(rhsvalQS[1],1) = y1*s1 + y2*s2 + y3*s3;
 
   return(0);
 }
diff --git a/examples/idas/serial/idasKrylovDemo_ls.c b/examples/idas/serial/idasKrylovDemo_ls.c
index 06cd3fe..42e819e 100644
--- a/examples/idas/serial/idasKrylovDemo_ls.c
+++ b/examples/idas/serial/idasKrylovDemo_ls.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2009/09/30 23:33:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -91,7 +91,7 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
                              N_Vector res);
 static void PrintHeader(realtype rtol, realtype atol, int linsolver);
 static void PrintOutput(void *mem, realtype t, N_Vector uu, int linsolver);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -309,9 +309,9 @@ int resHeat(realtype tt,
   realtype *uu_data, *up_data, *rr_data, coeff, dif1, dif2;
   UserData data;
   
-  uu_data = NV_DATA_S(uu); 
-  up_data = NV_DATA_S(up); 
-  rr_data = NV_DATA_S(rr);
+  uu_data = N_VGetArrayPointer_Serial(uu); 
+  up_data = N_VGetArrayPointer_Serial(up); 
+  rr_data = N_VGetArrayPointer_Serial(rr);
 
   data = (UserData) user_data;
   
@@ -363,7 +363,7 @@ int PsetupHeat(realtype tt,
   UserData data;
   
   data = (UserData) user_data;
-  ppv = NV_DATA_S(data->pp);
+  ppv = N_VGetArrayPointer_Serial(data->pp);
   mm = data->mm;
 
   /* Initialize the entire vector to 1., then set the interior points to the
@@ -421,8 +421,8 @@ static int SetInitialProfile(UserData data, N_Vector uu, N_Vector up,
 
   mm = data->mm;
 
-  udata = NV_DATA_S(uu);
-  updata = NV_DATA_S(up);
+  udata = N_VGetArrayPointer_Serial(uu);
+  updata = N_VGetArrayPointer_Serial(up);
 
   /* Initialize uu on all grid points. */ 
   mm1 = mm - 1;
@@ -472,7 +472,7 @@ static void PrintHeader(realtype rtol, realtype atol, int linsolver)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n", rtol, atol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n", rtol, atol);
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n", rtol, atol);
 #endif
@@ -532,7 +532,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu, int linsolver)
   printf(" %5.2Lf %13.5Le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2Le  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #elif defined(SUNDIALS_DOUBLE_PRECISION) 
-  printf(" %5.2f %13.5le  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2le  %3ld %3ld\n",
+  printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
          t, umax, kused, nst, nni, nje, nre, nreLS, hused, npe, nps);
 #else
   printf(" %5.2f %13.5e  %d  %3ld  %3ld  %3ld  %4ld  %4ld  %9.2e  %3ld %3ld\n",
@@ -550,7 +550,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector uu, int linsolver)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasRoberts_ASAi_dns.c b/examples/idas/serial/idasRoberts_ASAi_dns.c
index 2b3d8ad..ad3dacd 100644
--- a/examples/idas/serial/idasRoberts_ASAi_dns.c
+++ b/examples/idas/serial/idasRoberts_ASAi_dns.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 23:05:10 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2007, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Adjoint sensitivity example problem.
  *
@@ -117,7 +122,7 @@ static int resB(realtype tt,
 static int JacB(long int NeqB, realtype tt, realtype cjB,
                 N_Vector yy, N_Vector yp,
                 N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                DlsMat JacB, void *user_data,
+                DlsMat JB, void *user_data,
                 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
 
 
@@ -128,7 +133,7 @@ static int rhsQB(realtype tt,
 
 /* Prototypes of private functions */
 static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -271,7 +276,7 @@ int main(int argc, char *argv[])
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("G:          %12.4Le \n",Ith(q,1));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("G:          %12.4le \n",Ith(q,1));
+  printf("G:          %12.4e \n",Ith(q,1));
 #else
   printf("G:          %12.4e \n",Ith(q,1));
 #endif
@@ -458,7 +463,7 @@ int main(int argc, char *argv[])
 
   printf("Free memory\n\n");
 
-  IDAFree(ida_mem);
+  IDAFree(&ida_mem);
   N_VDestroy_Serial(yy);
   N_VDestroy_Serial(yp);
   N_VDestroy_Serial(q);
@@ -488,13 +493,13 @@ int main(int argc, char *argv[])
 
 static int res(realtype t, N_Vector yy, N_Vector yp, N_Vector resval, void *user_data)
 {
-  realtype y1, y2, y3,yp1, yp2, yp3, *rval;
+  realtype y1, y2, y3, yp1, yp2, *rval;
   UserData data;
   realtype p1, p2, p3;
 
   y1  = Ith(yy,1); y2  = Ith(yy,2); y3  = Ith(yy,3); 
-  yp1 = Ith(yp,1); yp2 = Ith(yp,2); yp3 = Ith(yp,3);
-  rval = NV_DATA_S(resval);
+  yp1 = Ith(yp,1); yp2 = Ith(yp,2);
+  rval = N_VGetArrayPointer_Serial(resval);
 
   data = (UserData) user_data;
   p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
@@ -516,11 +521,11 @@ static int Jac(long int Neq, realtype t, realtype cj,
                DlsMat J, void *user_data, 
                N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
 {
-  realtype y1, y2, y3;
+  realtype y2, y3;
   UserData data;
   realtype p1, p2, p3;
  
-  y1 = Ith(yy,1); y2 = Ith(yy,2); y3 = Ith(yy,3);
+  y2 = Ith(yy,2); y3 = Ith(yy,3);
   
   data = (UserData) user_data;
   p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
@@ -566,7 +571,7 @@ static int ewt(N_Vector y, N_Vector w, void *user_data)
 
   for (i=1; i<=3; i++) {
     yy = Ith(y,i);
-    ww = rtol * ABS(yy) + atol[i-1];  
+    ww = rtol * SUNRabs(yy) + atol[i-1];
     if (ww <= 0.0) return (-1);
     Ith(w,i) = 1.0/ww;
   }
@@ -585,11 +590,11 @@ static int resB(realtype tt,
                  void *user_dataB)
 {
   UserData data;
-  realtype y1, y2, y3;
+  realtype y2, y3;
   realtype p1, p2, p3;
   realtype l1, l2, l3;
-  realtype lp1, lp2, lp3;
-  realtype l21, l32, y23;
+  realtype lp1, lp2;
+  realtype l21;
   
   data = (UserData) user_dataB;
 
@@ -597,18 +602,16 @@ static int resB(realtype tt,
   p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
 
   /* The y  vector */
-  y1 = Ith(yy,1); y2 = Ith(yy,2); y3 = Ith(yy,3);
+  y2 = Ith(yy,2); y3 = Ith(yy,3);
   
   /* The lambda vector */
   l1 = Ith(yyB,1); l2 = Ith(yyB,2); l3 = Ith(yyB,3);
 
   /* The lambda dot vector */
-  lp1 = Ith(ypB,1); lp2 = Ith(ypB,2); lp3 = Ith(ypB,3);
+  lp1 = Ith(ypB,1); lp2 = Ith(ypB,2);
 
   /* Temporary variables */
   l21 = l2-l1;
-  l32 = l3-l2;
-  y23 = y2*y3;
 
   /* Load residual. */
   Ith(rrB,1) = lp1 + p1*l21 - l3;
@@ -625,12 +628,11 @@ static int JacB(long int NeqB, realtype tt, realtype cj,
                 DlsMat JB, void *user_data,
                 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
 {
-  realtype y1, y2, y3, l1, l2, l3;
+  realtype y2, y3;
   UserData data;
   realtype p1, p2, p3;
  
-  y1 = Ith(yy,1); y2 = Ith(yy,2); y3 = Ith(yy,3);
-  l1 = Ith(yyB,1); l2 = Ith(yyB,2); l3 = Ith(yyB,3);
+  y2 = Ith(yy,2); y3 = Ith(yy,3);
   
   data = (UserData) user_data;
   p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
@@ -656,22 +658,15 @@ static int rhsQB(realtype tt,
                  N_Vector yyB, N_Vector ypB, 
                  N_Vector rrQB, void *user_dataB)
 {
-  UserData data;
   realtype y1, y2, y3;
-  realtype p1, p2, p3;
-  realtype l1, l2, l3;
+  realtype l1, l2;
   realtype l21;
 
-  data = (UserData) user_dataB;
-
-  /* The p vector */
-  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
-
   /* The y vector */
   y1 = Ith(yy,1); y2 = Ith(yy,2); y3 = Ith(yy,3);
   
   /* The lambda vector */
-  l1 = Ith(yyB,1); l2 = Ith(yyB,2); l3 = Ith(yyB,3);
+  l1 = Ith(yyB,1); l2 = Ith(yyB,2);
   
   /* Temporary variables */
   l21 = l2-l1;
@@ -704,10 +699,10 @@ static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB)
   printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", 
          Ith(yB,1), Ith(yB,2), Ith(yB,3));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("tB0:        %12.4le\n",tfinal);
-  printf("dG/dp:      %12.4le %12.4le %12.4le\n", 
+  printf("tB0:        %12.4e\n",tfinal);
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
          -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
-  printf("lambda(t0): %12.4le %12.4le %12.4le\n", 
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
          Ith(yB,1), Ith(yB,2), Ith(yB,3));
 #else
   printf("tB0:        %12.4e\n",tfinal);
@@ -729,7 +724,7 @@ static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasRoberts_ASAi_klu.c b/examples/idas/serial/idasRoberts_ASAi_klu.c
new file mode 100644
index 0000000..d845164
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_ASAi_klu.c
@@ -0,0 +1,768 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on idasRoberts_ASAi_dns.c and modified to use KLU
+ * -----------------------------------------------------------------
+ * Adjoint sensitivity example problem.
+ *
+ * This simple example problem for IDAS, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt + p1*y1 - p2*y2*y3            = 0
+ *      dy2/dt - p1*y1 + p2*y2*y3 + p3*y2**2 = 0
+ *                 y1  +  y2  +  y3  -  1    = 0
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.The reaction rates are: p1=0.04,
+ * p2=1e4, and p3=3e7
+ *
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance.
+ *
+ * IDAS can also compute sensitivities with respect to
+ * the problem parameters p1, p2, and p3 of the following quantity:
+ *   G = int_t0^t1 g(t,p,y) dt
+ * where
+ *   g(t,p,y) = y3
+ *
+ * The gradient dG/dp is obtained as:
+ *   dG/dp = int_t0^t1 (g_p - lambda^T F_p ) dt - 
+ *           lambda^T*F_y'*y_p | _t0^t1
+ *         = int_t0^t1 (lambda^T*F_p) dt
+ * where lambda and are solutions of the adjoint system:
+ *   d(lambda^T * F_y' )/dt -lambda^T F_y = -g_y
+ *
+ * During the backward integration, IDAS also evaluates G as
+ *   G = - phi(t0)
+ * where
+ *   d(phi)/dt = g(t,y,p)
+ *   phi(t1) = 0
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <idas/idas.h>
+#include <idas/idas_klu.h>
+#include <sundials/sundials_sparse.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+/* Accessor macros */
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component i= 1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ      3             /* number of equations                  */
+
+#define RTOL     RCONST(1e-06) /* scalar relative tolerance            */
+
+#define ATOL1    RCONST(1e-08) /* vector absolute tolerance components */
+#define ATOL2    RCONST(1e-12)
+#define ATOL3    RCONST(1e-08)
+
+#define ATOLA    RCONST(1e-08) /* absolute tolerance for adjoint vars. */
+#define ATOLQ    RCONST(1e-06) /* absolute tolerance for quadratures   */
+
+#define T0       RCONST(0.0)   /* initial time                         */
+#define TOUT     RCONST(4e10)  /* final time                           */
+
+#define TB1      RCONST(50.0)  /* starting point for adjoint problem   */
+#define TB2      TOUT          /* starting point for adjoint problem   */
+
+#define T1B      RCONST(49.0)  /* for IDACalcICB                       */
+
+#define STEPS    100           /* number of steps between check points */
+
+#define NP       3             /* number of problem parameters         */
+
+#define ONE     RCONST(1.0)
+#define ZERO    RCONST(0.0)
+
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];
+} *UserData;
+
+/* Prototypes of user-supplied functions */
+
+static int res(realtype t, N_Vector yy, N_Vector yp, 
+               N_Vector resval, void *user_data);
+static int Jac(realtype t, realtype cj, 
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_data);
+static int ewt(N_Vector y, N_Vector w, void *user_data);
+
+static int resB(realtype tt, 
+                N_Vector yy, N_Vector yp,
+                N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                void *user_dataB);
+
+static int JacB(realtype tt, realtype cjB,
+                N_Vector yy, N_Vector yp,
+                N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                SlsMat JacMatB, void *user_data,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+
+static int rhsQB(realtype tt, 
+                 N_Vector yy, N_Vector yp, 
+                 N_Vector yyB, N_Vector ypB, 
+                 N_Vector rrQB, void *user_dataB);
+
+/* Prototypes of private functions */
+static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  UserData data;
+
+  void *ida_mem;
+
+  realtype reltolQ, abstolQ;
+  N_Vector yy, yp, q;
+  N_Vector yyTB1, ypTB1;
+  N_Vector id;
+
+  int steps;
+
+  int indexB;
+
+  realtype reltolB, abstolB, abstolQB;
+  N_Vector yB, ypB, qB;
+  realtype time;
+  int flag, nnz, ncheck;
+
+  IDAadjCheckPointRec *ckpnt;
+
+  long int nst, nstB;
+
+  data = NULL;
+  ckpnt = NULL;
+  ida_mem = NULL;
+  yy = yp = yB = qB = NULL;
+
+  /* Print problem description */
+  printf("\nAdjoint Sensitivity Example for Chemical Kinetics\n");
+  printf("-------------------------------------------------\n\n");
+  printf("DAE: dy1/dt + p1*y1 - p2*y2*y3 = 0\n");
+  printf("     dy2/dt - p1*y1 + p2*y2*y3 + p3*(y2)^2 = 0\n");
+  printf("               y1  +  y2  +  y3 = 0\n\n");
+  printf("Find dG/dp for\n");
+  printf("     G = int_t0^tB0 g(t,p,y) dt\n");
+  printf("     g(t,p,y) = y3\n\n\n");
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.04);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+
+  /* Initialize y */
+  yy = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yy, "N_VNew_Serial", 0)) return(1);
+  Ith(yy,1) = ONE;
+  Ith(yy,2) = ZERO;
+  Ith(yy,3) = ZERO;
+
+  /* Initialize yprime */
+  yp = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+  Ith(yp,1) = RCONST(-0.04);
+  Ith(yp,2) = RCONST( 0.04);
+  Ith(yp,3) = ZERO;
+
+  /* Initialize q */
+  q = N_VNew_Serial(1);
+  if (check_flag((void *)q, "N_VNew_Serial", 0)) return(1);
+  Ith(q,1) = ZERO;
+
+  /* Set the scalar realtive and absolute tolerances reltolQ and abstolQ */
+  reltolQ = RTOL;
+  abstolQ = ATOLQ;
+
+  /* Create and allocate IDAS memory for forward run */
+  printf("Create and allocate IDAS memory for forward runs\n");
+
+  ida_mem = IDACreate();
+  if (check_flag((void *)ida_mem, "IDACreate", 0)) return(1);
+
+  flag = IDAInit(ida_mem, res, T0, yy, yp);
+  if (check_flag(&flag, "IDAInit", 1)) return(1);
+
+  flag = IDAWFtolerances(ida_mem, ewt);
+  if (check_flag(&flag, "IDAWFtolerances", 1)) return(1);
+
+  flag = IDASetUserData(ida_mem, data);
+  if (check_flag(&flag, "IDASetUserData", 1)) return(1);
+
+  nnz = NEQ * NEQ;
+  flag = IDAKLU(ida_mem, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "IDAKLU", 1)) return(1);
+
+  flag = IDASlsSetSparseJacFn(ida_mem, Jac);
+  if (check_flag(&flag, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  flag = IDAQuadInit(ida_mem, rhsQ, q);
+  if (check_flag(&flag, "IDAQuadInit", 1)) return(1);
+
+  flag = IDAQuadSStolerances(ida_mem, reltolQ, abstolQ);
+  if (check_flag(&flag, "IDAQuadSStolerances", 1)) return(1);
+
+  flag = IDASetQuadErrCon(ida_mem, TRUE);
+  if (check_flag(&flag, "IDASetQuadErrCon", 1)) return(1);
+
+  /* Allocate global memory */
+
+  steps = STEPS;
+  flag = IDAAdjInit(ida_mem, steps, IDA_HERMITE);
+  /*flag = IDAAdjInit(ida_mem, steps, IDA_POLYNOMIAL);*/
+  if (check_flag(&flag, "IDAAdjInit", 1)) return(1);
+
+  /* Perform forward run */
+  printf("Forward integration ... ");
+
+  /* Integrate till TB1 and get the solution (y, y') at that time. */
+  flag = IDASolveF(ida_mem, TB1, &time, yy, yp, IDA_NORMAL, &ncheck);
+  if (check_flag(&flag, "IDASolveF", 1)) return(1);
+
+  yyTB1 = N_VClone(yy);
+  ypTB1 = N_VClone(yp);
+  /* Save the states at t=TB1. */
+  N_VScale(ONE, yy, yyTB1);
+  N_VScale(ONE, yp, ypTB1);
+  
+  /* Continue integrating till TOUT is reached. */
+  flag = IDASolveF(ida_mem, TOUT, &time, yy, yp, IDA_NORMAL, &ncheck);
+  if (check_flag(&flag, "IDASolveF", 1)) return(1);
+
+  flag = IDAGetNumSteps(ida_mem, &nst);
+  if (check_flag(&flag, "IDAGetNumSteps", 1)) return(1);
+
+  printf("done ( nst = %ld )\n",nst);
+
+  flag = IDAGetQuad(ida_mem, &time, q);
+  if (check_flag(&flag, "IDAGetQuad", 1)) return(1);
+
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("G:          %12.4Le \n",Ith(q,1));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("G:          %12.4e \n",Ith(q,1));
+#else
+  printf("G:          %12.4e \n",Ith(q,1));
+#endif
+  printf("--------------------------------------------------------\n\n");
+
+  /* Test check point linked list 
+     (uncomment next block to print check point information) */
+  
+  /*  
+  {
+    int i;
+    
+    printf("\nList of Check Points (ncheck = %d)\n\n", ncheck);
+    ckpnt = (IDAadjCheckPointRec *) malloc ( (ncheck+1)*sizeof(IDAadjCheckPointRec));
+    IDAGetAdjCheckPointsInfo(ida_mem, ckpnt);
+    for (i=0;i<=ncheck;i++) {
+      printf("Address:       %p\n",ckpnt[i].my_addr);
+      printf("Next:          %p\n",ckpnt[i].next_addr);
+      printf("Time interval: %le  %le\n",ckpnt[i].t0, ckpnt[i].t1);
+      printf("Step number:   %ld\n",ckpnt[i].nstep);
+      printf("Order:         %d\n",ckpnt[i].order);
+      printf("Step size:     %le\n",ckpnt[i].step);
+      printf("\n");
+    }
+    
+  }
+  */
+
+
+  /* Create BACKWARD problem. */
+
+  /* Allocate yB (i.e. lambda_0). */
+  yB = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yB, "N_VNew_Serial", 0)) return(1);
+
+  /* Consistently initialize yB. */
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = ONE;
+
+    
+  /* Allocate ypB (i.e. lambda'_0). */
+  ypB = N_VNew_Serial(NEQ);
+  if (check_flag((void *)ypB, "N_VNew_Serial", 0)) return(1);
+
+  /* Consistently initialize ypB. */
+  Ith(ypB,1) = ONE;
+  Ith(ypB,2) = ONE;
+  Ith(ypB,3) = ZERO;
+
+  
+  /* Set the scalar relative tolerance reltolB */
+  reltolB = RTOL;               
+
+  /* Set the scalar absolute tolerance abstolB */
+  abstolB = ATOLA;
+
+  /* Set the scalar absolute tolerance abstolQB */
+  abstolQB = ATOLQ;
+
+  /* Create and allocate IDAS memory for backward run */
+  printf("Create and allocate IDAS memory for backward run\n");
+
+  flag = IDACreateB(ida_mem, &indexB);
+  if (check_flag(&flag, "IDACreateB", 1)) return(1);
+
+  flag = IDAInitB(ida_mem, indexB, resB, TB2, yB, ypB);
+  if (check_flag(&flag, "IDAInitB", 1)) return(1);
+
+  flag = IDASStolerancesB(ida_mem, indexB, reltolB, abstolB);
+  if (check_flag(&flag, "IDASStolerancesB", 1)) return(1);
+
+  flag = IDASetUserDataB(ida_mem, indexB, data);
+  if (check_flag(&flag, "IDASetUserDataB", 1)) return(1);
+
+  flag = IDASetMaxNumStepsB(ida_mem, indexB, 1000);
+
+  flag = IDAKLUB(ida_mem, indexB, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "IDAKLUB", 1)) return(1);
+
+  flag = IDASlsSetSparseJacFnB(ida_mem, indexB, JacB);
+  if (check_flag(&flag, "IDASlsSetSparseJacB", 1)) return(1);
+
+
+  /* Quadrature for backward problem. */
+ 
+  /* Initialize qB */
+  qB = N_VNew_Serial(NP);
+  if (check_flag((void *)qB, "N_VNew", 0)) return(1);
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  flag = IDAQuadInitB(ida_mem, indexB, rhsQB, qB);
+  if (check_flag(&flag, "IDAQuadInitB", 1)) return(1);
+
+  flag = IDAQuadSStolerancesB(ida_mem, indexB, reltolB, abstolQB);
+  if (check_flag(&flag, "IDAQuadSStolerancesB", 1)) return(1);
+
+  /* Include quadratures in error control. */
+  flag = IDASetQuadErrConB(ida_mem, indexB, TRUE);
+  if (check_flag(&flag, "IDASetQuadErrConB", 1)) return(1);
+
+
+  /* Backward Integration */
+  printf("Backward integration ... ");
+
+  flag = IDASolveB(ida_mem, T0, IDA_NORMAL);
+  if (check_flag(&flag, "IDASolveB", 1)) return(1);
+
+  IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB), &nstB);
+  printf("done ( nst = %ld )\n", nstB);
+
+  flag = IDAGetB(ida_mem, indexB, &time, yB, ypB);
+  if (check_flag(&flag, "IDAGetB", 1)) return(1);
+
+  flag = IDAGetQuadB(ida_mem, indexB, &time, qB);
+  if (check_flag(&flag, "IDAGetB", 1)) return(1);
+
+  PrintOutput(TB2, yB, ypB, qB);
+
+
+  /* Reinitialize backward phase and start from a different time (TB1). */
+  printf("Re-initialize IDAS memory for backward run\n");
+
+  /* Both algebraic part from y and the entire y' are computed by IDACalcIC. */
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = RCONST(0.50); /* not consistent */
+
+  /* Rough guess for ypB. */
+  Ith(ypB,1) = RCONST(0.80);
+  Ith(ypB,2) = RCONST(0.75);
+  Ith(ypB,3) = ZERO;
+
+  /* Initialize qB */
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  flag = IDAReInitB(ida_mem, indexB, TB1, yB, ypB);
+  if (check_flag(&flag, "IDAReInitB", 1)) return(1);
+
+  /* Also reinitialize quadratures. */
+  flag = IDAQuadInitB(ida_mem, indexB, rhsQB, qB);
+  if (check_flag(&flag, "IDAQuadInitB", 1)) return(1);
+
+  /* Use IDACalcICB to compute consistent initial conditions 
+     for this backward problem. */
+
+  id = N_VNew_Serial(NEQ);
+  Ith(id,1) = 1.0;
+  Ith(id,2) = 1.0;
+  Ith(id,3) = 0.0;
+
+  /* Specify which variables are differential (1) and which algebraic (0).*/
+  flag = IDASetIdB(ida_mem, indexB, id);
+  if (check_flag(&flag, "IDASetId", 1)) return(1);
+
+  flag = IDACalcICB(ida_mem, indexB, T1B, yyTB1, ypTB1);
+  if (check_flag(&flag, "IDACalcICB", 1)) return(1);
+
+  /* Get the consistent IC found by IDAS. */
+  flag = IDAGetConsistentICB(ida_mem, indexB, yB, ypB);
+  if (check_flag(&flag, "IDAGetConsistentICB", 1)) return(1);
+
+  printf("Backward integration ... ");
+
+  flag = IDASolveB(ida_mem, T0, IDA_NORMAL);
+  if (check_flag(&flag, "IDASolveB", 1)) return(1);
+
+  IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB), &nstB);
+  printf("done ( nst = %ld )\n", nstB);
+
+  flag = IDAGetB(ida_mem, indexB, &time, yB, ypB);
+  if (check_flag(&flag, "IDAGetB", 1)) return(1);
+
+  flag = IDAGetQuadB(ida_mem, indexB, &time, qB);
+  if (check_flag(&flag, "IDAGetQuadB", 1)) return(1);
+
+  PrintOutput(TB1, yB, ypB, qB);
+
+  /* Free any memory used.*/
+
+  printf("Free memory\n\n");
+
+  IDAFree(&ida_mem);
+  N_VDestroy_Serial(yy);
+  N_VDestroy_Serial(yp);
+  N_VDestroy_Serial(q);
+  N_VDestroy_Serial(yB);
+  N_VDestroy_Serial(ypB);
+  N_VDestroy_Serial(qB);
+  N_VDestroy_Serial(id);
+  N_VDestroy_Serial(yyTB1);
+  N_VDestroy_Serial(ypTB1);
+
+  if (ckpnt != NULL) free(ckpnt);
+  free(data);
+
+  return(0);
+
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDAS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * f routine. Compute f(t,y). 
+*/
+
+static int res(realtype t, N_Vector yy, N_Vector yp, N_Vector resval, void *user_data)
+{
+  realtype y1, y2, y3,yp1, yp2, *rval;
+  UserData data;
+  realtype p1, p2, p3;
+
+  y1  = Ith(yy,1); y2  = Ith(yy,2); y3  = Ith(yy,3); 
+  yp1 = Ith(yp,1); yp2 = Ith(yp,2);
+  rval = N_VGetArrayPointer_Serial(resval);
+
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  rval[0] = p1*y1-p2*y2*y3;
+  rval[1] = -rval[0] + p3*y2*y2 + yp2;
+  rval[0]+= yp1;
+  rval[2] = y1+y2+y3-1;
+
+  return(0);
+}
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+*/
+
+static int Jac(realtype t, realtype cj,
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int *colptrs;
+  int *rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(yy);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = p1+cj;                        rowvals[0] = 0;
+  data[1] = -p1;                          rowvals[1] = 1;
+  data[2] = ONE;                          rowvals[2] = 2;
+
+  data[3] = -p2*yval[2];                  rowvals[3] = 0;
+  data[4] = p2*yval[2]+2*p3*yval[1]+cj;   rowvals[4] = 1;
+  data[5] = ONE;                          rowvals[5] = 2;
+
+  data[6] = -p2*yval[1];                  rowvals[6] = 0;
+  data[7] = p2*yval[1];                   rowvals[7] = 1;
+  data[8] = ONE;                          rowvals[8] = 2;
+
+  return(0);
+}
+
+/* 
+ * rhsQ routine. Compute fQ(t,y). 
+*/
+
+static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_data)
+{
+  Ith(qdot,1) = Ith(yy,3);  
+  return(0);
+}
+
+/*
+ * EwtSet function. Computes the error weights at the current solution.
+ */
+
+static int ewt(N_Vector y, N_Vector w, void *user_data)
+{
+  int i;
+  realtype yy, ww, rtol, atol[3];
+
+  rtol    = RTOL;
+  atol[0] = ATOL1;
+  atol[1] = ATOL2;
+  atol[2] = ATOL3;
+
+  for (i=1; i<=3; i++) {
+    yy = Ith(y,i);
+    ww = rtol * SUNRabs(yy) + atol[i-1];
+    if (ww <= 0.0) return (-1);
+    Ith(w,i) = 1.0/ww;
+  }
+
+  return(0);
+}
+
+ 
+/* 
+ * resB routine.
+*/
+
+static int resB(realtype tt, 
+                 N_Vector yy, N_Vector yp,
+                 N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                 void *user_dataB)
+{
+  UserData data;
+  realtype y2, y3;
+  realtype p1, p2, p3;
+  realtype l1, l2, l3;
+  realtype lp1, lp2;
+  realtype l21;
+  
+  data = (UserData) user_dataB;
+
+  /* The p vector */
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  /* The y  vector */
+  y2 = Ith(yy,2); y3 = Ith(yy,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yyB,1); l2 = Ith(yyB,2); l3 = Ith(yyB,3);
+
+  /* The lambda dot vector */
+  lp1 = Ith(ypB,1); lp2 = Ith(ypB,2);
+
+  /* Temporary variables */
+  l21 = l2-l1;
+
+  /* Load residual. */
+  Ith(rrB,1) = lp1 + p1*l21 - l3;
+  Ith(rrB,2) = lp2 - p2*y3*l21 - RCONST(2.0)*p3*y2*l2-l3;
+  Ith(rrB,3) = - p2*y2*l21 -l3 + RCONST(1.0);
+
+  return(0);
+}
+
+/*Jacobian for backward problem. */
+static int JacB(realtype tt, realtype cjB,
+                N_Vector yy, N_Vector yp,
+                N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                SlsMat JacMatB, void *user_data,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  realtype *yvalB;
+  int* colptrsB;
+  int* rowvalsB;
+  realtype* dataB;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yvalB = N_VGetArrayPointer_Serial(yy);
+  colptrsB = (*JacMatB->colptrs);
+  rowvalsB = (*JacMatB->rowvals);
+  dataB = JacMatB->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMatB);
+
+  colptrsB[0] = 0;
+  colptrsB[1] = 3;
+  colptrsB[2] = 6;
+  colptrsB[3] = 9;
+
+  dataB[0] = -p1+cjB;                          rowvalsB[0] = 0;
+  dataB[1] = p2*yvalB[2];                      rowvalsB[1] = 1;
+  dataB[2] = p2*yvalB[1];                      rowvalsB[2] = 2;
+
+  dataB[3] = p1;;                              rowvalsB[3] = 0;
+  dataB[4] = -(p2*yvalB[2]+RCONST(2.0)*p3*yvalB[1])+cjB;
+  rowvalsB[4] = 1;
+  dataB[5] = -p2*yvalB[1];                     rowvalsB[5] = 2;
+     
+  dataB[6] = -ONE;                             rowvalsB[6] = 0;
+  dataB[7] = -ONE;                             rowvalsB[7] = 1;
+  dataB[8] = -ONE;                             rowvalsB[8] = 2;
+
+  return(0);
+}
+
+static int rhsQB(realtype tt, 
+                 N_Vector yy, N_Vector yp, 
+                 N_Vector yyB, N_Vector ypB, 
+                 N_Vector rrQB, void *user_dataB)
+{
+  realtype y1, y2, y3;
+  realtype l1, l2;
+  realtype l21;
+
+  /* The y vector */
+  y1 = Ith(yy,1); y2 = Ith(yy,2); y3 = Ith(yy,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yyB,1); l2 = Ith(yyB,2);
+  
+  /* Temporary variables */
+  l21 = l2-l1;
+
+  Ith(rrQB,1) = y1*l21;
+  Ith(rrQB,2) = -y3*y2*l21;
+  Ith(rrQB,3) = -y2*y2*l2;
+
+  return(0);
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Print results after backward integration
+ */
+
+static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB)
+{
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("tB0:        %12.4Le\n",tfinal);
+  printf("dG/dp:      %12.4Le %12.4Le %12.4Le\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+  printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("tB0:        %12.4e\n",tfinal);
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+#else
+  printf("tB0:        %12.4e\n",tfinal);
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+#endif
+  printf("--------------------------------------------------------\n\n");
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/idas/serial/idasRoberts_ASAi_klu.out b/examples/idas/serial/idasRoberts_ASAi_klu.out
new file mode 100644
index 0000000..35dde25
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_ASAi_klu.out
@@ -0,0 +1,37 @@
+
+Adjoint Sensitivity Example for Chemical Kinetics
+-------------------------------------------------
+
+DAE: dy1/dt + p1*y1 - p2*y2*y3 = 0
+     dy2/dt - p1*y1 + p2*y2*y3 + p3*(y2)^2 = 0
+               y1  +  y2  +  y3 = 0
+
+Find dG/dp for
+     G = int_t0^tB0 g(t,p,y) dt
+     g(t,p,y) = y3
+
+
+Create and allocate IDAS memory for forward runs
+Forward integration ... done ( nst = 774 )
+--------------------------------------------------------
+G:            4.0000e+10 
+--------------------------------------------------------
+
+Create and allocate IDAS memory for backward run
+Backward integration ... done ( nst = 1350 )
+--------------------------------------------------------
+tB0:          4.0000e+10
+dG/dp:        1.4878e+06  -5.9467e+00   9.9112e-04
+lambda(t0):  -2.4998e+01   1.6442e-03   1.0000e+00
+--------------------------------------------------------
+
+Re-initialize IDAS memory for backward run
+Backward integration ... done ( nst = 437 )
+--------------------------------------------------------
+tB0:          5.0000e+01
+dG/dp:        1.7341e+02  -5.0592e-04   8.4323e-08
+lambda(t0):  -7.6780e+00  -1.2758e-04   1.0000e+00
+--------------------------------------------------------
+
+Free memory
+
diff --git a/examples/idas/serial/idasRoberts_ASAi_sps.c b/examples/idas/serial/idasRoberts_ASAi_sps.c
new file mode 100644
index 0000000..fb58b32
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_ASAi_sps.c
@@ -0,0 +1,769 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on idasRoberts_ASAi_dns.c and modified to use SuperLUMT
+ * -----------------------------------------------------------------
+ * Adjoint sensitivity example problem.
+ *
+ * This simple example problem for IDAS, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt + p1*y1 - p2*y2*y3            = 0
+ *      dy2/dt - p1*y1 + p2*y2*y3 + p3*y2**2 = 0
+ *                 y1  +  y2  +  y3  -  1    = 0
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.The reaction rates are: p1=0.04,
+ * p2=1e4, and p3=3e7
+ *
+ * It uses a scalar relative tolerance and a vector absolute
+ * tolerance.
+ *
+ * IDAS can also compute sensitivities with respect to
+ * the problem parameters p1, p2, and p3 of the following quantity:
+ *   G = int_t0^t1 g(t,p,y) dt
+ * where
+ *   g(t,p,y) = y3
+ *
+ * The gradient dG/dp is obtained as:
+ *   dG/dp = int_t0^t1 (g_p - lambda^T F_p ) dt - 
+ *           lambda^T*F_y'*y_p | _t0^t1
+ *         = int_t0^t1 (lambda^T*F_p) dt
+ * where lambda and are solutions of the adjoint system:
+ *   d(lambda^T * F_y' )/dt -lambda^T F_y = -g_y
+ *
+ * During the backward integration, IDAS also evaluates G as
+ *   G = - phi(t0)
+ * where
+ *   d(phi)/dt = g(t,y,p)
+ *   phi(t1) = 0
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <idas/idas.h>
+#include <idas/idas_superlumt.h>
+#include <sundials/sundials_sparse.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+/* Accessor macros */
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component i= 1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ      3             /* number of equations                  */
+
+#define RTOL     RCONST(1e-06) /* scalar relative tolerance            */
+
+#define ATOL1    RCONST(1e-08) /* vector absolute tolerance components */
+#define ATOL2    RCONST(1e-12)
+#define ATOL3    RCONST(1e-08)
+
+#define ATOLA    RCONST(1e-08) /* absolute tolerance for adjoint vars. */
+#define ATOLQ    RCONST(1e-06) /* absolute tolerance for quadratures   */
+
+#define T0       RCONST(0.0)   /* initial time                         */
+#define TOUT     RCONST(4e10)  /* final time                           */
+
+#define TB1      RCONST(50.0)  /* starting point for adjoint problem   */
+#define TB2      TOUT          /* starting point for adjoint problem   */
+
+#define T1B      RCONST(49.0)  /* for IDACalcICB                       */
+
+#define STEPS    100           /* number of steps between check points */
+
+#define NP       3             /* number of problem parameters         */
+
+#define ONE     RCONST(1.0)
+#define ZERO    RCONST(0.0)
+
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];
+} *UserData;
+
+/* Prototypes of user-supplied functions */
+
+static int res(realtype t, N_Vector yy, N_Vector yp, 
+               N_Vector resval, void *user_data);
+static int Jac(realtype t, realtype cj, 
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_data);
+static int ewt(N_Vector y, N_Vector w, void *user_data);
+
+static int resB(realtype tt, 
+                N_Vector yy, N_Vector yp,
+                N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                void *user_dataB);
+
+static int JacB(realtype tt, realtype cjB,
+                N_Vector yy, N_Vector yp,
+                N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                SlsMat JacMatB, void *user_data,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+
+static int rhsQB(realtype tt, 
+                 N_Vector yy, N_Vector yp, 
+                 N_Vector yyB, N_Vector ypB, 
+                 N_Vector rrQB, void *user_dataB);
+
+/* Prototypes of private functions */
+static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  UserData data;
+
+  void *ida_mem;
+
+  realtype reltolQ, abstolQ;
+  N_Vector yy, yp, q;
+  N_Vector yyTB1, ypTB1;
+  N_Vector id;
+
+  int steps;
+
+  int indexB;
+
+  realtype reltolB, abstolB, abstolQB;
+  N_Vector yB, ypB, qB;
+  realtype time;
+  int flag, nthreads, nnz, ncheck;
+
+  IDAadjCheckPointRec *ckpnt;
+
+  long int nst, nstB;
+
+  data = NULL;
+  ckpnt = NULL;
+  ida_mem = NULL;
+  yy = yp = yB = qB = NULL;
+
+  /* Print problem description */
+  printf("\nAdjoint Sensitivity Example for Chemical Kinetics\n");
+  printf("-------------------------------------------------\n\n");
+  printf("DAE: dy1/dt + p1*y1 - p2*y2*y3 = 0\n");
+  printf("     dy2/dt - p1*y1 + p2*y2*y3 + p3*(y2)^2 = 0\n");
+  printf("               y1  +  y2  +  y3 = 0\n\n");
+  printf("Find dG/dp for\n");
+  printf("     G = int_t0^tB0 g(t,p,y) dt\n");
+  printf("     g(t,p,y) = y3\n\n\n");
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.04);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+
+  /* Initialize y */
+  yy = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yy, "N_VNew_Serial", 0)) return(1);
+  Ith(yy,1) = ONE;
+  Ith(yy,2) = ZERO;
+  Ith(yy,3) = ZERO;
+
+  /* Initialize yprime */
+  yp = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+  Ith(yp,1) = RCONST(-0.04);
+  Ith(yp,2) = RCONST( 0.04);
+  Ith(yp,3) = ZERO;
+
+  /* Initialize q */
+  q = N_VNew_Serial(1);
+  if (check_flag((void *)q, "N_VNew_Serial", 0)) return(1);
+  Ith(q,1) = ZERO;
+
+  /* Set the scalar realtive and absolute tolerances reltolQ and abstolQ */
+  reltolQ = RTOL;
+  abstolQ = ATOLQ;
+
+  /* Create and allocate IDAS memory for forward run */
+  printf("Create and allocate IDAS memory for forward runs\n");
+
+  ida_mem = IDACreate();
+  if (check_flag((void *)ida_mem, "IDACreate", 0)) return(1);
+
+  flag = IDAInit(ida_mem, res, T0, yy, yp);
+  if (check_flag(&flag, "IDAInit", 1)) return(1);
+
+  flag = IDAWFtolerances(ida_mem, ewt);
+  if (check_flag(&flag, "IDAWFtolerances", 1)) return(1);
+
+  flag = IDASetUserData(ida_mem, data);
+  if (check_flag(&flag, "IDASetUserData", 1)) return(1);
+
+  nthreads = 1;
+  nnz = NEQ * NEQ;
+  flag = IDASuperLUMT(ida_mem, nthreads, NEQ, nnz);
+  if (check_flag(&flag, "IDASuperLUMT", 1)) return(1);
+
+  flag = IDASlsSetSparseJacFn(ida_mem, Jac);
+  if (check_flag(&flag, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  flag = IDAQuadInit(ida_mem, rhsQ, q);
+  if (check_flag(&flag, "IDAQuadInit", 1)) return(1);
+
+  flag = IDAQuadSStolerances(ida_mem, reltolQ, abstolQ);
+  if (check_flag(&flag, "IDAQuadSStolerances", 1)) return(1);
+
+  flag = IDASetQuadErrCon(ida_mem, TRUE);
+  if (check_flag(&flag, "IDASetQuadErrCon", 1)) return(1);
+
+  /* Allocate global memory */
+
+  steps = STEPS;
+  flag = IDAAdjInit(ida_mem, steps, IDA_HERMITE);
+  /*flag = IDAAdjInit(ida_mem, steps, IDA_POLYNOMIAL);*/
+  if (check_flag(&flag, "IDAAdjInit", 1)) return(1);
+
+  /* Perform forward run */
+  printf("Forward integration ... ");
+
+  /* Integrate till TB1 and get the solution (y, y') at that time. */
+  flag = IDASolveF(ida_mem, TB1, &time, yy, yp, IDA_NORMAL, &ncheck);
+  if (check_flag(&flag, "IDASolveF", 1)) return(1);
+
+  yyTB1 = N_VClone(yy);
+  ypTB1 = N_VClone(yp);
+  /* Save the states at t=TB1. */
+  N_VScale(ONE, yy, yyTB1);
+  N_VScale(ONE, yp, ypTB1);
+  
+  /* Continue integrating till TOUT is reached. */
+  flag = IDASolveF(ida_mem, TOUT, &time, yy, yp, IDA_NORMAL, &ncheck);
+  if (check_flag(&flag, "IDASolveF", 1)) return(1);
+
+  flag = IDAGetNumSteps(ida_mem, &nst);
+  if (check_flag(&flag, "IDAGetNumSteps", 1)) return(1);
+
+  printf("done ( nst = %ld )\n",nst);
+
+  flag = IDAGetQuad(ida_mem, &time, q);
+  if (check_flag(&flag, "IDAGetQuad", 1)) return(1);
+
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("G:          %12.4Le \n",Ith(q,1));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("G:          %12.4e \n",Ith(q,1));
+#else
+  printf("G:          %12.4e \n",Ith(q,1));
+#endif
+  printf("--------------------------------------------------------\n\n");
+
+  /* Test check point linked list 
+     (uncomment next block to print check point information) */
+  
+  /*  
+  {
+    int i;
+    
+    printf("\nList of Check Points (ncheck = %d)\n\n", ncheck);
+    ckpnt = (IDAadjCheckPointRec *) malloc ( (ncheck+1)*sizeof(IDAadjCheckPointRec));
+    IDAGetAdjCheckPointsInfo(ida_mem, ckpnt);
+    for (i=0;i<=ncheck;i++) {
+      printf("Address:       %p\n",ckpnt[i].my_addr);
+      printf("Next:          %p\n",ckpnt[i].next_addr);
+      printf("Time interval: %le  %le\n",ckpnt[i].t0, ckpnt[i].t1);
+      printf("Step number:   %ld\n",ckpnt[i].nstep);
+      printf("Order:         %d\n",ckpnt[i].order);
+      printf("Step size:     %le\n",ckpnt[i].step);
+      printf("\n");
+    }
+    
+  }
+  */
+
+
+  /* Create BACKWARD problem. */
+
+  /* Allocate yB (i.e. lambda_0). */
+  yB = N_VNew_Serial(NEQ);
+  if (check_flag((void *)yB, "N_VNew_Serial", 0)) return(1);
+
+  /* Consistently initialize yB. */
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = ONE;
+
+    
+  /* Allocate ypB (i.e. lambda'_0). */
+  ypB = N_VNew_Serial(NEQ);
+  if (check_flag((void *)ypB, "N_VNew_Serial", 0)) return(1);
+
+  /* Consistently initialize ypB. */
+  Ith(ypB,1) = ONE;
+  Ith(ypB,2) = ONE;
+  Ith(ypB,3) = ZERO;
+
+  
+  /* Set the scalar relative tolerance reltolB */
+  reltolB = RTOL;               
+
+  /* Set the scalar absolute tolerance abstolB */
+  abstolB = ATOLA;
+
+  /* Set the scalar absolute tolerance abstolQB */
+  abstolQB = ATOLQ;
+
+  /* Create and allocate IDAS memory for backward run */
+  printf("Create and allocate IDAS memory for backward run\n");
+
+  flag = IDACreateB(ida_mem, &indexB);
+  if (check_flag(&flag, "IDACreateB", 1)) return(1);
+
+  flag = IDAInitB(ida_mem, indexB, resB, TB2, yB, ypB);
+  if (check_flag(&flag, "IDAInitB", 1)) return(1);
+
+  flag = IDASStolerancesB(ida_mem, indexB, reltolB, abstolB);
+  if (check_flag(&flag, "IDASStolerancesB", 1)) return(1);
+
+  flag = IDASetUserDataB(ida_mem, indexB, data);
+  if (check_flag(&flag, "IDASetUserDataB", 1)) return(1);
+
+  flag = IDASetMaxNumStepsB(ida_mem, indexB, 1000);
+
+  flag = IDASuperLUMTB(ida_mem, indexB, nthreads, NEQ, nnz);
+  if (check_flag(&flag, "IDASuperLUMTB", 1)) return(1);
+
+  flag = IDASlsSetSparseJacFnB(ida_mem, indexB, JacB);
+  if (check_flag(&flag, "IDASlsSetSparseJacB", 1)) return(1);
+
+
+  /* Quadrature for backward problem. */
+ 
+  /* Initialize qB */
+  qB = N_VNew_Serial(NP);
+  if (check_flag((void *)qB, "N_VNew", 0)) return(1);
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  flag = IDAQuadInitB(ida_mem, indexB, rhsQB, qB);
+  if (check_flag(&flag, "IDAQuadInitB", 1)) return(1);
+
+  flag = IDAQuadSStolerancesB(ida_mem, indexB, reltolB, abstolQB);
+  if (check_flag(&flag, "IDAQuadSStolerancesB", 1)) return(1);
+
+  /* Include quadratures in error control. */
+  flag = IDASetQuadErrConB(ida_mem, indexB, TRUE);
+  if (check_flag(&flag, "IDASetQuadErrConB", 1)) return(1);
+
+
+  /* Backward Integration */
+  printf("Backward integration ... ");
+
+  flag = IDASolveB(ida_mem, T0, IDA_NORMAL);
+  if (check_flag(&flag, "IDASolveB", 1)) return(1);
+
+  IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB), &nstB);
+  printf("done ( nst = %ld )\n", nstB);
+
+  flag = IDAGetB(ida_mem, indexB, &time, yB, ypB);
+  if (check_flag(&flag, "IDAGetB", 1)) return(1);
+
+  flag = IDAGetQuadB(ida_mem, indexB, &time, qB);
+  if (check_flag(&flag, "IDAGetB", 1)) return(1);
+
+  PrintOutput(TB2, yB, ypB, qB);
+
+
+  /* Reinitialize backward phase and start from a different time (TB1). */
+  printf("Re-initialize IDAS memory for backward run\n");
+
+  /* Both algebraic part from y and the entire y' are computed by IDACalcIC. */
+  Ith(yB,1) = ZERO;
+  Ith(yB,2) = ZERO;
+  Ith(yB,3) = RCONST(0.50); /* not consistent */
+
+  /* Rough guess for ypB. */
+  Ith(ypB,1) = RCONST(0.80);
+  Ith(ypB,2) = RCONST(0.75);
+  Ith(ypB,3) = ZERO;
+
+  /* Initialize qB */
+  Ith(qB,1) = ZERO;
+  Ith(qB,2) = ZERO;
+  Ith(qB,3) = ZERO;
+
+  flag = IDAReInitB(ida_mem, indexB, TB1, yB, ypB);
+  if (check_flag(&flag, "IDAReInitB", 1)) return(1);
+
+  /* Also reinitialize quadratures. */
+  flag = IDAQuadInitB(ida_mem, indexB, rhsQB, qB);
+  if (check_flag(&flag, "IDAQuadInitB", 1)) return(1);
+
+  /* Use IDACalcICB to compute consistent initial conditions 
+     for this backward problem. */
+
+  id = N_VNew_Serial(NEQ);
+  Ith(id,1) = 1.0;
+  Ith(id,2) = 1.0;
+  Ith(id,3) = 0.0;
+
+  /* Specify which variables are differential (1) and which algebraic (0).*/
+  flag = IDASetIdB(ida_mem, indexB, id);
+  if (check_flag(&flag, "IDASetId", 1)) return(1);
+
+  flag = IDACalcICB(ida_mem, indexB, T1B, yyTB1, ypTB1);
+  if (check_flag(&flag, "IDACalcICB", 1)) return(1);
+
+  /* Get the consistent IC found by IDAS. */
+  flag = IDAGetConsistentICB(ida_mem, indexB, yB, ypB);
+  if (check_flag(&flag, "IDAGetConsistentICB", 1)) return(1);
+
+  printf("Backward integration ... ");
+
+  flag = IDASolveB(ida_mem, T0, IDA_NORMAL);
+  if (check_flag(&flag, "IDASolveB", 1)) return(1);
+
+  IDAGetNumSteps(IDAGetAdjIDABmem(ida_mem, indexB), &nstB);
+  printf("done ( nst = %ld )\n", nstB);
+
+  flag = IDAGetB(ida_mem, indexB, &time, yB, ypB);
+  if (check_flag(&flag, "IDAGetB", 1)) return(1);
+
+  flag = IDAGetQuadB(ida_mem, indexB, &time, qB);
+  if (check_flag(&flag, "IDAGetQuadB", 1)) return(1);
+
+  PrintOutput(TB1, yB, ypB, qB);
+
+  /* Free any memory used.*/
+
+  printf("Free memory\n\n");
+
+  IDAFree(&ida_mem);
+  N_VDestroy_Serial(yy);
+  N_VDestroy_Serial(yp);
+  N_VDestroy_Serial(q);
+  N_VDestroy_Serial(yB);
+  N_VDestroy_Serial(ypB);
+  N_VDestroy_Serial(qB);
+  N_VDestroy_Serial(id);
+  N_VDestroy_Serial(yyTB1);
+  N_VDestroy_Serial(ypTB1);
+
+  if (ckpnt != NULL) free(ckpnt);
+  free(data);
+
+  return(0);
+
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDAS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * f routine. Compute f(t,y). 
+*/
+
+static int res(realtype t, N_Vector yy, N_Vector yp, N_Vector resval, void *user_data)
+{
+  realtype y1, y2, y3,yp1, yp2, *rval;
+  UserData data;
+  realtype p1, p2, p3;
+
+  y1  = Ith(yy,1); y2  = Ith(yy,2); y3  = Ith(yy,3); 
+  yp1 = Ith(yp,1); yp2 = Ith(yp,2);
+  rval = N_VGetArrayPointer_Serial(resval);
+
+  data = (UserData) user_data;
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  rval[0] = p1*y1-p2*y2*y3;
+  rval[1] = -rval[0] + p3*y2*y2 + yp2;
+  rval[0]+= yp1;
+  rval[2] = y1+y2+y3-1;
+
+  return(0);
+}
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+*/
+
+static int Jac(realtype t, realtype cj,
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int *colptrs;
+  int *rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(yy);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = p1+cj;                        rowvals[0] = 0;
+  data[1] = -p1;                          rowvals[1] = 1;
+  data[2] = ONE;                          rowvals[2] = 2;
+
+  data[3] = -p2*yval[2];                  rowvals[3] = 0;
+  data[4] = p2*yval[2]+2*p3*yval[1]+cj;   rowvals[4] = 1;
+  data[5] = ONE;                          rowvals[5] = 2;
+
+  data[6] = -p2*yval[1];                  rowvals[6] = 0;
+  data[7] = p2*yval[1];                   rowvals[7] = 1;
+  data[8] = ONE;                          rowvals[8] = 2;
+
+  return(0);
+}
+
+/* 
+ * rhsQ routine. Compute fQ(t,y). 
+*/
+
+static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_data)
+{
+  Ith(qdot,1) = Ith(yy,3);  
+  return(0);
+}
+
+/*
+ * EwtSet function. Computes the error weights at the current solution.
+ */
+
+static int ewt(N_Vector y, N_Vector w, void *user_data)
+{
+  int i;
+  realtype yy, ww, rtol, atol[3];
+
+  rtol    = RTOL;
+  atol[0] = ATOL1;
+  atol[1] = ATOL2;
+  atol[2] = ATOL3;
+
+  for (i=1; i<=3; i++) {
+    yy = Ith(y,i);
+    ww = rtol * SUNRabs(yy) + atol[i-1];
+    if (ww <= 0.0) return (-1);
+    Ith(w,i) = 1.0/ww;
+  }
+
+  return(0);
+}
+
+ 
+/* 
+ * resB routine.
+*/
+
+static int resB(realtype tt, 
+                 N_Vector yy, N_Vector yp,
+                 N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                 void *user_dataB)
+{
+  UserData data;
+  realtype y2, y3;
+  realtype p1, p2, p3;
+  realtype l1, l2, l3;
+  realtype lp1, lp2;
+  realtype l21;
+  
+  data = (UserData) user_dataB;
+
+  /* The p vector */
+  p1 = data->p[0]; p2 = data->p[1]; p3 = data->p[2];
+
+  /* The y  vector */
+  y2 = Ith(yy,2); y3 = Ith(yy,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yyB,1); l2 = Ith(yyB,2); l3 = Ith(yyB,3);
+
+  /* The lambda dot vector */
+  lp1 = Ith(ypB,1); lp2 = Ith(ypB,2);
+
+  /* Temporary variables */
+  l21 = l2-l1;
+
+  /* Load residual. */
+  Ith(rrB,1) = lp1 + p1*l21 - l3;
+  Ith(rrB,2) = lp2 - p2*y3*l21 - RCONST(2.0)*p3*y2*l2-l3;
+  Ith(rrB,3) = - p2*y2*l21 -l3 + RCONST(1.0);
+
+  return(0);
+}
+
+/*Jacobian for backward problem. */
+static int JacB(realtype tt, realtype cjB,
+                N_Vector yy, N_Vector yp,
+                N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                SlsMat JacMatB, void *user_data,
+                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  realtype *yvalB;
+  int* colptrsB;
+  int* rowvalsB;
+  realtype* dataB;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yvalB = N_VGetArrayPointer_Serial(yy);
+  colptrsB = (*JacMatB->colptrs);
+  rowvalsB = (*JacMatB->rowvals);
+  dataB = JacMatB->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMatB);
+
+  colptrsB[0] = 0;
+  colptrsB[1] = 3;
+  colptrsB[2] = 6;
+  colptrsB[3] = 9;
+
+  dataB[0] = -p1+cjB;                          rowvalsB[0] = 0;
+  dataB[1] = p2*yvalB[2];                      rowvalsB[1] = 1;
+  dataB[2] = p2*yvalB[1];                      rowvalsB[2] = 2;
+
+  dataB[3] = p1;;                              rowvalsB[3] = 0;
+  dataB[4] = -(p2*yvalB[2]+RCONST(2.0)*p3*yvalB[1])+cjB;
+  rowvalsB[4] = 1;
+  dataB[5] = -p2*yvalB[1];                     rowvalsB[5] = 2;
+     
+  dataB[6] = -ONE;                             rowvalsB[6] = 0;
+  dataB[7] = -ONE;                             rowvalsB[7] = 1;
+  dataB[8] = -ONE;                             rowvalsB[8] = 2;
+
+  return(0);
+}
+
+static int rhsQB(realtype tt, 
+                 N_Vector yy, N_Vector yp, 
+                 N_Vector yyB, N_Vector ypB, 
+                 N_Vector rrQB, void *user_dataB)
+{
+  realtype y1, y2, y3;
+  realtype l1, l2;
+  realtype l21;
+
+  /* The y vector */
+  y1 = Ith(yy,1); y2 = Ith(yy,2); y3 = Ith(yy,3);
+  
+  /* The lambda vector */
+  l1 = Ith(yyB,1); l2 = Ith(yyB,2);
+  
+  /* Temporary variables */
+  l21 = l2-l1;
+
+  Ith(rrQB,1) = y1*l21;
+  Ith(rrQB,2) = -y3*y2*l21;
+  Ith(rrQB,3) = -y2*y2*l2;
+
+  return(0);
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Print results after backward integration
+ */
+
+static void PrintOutput(realtype tfinal, N_Vector yB, N_Vector ypB, N_Vector qB)
+{
+  printf("--------------------------------------------------------\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("tB0:        %12.4Le\n",tfinal);
+  printf("dG/dp:      %12.4Le %12.4Le %12.4Le\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+  printf("lambda(t0): %12.4Le %12.4Le %12.4Le\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("tB0:        %12.4e\n",tfinal);
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+#else
+  printf("tB0:        %12.4e\n",tfinal);
+  printf("dG/dp:      %12.4e %12.4e %12.4e\n", 
+         -Ith(qB,1), -Ith(qB,2), -Ith(qB,3));
+  printf("lambda(t0): %12.4e %12.4e %12.4e\n", 
+         Ith(yB,1), Ith(yB,2), Ith(yB,3));
+#endif
+  printf("--------------------------------------------------------\n\n");
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/idas/serial/idasRoberts_ASAi_sps.out b/examples/idas/serial/idasRoberts_ASAi_sps.out
new file mode 100644
index 0000000..21ea3e2
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_ASAi_sps.out
@@ -0,0 +1,37 @@
+
+Adjoint Sensitivity Example for Chemical Kinetics
+-------------------------------------------------
+
+DAE: dy1/dt + p1*y1 - p2*y2*y3 = 0
+     dy2/dt - p1*y1 + p2*y2*y3 + p3*(y2)^2 = 0
+               y1  +  y2  +  y3 = 0
+
+Find dG/dp for
+     G = int_t0^tB0 g(t,p,y) dt
+     g(t,p,y) = y3
+
+
+Create and allocate IDAS memory for forward runs
+Forward integration ... done ( nst = 774 )
+--------------------------------------------------------
+G:            4.0000e+10 
+--------------------------------------------------------
+
+Create and allocate IDAS memory for backward run
+Backward integration ... done ( nst = 1303 )
+--------------------------------------------------------
+tB0:          4.0000e+10
+dG/dp:        1.4878e+06  -5.9467e+00   9.9112e-04
+lambda(t0):  -2.4998e+01   1.6442e-03   1.0000e+00
+--------------------------------------------------------
+
+Re-initialize IDAS memory for backward run
+Backward integration ... done ( nst = 416 )
+--------------------------------------------------------
+tB0:          5.0000e+01
+dG/dp:        1.7341e+02  -5.0592e-04   8.4323e-08
+lambda(t0):  -7.6780e+00  -1.2758e-04   1.0000e+00
+--------------------------------------------------------
+
+Free memory
+
diff --git a/examples/idas/serial/idasRoberts_FSA_dns.c b/examples/idas/serial/idasRoberts_FSA_dns.c
index 68b487c..30afa2e 100644
--- a/examples/idas/serial/idasRoberts_FSA_dns.c
+++ b/examples/idas/serial/idasRoberts_FSA_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2008/04/15 16:37:37 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Cosmin Petra and Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -102,7 +102,7 @@ static void PrintSensOutput(N_Vector *uS);
 
 static void PrintFinalStats(void *ida_mem, booleantype sensi);
 
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 /*
  *--------------------------------------------------------------------
  * MAIN PROGRAM
@@ -123,6 +123,8 @@ int main(int argc, char *argv[])
   booleantype sensi, err_con;
   int sensi_meth;
 
+  N_Vector yQ, *yQS;
+
   ida_mem = NULL;
   data    = NULL;
   y       =  NULL;
@@ -243,7 +245,6 @@ int main(int argc, char *argv[])
   /*----------------------------------------------------------
    *               Q U A D R A T U R E S
    * ---------------------------------------------------------*/
-  N_Vector yQ, *yQS;
   yQ = N_VNew_Serial(2);
 
   Ith(yQ,1) = 0;
@@ -511,23 +512,23 @@ static void PrintIC(N_Vector y, N_Vector yp)
 {
   realtype* data;
 
-  data = NV_DATA_S(y);
+  data = N_VGetArrayPointer_Serial(y);
   printf("\n\nConsistent IC:\n");
   printf("\ty = ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", data[0], data[1], data[2]);
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
 #endif
 
-  data = NV_DATA_S(yp);
+  data = N_VGetArrayPointer_Serial(yp);
   printf("\typ= ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", data[0], data[1], data[2]);
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
 #endif
@@ -537,65 +538,65 @@ static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS)
 {
   realtype *sdata;
 
-  sdata = NV_DATA_S(yS[0]);
+  sdata = N_VGetArrayPointer_Serial(yS[0]);
   printf("                  Sensitivity 1  ");
 
   printf("\n\ts1 = ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
-  sdata = NV_DATA_S(ypS[0]);
+  sdata = N_VGetArrayPointer_Serial(ypS[0]);
   printf("\ts1'= ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
 
 
   printf("                  Sensitivity 2  ");
-  sdata = NV_DATA_S(yS[1]);
+  sdata = N_VGetArrayPointer_Serial(yS[1]);
   printf("\n\ts2 = ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
-  sdata = NV_DATA_S(ypS[1]);
+  sdata = N_VGetArrayPointer_Serial(ypS[1]);
   printf("\ts2'= ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
 
 
   printf("                  Sensitivity 3  ");
-  sdata = NV_DATA_S(yS[2]);
+  sdata = N_VGetArrayPointer_Serial(yS[2]);
   printf("\n\ts3 = ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
-  sdata = NV_DATA_S(ypS[2]);
+  sdata = N_VGetArrayPointer_Serial(ypS[2]);
   printf("\ts3'= ");
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
@@ -613,7 +614,7 @@ static void PrintOutput(void *ida_mem, realtype t, N_Vector u)
   int qu, flag;
   realtype hu, *udata;
   
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   flag = IDAGetNumSteps(ida_mem, &nst);
   check_flag(&flag, "IDAGetNumSteps", 1);
@@ -625,7 +626,7 @@ static void PrintOutput(void *ida_mem, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%8.3Le %2d  %8.3Le %5ld\n", t, qu, hu, nst);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%8.3le %2d  %8.3le %5ld\n", t, qu, hu, nst);
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
 #else
   printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
 #endif
@@ -635,7 +636,7 @@ static void PrintOutput(void *ida_mem, realtype t, N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", udata[0], udata[1], udata[2]);
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
 #endif
@@ -650,35 +651,35 @@ static void PrintSensOutput(N_Vector *uS)
 {
   realtype *sdata;
 
-  sdata = NV_DATA_S(uS[0]);
+  sdata = N_VGetArrayPointer_Serial(uS[0]);
   printf("                  Sensitivity 1  ");
 
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
   
-  sdata = NV_DATA_S(uS[1]);
+  sdata = N_VGetArrayPointer_Serial(uS[1]);
   printf("                  Sensitivity 2  ");
 
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
 
-  sdata = NV_DATA_S(uS[2]);
+  sdata = N_VGetArrayPointer_Serial(uS[2]);
   printf("                  Sensitivity 3  ");
 
 #if defined(SUNDIALS_EXTENDED_PRECISION)
   printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%12.4le %12.4le %12.4le \n", sdata[0], sdata[1], sdata[2]);
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #else
   printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
 #endif
@@ -757,7 +758,7 @@ static void PrintFinalStats(void *ida_mem, booleantype sensi)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasRoberts_FSA_klu.c b/examples/idas/serial/idasRoberts_FSA_klu.c
new file mode 100644
index 0000000..264b41f
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_FSA_klu.c
@@ -0,0 +1,830 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date: $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on idasRoberts_FSA_dns.c and modified to use KLU
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * This simple example problem for IDA, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt = -p1*y1 + p2*y2*y3
+ *      dy2/dt = p1*y1 - p2*y2*y3 - p3*y2**2
+ *         0   = y1 + y2 + y3 - 1
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.The reaction rates are: p1=0.04,
+ * p2=1e4, and p3=3e7
+ *
+ * Optionally, IDAS can compute sensitivities with respect to the
+ * problem parameters p1, p2, and p3.
+ * The sensitivity right hand side is given analytically through the
+ * user routine fS (of type SensRhs1Fn).
+ * Any of two sensitivity methods (SIMULTANEOUS and STAGGERED can be
+ * used and sensitivities may be included in the error test or not 
+ *(error control set on TRUE or FALSE, respectively).
+ *
+ * Execution:
+ *
+ * If no sensitivities are desired:
+ *    % idasRoberts_FSA_klu -nosensi
+ * If sensitivities are to be computed:
+ *    % idasRoberts_FSA_klu -sensi sensi_meth err_con
+ * where sensi_meth is one of {sim, stg} and err_con is one of
+ * {t, f}.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Header files with a description of contents used */
+
+#include <idas/idas.h>                 /* prototypes for IDAS fcts. and consts. */
+#include <idas/idas_klu.h>             /* prototypes for IDAKLU fcts. and constants */
+#include <sundials/sundials_sparse.h>  /* defs. of SlsMat */
+#include <nvector/nvector_serial.h>    /* defs. of serial NVECTOR fcts. and macros  */
+#include <sundials/sundials_types.h>   /* def. of type realtype */
+#include <sundials/sundials_math.h>    /* definition of ABS */
+
+/* Accessor macros */
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component i=1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ   3             /* number of equations  */
+#define T0    RCONST(0.0)   /* initial time */
+#define T1    RCONST(0.4)   /* first output time */
+#define TMULT RCONST(10.0)  /* output time factor */
+#define NOUT  12            /* number of output times */
+
+#define NP    3             /* number of problem parameters */
+#define NS    3             /* number of sensitivities computed */
+
+#define ZERO  RCONST(0.0)
+#define ONE   RCONST(1.0)
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];           /* problem parameters */
+  realtype coef;
+} *UserData;
+
+/* Prototypes of functions by IDAS */
+
+static int res(realtype t, N_Vector y, N_Vector yp, N_Vector resval, void *user_data);
+
+static int Jac(realtype t, realtype cj, 
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int resS(int Ns, realtype t, 
+                N_Vector y, N_Vector yp, N_Vector resval,
+                N_Vector *yyS, N_Vector *ypS, N_Vector *resvalS,
+                void *user_data, 
+                N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int rhsQ(realtype tres, N_Vector yy, N_Vector yp,
+                 N_Vector rrQ, void *user_data);
+
+/* Prototypes of private functions */
+
+static void ProcessArgs(int argc, char *argv[],
+                        booleantype *sensi, int *sensi_meth, 
+                        booleantype *err_con);
+static void WrongArgs(char *name);
+
+static void PrintIC(N_Vector y, N_Vector yp);
+static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS); 
+
+static void PrintOutput(void *ida_mem, realtype t, N_Vector u);
+static void PrintSensOutput(N_Vector *uS);
+
+static void PrintFinalStats(void *ida_mem, booleantype sensi);
+
+static int check_flag(void *flagvalue, char *funcname, int opt);
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  void *ida_mem;
+  UserData data;
+  realtype reltol, t, tout;
+  N_Vector y, yp, abstol, id;
+  int iout, flag, nnz;
+
+  realtype pbar[NS];
+  int is; 
+  N_Vector *yS, *ypS;
+  booleantype sensi, err_con;
+  int sensi_meth;
+
+  N_Vector yQ, *yQS;
+
+  ida_mem = NULL;
+  data    = NULL;
+  y       =  NULL;
+  yS      = NULL;
+  ypS     = NULL;
+
+  /* Process arguments */
+  ProcessArgs(argc, argv, &sensi, &sensi_meth, &err_con);
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.040);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+  data->coef = 0.5;
+
+  /* Initial conditions */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+
+  Ith(y,1) = ONE;
+  Ith(y,2) = ZERO;
+  Ith(y,3) = ZERO;
+
+  yp = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+
+  /* These initial conditions are NOT consistent. See IDACalcIC below. */
+  Ith(yp,1) = RCONST(0.1);
+  Ith(yp,2) = ZERO;
+  Ith(yp,3) = ZERO;  
+
+  /* Create IDAS object */
+  ida_mem = IDACreate();
+  if (check_flag((void *)ida_mem, "IDACreate", 0)) return(1);
+
+  /* Allocate space for IDAS */
+  flag = IDAInit(ida_mem, res, T0, y, yp);
+  if (check_flag(&flag, "IDAInit", 1)) return(1);
+
+  /* Specify scalar relative tol. and vector absolute tol. */
+  reltol = RCONST(1.0e-6);
+  abstol = N_VNew_Serial(NEQ);
+  Ith(abstol,1) = RCONST(1.0e-8);
+  Ith(abstol,2) = RCONST(1.0e-14);
+  Ith(abstol,3) = RCONST(1.0e-6);
+  flag = IDASVtolerances(ida_mem, reltol, abstol);
+  if (check_flag(&flag, "IDASVtolerances", 1)) return(1);
+
+  /* Set ID vector */
+  id = N_VNew_Serial(NEQ);
+  Ith(id,1) = 1.0;
+  Ith(id,2) = 1.0;
+  Ith(id,3) = 0.0;
+  flag = IDASetId(ida_mem, id);
+  if (check_flag(&flag, "IDASetId", 1)) return(1);
+
+  /* Attach user data */
+  flag = IDASetUserData(ida_mem, data);
+  if (check_flag(&flag, "IDASetUserData", 1)) return(1);
+
+  /* Attach linear solver */
+  nnz = NEQ * NEQ;
+  flag = IDAKLU(ida_mem, NEQ, nnz, CSC_MAT);
+  if (check_flag(&flag, "IDAKLU", 1)) return(1);
+
+  flag = IDASlsSetSparseJacFn(ida_mem, Jac);
+  if (check_flag(&flag, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  printf("\n3-species chemical kinetics problem\n");
+
+  /* Sensitivity-related settings */
+  if (sensi) {
+
+    pbar[0] = data->p[0];
+    pbar[1] = data->p[1];
+    pbar[2] = data->p[2];
+
+    yS = N_VCloneVectorArray_Serial(NS, y);
+    if (check_flag((void *)yS, "N_VCloneVectorArray_Serial", 0)) return(1);
+    for (is=0;is<NS;is++) N_VConst(ZERO, yS[is]);
+    
+    ypS = N_VCloneVectorArray_Serial(NS, y);
+    if (check_flag((void *)ypS, "N_VCloneVectorArray_Serial", 0)) return(1);
+    for (is=0;is<NS;is++) N_VConst(ZERO, ypS[is]);
+
+    /* 
+    * Only non-zero sensitivity I.C. are ypS[0]: 
+    * - Ith(ypS[0],1) = -ONE;
+    * - Ith(ypS[0],2) =  ONE;
+    *
+    * They are not set. IDACalcIC also computes consistent IC for sensitivities.
+    */
+    
+    flag = IDASensInit(ida_mem, NS, sensi_meth, resS, yS, ypS);
+    if(check_flag(&flag, "IDASensInit", 1)) return(1);
+
+    flag = IDASensEEtolerances(ida_mem);
+    if(check_flag(&flag, "IDASensEEtolerances", 1)) return(1);
+
+    flag = IDASetSensErrCon(ida_mem, err_con);
+    if (check_flag(&flag, "IDASetSensErrCon", 1)) return(1);
+
+    flag = IDASetSensParams(ida_mem, data->p, pbar, NULL);
+    if (check_flag(&flag, "IDASetSensParams", 1)) return(1);
+
+    printf("Sensitivity: YES ");
+    if(sensi_meth == IDA_SIMULTANEOUS)   
+      printf("( SIMULTANEOUS +");
+    else 
+      printf("( STAGGERED +");   
+    if(err_con) printf(" FULL ERROR CONTROL )");
+    else        printf(" PARTIAL ERROR CONTROL )");
+
+  } else {
+
+    printf("Sensitivity: NO ");
+
+  }
+
+  /*----------------------------------------------------------
+   *               Q U A D R A T U R E S
+   * ---------------------------------------------------------*/
+  yQ = N_VNew_Serial(2);
+
+  Ith(yQ,1) = 0;
+  Ith(yQ,2) = 0;
+
+  IDAQuadInit(ida_mem, rhsQ, yQ);
+
+  yQS = N_VCloneVectorArray_Serial(NS, yQ);
+  for (is=0;is<NS;is++) N_VConst(ZERO, yQS[is]);  
+
+  IDAQuadSensInit(ida_mem, NULL, yQS);
+
+  /* Call IDACalcIC to compute consistent initial conditions. If sensitivity is
+     enabled, this function also try to find consistent IC for the sensitivities. */
+
+  flag = IDACalcIC(ida_mem, IDA_YA_YDP_INIT, T1);;
+  if (check_flag(&flag, "IDACalcIC", 1)) return(1);
+
+  flag = IDAGetConsistentIC(ida_mem, y, yp);
+  if (check_flag(&flag, "IDAGetConsistentIC", 1)) return(1);
+
+  PrintIC(y, yp);
+
+  if(sensi) {
+      IDAGetSensConsistentIC(ida_mem, yS, ypS);
+      PrintSensIC(y, yp, yS, ypS); 
+    }
+      
+  /* In loop over output points, call IDA, print results, test for error */
+  
+  printf("\n\n");
+  printf("===========================================");
+  printf("============================\n");
+  printf("     T     Q       H      NST           y1");
+  printf("           y2           y3    \n");
+  printf("===========================================");
+  printf("============================\n");
+
+  for (iout=1, tout=T1; iout <= NOUT; iout++, tout *= TMULT) {
+    
+    flag = IDASolve(ida_mem, tout, &t, y, yp, IDA_NORMAL);
+    if (check_flag(&flag, "IDASolve", 1)) break;
+
+    PrintOutput(ida_mem, t, y);
+    
+    if (sensi) {
+      flag = IDAGetSens(ida_mem, &t, yS);
+      if (check_flag(&flag, "IDAGetSens", 1)) break;
+      PrintSensOutput(yS);
+    } 
+    printf("-----------------------------------------");
+    printf("------------------------------\n");
+
+  }
+
+  printf("\nQuadrature:\n");
+  IDAGetQuad(ida_mem, &t, yQ);
+  printf("G:      %10.4e\n", Ith(yQ,1)); 
+
+  if(sensi) {
+    IDAGetQuadSens(ida_mem, &t, yQS);
+    printf("\nSensitivities at t=%g:\n",t);
+    printf("dG/dp1: %11.4e\n", Ith(yQS[0], 1));
+    printf("dG/dp1: %11.4e\n", Ith(yQS[1], 1));
+    printf("dG/dp1: %11.4e\n", Ith(yQS[2], 1));
+  }
+
+  /* Print final statistics */
+  PrintFinalStats(ida_mem, sensi);
+
+  /* Free memory */
+  N_VDestroy_Serial(y);
+  if (sensi) {
+    N_VDestroyVectorArray_Serial(yS, NS);
+  }
+  free(data);
+  IDAFree(&ida_mem);
+  N_VDestroy_Serial(yQ);
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDAS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Residual routine. Compute F(t,y,y',p). 
+ */
+static int res(realtype t, N_Vector yy, N_Vector yp, N_Vector resval, void *user_data)
+{
+  UserData data;
+  realtype p1, p2, p3;
+  realtype y1, y2, y3;
+  realtype yp1, yp2;
+
+  data = (UserData) user_data;
+  p1 = data->p[0];
+  p2 = data->p[1];
+  p3 = data->p[2];
+
+  y1 = Ith(yy,1);
+  y2 = Ith(yy,2);
+  y3 = Ith(yy,3);
+
+  yp1 = Ith(yp,1);
+  yp2 = Ith(yp,2);
+
+  Ith(resval,1) = yp1 + p1*y1 - p2*y2*y3;
+  Ith(resval,2) = yp2 - p1*y1 + p2*y2*y3 + p3*y2*y2;
+  Ith(resval,3) = y1 + y2 + y3 - ONE;
+
+  return(0);
+}
+
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+*/
+
+static int Jac(realtype t, realtype cj,
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int *colptrs;
+  int *rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(yy);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = p1+cj;                        rowvals[0] = 0;
+  data[1] = -p1;                          rowvals[1] = 1;
+  data[2] = ONE;                          rowvals[2] = 2;
+
+  data[3] = -p2*yval[2];                  rowvals[3] = 0;
+  data[4] = p2*yval[2]+2*p3*yval[1]+cj;   rowvals[4] = 1;
+  data[5] = ONE;                          rowvals[5] = 2;
+
+  data[6] = -p2*yval[1];                  rowvals[6] = 0;
+  data[7] = p2*yval[1];                   rowvals[7] = 1;
+  data[8] = ONE;                          rowvals[8] = 2;
+
+  return(0);
+}
+ 
+/* 
+ * resS routine. Compute sensitivity r.h.s. 
+ */
+
+static int resS(int Ns, realtype t, 
+                N_Vector yy, N_Vector yp, N_Vector resval,
+                N_Vector *yyS, N_Vector *ypS, N_Vector *resvalS,
+                void *user_data, 
+                N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  UserData data;
+  realtype p1, p2, p3;
+  realtype y1, y2, y3;
+  realtype s1, s2, s3;
+  realtype sd1, sd2;
+  realtype rs1, rs2, rs3;
+  int is;
+
+  data = (UserData) user_data;
+  p1 = data->p[0];
+  p2 = data->p[1];
+  p3 = data->p[2];
+
+  y1 = Ith(yy,1);
+  y2 = Ith(yy,2);
+  y3 = Ith(yy,3);
+
+  for (is=0; is<NS; is++) {
+
+    s1 = Ith(yyS[is],1);
+    s2 = Ith(yyS[is],2);
+    s3 = Ith(yyS[is],3);
+
+    sd1 = Ith(ypS[is],1);
+    sd2 = Ith(ypS[is],2);
+
+    rs1 = sd1 + p1*s1 - p2*y3*s2 - p2*y2*s3;
+    rs2 = sd2 - p1*s1 + p2*y3*s2 + p2*y2*s3 + 2*p3*y2*s2;
+    rs3 = s1 + s2 + s3;
+
+    switch (is) {
+    case 0:
+      rs1 += y1;
+      rs2 -= y1;
+      break;
+    case 1:
+      rs1 -= y2*y3;
+      rs2 += y2*y3;
+      break;
+    case 2:
+      rs2 += y2*y2;
+      break;
+    }
+  
+    Ith(resvalS[is],1) = rs1;
+    Ith(resvalS[is],2) = rs2;
+    Ith(resvalS[is],3) = rs3;
+
+  }
+
+  return(0);
+}
+
+static int rhsQ(realtype t, N_Vector y, N_Vector yp, 
+              N_Vector ypQ, void* user_data)
+{
+  UserData data;
+
+  data = (UserData) user_data;
+
+  Ith(ypQ,1) = Ith(y,3);
+  
+  Ith(ypQ,2) = data->coef*( Ith(y,1)*Ith(y,1)+ 
+                            Ith(y,2)*Ith(y,2)+ 
+                            Ith(y,3)*Ith(y,3) );
+                    
+  return(0);
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Process and verify arguments to idasfwddenx.
+ */
+
+static void ProcessArgs(int argc, char *argv[], 
+                        booleantype *sensi, int *sensi_meth, booleantype *err_con)
+{
+  *sensi = FALSE;
+  *sensi_meth = -1;
+  *err_con = FALSE;
+
+  if (argc < 2) WrongArgs(argv[0]);
+
+  if (strcmp(argv[1],"-nosensi") == 0)
+    *sensi = FALSE;
+  else if (strcmp(argv[1],"-sensi") == 0)
+    *sensi = TRUE;
+  else
+    WrongArgs(argv[0]);
+  
+  if (*sensi) {
+
+    if (argc != 4)
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[2],"sim") == 0)
+      *sensi_meth = IDA_SIMULTANEOUS;
+    else if (strcmp(argv[2],"stg") == 0)
+      *sensi_meth = IDA_STAGGERED;
+    else 
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[3],"t") == 0)
+      *err_con = TRUE;
+    else if (strcmp(argv[3],"f") == 0)
+      *err_con = FALSE;
+    else
+      WrongArgs(argv[0]);
+  }
+
+}
+
+static void WrongArgs(char *name)
+{
+    printf("\nUsage: %s [-nosensi] [-sensi sensi_meth err_con]\n",name);
+    printf("         sensi_meth = sim or stg\n");
+    printf("         err_con    = t or f\n");
+    
+    exit(0);
+}
+
+
+static void PrintIC(N_Vector y, N_Vector yp)
+{
+  realtype* data;
+
+  data = N_VGetArrayPointer_Serial(y);
+  printf("\n\nConsistent IC:\n");
+  printf("\ty = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#endif
+
+  data = N_VGetArrayPointer_Serial(yp);
+  printf("\typ= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#endif
+
+}
+static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS)
+{
+  realtype *sdata;
+
+  sdata = N_VGetArrayPointer_Serial(yS[0]);
+  printf("                  Sensitivity 1  ");
+
+  printf("\n\ts1 = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  sdata = N_VGetArrayPointer_Serial(ypS[0]);
+  printf("\ts1'= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+
+  printf("                  Sensitivity 2  ");
+  sdata = N_VGetArrayPointer_Serial(yS[1]);
+  printf("\n\ts2 = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  sdata = N_VGetArrayPointer_Serial(ypS[1]);
+  printf("\ts2'= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+
+  printf("                  Sensitivity 3  ");
+  sdata = N_VGetArrayPointer_Serial(yS[2]);
+  printf("\n\ts3 = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  sdata = N_VGetArrayPointer_Serial(ypS[2]);
+  printf("\ts3'= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+
+}
+
+/*
+ * Print current t, step count, order, stepsize, and solution.
+ */
+
+static void PrintOutput(void *ida_mem, realtype t, N_Vector u)
+{
+  long int nst;
+  int qu, flag;
+  realtype hu, *udata;
+  
+  udata = N_VGetArrayPointer_Serial(u);
+
+  flag = IDAGetNumSteps(ida_mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetLastOrder(ida_mem, &qu);
+  check_flag(&flag, "IDAGetLastOrder", 1);
+  flag = IDAGetLastStep(ida_mem, &hu);
+  check_flag(&flag, "IDAGetLastStep", 1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%8.3Le %2d  %8.3Le %5ld\n", t, qu, hu, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#else
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#endif
+
+  printf("                  Solution       ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#endif
+
+}
+
+/* 
+ * Print sensitivities.
+*/
+
+static void PrintSensOutput(N_Vector *uS)
+{
+  realtype *sdata;
+
+  sdata = N_VGetArrayPointer_Serial(uS[0]);
+  printf("                  Sensitivity 1  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  
+  sdata = N_VGetArrayPointer_Serial(uS[1]);
+  printf("                  Sensitivity 2  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+  sdata = N_VGetArrayPointer_Serial(uS[2]);
+  printf("                  Sensitivity 3  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+}
+
+/* 
+ * Print some final statistics from the IDAS memory.
+ */
+
+static void PrintFinalStats(void *ida_mem, booleantype sensi)
+{
+  long int nst;
+  long int nfe, nsetups, nni, ncfn, netf;
+  long int nfSe, nfeS, nsetupsS, nniS, ncfnS, netfS;
+  int flag;
+
+  flag = IDAGetNumSteps(ida_mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetNumResEvals(ida_mem, &nfe);
+  check_flag(&flag, "IDAGetNumRhsEvals", 1);
+  flag = IDAGetNumLinSolvSetups(ida_mem, &nsetups);
+  check_flag(&flag, "IDAGetNumLinSolvSetups", 1);
+  flag = IDAGetNumErrTestFails(ida_mem, &netf);
+  check_flag(&flag, "IDAGetNumErrTestFails", 1);
+  flag = IDAGetNumNonlinSolvIters(ida_mem, &nni);
+  check_flag(&flag, "IDAGetNumNonlinSolvIters", 1);
+  flag = IDAGetNumNonlinSolvConvFails(ida_mem, &ncfn);
+  check_flag(&flag, "IDAGetNumNonlinSolvConvFails", 1);
+
+  if (sensi) {
+    flag = IDAGetSensNumResEvals(ida_mem, &nfSe);
+    check_flag(&flag, "IDAGetSensNumRhsEvals", 1);
+    flag = IDAGetNumResEvalsSens(ida_mem, &nfeS);
+    check_flag(&flag, "IDAGetNumResEvalsSens", 1);
+    flag = IDAGetSensNumLinSolvSetups(ida_mem, &nsetupsS);
+    check_flag(&flag, "IDAGetSensNumLinSolvSetups", 1);
+    flag = IDAGetSensNumErrTestFails(ida_mem, &netfS);
+    check_flag(&flag, "IDAGetSensNumErrTestFails", 1);
+    flag = IDAGetSensNumNonlinSolvIters(ida_mem, &nniS);
+    check_flag(&flag, "IDAGetSensNumNonlinSolvIters", 1);
+    flag = IDAGetSensNumNonlinSolvConvFails(ida_mem, &ncfnS);
+    check_flag(&flag, "IDAGetSensNumNonlinSolvConvFails", 1);
+  }
+
+  printf("\nFinal Statistics\n\n");
+  printf("nst     = %5ld\n\n", nst);
+  printf("nfe     = %5ld\n",   nfe);
+  printf("netf    = %5ld    nsetups  = %5ld\n", netf, nsetups);
+  printf("nni     = %5ld    ncfn     = %5ld\n", nni, ncfn);
+
+  if(sensi) {
+    printf("\n");
+    printf("nfSe    = %5ld    nfeS     = %5ld\n", nfSe, nfeS);
+    printf("netfs   = %5ld    nsetupsS = %5ld\n", netfS, nsetupsS);
+    printf("nniS    = %5ld    ncfnS    = %5ld\n", nniS, ncfnS);
+  }
+
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/idas/serial/idasRoberts_FSA_klu.out b/examples/idas/serial/idasRoberts_FSA_klu.out
new file mode 100644
index 0000000..0201d41
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_FSA_klu.out
@@ -0,0 +1,113 @@
+
+3-species chemical kinetics problem
+Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL )
+
+Consistent IC:
+	y =   1.0000e+00   0.0000e+00  -8.1102e-17 
+	yp=  -4.0000e-02   4.0000e-02   0.0000e+00 
+                  Sensitivity 1  
+	s1 =   0.0000e+00   0.0000e+00   0.0000e+00 
+	s1'=  -1.0000e+00   1.0000e+00   0.0000e+00 
+                  Sensitivity 2  
+	s2 =   0.0000e+00   0.0000e+00   0.0000e+00 
+	s2'=   0.0000e+00   0.0000e+00   0.0000e+00 
+                  Sensitivity 3  
+	s3 =   0.0000e+00   0.0000e+00   0.0000e+00 
+	s3'=   0.0000e+00   0.0000e+00   0.0000e+00 
+
+
+=======================================================================
+     T     Q       H      NST           y1           y2           y3    
+=======================================================================
+4.000e-01  5  7.149e-02   212
+                  Solution         9.8517e-01   3.3864e-05   1.4794e-02 
+                  Sensitivity 1   -3.5595e-01   3.9025e-04   3.5556e-01 
+                  Sensitivity 2    9.5424e-08  -2.1310e-10  -9.5210e-08 
+                  Sensitivity 3   -1.5832e-11  -5.2900e-13   1.6361e-11 
+-----------------------------------------------------------------------
+4.000e+00  5  1.430e-01   247
+                  Solution         9.0552e-01   2.2405e-05   9.4459e-02 
+                  Sensitivity 1   -1.8761e+00   1.7922e-04   1.8759e+00 
+                  Sensitivity 2    2.9614e-06  -5.8305e-10  -2.9608e-06 
+                  Sensitivity 3   -4.9334e-10  -2.7626e-13   4.9362e-10 
+-----------------------------------------------------------------------
+4.000e+01  2  1.991e-01   380
+                  Solution         7.1583e-01   9.1855e-06   2.8416e-01 
+                  Sensitivity 1   -4.2476e+00   4.5912e-05   4.2475e+00 
+                  Sensitivity 2    1.3731e-05  -2.3572e-10  -1.3731e-05 
+                  Sensitivity 3   -2.2884e-09  -1.1381e-13   2.2885e-09 
+-----------------------------------------------------------------------
+4.000e+02  5  6.240e+00   523
+                  Solution         4.5052e-01   3.2229e-06   5.4948e-01 
+                  Sensitivity 1   -5.9584e+00   3.5427e-06   5.9584e+00 
+                  Sensitivity 2    2.2738e-05  -2.2601e-11  -2.2738e-05 
+                  Sensitivity 3   -3.7897e-09  -4.9948e-14   3.7897e-09 
+-----------------------------------------------------------------------
+4.000e+03  4  6.558e+01   685
+                  Solution         1.8320e-01   8.9424e-07   8.1680e-01 
+                  Sensitivity 1   -4.7501e+00  -5.9937e-06   4.7501e+00 
+                  Sensitivity 2    1.8809e-05   2.3127e-11  -1.8809e-05 
+                  Sensitivity 3   -3.1348e-09  -1.8758e-14   3.1348e-09 
+-----------------------------------------------------------------------
+4.000e+04  5  7.922e+02   871
+                  Solution         3.8983e-02   1.6218e-07   9.6102e-01 
+                  Sensitivity 1   -1.5750e+00  -2.7620e-06   1.5750e+00 
+                  Sensitivity 2    6.2875e-06   1.1002e-11  -6.2875e-06 
+                  Sensitivity 3   -1.0479e-09  -4.5367e-15   1.0479e-09 
+-----------------------------------------------------------------------
+4.000e+05  4  8.317e+03  1010
+                  Solution         4.9383e-03   1.9850e-08   9.9506e-01 
+                  Sensitivity 1   -2.3633e-01  -4.5841e-07   2.3633e-01 
+                  Sensitivity 2    9.4503e-07   1.8325e-12  -9.4503e-07 
+                  Sensitivity 3   -1.5751e-10  -6.3625e-16   1.5751e-10 
+-----------------------------------------------------------------------
+4.000e+06  5  1.198e+05  1104
+                  Solution         5.1681e-04   2.0683e-09   9.9948e-01 
+                  Sensitivity 1   -2.5666e-02  -5.1061e-08   2.5666e-02 
+                  Sensitivity 2    1.0266e-07   2.0423e-13  -1.0266e-07 
+                  Sensitivity 3   -1.7110e-11  -6.8510e-17   1.7110e-11 
+-----------------------------------------------------------------------
+4.000e+07  5  1.916e+06  1159
+                  Solution         5.2033e-05   2.0814e-10   9.9995e-01 
+                  Sensitivity 1   -2.5993e-03  -5.1946e-09   2.5993e-03 
+                  Sensitivity 2    1.0397e-08   2.0778e-14  -1.0397e-08 
+                  Sensitivity 3   -1.7328e-12  -6.9321e-18   1.7328e-12 
+-----------------------------------------------------------------------
+4.000e+08  4  2.483e+07  1205
+                  Solution         5.2074e-06   2.0830e-11   9.9999e-01 
+                  Sensitivity 1   -2.6034e-04  -5.2063e-10   2.6034e-04 
+                  Sensitivity 2    1.0414e-09   2.0825e-15  -1.0414e-09 
+                  Sensitivity 3   -1.7356e-13  -6.9425e-19   1.7356e-13 
+-----------------------------------------------------------------------
+4.000e+09  2  2.649e+08  1239
+                  Solution         5.2055e-07   2.0822e-12   1.0000e+00 
+                  Sensitivity 1   -2.6027e-05  -5.2052e-11   2.6027e-05 
+                  Sensitivity 2    1.0411e-10   2.0821e-16  -1.0411e-10 
+                  Sensitivity 3   -1.7351e-14  -6.9405e-20   1.7351e-14 
+-----------------------------------------------------------------------
+4.000e+10  4  4.851e+09  1262
+                  Solution         5.1638e-08   2.0655e-13   1.0000e+00 
+                  Sensitivity 1   -2.5811e-06  -5.1604e-12   2.5811e-06 
+                  Sensitivity 2    1.0324e-11   2.0642e-17  -1.0324e-11 
+                  Sensitivity 3   -1.7214e-15  -6.8856e-21   1.7214e-15 
+-----------------------------------------------------------------------
+
+Quadrature:
+G:      4.0000e+10
+
+Sensitivities at t=4e+10:
+dG/dp1:  1.4874e+06
+dG/dp1: -5.9450e+00
+dG/dp1:  9.9085e-04
+
+Final Statistics
+
+nst     =  1262
+
+nfe     =  1492
+netf    =     2    nsetups  =    90
+nni     =  1489    ncfn     =     0
+
+nfSe    =  1587    nfeS     =     0
+netfs   =     0    nsetupsS =     1
+nniS    =  1585    ncfnS    =     0
diff --git a/examples/idas/serial/idasRoberts_FSA_sps.c b/examples/idas/serial/idasRoberts_FSA_sps.c
new file mode 100644
index 0000000..edeafbf
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_FSA_sps.c
@@ -0,0 +1,831 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date: $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on idasRoberts_FSA_dns.c and modified to use SuperLUMT
+ * -----------------------------------------------------------------
+ * Example problem:
+ *
+ * This simple example problem for IDA, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt = -p1*y1 + p2*y2*y3
+ *      dy2/dt = p1*y1 - p2*y2*y3 - p3*y2**2
+ *         0   = y1 + y2 + y3 - 1
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.The reaction rates are: p1=0.04,
+ * p2=1e4, and p3=3e7
+ *
+ * Optionally, IDAS can compute sensitivities with respect to the
+ * problem parameters p1, p2, and p3.
+ * The sensitivity right hand side is given analytically through the
+ * user routine fS (of type SensRhs1Fn).
+ * Any of two sensitivity methods (SIMULTANEOUS and STAGGERED can be
+ * used and sensitivities may be included in the error test or not 
+ *(error control set on TRUE or FALSE, respectively).
+ *
+ * Execution:
+ *
+ * If no sensitivities are desired:
+ *    % idasRoberts_FSA_sps -nosensi
+ * If sensitivities are to be computed:
+ *    % idasRoberts_FSA_sps -sensi sensi_meth err_con
+ * where sensi_meth is one of {sim, stg} and err_con is one of
+ * {t, f}.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Header files with a description of contents used */
+
+#include <idas/idas.h>                 /* prototypes for IDAS fcts. and consts. */
+#include <idas/idas_superlumt.h>       /* prototypes for IDASuperLUMT fcts. and consts. */
+#include <sundials/sundials_sparse.h>  /* defs. of SlsMat */
+#include <nvector/nvector_serial.h>    /* defs. of serial NVECTOR fcts. and macros  */
+#include <sundials/sundials_types.h>   /* def. of type realtype */
+#include <sundials/sundials_math.h>    /* definition of ABS */
+
+/* Accessor macros */
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* i-th vector component i=1..NEQ */
+
+/* Problem Constants */
+
+#define NEQ   3             /* number of equations  */
+#define T0    RCONST(0.0)   /* initial time */
+#define T1    RCONST(0.4)   /* first output time */
+#define TMULT RCONST(10.0)  /* output time factor */
+#define NOUT  12            /* number of output times */
+
+#define NP    3             /* number of problem parameters */
+#define NS    3             /* number of sensitivities computed */
+
+#define ZERO  RCONST(0.0)
+#define ONE   RCONST(1.0)
+
+/* Type : UserData */
+
+typedef struct {
+  realtype p[3];           /* problem parameters */
+  realtype coef;
+} *UserData;
+
+/* Prototypes of functions by IDAS */
+
+static int res(realtype t, N_Vector y, N_Vector yp, N_Vector resval, void *user_data);
+
+static int Jac(realtype t, realtype cj, 
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int resS(int Ns, realtype t, 
+                N_Vector y, N_Vector yp, N_Vector resval,
+                N_Vector *yyS, N_Vector *ypS, N_Vector *resvalS,
+                void *user_data, 
+                N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int rhsQ(realtype tres, N_Vector yy, N_Vector yp,
+                 N_Vector rrQ, void *user_data);
+
+/* Prototypes of private functions */
+
+static void ProcessArgs(int argc, char *argv[],
+                        booleantype *sensi, int *sensi_meth, 
+                        booleantype *err_con);
+static void WrongArgs(char *name);
+
+static void PrintIC(N_Vector y, N_Vector yp);
+static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS); 
+
+static void PrintOutput(void *ida_mem, realtype t, N_Vector u);
+static void PrintSensOutput(N_Vector *uS);
+
+static void PrintFinalStats(void *ida_mem, booleantype sensi);
+
+static int check_flag(void *flagvalue, char *funcname, int opt);
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  void *ida_mem;
+  UserData data;
+  realtype reltol, t, tout;
+  N_Vector y, yp, abstol, id;
+  int iout, flag, nthreads, nnz;
+
+  realtype pbar[NS];
+  int is; 
+  N_Vector *yS, *ypS;
+  booleantype sensi, err_con;
+  int sensi_meth;
+
+  N_Vector yQ, *yQS;
+
+  ida_mem = NULL;
+  data    = NULL;
+  y       =  NULL;
+  yS      = NULL;
+  ypS     = NULL;
+
+  /* Process arguments */
+  ProcessArgs(argc, argv, &sensi, &sensi_meth, &err_con);
+
+  /* User data structure */
+  data = (UserData) malloc(sizeof *data);
+  if (check_flag((void *)data, "malloc", 2)) return(1);
+  data->p[0] = RCONST(0.040);
+  data->p[1] = RCONST(1.0e4);
+  data->p[2] = RCONST(3.0e7);
+  data->coef = 0.5;
+
+  /* Initial conditions */
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+
+  Ith(y,1) = ONE;
+  Ith(y,2) = ZERO;
+  Ith(y,3) = ZERO;
+
+  yp = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+
+  /* These initial conditions are NOT consistent. See IDACalcIC below. */
+  Ith(yp,1) = RCONST(0.1);
+  Ith(yp,2) = ZERO;
+  Ith(yp,3) = ZERO;  
+
+  /* Create IDAS object */
+  ida_mem = IDACreate();
+  if (check_flag((void *)ida_mem, "IDACreate", 0)) return(1);
+
+  /* Allocate space for IDAS */
+  flag = IDAInit(ida_mem, res, T0, y, yp);
+  if (check_flag(&flag, "IDAInit", 1)) return(1);
+
+  /* Specify scalar relative tol. and vector absolute tol. */
+  reltol = RCONST(1.0e-6);
+  abstol = N_VNew_Serial(NEQ);
+  Ith(abstol,1) = RCONST(1.0e-8);
+  Ith(abstol,2) = RCONST(1.0e-14);
+  Ith(abstol,3) = RCONST(1.0e-6);
+  flag = IDASVtolerances(ida_mem, reltol, abstol);
+  if (check_flag(&flag, "IDASVtolerances", 1)) return(1);
+
+  /* Set ID vector */
+  id = N_VNew_Serial(NEQ);
+  Ith(id,1) = 1.0;
+  Ith(id,2) = 1.0;
+  Ith(id,3) = 0.0;
+  flag = IDASetId(ida_mem, id);
+  if (check_flag(&flag, "IDASetId", 1)) return(1);
+
+  /* Attach user data */
+  flag = IDASetUserData(ida_mem, data);
+  if (check_flag(&flag, "IDASetUserData", 1)) return(1);
+
+  /* Attach linear solver */
+  nthreads = 1;
+  nnz = NEQ * NEQ;
+  flag = IDASuperLUMT(ida_mem, nthreads, NEQ, nnz);
+  if (check_flag(&flag, "IDASuperLUMT", 1)) return(1);
+
+  flag = IDASlsSetSparseJacFn(ida_mem, Jac);
+  if (check_flag(&flag, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  printf("\n3-species chemical kinetics problem\n");
+
+  /* Sensitivity-related settings */
+  if (sensi) {
+
+    pbar[0] = data->p[0];
+    pbar[1] = data->p[1];
+    pbar[2] = data->p[2];
+
+    yS = N_VCloneVectorArray_Serial(NS, y);
+    if (check_flag((void *)yS, "N_VCloneVectorArray_Serial", 0)) return(1);
+    for (is=0;is<NS;is++) N_VConst(ZERO, yS[is]);
+    
+    ypS = N_VCloneVectorArray_Serial(NS, y);
+    if (check_flag((void *)ypS, "N_VCloneVectorArray_Serial", 0)) return(1);
+    for (is=0;is<NS;is++) N_VConst(ZERO, ypS[is]);
+
+    /* 
+    * Only non-zero sensitivity I.C. are ypS[0]: 
+    * - Ith(ypS[0],1) = -ONE;
+    * - Ith(ypS[0],2) =  ONE;
+    *
+    * They are not set. IDACalcIC also computes consistent IC for sensitivities.
+    */
+    
+    flag = IDASensInit(ida_mem, NS, sensi_meth, resS, yS, ypS);
+    if(check_flag(&flag, "IDASensInit", 1)) return(1);
+
+    flag = IDASensEEtolerances(ida_mem);
+    if(check_flag(&flag, "IDASensEEtolerances", 1)) return(1);
+
+    flag = IDASetSensErrCon(ida_mem, err_con);
+    if (check_flag(&flag, "IDASetSensErrCon", 1)) return(1);
+
+    flag = IDASetSensParams(ida_mem, data->p, pbar, NULL);
+    if (check_flag(&flag, "IDASetSensParams", 1)) return(1);
+
+    printf("Sensitivity: YES ");
+    if(sensi_meth == IDA_SIMULTANEOUS)   
+      printf("( SIMULTANEOUS +");
+    else 
+      printf("( STAGGERED +");   
+    if(err_con) printf(" FULL ERROR CONTROL )");
+    else        printf(" PARTIAL ERROR CONTROL )");
+
+  } else {
+
+    printf("Sensitivity: NO ");
+
+  }
+
+  /*----------------------------------------------------------
+   *               Q U A D R A T U R E S
+   * ---------------------------------------------------------*/
+  yQ = N_VNew_Serial(2);
+
+  Ith(yQ,1) = 0;
+  Ith(yQ,2) = 0;
+
+  IDAQuadInit(ida_mem, rhsQ, yQ);
+
+  yQS = N_VCloneVectorArray_Serial(NS, yQ);
+  for (is=0;is<NS;is++) N_VConst(ZERO, yQS[is]);  
+
+  IDAQuadSensInit(ida_mem, NULL, yQS);
+
+  /* Call IDACalcIC to compute consistent initial conditions. If sensitivity is
+     enabled, this function also try to find consistent IC for the sensitivities. */
+
+  flag = IDACalcIC(ida_mem, IDA_YA_YDP_INIT, T1);;
+  if (check_flag(&flag, "IDACalcIC", 1)) return(1);
+
+  flag = IDAGetConsistentIC(ida_mem, y, yp);
+  if (check_flag(&flag, "IDAGetConsistentIC", 1)) return(1);
+
+  PrintIC(y, yp);
+
+  if(sensi) {
+      IDAGetSensConsistentIC(ida_mem, yS, ypS);
+      PrintSensIC(y, yp, yS, ypS); 
+    }
+      
+  /* In loop over output points, call IDA, print results, test for error */
+  
+  printf("\n\n");
+  printf("===========================================");
+  printf("============================\n");
+  printf("     T     Q       H      NST           y1");
+  printf("           y2           y3    \n");
+  printf("===========================================");
+  printf("============================\n");
+
+  for (iout=1, tout=T1; iout <= NOUT; iout++, tout *= TMULT) {
+    
+    flag = IDASolve(ida_mem, tout, &t, y, yp, IDA_NORMAL);
+    if (check_flag(&flag, "IDASolve", 1)) break;
+
+    PrintOutput(ida_mem, t, y);
+    
+    if (sensi) {
+      flag = IDAGetSens(ida_mem, &t, yS);
+      if (check_flag(&flag, "IDAGetSens", 1)) break;
+      PrintSensOutput(yS);
+    } 
+    printf("-----------------------------------------");
+    printf("------------------------------\n");
+
+  }
+
+  printf("\nQuadrature:\n");
+  IDAGetQuad(ida_mem, &t, yQ);
+  printf("G:      %10.4e\n", Ith(yQ,1)); 
+
+  if(sensi) {
+    IDAGetQuadSens(ida_mem, &t, yQS);
+    printf("\nSensitivities at t=%g:\n",t);
+    printf("dG/dp1: %11.4e\n", Ith(yQS[0], 1));
+    printf("dG/dp1: %11.4e\n", Ith(yQS[1], 1));
+    printf("dG/dp1: %11.4e\n", Ith(yQS[2], 1));
+  }
+
+  /* Print final statistics */
+  PrintFinalStats(ida_mem, sensi);
+
+  /* Free memory */
+  N_VDestroy_Serial(y);
+  if (sensi) {
+    N_VDestroyVectorArray_Serial(yS, NS);
+  }
+  free(data);
+  IDAFree(&ida_mem);
+  N_VDestroy_Serial(yQ);
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY IDAS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Residual routine. Compute F(t,y,y',p). 
+ */
+static int res(realtype t, N_Vector yy, N_Vector yp, N_Vector resval, void *user_data)
+{
+  UserData data;
+  realtype p1, p2, p3;
+  realtype y1, y2, y3;
+  realtype yp1, yp2;
+
+  data = (UserData) user_data;
+  p1 = data->p[0];
+  p2 = data->p[1];
+  p3 = data->p[2];
+
+  y1 = Ith(yy,1);
+  y2 = Ith(yy,2);
+  y3 = Ith(yy,3);
+
+  yp1 = Ith(yp,1);
+  yp2 = Ith(yp,2);
+
+  Ith(resval,1) = yp1 + p1*y1 - p2*y2*y3;
+  Ith(resval,2) = yp2 - p1*y1 + p2*y2*y3 + p3*y2*y2;
+  Ith(resval,3) = y1 + y2 + y3 - ONE;
+
+  return(0);
+}
+
+
+/* 
+ * Jacobian routine. Compute J(t,y). 
+*/
+
+static int Jac(realtype t, realtype cj,
+               N_Vector yy, N_Vector yp, N_Vector resvec, 
+               SlsMat JacMat, void *user_data, 
+               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype *yval;
+  int *colptrs;
+  int *rowvals;
+  realtype* data;
+  UserData userdata;
+  realtype p1, p2, p3;
+ 
+  yval = N_VGetArrayPointer_Serial(yy);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data = JacMat->data;
+  userdata = (UserData) user_data;
+  p1 = userdata->p[0]; p2 = userdata->p[1]; p3 = userdata->p[2];
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = p1+cj;                        rowvals[0] = 0;
+  data[1] = -p1;                          rowvals[1] = 1;
+  data[2] = ONE;                          rowvals[2] = 2;
+
+  data[3] = -p2*yval[2];                  rowvals[3] = 0;
+  data[4] = p2*yval[2]+2*p3*yval[1]+cj;   rowvals[4] = 1;
+  data[5] = ONE;                          rowvals[5] = 2;
+
+  data[6] = -p2*yval[1];                  rowvals[6] = 0;
+  data[7] = p2*yval[1];                   rowvals[7] = 1;
+  data[8] = ONE;                          rowvals[8] = 2;
+
+  return(0);
+}
+ 
+/* 
+ * resS routine. Compute sensitivity r.h.s. 
+ */
+
+static int resS(int Ns, realtype t, 
+                N_Vector yy, N_Vector yp, N_Vector resval,
+                N_Vector *yyS, N_Vector *ypS, N_Vector *resvalS,
+                void *user_data, 
+                N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  UserData data;
+  realtype p1, p2, p3;
+  realtype y1, y2, y3;
+  realtype s1, s2, s3;
+  realtype sd1, sd2;
+  realtype rs1, rs2, rs3;
+  int is;
+
+  data = (UserData) user_data;
+  p1 = data->p[0];
+  p2 = data->p[1];
+  p3 = data->p[2];
+
+  y1 = Ith(yy,1);
+  y2 = Ith(yy,2);
+  y3 = Ith(yy,3);
+
+  for (is=0; is<NS; is++) {
+
+    s1 = Ith(yyS[is],1);
+    s2 = Ith(yyS[is],2);
+    s3 = Ith(yyS[is],3);
+
+    sd1 = Ith(ypS[is],1);
+    sd2 = Ith(ypS[is],2);
+
+    rs1 = sd1 + p1*s1 - p2*y3*s2 - p2*y2*s3;
+    rs2 = sd2 - p1*s1 + p2*y3*s2 + p2*y2*s3 + 2*p3*y2*s2;
+    rs3 = s1 + s2 + s3;
+
+    switch (is) {
+    case 0:
+      rs1 += y1;
+      rs2 -= y1;
+      break;
+    case 1:
+      rs1 -= y2*y3;
+      rs2 += y2*y3;
+      break;
+    case 2:
+      rs2 += y2*y2;
+      break;
+    }
+  
+    Ith(resvalS[is],1) = rs1;
+    Ith(resvalS[is],2) = rs2;
+    Ith(resvalS[is],3) = rs3;
+
+  }
+
+  return(0);
+}
+
+static int rhsQ(realtype t, N_Vector y, N_Vector yp, 
+              N_Vector ypQ, void* user_data)
+{
+  UserData data;
+
+  data = (UserData) user_data;
+
+  Ith(ypQ,1) = Ith(y,3);
+  
+  Ith(ypQ,2) = data->coef*( Ith(y,1)*Ith(y,1)+ 
+                            Ith(y,2)*Ith(y,2)+ 
+                            Ith(y,3)*Ith(y,3) );
+                    
+  return(0);
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Process and verify arguments to idasfwddenx.
+ */
+
+static void ProcessArgs(int argc, char *argv[], 
+                        booleantype *sensi, int *sensi_meth, booleantype *err_con)
+{
+  *sensi = FALSE;
+  *sensi_meth = -1;
+  *err_con = FALSE;
+
+  if (argc < 2) WrongArgs(argv[0]);
+
+  if (strcmp(argv[1],"-nosensi") == 0)
+    *sensi = FALSE;
+  else if (strcmp(argv[1],"-sensi") == 0)
+    *sensi = TRUE;
+  else
+    WrongArgs(argv[0]);
+  
+  if (*sensi) {
+
+    if (argc != 4)
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[2],"sim") == 0)
+      *sensi_meth = IDA_SIMULTANEOUS;
+    else if (strcmp(argv[2],"stg") == 0)
+      *sensi_meth = IDA_STAGGERED;
+    else 
+      WrongArgs(argv[0]);
+
+    if (strcmp(argv[3],"t") == 0)
+      *err_con = TRUE;
+    else if (strcmp(argv[3],"f") == 0)
+      *err_con = FALSE;
+    else
+      WrongArgs(argv[0]);
+  }
+
+}
+
+static void WrongArgs(char *name)
+{
+    printf("\nUsage: %s [-nosensi] [-sensi sensi_meth err_con]\n",name);
+    printf("         sensi_meth = sim or stg\n");
+    printf("         err_con    = t or f\n");
+    
+    exit(0);
+}
+
+
+static void PrintIC(N_Vector y, N_Vector yp)
+{
+  realtype* data;
+
+  data = N_VGetArrayPointer_Serial(y);
+  printf("\n\nConsistent IC:\n");
+  printf("\ty = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#endif
+
+  data = N_VGetArrayPointer_Serial(yp);
+  printf("\typ= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", data[0], data[1], data[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", data[0], data[1], data[2]);
+#endif
+
+}
+static void PrintSensIC(N_Vector y, N_Vector yp, N_Vector* yS, N_Vector* ypS)
+{
+  realtype *sdata;
+
+  sdata = N_VGetArrayPointer_Serial(yS[0]);
+  printf("                  Sensitivity 1  ");
+
+  printf("\n\ts1 = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  sdata = N_VGetArrayPointer_Serial(ypS[0]);
+  printf("\ts1'= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+
+  printf("                  Sensitivity 2  ");
+  sdata = N_VGetArrayPointer_Serial(yS[1]);
+  printf("\n\ts2 = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  sdata = N_VGetArrayPointer_Serial(ypS[1]);
+  printf("\ts2'= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+
+  printf("                  Sensitivity 3  ");
+  sdata = N_VGetArrayPointer_Serial(yS[2]);
+  printf("\n\ts3 = ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  sdata = N_VGetArrayPointer_Serial(ypS[2]);
+  printf("\ts3'= ");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+
+}
+
+/*
+ * Print current t, step count, order, stepsize, and solution.
+ */
+
+static void PrintOutput(void *ida_mem, realtype t, N_Vector u)
+{
+  long int nst;
+  int qu, flag;
+  realtype hu, *udata;
+  
+  udata = N_VGetArrayPointer_Serial(u);
+
+  flag = IDAGetNumSteps(ida_mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetLastOrder(ida_mem, &qu);
+  check_flag(&flag, "IDAGetLastOrder", 1);
+  flag = IDAGetLastStep(ida_mem, &hu);
+  check_flag(&flag, "IDAGetLastStep", 1);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%8.3Le %2d  %8.3Le %5ld\n", t, qu, hu, nst);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#else
+  printf("%8.3e %2d  %8.3e %5ld\n", t, qu, hu, nst);
+#endif
+
+  printf("                  Solution       ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", udata[0], udata[1], udata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", udata[0], udata[1], udata[2]);
+#endif
+
+}
+
+/* 
+ * Print sensitivities.
+*/
+
+static void PrintSensOutput(N_Vector *uS)
+{
+  realtype *sdata;
+
+  sdata = N_VGetArrayPointer_Serial(uS[0]);
+  printf("                  Sensitivity 1  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+  
+  sdata = N_VGetArrayPointer_Serial(uS[1]);
+  printf("                  Sensitivity 2  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+
+  sdata = N_VGetArrayPointer_Serial(uS[2]);
+  printf("                  Sensitivity 3  ");
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%12.4Le %12.4Le %12.4Le \n", sdata[0], sdata[1], sdata[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#else
+  printf("%12.4e %12.4e %12.4e \n", sdata[0], sdata[1], sdata[2]);
+#endif
+}
+
+/* 
+ * Print some final statistics from the IDAS memory.
+ */
+
+static void PrintFinalStats(void *ida_mem, booleantype sensi)
+{
+  long int nst;
+  long int nfe, nsetups, nni, ncfn, netf;
+  long int nfSe, nfeS, nsetupsS, nniS, ncfnS, netfS;
+  int flag;
+
+  flag = IDAGetNumSteps(ida_mem, &nst);
+  check_flag(&flag, "IDAGetNumSteps", 1);
+  flag = IDAGetNumResEvals(ida_mem, &nfe);
+  check_flag(&flag, "IDAGetNumRhsEvals", 1);
+  flag = IDAGetNumLinSolvSetups(ida_mem, &nsetups);
+  check_flag(&flag, "IDAGetNumLinSolvSetups", 1);
+  flag = IDAGetNumErrTestFails(ida_mem, &netf);
+  check_flag(&flag, "IDAGetNumErrTestFails", 1);
+  flag = IDAGetNumNonlinSolvIters(ida_mem, &nni);
+  check_flag(&flag, "IDAGetNumNonlinSolvIters", 1);
+  flag = IDAGetNumNonlinSolvConvFails(ida_mem, &ncfn);
+  check_flag(&flag, "IDAGetNumNonlinSolvConvFails", 1);
+
+  if (sensi) {
+    flag = IDAGetSensNumResEvals(ida_mem, &nfSe);
+    check_flag(&flag, "IDAGetSensNumRhsEvals", 1);
+    flag = IDAGetNumResEvalsSens(ida_mem, &nfeS);
+    check_flag(&flag, "IDAGetNumResEvalsSens", 1);
+    flag = IDAGetSensNumLinSolvSetups(ida_mem, &nsetupsS);
+    check_flag(&flag, "IDAGetSensNumLinSolvSetups", 1);
+    flag = IDAGetSensNumErrTestFails(ida_mem, &netfS);
+    check_flag(&flag, "IDAGetSensNumErrTestFails", 1);
+    flag = IDAGetSensNumNonlinSolvIters(ida_mem, &nniS);
+    check_flag(&flag, "IDAGetSensNumNonlinSolvIters", 1);
+    flag = IDAGetSensNumNonlinSolvConvFails(ida_mem, &ncfnS);
+    check_flag(&flag, "IDAGetSensNumNonlinSolvConvFails", 1);
+  }
+
+  printf("\nFinal Statistics\n\n");
+  printf("nst     = %5ld\n\n", nst);
+  printf("nfe     = %5ld\n",   nfe);
+  printf("netf    = %5ld    nsetups  = %5ld\n", netf, nsetups);
+  printf("nni     = %5ld    ncfn     = %5ld\n", nni, ncfn);
+
+  if(sensi) {
+    printf("\n");
+    printf("nfSe    = %5ld    nfeS     = %5ld\n", nfSe, nfeS);
+    printf("netfs   = %5ld    nsetupsS = %5ld\n", netfS, nsetupsS);
+    printf("nniS    = %5ld    ncfnS    = %5ld\n", nniS, ncfnS);
+  }
+
+}
+
+/* 
+ * Check function return value.
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); }}
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1); }
+
+  return(0);
+}
diff --git a/examples/idas/serial/idasRoberts_FSA_sps.out b/examples/idas/serial/idasRoberts_FSA_sps.out
new file mode 100644
index 0000000..8f842a9
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_FSA_sps.out
@@ -0,0 +1,113 @@
+
+3-species chemical kinetics problem
+Sensitivity: YES ( STAGGERED + FULL ERROR CONTROL )
+
+Consistent IC:
+	y =   1.0000e+00   0.0000e+00  -8.1102e-17 
+	yp=  -4.0000e-02   4.0000e-02   0.0000e+00 
+                  Sensitivity 1  
+	s1 =   0.0000e+00   0.0000e+00   0.0000e+00 
+	s1'=  -1.0000e+00   1.0000e+00   0.0000e+00 
+                  Sensitivity 2  
+	s2 =   0.0000e+00   0.0000e+00   0.0000e+00 
+	s2'=   0.0000e+00   0.0000e+00   0.0000e+00 
+                  Sensitivity 3  
+	s3 =   0.0000e+00   0.0000e+00   0.0000e+00 
+	s3'=   0.0000e+00   0.0000e+00   0.0000e+00 
+
+
+=======================================================================
+     T     Q       H      NST           y1           y2           y3    
+=======================================================================
+4.000e-01  5  7.149e-02   212
+                  Solution         9.8517e-01   3.3864e-05   1.4794e-02 
+                  Sensitivity 1   -3.5595e-01   3.9025e-04   3.5556e-01 
+                  Sensitivity 2    9.5424e-08  -2.1310e-10  -9.5210e-08 
+                  Sensitivity 3   -1.5832e-11  -5.2900e-13   1.6361e-11 
+-----------------------------------------------------------------------
+4.000e+00  5  1.430e-01   247
+                  Solution         9.0552e-01   2.2405e-05   9.4459e-02 
+                  Sensitivity 1   -1.8761e+00   1.7922e-04   1.8759e+00 
+                  Sensitivity 2    2.9614e-06  -5.8305e-10  -2.9608e-06 
+                  Sensitivity 3   -4.9334e-10  -2.7626e-13   4.9362e-10 
+-----------------------------------------------------------------------
+4.000e+01  2  1.991e-01   380
+                  Solution         7.1583e-01   9.1855e-06   2.8416e-01 
+                  Sensitivity 1   -4.2476e+00   4.5912e-05   4.2475e+00 
+                  Sensitivity 2    1.3731e-05  -2.3572e-10  -1.3731e-05 
+                  Sensitivity 3   -2.2884e-09  -1.1381e-13   2.2885e-09 
+-----------------------------------------------------------------------
+4.000e+02  5  6.239e+00   523
+                  Solution         4.5052e-01   3.2229e-06   5.4948e-01 
+                  Sensitivity 1   -5.9584e+00   3.5427e-06   5.9584e+00 
+                  Sensitivity 2    2.2738e-05  -2.2601e-11  -2.2738e-05 
+                  Sensitivity 3   -3.7897e-09  -4.9948e-14   3.7897e-09 
+-----------------------------------------------------------------------
+4.000e+03  4  1.019e+02   681
+                  Solution         1.8320e-01   8.9424e-07   8.1680e-01 
+                  Sensitivity 1   -4.7501e+00  -5.9937e-06   4.7501e+00 
+                  Sensitivity 2    1.8809e-05   2.3127e-11  -1.8809e-05 
+                  Sensitivity 3   -3.1348e-09  -1.8758e-14   3.1348e-09 
+-----------------------------------------------------------------------
+4.000e+04  4  5.747e+02   866
+                  Solution         3.8983e-02   1.6218e-07   9.6102e-01 
+                  Sensitivity 1   -1.5750e+00  -2.7620e-06   1.5750e+00 
+                  Sensitivity 2    6.2875e-06   1.1002e-11  -6.2875e-06 
+                  Sensitivity 3   -1.0479e-09  -4.5367e-15   1.0479e-09 
+-----------------------------------------------------------------------
+4.000e+05  4  8.382e+03  1004
+                  Solution         4.9383e-03   1.9850e-08   9.9506e-01 
+                  Sensitivity 1   -2.3633e-01  -4.5841e-07   2.3633e-01 
+                  Sensitivity 2    9.4503e-07   1.8325e-12  -9.4503e-07 
+                  Sensitivity 3   -1.5750e-10  -6.3625e-16   1.5751e-10 
+-----------------------------------------------------------------------
+4.000e+06  5  1.086e+05  1083
+                  Solution         5.1681e-04   2.0683e-09   9.9948e-01 
+                  Sensitivity 1   -2.5666e-02  -5.1061e-08   2.5666e-02 
+                  Sensitivity 2    1.0266e-07   2.0423e-13  -1.0266e-07 
+                  Sensitivity 3   -1.7110e-11  -6.8510e-17   1.7110e-11 
+-----------------------------------------------------------------------
+4.000e+07  5  1.738e+06  1142
+                  Solution         5.2033e-05   2.0814e-10   9.9995e-01 
+                  Sensitivity 1   -2.5993e-03  -5.1946e-09   2.5993e-03 
+                  Sensitivity 2    1.0397e-08   2.0778e-14  -1.0397e-08 
+                  Sensitivity 3   -1.7328e-12  -6.9321e-18   1.7328e-12 
+-----------------------------------------------------------------------
+4.000e+08  4  2.253e+07  1188
+                  Solution         5.2072e-06   2.0829e-11   9.9999e-01 
+                  Sensitivity 1   -2.6033e-04  -5.2060e-10   2.6033e-04 
+                  Sensitivity 2    1.0413e-09   2.0824e-15  -1.0413e-09 
+                  Sensitivity 3   -1.7355e-13  -6.9422e-19   1.7355e-13 
+-----------------------------------------------------------------------
+4.000e+09  3  5.034e+08  1218
+                  Solution         5.2052e-07   2.0821e-12   1.0000e+00 
+                  Sensitivity 1   -2.6023e-05  -5.2042e-11   2.6023e-05 
+                  Sensitivity 2    1.0409e-10   2.0817e-16  -1.0409e-10 
+                  Sensitivity 3   -1.7350e-14  -6.9402e-20   1.7350e-14 
+-----------------------------------------------------------------------
+4.000e+10  3  4.072e+09  1240
+                  Solution         5.1691e-08   2.0677e-13   1.0000e+00 
+                  Sensitivity 1   -2.5827e-06  -5.1617e-12   2.5827e-06 
+                  Sensitivity 2    1.0331e-11   2.0647e-17  -1.0331e-11 
+                  Sensitivity 3   -1.7231e-15  -6.8924e-21   1.7231e-15 
+-----------------------------------------------------------------------
+
+Quadrature:
+G:      4.0000e+10
+
+Sensitivities at t=4e+10:
+dG/dp1:  1.4875e+06
+dG/dp1: -5.9454e+00
+dG/dp1:  9.9096e-04
+
+Final Statistics
+
+nst     =  1240
+
+nfe     =  1527
+netf    =     3    nsetups  =    90
+nni     =  1524    ncfn     =     0
+
+nfSe    =  1643    nfeS     =     0
+netfs   =     0    nsetupsS =     2
+nniS    =  1641    ncfnS    =     0
diff --git a/examples/idas/serial/idasRoberts_dns.c b/examples/idas/serial/idasRoberts_dns.c
index b43dac7..2dffb09 100644
--- a/examples/idas/serial/idasRoberts_dns.c
+++ b/examples/idas/serial/idasRoberts_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 23:05:10 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -40,8 +40,8 @@
 #define NEQ   3
 #define NOUT  12
 
-#define ZERO RCONST(0.0);
-#define ONE  RCONST(1.0);
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
 
 /* Macro to define dense matrix elements, indexed from 1. */
 
@@ -65,7 +65,7 @@ static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y);
 static void PrintOutput(void *mem, realtype t, N_Vector y);
 static void PrintRootInfo(int root_f1, int root_f2);
 static void PrintFinalStats(void *mem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -95,19 +95,19 @@ int main(void)
   if(check_flag((void *)avtol, "N_VNew_Serial", 0)) return(1);
 
   /* Create and initialize  y, y', and absolute tolerance vectors. */
-  yval  = NV_DATA_S(yy);
+  yval  = N_VGetArrayPointer_Serial(yy);
   yval[0] = ONE;
   yval[1] = ZERO;
   yval[2] = ZERO;
 
-  ypval = NV_DATA_S(yp);
+  ypval = N_VGetArrayPointer_Serial(yp);
   ypval[0]  = RCONST(-0.04);
   ypval[1]  = RCONST(0.04);
   ypval[2]  = ZERO;  
 
   rtol = RCONST(1.0e-4);
 
-  atval = NV_DATA_S(avtol);
+  atval = N_VGetArrayPointer_Serial(avtol);
   atval[0] = RCONST(1.0e-8);
   atval[1] = RCONST(1.0e-6);
   atval[2] = RCONST(1.0e-6);
@@ -191,9 +191,9 @@ int resrob(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data
 {
   realtype *yval, *ypval, *rval;
 
-  yval = NV_DATA_S(yy); 
-  ypval = NV_DATA_S(yp); 
-  rval = NV_DATA_S(rr);
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
 
   rval[0]  = RCONST(-0.04)*yval[0] + RCONST(1.0e4)*yval[1]*yval[2];
   rval[1]  = -rval[0] - RCONST(3.0e7)*yval[1]*yval[1] - ypval[1];
@@ -212,7 +212,7 @@ static int grob(realtype t, N_Vector yy, N_Vector yp, realtype *gout,
 {
   realtype *yval, y1, y3;
 
-  yval = NV_DATA_S(yy); 
+  yval = N_VGetArrayPointer_Serial(yy); 
   y1 = yval[0]; y3 = yval[2];
   gout[0] = y1 - RCONST(0.0001);
   gout[1] = y3 - RCONST(0.01);
@@ -231,7 +231,7 @@ int jacrob(long int Neq, realtype tt,  realtype cj,
 {
   realtype *yval;
   
-  yval = NV_DATA_S(yy);
+  yval = N_VGetArrayPointer_Serial(yy);
 
   IJth(JJ,1,1) = RCONST(-0.04) - cj;
   IJth(JJ,2,1) = RCONST(0.04);
@@ -260,8 +260,8 @@ static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
 {
   realtype *atval, *yval;
 
-  atval  = NV_DATA_S(avtol);
-  yval  = NV_DATA_S(y);
+  atval  = N_VGetArrayPointer_Serial(avtol);
+  yval  = N_VGetArrayPointer_Serial(y);
 
   printf("\nidasRoberts_dns: Robertson kinetics DAE serial example problem for IDA.\n");
   printf("               Three equation chemical kinetics problem.\n\n");
@@ -272,9 +272,9 @@ static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
   printf("Initial conditions y0 = (%Lg %Lg %Lg)\n",
          yval[0], yval[1], yval[2]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg %lg %lg \n",
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
          rtol, atval[0],atval[1],atval[2]);
-  printf("Initial conditions y0 = (%lg %lg %lg)\n",
+  printf("Initial conditions y0 = (%g %g %g)\n",
          yval[0], yval[1], yval[2]);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
@@ -300,7 +300,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   long int nst;
   realtype hused;
 
-  yval  = NV_DATA_S(y);
+  yval  = N_VGetArrayPointer_Serial(y);
 
   retval = IDAGetLastOrder(mem, &kused);
   check_flag(&retval, "IDAGetLastOrder", 1);
@@ -312,7 +312,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld  %1d %12.4Le\n", 
          t, yval[0], yval[1], yval[2], nst, kused, hused);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%10.4le %12.4le %12.4le %12.4le | %3ld  %1d %12.4le\n", 
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
          t, yval[0], yval[1], yval[2], nst, kused, hused);
 #else
   printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
@@ -372,7 +372,7 @@ static void PrintFinalStats(void *mem)
  *            NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
   /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
diff --git a/examples/idas/serial/idasRoberts_klu.c b/examples/idas/serial/idasRoberts_klu.c
new file mode 100644
index 0000000..be8d65d
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_klu.c
@@ -0,0 +1,427 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL  (based on idasRoberts_dns.c)
+ * -----------------------------------------------------------------
+ * This simple example problem for IDA, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *      dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+ *         0   = y1 + y2 + y3 - 1
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.
+ *
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01.
+ *
+ * The problem is solved with IDA using IDAKLU for the linear
+ * solver, with a user-supplied Jacobian. Output is printed at
+ * t = .4, 4, 40, ..., 4e10.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include <idas/idas.h>
+#include <idas/idas_klu.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+#define NEQ   3
+#define NOUT  12
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* Prototypes of functions called by IDA */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, 
+           N_Vector resval, void *user_data);
+
+static int grob(realtype t, N_Vector yy, N_Vector yp,
+                realtype *gout, void *user_data);
+
+int jacrob(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec, 
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
+
+/* Prototypes of private functions */
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y);
+static void PrintOutput(void *mem, realtype t, N_Vector y);
+static void PrintRootInfo(int root_f1, int root_f2);
+static void PrintFinalStats(void *mem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * Main Program
+ *--------------------------------------------------------------------
+ */
+
+int main(void)
+{
+  void *mem;
+  N_Vector yy, yp, avtol;
+  realtype rtol, *yval, *ypval, *atval;
+  realtype t0, tout1, tout, tret;
+  int iout, retval, retvalr;
+  int rootsfound[2];
+
+  int nnz;
+
+  mem = NULL;
+  yy = yp = avtol = NULL;
+  yval = ypval = atval = NULL;
+
+  /* Allocate N-vectors. */
+  yy = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yy, "N_VNew_Serial", 0)) return(1);
+  yp = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+  avtol = N_VNew_Serial(NEQ);
+  if(check_flag((void *)avtol, "N_VNew_Serial", 0)) return(1);
+
+  /* Create and initialize  y, y', and absolute tolerance vectors. */
+  yval  = N_VGetArrayPointer_Serial(yy);
+  yval[0] = ONE;
+  yval[1] = ZERO;
+  yval[2] = ZERO;
+
+  ypval = N_VGetArrayPointer_Serial(yp);
+  ypval[0]  = RCONST(-0.04);
+  ypval[1]  = RCONST(0.04);
+  ypval[2]  = ZERO;  
+
+  rtol = RCONST(1.0e-4);
+
+  atval = N_VGetArrayPointer_Serial(avtol);
+  atval[0] = RCONST(1.0e-8);
+  atval[1] = RCONST(1.0e-6);
+  atval[2] = RCONST(1.0e-6);
+
+  /* Integration limits */
+  t0 = ZERO;
+  tout1 = RCONST(0.4);
+
+  PrintHeader(rtol, avtol, yy);
+
+  /* Call IDACreate and IDAMalloc to initialize IDA memory */
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+  retval = IDAInit(mem, resrob, t0, yy, yp);
+  if(check_flag(&retval, "IDAInit", 1)) return(1);
+  retval = IDASVtolerances(mem, rtol, avtol);
+  if(check_flag(&retval, "IDASVtolerances", 1)) return(1);
+
+  /* Free avtol */
+  N_VDestroy_Serial(avtol);
+
+  /* Call IDARootInit to specify the root function grob with 2 components */
+  retval = IDARootInit(mem, 2, grob);
+  if (check_flag(&retval, "IDARootInit", 1)) return(1);
+
+  /* Call IDAKLU and set up the linear solver. */
+  nnz = NEQ * NEQ;
+  retval = IDAKLU(mem, NEQ, nnz, CSC_MAT);
+  if(check_flag(&retval, "IDAKLU", 1)) return(1);
+  retval = IDASlsSetSparseJacFn(mem, jacrob);
+  if(check_flag(&retval, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call IDASolve, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached. */
+
+  iout = 0; tout = tout1;
+  while(1) {
+
+    retval = IDASolve(mem, tout, &tret, yy, yp, IDA_NORMAL);
+
+    PrintOutput(mem,tret,yy);
+
+    if(check_flag(&retval, "IDASolve", 1)) return(1);
+
+    if (retval == IDA_ROOT_RETURN) {
+      retvalr = IDAGetRootInfo(mem, rootsfound);
+      check_flag(&retvalr, "IDAGetRootInfo", 1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (retval == IDA_SUCCESS) {
+      iout++;
+      tout *= RCONST(10.0);
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  PrintFinalStats(mem);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+  N_VDestroy_Serial(yy);
+  N_VDestroy_Serial(yp);
+
+  return(0);
+  
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Functions called by IDA
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Define the system residual function. 
+ */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data)
+{
+  realtype *yval, *ypval, *rval;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
+
+  rval[0]  = RCONST(-0.04)*yval[0] + RCONST(1.0e4)*yval[1]*yval[2];
+  rval[1]  = -rval[0] - RCONST(3.0e7)*yval[1]*yval[1] - ypval[1];
+  rval[0] -=  ypval[0];
+  rval[2]  =  yval[0] + yval[1] + yval[2] - ONE;
+
+  return(0);
+}
+
+/*
+ * Root function routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int grob(realtype t, N_Vector yy, N_Vector yp, realtype *gout,
+                void *user_data)
+{
+  realtype *yval, y1, y3;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  y1 = yval[0]; y3 = yval[2];
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Define the Jacobian function. 
+ */
+
+int jacrob(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec,
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
+{
+  realtype *yval;
+  int* colptrs;
+  int* rowvals;
+  realtype* data;
+  
+  yval = N_VGetArrayPointer_Serial(yy);
+  colptrs = (*JacMat->colptrs);
+  rowvals = (*JacMat->rowvals);
+  data    = JacMat->data;
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  data[0] = RCONST(-0.04) - cj;
+  rowvals[0] = 0;
+  data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  data[2] = ONE;
+  rowvals[2] = 2;
+
+  data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]) - cj;
+  rowvals[4] = 1;
+  data[5] = ONE;
+  rowvals[5] = 2;
+
+  data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  data[8] = ONE;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Private functions
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
+{
+  realtype *atval, *yval;
+
+  atval  = N_VGetArrayPointer_Serial(avtol);
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  printf("\nidasRoberts_klu: Robertson kinetics DAE serial example problem for IDA.\n");
+  printf("               Three equation chemical kinetics problem.\n\n");
+  printf("Linear solver: IDAKLU, with user-supplied Jacobian.\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg %Lg %Lg \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%Lg %Lg %Lg)\n",
+         yval[0], yval[1], yval[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#endif
+  printf("Constraints and id not used.\n\n");
+  printf("-----------------------------------------------------------------------\n");
+  printf("  t             y1           y2           y3");
+  printf("      | nst  k      h\n");
+  printf("-----------------------------------------------------------------------\n");
+}
+
+/*
+ * Print Output
+ */
+
+static void PrintOutput(void *mem, realtype t, N_Vector y)
+{
+  realtype *yval;
+  int retval, kused;
+  long int nst;
+  realtype hused;
+
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  retval = IDAGetLastOrder(mem, &kused);
+  check_flag(&retval, "IDAGetLastOrder", 1);
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetLastStep(mem, &hused);
+  check_flag(&retval, "IDAGetLastStep", 1);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld  %1d %12.4Le\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#else
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#endif
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+  return;
+}
+
+/*
+ * Print final integrator statistics
+ */
+
+static void PrintFinalStats(void *mem)
+{
+  int retval;
+  long int nst, nni, nje, nre, nreLS, netf, ncfn, nge;
+
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetNumResEvals(mem, &nre);
+  check_flag(&retval, "IDAGetNumResEvals", 1);
+  retval = IDASlsGetNumJacEvals(mem, &nje);
+  check_flag(&retval, "IDASlsGetNumJacEvals", 1);
+  retval = IDAGetNumNonlinSolvIters(mem, &nni);
+  check_flag(&retval, "IDAGetNumNonlinSolvIters", 1);
+  retval = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&retval, "IDAGetNumErrTestFails", 1);
+  retval = IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  check_flag(&retval, "IDAGetNumNonlinSolvConvFails", 1);
+  /*  
+      retval = IDASlsGetNumResEvals(mem, &nreLS);
+      check_flag(&retval, "IDASlsGetNumResEvals", 1);
+  */
+  nreLS = 0;
+  retval = IDAGetNumGEvals(mem, &nge);
+  check_flag(&retval, "IDAGetNumGEvals", 1);
+
+  printf("\nFinal Run Statistics: \n\n");
+  printf("Number of steps                    = %ld\n", nst);
+  printf("Number of residual evaluations     = %ld\n", nre+nreLS);
+  printf("Number of Jacobian evaluations     = %ld\n", nje);
+  printf("Number of nonlinear iterations     = %ld\n", nni);
+  printf("Number of error test failures      = %ld\n", netf);
+  printf("Number of nonlinear conv. failures = %ld\n", ncfn);
+  printf("Number of root fn. evaluations     = %ld\n", nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/idas/serial/idasRoberts_klu.out b/examples/idas/serial/idasRoberts_klu.out
new file mode 100644
index 0000000..d986b7f
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_klu.out
@@ -0,0 +1,38 @@
+
+idasRoberts_klu: Robertson kinetics DAE serial example problem for IDA.
+               Three equation chemical kinetics problem.
+
+Linear solver: IDAKLU, with user-supplied Jacobian.
+Tolerance parameters:  rtol = 0.0001   atol = 1e-08 1e-06 1e-06 
+Initial conditions y0 = (1 0 0)
+Constraints and id not used.
+
+-----------------------------------------------------------------------
+  t             y1           y2           y3      | nst  k      h
+-----------------------------------------------------------------------
+2.6402e-01   9.8997e-01   3.4706e-05   1.0000e-02 |  27  2   4.4012e-02
+    rootsfound[] =   0   1
+4.0000e-01   9.8517e-01   3.3864e-05   1.4794e-02 |  29  3   8.8024e-02
+4.0000e+00   9.0553e-01   2.2406e-05   9.4452e-02 |  43  4   6.3377e-01
+4.0000e+01   7.1579e-01   9.1838e-06   2.8420e-01 |  68  4   3.1932e+00
+4.0000e+02   4.5044e-01   3.2218e-06   5.4956e-01 |  95  4   3.3201e+01
+4.0000e+03   1.8320e-01   8.9444e-07   8.1680e-01 | 126  3   3.1458e+02
+4.0000e+04   3.8992e-02   1.6221e-07   9.6101e-01 | 161  5   2.5058e+03
+4.0000e+05   4.9369e-03   1.9842e-08   9.9506e-01 | 202  3   2.6371e+04
+4.0000e+06   5.1693e-04   2.0688e-09   9.9948e-01 | 252  5   2.5583e+05
+2.0801e+07   1.0000e-04   4.0004e-10   9.9990e-01 | 291  4   1.1781e+06
+    rootsfound[] =  -1   0
+4.0000e+07   5.2043e-05   2.0818e-10   9.9995e-01 | 303  5   2.3562e+06
+4.0000e+08   5.2113e-06   2.0845e-11   9.9999e-01 | 336  4   3.7885e+07
+4.0000e+09   5.2515e-07   2.1006e-12   1.0000e+00 | 359  3   5.4083e+08
+4.0000e+10   5.1251e-08   2.0500e-13   1.0000e+00 | 375  3   8.6532e+09
+
+Final Run Statistics: 
+
+Number of steps                    = 375
+Number of residual evaluations     = 529
+Number of Jacobian evaluations     = 54
+Number of nonlinear iterations     = 529
+Number of error test failures      = 10
+Number of nonlinear conv. failures = 0
+Number of root fn. evaluations     = 417
diff --git a/examples/idas/serial/idasRoberts_sps.c b/examples/idas/serial/idasRoberts_sps.c
new file mode 100644
index 0000000..e4c67ca
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_sps.c
@@ -0,0 +1,421 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL  (based on idasRoberts_dns.c)
+ * -----------------------------------------------------------------
+ * This simple example problem for IDA, due to Robertson, 
+ * is from chemical kinetics, and consists of the following three 
+ * equations:
+ *
+ *      dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *      dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*y2**2
+ *         0   = y1 + y2 + y3 - 1
+ *
+ * on the interval from t = 0.0 to t = 4.e10, with initial
+ * conditions: y1 = 1, y2 = y3 = 0.
+ *
+ * While integrating the system, we also use the rootfinding
+ * feature to find the points at which y1 = 1e-4 or at which
+ * y3 = 0.01.
+ *
+ * The problem is solved with IDA using IDASUPERLUMT for the linear
+ * solver, with a user-supplied Jacobian. Output is printed at
+ * t = .4, 4, 40, ..., 4e10.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include <idas/idas.h>
+#include <idas/idas_superlumt.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+#define NEQ   3
+#define NOUT  12
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* Prototypes of functions called by IDA */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, 
+           N_Vector resval, void *user_data);
+
+static int grob(realtype t, N_Vector yy, N_Vector yp,
+                realtype *gout, void *user_data);
+
+int jacrob(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec, 
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3);
+
+/* Prototypes of private functions */
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y);
+static void PrintOutput(void *mem, realtype t, N_Vector y);
+static void PrintRootInfo(int root_f1, int root_f2);
+static void PrintFinalStats(void *mem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * Main Program
+ *--------------------------------------------------------------------
+ */
+
+int main(void)
+{
+  void *mem;
+  N_Vector yy, yp, avtol;
+  realtype rtol, *yval, *ypval, *atval;
+  realtype t0, tout1, tout, tret;
+  int iout, retval, retvalr;
+  int rootsfound[2];
+
+  int nnz;
+
+  mem = NULL;
+  yy = yp = avtol = NULL;
+  yval = ypval = atval = NULL;
+
+  /* Allocate N-vectors. */
+  yy = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yy, "N_VNew_Serial", 0)) return(1);
+  yp = N_VNew_Serial(NEQ);
+  if(check_flag((void *)yp, "N_VNew_Serial", 0)) return(1);
+  avtol = N_VNew_Serial(NEQ);
+  if(check_flag((void *)avtol, "N_VNew_Serial", 0)) return(1);
+
+  /* Create and initialize  y, y', and absolute tolerance vectors. */
+  yval  = N_VGetArrayPointer_Serial(yy);
+  yval[0] = ONE;
+  yval[1] = ZERO;
+  yval[2] = ZERO;
+
+  ypval = N_VGetArrayPointer_Serial(yp);
+  ypval[0]  = RCONST(-0.04);
+  ypval[1]  = RCONST(0.04);
+  ypval[2]  = ZERO;  
+
+  rtol = RCONST(1.0e-4);
+
+  atval = N_VGetArrayPointer_Serial(avtol);
+  atval[0] = RCONST(1.0e-8);
+  atval[1] = RCONST(1.0e-6);
+  atval[2] = RCONST(1.0e-6);
+
+  /* Integration limits */
+  t0 = ZERO;
+  tout1 = RCONST(0.4);
+
+  PrintHeader(rtol, avtol, yy);
+
+  /* Call IDACreate and IDAMalloc to initialize IDA memory */
+  mem = IDACreate();
+  if(check_flag((void *)mem, "IDACreate", 0)) return(1);
+  retval = IDAInit(mem, resrob, t0, yy, yp);
+  if(check_flag(&retval, "IDAInit", 1)) return(1);
+  retval = IDASVtolerances(mem, rtol, avtol);
+  if(check_flag(&retval, "IDASVtolerances", 1)) return(1);
+
+  /* Free avtol */
+  N_VDestroy_Serial(avtol);
+
+  /* Call IDARootInit to specify the root function grob with 2 components */
+  retval = IDARootInit(mem, 2, grob);
+  if (check_flag(&retval, "IDARootInit", 1)) return(1);
+
+  /* Call IDASuperLUMT and set up the linear solver. */
+  nnz = NEQ * NEQ;
+  retval = IDASuperLUMT(mem, 1, NEQ, nnz);
+  if(check_flag(&retval, "IDASuperLUMT", 1)) return(1);
+  retval = IDASlsSetSparseJacFn(mem, jacrob);
+  if(check_flag(&retval, "IDASlsSetSparseJacFn", 1)) return(1);
+
+  /* In loop, call IDASolve, print results, and test for error.
+     Break out of loop when NOUT preset output times have been reached. */
+
+  iout = 0; tout = tout1;
+  while(1) {
+
+    retval = IDASolve(mem, tout, &tret, yy, yp, IDA_NORMAL);
+
+    PrintOutput(mem,tret,yy);
+
+    if(check_flag(&retval, "IDASolve", 1)) return(1);
+
+    if (retval == IDA_ROOT_RETURN) {
+      retvalr = IDAGetRootInfo(mem, rootsfound);
+      check_flag(&retvalr, "IDAGetRootInfo", 1);
+      PrintRootInfo(rootsfound[0],rootsfound[1]);
+    }
+
+    if (retval == IDA_SUCCESS) {
+      iout++;
+      tout *= RCONST(10.0);
+    }
+
+    if (iout == NOUT) break;
+  }
+
+  PrintFinalStats(mem);
+
+  /* Free memory */
+
+  IDAFree(&mem);
+  N_VDestroy_Serial(yy);
+  N_VDestroy_Serial(yp);
+
+  return(0);
+  
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Functions called by IDA
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Define the system residual function. 
+ */
+
+int resrob(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *user_data)
+{
+  realtype *yval, *ypval, *rval;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
+
+  rval[0]  = RCONST(-0.04)*yval[0] + RCONST(1.0e4)*yval[1]*yval[2];
+  rval[1]  = -rval[0] - RCONST(3.0e7)*yval[1]*yval[1] - ypval[1];
+  rval[0] -=  ypval[0];
+  rval[2]  =  yval[0] + yval[1] + yval[2] - ONE;
+
+  return(0);
+}
+
+/*
+ * Root function routine. Compute functions g_i(t,y) for i = 0,1. 
+ */
+
+static int grob(realtype t, N_Vector yy, N_Vector yp, realtype *gout,
+                void *user_data)
+{
+  realtype *yval, y1, y3;
+
+  yval = N_VGetArrayPointer_Serial(yy); 
+  y1 = yval[0]; y3 = yval[2];
+  gout[0] = y1 - RCONST(0.0001);
+  gout[1] = y3 - RCONST(0.01);
+
+  return(0);
+}
+
+/*
+ * Define the Jacobian function. 
+ */
+
+int jacrob(realtype tt,  realtype cj, 
+           N_Vector yy, N_Vector yp, N_Vector resvec,
+	   SlsMat JacMat, void *user_data,
+           N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
+{
+  realtype *yval;
+  int *colptrs = *JacMat->colptrs;
+  int *rowvals = *JacMat->rowvals;
+  
+  yval = N_VGetArrayPointer_Serial(yy);
+
+  SparseSetMatToZero(JacMat);
+
+  colptrs[0] = 0;
+  colptrs[1] = 3;
+  colptrs[2] = 6;
+  colptrs[3] = 9;
+
+  JacMat->data[0] = RCONST(-0.04) - cj;
+  rowvals[0] = 0;
+  JacMat->data[1] = RCONST(0.04);
+  rowvals[1] = 1;
+  JacMat->data[2] = ONE;
+  rowvals[2] = 2;
+
+  JacMat->data[3] = RCONST(1.0e4)*yval[2];
+  rowvals[3] = 0;
+  JacMat->data[4] = (RCONST(-1.0e4)*yval[2]) - (RCONST(6.0e7)*yval[1]) - cj;
+  rowvals[4] = 1;
+  JacMat->data[5] = ONE;
+  rowvals[5] = 2;
+
+  JacMat->data[6] = RCONST(1.0e4)*yval[1];
+  rowvals[6] = 0;
+  JacMat->data[7] = RCONST(-1.0e4)*yval[1];
+  rowvals[7] = 1;
+  JacMat->data[8] = ONE;
+  rowvals[8] = 2;
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * Private functions
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(realtype rtol, N_Vector avtol, N_Vector y)
+{
+  realtype *atval, *yval;
+
+  atval  = N_VGetArrayPointer_Serial(avtol);
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  printf("\nidasRoberts_sps: Robertson kinetics DAE serial example problem for IDA.\n");
+  printf("               Three equation chemical kinetics problem.\n\n");
+  printf("Linear solver: IDASUPERLUMT, with user-supplied Jacobian.\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("Tolerance parameters:  rtol = %Lg   atol = %Lg %Lg %Lg \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%Lg %Lg %Lg)\n",
+         yval[0], yval[1], yval[2]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#else
+  printf("Tolerance parameters:  rtol = %g   atol = %g %g %g \n",
+         rtol, atval[0],atval[1],atval[2]);
+  printf("Initial conditions y0 = (%g %g %g)\n",
+         yval[0], yval[1], yval[2]);
+#endif
+  printf("Constraints and id not used.\n\n");
+  printf("-----------------------------------------------------------------------\n");
+  printf("  t             y1           y2           y3");
+  printf("      | nst  k      h\n");
+  printf("-----------------------------------------------------------------------\n");
+}
+
+/*
+ * Print Output
+ */
+
+static void PrintOutput(void *mem, realtype t, N_Vector y)
+{
+  realtype *yval;
+  int retval, kused;
+  long int nst;
+  realtype hused;
+
+  yval  = N_VGetArrayPointer_Serial(y);
+
+  retval = IDAGetLastOrder(mem, &kused);
+  check_flag(&retval, "IDAGetLastOrder", 1);
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetLastStep(mem, &hused);
+  check_flag(&retval, "IDAGetLastStep", 1);
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("%10.4Le %12.4Le %12.4Le %12.4Le | %3ld  %1d %12.4Le\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#else
+  printf("%10.4e %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
+         t, yval[0], yval[1], yval[2], nst, kused, hused);
+#endif
+}
+
+static void PrintRootInfo(int root_f1, int root_f2)
+{
+  printf("    rootsfound[] = %3d %3d\n", root_f1, root_f2);
+  return;
+}
+
+/*
+ * Print final integrator statistics
+ */
+
+static void PrintFinalStats(void *mem)
+{
+  int retval;
+  long int nst, nni, nje, nre, nreLS, netf, ncfn, nge;
+
+  retval = IDAGetNumSteps(mem, &nst);
+  check_flag(&retval, "IDAGetNumSteps", 1);
+  retval = IDAGetNumResEvals(mem, &nre);
+  check_flag(&retval, "IDAGetNumResEvals", 1);
+  retval = IDASlsGetNumJacEvals(mem, &nje);
+  check_flag(&retval, "IDASlsGetNumJacEvals", 1);
+  retval = IDAGetNumNonlinSolvIters(mem, &nni);
+  check_flag(&retval, "IDAGetNumNonlinSolvIters", 1);
+  retval = IDAGetNumErrTestFails(mem, &netf);
+  check_flag(&retval, "IDAGetNumErrTestFails", 1);
+  retval = IDAGetNumNonlinSolvConvFails(mem, &ncfn);
+  check_flag(&retval, "IDAGetNumNonlinSolvConvFails", 1);
+  /*  retval = IDASlsGetNumResEvals(mem, &nreLS); */
+  /*  check_flag(&retval, "IDASlsGetNumResEvals", 1); */
+  nreLS = 0;
+  retval = IDAGetNumGEvals(mem, &nge);
+  check_flag(&retval, "IDAGetNumGEvals", 1);
+
+  printf("\nFinal Run Statistics: \n\n");
+  printf("Number of steps                    = %ld\n", nst);
+  printf("Number of residual evaluations     = %ld\n", nre+nreLS);
+  printf("Number of Jacobian evaluations     = %ld\n", nje);
+  printf("Number of nonlinear iterations     = %ld\n", nni);
+  printf("Number of error test failures      = %ld\n", netf);
+  printf("Number of nonlinear conv. failures = %ld\n", ncfn);
+  printf("Number of root fn. evaluations     = %ld\n", nge);
+}
+
+/*
+ * Check function return value...
+ *   opt == 0 means SUNDIALS function allocates memory so check if
+ *            returned NULL pointer
+ *   opt == 1 means SUNDIALS function returns a flag so check if
+ *            flag >= 0
+ *   opt == 2 means function allocates memory so check if returned
+ *            NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  } else if (opt == 1) {
+    /* Check if flag < 0 */
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr, 
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n", 
+              funcname, *errflag);
+      return(1); 
+    }
+  } else if (opt == 2 && flagvalue == NULL) {
+    /* Check if function returned NULL pointer - no memory allocated */
+    fprintf(stderr, 
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n", 
+            funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/idas/serial/idasRoberts_sps.out b/examples/idas/serial/idasRoberts_sps.out
new file mode 100644
index 0000000..d0739a6
--- /dev/null
+++ b/examples/idas/serial/idasRoberts_sps.out
@@ -0,0 +1,38 @@
+
+idasRoberts_sps: Robertson kinetics DAE serial example problem for IDA.
+               Three equation chemical kinetics problem.
+
+Linear solver: IDASUPERLUMT, with user-supplied Jacobian.
+Tolerance parameters:  rtol = 0.0001   atol = 1e-08 1e-06 1e-06 
+Initial conditions y0 = (1 0 0)
+Constraints and id not used.
+
+-----------------------------------------------------------------------
+  t             y1           y2           y3      | nst  k      h
+-----------------------------------------------------------------------
+2.6402e-01   9.8997e-01   3.4706e-05   1.0000e-02 |  27  2   4.4012e-02
+    rootsfound[] =   0   1
+4.0000e-01   9.8517e-01   3.3864e-05   1.4794e-02 |  29  3   8.8024e-02
+4.0000e+00   9.0553e-01   2.2406e-05   9.4452e-02 |  43  4   6.3377e-01
+4.0000e+01   7.1579e-01   9.1838e-06   2.8420e-01 |  68  4   3.1932e+00
+4.0000e+02   4.5044e-01   3.2218e-06   5.4956e-01 |  95  4   3.3201e+01
+4.0000e+03   1.8320e-01   8.9444e-07   8.1680e-01 | 126  3   3.1458e+02
+4.0000e+04   3.8992e-02   1.6221e-07   9.6101e-01 | 161  5   2.5058e+03
+4.0000e+05   4.9369e-03   1.9842e-08   9.9506e-01 | 202  3   2.6371e+04
+4.0000e+06   5.1693e-04   2.0688e-09   9.9948e-01 | 252  5   2.5583e+05
+2.0801e+07   1.0000e-04   4.0004e-10   9.9990e-01 | 291  4   1.1781e+06
+    rootsfound[] =  -1   0
+4.0000e+07   5.2043e-05   2.0818e-10   9.9995e-01 | 303  5   2.3562e+06
+4.0000e+08   5.2113e-06   2.0845e-11   9.9999e-01 | 336  4   3.7885e+07
+4.0000e+09   5.2515e-07   2.1006e-12   1.0000e+00 | 359  3   5.4083e+08
+4.0000e+10   5.1251e-08   2.0500e-13   1.0000e+00 | 375  3   8.6532e+09
+
+Final Run Statistics: 
+
+Number of steps                    = 375
+Number of residual evaluations     = 529
+Number of Jacobian evaluations     = 54
+Number of nonlinear iterations     = 529
+Number of error test failures      = 10
+Number of nonlinear conv. failures = 0
+Number of root fn. evaluations     = 417
diff --git a/examples/idas/serial/idasSlCrank_FSA_dns.c b/examples/idas/serial/idasSlCrank_FSA_dns.c
index 425637d..790b238 100644
--- a/examples/idas/serial/idasSlCrank_FSA_dns.c
+++ b/examples/idas/serial/idasSlCrank_FSA_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2009/04/29 20:40:07 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
@@ -74,7 +74,7 @@ static int ressc(realtype tres, N_Vector yy, N_Vector yp,
 static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_data);
 
 static int rhsQS(int Ns, realtype t, N_Vector yy, N_Vector yp, 
-                 N_Vector *yyS, N_Vector *ypS, N_Vector rrQ, N_Vector *rhsQS,
+                 N_Vector *yyS, N_Vector *ypS, N_Vector rrQ, N_Vector *rhsvalQS,
                  void *user_data,  N_Vector yytmp, N_Vector yptmp, N_Vector tmpQS);
 
 
@@ -82,7 +82,7 @@ static void setIC(N_Vector yy, N_Vector yp, UserData data);
 static void force(N_Vector yy, realtype *Q, UserData data);
 
 static void PrintFinalStats(void *mem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 /*
  *--------------------------------------------------------------------
  * Main Program
@@ -185,7 +185,7 @@ int main(void)
   
   IDAGetQuadSens(mem, &tret, qS);
   printf("-------------F O R W A R D------------------\n");
-  printf("   dG/dp:  %12.4le %12.4le\n", Ith(qS[0],1), Ith(qS[1],1));
+  printf("   dG/dp:  %12.4e %12.4e\n", Ith(qS[0],1), Ith(qS[1],1));
   printf("--------------------------------------------\n\n");
 
   IDAFree(&mem);
@@ -281,15 +281,15 @@ int main(void)
   printf("\n\n   Checking using Finite Differences \n\n");
 
   printf("---------------BACKWARD------------------\n");
-  printf("   dG/dp:  %12.4le %12.4le\n", (G-Gm[0])/dp, (G-Gm[1])/dp);
+  printf("   dG/dp:  %12.4e %12.4e\n", (G-Gm[0])/dp, (G-Gm[1])/dp);
   printf("-----------------------------------------\n\n");
 
   printf("---------------FORWARD-------------------\n");
-  printf("   dG/dp:  %12.4le %12.4le\n", (Gp[0]-G)/dp, (Gp[1]-G)/dp);
+  printf("   dG/dp:  %12.4e %12.4e\n", (Gp[0]-G)/dp, (Gp[1]-G)/dp);
   printf("-----------------------------------------\n\n");
 
   printf("--------------CENTERED-------------------\n");
-  printf("   dG/dp:  %12.4le %12.4le\n", (Gp[0]-Gm[0])/(TWO*dp) ,(Gp[1]-Gm[1])/(TWO*dp));
+  printf("   dG/dp:  %12.4e %12.4e\n", (Gp[0]-Gm[0])/(TWO*dp) ,(Gp[1]-Gm[1])/(TWO*dp));
   printf("-----------------------------------------\n\n");
 
 
@@ -368,7 +368,7 @@ static void force(N_Vector yy, realtype *Q, UserData data)
   c21 = c2*c1 + s2*s1;
 
   l2 = x*x - x*(c2+a*c1) + (ONE + a*a)/FOUR + a*c21/TWO;
-  l = RSqrt(l2);
+  l = SUNRsqrt(l2);
   ld = TWO*x*xd - xd*(c2+a*c1) + x*(s2*pd+a*s1*qd) - a*s21*(pd-qd)/TWO;
   ld /= TWO*l;
 
@@ -399,9 +399,9 @@ static int ressc(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *use
   m2 = data->m2;
   J2 = data->J2;
 
-  yval = NV_DATA_S(yy); 
-  ypval = NV_DATA_S(yp); 
-  rval = NV_DATA_S(rr);
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
 
   q = yval[0];
   x = yval[1];
@@ -464,7 +464,7 @@ static int rhsQ(realtype t, N_Vector yy, N_Vector yp, N_Vector qdot, void *user_
 }
 
 static int rhsQS(int Ns, realtype t, N_Vector yy, N_Vector yp, 
-                 N_Vector *yyS, N_Vector *ypS, N_Vector rrQ, N_Vector *rhsQS,
+                 N_Vector *yyS, N_Vector *ypS, N_Vector rrQ, N_Vector *rhsvalQS,
                  void *user_data,  N_Vector yytmp, N_Vector yptmp, N_Vector tmpQS)
 {
   realtype v1, v2, v3;
@@ -488,13 +488,13 @@ static int rhsQS(int Ns, realtype t, N_Vector yy, N_Vector yp,
   s2 = Ith(yyS[0],5);
   s3 = Ith(yyS[0],6);
 
-  Ith(rhsQS[0], 1) = J1*v1*s1 + m2*v2*s2 + J2*v3*s3;
+  Ith(rhsvalQS[0], 1) = J1*v1*s1 + m2*v2*s2 + J2*v3*s3;
 
   s1 = Ith(yyS[1],4);
   s2 = Ith(yyS[1],5);
   s3 = Ith(yyS[1],6);
 
-  Ith(rhsQS[1], 1) = J1*v1*s1 + m2*v2*s2 + J2*v3*s3;
+  Ith(rhsvalQS[1], 1) = J1*v1*s1 + m2*v2*s2 + J2*v3*s3;
 
   return(0);
 }
@@ -522,7 +522,7 @@ static void PrintFinalStats(void *mem)
 }
 
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/idas/serial/idasSlCrank_dns.c b/examples/idas/serial/idasSlCrank_dns.c
index 999c96b..fb1d782 100644
--- a/examples/idas/serial/idasSlCrank_dns.c
+++ b/examples/idas/serial/idasSlCrank_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2009/09/30 23:33:29 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
@@ -74,7 +74,7 @@ static void force(N_Vector yy, realtype *Q, UserData data);
 static void PrintHeader(realtype rtol, realtype avtol, N_Vector y);
 static void PrintOutput(void *mem, realtype t, N_Vector y);
 static void PrintFinalStats(void *mem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 /*
  *--------------------------------------------------------------------
  * Main Program
@@ -237,7 +237,7 @@ static void force(N_Vector yy, realtype *Q, UserData data)
   c21 = c2*c1 + s2*s1;
 
   l2 = x*x - x*(c2+a*c1) + (ONE + a*a)/FOUR + a*c21/TWO;
-  l = RSqrt(l2);
+  l = SUNRsqrt(l2);
   ld = TWO*x*xd - xd*(c2+a*c1) + x*(s2*pd+a*s1*qd) - a*s21*(pd-qd)/TWO;
   ld /= TWO*l;
 
@@ -268,9 +268,9 @@ static int ressc(realtype tres, N_Vector yy, N_Vector yp, N_Vector rr, void *use
   m2 = data->m2;
   J2 = data->J2;
 
-  yval = NV_DATA_S(yy); 
-  ypval = NV_DATA_S(yp); 
-  rval = NV_DATA_S(rr);
+  yval = N_VGetArrayPointer_Serial(yy); 
+  ypval = N_VGetArrayPointer_Serial(yp); 
+  rval = N_VGetArrayPointer_Serial(rr);
 
   q = yval[0];
   x = yval[1];
@@ -340,7 +340,7 @@ static void PrintHeader(realtype rtol, realtype avtol, N_Vector y)
   printf("Tolerance parameters:  rtol = %Lg   atol = %Lg\n",
          rtol, avtol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  rtol = %lg   atol = %lg\n",
+  printf("Tolerance parameters:  rtol = %g   atol = %g\n",
          rtol, avtol);
 #else
   printf("Tolerance parameters:  rtol = %g   atol = %g\n",
@@ -360,7 +360,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   long int nst;
   realtype hused;
 
-  yval  = NV_DATA_S(y);
+  yval  = N_VGetArrayPointer_Serial(y);
 
   retval = IDAGetLastOrder(mem, &kused);
   check_flag(&retval, "IDAGetLastOrder", 1);
@@ -372,7 +372,7 @@ static void PrintOutput(void *mem, realtype t, N_Vector y)
   printf("%5.2Lf %12.4Le %12.4Le %12.4Le | %3ld  %1d %12.4Le\n", 
          t, yval[0], yval[1], yval[2], nst, kused, hused);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("%5.2lf %12.4le %12.4le %12.4le | %3ld  %1d %12.4le\n", 
+  printf("%5.2f %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
          t, yval[0], yval[1], yval[2], nst, kused, hused);
 #else
   printf("%5.2f %12.4e %12.4e %12.4e | %3ld  %1d %12.4e\n", 
@@ -403,7 +403,7 @@ static void PrintFinalStats(void *mem)
   printf("Number of nonlinear conv. failures = %ld\n", ncfn);
 }
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/kinsol/C_openmp/CMakeLists.txt b/examples/kinsol/C_openmp/CMakeLists.txt
new file mode 100644
index 0000000..06c937f
--- /dev/null
+++ b/examples/kinsol/C_openmp/CMakeLists.txt
@@ -0,0 +1,128 @@
+# ---------------------------------------------------------------
+# Programmer: Ting Yan @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt file for KINSOL OpenMP examples
+
+# Only include tests if OpenMP is enabled
+IF(OPENMP_FOUND)
+
+# Add variable KINSOL_examples_OMP with the names of the openmp KINSOL examples
+SET(KINSOL_examples_OMP
+  kinFoodWeb_kry_omp
+  )
+
+ENDIF(OPENMP_FOUND)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(KINSOL_LIB sundials_kinsol_static)
+  SET(NVECOMP_LIB sundials_nvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(KINSOL_LIB sundials_kinsol_shared)
+  SET(NVECOMP_LIB sundials_nvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${KINSOL_LIB} ${NVECOMP_LIB} ${EXTRA_LINK_LIBS})
+IF(LAPACK_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+# update the compilation flags to include OpenMP support
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+
+# Add the build and install targets for each KINSOL example
+FOREACH(example ${KINSOL_examples_OMP})
+  ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  #SUNDIALS_ADD_TEST(${example} ${example} TEST_ARGS 4) # No test until TestRunner modified for OpenMP
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/C_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${KINSOL_examples_OMP})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES README DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/C_openmp)
+
+  # Install the extra files
+  FOREACH(extrafile ${KINSOL_extras_OMP})
+    INSTALL(FILES ${extrafile} DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/C_openmp)
+  ENDFOREACH(extrafile ${KINSOL_extras_OMP})
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER "KINSOL")
+  SET(SOLVER_LIB "sundials_kinsol")
+  LIST2STRING(KINSOL_examples_OMP EXAMPLES)
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
+
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/kinsol/C_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/kinsol/C_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/C_openmp 
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/kinsol/C_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/kinsol/C_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/C_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/kinsol/C_openmp/README b/examples/kinsol/C_openmp/README
new file mode 100644
index 0000000..56fb7dd
--- /dev/null
+++ b/examples/kinsol/C_openmp/README
@@ -0,0 +1,49 @@
+List of C_openmp KINSOL examples
+
+  kinFoodWeb_kry_omp: 2-D food web system, block-diagonal preconditioner
+
+
+The following CMake command was used to configure SUNDIALS:
+
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
+
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c b/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c
new file mode 100644
index 0000000..c50b8c9
--- /dev/null
+++ b/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.c
@@ -0,0 +1,824 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:  $
+ * $Date:  $
+ * -----------------------------------------------------------------
+ * Programmer(s): Ting Yan @ SMU
+ *      Based on kinFoodWeb_kry.c and parallelized with OpenMP
+ * -----------------------------------------------------------------
+ * Example (serial):
+ *
+ * This example solves a nonlinear system that arises from a system
+ * of partial differential equations. The PDE system is a food web
+ * population model, with predator-prey interaction and diffusion
+ * on the unit square in two dimensions. The dependent variable
+ * vector is the following:
+ * 
+ *       1   2         ns
+ * c = (c , c ,  ..., c  )     (denoted by the variable cc)
+ * 
+ * and the PDE's are as follows:
+ *
+ *                    i       i
+ *         0 = d(i)*(c     + c    )  +  f  (x,y,c)   (i=1,...,ns)
+ *                    xx      yy         i
+ *
+ *   where
+ *
+ *                   i             ns         j
+ *   f  (x,y,c)  =  c  * (b(i)  + sum a(i,j)*c )
+ *    i                           j=1
+ *
+ * The number of species is ns = 2 * np, with the first np being
+ * prey and the last np being predators. The number np is both the
+ * number of prey and predator species. The coefficients a(i,j),
+ * b(i), d(i) are:
+ *
+ *   a(i,i) = -AA   (all i)
+ *   a(i,j) = -GG   (i <= np , j >  np)
+ *   a(i,j) =  EE   (i >  np,  j <= np)
+ *   b(i) = BB * (1 + alpha * x * y)   (i <= np)
+ *   b(i) =-BB * (1 + alpha * x * y)   (i >  np)
+ *   d(i) = DPREY   (i <= np)
+ *   d(i) = DPRED   ( i > np)
+ *
+ * The various scalar parameters are set using define's or in
+ * routine InitUserData.
+ *
+ * The boundary conditions are: normal derivative = 0, and the
+ * initial guess is constant in x and y, but the final solution
+ * is not.
+ *
+ * The PDEs are discretized by central differencing on an MX by
+ * MY mesh.
+ * 
+ * The nonlinear system is solved by KINSOL using the method
+ * specified in local variable globalstrat.
+ *
+ * The preconditioner matrix is a block-diagonal matrix based on
+ * the partial derivatives of the interaction terms f only.
+ *
+ * Constraints are imposed to make all components of the solution
+ * positive.
+ *
+ * Optionally, we can set the number of threads from environment 
+ * variable or command line. To check the current value for number
+ * of threads from environment:
+ *      % echo $OMP_NUM_THREADS
+ *
+ * Execution:
+ *
+ * If the user want to use the default value or the number of threads 
+ * from environment value:
+ *      % ./kinFoodWeb_kry_omp 
+ * If the user want to specify the number of threads to use
+ *      % ./kinFoodWeb_kry_omp num_threads
+ * where num_threads is the number of threads the user want to use 
+ *
+ * -----------------------------------------------------------------
+ * References:
+ *
+ * 1. Peter N. Brown and Youcef Saad,
+ *    Hybrid Krylov Methods for Nonlinear Systems of Equations
+ *    LLNL report UCRL-97645, November 1987.
+ *
+ * 2. Peter N. Brown and Alan C. Hindmarsh,
+ *    Reduced Storage Matrix Methods in Stiff ODE systems,
+ *    Lawrence Livermore National Laboratory Report  UCRL-95088,
+ *    Rev. 1, June 1987, and  Journal of Applied Mathematics and
+ *    Computation, Vol. 31 (May 1989), pp. 40-91. (Presents a
+ *    description of the time-dependent version of this test
+ *    problem.)
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <kinsol/kinsol.h>
+#include <kinsol/kinsol_spgmr.h>
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_dense.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+/* Problem Constants */
+
+#define NUM_SPECIES     6  /* must equal 2*(number of prey or predators)
+                              number of prey = number of predators       */ 
+
+#define PI       RCONST(3.1415926535898)   /* pi */ 
+
+#define MX          8              /* MX = number of x mesh points */
+#define MY          8              /* MY = number of y mesh points */
+#define NSMX        (NUM_SPECIES * MX)
+#define NEQ         (NSMX * MY)    /* number of equations in the system */
+#define AA          RCONST(1.0)    /* value of coefficient AA in above eqns */
+#define EE          RCONST(10000.) /* value of coefficient EE in above eqns */
+#define GG          RCONST(0.5e-6) /* value of coefficient GG in above eqns */
+#define BB          RCONST(1.0)    /* value of coefficient BB in above eqns */
+#define DPREY       RCONST(1.0)    /* value of coefficient dprey above */
+#define DPRED       RCONST(0.5)    /* value of coefficient dpred above */
+#define ALPHA       RCONST(1.0)    /* value of coefficient alpha above */
+#define AX          RCONST(1.0)    /* total range of x variable */
+#define AY          RCONST(1.0)    /* total range of y variable */
+#define FTOL        RCONST(1.e-7)  /* ftol tolerance */
+#define STOL        RCONST(1.e-13) /* stol tolerance */
+#define THOUSAND    RCONST(1000.0) /* one thousand */
+#define ZERO        RCONST(0.)     /* 0. */
+#define ONE         RCONST(1.0)    /* 1. */
+#define TWO         RCONST(2.0)    /* 2. */
+#define PREYIN      RCONST(1.0)    /* initial guess for prey concentrations. */
+#define PREDIN      RCONST(30000.0)/* initial guess for predator concs.      */
+
+/* User-defined vector access macro: IJ_Vptr */
+
+/* IJ_Vptr is defined in order to translate from the underlying 3D structure
+   of the dependent variable vector to the 1D storage scheme for an N-vector.
+   IJ_Vptr(vv,i,j) returns a pointer to the location in vv corresponding to 
+   indices is = 0, jx = i, jy = j.    */
+
+#define IJ_Vptr(vv,i,j)   (&NV_Ith_OMP(vv, i*NUM_SPECIES + j*NSMX))
+
+/* Type : UserData 
+   contains preconditioner blocks, pivot arrays, and problem constants */
+
+typedef struct {
+  realtype **P[MX][MY];
+  long int *pivot[MX][MY];
+  realtype **acoef, *bcoef;
+  N_Vector rates;
+  realtype *cox, *coy;
+  realtype ax, ay, dx, dy;
+  realtype uround, sqruround;
+  long int mx, my, ns, np;
+  int nthreads;
+} *UserData;
+
+/* Functions Called by the KINSOL Solver */
+
+static int func(N_Vector cc, N_Vector fval, void *user_data);
+
+static int PrecSetupBD(N_Vector cc, N_Vector cscale,
+                       N_Vector fval, N_Vector fscale,
+                       void *user_data,
+                       N_Vector vtemp1, N_Vector vtemp2);
+
+static int PrecSolveBD(N_Vector cc, N_Vector cscale, 
+                       N_Vector fval, N_Vector fscale, 
+                       N_Vector vv, void *user_data,
+                       N_Vector ftem);
+
+/* Private Helper Functions */
+
+static UserData AllocUserData(void);
+static void InitUserData(UserData data);
+static void FreeUserData(UserData data);
+static void SetInitialProfiles(N_Vector cc, N_Vector sc);
+static void PrintHeader(int globalstrategy, int maxl, int maxlrst, 
+                        realtype fnormtol, realtype scsteptol);
+static void PrintOutput(N_Vector cc);
+static void PrintFinalStats(void *kmem);
+static void WebRate(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
+                    void *user_data);
+static realtype DotProd(long int size, realtype *x1, realtype *x2);
+static int check_flag(void *flagvalue, char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main(int argc, char *argv[])
+{
+  int globalstrategy;
+  realtype fnormtol, scsteptol;
+  N_Vector cc, sc, constraints;
+  UserData data;
+  int flag, maxl, maxlrst;
+  void *kmem;
+  int num_threads;
+
+  cc = sc = constraints = NULL;
+  kmem = NULL;
+  data = NULL;
+
+  /* Allocate memory, and set problem data, initial values, tolerances */ 
+  globalstrategy = KIN_NONE;
+
+  /* Set the number of threads to use */
+  num_threads = 1;     /* default value*/
+#ifdef _OPENMP
+  num_threads = omp_get_max_threads();    /* Overwrite with OMP_NUM_THREADS environment variable */
+#endif
+  if (argc > 1)        /* overwrithe with command line value, if supplied */
+    num_threads = strtol(argv[1], NULL, 0);
+
+  data = AllocUserData();
+  if (check_flag((void *)data, "AllocUserData", 2)) return(1);
+  InitUserData(data);
+  data->nthreads = num_threads;
+
+  /* Create serial vectors of length NEQ */
+  cc = N_VNew_OpenMP(NEQ, num_threads);
+  if (check_flag((void *)cc, "N_VNew_OpenMP", 0)) return(1);
+  sc = N_VNew_OpenMP(NEQ, num_threads);
+  if (check_flag((void *)sc, "N_VNew_OpenMP", 0)) return(1);
+  data->rates = N_VNew_OpenMP(NEQ, num_threads);
+  if (check_flag((void *)data->rates, "N_VNew_OpenMP", 0)) return(1);
+
+  constraints = N_VNew_OpenMP(NEQ, num_threads);
+  if (check_flag((void *)constraints, "N_VNew_OpenMP", 0)) return(1);
+  N_VConst(TWO, constraints);
+
+  SetInitialProfiles(cc, sc);
+
+  fnormtol=FTOL; scsteptol=STOL;
+
+  /* Call KINCreate/KINInit to initialize KINSOL.
+     A pointer to KINSOL problem memory is returned and stored in kmem. */
+  kmem = KINCreate();
+  if (check_flag((void *)kmem, "KINCreate", 0)) return(1);
+
+  /* Vector cc passed as template vector. */
+  flag = KINInit(kmem, func, cc);
+  if (check_flag(&flag, "KINInit", 1)) return(1);
+
+  flag = KINSetUserData(kmem, data);
+  if (check_flag(&flag, "KINSetUserData", 1)) return(1);
+  flag = KINSetConstraints(kmem, constraints);
+  if (check_flag(&flag, "KINSetConstraints", 1)) return(1);
+  flag = KINSetFuncNormTol(kmem, fnormtol);
+  if (check_flag(&flag, "KINSetFuncNormTol", 1)) return(1);
+  flag = KINSetScaledStepTol(kmem, scsteptol);
+  if (check_flag(&flag, "KINSetScaledStepTol", 1)) return(1);
+
+  /* We no longer need the constraints vector since KINSetConstraints
+     creates a private copy for KINSOL to use. */
+  N_VDestroy_OpenMP(constraints);
+
+  /* Call KINSpgmr to specify the linear solver KINSPGMR with preconditioner
+     routines PrecSetupBD and PrecSolveBD. */
+  maxl = 15; 
+  maxlrst = 2;
+  flag = KINSpgmr(kmem, maxl);
+  if (check_flag(&flag, "KINSpgmr", 1)) return(1);
+
+  flag = KINSpilsSetMaxRestarts(kmem, maxlrst);
+  if (check_flag(&flag, "KINSpilsSetMaxRestarts", 1)) return(1);
+  flag = KINSpilsSetPreconditioner(kmem,
+				   PrecSetupBD,
+				   PrecSolveBD);
+  if (check_flag(&flag, "KINSpilsSetPreconditioner", 1)) return(1);
+
+  /* Print out the problem size, solution parameters, initial guess. */
+  PrintHeader(globalstrategy, maxl, maxlrst, fnormtol, scsteptol);
+
+  /* Call KINSol and print output concentration profile */
+  flag = KINSol(kmem,           /* KINSol memory block */
+                cc,             /* initial guess on input; solution vector */
+                globalstrategy, /* global strategy choice */
+                sc,             /* scaling vector, for the variable cc */
+                sc);            /* scaling vector for function values fval */
+  if (check_flag(&flag, "KINSol", 1)) return(1);
+
+  printf("\n\nComputed equilibrium species concentrations:\n");
+  PrintOutput(cc);
+
+  /* Print final statistics and free memory */  
+  PrintFinalStats(kmem);
+  printf("num_threads = %i\n", num_threads);
+
+  N_VDestroy_OpenMP(cc);
+  N_VDestroy_OpenMP(sc);
+  KINFree(&kmem);
+  FreeUserData(data);
+
+  return(0);
+}
+
+/* Readability definitions used in other routines below */
+
+#define acoef  (data->acoef)
+#define bcoef  (data->bcoef)
+#define cox    (data->cox)
+#define coy    (data->coy)
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY KINSOL
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * System function for predator-prey system 
+ */
+
+static int func(N_Vector cc, N_Vector fval, void *user_data)
+{
+  realtype xx, yy, delx, dely, *cxy, *rxy, *fxy, dcyli, dcyui, dcxli, dcxri;
+  long int jx, jy, is, idyu, idyl, idxr, idxl;
+  UserData data;
+  
+  data = (UserData)user_data;
+  delx = data->dx;
+  dely = data->dy;
+  
+  /* Loop over all mesh points, evaluating rate array at each point*/
+  for (jy = 0; jy < MY; jy++) {
+    
+    yy = dely*jy;
+
+    /* Set lower/upper index shifts, special at boundaries. */
+    idyl = (jy != 0   ) ? NSMX : -NSMX;
+    idyu = (jy != MY-1) ? NSMX : -NSMX;
+    
+    for (jx = 0; jx < MX; jx++) {
+
+      xx = delx*jx;
+
+      /* Set left/right index shifts, special at boundaries. */
+      idxl = (jx !=  0  ) ?  NUM_SPECIES : -NUM_SPECIES;
+      idxr = (jx != MX-1) ?  NUM_SPECIES : -NUM_SPECIES;
+
+      cxy = IJ_Vptr(cc,jx,jy);
+      rxy = IJ_Vptr(data->rates,jx,jy);
+      fxy = IJ_Vptr(fval,jx,jy);
+
+      /* Get species interaction rate array at (xx,yy) */
+      WebRate(xx, yy, cxy, rxy, user_data);
+
+      for(is = 0; is < NUM_SPECIES; is++) {
+        
+        /* Differencing in x direction */
+        dcyli = *(cxy+is) - *(cxy - idyl + is) ;
+        dcyui = *(cxy + idyu + is) - *(cxy+is);
+        
+        /* Differencing in y direction */
+        dcxli = *(cxy+is) - *(cxy - idxl + is);
+        dcxri = *(cxy + idxr +is) - *(cxy+is);
+        
+        /* Compute the total rate value at (xx,yy) */
+        fxy[is] = (coy)[is] * (dcyui - dcyli) +
+          (cox)[is] * (dcxri - dcxli) + rxy[is];
+        
+      } /* end of is loop */
+      
+    } /* end of jx loop */
+    
+  } /* end of jy loop */
+
+  return(0);
+}
+
+/*
+ * Preconditioner setup routine. Generate and preprocess P. 
+ */
+
+static int PrecSetupBD(N_Vector cc, N_Vector cscale,
+                       N_Vector fval, N_Vector fscale,
+                       void *user_data,
+                       N_Vector vtemp1, N_Vector vtemp2)
+{
+  realtype r, r0, uround, sqruround, xx, yy, delx, dely, csave, fac;
+  realtype *cxy, *scxy, **Pxy, *ratesxy, *Pxycol, perturb_rates[NUM_SPECIES];
+  long int i, j, jx, jy, ret;
+  UserData data;
+  
+  data = (UserData) user_data;
+  delx = data->dx;
+  dely = data->dy;
+  
+  uround = data->uround;
+  sqruround = data->sqruround;
+  fac = N_VWL2Norm(fval, fscale);
+  r0 = THOUSAND * uround * fac * NEQ;
+  if(r0 == ZERO) r0 = ONE;
+  
+  /* Loop over spatial points; get size NUM_SPECIES Jacobian block at each */
+  for (jy = 0; jy < MY; jy++) {
+    yy = jy*dely;
+    
+    for (jx = 0; jx < MX; jx++) {
+      xx = jx*delx;
+      Pxy = (data->P)[jx][jy];
+      cxy = IJ_Vptr(cc,jx,jy);
+      scxy= IJ_Vptr(cscale,jx,jy);
+      ratesxy = IJ_Vptr((data->rates),jx,jy);
+      
+      /* Compute difference quotients of interaction rate fn. */
+      for (j = 0; j < NUM_SPECIES; j++) {
+        
+        csave = cxy[j];  /* Save the j,jx,jy element of cc */
+        r = SUNMAX(sqruround*SUNRabs(csave), r0/scxy[j]);
+        cxy[j] += r; /* Perturb the j,jx,jy element of cc */
+        fac = ONE/r;
+        
+        WebRate(xx, yy, cxy, perturb_rates, data);
+        
+        /* Restore j,jx,jy element of cc */
+        cxy[j] = csave;
+        
+        /* Load the j-th column of difference quotients */
+        Pxycol = Pxy[j];
+	
+#pragma omp parallel for default(shared) private(i)
+        for (i = 0; i < NUM_SPECIES; i++)
+          Pxycol[i] = (perturb_rates[i] - ratesxy[i]) * fac;
+        
+        
+      } /* end of j loop */
+      
+      /* Do LU decomposition of size NUM_SPECIES preconditioner block */
+      ret = denseGETRF(Pxy, NUM_SPECIES, NUM_SPECIES, (data->pivot)[jx][jy]);
+      if (ret != 0) return(1);
+      
+    } /* end of jx loop */
+    
+  } /* end of jy loop */
+  
+  return(0);  
+}
+
+/*
+ * Preconditioner solve routine 
+ */
+
+static int PrecSolveBD(N_Vector cc, N_Vector cscale, 
+                       N_Vector fval, N_Vector fscale, 
+                       N_Vector vv, void *user_data,
+                       N_Vector ftem)
+{
+  realtype **Pxy, *vxy;
+  long int *piv, jx, jy;
+  UserData data;
+  
+  data = (UserData)user_data;
+  
+#pragma omp parallel for collapse(2) default(shared) private(jx, jy, Pxy, piv, vxy) schedule(static) 
+  for (jx=0; jx<MX; jx++) {
+    
+    for (jy=0; jy<MY; jy++) {
+      
+      /* For each (jx,jy), solve a linear system of size NUM_SPECIES.
+         vxy is the address of the corresponding portion of the vector vv;
+         Pxy is the address of the corresponding block of the matrix P;
+         piv is the address of the corresponding block of the array pivot. */
+      vxy = IJ_Vptr(vv,jx,jy);
+      Pxy = (data->P)[jx][jy];
+      piv = (data->pivot)[jx][jy];
+      denseGETRS(Pxy, NUM_SPECIES, piv, vxy);
+      
+    } /* end of jy loop */
+    
+  } /* end of jx loop */
+  
+  return(0);
+}
+
+/*
+ * Interaction rate function routine 
+ */
+
+static void WebRate(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
+                    void *user_data)
+{
+  long int i;
+  realtype fac;
+  UserData data;
+  
+  data = (UserData)user_data;
+  
+  for (i = 0; i<NUM_SPECIES; i++)
+    ratesxy[i] = DotProd(NUM_SPECIES, cxy, acoef[i]);
+  
+  fac = ONE + ALPHA * xx * yy;
+  
+#pragma omp parallel for default(shared) private(i) 
+  for (i = 0; i < NUM_SPECIES; i++)
+    ratesxy[i] = cxy[i] * ( bcoef[i] * fac + ratesxy[i] );  
+}
+
+/*
+ * Dot product routine for realtype arrays 
+ */
+
+static realtype DotProd(long int size, realtype *x1, realtype *x2)
+{
+  long int i;
+  realtype *xx1, *xx2, temp = ZERO;
+  
+  xx1 = x1; xx2 = x2;
+  for (i = 0; i < size; i++) temp += (*xx1++) * (*xx2++);
+
+  return(temp);  
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Allocate memory for data structure of type UserData 
+ */
+
+static UserData AllocUserData(void)
+{
+  int jx, jy;
+  UserData data;
+
+  data = (UserData) malloc(sizeof *data);
+  
+  for (jx=0; jx < MX; jx++) {
+    for (jy=0; jy < MY; jy++) {
+      (data->P)[jx][jy] = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+      (data->pivot)[jx][jy] = newLintArray(NUM_SPECIES);
+    }
+  }
+  acoef = newDenseMat(NUM_SPECIES, NUM_SPECIES);
+  bcoef = (realtype *)malloc(NUM_SPECIES * sizeof(realtype));
+  cox   = (realtype *)malloc(NUM_SPECIES * sizeof(realtype));
+  coy   = (realtype *)malloc(NUM_SPECIES * sizeof(realtype));
+  
+  return(data);
+}
+
+/* 
+ * Load problem constants in data 
+ */
+
+static void InitUserData(UserData data)
+{
+  long int i, j, np;
+  realtype *a1,*a2, *a3, *a4, dx2, dy2;
+
+  data->mx = MX;
+  data->my = MY;
+  data->ns = NUM_SPECIES;
+  data->np = NUM_SPECIES/2;
+  data->ax = AX;
+  data->ay = AY;
+  data->dx = (data->ax)/(MX-1);
+  data->dy = (data->ay)/(MY-1);
+  data->uround = UNIT_ROUNDOFF;
+  data->sqruround = SUNRsqrt(data->uround);
+
+  /* Set up the coefficients a and b plus others found in the equations */
+  np = data->np;
+
+  dx2=(data->dx)*(data->dx); dy2=(data->dy)*(data->dy);
+
+  for (i = 0; i < np; i++) {
+    a1= &(acoef[i][np]);
+    a2= &(acoef[i+np][0]);
+    a3= &(acoef[i][0]);
+    a4= &(acoef[i+np][np]);
+
+    /*  Fill in the portion of acoef in the four quadrants, row by row */
+    for (j = 0; j < np; j++) {
+      *a1++ =  -GG;
+      *a2++ =   EE;
+      *a3++ = ZERO;
+      *a4++ = ZERO;
+    }
+
+    /* and then change the diagonal elements of acoef to -AA */
+    acoef[i][i]=-AA;
+    acoef[i+np][i+np] = -AA;
+
+    bcoef[i] = BB;
+    bcoef[i+np] = -BB;
+
+    cox[i]=DPREY/dx2;
+    cox[i+np]=DPRED/dx2;
+
+    coy[i]=DPREY/dy2;
+    coy[i+np]=DPRED/dy2;
+  }  
+}
+
+/* 
+ * Free data memory 
+ */
+
+static void FreeUserData(UserData data)
+{
+  int jx, jy;
+  
+  for (jx=0; jx < MX; jx++) {
+    for (jy=0; jy < MY; jy++) {
+      destroyMat((data->P)[jx][jy]);
+      destroyArray((data->pivot)[jx][jy]);
+    }
+  }
+  
+  destroyMat(acoef);
+  free(bcoef);
+  free(cox);
+  free(coy);
+  N_VDestroy_OpenMP(data->rates);
+  free(data);
+}
+
+/* 
+ * Set initial conditions in cc 
+ */
+
+static void SetInitialProfiles(N_Vector cc, N_Vector sc)
+{
+  int i, jx, jy;
+  realtype *cloc, *sloc;
+  realtype  ctemp[NUM_SPECIES], stemp[NUM_SPECIES];
+  
+  /* Initialize arrays ctemp and stemp used in the loading process */
+  for (i = 0; i < NUM_SPECIES/2; i++) {
+    ctemp[i] = PREYIN;
+    stemp[i] = ONE;
+  }
+  for (i = NUM_SPECIES/2; i < NUM_SPECIES; i++) {
+    ctemp[i] = PREDIN;
+    stemp[i] = RCONST(0.00001);
+  }
+
+  /* Load initial profiles into cc and sc vector from ctemp and stemp. */
+  for (jy = 0; jy < MY; jy++) {
+    for (jx = 0; jx < MX; jx++) {
+      cloc = IJ_Vptr(cc,jx,jy);
+      sloc = IJ_Vptr(sc,jx,jy);
+      for (i = 0; i < NUM_SPECIES; i++) {
+        cloc[i] = ctemp[i];
+        sloc[i] = stemp[i];
+      }
+    }
+  }
+}
+
+/* 
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(int globalstrategy, int maxl, int maxlrst, 
+                        realtype fnormtol, realtype scsteptol)
+{
+  printf("\nPredator-prey test problem --  KINSol (OpenMP version)\n\n");
+  printf("Mesh dimensions = %d X %d\n", MX, MY);
+  printf("Number of species = %d\n", NUM_SPECIES);
+  printf("Total system size = %d\n\n", NEQ);
+  printf("Flag globalstrategy = %d (0 = None, 1 = Linesearch)\n",
+         globalstrategy);
+  printf("Linear solver is SPGMR with maxl = %d, maxlrst = %d\n",
+         maxl, maxlrst);
+  printf("Preconditioning uses interaction-only block-diagonal matrix\n");
+  printf("Positivity constraints imposed on all components \n");
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("Tolerance parameters:  fnormtol = %Lg   scsteptol = %Lg\n",
+         fnormtol, scsteptol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
+         fnormtol, scsteptol);
+#else
+  printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
+         fnormtol, scsteptol);
+#endif
+
+  printf("\nInitial profile of concentration\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("At all mesh points:  %Lg %Lg %Lg   %Lg %Lg %Lg\n", 
+         PREYIN, PREYIN, PREYIN,
+         PREDIN, PREDIN, PREDIN);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("At all mesh points:  %g %g %g   %g %g %g\n", 
+         PREYIN, PREYIN, PREYIN,
+         PREDIN, PREDIN, PREDIN);
+#else
+  printf("At all mesh points:  %g %g %g   %g %g %g\n", 
+         PREYIN, PREYIN, PREYIN,
+         PREDIN, PREDIN, PREDIN);
+#endif
+}
+
+/* 
+ * Print sampled values of current cc 
+ */
+
+static void PrintOutput(N_Vector cc)
+{
+  int is, jx, jy;
+  realtype *ct;
+  
+  jy = 0; jx = 0;
+  ct = IJ_Vptr(cc,jx,jy);
+  printf("\nAt bottom left:");
+
+  /* Print out lines with up to 6 values per line */
+  for (is = 0; is < NUM_SPECIES; is++){
+    if ((is%6)*6 == is) printf("\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf(" %Lg",ct[is]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf(" %g",ct[is]);
+#else
+    printf(" %g",ct[is]);
+#endif
+  }
+  
+  jy = MY-1; jx = MX-1;
+  ct = IJ_Vptr(cc,jx,jy);
+  printf("\n\nAt top right:");
+
+  /* Print out lines with up to 6 values per line */
+  for (is = 0; is < NUM_SPECIES; is++) {
+    if ((is%6)*6 == is) printf("\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf(" %Lg",ct[is]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf(" %g",ct[is]);
+#else
+    printf(" %g",ct[is]);
+#endif
+  }
+  printf("\n\n");
+}
+
+/* 
+ * Print final statistics contained in iopt 
+ */
+
+static void PrintFinalStats(void *kmem)
+{
+  long int nni, nfe, nli, npe, nps, ncfl, nfeSG;
+  int flag;
+  
+  flag = KINGetNumNonlinSolvIters(kmem, &nni);
+  check_flag(&flag, "KINGetNumNonlinSolvIters", 1);
+  flag = KINGetNumFuncEvals(kmem, &nfe);
+  check_flag(&flag, "KINGetNumFuncEvals", 1);
+  flag = KINSpilsGetNumLinIters(kmem, &nli);
+  check_flag(&flag, "KINSpilsGetNumLinIters", 1);
+  flag = KINSpilsGetNumPrecEvals(kmem, &npe);
+  check_flag(&flag, "KINSpilsGetNumPrecEvals", 1);
+  flag = KINSpilsGetNumPrecSolves(kmem, &nps);
+  check_flag(&flag, "KINSpilsGetNumPrecSolves", 1);
+  flag = KINSpilsGetNumConvFails(kmem, &ncfl);
+  check_flag(&flag, "KINSpilsGetNumConvFails", 1);
+  flag = KINSpilsGetNumFuncEvals(kmem, &nfeSG);
+  check_flag(&flag, "KINSpilsGetNumFuncEvals", 1);
+
+  printf("Final Statistics.. \n");
+  printf("nni    = %5ld    nli   = %5ld\n", nni, nli);
+  printf("nfe    = %5ld    nfeSG = %5ld\n", nfe, nfeSG);
+  printf("nps    = %5ld    npe   = %5ld     ncfl  = %5ld\n", nps, npe, ncfl);
+  
+}
+
+/*
+ * Check function return value...
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr,
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); 
+    }
+  }
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr,
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.out b/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.out
new file mode 100644
index 0000000..e4829be
--- /dev/null
+++ b/examples/kinsol/C_openmp/kinFoodWeb_kry_omp.out
@@ -0,0 +1,30 @@
+
+Predator-prey test problem --  KINSol (OpenMP version)
+
+Mesh dimensions = 8 X 8
+Number of species = 6
+Total system size = 384
+
+Flag globalstrategy = 0 (0 = None, 1 = Linesearch)
+Linear solver is SPGMR with maxl = 15, maxlrst = 2
+Preconditioning uses interaction-only block-diagonal matrix
+Positivity constraints imposed on all components 
+Tolerance parameters:  fnormtol = 1e-07   scsteptol = 1e-13
+
+Initial profile of concentration
+At all mesh points:  1 1 1   30000 30000 30000
+
+
+Computed equilibrium species concentrations:
+
+At bottom left:
+ 1.16428 1.16428 1.16428 34927.5 34927.5 34927.5
+
+At top right:
+ 1.25797 1.25797 1.25797 37736.7 37736.7 37736.7
+
+Final Statistics.. 
+nni    =    10    nli   =   378
+nfe    =    11    nfeSG =   388
+nps    =   388    npe   =     1     ncfl  =     7
+num_threads = 32
diff --git a/examples/kinsol/fcmix_parallel/CMakeLists.txt b/examples/kinsol/fcmix_parallel/CMakeLists.txt
index 0141694..d3f5d60 100644
--- a/examples/kinsol/fcmix_parallel/CMakeLists.txt
+++ b/examples/kinsol/fcmix_parallel/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4096 $
+# $Date: 2014-05-02 14:49:50 -0700 (Fri, 02 May 2014) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the FKINSOL parallel examples
 
@@ -15,7 +20,7 @@
 # Add variable kinsol_examples with the names of the parallel KINSOL examples
 
 SET(FKINSOL_examples
-  fkinDiagon_kry_p
+  "fkinDiagon_kry_p\;1\;4"
   )
 
 # Check whether we use MPI compiler scripts.
@@ -51,14 +56,27 @@ SET(FKINSOL_LIB sundials_fkinsol_static)
 
 SET(SUNDIALS_LIBS ${FKINSOL_LIB} ${KINSOL_LIB} ${FNVECP_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
 # Add the build and install targets for each KINSOL example
 
-FOREACH(example ${FKINSOL_examples})
+FOREACH(example_tuple ${FKINSOL_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
   ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPIF77)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -66,7 +84,7 @@ FOREACH(example ${FKINSOL_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/fcmix_parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${FKINSOL_examples})
+ENDFOREACH(example_tuple ${FKINSOL_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -77,7 +95,10 @@ IF(EXAMPLES_INSTALL)
   SET(SOLVER "KINSOL")
   SET(SOLVER_LIB "sundials_kinsol")
   SET(SOLVER_FLIB "sundials_fkinsol")
-  LIST2STRING(FKINSOL_examples EXAMPLES)
+  FOREACH(example_tuple ${FKINSOL_examples})
+    list(GET example_tuple 0 example)
+    LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${FKINSOL_examples})
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/kinsol/fcmix_parallel/Makefile.in b/examples/kinsol/fcmix_parallel/Makefile.in
deleted file mode 100644
index e4bfcc9..0000000
--- a/examples/kinsol/fcmix_parallel/Makefile.in
+++ /dev/null
@@ -1,114 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FKINSOL parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-FFLAGS       = @FFLAGS@
-F77_LDFLAGS  = @F77_LDFLAGS@
-F77_LIBS     = @F77_LIBS@
-
-MPIF77       = @MPIF77@
-MPI_INC_DIR  = @MPI_INC_DIR@
-MPI_FLAGS    = @MPI_FLAGS@
-MPIF77_LNKR  = @MPIF77_LNKR@
-MPI_LIB_DIR  = @MPI_LIB_DIR@
-MPI_LIBS     = @MPI_LIBS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_LIBS = $(top_builddir)/src/kinsol/fcmix/libsundials_fkinsol.la   \
-	        $(top_builddir)/src/kinsol/libsundials_kinsol.la          \
-	        $(top_builddir)/src/nvec_par/libsundials_fnvecparallel.la \
-	        $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-fortran-update = ${SHELL} ${top_builddir}/bin/fortran-update.sh
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = fkinDiagon_kry_p
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${MPIF77} ${MPI_FLAGS} -I${MPI_INC_DIR} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${MPIF77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${MPI_FLAGS} ${F77_LDFLAGS} ${SUNDIALS_LIBS} -L${MPI_LIB_DIR} ${MPI_LIBS} ${F77_LIBS} $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/kinsol/fcmix_parallel
-	$(INSTALL_FILE) Makefile_ex  $(EXS_INSTDIR)/kinsol/fcmix_parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_parallel/README  $(EXS_INSTDIR)/kinsol/fcmix_parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_parallel/$${i}.f   $(EXS_INSTDIR)/kinsol/fcmix_parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_parallel/$${i}.out $(EXS_INSTDIR)/kinsol/fcmix_parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/kinsol/fcmix_parallel/Makefile
-	rm -f $(EXS_INSTDIR)/kinsol/fcmix_parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/kinsol/fcmix_parallel/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/kinsol/fcmix_parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol/fcmix_parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f *-updated.f
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/kinsol/fcmix_parallel/README b/examples/kinsol/fcmix_parallel/README
index 5b78a3c..1c00d9e 100644
--- a/examples/kinsol/fcmix_parallel/README
+++ b/examples/kinsol/fcmix_parallel/README
@@ -2,14 +2,48 @@ List of parallel KINSOL FCMIX examples
 
   fkinDiagon_kry_p: simple diagonal test with Fortran interface
 
-Sample result:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC)
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/kinsol/fcmix_parallel/fkinDiagon_kry_p.f b/examples/kinsol/fcmix_parallel/fkinDiagon_kry_p.f
index dd51516..bebff32 100644
--- a/examples/kinsol/fcmix_parallel/fkinDiagon_kry_p.f
+++ b/examples/kinsol/fcmix_parallel/fkinDiagon_kry_p.f
@@ -1,7 +1,7 @@
       program fkinDiagon_kry_p
 c     ----------------------------------------------------------------
-c     $Revision: 1.2 $
-c     $Date: 2009/09/30 23:42:12 $
+c     $Revision: 4881 $
+c     $Date: 2016-09-01 15:31:14 -0700 (Thu, 01 Sep 2016) $
 c     ----------------------------------------------------------------
 c     Programmer(s): Allan G. Taylor, Alan C. Hindmarsh and
 c                    Radu Serban @ LLNL
@@ -25,18 +25,19 @@ c
 
       include "mpif.h"
 
+      integer localsize
+      parameter(localsize=32)
+      integer baseadd, i, ii
       integer ier, size, globalstrat, rank, mype, npes
       integer maxl, maxlrst
-      integer*4 localsize
-      parameter(localsize=32)
-      integer*4 neq, nlocal, msbpre, baseadd, i, ii
-      integer*4 iout(15)
+c The following declaration specification should match C type long int.
+      integer*8 neq, nlocal, iout(15), msbpre
       double precision rout(2)
       double precision pp, fnormtol, scsteptol
       double precision uu(localsize), scale(localsize)
       double precision constr(localsize)
 
-      common /pcom/ pp(localsize), mype, npes, baseadd, nlocal
+      common /pcom/ pp(localsize), nlocal, mype, npes, baseadd
 
       nlocal = localsize
       neq = 4 * nlocal
@@ -57,14 +58,14 @@ c     number of this process.
       call mpi_init(ier)
       if (ier .ne. 0) then
          write(6,1210) ier
- 1210    format('MPI_ERROR: MPI_INIT returned IER = ', i2)
+ 1210    format('MPI_ERROR: MPI_INIT returned IER = ', i4)
          stop
       endif
 
       call fnvinitp(mpi_comm_world, 3, nlocal, neq, ier)
       if (ier .ne. 0) then
          write(6,1220) ier
- 1220    format('SUNDIALS_ERROR: FNVINITP returned IER = ', i2)
+ 1220    format('SUNDIALS_ERROR: FNVINITP returned IER = ', i4)
          call mpi_finalize(ier)
          stop
       endif
@@ -72,7 +73,7 @@ c     number of this process.
       call mpi_comm_size(mpi_comm_world, size, ier)
       if (ier .ne. 0) then
          write(6,1222) ier
- 1222    format('MPI_ERROR: MPI_COMM_SIZE returned IER = ', i2)
+ 1222    format('MPI_ERROR: MPI_COMM_SIZE returned IER = ', i4)
          call mpi_abort(mpi_comm_world, 1, ier)
          stop
       endif
@@ -88,7 +89,7 @@ c     number of this process.
       call mpi_comm_rank(mpi_comm_world, rank, ier)
       if (ier .ne. 0) then
          write(6,1224) ier
- 1224    format('MPI_ERROR: MPI_COMM_RANK returned IER = ', i2)
+ 1224    format('MPI_ERROR: MPI_COMM_RANK returned IER = ', i4)
          call mpi_abort(mpi_comm_world, 1, ier)
          stop
       endif
@@ -103,11 +104,10 @@ c     number of this process.
          constr(ii) = 0.0d0
  20   continue
       
-      call fkinmalloc(iout, rout, ier)
-      
+      call fkincreate(ier)
       if (ier .ne. 0) then
          write(6,1231)ier
- 1231    format('SUNDIALS_ERROR: FKINMALLOC returned IER = ', i2)
+ 1231    format('SUNDIALS_ERROR: FKINCREATE returned IER = ', i4)
          call mpi_abort(mpi_comm_world, 1, ier)
          stop
       endif
@@ -117,6 +117,14 @@ c     number of this process.
       call fkinsetrin('SSTEP_TOL', scsteptol, ier)
       call fkinsetvin('CONSTR_VEC', constr, ier)
 
+      call fkininit(iout, rout, ier)
+      if (ier .ne. 0) then
+         write(6,1232)ier
+ 1232    format('SUNDIALS_ERROR: FKININIT returned IER = ', i4)
+         call mpi_abort(mpi_comm_world, 1, ier)
+         stop
+      endif
+
       call fkinspgmr(maxl, maxlrst, ier)
       call fkinspilssetprec(1, ier)
       
@@ -130,8 +138,8 @@ c     number of this process.
       call fkinsol(uu, globalstrat, scale, scale, ier)
       if (ier .lt. 0) then
          write(6,1242) ier, iout(9)
- 1242    format('SUNDIALS_ERROR: FKINSOL returned IER = ', i2, /,
-     1          '                Linear Solver returned IER = ', i2)
+ 1242    format('SUNDIALS_ERROR: FKINSOL returned IER = ', i4, /,
+     1          '                Linear Solver returned IER = ', i4)
          call mpi_abort(mpi_comm_world, 1, ier)
          stop
       endif
@@ -173,17 +181,21 @@ c     function with the following name and form.
 
       implicit none
 
-      integer mype, npes, ier
-      integer*4 baseadd, nlocal, i, localsize
+c The following declaration specification should match C type long int.
+      integer*8 nlocal
+      integer ier, mype, npes, baseadd, i
+      integer localsize
       parameter(localsize=32)
       double precision pp
       double precision fval(*), uu(*)
 
-      common /pcom/ pp(localsize), mype, npes, baseadd, nlocal
+      common /pcom/ pp(localsize), nlocal, mype, npes, baseadd
 
       do 10 i = 1, nlocal
  10      fval(i) = uu(i) * uu(i) - (i + baseadd) * (i + baseadd)
       
+      ier = 0
+      
       return
       end
       
@@ -198,15 +210,16 @@ c     to it.  The argument list must also be as illustrated below:
 
       implicit none
 
-      integer ier, mype, npes
-      integer*4 localsize
+c The following declaration specification should match C type long int.
+      integer*8 nlocal
+      integer ier, mype, npes, baseadd, i
+      integer localsize
       parameter(localsize=32)
-      integer*4 baseadd, nlocal, i
       double precision pp
       double precision udata(*), uscale(*), fdata(*), fscale(*)
       double precision vtemp1(*), vtemp2(*)
 
-      common /pcom/ pp(localsize), mype, npes, baseadd, nlocal
+      common /pcom/ pp(localsize), nlocal, mype, npes, baseadd
 
       do 10 i = 1, nlocal
  10      pp(i) = 0.5d0 / (udata(i)+ 5.0d0)
@@ -227,15 +240,16 @@ c     to it.  The argument list must also be as illustrated below:
 
       implicit none
 
-      integer ier, mype, npes
-      integer*4 baseadd, nlocal, i
-      integer*4 localsize
+c The following declaration specification should match C type long int.
+      integer*8 nlocal
+      integer ier, mype, npes, baseadd, i
+      integer localsize
       parameter(localsize=32)
       double precision udata(*), uscale(*), fdata(*), fscale(*)
       double precision vv(*), ftem(*)
       double precision pp
 
-      common /pcom/ pp(localsize), mype, npes, baseadd, nlocal
+      common /pcom/ pp(localsize), nlocal, mype, npes, baseadd
 
       do 10 i = 1, nlocal
  10      vv(i) = vv(i) * pp(i)
diff --git a/examples/kinsol/fcmix_serial/CMakeLists.txt b/examples/kinsol/fcmix_serial/CMakeLists.txt
index 01803e9..d739119 100644
--- a/examples/kinsol/fcmix_serial/CMakeLists.txt
+++ b/examples/kinsol/fcmix_serial/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.5 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4096 $
+# $Date: 2014-05-02 14:49:50 -0700 (Fri, 02 May 2014) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the FKINSOL serial examples
 
@@ -45,14 +50,23 @@ SET(FKINSOL_LIB sundials_fkinsol_static)
 
 SET(SUNDIALS_LIBS ${FKINSOL_LIB} ${KINSOL_LIB} ${FNVECS_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
 # Add the build and install targets for each FKINSOL example
 
 FOREACH(example ${FKINSOL_examples})
   ADD_EXECUTABLE(${example} ${example}.f)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/fcmix_serial)
@@ -65,6 +79,8 @@ ENDFOREACH(example ${FKINSOL_examples})
 IF(LAPACK_FOUND)
   FOREACH(example ${FKINSOL_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.f)
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     IF(EXAMPLES_INSTALL)
       INSTALL(FILES ${example}.f ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/fcmix_serial)
diff --git a/examples/kinsol/fcmix_serial/Makefile.in b/examples/kinsol/fcmix_serial/Makefile.in
deleted file mode 100644
index 20fb2c3..0000000
--- a/examples/kinsol/fcmix_serial/Makefile.in
+++ /dev/null
@@ -1,134 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.10 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FKINSOL serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-F77          = @F77@
-FFLAGS       = @FFLAGS@
-F77_LNKR     = @F77_LNKR@
-F77_LDFLAGS  = @F77_LDFLAGS@
-F77_LIBS     = @F77_LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_LIBS = $(top_builddir)/src/kinsol/fcmix/libsundials_fkinsol.la \
-	        $(top_builddir)/src/kinsol/libsundials_kinsol.la        \
-	        $(top_builddir)/src/nvec_ser/libsundials_fnvecserial.la \
-	        $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-fortran-update = ${SHELL} ${top_builddir}/bin/fortran-update.sh
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = fkinDiagon_kry
-
-EXAMPLES_BL =
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${F77} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${F77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${F77_LDFLAGS} ${SUNDIALS_LIBS} ${F77_LIBS} ${BLAS_LAPACK_LIBS} ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  ${fortran-update} ${srcdir} $${i}.f ; \
-	  ${LIBTOOL} --mode=compile ${F77} ${FFLAGS} -c ${builddir}/$${i}-updated.f ; \
-	  ${LIBTOOL} --mode=link ${F77_LNKR} -o ${builddir}/$${i}${EXE_EXT} ${builddir}/$${i}-updated${OBJ_EXT} ${F77_LDFLAGS} ${SUNDIALS_LIBS} ${F77_LIBS} ${BLAS_LAPACK_LIBS} ; \
-	done ; \
-	fi
-
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/kinsol/fcmix_serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/kinsol/fcmix_serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_serial/README $(EXS_INSTDIR)/kinsol/fcmix_serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_serial/$${i}.f   $(EXS_INSTDIR)/kinsol/fcmix_serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_serial/$${i}.out $(EXS_INSTDIR)/kinsol/fcmix_serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_serial/$${i}.f   $(EXS_INSTDIR)/kinsol/fcmix_serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/fcmix_serial/$${i}.out $(EXS_INSTDIR)/kinsol/fcmix_serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/kinsol/fcmix_serial/Makefile
-	rm -f $(EXS_INSTDIR)/kinsol/fcmix_serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/kinsol/fcmix_serial/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/kinsol/fcmix_serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/kinsol/fcmix_serial/$${i}.f ; \
-	  rm -f $(EXS_INSTDIR)/kinsol/fcmix_serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol/fcmix_serial
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f *-updated.f
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/kinsol/fcmix_serial/README b/examples/kinsol/fcmix_serial/README
index 0328aec..d23c56f 100644
--- a/examples/kinsol/fcmix_serial/README
+++ b/examples/kinsol/fcmix_serial/README
@@ -2,13 +2,48 @@ List of serial KINSOL FCMIX examples
 
   fkinDiagon_kry: simple diagonal test with Fortran interface
 
-Sample result:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC)
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/kinsol/fcmix_serial/fkinDiagon_kry.f b/examples/kinsol/fcmix_serial/fkinDiagon_kry.f
index 9c050d8..87f1553 100644
--- a/examples/kinsol/fcmix_serial/fkinDiagon_kry.f
+++ b/examples/kinsol/fcmix_serial/fkinDiagon_kry.f
@@ -1,7 +1,7 @@
       program fkinDiagon_kry
 c     ----------------------------------------------------------------
-c     $Revision: 1.2 $
-c     $Date: 2009/09/30 23:41:32 $
+c     $Revision: 4881 $
+c     $Date: 2016-09-01 15:31:14 -0700 (Thu, 01 Sep 2016) $
 c     ----------------------------------------------------------------
 c     Programmer(s): Allan Taylor, Alan Hindmarsh and
 c                    Radu Serban @ LLNL  
@@ -21,11 +21,11 @@ c     ----------------------------------------------------------------
 c
       implicit none
 
-      integer ier, globalstrat, maxl, maxlrst
-      integer*4 PROBSIZE
+      integer PROBSIZE
       parameter(PROBSIZE=128)
-      integer*4 neq, i, msbpre
-      integer*4 iout(15)
+c The following declaration specification should match C type long int.
+      integer*8 neq, iout(15), msbpre
+      integer ier, globalstrat, maxl, maxlrst, i
       double precision pp, fnormtol, scsteptol
       double precision rout(2), uu(PROBSIZE), scale(PROBSIZE)
       double precision constr(PROBSIZE)
@@ -46,7 +46,7 @@ c * * * * * * * * * * * * * * * * * * * * * *
       call fnvinits(3, neq, ier)
       if (ier .ne. 0) then
          write(6,1220) ier
- 1220    format('SUNDIALS_ERROR: FNVINITS returned IER = ', i2)
+ 1220    format('SUNDIALS_ERROR: FNVINITS returned IER = ', i4)
          stop
       endif
 
@@ -56,22 +56,55 @@ c * * * * * * * * * * * * * * * * * * * * * *
          constr(i) = 0.0d0
   20  continue
 
-      call fkinmalloc(iout, rout, ier)
+      call fkincreate(ier)
       if (ier .ne. 0) then
          write(6,1230) ier
- 1230    format('SUNDIALS_ERROR: FKINMALLOC returned IER = ', i2)
+ 1230    format('SUNDIALS_ERROR: FKINCREATE returned IER = ', i4)
          stop
       endif
 
       call fkinsetiin('MAX_SETUPS', msbpre, ier)
+      if (ier .ne. 0) then
+         write(6,1231) ier
+ 1231    format('SUNDIALS_ERROR: FKINSETIIN returned IER = ', i4)
+         call fkinfree
+         stop
+      endif
+
       call fkinsetrin('FNORM_TOL', fnormtol, ier)
+      if (ier .ne. 0) then
+         write(6,1232) ier
+ 1232    format('SUNDIALS_ERROR: FKINSETRIN returned IER = ', i4)
+         call fkinfree
+         stop
+      endif
+
       call fkinsetrin('SSTEP_TOL', scsteptol, ier)
+      if (ier .ne. 0) then
+         write(6,1232) ier
+         call fkinfree
+         stop
+      endif
+
       call fkinsetvin('CONSTR_VEC', constr, ier)
+      if (ier .ne. 0) then
+         write(6,1233) ier
+ 1233    format('SUNDIALS_ERROR: FKINSETVIN returned IER = ', i4)
+         call fkinfree
+         stop
+      endif
+
+      call fkininit(iout, rout, ier)
+      if (ier .ne. 0) then
+         write(6,1234) ier
+ 1234    format('SUNDIALS_ERROR: FKININIT returned IER = ', i4)
+         stop
+      endif
 
       call fkinspgmr(maxl, maxlrst, ier)
       if (ier .ne. 0) then
          write(6,1235) ier
- 1235    format('SUNDIALS_ERROR: FKINSPGMR returned IER = ', i2)
+ 1235    format('SUNDIALS_ERROR: FKINSPGMR returned IER = ', i4)
          call fkinfree
          stop
       endif
@@ -88,14 +121,14 @@ c * * * * * * * * * * * * * * * * * * * * * *
       call fkinsol(uu, globalstrat, scale, scale, ier)
       if (ier .lt. 0) then
          write(6,1242) ier, iout(9)
- 1242    format('SUNDIALS_ERROR: FKINSOL returned IER = ', i2, /,
-     1          '                Linear Solver returned IER = ', i2)
+ 1242    format('SUNDIALS_ERROR: FKINSOL returned IER = ', i4, /,
+     1          '                Linear Solver returned IER = ', i4)
          call fkinfree
          stop
       endif
 
       write(6,1245) ier
- 1245 format(/' FKINSOL return code is ', i3)
+ 1245 format(/' FKINSOL return code is ', i4)
 
       write(6,1246)
  1246 format(//' The resultant values of uu are:'/)
@@ -125,8 +158,9 @@ c     function of the following form.
 
       implicit none
 
-      integer ier
-      integer*4 neq, i
+      integer ier, i
+c The following declaration specification should match C type long int.
+      integer*8 neq
       double precision fval(*), uu(*)
 
       common /psize/ neq
@@ -146,13 +180,14 @@ c     The routine kpreco is the preconditioner setup routine. It must have
 c     that specific name be used in order that the c code can find and link
 c     to it.  The argument list must also be as illustrated below:
       
-      subroutine fkpset(udata, uscale, fdata, fscale, 
-     1                  vtemp1, vtemp2, ier)
+      subroutine fkpset(udata, uscale, fdata, fscale, vtemp1, vtemp2,
+     1                  ier)
 
       implicit none
 
-      integer ier
-      integer*4 neq, i
+      integer ier, i
+c The following declaration specification should match C type long int.
+      integer*8 neq
       double precision pp
       double precision udata(*), uscale(*), fdata(*), fscale(*)
       double precision vtemp1(*), vtemp2(*)
@@ -174,13 +209,13 @@ c     The routine kpsol is the preconditioner solve routine. It must have
 c     that specific name be used in order that the c code can find and link
 c     to it.  The argument list must also be as illustrated below:
       
-      subroutine fkpsol(udata, uscale, fdata, fscale, 
-     1                  vv, ftem, ier)
+      subroutine fkpsol(udata, uscale, fdata, fscale, vv, ftem, ier)
 
       implicit none
 
-      integer ier
-      integer*4 neq, i
+      integer ier, i
+c The following declaration specification should match C type long int.
+      integer*8 neq
       double precision pp
       double precision udata(*), uscale(*), fdata(*), fscale(*)
       double precision vv(*), ftem(*)
diff --git a/examples/kinsol/parallel/CMakeLists.txt b/examples/kinsol/parallel/CMakeLists.txt
index 7a1edc9..4a08d8f 100644
--- a/examples/kinsol/parallel/CMakeLists.txt
+++ b/examples/kinsol/parallel/CMakeLists.txt
@@ -1,22 +1,27 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4137 $
+# $Date: 2014-06-15 12:26:15 -0700 (Sun, 15 Jun 2014) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for KINSOL parallel examples
 
 
 # Add variable KINSOL_examples with the names of the parallel KINSOL examples
-
+# "name\;nodes\;tasks"
 SET(KINSOL_examples
-  kinFoodWeb_kry_bbd_p
-  kinFoodWeb_kry_p
+  "kinFoodWeb_kry_bbd_p\;1\;4"
+  "kinFoodWeb_kry_p\;1\;4"
   )
 
 # Check whether we use MPI compiler scripts.
@@ -46,14 +51,27 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${KINSOL_LIB} ${NVECP_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
 # Add the build and install targets for each KINSOL example
 
-FOREACH(example ${KINSOL_examples})
+FOREACH(example_tuple ${KINSOL_examples})
+  list(GET example_tuple 0 example)
+  list(GET example_tuple 1 number_of_nodes)
+  list(GET example_tuple 2 number_of_tasks)
+  # first item is example
   ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example} MPI_NPROCS ${number_of_tasks})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(NOT MPI_MPICC)
     TARGET_LINK_LIBRARIES(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES})
@@ -61,7 +79,7 @@ FOREACH(example ${KINSOL_examples})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/parallel)
   ENDIF(EXAMPLES_INSTALL)
-ENDFOREACH(example ${KINSOL_examples})
+ENDFOREACH(example_tuple ${KINSOL_examples})
 
 IF(EXAMPLES_INSTALL)
 
@@ -71,7 +89,10 @@ IF(EXAMPLES_INSTALL)
   # Prepare substitution variables for Makefile and/or CMakeLists templates
   SET(SOLVER "KINSOL")
   SET(SOLVER_LIB "sundials_kinsol")
-  LIST2STRING(KINSOL_examples EXAMPLES)
+  FOREACH(example_tuple ${KINSOL_examples})
+  	list(GET example_tuple 0 example)
+  	LIST2STRING(example EXAMPLES)
+  ENDFOREACH(example_tuple ${KINSOL_examples})
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/kinsol/parallel/Makefile.in b/examples/kinsol/parallel/Makefile.in
deleted file mode 100644
index 8d24ac8..0000000
--- a/examples/kinsol/parallel/Makefile.in
+++ /dev/null
@@ -1,111 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for KINSOL parallel examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP         = @CPP@
-CPPFLAGS    = @CPPFLAGS@
-CC          = @CC@
-CFLAGS      = @CFLAGS@
-LDFLAGS     = @LDFLAGS@
-LIBS        = @LIBS@
-MPICC       = @MPICC@
-MPI_INC_DIR = @MPI_INC_DIR@
-MPI_LIB_DIR = @MPI_LIB_DIR@
-MPI_LIBS    = @MPI_LIBS@
-MPI_FLAGS   = @MPI_FLAGS@
-
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-SUNDIALS_LIBS = $(top_builddir)/src/kinsol/libsundials_kinsol.la         \
-	        $(top_builddir)/src/nvec_par/libsundials_nvecparallel.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = kinFoodWeb_kry_bbd_p \
-	   kinFoodWeb_kry_p
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(MPICC) $(CPPFLAGS) $(MPI_FLAGS) $(SUNDIALS_INCS) -I$(MPI_INC_DIR) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(MPICC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}$(OBJ_EXT) $(MPI_FLAGS) $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) -L$(MPI_LIB_DIR) $(MPI_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/kinsol/parallel
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/kinsol/parallel/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/kinsol/parallel/README $(EXS_INSTDIR)/kinsol/parallel/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/parallel/$${i}.c   $(EXS_INSTDIR)/kinsol/parallel/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/parallel/$${i}.out $(EXS_INSTDIR)/kinsol/parallel/ ; \
-	done
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/kinsol/parallel/Makefile
-	rm -f $(EXS_INSTDIR)/kinsol/parallel/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/kinsol/parallel/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/kinsol/parallel/$${i}.out ; \
-	done
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol/parallel
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol
-
-clean:
-	rm -rf .libs
-	rm -f *.lo *.o
-	rm -f ${OBJECTS}
-	rm -f $(EXECS)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/examples/kinsol/parallel/README b/examples/kinsol/parallel/README
index eb18b72..f2d9bf4 100644
--- a/examples/kinsol/parallel/README
+++ b/examples/kinsol/parallel/README
@@ -3,14 +3,48 @@ List of parallel KINSOL examples
   kinFoodWeb_kry_bbd_p: 2-D food web system, BBD preconditioner
   kinFoodWeb_kry_p:     2-D food web system, block-diagonal preconditioner
 
-Sample results:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC)
-  MPI Implementation: Open MPI v1.1
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c b/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c
index 3401863..0543096 100644
--- a/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c
+++ b/examples/kinsol/parallel/kinFoodWeb_kry_bbd_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 23:09:24 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -187,7 +187,7 @@ static void BRecvPost(MPI_Comm comm, MPI_Request request[], int my_pe,
 static void BRecvWait(MPI_Request request[], int isubx,
                       int isuby, int dsizex, realtype *cext,
                       realtype *buffer);
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -370,7 +370,7 @@ static int ccomm(long int Nlocal, N_Vector cc, void *userdata)
   nsmysub = NUM_SPECIES*MYSUB;
   cext = data->cext;
 
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
 
   /* Start receiving boundary data from neighboring PEs */
   BRecvPost(comm, request, my_pe, isubx, isuby, nsmxsub, nsmysub, cext, buffer);
@@ -398,7 +398,7 @@ static int func_local(long int Nlocal, N_Vector cc, N_Vector fval, void *user_da
   UserData data;
   
   data = (UserData)user_data;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
   
   /* Get subgrid indices, data sizes, extended work array cext */
   isubx = data->isubx;   isuby = data->isuby;
@@ -705,15 +705,15 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
     printf("Linear solver is SPGMR with maxl = %d, maxlrst = %d\n",
            maxl, maxlrst);
     printf("Preconditioning uses band-block-diagonal matrix from KINBBDPRE\n");
-    printf("  Difference quotient half-bandwidths: mudq = %d, mldq = %d\n",
+    printf("  Difference quotient half-bandwidths: mudq = %ld, mldq = %ld\n",
 	   mudq, mldq);
-    printf("  Retained band block half-bandwidths: mukeep = %d, mlkeep = %d\n",
+    printf("  Retained band block half-bandwidths: mukeep = %ld, mlkeep = %ld\n",
 	   mukeep, mlkeep);
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
     printf("Tolerance parameters:  fnormtol = %Lg   scsteptol = %Lg\n",
            fnormtol, scsteptol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("Tolerance parameters:  fnormtol = %lg   scsteptol = %lg\n",
+    printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
            fnormtol, scsteptol);
 #else
     printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
@@ -725,7 +725,7 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
     printf("At all mesh points:  %Lg %Lg %Lg   %Lg %Lg %Lg\n",
            PREYIN,PREYIN,PREYIN, PREDIN,PREDIN,PREDIN);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("At all mesh points:  %lg %lg %lg   %lg %lg %lg\n",
+    printf("At all mesh points:  %g %g %g   %g %g %g\n",
            PREYIN,PREYIN,PREYIN, PREDIN,PREDIN,PREDIN);
 #else
     printf("At all mesh points:  %g %g %g   %g %g %g\n", PREYIN,PREYIN,PREYIN,
@@ -745,7 +745,7 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc)
   
   npelast = NPEX*NPEY - 1;
   
-  ct = NV_DATA_P(cc);
+  ct = N_VGetArrayPointer_Parallel(cc);
   
   /* Send the cc values (for all species) at the top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -769,7 +769,7 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
       printf(" %Lg",ct[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      printf(" %lg",ct[is]);
+      printf(" %g",ct[is]);
 #else
       printf(" %g",ct[is]);
 #endif
@@ -781,7 +781,7 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
       printf(" %Lg",tempc[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      printf(" %lg",tempc[is]);
+      printf(" %g",tempc[is]);
 #else
       printf(" %g",tempc[is]);
 #endif
@@ -974,7 +974,7 @@ static void BRecvWait(MPI_Request request[], int isubx,
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/kinsol/parallel/kinFoodWeb_kry_p.c b/examples/kinsol/parallel/kinFoodWeb_kry_p.c
index 35c4664..0cbe6fe 100644
--- a/examples/kinsol/parallel/kinFoodWeb_kry_p.c
+++ b/examples/kinsol/parallel/kinFoodWeb_kry_p.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 23:09:24 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -189,7 +189,7 @@ static void BRecvWait(MPI_Request request[], int isubx,
                       realtype *buffer);
 static void ccomm(realtype *cdata, UserData data);
 static void fcalcprpr(N_Vector cc, N_Vector fval,void *user_data);
-static int check_flag(void *flagvalue, char *funcname, int opt, int id);
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id);
 
 /*
  *--------------------------------------------------------------------
@@ -348,8 +348,8 @@ static int funcprpr(N_Vector cc, N_Vector fval, void *user_data)
   realtype *cdata, *fvdata;
   UserData data;
   
-  cdata = NV_DATA_P(cc);
-  fvdata = NV_DATA_P(fval);
+  cdata = N_VGetArrayPointer_Parallel(cc);
+  fvdata = N_VGetArrayPointer_Parallel(fval);
   data = (UserData) user_data;
   
   /* Call ccomm to do inter-processor communicaiton */
@@ -400,7 +400,7 @@ static int Precondbd(N_Vector cc, N_Vector cscale,
       for (j = 0; j < NUM_SPECIES; j++) {
         
         csave = cxy[j];  /* Save the j,jx,jy element of cc */
-        r = MAX(sqruround*ABS(csave), r0/scxy[j]);
+        r = SUNMAX(sqruround*SUNRabs(csave), r0/scxy[j]);
         cxy[j] += r; /* Perturb the j,jx,jy element of cc */
         fac = ONE/r;
         
@@ -550,7 +550,7 @@ static void InitUserData(int my_pe, MPI_Comm comm, UserData data)
   data->dx = (data->ax)/(MX-1);
   data->dy = (data->ay)/(MY-1);
   data->uround = UNIT_ROUNDOFF;
-  data->sqruround = SQRT(data->uround);
+  data->sqruround = SUNRsqrt(data->uround);
   data->my_pe = my_pe;
   data->comm = comm;
   data->isuby = my_pe/NPEX;
@@ -673,7 +673,7 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
   printf("Tolerance parameters:  fnormtol = %Lg   scsteptol = %Lg\n",
          fnormtol, scsteptol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  fnormtol = %lg   scsteptol = %lg\n",
+  printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
          fnormtol, scsteptol);
 #else
   printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
@@ -686,7 +686,7 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
          PREYIN,PREYIN,PREYIN,
          PREDIN,PREDIN,PREDIN);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At all mesh points:  %lg %lg %lg   %lg %lg %lg\n", 
+  printf("At all mesh points:  %g %g %g   %g %g %g\n", 
          PREYIN,PREYIN,PREYIN,
          PREDIN,PREDIN,PREDIN);
 #else
@@ -708,7 +708,7 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc)
 
   npelast = NPEX*NPEY - 1;
 
-  ct = NV_DATA_P(cc);
+  ct = N_VGetArrayPointer_Parallel(cc);
   
   /* Send the cc values (for all species) at the top right mesh point to PE 0 */
   if (my_pe == npelast) {
@@ -732,7 +732,7 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
       printf(" %Lg",ct[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      printf(" %lg",ct[is]);
+      printf(" %g",ct[is]);
 #else
       printf(" %g",ct[is]);
 #endif
@@ -744,7 +744,7 @@ static void PrintOutput(int my_pe, MPI_Comm comm, N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION) 
       printf(" %Lg",tempc[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      printf(" %lg",tempc[is]);
+      printf(" %g",tempc[is]);
 #else
       printf(" %g",tempc[is]);
 #endif
@@ -973,7 +973,7 @@ static void fcalcprpr(N_Vector cc, N_Vector fval, void *user_data)
   UserData data;
   
   data = (UserData)user_data;
-  cdata = NV_DATA_P(cc);
+  cdata = N_VGetArrayPointer_Parallel(cc);
 
   /* Get subgrid indices, data sizes, extended work array cext */
   isubx = data->isubx;   isuby = data->isuby;
@@ -1077,7 +1077,7 @@ static void fcalcprpr(N_Vector cc, N_Vector fval, void *user_data)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt, int id)
+static int check_flag(void *flagvalue, const char *funcname, int opt, int id)
 {
   int *errflag;
 
diff --git a/examples/kinsol/serial/CMakeLists.txt b/examples/kinsol/serial/CMakeLists.txt
index f32a4dd..1c0a39e 100644
--- a/examples/kinsol/serial/CMakeLists.txt
+++ b/examples/kinsol/serial/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.5 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4901 $
+# $Date: 2016-09-14 07:45:54 -0700 (Wed, 14 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for KINSOL serial examples
 
@@ -19,6 +24,8 @@ SET(KINSOL_examples
   kinFoodWeb_kry
   kinKrylovDemo_ls
   kinLaplace_bnd
+  kinLaplace_picard_bnd
+  kinRoberts_fp
   kinRoboKin_dns
   )
 
@@ -28,6 +35,14 @@ SET(KINSOL_examples
 SET(KINSOL_examples_BL
   )
 
+SET(KINSOL_examples_SUPERLUMT
+  kinRoboKin_slu
+  )
+
+SET(KINSOL_examples_KLU
+  kinFerTron_klu
+  )
+
 # Specify libraries to link against (through the target that was used to 
 # generate them) based on the value of the variable LINK_LIBRARY_TYPE
 
@@ -43,14 +58,23 @@ ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
 
 SET(SUNDIALS_LIBS ${KINSOL_LIB} ${NVECS_LIB} ${EXTRA_LINK_LIBS})
 IF(LAPACK_FOUND)
-  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}")
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_FOUND)
 
+IF(SUPERLUMT_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_FOUND)
+
+IF(KLU_FOUND)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_FOUND)
+
 # Add the build and install targets for each KINSOL example
 
 FOREACH(example ${KINSOL_examples})
   ADD_EXECUTABLE(${example} ${example}.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+  SUNDIALS_ADD_TEST(${example} ${example})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
   IF(EXAMPLES_INSTALL)
     INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/serial)
@@ -63,6 +87,8 @@ ENDFOREACH(example ${KINSOL_examples})
 IF(LAPACK_FOUND)
   FOREACH(example ${KINSOL_examples_BL})
     ADD_EXECUTABLE(${example} ${example}.c)    
+    SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+    SUNDIALS_ADD_TEST(${example} ${example})
     TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
     IF(EXAMPLES_INSTALL)
       INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/serial)
@@ -70,6 +96,33 @@ IF(LAPACK_FOUND)
   ENDFOREACH(example ${KINSOL_examples_BL})
 ENDIF(LAPACK_FOUND)
 
+# If SUPERLUMT support is enabled, add the build and install targets for
+# the examples using SUPERLUMT
+IF(SUPERLUMT_FOUND)
+  FOREACH(example ${KINSOL_examples_SUPERLUMT})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${KINSOL_examples_SUPERLUMT})
+ENDIF(SUPERLUMT_FOUND)
+
+# If KLU support is enabled, add the build and install targets for
+# the examples using KLU
+IF(KLU_FOUND)
+  FOREACH(example ${KINSOL_examples_KLU})
+    ADD_EXECUTABLE(${example} ${example}.c)
+    SUNDIALS_ADD_TEST(${example} ${example})
+    TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+    IF(EXAMPLES_INSTALL)
+      INSTALL(FILES ${example}.c ${example}.out DESTINATION ${EXAMPLES_INSTALL_PATH}/kinsol/serial)
+    ENDIF(EXAMPLES_INSTALL)
+  ENDFOREACH(example ${KINSOL_examples_KLU})
+ENDIF(KLU_FOUND)
+
+
 IF(EXAMPLES_INSTALL)
 
   # Install the README file
@@ -81,9 +134,20 @@ IF(EXAMPLES_INSTALL)
   LIST2STRING(KINSOL_examples EXAMPLES)
   IF(LAPACK_FOUND)
     LIST2STRING(KINSOL_examples_BL EXAMPLES_BL)
-  ELSE(LAPACK_FOUND)
+  ELSE()
     SET(EXAMPLES_BL "")
-  ENDIF(LAPACK_FOUND)
+  ENDIF()
+
+  IF(SUPERLUMT_FOUND)
+    LIST2STRING(KINSOL_examples_SUPERLUMT EXAMPLES)
+  ENDIF()
+
+  IF(KLU_FOUND)
+    LIST2STRING(KINSOL_examples_KLU EXAMPLES)
+  ENDIF()
+
+  STRING (REPLACE ";" " " TMP_STR ${EXAMPLES})
+  SET(EXAMPLES ${TMP_STR})
 
   # Regardless of the platform we're on, we will generate and install 
   # CMakeLists.txt file for building the examples. This file  can then 
diff --git a/examples/kinsol/serial/Makefile.in b/examples/kinsol/serial/Makefile.in
deleted file mode 100644
index daa6d4f..0000000
--- a/examples/kinsol/serial/Makefile.in
+++ /dev/null
@@ -1,133 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.11 $
-# $Date: 2009/02/17 02:58:47 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for KINSOL serial examples
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-top_builddir = @top_builddir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL      = @INSTALL@
-INSTALL_PROG = @INSTALL_PROGRAM@
-INSTALL_FILE = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-BLAS_LAPACK_LIBS = @BLAS_LAPACK_LIBS@
-
-OBJ_EXT = @OBJEXT@
-EXE_EXT = @EXEEXT@
-
-EXS_INSTDIR = @EXS_INSTDIR@
-
-top_srcdir = $(srcdir)/../../..
-
-SUNDIALS_INCS = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SUNDIALS_LIBS = $(top_builddir)/src/kinsol/libsundials_kinsol.la         \
-	        $(top_builddir)/src/nvec_ser/libsundials_nvecserial.la
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-EXAMPLES = kinFerTron_dns \
-	   kinFoodWeb_kry \
-	   kinKrylovDemo_ls \
-	   kinLaplace_bnd \
-	   kinRoboKin_dns
-
-EXAMPLES_BL =
-
-OBJECTS = ${EXAMPLES:=${OBJ_EXT}}
-OBJECTS_BL = ${EXAMPLES_BL:=${OBJ_EXT}}
-EXECS = ${EXAMPLES:=${EXE_EXT}}
-EXECS_BL = ${EXAMPLES_BL:=${EXE_EXT}}
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all:
-	@for i in ${EXAMPLES} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(SUNDIALS_INCS) $(CFLAGS) -c $(srcdir)/$${i}.c -o $${i}${OBJ_EXT} ; \
-	  $(LIBTOOL) --mode=link $(CC) -o $(builddir)/$${i}$(EXE_EXT) $(builddir)/$${i}${OBJ_EXT} $(CFLAGS) $(LDFLAGS) $(SUNDIALS_LIBS) $(LIBS) $(BLAS_LAPACK_LIBS) ; \
-	done ; \
-	fi
-
-install:
-	$(mkinstalldirs) $(EXS_INSTDIR)/kinsol/serial
-	$(INSTALL_FILE) Makefile_ex $(EXS_INSTDIR)/kinsol/serial/Makefile
-	$(INSTALL_FILE) $(top_srcdir)/examples/kinsol/serial/README $(EXS_INSTDIR)/kinsol/serial/
-	for i in ${EXAMPLES} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/serial/$${i}.c   $(EXS_INSTDIR)/kinsol/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/serial/$${i}.out $(EXS_INSTDIR)/kinsol/serial/ ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/serial/$${i}.c   $(EXS_INSTDIR)/kinsol/serial/ ; \
-	  $(INSTALL_FILE) $(top_srcdir)/examples/kinsol/serial/$${i}.out $(EXS_INSTDIR)/kinsol/serial/ ; \
-	done ; \
-	fi
-
-uninstall:
-	rm -f $(EXS_INSTDIR)/kinsol/serial/Makefile
-	rm -f $(EXS_INSTDIR)/kinsol/serial/README
-	for i in ${EXAMPLES} ; do \
-	  rm -f $(EXS_INSTDIR)/kinsol/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/kinsol/serial/$${i}.out ; \
-	done
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	for i in ${EXAMPLES_BL} ; do \
-	  rm -f $(EXS_INSTDIR)/kinsol/serial/$${i}.c ; \
-	  rm -f $(EXS_INSTDIR)/kinsol/serial/$${i}.out ; \
-	done ; \
-	fi
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol/serial
-	$(rminstalldirs) $(EXS_INSTDIR)/kinsol
-
-clean:
-	rm -rf .libs
-	rm -f *.lo
-	rm -f ${OBJECTS} ${OBJECTS_BL}
-	rm -f $(EXECS) $(EXECS_BL)
-
-distclean: clean
-	rm -f Makefile
-	rm -f Makefile_ex
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	${SHELL} ./config.status --recheck ; \
-	cd ${abs_builddir}
diff --git a/examples/kinsol/serial/README b/examples/kinsol/serial/README
index a8d4959..ae1b396 100644
--- a/examples/kinsol/serial/README
+++ b/examples/kinsol/serial/README
@@ -1,18 +1,56 @@
 List of serial KINSOL examples
 
-  kinFerTron_dns:   Ferraris-Tronconi example (DENSE)
-  kinFoodWeb_kry:   2-D food web system, block-diagonal preconditioner
-  kinKrylovDemo_ls: demonstration program with 3 Krylov solvers
-  kinLaplace_bnd:   2-D elliptic PDE (BAND)
-  kinRoboKin_dns:   Robot kinematics problem (DENSE)
+  kinFerTron_dns:          Ferraris-Tronconi example (DENSE)
+  kinFoodWeb_kry:          2-D food web system, block-diagonal preconditioner
+  kinKrylovDemo_ls:        demonstration program with 3 Krylov solvers
+  kinLaplace_bnd:          2-D elliptic PDE (BAND)
+  kinLaplace_picard_bnd:   2-D elliptic PDE (Accelerated Picard solver, BAND)
+  kinRoberts_fp:           3-eqn chemical kinetics, accelerated fixed point
+  kinRoboKin_dns:          Robot kinematics problem (DENSE)
+  kinRoboKin_slu:          Robot problem with SuperLUMT sparse linear solver
 
-Sample result:
 
-  SUNDIALS was built with the following options:
+The following CMake command was used to configure SUNDIALS:
 
-  ./configure CC=gcc F77=gfortran CFLAGS="-g3 -O0" FFLAGS="-g3 -O0" --enable-examples
+ cmake \
+-DCMAKE_BUILD_TYPE=DEBUG \
+-DCXX_ENABLE=ON \
+-DBUILD_ARKODE=ON \
+-DBUILD_CVODE=ON \
+-DBUILD_CVODES=ON \
+-DBUILD_IDA=ON \
+-DBUILD_IDAS=ON \
+-DBUILD_KINSOL=ON \
+-DCMAKE_INSTALL_PREFIX=/home/user1/sundials/build/install \
+-DEXAMPLES_INSTALL_PATH=/home/user1/sundials/build/install/examples \
+-DBUILD_SHARED_LIBS=OFF \
+-DBUILD_STATIC_LIBS=ON \
+-DEXAMPLES_ENABLE=ON \
+-DEXAMPLES_INSTALL=ON \
+-DMPI_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DLAPACK_ENABLE=ON \
+-DKLU_ENABLE=ON \
+-DKLU_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/include \
+-DKLU_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/suitesparse/4.5.3/lib \
+-DHYPRE_ENABLE=ON \
+-DHYPRE_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/hypre/2.11.1/include \
+-DHYPRE_LIBRARY=/usr/casc/sundials/apps/rh6/hypre/2.11.1/lib/libHYPRE.a \
+-DOPENMP_ENABLE=ON \
+-DPTHREAD_ENABLE=ON \
+-DFCMIX_ENABLE=ON \
+-DF90_ENABLE=ON \
+-DSUPERLUMT_ENABLE=ON \
+-DSUPERLUMT_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/SRC \
+-DSUPERLUMT_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/superlu_mt/SuperLU_MT_3.1/lib \
+-DSUPERLUMT_THREAD_TYPE=Pthread \
+-DPETSC_ENABLE=ON \
+-DPETSC_INCLUDE_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/include \
+-DPETSC_LIBRARY_DIR=/usr/casc/sundials/apps/rh6/petsc/3.7.2/lib \
+../sundials
 
-  System Architecture: IA-32
-  Processor Type: Intel Pentium 4 Xeon DP (i686)
-  Operating System: Red Hat Enterprise Linux WS 3 (Taroon Update 7)
-  C/Fortran Compilers: gcc/gfortran v4.1.0 (GCC)
+  System Architecture: x86_64
+  Processor Type: Intel(R) Xeon(R) CPU E31230 @ 3.20GHz
+  Operating System: Red Hat 6.8
+  C/Fortran Compilers: gcc/gfortran v4.4.7
+  MPI: Open MPI v1.8.8
diff --git a/examples/kinsol/serial/kinFerTron_dns.c b/examples/kinsol/serial/kinFerTron_dns.c
index 3ea57bc..1a3c3c3 100644
--- a/examples/kinsol/serial/kinFerTron_dns.c
+++ b/examples/kinsol/serial/kinFerTron_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2008/12/17 19:38:48 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -87,11 +87,10 @@ static int func(N_Vector u, N_Vector f, void *user_data);
 static void SetInitialGuess1(N_Vector u, UserData data);
 static void SetInitialGuess2(N_Vector u, UserData data);
 static int SolveIt(void *kmem, N_Vector u, N_Vector s, int glstr, int mset);
-static void PrintHeader(int globalstrategy, realtype fnormtol,
-                        realtype scsteptol);
+static void PrintHeader(realtype fnormtol, realtype scsteptol);
 static void PrintOutput(N_Vector u);
 static void PrintFinalStats(void *kmem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -111,7 +110,6 @@ int main()
   s = c = NULL;
   kmem = NULL;
   data = NULL;
-  glstr = KIN_NONE;
 
   /* User data */
 
@@ -171,7 +169,7 @@ int main()
   if (check_flag(&flag, "KINDense", 1)) return(1);
 
   /* Print out the problem size, solution parameters, initial guess. */
-  PrintHeader(glstr, fnormtol, scsteptol);
+  PrintHeader(fnormtol, scsteptol);
 
   /* --------------------------- */
 
@@ -309,8 +307,8 @@ static int func(N_Vector u, N_Vector f, void *user_data)
   lb = data->lb;
   ub = data->ub;
 
-  udata = NV_DATA_S(u);
-  fdata = NV_DATA_S(f);
+  udata = N_VGetArrayPointer_Serial(u);
+  fdata = N_VGetArrayPointer_Serial(f);
 
   x1 = udata[0];
   x2 = udata[1];
@@ -320,7 +318,7 @@ static int func(N_Vector u, N_Vector f, void *user_data)
   L2 = udata[5];
 
   fdata[0] = PT5 * sin(x1*x2) - PT25 * x2 / PI - PT5 * x1;
-  fdata[1] = (ONE - PT25/PI)*(EXP(TWO*x1)-E) + E*x2/PI - TWO*E*x1;
+  fdata[1] = (ONE - PT25/PI)*(SUNRexp(TWO*x1)-E) + E*x2/PI - TWO*E*x1;
   fdata[2] = l1 - x1 + lb[0];
   fdata[3] = L1 - x1 + ub[0];
   fdata[4] = l2 - x2 + lb[1];
@@ -345,7 +343,7 @@ static void SetInitialGuess1(N_Vector u, UserData data)
   realtype *udata;
   realtype *lb, *ub;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   lb = data->lb;
   ub = data->ub;
@@ -370,7 +368,7 @@ static void SetInitialGuess2(N_Vector u, UserData data)
   realtype *udata;
   realtype *lb, *ub;
 
-  udata = NV_DATA_S(u);
+  udata = N_VGetArrayPointer_Serial(u);
 
   lb = data->lb;
   ub = data->ub;
@@ -393,8 +391,7 @@ static void SetInitialGuess2(N_Vector u, UserData data)
  * Print first lines of output (problem description)
  */
 
-static void PrintHeader(int globalstrategy, realtype fnormtol,
-                        realtype scsteptol)
+static void PrintHeader(realtype fnormtol, realtype scsteptol)
 {
   printf("\nFerraris and Tronconi test problem\n");
   printf("Tolerance parameters:\n");
@@ -402,7 +399,7 @@ static void PrintHeader(int globalstrategy, realtype fnormtol,
   printf("  fnormtol  = %10.6Lg\n  scsteptol = %10.6Lg\n",
          fnormtol, scsteptol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("  fnormtol  = %10.6lg\n  scsteptol = %10.6lg\n",
+  printf("  fnormtol  = %10.6g\n  scsteptol = %10.6g\n",
          fnormtol, scsteptol);
 #else
   printf("  fnormtol  = %10.6g\n  scsteptol = %10.6g\n",
@@ -419,7 +416,7 @@ static void PrintOutput(N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf(" %8.6Lg  %8.6Lg\n", Ith(u,1), Ith(u,2));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %8.6lg  %8.6lg\n", Ith(u,1), Ith(u,2));
+    printf(" %8.6g  %8.6g\n", Ith(u,1), Ith(u,2));
 #else
     printf(" %8.6g  %8.6g\n", Ith(u,1), Ith(u,2));
 #endif
@@ -459,7 +456,7 @@ static void PrintFinalStats(void *kmem)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/kinsol/serial/kinFerTron_klu.c b/examples/kinsol/serial/kinFerTron_klu.c
new file mode 100644
index 0000000..2d8bc06
--- /dev/null
+++ b/examples/kinsol/serial/kinFerTron_klu.c
@@ -0,0 +1,623 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4552 $
+ * $Date: 2015-07-29 10:12:20 -0700 (Wed, 29 Jul 2015) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * Example (serial):
+ *
+ * This example solves a nonlinear system from.
+ *
+ * Source: "Handbook of Test Problems in Local and Global Optimization",
+ *             C.A. Floudas, P.M. Pardalos et al.
+ *             Kluwer Academic Publishers, 1999.
+ * Test problem 4 from Section 14.1, Chapter 14: Ferraris and Tronconi
+ * 
+ * This problem involves a blend of trigonometric and exponential terms.
+ *    0.5 sin(x1 x2) - 0.25 x2/pi - 0.5 x1 = 0
+ *    (1-0.25/pi) ( exp(2 x1)-e ) + e x2 / pi - 2 e x1 = 0
+ * such that
+ *    0.25 <= x1 <=1.0
+ *    1.5 <= x2 <= 2 pi
+ * 
+ * The treatment of the bound constraints on x1 and x2 is done using
+ * the additional variables
+ *    l1 = x1 - x1_min >= 0
+ *    L1 = x1 - x1_max <= 0
+ *    l2 = x2 - x2_min >= 0
+ *    L2 = x2 - x2_max >= 0
+ * 
+ * and using the constraint feature in KINSOL to impose
+ *    l1 >= 0    l2 >= 0
+ *    L1 <= 0    L2 <= 0
+ * 
+ * The Ferraris-Tronconi test problem has two known solutions.
+ * The nonlinear system is solved by KINSOL using different 
+ * combinations of globalization and Jacobian update strategies 
+ * and with different initial guesses (leading to one or the other
+ * of the known solutions).
+ *
+ *
+ * Constraints are imposed to make all components of the solution
+ * positive.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <kinsol/kinsol.h>
+#include <kinsol/kinsol_klu.h>
+#include <kinsol/kinsol_dense.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+#define NVAR   2
+#define NEQ    3*NVAR
+
+#define FTOL   RCONST(1.e-5) /* function tolerance */
+#define STOL   RCONST(1.e-5) /* step tolerance     */
+
+#define ZERO   RCONST(0.0)
+#define PT25   RCONST(0.25)
+#define PT5    RCONST(0.5)
+#define ONE    RCONST(1.0)
+#define ONEPT5 RCONST(1.5)
+#define TWO    RCONST(2.0)
+
+#define PI     RCONST(3.1415926)
+#define E      RCONST(2.7182818)
+
+typedef struct {
+  realtype lb[NVAR];
+  realtype ub[NVAR];
+  int nnz;
+} *UserData;
+
+/* Functions Called by the KINSOL Solver */
+static int func(N_Vector u, N_Vector f, void *user_data);
+static int jac(N_Vector y, N_Vector f, SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2);
+static int jacDense(long int N,
+                    N_Vector y, N_Vector f,
+                    DlsMat J, void *user_data,
+                    N_Vector tmp1, N_Vector tmp2);
+
+/* Private Helper Functions */
+static void SetInitialGuess1(N_Vector u, UserData data);
+static void SetInitialGuess2(N_Vector u, UserData data);
+static int SolveIt(void *kmem, N_Vector u, N_Vector s, int glstr, int mset);
+static void PrintHeader(realtype fnormtol, realtype scsteptol);
+static void PrintOutput(N_Vector u);
+static void PrintFinalStats(void *kmem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main()
+{
+  UserData data;
+  realtype fnormtol, scsteptol;
+  N_Vector u1, u2, u, s, c;
+  int glstr, mset, flag;
+  void *kmem;
+
+  u1 = u2 = u = NULL;
+  s = c = NULL;
+  kmem = NULL;
+  data = NULL;
+
+  /* User data */
+
+  data = (UserData)malloc(sizeof *data);
+  data->lb[0] = PT25;       data->ub[0] = ONE;
+  data->lb[1] = ONEPT5;     data->ub[1] = TWO*PI;
+  data->nnz = 12;
+
+  /* Create serial vectors of length NEQ */
+  u1 = N_VNew_Serial(NEQ);
+  if (check_flag((void *)u1, "N_VNew_Serial", 0)) return(1);
+
+  u2 = N_VNew_Serial(NEQ);
+  if (check_flag((void *)u2, "N_VNew_Serial", 0)) return(1);
+
+  u = N_VNew_Serial(NEQ);
+  if (check_flag((void *)u, "N_VNew_Serial", 0)) return(1);
+
+  s = N_VNew_Serial(NEQ);
+  if (check_flag((void *)s, "N_VNew_Serial", 0)) return(1);
+
+  c = N_VNew_Serial(NEQ);
+  if (check_flag((void *)c, "N_VNew_Serial", 0)) return(1);
+
+  SetInitialGuess1(u1,data);
+  SetInitialGuess2(u2,data);
+
+  N_VConst_Serial(ONE,s); /* no scaling */
+
+  NV_Ith_S(c,0) =  ZERO;   /* no constraint on x1 */
+  NV_Ith_S(c,1) =  ZERO;   /* no constraint on x2 */
+  NV_Ith_S(c,2) =  ONE;    /* l1 = x1 - x1_min >= 0  */
+  NV_Ith_S(c,3) = -ONE;    /* L1 = x1 - x1_max <= 0  */
+  NV_Ith_S(c,4) =  ONE;    /* l2 = x2 - x2_min >= 0  */
+  NV_Ith_S(c,5) = -ONE;    /* L2 = x2 - x22_min <= 0 */
+  
+  fnormtol=FTOL; scsteptol=STOL;
+
+
+  kmem = KINCreate();
+  if (check_flag((void *)kmem, "KINCreate", 0)) return(1);
+
+  flag = KINSetUserData(kmem, data);
+  if (check_flag(&flag, "KINSetUserData", 1)) return(1);
+  flag = KINSetConstraints(kmem, c);
+  if (check_flag(&flag, "KINSetConstraints", 1)) return(1);
+  flag = KINSetFuncNormTol(kmem, fnormtol);
+  if (check_flag(&flag, "KINSetFuncNormTol", 1)) return(1);
+  flag = KINSetScaledStepTol(kmem, scsteptol);
+  if (check_flag(&flag, "KINSetScaledStepTol", 1)) return(1);
+
+  flag = KINInit(kmem, func, u);
+  if (check_flag(&flag, "KINInit", 1)) return(1);
+
+  /* Call KINDense to specify the linear solver */
+/*   
+ * flag = KINDense(kmem, NEQ); // <-- Replace with KINKLU
+ * if (check_flag(&flag, "KINDense", 1)) return(1);
+ * flag = KINDlsSetDenseJacFn(kmem, jacDense);
+ * if (check_flag(&flag, "KINDlsSetDenseJacFn", 1)) return(1);
+ */
+
+  /* Attach KLU linear solver, which uses CSR matrix */
+  flag = KINKLU(kmem, NEQ, data->nnz, CSR_MAT);
+  if (check_flag(&flag, "KINKLU", 1)) return(1);
+
+  flag = KINSlsSetSparseJacFn(kmem, jac);
+  if (check_flag(&flag, "KINSlsSetSparseJacFn", 1)) return(1);
+
+  /* Print out the problem size, solution parameters, initial guess. */
+  PrintHeader(fnormtol, scsteptol);
+
+  /* --------------------------- */
+
+  printf("\n------------------------------------------\n");
+  printf("\nInitial guess on lower bounds\n");
+  printf("  [x1,x2] = ");
+  PrintOutput(u1);
+
+  N_VScale_Serial(ONE,u1,u);
+  glstr = KIN_NONE;
+  mset = 1;
+  SolveIt(kmem, u, s, glstr, mset);
+
+  /* --------------------------- */
+
+  N_VScale_Serial(ONE,u1,u);
+  glstr = KIN_LINESEARCH;
+  mset = 1;
+  SolveIt(kmem, u, s, glstr, mset);
+
+  /* --------------------------- */
+
+  N_VScale_Serial(ONE,u1,u);
+  glstr = KIN_NONE;
+  mset = 0;
+  SolveIt(kmem, u, s, glstr, mset);
+
+  /* --------------------------- */
+
+  N_VScale_Serial(ONE,u1,u);
+  glstr = KIN_LINESEARCH;
+  mset = 0;
+  SolveIt(kmem, u, s, glstr, mset);
+
+
+
+  /* --------------------------- */
+
+  printf("\n------------------------------------------\n");
+  printf("\nInitial guess in middle of feasible region\n");
+  printf("  [x1,x2] = ");
+  PrintOutput(u2);
+
+  N_VScale_Serial(ONE,u2,u);
+  glstr = KIN_NONE;
+  mset = 1;
+  SolveIt(kmem, u, s, glstr, mset);
+
+  /* --------------------------- */
+
+  N_VScale_Serial(ONE,u2,u);
+  glstr = KIN_LINESEARCH;
+  mset = 1;
+  SolveIt(kmem, u, s, glstr, mset);
+
+  /* --------------------------- */
+
+  N_VScale_Serial(ONE,u2,u);
+  glstr = KIN_NONE;
+  mset = 0;
+  SolveIt(kmem, u, s, glstr, mset);
+
+  /* --------------------------- */
+
+  N_VScale_Serial(ONE,u2,u);
+  glstr = KIN_LINESEARCH;
+  mset = 0;
+  SolveIt(kmem, u, s, glstr, mset);
+
+
+
+
+  /* Free memory */
+
+  N_VDestroy_Serial(u1);
+  N_VDestroy_Serial(u2);
+  N_VDestroy_Serial(u);
+  N_VDestroy_Serial(s);
+  N_VDestroy_Serial(c);
+  KINFree(&kmem);
+  free(data);
+
+  return(0);
+}
+
+
+static int SolveIt(void *kmem, N_Vector u, N_Vector s, int glstr, int mset)
+{
+  int flag;
+
+  printf("\n");
+
+  if (mset==1)
+    printf("Exact Newton");
+  else
+    printf("Modified Newton");
+
+  if (glstr == KIN_NONE)
+    printf("\n");
+  else
+    printf(" with line search\n");
+
+  flag = KINSetMaxSetupCalls(kmem, mset);
+  if (check_flag(&flag, "KINSetMaxSetupCalls", 1)) return(1);
+
+  flag = KINSol(kmem, u, glstr, s, s);
+  if (check_flag(&flag, "KINSol", 1)) return(1);
+
+  printf("Solution:\n  [x1,x2] = ");
+  PrintOutput(u);
+
+  PrintFinalStats(kmem);
+
+  return(0);
+
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * FUNCTIONS CALLED BY KINSOL
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * System function for predator-prey system 
+ */
+
+static int func(N_Vector u, N_Vector f, void *user_data)
+{
+  realtype *udata, *fdata;
+  realtype x1, l1, L1, x2, l2, L2;
+  realtype *lb, *ub;
+  UserData params;
+  
+  params = (UserData)user_data;
+  lb = params->lb;
+  ub = params->ub;
+
+  udata = N_VGetArrayPointer_Serial(u);
+  fdata = N_VGetArrayPointer_Serial(f);
+
+  x1 = udata[0];
+  x2 = udata[1];
+  l1 = udata[2];
+  L1 = udata[3];
+  l2 = udata[4];
+  L2 = udata[5];
+
+  fdata[0] = PT5 * sin(x1*x2) - PT25 * x2 / PI - PT5 * x1;
+  fdata[1] = (ONE - PT25/PI)*(SUNRexp(TWO*x1)-E) + E*x2/PI - TWO*E*x1;
+  fdata[2] = l1 - x1 + lb[0];
+  fdata[3] = L1 - x1 + ub[0];
+  fdata[4] = l2 - x2 + lb[1];
+  fdata[5] = L2 - x2 + ub[1];
+
+  return(0);
+}
+
+
+/*
+ * System Jacobian
+ */
+
+static int jac(N_Vector y, N_Vector f,
+               SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2)
+{
+  realtype *yd;
+  int *rowptrs;
+  int *colvals;
+  realtype *data;
+  
+  yd = N_VGetArrayPointer_Serial(y);
+  rowptrs = (*J->rowptrs);
+  colvals = (*J->colvals);
+  data    = J->data;
+  
+  SparseSetMatToZero(J);
+
+  rowptrs[0] =  0;
+  rowptrs[1] =  2;
+  rowptrs[2] =  4;
+  rowptrs[3] =  6;
+  rowptrs[4] =  8;
+  rowptrs[5] = 10;
+  rowptrs[6] = 12;
+
+  /* row 0 */
+  data[0] = PT5 * cos(yd[0]*yd[1]) * yd[1] - PT5;
+  colvals[0] = 0;
+  data[1] = PT5 * cos(yd[0]*yd[1]) * yd[0] - PT25/PI;
+  colvals[1] = 1;
+
+  /* row 1 */
+  data[2] = TWO * (ONE - PT25/PI) * (SUNRexp(TWO*yd[0]) - E);
+  colvals[2] = 0;
+  data[3] = E/PI;
+  colvals[3] = 1;
+  
+  /* row 2 */
+  data[4] = -ONE;
+  colvals[4] = 0;
+  data[5] =  ONE;
+  colvals[5] = 2;
+  
+  /* row 3 */
+  data[6] = -ONE;
+  colvals[6] = 0;
+  data[7] =  ONE;
+  colvals[7] = 3;
+  
+  /* row 4 */
+  data[8] = -ONE;
+  colvals[8] = 1;
+  data[9] =  ONE;
+  colvals[9] = 4;
+  
+  /* row 5 */
+  data[10] = -ONE;
+  colvals[10] = 1;
+  data[11] =  ONE;
+  colvals[11] = 5;
+  
+  return(0);
+
+}
+
+
+/*
+ * System dense Jacobian
+ */
+
+static int jacDense(long int N,
+                    N_Vector y, N_Vector f,
+                    DlsMat J, void *user_data,
+                    N_Vector tmp1, N_Vector tmp2)
+{
+  realtype *yd;
+
+  yd = N_VGetArrayPointer_Serial(y);
+
+  /* row 0 */
+  DENSE_ELEM(J,0,0) = PT5 * cos(yd[0]*yd[1]) * yd[1] - PT5;
+  DENSE_ELEM(J,0,1) = PT5 * cos(yd[0]*yd[1]) * yd[0] - PT25/PI;
+
+  /* row 1 */
+  DENSE_ELEM(J,1,0) = TWO * (ONE - PT25/PI) * (SUNRexp(TWO*yd[0]) - E);
+  DENSE_ELEM(J,1,1) = E/PI;
+  
+  /* row 2 */
+  DENSE_ELEM(J,2,0) = -ONE;
+  DENSE_ELEM(J,2,2) =  ONE;
+  
+  /* row 3 */
+  DENSE_ELEM(J,3,0) = -ONE;
+  DENSE_ELEM(J,3,3) =  ONE;
+  
+  /* row 4 */
+  DENSE_ELEM(J,4,1) = -ONE;
+  DENSE_ELEM(J,4,4) =  ONE;
+  
+  /* row 5 */
+  DENSE_ELEM(J,5,1) = -ONE;
+  DENSE_ELEM(J,5,5) =  ONE;
+  
+
+  return(0);
+}
+
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/*
+ * Initial guesses
+ */
+
+static void SetInitialGuess1(N_Vector u, UserData data)
+{
+  realtype x1, x2;
+  realtype *udata;
+  realtype *lb, *ub;
+
+  udata = N_VGetArrayPointer_Serial(u);
+
+  lb = data->lb;
+  ub = data->ub;
+
+  /* There are two known solutions for this problem */
+
+  /* this init. guess should take us to (0.29945; 2.83693) */
+  x1 = lb[0];
+  x2 = lb[1];
+
+  udata[0] = x1;
+  udata[1] = x2;
+  udata[2] = x1 - lb[0];
+  udata[3] = x1 - ub[0];
+  udata[4] = x2 - lb[1];
+  udata[5] = x2 - ub[1];
+}
+
+static void SetInitialGuess2(N_Vector u, UserData data)
+{
+  realtype x1, x2;
+  realtype *udata;
+  realtype *lb, *ub;
+
+  udata = N_VGetArrayPointer_Serial(u);
+
+  lb = data->lb;
+  ub = data->ub;
+
+  /* There are two known solutions for this problem */
+
+  /* this init. guess should take us to (0.5; 3.1415926) */
+  x1 = PT5 * (lb[0] + ub[0]);
+  x2 = PT5 * (lb[1] + ub[1]);
+
+  udata[0] = x1;
+  udata[1] = x2;
+  udata[2] = x1 - lb[0];
+  udata[3] = x1 - ub[0];
+  udata[4] = x2 - lb[1];
+  udata[5] = x2 - ub[1];
+}
+
+/* 
+ * Print first lines of output (problem description)
+ */
+
+static void PrintHeader(realtype fnormtol, realtype scsteptol)
+{
+  printf("\nFerraris and Tronconi test problem\n");
+  printf("Tolerance parameters:\n");
+#if defined(SUNDIALS_EXTENDED_PRECISION) 
+  printf("  fnormtol  = %10.6Lg\n  scsteptol = %10.6Lg\n",
+         fnormtol, scsteptol);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("  fnormtol  = %10.6g\n  scsteptol = %10.6g\n",
+         fnormtol, scsteptol);
+#else
+  printf("  fnormtol  = %10.6g\n  scsteptol = %10.6g\n",
+         fnormtol, scsteptol);
+#endif
+}
+
+/* 
+ * Print solution
+ */
+
+static void PrintOutput(N_Vector u)
+{
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf(" %8.6Lg  %8.6Lg\n", NV_Ith_S(u,0), NV_Ith_S(u,1));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf(" %8.6g  %8.6g\n", NV_Ith_S(u,0), NV_Ith_S(u,1));
+#else
+    printf(" %8.6g  %8.6g\n", NV_Ith_S(u,0), NV_Ith_S(u,1));
+#endif
+}
+
+/* 
+ * Print final statistics contained in iopt 
+ */
+
+static void PrintFinalStats(void *kmem)
+{
+  long int nni, nfe, nje, nfeD;
+  int flag;
+  
+  flag = KINGetNumNonlinSolvIters(kmem, &nni);
+  check_flag(&flag, "KINGetNumNonlinSolvIters", 1);
+  flag = KINGetNumFuncEvals(kmem, &nfe);
+  check_flag(&flag, "KINGetNumFuncEvals", 1);
+
+/*   flag = KINDlsGetNumJacEvals(kmem, &nje);
+ *   check_flag(&flag, "KINDlsGetNumJacEvals", 1);
+ */
+
+  flag = KINSlsGetNumJacEvals(kmem, &nje);
+  check_flag(&flag, "KINSlsGetNumJacEvals", 1);
+  
+  printf("Final Statistics:\n");
+  printf("  nni = %5ld    nfe  = %5ld \n", nni, nfe);
+  printf("  nje = %5ld    \n", nje);
+}
+
+/*
+ * Check function return value...
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1);
+  }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr,
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+              funcname, *errflag);
+      return(1); 
+    }
+  }
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr,
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+            funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/kinsol/serial/kinFerTron_klu.out b/examples/kinsol/serial/kinFerTron_klu.out
new file mode 100644
index 0000000..df23733
--- /dev/null
+++ b/examples/kinsol/serial/kinFerTron_klu.out
@@ -0,0 +1,71 @@
+
+Ferraris and Tronconi test problem
+Tolerance parameters:
+  fnormtol  =      1e-05
+  scsteptol =      1e-05
+
+------------------------------------------
+
+Initial guess on lower bounds
+  [x1,x2] =      0.25       1.5
+
+Exact Newton
+Solution:
+  [x1,x2] =  0.299448   2.83693
+Final Statistics:
+  nni =     4    nfe  =     5 
+  nje =     4    
+
+Exact Newton with line search
+Solution:
+  [x1,x2] =  0.299448   2.83693
+Final Statistics:
+  nni =     4    nfe  =     5 
+  nje =     4    
+
+Modified Newton
+Solution:
+  [x1,x2] =  0.299448   2.83693
+Final Statistics:
+  nni =    12    nfe  =    13 
+  nje =     2    
+
+Modified Newton with line search
+Solution:
+  [x1,x2] =  0.299448   2.83693
+Final Statistics:
+  nni =    12    nfe  =    13 
+  nje =     2    
+
+------------------------------------------
+
+Initial guess in middle of feasible region
+  [x1,x2] =     0.625   3.89159
+
+Exact Newton
+Solution:
+  [x1,x2] =  0.499999    3.1416
+Final Statistics:
+  nni =     6    nfe  =     7 
+  nje =     6    
+
+Exact Newton with line search
+Solution:
+  [x1,x2] =  0.500001   3.14159
+Final Statistics:
+  nni =     6    nfe  =     8 
+  nje =     6    
+
+Modified Newton
+Solution:
+  [x1,x2] =       0.5   3.14159
+Final Statistics:
+  nni =    14    nfe  =    15 
+  nje =     2    
+
+Modified Newton with line search
+Solution:
+  [x1,x2] =       0.5   3.14159
+Final Statistics:
+  nni =    14    nfe  =    15 
+  nje =     2    
diff --git a/examples/kinsol/serial/kinFoodWeb_kry.c b/examples/kinsol/serial/kinFoodWeb_kry.c
index c64018a..b6151ea 100644
--- a/examples/kinsol/serial/kinFoodWeb_kry.c
+++ b/examples/kinsol/serial/kinFoodWeb_kry.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2010/12/01 23:08:49 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
@@ -167,7 +167,7 @@ static void PrintFinalStats(void *kmem);
 static void WebRate(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
                     void *user_data);
 static realtype DotProd(long int size, realtype *x1, realtype *x2);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -253,7 +253,7 @@ int main(void)
   /* Call KINSol and print output concentration profile */
   flag = KINSol(kmem,           /* KINSol memory block */
                 cc,             /* initial guess on input; solution vector */
-                globalstrategy, /* global stragegy choice */
+                globalstrategy, /* global strategy choice */
                 sc,             /* scaling vector, for the variable cc */
                 sc);            /* scaling vector for function values fval */
   if (check_flag(&flag, "KINSol", 1)) return(1);
@@ -385,7 +385,7 @@ static int PrecSetupBD(N_Vector cc, N_Vector cscale,
       for (j = 0; j < NUM_SPECIES; j++) {
         
         csave = cxy[j];  /* Save the j,jx,jy element of cc */
-        r = MAX(sqruround*ABS(csave), r0/scxy[j]);
+        r = SUNMAX(sqruround*SUNRabs(csave), r0/scxy[j]);
         cxy[j] += r; /* Perturb the j,jx,jy element of cc */
         fac = ONE/r;
         
@@ -534,7 +534,7 @@ static void InitUserData(UserData data)
   data->dx = (data->ax)/(MX-1);
   data->dy = (data->ay)/(MY-1);
   data->uround = UNIT_ROUNDOFF;
-  data->sqruround = SQRT(data->uround);
+  data->sqruround = SUNRsqrt(data->uround);
 
   /* Set up the coefficients a and b plus others found in the equations */
   np = data->np;
@@ -647,7 +647,7 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
   printf("Tolerance parameters:  fnormtol = %Lg   scsteptol = %Lg\n",
          fnormtol, scsteptol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  fnormtol = %lg   scsteptol = %lg\n",
+  printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
          fnormtol, scsteptol);
 #else
   printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
@@ -660,7 +660,7 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
          PREYIN, PREYIN, PREYIN,
          PREDIN, PREDIN, PREDIN);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At all mesh points:  %lg %lg %lg   %lg %lg %lg\n", 
+  printf("At all mesh points:  %g %g %g   %g %g %g\n", 
          PREYIN, PREYIN, PREYIN,
          PREDIN, PREDIN, PREDIN);
 #else
@@ -689,7 +689,7 @@ static void PrintOutput(N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf(" %Lg",ct[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %lg",ct[is]);
+    printf(" %g",ct[is]);
 #else
     printf(" %g",ct[is]);
 #endif
@@ -705,7 +705,7 @@ static void PrintOutput(N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf(" %Lg",ct[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %lg",ct[is]);
+    printf(" %g",ct[is]);
 #else
     printf(" %g",ct[is]);
 #endif
@@ -754,7 +754,7 @@ static void PrintFinalStats(void *kmem)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/kinsol/serial/kinKrylovDemo_ls.c b/examples/kinsol/serial/kinKrylovDemo_ls.c
index 6d465f0..d446e05 100644
--- a/examples/kinsol/serial/kinKrylovDemo_ls.c
+++ b/examples/kinsol/serial/kinKrylovDemo_ls.c
@@ -1,14 +1,14 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 23:08:49 $
+ * $Revision: 4840 $
+ * $Date: 2016-08-03 13:07:16 -0700 (Wed, 03 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
  *
  * This example loops through the available iterative linear solvers:
- * SPGMR, SPBCG and SPTFQMR.
+ * SPGMR, SPBCG, SPTFQMR, and SPFGMR.
  *
  * Example (serial):
  *
@@ -89,6 +89,7 @@
 #include <kinsol/kinsol_spgmr.h>
 #include <kinsol/kinsol_spbcgs.h>
 #include <kinsol/kinsol_sptfqmr.h>
+#include <kinsol/kinsol_spfgmr.h>
 #include <nvector/nvector_serial.h>
 #include <sundials/sundials_dense.h>
 #include <sundials/sundials_types.h>
@@ -128,6 +129,7 @@
 #define USE_SPGMR   0
 #define USE_SPBCG   1
 #define USE_SPTFQMR 2
+#define USE_SPFGMR  3
 
 /* User-defined vector access macro: IJ_Vptr */
 
@@ -180,7 +182,7 @@ static void PrintFinalStats(void *kmem, int linsolver);
 static void WebRate(realtype xx, realtype yy, realtype *cxy, realtype *ratesxy, 
                     void *user_data);
 static realtype DotProd(int size, realtype *x1, realtype *x2);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -220,37 +222,31 @@ int main(void)
   if (check_flag((void *)constraints, "N_VNew_Serial", 0)) return(1);
   N_VConst(TWO, constraints);
 
-  SetInitialProfiles(cc, sc);
-
   fnormtol=FTOL; scsteptol=STOL;
 
-  /* Call KINCreate/KINInit to initialize KINSOL: 
-     nvSpec is the nvSpec pointer used in the serial version
-     A pointer to KINSOL problem memory is returned and stored in kmem. */
-  kmem = KINCreate();
-  if (check_flag((void *)kmem, "KINCreate", 0)) return(1);
-  /* Vector cc passed as template vector. */
-  flag = KINInit(kmem, func, cc);
-  if (check_flag(&flag, "KINInit", 1)) return(1);
-
-  flag = KINSetUserData(kmem, data);
-  if (check_flag(&flag, "KINSetUserData", 1)) return(1);
-  flag = KINSetConstraints(kmem, constraints);
-  if (check_flag(&flag, "KINSetConstraints", 1)) return(1);
-  flag = KINSetFuncNormTol(kmem, fnormtol);
-  if (check_flag(&flag, "KINSetFuncNormTol", 1)) return(1);
-  flag = KINSetScaledStepTol(kmem, scsteptol);
-  if (check_flag(&flag, "KINSetScaledStepTol", 1)) return(1);
-
-  /* We no longer need the constraints vector since KINSetConstraints
-     creates a private copy for KINSOL to use. */
-  N_VDestroy_Serial(constraints);
+  /* START: Loop through SPGMR, SPBCG, SPTFQMR and SPFGMR linear solver modules */
+  for (linsolver = 0; linsolver < 4; ++linsolver) {
+
+    /* (Re-)Initialize user data */
+    SetInitialProfiles(cc, sc);
+
+    /* Call KINCreate/KINInit to initialize KINSOL:
+       A pointer to KINSOL problem memory is returned and stored in kmem. */
+    kmem = KINCreate();
+    if (check_flag((void *)kmem, "KINCreate", 0)) return(1);
 
-  /* START: Loop through SPGMR, SPBCG and SPTFQMR linear solver modules */
-  for (linsolver = 0; linsolver < 3; ++linsolver) {
+    /* Vector cc passed as template vector. */
+    flag = KINInit(kmem, func, cc);
+    if (check_flag(&flag, "KINInit", 1)) return(1);
 
-    /* Re-initialize user data */
-    if (linsolver != 0) SetInitialProfiles(cc, sc);
+    flag = KINSetUserData(kmem, data);
+    if (check_flag(&flag, "KINSetUserData", 1)) return(1);
+    flag = KINSetConstraints(kmem, constraints);
+    if (check_flag(&flag, "KINSetConstraints", 1)) return(1);
+    flag = KINSetFuncNormTol(kmem, fnormtol);
+    if (check_flag(&flag, "KINSetFuncNormTol", 1)) return(1);
+    flag = KINSetScaledStepTol(kmem, scsteptol);
+    if (check_flag(&flag, "KINSetScaledStepTol", 1)) return(1);
 
     /* Attach a linear solver module */
     switch(linsolver) {
@@ -307,12 +303,30 @@ int main(void)
 
       break;
 
+    /* (d) SPFGMR */
+    case(USE_SPFGMR):
+
+      /* Print header */
+      printf(" -------");
+      printf(" \n| SPFGMR |\n");
+      printf(" -------\n");
+
+      /* Call KINSpfgmr to specify the linear solver KINSPFGMR with preconditioner
+	 routines PrecSetupBD and PrecSolveBD, and the pointer to the user block data. */
+      maxl = 15; 
+      maxlrst = 2;
+      flag = KINSpfgmr(kmem, maxl);
+      if (check_flag(&flag, "KINSpfgmr", 1)) return(1);
+
+      flag = KINSpilsSetMaxRestarts(kmem, maxlrst);
+      if (check_flag(&flag, "KINSpilsSetMaxRestarts", 1)) return(1);
+
+      break;
+
     }
 
     /* Set preconditioner functions */
-    flag = KINSpilsSetPreconditioner(kmem,
-                                     PrecSetupBD,
-                                     PrecSolveBD);
+    flag = KINSpilsSetPreconditioner(kmem, PrecSetupBD, PrecSolveBD);
     if (check_flag(&flag, "KINSpilsSetPreconditioner", 1)) return(1);
     
     /* Print out the problem size, solution parameters, initial guess. */
@@ -321,7 +335,7 @@ int main(void)
     /* Call KINSol and print output concentration profile */
     flag = KINSol(kmem,           /* KINSol memory block */
 		  cc,             /* initial guess on input; solution vector */
-		  globalstrategy, /* global stragegy choice */
+		  globalstrategy, /* global strategy choice */
 		  sc,             /* scaling vector, for the variable cc */
 		  sc);            /* scaling vector for function values fval */
     if (check_flag(&flag, "KINSol", 1)) return(1);
@@ -332,11 +346,13 @@ int main(void)
     /* Print final statistics and free memory */  
     PrintFinalStats(kmem, linsolver);
 
-  }  /* END: Loop through SPGMR, SPBCG and SPTFQMR linear solver modules */
+    KINFree(&kmem);
 
+  }  /* END: Loop through SPGMR, SPBCG, SPTFQMR, and SPFGMR linear solver modules */
+
+  N_VDestroy_Serial(constraints);
   N_VDestroy_Serial(cc);
   N_VDestroy_Serial(sc);
-  KINFree(&kmem);
   FreeUserData(data);
 
   return(0);
@@ -455,7 +471,7 @@ static int PrecSetupBD(N_Vector cc, N_Vector cscale,
       for (j = 0; j < NUM_SPECIES; j++) {
         
         csave = cxy[j];  /* Save the j,jx,jy element of cc */
-        r = MAX(sqruround*ABS(csave), r0/scxy[j]);
+        r = SUNMAX(sqruround*SUNRabs(csave), r0/scxy[j]);
         cxy[j] += r; /* Perturb the j,jx,jy element of cc */
         fac = ONE/r;
         
@@ -604,7 +620,7 @@ static void InitUserData(UserData data)
   data->dx = (data->ax)/(MX-1);
   data->dy = (data->ay)/(MY-1);
   data->uround = UNIT_ROUNDOFF;
-  data->sqruround = SQRT(data->uround);
+  data->sqruround = SUNRsqrt(data->uround);
 
   /* Set up the coefficients a and b plus others found in the equations */
   np = data->np;
@@ -726,6 +742,11 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
     printf("Linear solver is SPTFQMR with maxl = %d\n", maxl);
     break;
 
+  case(USE_SPFGMR):
+    printf("Linear solver is SPFGMR with maxl = %d, maxlrst = %d\n",
+	   maxl, maxlrst);
+    break;
+
   }
 
   printf("Preconditioning uses interaction-only block-diagonal matrix\n");
@@ -734,7 +755,7 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
   printf("Tolerance parameters:  fnormtol = %Lg   scsteptol = %Lg\n",
          fnormtol, scsteptol);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("Tolerance parameters:  fnormtol = %lg   scsteptol = %lg\n",
+  printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
          fnormtol, scsteptol);
 #else
   printf("Tolerance parameters:  fnormtol = %g   scsteptol = %g\n",
@@ -747,7 +768,7 @@ static void PrintHeader(int globalstrategy, int maxl, int maxlrst,
          PREYIN, PREYIN, PREYIN,
          PREDIN, PREDIN, PREDIN);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-  printf("At all mesh points:  %lg %lg %lg   %lg %lg %lg\n", 
+  printf("At all mesh points:  %g %g %g   %g %g %g\n", 
          PREYIN, PREYIN, PREYIN,
          PREDIN, PREDIN, PREDIN);
 #else
@@ -776,7 +797,7 @@ static void PrintOutput(N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf(" %Lg",ct[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %lg",ct[is]);
+    printf(" %g",ct[is]);
 #else
     printf(" %g",ct[is]);
 #endif
@@ -792,7 +813,7 @@ static void PrintOutput(N_Vector cc)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf(" %Lg",ct[is]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %lg",ct[is]);
+    printf(" %g",ct[is]);
 #else
     printf(" %g",ct[is]);
 #endif
@@ -830,7 +851,7 @@ static void PrintFinalStats(void *kmem, int linsolver)
   printf("nfe    = %5ld    nfeSG = %5ld\n", nfe, nfeSG);
   printf("nps    = %5ld    npe   = %5ld     ncfl  = %5ld\n", nps, npe, ncfl);
 
-  if (linsolver < 2) printf("\n=========================================================\n\n");
+  if (linsolver < 3) printf("\n=========================================================\n\n");
 
 }
 
@@ -844,7 +865,7 @@ static void PrintFinalStats(void *kmem, int linsolver)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/kinsol/serial/kinKrylovDemo_ls.out b/examples/kinsol/serial/kinKrylovDemo_ls.out
index 888089a..577c261 100644
--- a/examples/kinsol/serial/kinKrylovDemo_ls.out
+++ b/examples/kinsol/serial/kinKrylovDemo_ls.out
@@ -27,9 +27,9 @@ At top right:
  1.2637 1.2637 1.2637 37908.7 37908.7 37908.7
 
 Final Statistics.. 
-nni    =     5    nli   =    90
-nfe    =     6    nfeSG =    95
-nps    =    95    npe   =     1     ncfl  =     0
+nni    =     5    nli   =   115
+nfe    =     6    nfeSG =   120
+nps    =   120    npe   =     1     ncfl  =     2
 
 =========================================================
 
@@ -62,9 +62,9 @@ At top right:
  1.2637 1.2637 1.2637 37908.7 37908.7 37908.7
 
 Final Statistics.. 
-nni    =     7    nli   =    82
-nfe    =     8    nfeSG =   171
-nps    =   171    npe   =     1     ncfl  =     4
+nni    =     7    nli   =    80
+nfe    =     8    nfeSG =   167
+nps    =   167    npe   =     1     ncfl  =     4
 
 =========================================================
 
@@ -97,6 +97,41 @@ At top right:
  1.2637 1.2637 1.2637 37908.7 37908.7 37908.7
 
 Final Statistics.. 
-nni    =     8    nli   =   166
-nfe    =     9    nfeSG =   676
-nps    =   676    npe   =     1     ncfl  =     6
+nni    =     8    nli   =   164
+nfe    =     9    nfeSG =   664
+nps    =   664    npe   =     1     ncfl  =     5
+
+=========================================================
+
+ ------- 
+| SPFGMR |
+ -------
+
+Predator-prey test problem --  KINSol (serial version)
+
+Mesh dimensions = 5 X 5
+Number of species = 6
+Total system size = 150
+
+Flag globalstrategy = 0 (0 = None, 1 = Linesearch)
+Linear solver is SPFGMR with maxl = 15, maxlrst = 2
+Preconditioning uses interaction-only block-diagonal matrix
+Positivity constraints imposed on all components 
+Tolerance parameters:  fnormtol = 1e-07   scsteptol = 1e-13
+
+Initial profile of concentration
+At all mesh points:  1 1 1   30000 30000 30000
+
+
+Computed equilibrium species concentrations:
+
+At bottom left:
+ 1.16253 1.16253 1.16253 34875 34875 34875
+
+At top right:
+ 1.2637 1.2637 1.2637 37908.7 37908.7 37908.7
+
+Final Statistics.. 
+nni    =     5    nli   =   115
+nfe    =     6    nfeSG =   120
+nps    =   115    npe   =     1     ncfl  =     2
diff --git a/examples/kinsol/serial/kinLaplace_bnd.c b/examples/kinsol/serial/kinLaplace_bnd.c
index 947f209..cade735 100644
--- a/examples/kinsol/serial/kinLaplace_bnd.c
+++ b/examples/kinsol/serial/kinLaplace_bnd.c
@@ -1,13 +1,13 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2007/10/25 20:03:41 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
  * This example solves a 2D elliptic PDE
  *
- *    d^2 u / dx^2 + d^2 u / dy^2 = u^3 - u + 2.0
+ *    d^2 u / dx^2 + d^2 u / dy^2 = u^3 - u - 2.0
  *
  * subject to homogeneous Dirichelt boundary conditions.
  * The PDE is discretized on a uniform NX+2 by NY+2 grid with
@@ -47,7 +47,7 @@
    to the underlying 1-dimensional storage. 
    IJth(vdata,i,j) references the element in the vdata array for
    u at mesh point (i,j), where 1 <= i <= NX, 1 <= j <= NY.
-   The vdata array is obtained via the macro call vdata = NV_DATA_S(v),
+   The vdata array is obtained via the macro call vdata = N_VGetArrayPointer_Serial(v),
    where v is an N_Vector. 
    The variables are ordered by the y index j, then by the x index i. */
 
@@ -58,7 +58,7 @@
 static int func(N_Vector u, N_Vector f, void *user_data);
 static void PrintOutput(N_Vector u);
 static void PrintFinalStats(void *kmem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -122,7 +122,7 @@ int main()
    * Attach band linear solver 
    * ------------------------- */
 
-  flag = KINBand(kmem, NEQ, NY, NY);
+  flag = KINBand(kmem, NEQ, NX, NX);
   if (check_flag(&flag, "KINBand", 1)) return(1);
 
   /* ------------------------------
@@ -156,7 +156,7 @@ int main()
   /* Call main solver */
   flag = KINSol(kmem,           /* KINSol memory block */
                 y,              /* initial guess on input; solution vector */
-                KIN_LINESEARCH, /* global stragegy choice */
+                KIN_LINESEARCH, /* global strategy choice */
                 scale,          /* scaling vector, for the variable cc */
                 scale);         /* scaling vector for function values fval */
   if (check_flag(&flag, "KINSol", 1)) return(1);
@@ -212,8 +212,8 @@ static int func(N_Vector u, N_Vector f, void *user_data)
   hdc = ONE/(dx*dx);
   vdc = ONE/(dy*dy);
 
-  udata = NV_DATA_S(u);
-  fdata = NV_DATA_S(f);
+  udata = N_VGetArrayPointer_Serial(u);
+  fdata = N_VGetArrayPointer_Serial(f);
 
   for (j=1; j <= NY; j++) {
 
@@ -260,7 +260,7 @@ static void PrintOutput(N_Vector u)
   dx = ONE/(NX+1);
   dy = ONE/(NY+1);
 
-  udata =  NV_DATA_S(u);
+  udata =  N_VGetArrayPointer_Serial(u);
 
   printf("            ");
   for (i=1; i<=NX; i+= SKIP) {
@@ -268,7 +268,7 @@ static void PrintOutput(N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
       printf("%-8.5Lf ", x);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      printf("%-8.5lf ", x);
+      printf("%-8.5f ", x);
 #else
       printf("%-8.5f ", x);
 #endif
@@ -280,7 +280,7 @@ static void PrintOutput(N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
       printf("%-8.5Lf    ", y);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      printf("%-8.5lf    ", y);
+      printf("%-8.5f    ", y);
 #else
       printf("%-8.5f    ", y);
 #endif
@@ -288,7 +288,7 @@ static void PrintOutput(N_Vector u)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
       printf("%-8.5Lf ", IJth(udata,i,j));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-      printf("%-8.5lf ", IJth(udata,i,j));
+      printf("%-8.5f ", IJth(udata,i,j));
 #else
       printf("%-8.5f ", IJth(udata,i,j));
 #endif
@@ -359,7 +359,7 @@ static void PrintFinalStats(void *kmem)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/kinsol/serial/kinLaplace_picard_bnd.c b/examples/kinsol/serial/kinLaplace_picard_bnd.c
new file mode 100644
index 0000000..b93a710
--- /dev/null
+++ b/examples/kinsol/serial/kinLaplace_picard_bnd.c
@@ -0,0 +1,432 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * This example solves a 2D elliptic PDE
+ *
+ *    d^2 u / dx^2 + d^2 u / dy^2 = u^3 - u - 2.0
+ *
+ * subject to homogeneous Dirichelt boundary conditions.
+ * The PDE is discretized on a uniform NX+2 by NY+2 grid with
+ * central differencing, and with boundary values eliminated,
+ * leaving a system of size NEQ = NX*NY.
+ * The nonlinear system is solved by KINSOL using the Picard
+ * iteration and the BAND linear solver.
+ *
+ * This file is strongly based on the kinLaplace_bnd.c file 
+ * developed by Radu Serban.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <kinsol/kinsol.h>
+#include <kinsol/kinsol_band.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+#define NX   31             /* no. of points in x direction */
+#define NY   31             /* no. of points in y direction */
+/* #define NX   3 */             /* no. of points in x direction */
+/* #define NY   3 */            /* no. of points in y direction */
+#define NEQ  NX*NY          /* problem dimension */
+
+#define SKIP 3              /* no. of points skipped for printing */
+
+#define FTOL RCONST(1.e-12) /* function tolerance */
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+#define TWO  RCONST(2.0)
+
+/* IJth is defined in order to isolate the translation from the
+   mathematical 2-dimensional structure of the dependent variable vector
+   to the underlying 1-dimensional storage. 
+   IJth(vdata,i,j) references the element in the vdata array for
+   u at mesh point (i,j), where 1 <= i <= NX, 1 <= j <= NY.
+   The vdata array is obtained via the macro call vdata = N_VGetArrayPointer_Serial(v),
+   where v is an N_Vector. 
+   The variables are ordered by the y index j, then by the x index i. */
+
+#define IJth(vdata,i,j) (vdata[(j-1) + (i-1)*NY])
+
+/* Private functions */
+
+static int func(N_Vector u, N_Vector f, void *user_data);
+static int jac(long int N, long int mu, long int ml, 
+	       N_Vector u, N_Vector f, DlsMat J, void *user_data,
+	       N_Vector tmp1, N_Vector tmp2);
+static void PrintOutput(N_Vector u);
+static void PrintFinalStats(void *kmem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main()
+{
+  realtype fnormtol, fnorm;
+  N_Vector y, scale;
+  int flag;
+  void *kmem;
+
+  y = scale = NULL;
+  kmem = NULL;
+
+  /* -------------------------
+   * Print problem description
+   * ------------------------- */
+  
+  printf("\n2D elliptic PDE on unit square\n");
+  printf("   d^2 u / dx^2 + d^2 u / dy^2 = u^3 - u + 2.0\n");
+  printf(" + homogeneous Dirichlet boundary conditions\n\n");
+  printf("Solution method: Anderson accelerated Picard iteration with band linear solver.\n");
+  printf("Problem size: %2ld x %2ld = %4ld\n", 
+	 (long int) NX, (long int) NY, (long int) NEQ);
+
+  /* --------------------------------------
+   * Create vectors for solution and scales
+   * -------------------------------------- */
+
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+
+  scale = N_VNew_Serial(NEQ);
+  if (check_flag((void *)scale, "N_VNew_Serial", 0)) return(1);
+
+  /* ----------------------------------------------------------------------------------
+   * Initialize and allocate memory for KINSOL, set parametrs for Anderson acceleration
+   * ---------------------------------------------------------------------------------- */
+
+  kmem = KINCreate();
+  if (check_flag((void *)kmem, "KINCreate", 0)) return(1);
+
+  /* y is used as a template */
+
+  /* Use acceleration with up to 3 prior residuals */
+  flag = KINSetMAA(kmem, 3);
+  if (check_flag(&flag, "KINSetMAA", 1)) return(1);
+
+  flag = KINInit(kmem, func, y);
+  if (check_flag(&flag, "KINInit", 1)) return(1);
+
+  /* -------------------
+   * Set optional inputs 
+   * ------------------- */
+
+  /* Specify stopping tolerance based on residual */
+
+  fnormtol  = FTOL; 
+  flag = KINSetFuncNormTol(kmem, fnormtol);
+  if (check_flag(&flag, "KINSetFuncNormTol", 1)) return(1);
+
+  /* -------------------------
+   * Attach band linear solver 
+   * ------------------------- */
+
+  flag = KINBand(kmem, NEQ, NX, NX);
+  if (check_flag(&flag, "KINBand", 1)) return(1);
+  flag = KINDlsSetBandJacFn(kmem, jac);
+  if (check_flag(&flag, "KINDlsBandJacFn", 1)) return(1);
+
+  /* -------------
+   * Initial guess 
+   * ------------- */
+
+  N_VConst_Serial(ZERO, y);
+  IJth(N_VGetArrayPointer_Serial(y), 2, 2) = ONE;
+
+  /* ----------------------------
+   * Call KINSol to solve problem 
+   * ---------------------------- */
+
+  /* No scaling used */
+  N_VConst_Serial(ONE,scale);
+
+  /* Call main solver */
+  flag = KINSol(kmem,           /* KINSol memory block */
+                y,              /* initial guess on input; solution vector */
+                KIN_PICARD,     /* global strategy choice */
+                scale,          /* scaling vector, for the variable cc */
+                scale);         /* scaling vector for function values fval */
+  if (check_flag(&flag, "KINSol", 1)) return(1);
+
+
+  /* ------------------------------------
+   * Print solution and solver statistics 
+   * ------------------------------------ */
+
+  /* Get scaled norm of the system function */
+
+  flag = KINGetFuncNorm(kmem, &fnorm);
+  if (check_flag(&flag, "KINGetfuncNorm", 1)) return(1);
+
+  printf("\nComputed solution (||F|| = %g):\n\n",fnorm);
+  PrintOutput(y);
+
+  PrintFinalStats(kmem);
+
+  /* -----------
+   * Free memory 
+   * ----------- */
+  
+  N_VDestroy_Serial(y);
+  N_VDestroy_Serial(scale);
+  KINFree(&kmem);
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * System function 
+ */
+
+static int func(N_Vector u, N_Vector f, void *user_data)
+{
+  realtype dx, dy, hdiff, vdiff;
+  realtype hdc, vdc;
+  realtype uij, udn, uup, ult, urt;
+  realtype *udata, *fdata;
+  realtype x,y;
+
+  int i, j;
+
+  dx = ONE/(NX+1);  
+  dy = ONE/(NY+1);
+  hdc = ONE/(dx*dx);
+  vdc = ONE/(dy*dy);
+
+  udata = N_VGetArrayPointer_Serial(u);
+  fdata = N_VGetArrayPointer_Serial(f);
+
+  for (j=1; j <= NY; j++) {
+
+    y = j*dy;
+
+    for (i=1; i <= NX; i++) {
+
+      x = i*dx;
+
+      /* Extract u at x_i, y_j and four neighboring points */
+
+      uij = IJth(udata, i, j);
+      udn = (j == 1)  ? ZERO : IJth(udata, i, j-1);
+      uup = (j == NY) ? ZERO : IJth(udata, i, j+1);
+      ult = (i == 1)  ? ZERO : IJth(udata, i-1, j);
+      urt = (i == NX) ? ZERO : IJth(udata, i+1, j);
+
+      /* Evaluate diffusion components */
+
+      hdiff = hdc*(ult - TWO*uij + urt);
+      vdiff = vdc*(uup - TWO*uij + udn);
+
+      /* Set residual at x_i, y_j */
+
+      IJth(fdata, i, j) = hdiff + vdiff + uij - uij*uij*uij + 2.0;
+
+    }
+
+  }
+
+  return(0);
+}
+
+/* 
+ * Jacobian function 
+ */
+
+static int jac(long int N, long int mu, long int ml, 
+	       N_Vector u, N_Vector f, 
+	       DlsMat J, void *user_data,
+	       N_Vector tmp1, N_Vector tmp2)
+{
+  realtype dx, dy;
+  realtype hdc, vdc;
+  realtype *kthCol;
+
+  int i, j, k;
+
+  dx = ONE/(NX+1);  
+  dy = ONE/(NY+1);
+  hdc = ONE/(dx*dx);
+  vdc = ONE/(dy*dy);
+
+  /*
+     The components of f(t,u) which depend on u_{i,j} are
+     f_{i,j}, f_{i-1,j}, f_{i+1,j}, f_{i,j+1}, and f_{i,j-1}.
+     Thus, a column of the Jacobian will contain an entry from
+     each of these equations exception the ones on the boundary.
+
+     f_{i,j}   = hdc*(u_{i-1,j}  -2u_{i,j}  +u_{i+1,j})   + vdc*(u_{i,j-1}  -2u_{i,j}  +u_{i,j+1})
+     f_{i-1,j} = hdc*(u_{i-2,j}  -2u_{i-1,j}+u_{i,j})     + vdc*(u_{i-1,j-1}-2u_{i-1,j}+u_{i-1,j+1})
+     f_{i+1,j} = hdc*(u_{i,j}    -2u_{i+1,j}+u_{i+2,j})   + vdc*(u_{i+1,j-1}-2u_{i+1,j}+u_{i+1,j+1})
+     f_{i,j-1} = hdc*(u_{i-1,j-1}-2u_{i,j-1}+u_{i+1,j-1}) + vdc*(u_{i,j-2}  -2u_{i,j-1}+u_{i,j})
+     f_{i,j+1} = hdc*(u_{i-1,j+1}-2u_{i,j+1}+u_{i+1,j+1}) + vdc*(u_{i,j}    -2u_{i,j+1}+u_{i,j+2})
+
+  */
+
+  for (j=0; j <= NY-1; j++) {
+    for (i=0; i <= NX-1; i++) {
+
+      /* Evaluate diffusion coefficients */
+
+      k = i + j*NX;
+      kthCol = BAND_COL(J, k);
+      BAND_COL_ELEM(kthCol,k,k) = -2.0*hdc - 2.0*vdc;
+      if ( i != (NX-1) ) BAND_COL_ELEM(kthCol,k+1,k) = hdc;
+      if ( i != 0 )      BAND_COL_ELEM(kthCol,k-1,k) = hdc;
+      if ( j != (NY-1) ) BAND_COL_ELEM(kthCol,k+NX,k) = vdc;
+      if ( j != 0 )      BAND_COL_ELEM(kthCol,k-NX,k) = vdc;
+    }
+  }
+
+  return(0);
+}
+
+/* 
+ * Print solution at selected points
+ */
+
+static void PrintOutput(N_Vector u)
+{
+  int i, j;
+  realtype dx, dy, x, y;
+  realtype *udata;
+
+  dx = ONE/(NX+1);
+  dy = ONE/(NY+1);
+
+  udata =  N_VGetArrayPointer_Serial(u);
+
+  printf("            ");
+  for (i=1; i<=NX; i+= SKIP) {
+    x = i*dx;
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+      printf("%-8.5Lf ", x);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+      printf("%-8.5f ", x);
+#else
+      printf("%-8.5f ", x);
+#endif
+  }
+  printf("\n\n");
+
+  for (j=1; j<=NY; j+= SKIP) {
+    y = j*dy;
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+      printf("%-8.5Lf    ", y);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+      printf("%-8.5f    ", y);
+#else
+      printf("%-8.5f    ", y);
+#endif
+    for (i=1; i<=NX; i+= SKIP) {
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+      printf("%-8.5Lf ", IJth(udata,i,j));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+      printf("%-8.5f ", IJth(udata,i,j));
+#else
+      printf("%-8.5f ", IJth(udata,i,j));
+#endif
+    }
+    printf("\n");
+  }
+}
+
+/* 
+ * Print final statistics
+ */
+
+static void PrintFinalStats(void *kmem)
+{
+  long int nni, nfe, nje, nfeD;
+  long int lenrwB, leniwB;
+  int flag;
+  
+  /* Main solver statistics */
+
+  flag = KINGetNumNonlinSolvIters(kmem, &nni);
+  check_flag(&flag, "KINGetNumNonlinSolvIters", 1);
+  flag = KINGetNumFuncEvals(kmem, &nfe);
+  check_flag(&flag, "KINGetNumFuncEvals", 1);
+
+  /* Band linear solver statistics */
+
+  flag = KINDlsGetNumJacEvals(kmem, &nje);
+  check_flag(&flag, "KINDlsGetNumJacEvals", 1);
+  flag = KINDlsGetNumFuncEvals(kmem, &nfeD);
+  check_flag(&flag, "KINDlsGetNumFuncEvals", 1);
+
+  /* Band linear solver workspace size */
+
+  flag = KINDlsGetWorkSpace(kmem, &lenrwB, &leniwB);
+  check_flag(&flag, "KINDlsGetWorkSpace", 1);
+
+  printf("\nFinal Statistics.. \n\n");
+  printf("nni      = %6ld    nfe     = %6ld \n", nni, nfe);
+  printf("nje      = %6ld    nfeB    = %6ld \n", nje, nfeD);
+  printf("\n");
+  printf("lenrwB   = %6ld    leniwB  = %6ld \n", lenrwB, leniwB);
+  
+}
+
+/*
+ * Check function return value...
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr,
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); 
+    }
+  }
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr,
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/kinsol/serial/kinLaplace_picard_bnd.out b/examples/kinsol/serial/kinLaplace_picard_bnd.out
new file mode 100644
index 0000000..6ef27cc
--- /dev/null
+++ b/examples/kinsol/serial/kinLaplace_picard_bnd.out
@@ -0,0 +1,30 @@
+
+2D elliptic PDE on unit square
+   d^2 u / dx^2 + d^2 u / dy^2 = u^3 - u + 2.0
+ + homogeneous Dirichlet boundary conditions
+
+Solution method: Anderson accelerated Picard iteration with band linear solver.
+Problem size: 31 x 31 =  961
+
+Computed solution (||F|| = 1.83409e-13):
+
+            0.03125  0.12500  0.21875  0.31250  0.40625  0.50000  0.59375  0.68750  0.78125  0.87500  0.96875  
+
+0.03125     0.00405  0.01165  0.01617  0.01896  0.02051  0.02100  0.02051  0.01896  0.01617  0.01165  0.00405  
+0.12500     0.01165  0.03772  0.05461  0.06530  0.07126  0.07318  0.07126  0.06530  0.05461  0.03772  0.01165  
+0.21875     0.01617  0.05461  0.08098  0.09813  0.10780  0.11093  0.10780  0.09813  0.08098  0.05461  0.01617  
+0.31250     0.01896  0.06530  0.09813  0.11989  0.13229  0.13631  0.13229  0.11989  0.09813  0.06530  0.01896  
+0.40625     0.02051  0.07126  0.10780  0.13229  0.14632  0.15089  0.14632  0.13229  0.10780  0.07126  0.02051  
+0.50000     0.02100  0.07318  0.11093  0.13631  0.15089  0.15564  0.15089  0.13631  0.11093  0.07318  0.02100  
+0.59375     0.02051  0.07126  0.10780  0.13229  0.14632  0.15089  0.14632  0.13229  0.10780  0.07126  0.02051  
+0.68750     0.01896  0.06530  0.09813  0.11989  0.13229  0.13631  0.13229  0.11989  0.09813  0.06530  0.01896  
+0.78125     0.01617  0.05461  0.08098  0.09813  0.10780  0.11093  0.10780  0.09813  0.08098  0.05461  0.01617  
+0.87500     0.01165  0.03772  0.05461  0.06530  0.07126  0.07318  0.07126  0.06530  0.05461  0.03772  0.01165  
+0.96875     0.00405  0.01165  0.01617  0.01896  0.02051  0.02100  0.02051  0.01896  0.01617  0.01165  0.00405  
+
+Final Statistics.. 
+
+nni      =      6    nfe     =      7 
+nje      =      6    nfeB    =      0 
+
+lenrwB   = 150877    leniwB  =    961 
diff --git a/examples/kinsol/serial/kinRoberts_fp.c b/examples/kinsol/serial/kinRoberts_fp.c
new file mode 100644
index 0000000..82edd67
--- /dev/null
+++ b/examples/kinsol/serial/kinRoberts_fp.c
@@ -0,0 +1,299 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * Example problem:
+ * 
+ * The following is a simple example problem, with the coding
+ * needed for its solution by the accelerated fixed point solver in 
+ * KINSOL. 
+ * The problem is from chemical kinetics, and consists of solving 
+ * the first time step in a Backward Euler solution for the 
+ * following three rate equations:         
+ *    dy1/dt = -.04*y1 + 1.e4*y2*y3
+ *    dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e2*(y2)^2
+ *    dy3/dt = 3.e2*(y2)^2
+ * on the interval from t = 0.0 to t = 0.1, with initial
+ * conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
+ * Run statistics (optional outputs) are printed at the end.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <kinsol/kinsol.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+/* Problem Constants */
+
+#define NEQ   3              /* number of equations  */
+#define Y10   RCONST(1.0)    /* initial y components */
+#define Y20   RCONST(0.0)
+#define Y30   RCONST(0.0)
+#define TOL   RCONST(1.e-10) /* function tolerance */
+#define DSTEP RCONST(0.1)    /* Size of the single time step used */
+
+#define PRIORS 2
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* User-defined vector accessor macro: Ith */
+
+/* This macro is defined in order to write code which exactly matches
+   the mathematical problem description given above.
+
+   Ith(v,i) references the ith component of the vector v, where i is in
+   the range [1..NEQ] and NEQ is defined above. The Ith macro is defined
+   using the N_VIth macro in nvector.h. N_VIth numbers the components of
+   a vector starting from 0.
+*/
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)       /* Ith numbers components 1..NEQ */
+
+
+/* Private functions */
+
+static int funcRoberts(N_Vector u, N_Vector f, void *user_data);
+static void PrintOutput(N_Vector u);
+static void PrintFinalStats(void *kmem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main()
+{
+  realtype fnormtol, fnorm;
+  N_Vector y, scale;
+  int flag;
+  void *kmem;
+
+  fnorm = 0.0;
+  y = scale = NULL;
+  kmem = NULL;
+
+  /* -------------------------
+   * Print problem description
+   * ------------------------- */
+  
+  printf("Example problem from chemical kinetics solving\n"); 
+  printf("the first time step in a Backward Euler solution for the\n");
+  printf("following three rate equations:\n");
+  printf("    dy1/dt = -.04*y1 + 1.e4*y2*y3\n");
+  printf("    dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e2*(y2)^2\n");
+  printf("    dy3/dt = 3.e2*(y2)^2\n");
+  printf("on the interval from t = 0.0 to t = 0.1, with initial\n");
+  printf("conditions: y1 = 1.0, y2 = y3 = 0.\n"); 
+  printf("Solution method: Anderson accelerated fixed point iteration.\n");
+
+  /* --------------------------------------
+   * Create vectors for solution and scales
+   * -------------------------------------- */
+
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+
+  scale = N_VNew_Serial(NEQ);
+  if (check_flag((void *)scale, "N_VNew_Serial", 0)) return(1);
+
+  /* -----------------------------------------
+   * Initialize and allocate memory for KINSOL
+   * ----------------------------------------- */
+
+  kmem = KINCreate();
+  if (check_flag((void *)kmem, "KINCreate", 0)) return(1);
+
+  /* y is used as a template */
+
+  /* Set number of prior residuals used in Anderson acceleration */
+  flag = KINSetMAA(kmem, PRIORS);
+
+  flag = KINInit(kmem, funcRoberts, y);
+  if (check_flag(&flag, "KINInit", 1)) return(1);
+
+  /* -------------------
+   * Set optional inputs 
+   * ------------------- */
+
+  /* Specify stopping tolerance based on residual */
+
+  fnormtol  = TOL; 
+  flag = KINSetFuncNormTol(kmem, fnormtol);
+  if (check_flag(&flag, "KINSetFuncNormTol", 1)) return(1);
+
+  /* -------------
+   * Initial guess 
+   * ------------- */
+
+  N_VConst_Serial(ZERO, y);
+  Ith(y,1) = ONE;
+
+  /* ----------------------------
+   * Call KINSol to solve problem 
+   * ---------------------------- */
+
+  /* No scaling used */
+  N_VConst_Serial(ONE,scale);
+
+  /* Call main solver */
+  flag = KINSol(kmem,           /* KINSol memory block */
+                y,              /* initial guess on input; solution vector */
+                KIN_FP,         /* global strategy choice */
+                scale,          /* scaling vector, for the variable cc */
+                scale);         /* scaling vector for function values fval */
+  if (check_flag(&flag, "KINSol", 1)) return(1);
+
+
+  /* ------------------------------------
+   * Print solution and solver statistics 
+   * ------------------------------------ */
+
+  /* Get scaled norm of the system function */
+
+  flag = KINGetFuncNorm(kmem, &fnorm);
+  if (check_flag(&flag, "KINGetfuncNorm", 1)) return(1);
+
+  printf("\nComputed solution (||F|| = %g):\n\n",fnorm);
+  PrintOutput(y);
+
+  PrintFinalStats(kmem);
+
+  /* -----------
+   * Free memory 
+   * ----------- */
+  
+  N_VDestroy_Serial(y);
+  N_VDestroy_Serial(scale);
+  KINFree(&kmem);
+
+  return(0);
+}
+
+/*
+ *--------------------------------------------------------------------
+ * PRIVATE FUNCTIONS
+ *--------------------------------------------------------------------
+ */
+
+/* 
+ * System function 
+ */
+
+static int funcRoberts(N_Vector y, N_Vector g, void *user_data)
+{
+  realtype y1, y2, y3;
+  realtype yd1, yd3;
+
+  y1 = Ith(y,1);
+  y2 = Ith(y,2);
+  y3 = Ith(y,3);
+
+  yd1 = DSTEP * ( RCONST(-0.04)*y1 + RCONST(1.0e4)*y2*y3 );
+  yd3 = DSTEP * RCONST(3.0e2)*y2*y2;
+
+  Ith(g,1) = yd1 + Y10;
+  Ith(g,2) = -yd1 - yd3 + Y20;
+  Ith(g,3) = yd3 + Y30;
+
+  return(0);
+}
+
+/* 
+ * Print solution at selected points
+ */
+
+static void PrintOutput(N_Vector y)
+{
+  realtype y1, y2, y3;
+
+  y1 = Ith(y,1);
+  y2 = Ith(y,2);
+  y3 = Ith(y,3);
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+  printf("y =%14.6Le  %14.6Le  %14.6Le\n", y1, y2, y3);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  printf("y =%14.6e  %14.6e  %14.6e\n", y1, y2, y3);
+#else
+  printf("y =%14.6e  %14.6e  %14.6e\n", y1, y2, y3);
+#endif
+
+  return;
+}
+
+/* 
+ * Print final statistics
+ */
+
+static void PrintFinalStats(void *kmem)
+{
+  long int nni, nfe;
+  int flag;
+  
+  /* Main solver statistics */
+
+  flag = KINGetNumNonlinSolvIters(kmem, &nni);
+  check_flag(&flag, "KINGetNumNonlinSolvIters", 1);
+  flag = KINGetNumFuncEvals(kmem, &nfe);
+  check_flag(&flag, "KINGetNumFuncEvals", 1);
+
+  printf("\nFinal Statistics.. \n\n");
+  printf("nni      = %6ld    nfe     = %6ld \n", nni, nfe);
+}
+
+/*
+ * Check function return value...
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr,
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); 
+    }
+  }
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr,
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/kinsol/serial/kinRoberts_fp.out b/examples/kinsol/serial/kinRoberts_fp.out
new file mode 100644
index 0000000..f105fcb
--- /dev/null
+++ b/examples/kinsol/serial/kinRoberts_fp.out
@@ -0,0 +1,17 @@
+Example problem from chemical kinetics solving
+the first time step in a Backward Euler solution for the
+following three rate equations:
+    dy1/dt = -.04*y1 + 1.e4*y2*y3
+    dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e2*(y2)^2
+    dy3/dt = 3.e2*(y2)^2
+on the interval from t = 0.0 to t = 0.1, with initial
+conditions: y1 = 1.0, y2 = y3 = 0.
+Solution method: Anderson accelerated fixed point iteration.
+
+Computed solution (||F|| = 3.96494e-12):
+
+y =  9.967854e-01    2.953006e-03    2.616074e-04
+
+Final Statistics.. 
+
+nni      =      8    nfe     =      8 
diff --git a/examples/kinsol/serial/kinRoboKin_dns.c b/examples/kinsol/serial/kinRoboKin_dns.c
index e3842f3..baaf4bf 100644
--- a/examples/kinsol/serial/kinRoboKin_dns.c
+++ b/examples/kinsol/serial/kinRoboKin_dns.c
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 23:08:49 $
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -52,7 +52,7 @@ static int jac(long int N,
                N_Vector tmp1, N_Vector tmp2);
 static void PrintOutput(N_Vector y);
 static void PrintFinalStats(void *kmem);
-static int check_flag(void *flagvalue, char *funcname, int opt);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
 
 /*
  *--------------------------------------------------------------------
@@ -126,7 +126,7 @@ int main()
   /* Initial guess */
 
   N_VConst_Serial(ONE, y);
-  for(i = 1; i <= NVAR; i++) Ith(y,i) = SQRT(TWO)/TWO;
+  for(i = 1; i <= NVAR; i++) Ith(y,i) = SUNRsqrt(TWO)/TWO;
 
   printf("Initial guess:\n");
   PrintOutput(y);
@@ -136,7 +136,7 @@ int main()
   N_VConst_Serial(ONE,scale);
   flag = KINSol(kmem,           /* KINSol memory block */
                 y,              /* initial guess on input; solution vector */
-                KIN_LINESEARCH, /* global stragegy choice */
+                KIN_LINESEARCH, /* global strategy choice */
                 scale,          /* scaling vector, for the variable cc */
                 scale);         /* scaling vector for function values fval */
   if (check_flag(&flag, "KINSol", 1)) return(1);
@@ -172,8 +172,8 @@ static int func(N_Vector y, N_Vector f, void *user_data)
   realtype lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8;
   realtype ub1, ub2, ub3, ub4, ub5, ub6, ub7, ub8;
 
-  yd = NV_DATA_S(y);
-  fd = NV_DATA_S(f);
+  yd = N_VGetArrayPointer_Serial(y);
+  fd = N_VGetArrayPointer_Serial(f);
 
   x1 = yd[0]; l1 = yd[ 8]; u1 = yd[16]; 
   x2 = yd[1]; l2 = yd[ 9]; u2 = yd[17]; 
@@ -244,7 +244,7 @@ static int jac(long int N,
   realtype *yd;
   realtype x1, x2, x3, x4, x5, x6, x7, x8;
 
-  yd = NV_DATA_S(y);
+  yd = N_VGetArrayPointer_Serial(y);
 
   x1 = yd[0];
   x2 = yd[1];
@@ -357,7 +357,7 @@ static void PrintOutput(N_Vector y)
     printf(" %10.6Lg   %10.6Lg   %10.6Lg\n", 
            Ith(y,i+NVAR), Ith(y,i), Ith(y,i+2*NVAR));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf(" %10.6lg   %10.6lg   %10.6lg\n", 
+    printf(" %10.6g   %10.6g   %10.6g\n", 
            Ith(y,i+NVAR), Ith(y,i), Ith(y,i+2*NVAR));
 #else
     printf(" %10.6g   %10.6g   %10.6g\n", 
@@ -402,7 +402,7 @@ static void PrintFinalStats(void *kmem)
  *             NULL pointer 
  */
 
-static int check_flag(void *flagvalue, char *funcname, int opt)
+static int check_flag(void *flagvalue, const char *funcname, int opt)
 {
   int *errflag;
 
diff --git a/examples/kinsol/serial/kinRoboKin_slu.c b/examples/kinsol/serial/kinRoboKin_slu.c
new file mode 100644
index 0000000..4e3a8b1
--- /dev/null
+++ b/examples/kinsol/serial/kinRoboKin_slu.c
@@ -0,0 +1,614 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4834 $
+ * $Date: 2016-08-01 16:59:05 -0700 (Mon, 01 Aug 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol S. Woodward @ LLNL.  Adapted from the file
+ *    kinRoboKin_dns.c by Radu Serban @ LLNL
+ * -----------------------------------------------------------------
+ * This example solves a nonlinear system from robot kinematics.
+ *
+ * Source: "Handbook of Test Problems in Local and Global Optimization",
+ *             C.A. Floudas, P.M. Pardalos et al.
+ *             Kluwer Academic Publishers, 1999.
+ * Test problem 6 from Section 14.1, Chapter 14
+ * 
+ * The nonlinear system is solved by KINSOL using the SUPERLU_MT linear
+ * solver.
+ *
+ * Constraints are imposed to make all components of the solution
+ * be within [-1,1].
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <kinsol/kinsol.h>
+#include <kinsol/kinsol_superlumt.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+/* Problem Constants */
+
+#define NVAR  8              /* variables */ 
+#define NEQ   3*NVAR         /* equations + bounds */
+
+#define FTOL   RCONST(1.e-5) /* function tolerance */
+#define STOL   RCONST(1.e-5) /* step tolerance */
+
+#define ZERO  RCONST(0.0)
+#define ONE   RCONST(1.0)
+#define TWO   RCONST(2.0)
+
+#define Ith(v,i)    NV_Ith_S(v,i-1)
+
+static int func(N_Vector y, N_Vector f, void *user_data);
+static int jac(N_Vector y, N_Vector f,
+               SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2);
+static void PrintOutput(N_Vector y);
+static void PrintFinalStats(void *kmem);
+static int check_flag(void *flagvalue, const char *funcname, int opt);
+
+/*
+ *--------------------------------------------------------------------
+ * MAIN PROGRAM
+ *--------------------------------------------------------------------
+ */
+
+int main()
+{
+  realtype fnormtol, scsteptol;
+  N_Vector y, scale, constraints;
+  int mset, flag, i;
+  void *kmem;
+
+  int nnz, num_threads;
+
+  y = scale = constraints = NULL;
+  kmem = NULL;
+
+  printf("\nRobot Kinematics Example\n");
+  printf("8 variables; -1 <= x_i <= 1\n");
+  printf("KINSOL problem size: 8 + 2*8 = 24 \n\n");
+
+  /* Create vectors for solution, scales, and constraints */
+
+  y = N_VNew_Serial(NEQ);
+  if (check_flag((void *)y, "N_VNew_Serial", 0)) return(1);
+
+  scale = N_VNew_Serial(NEQ);
+  if (check_flag((void *)scale, "N_VNew_Serial", 0)) return(1);
+
+  constraints = N_VNew_Serial(NEQ);
+  if (check_flag((void *)constraints, "N_VNew_Serial", 0)) return(1);
+
+  /* Initialize and allocate memory for KINSOL */
+
+  kmem = KINCreate();
+  if (check_flag((void *)kmem, "KINCreate", 0)) return(1);
+
+  flag = KINInit(kmem, func, y); /* y passed as a template */
+  if (check_flag(&flag, "KINInit", 1)) return(1);
+
+  /* Set optional inputs */
+
+  N_VConst_Serial(ZERO,constraints);
+  for (i = NVAR+1; i <= NEQ; i++) Ith(constraints, i) = ONE;
+  
+  flag = KINSetConstraints(kmem, constraints);
+  if (check_flag(&flag, "KINSetConstraints", 1)) return(1);
+
+  fnormtol  = FTOL; 
+  flag = KINSetFuncNormTol(kmem, fnormtol);
+  if (check_flag(&flag, "KINSetFuncNormTol", 1)) return(1);
+
+  scsteptol = STOL;
+  flag = KINSetScaledStepTol(kmem, scsteptol);
+  if (check_flag(&flag, "KINSetScaledStepTol", 1)) return(1);
+
+  /* Attach SuperLU_MT linear solver */
+  /* Set the number of nonzeros in the Jacobian */
+  nnz = 56;
+  /* Set the number fo threads to use */
+  num_threads = 2;
+  flag = KINSuperLUMT(kmem, num_threads, NEQ, nnz);
+  if (check_flag(&flag, "KINSuperLUMT", 1)) return(1);
+
+  flag = KINSlsSetSparseJacFn(kmem, jac);
+  if (check_flag(&flag, "KINSlsSetSparseJacFn", 1)) return(1);
+
+  /* Indicate exact Newton */
+
+  mset = 1;
+  flag = KINSetMaxSetupCalls(kmem, mset);
+  if (check_flag(&flag, "KINSetMaxSetupCalls", 1)) return(1);
+
+  /* Initial guess */
+
+  N_VConst_Serial(ONE, y);
+  for(i = 1; i <= NVAR; i++) Ith(y,i) = SUNRsqrt(TWO)/TWO;
+
+  printf("Initial guess:\n");
+  PrintOutput(y);
+
+  /* Call KINSol to solve problem */
+
+  N_VConst_Serial(ONE,scale);
+  flag = KINSol(kmem,           /* KINSol memory block */
+                y,              /* initial guess on input; solution vector */
+                KIN_LINESEARCH, /* global strategy choice */
+                scale,          /* scaling vector, for the variable cc */
+                scale);         /* scaling vector for function values fval */
+  if (check_flag(&flag, "KINSol", 1)) return(1);
+
+  printf("\nComputed solution:\n");
+  PrintOutput(y);
+
+  /* Print final statistics and free memory */  
+
+  PrintFinalStats(kmem);
+
+  N_VDestroy_Serial(y);
+  N_VDestroy_Serial(scale);
+  N_VDestroy_Serial(constraints);
+  KINFree(&kmem);
+
+  return(0);
+}
+
+/* 
+ * System function 
+ */
+
+static int func(N_Vector y, N_Vector f, void *user_data)
+{
+  realtype *yd, *fd;
+
+  realtype x1, x2, x3, x4, x5, x6, x7, x8;
+  realtype l1, l2, l3, l4, l5, l6, l7, l8;
+  realtype u1, u2, u3, u4, u5, u6, u7, u8;
+
+  realtype eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8;
+  realtype lb1, lb2, lb3, lb4, lb5, lb6, lb7, lb8;
+  realtype ub1, ub2, ub3, ub4, ub5, ub6, ub7, ub8;
+
+  yd = N_VGetArrayPointer_Serial(y);
+  fd = N_VGetArrayPointer_Serial(f);
+
+  x1 = yd[0]; l1 = yd[ 8]; u1 = yd[16]; 
+  x2 = yd[1]; l2 = yd[ 9]; u2 = yd[17]; 
+  x3 = yd[2]; l3 = yd[10]; u3 = yd[18]; 
+  x4 = yd[3]; l4 = yd[11]; u4 = yd[19]; 
+  x5 = yd[4]; l5 = yd[12]; u5 = yd[20]; 
+  x6 = yd[5]; l6 = yd[13]; u6 = yd[21]; 
+  x7 = yd[6]; l7 = yd[14]; u7 = yd[22]; 
+  x8 = yd[7]; l8 = yd[15]; u8 = yd[23]; 
+
+  /* Nonlinear equations */
+
+  eq1 = - 0.1238*x1 + x7 - 0.001637*x2 
+    - 0.9338*x4 + 0.004731*x1*x3 - 0.3578*x2*x3 - 0.3571;
+  eq2 = 0.2638*x1 - x7 - 0.07745*x2 
+    - 0.6734*x4 + 0.2238*x1*x3 + 0.7623*x2*x3 - 0.6022;
+  eq3 = 0.3578*x1 + 0.004731*x2 + x6*x8;
+  eq4 = - 0.7623*x1 + 0.2238*x2 + 0.3461;
+  eq5 = x1*x1 + x2*x2 - 1;
+  eq6 = x3*x3 + x4*x4 - 1;
+  eq7 = x5*x5 + x6*x6 - 1;
+  eq8 = x7*x7 + x8*x8 - 1;
+
+  /* Lower bounds ( l_i = 1 + x_i >= 0)*/
+
+  lb1 = l1 - 1.0 - x1;
+  lb2 = l2 - 1.0 - x2;
+  lb3 = l3 - 1.0 - x3;
+  lb4 = l4 - 1.0 - x4;
+  lb5 = l5 - 1.0 - x5;
+  lb6 = l6 - 1.0 - x6;
+  lb7 = l7 - 1.0 - x7;
+  lb8 = l8 - 1.0 - x8;
+
+  /* Upper bounds ( u_i = 1 - x_i >= 0)*/
+
+  ub1 = u1 - 1.0 + x1;
+  ub2 = u2 - 1.0 + x2;
+  ub3 = u3 - 1.0 + x3;
+  ub4 = u4 - 1.0 + x4;
+  ub5 = u5 - 1.0 + x5;
+  ub6 = u6 - 1.0 + x6;
+  ub7 = u7 - 1.0 + x7;
+  ub8 = u8 - 1.0 + x8;
+
+  fd[0] = eq1; fd[ 8] = lb1; fd[16] = ub1;
+  fd[1] = eq2; fd[ 9] = lb2; fd[17] = ub2;
+  fd[2] = eq3; fd[10] = lb3; fd[18] = ub3;
+  fd[3] = eq4; fd[11] = lb4; fd[19] = ub4;
+  fd[4] = eq5; fd[12] = lb5; fd[20] = ub5;
+  fd[5] = eq6; fd[13] = lb6; fd[21] = ub6;
+  fd[6] = eq7; fd[14] = lb7; fd[22] = ub7;
+  fd[7] = eq8; fd[15] = lb8; fd[23] = ub8;
+
+  return(0);
+}
+
+/*
+ * System Jacobian
+ */
+
+static int jac(N_Vector y, N_Vector f,
+               SlsMat J, void *user_data,
+               N_Vector tmp1, N_Vector tmp2)
+{
+  realtype *yd;
+  realtype x1, x2, x3, x4, x5, x6, x7, x8;
+  int *colptrs = *J->colptrs;
+  int *rowvals = *J->rowvals;
+  realtype *data = J->data;
+
+  yd = N_VGetArrayPointer_Serial(y);
+
+  x1 = yd[0];
+  x2 = yd[1];
+  x3 = yd[2];
+  x4 = yd[3];
+  x5 = yd[4];
+  x6 = yd[5];
+  x7 = yd[6];
+  x8 = yd[7];
+
+  SparseSetMatToZero(J);
+  
+  colptrs[0] = 0;
+  colptrs[1] = 7;
+  colptrs[2] = 14;
+  colptrs[3] = 19;
+  colptrs[4] = 24;
+  colptrs[5] = 27;
+  colptrs[6] = 31;
+  colptrs[7] = 36;
+  colptrs[8] = 40;
+  colptrs[9] = 41;
+  colptrs[10] = 42;
+  colptrs[11] = 43;
+  colptrs[12] = 44;
+  colptrs[13] = 45;
+  colptrs[14] = 46;
+  colptrs[15] = 47;
+  colptrs[16] = 48;
+  colptrs[17] = 49;
+  colptrs[18] = 50;
+  colptrs[19] = 51;
+  colptrs[20] = 52;
+  colptrs[21] = 53;
+  colptrs[22] = 54;
+  colptrs[23] = 55;
+  colptrs[24] = 56;
+
+  /* Nonlinear equations */
+
+  /* 
+     - 0.1238*x1 + x7 - 0.001637*x2 
+     - 0.9338*x4 + 0.004731*x1*x3 - 0.3578*x2*x3 - 0.3571 
+  */
+  /*
+  IJth(J,1,1) = - 0.1238 + 0.004731*x3;
+  IJth(J,1,2) = - 0.001637 - 0.3578*x3;
+  IJth(J,1,3) = 0.004731*x1 - 0.3578*x2;
+  IJth(J,1,4) = - 0.9338;
+  IJth(J,1,7) = 1.0;
+  */
+
+  J->data[0] = - 0.1238 + 0.004731*x3;
+  rowvals[0] = 0;
+  J->data[7] = - 0.001637 - 0.3578*x3;
+  rowvals[7] = 0;
+  J->data[14] = 0.004731*x1 - 0.3578*x2;
+  rowvals[14] = 0;
+  J->data[19] = - 0.9338;
+  rowvals[19] = 0;
+  J->data[31] = 1.0;
+  rowvals[31] = 0;
+
+  /*
+    0.2638*x1 - x7 - 0.07745*x2 
+    - 0.6734*x4 + 0.2238*x1*x3 + 0.7623*x2*x3 - 0.6022
+  */
+  /*
+  IJth(J,2,1) = 0.2638 + 0.2238*x3;
+  IJth(J,2,2) = - 0.07745 + 0.7623*x3;
+  IJth(J,2,3) = 0.2238*x1 + 0.7623*x2;
+  IJth(J,2,4) = - 0.6734;
+  IJth(J,2,7) = -1.0;
+  */
+
+  J->data[1] = 0.2638 + 0.2238*x3;
+  rowvals[1] = 1;
+  J->data[8] = - 0.07745 + 0.7623*x3;
+  rowvals[8] = 1;
+  J->data[15] = 0.2238*x1 + 0.7623*x2;
+  rowvals[15] = 1;
+  J->data[20] = - 0.6734;
+  rowvals[20] = 1;
+  J->data[32] = -1.0;
+  rowvals[32] = 1;
+
+
+  /*
+    0.3578*x1 + 0.004731*x2 + x6*x8
+  */
+  /*
+  IJth(J,3,1) = 0.3578;
+  IJth(J,3,2) = 0.004731;
+  IJth(J,3,6) = x8;
+  IJth(J,3,8) = x6;
+  */
+
+  J->data[2] = 0.3578;
+  rowvals[2] = 2;
+  J->data[9] = 0.004731;
+  rowvals[9] = 2;
+  J->data[27] = x8;
+  rowvals[27] = 2;
+  J->data[36] = x6;
+  rowvals[36] = 2;
+
+
+  /*
+    - 0.7623*x1 + 0.2238*x2 + 0.3461
+  */
+  /*
+  IJth(J,4,1) = - 0.7623;
+  IJth(J,4,2) = 0.2238;
+  */
+
+  J->data[3] = - 0.7623;
+  rowvals[3] = 3;
+  J->data[10] = 0.2238;
+  rowvals[10] = 3;
+
+  /*
+    x1*x1 + x2*x2 - 1
+  */
+  /*
+  IJth(J,5,1) = 2.0*x1;
+  IJth(J,5,2) = 2.0*x2;
+  */
+
+  J->data[4] = 2.0*x1;
+  rowvals[4] = 4;
+  J->data[11] = 2.0*x2;
+  rowvals[11] = 4;
+
+  /*
+    x3*x3 + x4*x4 - 1
+  */
+  /*
+  IJth(J,6,3) = 2.0*x3;
+  IJth(J,6,4) = 2.0*x4;
+  */
+
+  J->data[16] = 2.0*x3;
+  rowvals[16] = 5;
+  J->data[21] = 2.0*x4;
+  rowvals[21] = 5;
+
+  /*
+    x5*x5 + x6*x6 - 1
+  */
+  /*
+  IJth(J,7,5) = 2.0*x5;
+  IJth(J,7,6) = 2.0*x6;
+  */
+
+  J->data[24] = 2.0*x5;
+  rowvals[24] = 6;
+  J->data[28] = 2.0*x6;
+  rowvals[28] = 6;
+
+  /*
+    x7*x7 + x8*x8 - 1
+  */
+  /*
+  IJth(J,8,7) = 2.0*x7;
+  IJth(J,8,8) = 2.0*x8;
+  */
+  J->data[33] = 2.0*x7;
+  rowvals[33] = 7;
+  J->data[37] = 2.0*x8;
+  rowvals[37] = 7;
+
+  
+  /*
+    Lower bounds ( l_i = 1 + x_i >= 0)
+    l_i - 1.0 - x_i
+   */
+
+
+  /*
+  for(i=1;i<=8;i++) {
+    IJth(J,8+i,i)   = -1.0;
+    IJth(J,8+i,8+i) =  1.0;
+  } 
+  */
+
+  J->data[5] = -1.0;
+  rowvals[5] = 8;
+  J->data[12] = -1.0;
+  rowvals[12] = 9;
+  J->data[17] = -1.0;
+  rowvals[17] = 10;
+  J->data[22] = -1.0;
+  rowvals[22] = 11;
+  J->data[25] = -1.0;
+  rowvals[25] = 12;
+  J->data[29] = -1.0;
+  rowvals[29] = 13;
+  J->data[34] = -1.0;
+  rowvals[34] = 14;
+  J->data[38] = -1.0;
+  rowvals[38] = 15;
+
+  J->data[40] = 1.0;
+  rowvals[40] = 8;
+  J->data[41] = 1.0;
+  rowvals[41] = 9;
+  J->data[42] = 1.0;
+  rowvals[42] = 10;
+  J->data[43] = 1.0;
+  rowvals[43] = 11;
+  J->data[44] = 1.0;
+  rowvals[44] = 12;
+  J->data[45] = 1.0;
+  rowvals[45] = 13;
+  J->data[46] = 1.0;
+  rowvals[46] = 14;
+  J->data[47] = 1.0;
+  rowvals[47] = 15;
+
+
+  /*
+    Upper bounds ( u_i = 1 - x_i >= 0)
+    u_i - 1.0 + x_i
+   */
+  /*
+  for(i=1;i<=8;i++) {
+    IJth(J,16+i,i)    = 1.0;
+    IJth(J,16+i,16+i) = 1.0;
+  }
+  */
+
+  J->data[6] = 1.0;
+  rowvals[6] = 16;
+  J->data[13] = 1.0;
+  rowvals[13] = 17;
+  J->data[18] = 1.0;
+  rowvals[18] = 18;
+  J->data[23] = 1.0;
+  rowvals[23] = 19;
+  J->data[26] = 1.0;
+  rowvals[26] = 20;
+  J->data[30] = 1.0;
+  rowvals[30] = 21;
+  J->data[35] = 1.0;
+  rowvals[35] = 22;
+  J->data[39] = 1.0;
+  rowvals[39] = 23;
+
+  J->data[48] = 1.0;
+  rowvals[48] = 16;
+  J->data[49] = 1.0;
+  rowvals[49] = 17;
+  J->data[50] = 1.0;
+  rowvals[50] = 18;
+  J->data[51] = 1.0;
+  rowvals[51] = 19;
+  J->data[52] = 1.0;
+  rowvals[52] = 20;
+  J->data[53] = 1.0;
+  rowvals[53] = 21;
+  J->data[54] = 1.0;
+  rowvals[54] = 22;
+  J->data[55] = 1.0;
+  rowvals[55] = 23;
+
+  return(0);
+
+}
+
+/* 
+ * Print solution
+ */
+
+static void PrintOutput(N_Vector y)
+{
+  int i;
+
+  printf("     l=x+1          x         u=1-x\n");
+  printf("   ----------------------------------\n");
+
+  for(i=1; i<=NVAR; i++) {
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf(" %10.6Lg   %10.6Lg   %10.6Lg\n", 
+           Ith(y,i+NVAR), Ith(y,i), Ith(y,i+2*NVAR));
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf(" %10.6g   %10.6g   %10.6g\n", 
+           Ith(y,i+NVAR), Ith(y,i), Ith(y,i+2*NVAR));
+#else
+    printf(" %10.6g   %10.6g   %10.6g\n", 
+           Ith(y,i+NVAR), Ith(y,i), Ith(y,i+2*NVAR));
+#endif
+
+  }
+
+}
+
+/* 
+ * Print final statistics
+ */
+
+static void PrintFinalStats(void *kmem)
+{
+  long int nni, nfe, nje;
+  int flag;
+  
+  flag = KINGetNumNonlinSolvIters(kmem, &nni);
+  check_flag(&flag, "KINGetNumNonlinSolvIters", 1);
+  flag = KINGetNumFuncEvals(kmem, &nfe);
+  check_flag(&flag, "KINGetNumFuncEvals", 1);
+
+  flag = KINSlsGetNumJacEvals(kmem, &nje);
+  check_flag(&flag, "KINSlsGetNumJacEvals", 1);
+
+  printf("\nFinal Statistics.. \n");
+  printf("nni    = %5ld    nfe   = %5ld \n", nni, nfe);
+  printf("nje    = %5ld \n", nje);
+}
+
+/*
+ * Check function return value...
+ *    opt == 0 means SUNDIALS function allocates memory so check if
+ *             returned NULL pointer
+ *    opt == 1 means SUNDIALS function returns a flag so check if
+ *             flag >= 0
+ *    opt == 2 means function allocates memory so check if returned
+ *             NULL pointer 
+ */
+
+static int check_flag(void *flagvalue, const char *funcname, int opt)
+{
+  int *errflag;
+
+  /* Check if SUNDIALS function returned NULL pointer - no memory allocated */
+  if (opt == 0 && flagvalue == NULL) {
+    fprintf(stderr, 
+            "\nSUNDIALS_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  /* Check if flag < 0 */
+  else if (opt == 1) {
+    errflag = (int *) flagvalue;
+    if (*errflag < 0) {
+      fprintf(stderr,
+              "\nSUNDIALS_ERROR: %s() failed with flag = %d\n\n",
+	      funcname, *errflag);
+      return(1); 
+    }
+  }
+
+  /* Check if function returned NULL pointer - no memory allocated */
+  else if (opt == 2 && flagvalue == NULL) {
+    fprintf(stderr,
+            "\nMEMORY_ERROR: %s() failed - returned NULL pointer\n\n",
+	    funcname);
+    return(1);
+  }
+
+  return(0);
+}
diff --git a/examples/kinsol/serial/kinRoboKin_slu.out b/examples/kinsol/serial/kinRoboKin_slu.out
new file mode 100644
index 0000000..0938b70
--- /dev/null
+++ b/examples/kinsol/serial/kinRoboKin_slu.out
@@ -0,0 +1,32 @@
+
+Robot Kinematics Example
+8 variables; -1 <= x_i <= 1
+KINSOL problem size: 8 + 2*8 = 24 
+
+Initial guess:
+     l=x+1          x         u=1-x
+   ----------------------------------
+          1     0.707107            1
+          1     0.707107            1
+          1     0.707107            1
+          1     0.707107            1
+          1     0.707107            1
+          1     0.707107            1
+          1     0.707107            1
+          1     0.707107            1
+
+Computed solution:
+     l=x+1          x         u=1-x
+   ----------------------------------
+    1.67155     0.671554     0.328446
+    1.74096     0.740955     0.259045
+    1.95189     0.951893    0.0481072
+   0.693569    -0.306431      1.30643
+    1.96381     0.963811    0.0361892
+   0.733413    -0.266587      1.26659
+    1.40464     0.404641     0.595359
+    1.91448     0.914475    0.0855246
+
+Final Statistics.. 
+nni    =     6    nfe   =     7 
+nje    =     6 
diff --git a/examples/nvector/C_openmp/CMakeLists.txt b/examples/nvector/C_openmp/CMakeLists.txt
new file mode 100644
index 0000000..9fca937
--- /dev/null
+++ b/examples/nvector/C_openmp/CMakeLists.txt
@@ -0,0 +1,120 @@
+# ---------------------------------------------------------------
+# $Revision: 4945 $
+# $Date: 2016-09-21 22:15:14 -0700 (Wed, 21 Sep 2016) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for nvector examples
+
+# Add variable nvector_openmp_examples with the names of the nvector examples
+
+SET(nvector_openmp_examples
+  test_nvector_openmp
+)
+
+SET(nvector_examples_dependencies
+  test_nvector
+  sundials_nvector
+)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(. ..)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecopenmp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecopenmp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+
+IF(OPENMP_FOUND)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+  # Use C flags for linker as well.
+  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+ENDIF(OPENMP_FOUND)
+
+# Add the build and install targets for each nvector example
+
+FOREACH(example ${nvector_openmp_examples})
+  ADD_EXECUTABLE(${example} ${example}.c ../test_nvector.c ../../../src/sundials/sundials_nvector.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+
+  SUNDIALS_ADD_TEST(${example}_1000_1_0 ${example} TEST_ARGS 1000 1 0)
+  SUNDIALS_ADD_TEST(${example}_1000_2_0 ${example} TEST_ARGS 1000 2 0)
+  SUNDIALS_ADD_TEST(${example}_1000_4_0 ${example} TEST_ARGS 1000 4 0)
+
+  SUNDIALS_ADD_TEST(${example}_10000_1_0 ${example} TEST_ARGS 10000 1 0)
+  SUNDIALS_ADD_TEST(${example}_10000_2_0 ${example} TEST_ARGS 10000 2 0)
+  SUNDIALS_ADD_TEST(${example}_10000_4_0 ${example} TEST_ARGS 10000 4 0)
+
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ../test_nvector.c ../test_nvector.h ../../../src/sundials/sundials_nvector.c DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/C_openmp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${nvector_openmp_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/C_openmp)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER_LIB "sundials_nvecopenmp")
+  LIST2STRING(nvector_openmp_examples EXAMPLES)
+  LIST2STRING(nvector_examples_dependencies EXAMPLES_DEPENDENCIES)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/C_openmp
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_openmp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/nvector/C_openmp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/C_openmp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/nvector/C_openmp/test_nvector_openmp.c b/examples/nvector/C_openmp/test_nvector_openmp.c
new file mode 100644
index 0000000..5319bcb
--- /dev/null
+++ b/examples/nvector/C_openmp/test_nvector_openmp.c
@@ -0,0 +1,160 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4790 $
+ * $Date: 2016-06-29 14:47:05 -0700 (Wed, 29 Jun 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the testing routine to check the open MP NVECTOR module
+ * implementation. 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sundials/sundials_types.h>
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_math.h>
+#include "test_nvector.h"
+
+
+/* ----------------------------------------------------------------------
+ * Main NVector Testing Routine
+ * --------------------------------------------------------------------*/
+int main(int argc, char *argv[]) 
+{
+  int      fails = 0;            /* counter for test failures */
+  long int veclen;               /* vector length             */
+  N_Vector W, X, Y, Z;           /* test vectors              */
+  int      num_threads;
+  int      print_timing;
+
+  /* check input and set vector length */
+  if (argc < 4){
+    printf("ERROR: THREE (3) arguments required: <vector length> <number of threads> <print timing>\n");
+    return(-1);
+  }
+
+  veclen = atol(argv[1]); 
+  if (veclen <= 0) {
+    printf("ERROR: length of vector must be a positive integer \n");
+    return(-1); 
+  }
+
+  num_threads = atoi(argv[2]);
+  if (num_threads <= 0) {
+    printf("ERROR: numbber of threads must be a positive integer \n");
+    return(-1); 
+  }
+
+  print_timing = atoi(argv[3]);
+  SetTiming(print_timing);
+
+  printf("\nRunning with vector length %ld \n \n", veclen);
+  printf("\nRunning with number of threads %d \n \n", num_threads);
+
+  /* Create vectors */
+  W = N_VNewEmpty_OpenMP(veclen, num_threads);
+  X = N_VNew_OpenMP(veclen, num_threads);
+  Y = N_VNew_OpenMP(veclen, num_threads);
+  Z = N_VNew_OpenMP(veclen, num_threads);
+
+  if(N_VGetVectorID(W) == SUNDIALS_NVEC_OPENMP) {
+    /*printf("Testing OpenMP variant of N_Vector...\n");*/
+  }
+  
+  /* NVector Tests */
+  fails += Test_N_VSetArrayPointer(W, veclen, 0);
+  fails += Test_N_VGetArrayPointer(X, veclen, 0);
+  fails += Test_N_VLinearSum(X, Y, Z, veclen, 0);
+  fails += Test_N_VConst(X, veclen, 0);
+  fails += Test_N_VProd(X, Y, Z, veclen, 0);
+  fails += Test_N_VDiv(X, Y, Z, veclen, 0);
+  fails += Test_N_VScale(X, Z, veclen, 0);
+  fails += Test_N_VAbs(X, Z, veclen, 0);
+  fails += Test_N_VInv(X, Z, veclen, 0);
+  fails += Test_N_VAddConst(X, Z, veclen, 0);
+  fails += Test_N_VDotProd(X, Y, veclen, veclen, 0);
+  fails += Test_N_VMaxNorm(X, veclen, 0);
+  fails += Test_N_VWrmsNorm(X, Y, veclen, 0);
+  fails += Test_N_VWrmsNormMask(X, Y, Z, veclen, veclen, 0);
+  fails += Test_N_VMin(X, veclen, 0);
+  fails += Test_N_VWL2Norm(X, Y, veclen, veclen, 0);
+  fails += Test_N_VL1Norm(X, veclen, veclen, 0);
+  fails += Test_N_VCompare(X, Z, veclen, 0);
+  fails += Test_N_VInvTest(X, Z, veclen, 0);
+  fails += Test_N_VConstrMask(X, Y, Z, veclen, 0);
+  fails += Test_N_VMinQuotient(X, Y, veclen, 0);
+  fails += Test_N_VCloneVectorArray(5, X, veclen, 0);
+  fails += Test_N_VCloneEmptyVectorArray(5, X, 0);
+  fails += Test_N_VCloneEmpty(X, 0);
+  fails += Test_N_VClone(X, veclen, 0);
+
+  /* Free vectors */
+  N_VDestroy_OpenMP(W);
+  N_VDestroy_OpenMP(X);
+  N_VDestroy_OpenMP(Y);
+  N_VDestroy_OpenMP(Z);
+
+  /* Print results */
+  if (fails) {
+    printf("FAIL: NVector module failed %i tests \n \n", fails);
+  } else {
+    printf("SUCCESS: NVector module passed all tests \n \n");
+  }
+
+  return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * Check vector
+ * --------------------------------------------------------------------*/
+int check_ans(realtype ans, N_Vector X, long int local_length)
+{
+  int      failure = 0;
+  long int i;
+  realtype *Xdata;
+  
+  Xdata = N_VGetArrayPointer(X);
+
+  /* check vector data */
+  for(i=0; i < local_length; i++){
+    failure += FNEQ(Xdata[i], ans);
+  }
+
+  if (failure > ZERO)
+    return(1);
+  else
+    return(0);
+}
+
+booleantype has_data(N_Vector X)
+{
+  realtype *Xdata = N_VGetArrayPointer(X);
+  if (Xdata == NULL)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+void set_element(N_Vector X, long int i, realtype val)
+{
+  NV_Ith_OMP(X,i) = val;
+}
+ 
+realtype get_element(N_Vector X, long int i)
+{
+  return NV_Ith_OMP(X,i);
+}
+
diff --git a/examples/nvector/parallel/CMakeLists.txt b/examples/nvector/parallel/CMakeLists.txt
new file mode 100644
index 0000000..4f37514
--- /dev/null
+++ b/examples/nvector/parallel/CMakeLists.txt
@@ -0,0 +1,131 @@
+# ---------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for nvector examples
+
+# Add variable nvector_parallel_examples with the names of the nvector examples
+
+SET(nvector_parallel_examples
+  test_nvector_mpi
+)
+
+SET(nvector_examples_dependencies
+  test_nvector
+  sundials_nvector
+)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(. ..)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecparallel_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecparallel_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+  TARGET_LINK_LIBRARIES(${example} MPI_LIBRARIES)
+ENDIF(MPI_MPICC)
+
+# Add the build and install targets for each nvector example
+
+FOREACH(example ${nvector_parallel_examples})
+
+  ADD_EXECUTABLE(${example} ${example}.c ../test_nvector.c ../../../src/sundials/sundials_nvector.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+
+  # Run sequentially
+  SUNDIALS_ADD_TEST("${example}" ${example})
+
+  # Run sequentially with arguments
+  SUNDIALS_ADD_TEST("${example}_1000_0" ${example} TEST_ARGS 1000 0)
+
+  # Run in parallel on 4 procs
+  SUNDIALS_ADD_TEST("${example}_4" ${example} MPI_NPROCS 4)
+  
+  # Parallel with additional arguments and supplying an answer file
+  SUNDIALS_ADD_TEST("${example}_4_1000_0" ${example} MPI_NPROCS 4 TEST_ARGS 1000 0 ANSWER_FILE ${example})
+
+  # Specify floating point precision and integer percentage for comparison
+  SUNDIALS_ADD_TEST("${example}_precision" ${example} MPI_NPROCS 4 TEST_ARGS 1000 0 ANSWER_FILE ${example}
+    FLOAT_PRECISION 5 INTEGER_PERCENTAGE 0)
+  
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ../test_nvector.c ../test_nvector.h ../../../src/sundials/sundials_nvector.c DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parallel)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${nvector_parallel_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parallel)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER_LIB "sundials_nvecparallel")
+  LIST2STRING(nvector_parallel_examples EXAMPLES)
+  LIST2STRING(nvector_examples_dependencies EXAMPLES_DEPENDENCIES)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parallel_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/parallel/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/nvector/parallel/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parallel
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parallel_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/parallel/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/nvector/parallel/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parallel
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/nvector/parallel/test_nvector_mpi.c b/examples/nvector/parallel/test_nvector_mpi.c
new file mode 100644
index 0000000..c6535f2
--- /dev/null
+++ b/examples/nvector/parallel/test_nvector_mpi.c
@@ -0,0 +1,153 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4790 $
+ * $Date: 2016-06-29 14:47:05 -0700 (Wed, 29 Jun 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the testing routine to check the NVECTOR Parallel module 
+ * implementation. 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sundials/sundials_types.h>
+#include <nvector/nvector_parallel.h>
+#include <sundials/sundials_math.h>
+#include "test_nvector.h"
+
+#include <mpi.h>
+
+
+/* local vector length */
+#define VECLEN 10000
+
+/* ----------------------------------------------------------------------
+ * Main NVector Testing Routine
+ * --------------------------------------------------------------------*/
+int main(int argc, char *argv[]) 
+{
+  int      fails = 0;                   /* counter for test failures */
+  long int local_length, global_length; /* vector lengths            */
+  N_Vector W, X, Y, Z;                  /* test vectors              */
+  MPI_Comm comm;                        /* MPI Communicator          */
+  int      nprocs, myid;                /* Number of procs, proc id  */
+
+  /* Get processor number and total number of processes */
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &nprocs);
+  MPI_Comm_rank(comm, &myid);
+
+  /* set local and global lengths */
+  local_length = VECLEN;
+  global_length = nprocs*local_length;
+
+  /* Create vectors */
+  W = N_VNewEmpty_Parallel(comm, local_length, global_length);
+  X = N_VNew_Parallel(comm, local_length, global_length);
+  Y = N_VNew_Parallel(comm, local_length, global_length);
+  Z = N_VNew_Parallel(comm, local_length, global_length);
+
+  if(N_VGetVectorID(W) == SUNDIALS_NVEC_PARALLEL && myid == 0) {
+    /*printf("Testing parallel (MPI) variant of N_Vector...\n");*/
+  }
+
+  /* NVector Test */
+  fails += Test_N_VSetArrayPointer(W, local_length, myid);
+  fails += Test_N_VGetArrayPointer(X, local_length, myid);
+  fails += Test_N_VLinearSum(X, Y, Z, local_length, myid);
+  fails += Test_N_VConst(X, local_length, myid);
+  fails += Test_N_VProd(X, Y, Z, local_length, myid);
+  fails += Test_N_VDiv(X, Y, Z, local_length, myid);
+  fails += Test_N_VScale(X, Z, local_length, myid);
+  fails += Test_N_VAbs(X, Z, local_length, myid);
+  fails += Test_N_VInv(X, Z, local_length, myid);
+  fails += Test_N_VAddConst(X, Z, local_length, myid);
+  fails += Test_N_VDotProd(X, Y, local_length, global_length, myid);
+  fails += Test_N_VMaxNorm(X, local_length, myid);
+  fails += Test_N_VWrmsNorm(X, Y, local_length, myid);
+  fails += Test_N_VWrmsNormMask(X, Y, Z, local_length, global_length, myid);
+  fails += Test_N_VMin(X, local_length, myid);
+  fails += Test_N_VWL2Norm(X, Y, local_length, global_length, myid);
+  fails += Test_N_VL1Norm(X, local_length, global_length, myid);
+  fails += Test_N_VCompare(X, Z, local_length, myid);
+  fails += Test_N_VInvTest(X, Z, local_length, myid);
+  fails += Test_N_VConstrMask(X, Y, Z, local_length, myid);
+  fails += Test_N_VMinQuotient(X, Y, local_length, myid);
+  fails += Test_N_VCloneVectorArray(5, X, local_length, myid);
+  fails += Test_N_VCloneEmptyVectorArray(5, X, myid);
+  fails += Test_N_VCloneEmpty(X, myid);
+  fails += Test_N_VClone(X, local_length, myid);
+
+  /* Free vectors */
+  N_VDestroy_Parallel(W);
+  N_VDestroy_Parallel(X);
+  N_VDestroy_Parallel(Y);
+  N_VDestroy_Parallel(Z);
+
+  /* Print result */
+  if (fails) {
+    printf("FAIL: NVector module failed %i tests, Proc %d \n \n", fails, myid);
+  } else {
+     if(myid == 0) {
+	printf("SUCCESS: NVector module passed all tests, Proc %d \n \n",myid);
+     }
+  }
+  
+  MPI_Finalize();
+  return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * Check vector
+ * --------------------------------------------------------------------*/
+int check_ans(realtype ans, N_Vector X, long int local_length)
+{
+  int      failure = 0;
+  long int i;
+  realtype *Xdata;
+  
+  Xdata = N_VGetArrayPointer(X);
+
+  /* check vector data */
+  for(i=0; i < local_length; i++){
+    failure += FNEQ(Xdata[i], ans);
+  }
+
+  if (failure > ZERO)
+    return(1);
+  else
+    return(0);
+}
+
+booleantype has_data(N_Vector X)
+{
+  realtype *Xdata = N_VGetArrayPointer(X);
+  if (Xdata == NULL)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+void set_element(N_Vector X, long int i, realtype val)
+{
+  NV_Ith_P(X,i) = val;    
+}
+
+realtype get_element(N_Vector X, long int i)
+{
+  return NV_Ith_P(X,i);    
+}
diff --git a/examples/nvector/parhyp/CMakeLists.txt b/examples/nvector/parhyp/CMakeLists.txt
new file mode 100644
index 0000000..ad687bb
--- /dev/null
+++ b/examples/nvector/parhyp/CMakeLists.txt
@@ -0,0 +1,136 @@
+# ---------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for nvector examples
+
+# Add variable nvector_parhyp_examples with the names of the nvector examples
+
+SET(nvector_parhyp_examples
+  test_nvector_parhyp
+)
+
+SET(nvector_examples_dependencies
+  test_nvector
+  sundials_nvector
+)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(. ..)
+INCLUDE_DIRECTORIES(${HYPRE_INC_PATH})
+INCLUDE_DIRECTORIES(${HYPRE_INC_DIR})
+INCLUDE_DIRECTORIES(${HYPRE_LIB_DIR})
+  
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecparhyp_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecparhyp_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+SET(SUNDIALS_LIBS ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+SET(HYPRE_LIBS ${HYPRE_LIBRARIES})
+
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+  TARGET_LINK_LIBRARIES(${example} MPI_LIBRARIES)
+ENDIF(MPI_MPICC)
+
+# Add the build and install targets for each nvector example
+
+FOREACH(example ${nvector_parhyp_examples})
+
+  ADD_EXECUTABLE(${example} ${example}.c ../test_nvector.c ../../../src/sundials/sundials_nvector.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+
+  # Run sequentially
+  SUNDIALS_ADD_TEST("${example}" ${example})
+
+  # Run sequentially with arguments
+  SUNDIALS_ADD_TEST("${example}_10000_0" ${example} TEST_ARGS 10000 0)
+
+  # Run in parhyp on 4 procs
+  SUNDIALS_ADD_TEST("${example}_4" ${example} MPI_NPROCS 4)
+  
+  # parhyp with additional arguments and supplying an answer file
+  SUNDIALS_ADD_TEST("${example}_4_10000_0" ${example} MPI_NPROCS 4 TEST_ARGS 10000 0 ANSWER_FILE ${example})
+
+  # Specify floating point precision and integer percentage for comparison
+  SUNDIALS_ADD_TEST("${example}_precision" ${example} MPI_NPROCS 4 TEST_ARGS 10000 0 ANSWER_FILE ${example}
+    FLOAT_PRECISION 5 INTEGER_PERCENTAGE 0)
+
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  
+  TARGET_LINK_LIBRARIES(${example} ${HYPRE_LIBRARIES})
+  
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ../test_nvector.c ../test_nvector.h ../../../src/sundials/sundials_nvector.c DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parhyp)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${nvector_parhyp_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parhyp)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER_LIB "sundials_nvecparhyp")
+  LIST2STRING(nvector_parhyp_examples EXAMPLES)
+  LIST2STRING(nvector_examples_dependencies EXAMPLES_DEPENDENCIES)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_parhyp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/parhyp/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/nvector/parhyp/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parhyp
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_parhyp_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/parhyp/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/nvector/parhyp/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/parhyp
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/nvector/parhyp/test_nvector_parhyp.c b/examples/nvector/parhyp/test_nvector_parhyp.c
new file mode 100644
index 0000000..adf9ee3
--- /dev/null
+++ b/examples/nvector/parhyp/test_nvector_parhyp.c
@@ -0,0 +1,315 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4137 $
+ * $Date: 2014-06-15 12:26:15 -0700 (Sun, 15 Jun 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the testing routine to check the NVECTOR Parallel module 
+ * implementation. 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sundials/sundials_types.h>
+#include <nvector/nvector_parhyp.h>
+#include <sundials/sundials_math.h>
+#include "test_nvector.h"
+
+#include <mpi.h>
+#include <omp.h>
+
+#if defined( SUNDIALS_HAVE_POSIX_TIMERS) && defined(_POSIX_TIMERS)
+#include <time.h>
+#include <unistd.h>
+#endif
+
+/* default local vector length */
+#define VECLEN 5000
+
+
+static int Test_N_VMake(HYPRE_ParVector W, int myid);
+static int Test_N_VGetVectorID(N_Vector W, int myid);
+
+/* ----------------------------------------------------------------------
+ * Main NVector Testing Routine
+ * --------------------------------------------------------------------*/
+int main(int argc, char *argv[]) 
+{
+  int      fails = 0;                   /* counter for test failures */
+  long int local_length, global_length; /* vector lengths            */
+  N_Vector W;
+  N_Vector X, Y, Z;                     /* test vectors              */
+  MPI_Comm comm;                        /* MPI Communicator          */
+  int      nprocs, myid;                /* Number of procs, proc id  */
+  long int veclen;                      /* vector length             */
+  int      print_timing;
+  HYPRE_Int *partitioning;      /* Vector Partitioning */
+  HYPRE_ParVector Xhyp;         /* Instantiate hypre parallel vector */
+
+  /* check input and set vector length */
+  if (argc < 3) {
+    SetTiming(0);
+  } else {
+   print_timing = atoi(argv[2]);
+   SetTiming(print_timing);
+  }
+  
+  if (argc < 2) {
+    veclen = VECLEN;
+  } else {
+    veclen = atol(argv[1]); 
+    if (veclen <= 0) {
+      printf("ERROR: length of vector must be a positive integer \n");
+      return(-1); 
+    }
+  }
+
+  /* printf("\nRunning with vector length %ld \n \n", veclen); */
+  /* Get processor number and total number of processes */
+  MPI_Init(&argc, &argv);
+  /* omp_set_num_threads(4); */
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &nprocs);
+  MPI_Comm_rank(comm, &myid);
+
+  /* set partitioning */
+  local_length = veclen;
+  global_length = nprocs*local_length;
+  if(HYPRE_AssumedPartitionCheck()) {
+    partitioning = (HYPRE_Int*) malloc(2*sizeof(HYPRE_Int));
+    partitioning[0] = myid*local_length;
+    partitioning[1] = (myid+1)*local_length;
+  } else {
+    partitioning = (HYPRE_Int*) malloc((nprocs+1)*sizeof(HYPRE_Int));
+    if (veclen <= 0) {
+      printf("Using global partition.\n");
+      printf("I don't do this stuff. Now exiting...\n");
+      return -1;
+    }
+  }
+  /* Create template hypre vector */
+  HYPRE_ParVectorCreate(comm, global_length, partitioning, &Xhyp);
+  HYPRE_ParVectorInitialize(Xhyp);
+
+  /* Create empty vector */
+  W = N_VNewEmpty_ParHyp(comm, local_length, global_length);
+
+  /* NVector Test */
+
+  /* Hypre specific tests */
+  fails += Test_N_VMake(Xhyp, myid);
+
+  /* Create hypre vector wrapper */
+  X = N_VMake_ParHyp(Xhyp);
+
+  /* Memory allocation tests */
+  fails += Test_N_VCloneEmpty(X, myid);
+  fails += Test_N_VClone(X, local_length, myid);
+  fails += Test_N_VCloneEmptyVectorArray(5, X, myid);
+  fails += Test_N_VCloneVectorArray(5, X, local_length, myid);
+
+  /* Create a couple of more vectors by cloning X */
+  Y = N_VClone(X);
+  Z = N_VClone(X);
+  
+  /* Skipped tests */
+  /* Accessing HYPRE vector raw data is not allowed from N_Vector interface */
+  /* fails += Test_N_VSetArrayPointer(W, local_length, myid); */
+  /* fails += Test_N_VGetArrayPointer(X, local_length, myid); */
+  
+  /* N_Vector interface tests */
+  fails += Test_N_VGetVectorID(W, myid);
+  fails += Test_N_VConst(X, local_length, myid);
+  fails += Test_N_VLinearSum(X, Y, Z, local_length, myid);
+  fails += Test_N_VProd(X, Y, Z, local_length, myid);
+  fails += Test_N_VDiv(X, Y, Z, local_length, myid);
+  fails += Test_N_VScale(X, Z, local_length, myid);
+  fails += Test_N_VAbs(X, Z, local_length, myid);
+  fails += Test_N_VInv(X, Z, local_length, myid);
+  fails += Test_N_VAddConst(X, Z, local_length, myid);
+  fails += Test_N_VDotProd(X, Y, local_length, global_length, myid);
+  fails += Test_N_VMaxNorm(X, local_length, myid);
+  fails += Test_N_VWrmsNorm(X, Y, local_length, myid);
+  fails += Test_N_VWrmsNormMask(X, Y, Z, local_length, global_length, myid);
+  fails += Test_N_VMin(X, local_length, myid);
+  fails += Test_N_VWL2Norm(X, Y, local_length, global_length, myid);
+  fails += Test_N_VL1Norm(X, local_length, global_length, myid);
+  fails += Test_N_VCompare(X, Z, local_length, myid);
+  fails += Test_N_VInvTest(X, Z, local_length, myid);
+  fails += Test_N_VConstrMask(X, Y, Z, local_length, myid);
+  fails += Test_N_VMinQuotient(X, Y, local_length, myid);
+
+  /* Free vectors */
+  N_VDestroy_ParHyp(W);
+  N_VDestroy_ParHyp(X);
+  N_VDestroy_ParHyp(Y);
+  N_VDestroy_ParHyp(Z);
+  
+  /* Print result */
+  if (fails) {
+    printf("FAIL: NVector module failed %i tests, Proc %d \n \n", fails, myid);
+  } else {
+     if(myid == 0) {
+       printf("SUCCESS: NVector module passed all tests, Proc %d \n \n",myid);
+     }
+  }
+
+  /* Free hypre template vector */
+  HYPRE_ParVectorDestroy(Xhyp);
+  
+  MPI_Finalize();
+  return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * Check vector
+ * 
+ * Checks if all elements of vector X are set to value ans. 
+ * --------------------------------------------------------------------*/
+int check_ans(realtype ans, N_Vector X, long int local_length)
+{
+  int      failure = 0;
+  long int i;
+  hypre_ParVector *Xvec = N_VGetVector_ParHyp(X);
+  realtype *Xdata = Xvec == NULL ? NULL : hypre_VectorData(hypre_ParVectorLocalVector(Xvec));
+  
+  /* check vector data */
+  for(i=0; i < local_length; i++) {
+    failure += FNEQ(Xdata[i], ans);
+  }
+
+  if (failure > ZERO)
+    return(1);
+  else
+    return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * has_data
+ *
+ * Utility that drills down to the hypre vector local data block and 
+ * checks if it is allocated. Does not verify the size of the block.
+ * --------------------------------------------------------------------*/
+booleantype has_data(N_Vector X)
+{
+  hypre_ParVector *Xvec = N_VGetVector_ParHyp(X);
+  realtype *Xdata = Xvec == NULL ? NULL : hypre_VectorData(hypre_ParVectorLocalVector(Xvec));
+  if (Xdata == NULL)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+
+/* ----------------------------------------------------------------------
+ * set_element
+ *
+ * Sets single element in hypre vector by accessing its raw block. 
+ * Probably not the most efficient way to set the entire vector.
+ * --------------------------------------------------------------------*/
+void set_element(N_Vector X, long int i, realtype val)
+{
+  hypre_ParVector *Xvec = N_VGetVector_ParHyp(X);
+  realtype *Xdata = hypre_VectorData(hypre_ParVectorLocalVector(Xvec));
+  Xdata[i] = val;
+}
+ 
+/* ----------------------------------------------------------------------
+ * get_element
+ *
+ * Reads single element from hypre vector by accessing its raw block. 
+ * Probably not the most efficient way to get the vector values.
+ * --------------------------------------------------------------------*/
+realtype get_element(N_Vector X, long int i)
+{
+  hypre_ParVector *Xvec = N_VGetVector_ParHyp(X);
+  const realtype *Xdata = hypre_VectorData(hypre_ParVectorLocalVector(Xvec));
+  return Xdata[i];
+}
+
+/* ----------------------------------------------------------------------
+ * N_VGetVectorID Test
+ *
+ * --------------------------------------------------------------------*/
+int Test_N_VGetVectorID(N_Vector v, int myid)
+{
+  N_Vector_ID id = N_VGetVectorID(v);
+  if (id == SUNDIALS_NVEC_PARHYP) {
+    if (myid == 0) {
+      printf("    PASSED test -- N_VGetVectorID \n");
+      /* PRINT_TIME("    N_VMake Time: %22.15e \n \n", stop_time - start_time); */
+    }
+    return (0);
+  } else {
+    printf(">>> FAILED test -- N_VGetVectorID, Proc %d \n", myid);
+    printf("    Unrecognized vector type %d \n \n", id);
+    return (1);    
+  }
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VMake Test
+ *
+ * NOTE: This routine depends on N_VConst to check vector data.
+ * --------------------------------------------------------------------*/
+int Test_N_VMake(HYPRE_ParVector W, int myid)
+{
+  int failure;
+  /* double   start_time, stop_time; */
+  N_Vector X;
+  int local_length = hypre_ParVectorLastIndex(W) 
+                     - hypre_ParVectorFirstIndex(W) + 1;
+
+  /* clone vector */
+  /* start_time = get_time(); */  
+  X = N_VMake_ParHyp(W);
+  /* stop_time = get_time();  */
+
+  /* check cloned vector */
+  if (X == NULL) {
+    printf(">>> FAILED test -- N_VMake, Proc %d \n", myid);
+    printf("    After N_VMakeEmpty, X == NULL \n \n");
+    return(1);
+  } 
+
+  /* check cloned vector data */
+  if (!has_data(X)) {
+    printf(">>> FAILED test -- N_VMake, Proc %d \n", myid);
+    printf("    Vector data == NULL \n \n");
+    N_VDestroy(X);
+    return(1);
+  }    
+
+  N_VConst(ONE,X);
+  failure = check_ans(ONE, X, local_length);
+  if (failure) {
+    printf(">>> FAILED test -- N_VMake, Proc %d \n", myid);
+    printf("    Failed N_VConst check \n \n");
+    N_VDestroy(X);
+    return(1);
+  }    
+
+  N_VDestroy(X); 
+
+  if (myid == 0) {
+    printf("    PASSED test -- N_VMake \n");
+    /* PRINT_TIME("    N_VMake Time: %22.15e \n \n", stop_time - start_time); */
+  }
+
+  return(0);
+}
+
diff --git a/examples/nvector/petsc/CMakeLists.txt b/examples/nvector/petsc/CMakeLists.txt
new file mode 100644
index 0000000..2ced736
--- /dev/null
+++ b/examples/nvector/petsc/CMakeLists.txt
@@ -0,0 +1,133 @@
+# ---------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for nvector examples
+
+# Add variable nvector_petsc_examples with the names of the nvector examples
+
+SET(nvector_petsc_examples
+  test_nvector_petsc
+)
+
+SET(nvector_examples_dependencies
+  test_nvector
+  sundials_nvector
+)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(. ..)
+INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIR})
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecpetsc_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecpetsc_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+  TARGET_LINK_LIBRARIES(${example} MPI_LIBRARIES)
+ENDIF(MPI_MPICC)
+
+# Add the build and install targets for each nvector example
+
+FOREACH(example ${nvector_petsc_examples})
+
+  ADD_EXECUTABLE(${example} ${example}.c ../test_nvector.c ../../../src/sundials/sundials_nvector.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+
+  # Run sequentially
+  SUNDIALS_ADD_TEST("${example}" ${example})
+
+  # Run sequentially with arguments
+  SUNDIALS_ADD_TEST("${example}_1000_0" ${example} TEST_ARGS 1000 0)
+
+  # Run in petsc on 4 procs
+  SUNDIALS_ADD_TEST("${example}_4" ${example} MPI_NPROCS 4)
+  
+  # Parallel with additional arguments and supplying an answer file
+  SUNDIALS_ADD_TEST("${example}_4_1000_0" ${example} MPI_NPROCS 4 TEST_ARGS 1000 0 ANSWER_FILE ${example})
+
+  # Specify floating point precision and integer percentage for comparison
+  SUNDIALS_ADD_TEST("${example}_precision" ${example} MPI_NPROCS 4 TEST_ARGS 1000 0 ANSWER_FILE ${example}
+    FLOAT_PRECISION 5 INTEGER_PERCENTAGE 0)
+  
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+  TARGET_LINK_LIBRARIES(${example} ${PETSC_LIBRARIES})
+
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ../test_nvector.c ../test_nvector.h ../../../src/sundials/sundials_nvector.c DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/petsc)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${nvector_petsc_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/petsc)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER_LIB "sundials_nvecpetsc")
+  LIST2STRING(nvector_petsc_examples EXAMPLES)
+  LIST2STRING(nvector_examples_dependencies EXAMPLES_DEPENDENCIES)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_petsc_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/petsc/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/nvector/petsc/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/petsc
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_petsc_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/petsc/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/nvector/petsc/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/petsc
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/nvector/petsc/test_nvector_petsc.c b/examples/nvector/petsc/test_nvector_petsc.c
new file mode 100644
index 0000000..513b522
--- /dev/null
+++ b/examples/nvector/petsc/test_nvector_petsc.c
@@ -0,0 +1,239 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4137 $
+ * $Date: 2014-06-15 12:26:15 -0700 (Sun, 15 Jun 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the testing routine to check the NVECTOR Parallel module 
+ * implementation. 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <petscvec.h>
+#include <sundials/sundials_types.h>
+#include <nvector/nvector_petsc.h>
+#include <sundials/sundials_math.h>
+#include "test_nvector.h"
+
+#include <mpi.h>
+
+
+/* local vector length */
+#define VECLEN 10000
+
+static int Test_N_VMake(Vec* W, int myid);
+
+/* ----------------------------------------------------------------------
+ * Main NVector Testing Routine
+ * --------------------------------------------------------------------*/
+int main(int argc, char *argv[]) 
+{
+  int      fails = 0;                   /* counter for test failures */
+  long int local_length, global_length; /* vector lengths            */
+  N_Vector W, X, Y, Z;                  /* test vectors              */
+  MPI_Comm comm;                        /* MPI Communicator          */
+  int      nprocs, myid;                /* Number of procs, proc id  */
+  Vec xvec;                             /* PETSc vector              */
+  PetscErrorCode ierr;                  /* PETSc error code          */
+
+  /* Get processor number and total number of processes */
+  MPI_Init(&argc, &argv);
+  comm = MPI_COMM_WORLD;
+  MPI_Comm_size(comm, &nprocs);
+  MPI_Comm_rank(comm, &myid);
+  ierr = PetscInitializeNoArguments();
+  CHKERRQ(ierr);
+  
+  /* set local and global lengths */
+  local_length = VECLEN;
+  global_length = nprocs*local_length;
+  
+  /* Allocate and initialize PETSc vector */
+  VecCreate(comm, &xvec);
+  VecSetSizes(xvec, local_length, global_length);
+  VecSetFromOptions(xvec);
+  
+  /* Create vectors */
+  W = N_VNewEmpty_Petsc(comm, local_length, global_length);
+  if(N_VGetVectorID(W) == SUNDIALS_NVEC_PETSC && myid == 0) {
+    /*printf("Testing PETSc vector wrapper...\n");*/
+  }
+    
+
+  /* NVector Test */
+
+  /* PETSc specific tests */
+  fails += Test_N_VMake(&xvec, myid);
+  
+  X = N_VMake_Petsc(&xvec);
+
+  /* Memory allocation tests */
+  fails += Test_N_VCloneEmpty(X, myid);
+  fails += Test_N_VClone(X, local_length, myid);
+  fails += Test_N_VCloneEmptyVectorArray(5, X, myid);
+  fails += Test_N_VCloneVectorArray(5, X, local_length, myid);
+
+  Y = N_VClone_Petsc(X);
+  Z = N_VClone_Petsc(X);
+
+  /* Skipped tests */
+  /* fails += Test_N_VSetArrayPointer(W, local_length, myid); */
+  /* fails += Test_N_VGetArrayPointer(X, local_length, myid); */
+  
+  /* Vector operations tests */
+  fails += Test_N_VConst(X, local_length, myid);
+  fails += Test_N_VLinearSum(X, Y, Z, local_length, myid);
+  fails += Test_N_VProd(X, Y, Z, local_length, myid);
+  fails += Test_N_VDiv(X, Y, Z, local_length, myid);
+  fails += Test_N_VScale(X, Z, local_length, myid);
+  fails += Test_N_VAbs(X, Z, local_length, myid);
+  fails += Test_N_VInv(X, Z, local_length, myid);
+  fails += Test_N_VAddConst(X, Z, local_length, myid);
+  fails += Test_N_VDotProd(X, Y, local_length, global_length, myid);
+  fails += Test_N_VMaxNorm(X, local_length, myid);
+  fails += Test_N_VWrmsNorm(X, Y, local_length, myid);
+  fails += Test_N_VWrmsNormMask(X, Y, Z, local_length, global_length, myid);
+  fails += Test_N_VMin(X, local_length, myid);
+  fails += Test_N_VWL2Norm(X, Y, local_length, global_length, myid);
+  fails += Test_N_VL1Norm(X, local_length, global_length, myid);
+  fails += Test_N_VCompare(X, Z, local_length, myid);
+  fails += Test_N_VInvTest(X, Z, local_length, myid);
+  fails += Test_N_VConstrMask(X, Y, Z, local_length, myid);
+  fails += Test_N_VMinQuotient(X, Y, local_length, myid);
+
+  /* Free vectors */
+  N_VDestroy_Petsc(W);
+  N_VDestroy_Petsc(X);
+  N_VDestroy_Petsc(Y);
+  N_VDestroy_Petsc(Z);
+
+  /* Print result */
+  if (fails) {
+    printf("FAIL: NVector module failed %i tests, Proc %d \n \n", fails, myid);
+  } else {
+     if(myid == 0) {
+       printf("SUCCESS: NVector module passed all tests, Proc %d \n \n",myid);
+     }
+  }
+  
+  ierr = PetscFinalize();
+  CHKERRQ(ierr);
+  MPI_Finalize();
+  return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * Check vector
+ * --------------------------------------------------------------------*/
+int check_ans(realtype ans, N_Vector X, long int local_length)
+{
+  int failure = 0;
+  long int i;
+  Vec *xv = N_VGetVector_Petsc(X);
+  PetscScalar *a;
+
+  failure = 0;
+  /* check PETSc vector */
+  VecGetArray(*xv, &a);
+  for (i = 0; i < local_length; ++i){
+    failure += FNEQ(a[i], ans);
+  }
+  VecRestoreArray(*xv, &a);
+
+  if (failure > ZERO)
+    return(1);
+  else
+    return(0);
+}
+
+booleantype has_data(N_Vector X)
+{
+  if(N_VGetVector_Petsc(X) == NULL)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+void set_element(N_Vector X, long int i, realtype val)
+{
+  PetscScalar *a;
+  Vec *xv = N_VGetVector_Petsc(X);
+  
+  VecGetArray(*xv, &a);
+  a[i] = val;
+  VecRestoreArray(*xv, &a);
+}
+
+realtype get_element(N_Vector X, long int i)
+{
+  PetscScalar *a;
+  Vec *xv = N_VGetVector_Petsc(X);
+  realtype val;
+  
+  VecGetArray(*xv, &a);
+  val = a[i];
+  VecRestoreArray(*xv, &a);
+  
+  return val;    
+}
+
+/* ----------------------------------------------------------------------
+ * N_VMake Test
+ *
+ * NOTE: This routine depends on N_VConst to check vector data.
+ * --------------------------------------------------------------------*/
+static int Test_N_VMake(Vec* W, int myid)
+{
+  /* double   start_time, stop_time; */
+  N_Vector X;
+
+  /* clone vector */
+  /* start_time = get_time(); */  
+  X = N_VMake_Petsc(W);
+  /* stop_time = get_time();  */
+
+  /* check vector wrapper */
+  if (X == NULL) {
+    printf(">>> FAILED test -- N_VMake, Proc %d \n", myid);
+    printf("    After N_VMake, X == NULL \n \n");
+    return(1);
+  } 
+
+  /* check underlying PETSc vector is correct */
+  if (*W != *N_VGetVector_Petsc(X)) {
+    printf(">>> FAILED test -- N_VMake, Proc %d \n", myid);
+    printf("    PETSc not wrapped correctly \n \n");
+    N_VDestroy(X);
+    return(1);
+  }    
+
+  N_VDestroy(X); 
+
+  if (*W == NULL) {
+    printf(">>> FAILED test -- N_VMake, Proc %d \n", myid);
+    printf("    Destroying wrapper destroyed underlying PETSc vector \n \n");
+    return(1);
+  }    
+
+  if (myid == 0) {
+    printf("    PASSED test -- N_VMake \n");
+    /* PRINT_TIME("    N_VMake Time: %22.15e \n \n", stop_time - start_time); */
+  }
+
+  return(0);
+}
+
diff --git a/examples/nvector/pthreads/CMakeLists.txt b/examples/nvector/pthreads/CMakeLists.txt
new file mode 100644
index 0000000..946d0d3
--- /dev/null
+++ b/examples/nvector/pthreads/CMakeLists.txt
@@ -0,0 +1,124 @@
+# ---------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for nvector examples
+
+# Add variable nvector_pthreads_examples with the names of the nvector examples
+
+SET(nvector_pthreads_examples
+  test_nvector_pthreads
+)
+
+SET(nvector_examples_dependencies
+  test_nvector
+  sundials_nvector
+)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(. ..)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecpthreads_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecpthreads_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+
+# Add the build and install targets for each nvector example
+
+FOREACH(example ${nvector_pthreads_examples})
+
+  IF(WIN32)
+    # This is used to get around DLL linkage issue since we are
+    # manually including sundials_nvector.c here, which is normally in
+    # a library that is included.  If this is not set build system
+    # thinks nvector is externally linked.
+    ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+  ENDIF(WIN32)
+
+  ADD_EXECUTABLE(${example} ${example}.c ../test_nvector.c ../../../src/sundials/sundials_nvector.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+
+  SUNDIALS_ADD_TEST(${example}_1000_1_0 ${example} TEST_ARGS 1000 1 0)
+  SUNDIALS_ADD_TEST(${example}_1000_2_0 ${example} TEST_ARGS 1000 2 0)
+  SUNDIALS_ADD_TEST(${example}_1000_4_0 ${example} TEST_ARGS 1000 4 0)
+
+  SUNDIALS_ADD_TEST(${example}_10000_1_0 ${example} TEST_ARGS 10000 1 0)
+  SUNDIALS_ADD_TEST(${example}_10000_2_0 ${example} TEST_ARGS 10000 2 0)
+  SUNDIALS_ADD_TEST(${example}_10000_4_0 ${example} TEST_ARGS 10000 4 0)
+
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+
+  TARGET_LINK_LIBRARIES(${example} ${CMAKE_THREAD_LIBS_INIT})
+
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ../test_nvector.c ../test_nvector.h ../../../src/sundials/sundials_nvector.c DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/pthreads)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${nvector_pthreads_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/pthreads)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER_LIB "sundials_nvecpthreads")
+  LIST2STRING(nvector_pthreads_examples EXAMPLES)
+  LIST2STRING(nvector_examples_dependencies EXAMPLES_DEPENDENCIES)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_pthreads_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/pthreads/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/nvector/pthreads/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/pthreads
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_pthreads_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/pthreads/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/nvector/pthreads/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/pthreads
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/nvector/pthreads/test_nvector_pthreads.c b/examples/nvector/pthreads/test_nvector_pthreads.c
new file mode 100644
index 0000000..e29402a
--- /dev/null
+++ b/examples/nvector/pthreads/test_nvector_pthreads.c
@@ -0,0 +1,161 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4790 $
+ * $Date: 2016-06-29 14:47:05 -0700 (Wed, 29 Jun 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the testing routine to check the POSIX Threads (Pthreads) 
+ * NVECTOR module implementation which uses a LOCAL data struct to 
+ * share data between threads. 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sundials/sundials_types.h>
+#include <nvector/nvector_pthreads.h>
+#include <sundials/sundials_math.h>
+#include "test_nvector.h"
+
+
+/* ----------------------------------------------------------------------
+ * Main NVector Testing Routine
+ * --------------------------------------------------------------------*/
+int main(int argc, char *argv[]) 
+{
+  int      fails = 0;  /* counter for test failures */
+  int      nthreads;   /* number of threads         */
+  long int veclen;     /* vector length             */
+  N_Vector W, X, Y, Z; /* test vectors              */
+  int      print_timing;
+
+  /* check inputs, set vector length, and number of threads */
+  if (argc < 4){
+    printf("ERROR: THREE (3) Inputs required: vector length, number of threads, print timing \n");
+    return(-1);
+  }
+
+  veclen = atol(argv[1]); 
+  if (veclen <= 0) {
+    printf("ERROR: length of vector must be a positive integer \n");
+    return(-1); 
+  }
+
+  nthreads = atoi(argv[2]);
+  if (nthreads < 1) {
+    printf("ERROR: number of threads must be at least 1 \n");
+    return(-1); 
+  }
+
+  print_timing = atoi(argv[3]);
+  SetTiming(print_timing);
+
+
+  printf("\nRunning with %d threads and vector length %ld \n \n", nthreads, veclen);
+
+  /* Create vectors */
+  W = N_VNewEmpty_Pthreads(veclen, nthreads);
+  X = N_VNew_Pthreads(veclen, nthreads);
+  Y = N_VNew_Pthreads(veclen, nthreads);
+  Z = N_VNew_Pthreads(veclen, nthreads);
+
+  if(N_VGetVectorID(W) == SUNDIALS_NVEC_PTHREADS) {
+    /* printf("Testing Pthreads variant of N_Vector...\n"); */
+  }
+  
+  /* NVector Tests */
+  fails += Test_N_VSetArrayPointer(W, veclen, 0);
+  fails += Test_N_VGetArrayPointer(X, veclen, 0);
+  fails += Test_N_VLinearSum(X, Y, Z, veclen, 0);
+  fails += Test_N_VConst(X, veclen, 0);
+  fails += Test_N_VProd(X, Y, Z, veclen, 0);
+  fails += Test_N_VDiv(X, Y, Z, veclen, 0);
+  fails += Test_N_VScale(X, Z, veclen, 0);
+  fails += Test_N_VAbs(X, Z, veclen, 0);
+  fails += Test_N_VInv(X, Z, veclen, 0);
+  fails += Test_N_VAddConst(X, Z, veclen, 0);
+  fails += Test_N_VDotProd(X, Y, veclen, veclen, 0);
+  fails += Test_N_VMaxNorm(X, veclen, 0);
+  fails += Test_N_VWrmsNorm(X, Y, veclen, 0);
+  fails += Test_N_VWrmsNormMask(X, Y, Z, veclen, veclen, 0);
+  fails += Test_N_VMin(X, veclen, 0);
+  fails += Test_N_VWL2Norm(X, Y, veclen, veclen, 0);
+  fails += Test_N_VL1Norm(X, veclen, veclen, 0);
+  fails += Test_N_VCompare(X, Z, veclen, 0);
+  fails += Test_N_VInvTest(X, Z, veclen, 0);
+  fails += Test_N_VConstrMask(X, Y, Z, veclen, 0);
+  fails += Test_N_VMinQuotient(X, Y, veclen, 0);
+  fails += Test_N_VCloneVectorArray(5, X, veclen, 0);
+  fails += Test_N_VCloneEmptyVectorArray(5, X, 0);
+  fails += Test_N_VCloneEmpty(X, 0);
+  fails += Test_N_VClone(X, veclen, 0);
+
+  /* Free vectors */
+  N_VDestroy_Pthreads(W);
+  N_VDestroy_Pthreads(X);
+  N_VDestroy_Pthreads(Y);
+  N_VDestroy_Pthreads(Z);
+
+  /* Print result */
+  if (fails) {
+    printf("FAIL: NVector module failed %i tests \n \n", fails);
+  } else {
+    printf("SUCCESS: NVector module passed all tests \n \n");
+  }
+
+  return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * Check vector
+ * --------------------------------------------------------------------*/
+int check_ans(realtype ans, N_Vector X, long int local_length)
+{
+  int      failure = 0;
+  long int i;
+  realtype *Xdata;
+  
+  Xdata = N_VGetArrayPointer(X);
+
+  /* check vector data */
+  for(i=0; i < local_length; i++){
+    failure += FNEQ(Xdata[i], ans);
+  }
+
+  if (failure > ZERO)
+    return(1);
+  else
+    return(0);
+}
+
+booleantype has_data(N_Vector X)
+{
+  realtype *Xdata = N_VGetArrayPointer(X);
+  if (Xdata == NULL)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+void set_element(N_Vector X, long int i, realtype val)
+{
+  NV_Ith_PT(X,i) = val;
+}
+ 
+realtype get_element(N_Vector X, long int i)
+{
+  return NV_Ith_PT(X,i);
+}
+
diff --git a/examples/nvector/serial/CMakeLists.txt b/examples/nvector/serial/CMakeLists.txt
new file mode 100644
index 0000000..9c38a10
--- /dev/null
+++ b/examples/nvector/serial/CMakeLists.txt
@@ -0,0 +1,117 @@
+# ---------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# ---------------------------------------------------------------
+# Programmer:  Steven Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for nvector examples
+
+# Add variable nvector_serial_examples with the names of the nvector examples
+
+SET(nvector_serial_examples
+  test_nvector_serial
+)
+
+SET(nvector_examples_dependencies
+  test_nvector
+  sundials_nvector
+)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(. ..)
+
+# Specify libraries to link against (through the target that was used to 
+# generate them) based on the value of the variable LINK_LIBRARY_TYPE
+
+IF(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecserial_static)
+ELSE(LINK_LIBRARY_TYPE MATCHES "static")
+  SET(NVECS_LIB sundials_nvecserial_shared)
+ENDIF(LINK_LIBRARY_TYPE MATCHES "static")
+
+# Set-up linker flags and link libraries
+
+SET(SUNDIALS_LIBS ${NVECS_LIB} ${EXTRA_LINK_LIBS})
+
+# Add the build and install targets for each nvector example
+
+FOREACH(example ${nvector_serial_examples})
+
+  IF(WIN32)
+    # This is used to get around DLL linkage issue since we are
+    # manually including sundials_nvector.c here, which is normally in
+    # a library that is included.  If this is not set build system
+    # thinks nvector is externally linked.
+    ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+  ENDIF(WIN32)
+
+  ADD_EXECUTABLE(${example} ${example}.c ../test_nvector.c ../../../src/sundials/sundials_nvector.c)
+  SET_TARGET_PROPERTIES(${example} PROPERTIES FOLDER "Examples")
+
+  SUNDIALS_ADD_TEST( ${example}_1000_0 ${example} TEST_ARGS 1000 0)
+  SUNDIALS_ADD_TEST( ${example}_10000_0 ${example} TEST_ARGS 10000 0)
+
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+
+  IF(EXAMPLES_INSTALL)
+    INSTALL(FILES ${example}.c ../test_nvector.c ../test_nvector.h ../../../src/sundials/sundials_nvector.c DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/serial)
+  ENDIF(EXAMPLES_INSTALL)
+ENDFOREACH(example ${nvector_serial_examples})
+
+IF(EXAMPLES_INSTALL)
+
+  # Install the README file
+  INSTALL(FILES DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/serial)
+
+  # Prepare substitution variables for Makefile and/or CMakeLists templates
+  SET(SOLVER_LIB "sundials_nvecserial")
+  LIST2STRING(nvector_serial_examples EXAMPLES)
+  LIST2STRING(nvector_examples_dependencies EXAMPLES_DEPENDENCIES)
+
+  # Regardless of the platform we're on, we will generate and install 
+  # CMakeLists.txt file for building the examples. This file  can then 
+  # be used as a template for the user's own programs.
+
+  # generate CMakelists.txt in the binary directory
+  CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/cmakelists_serial_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/serial/CMakeLists.txt
+      @ONLY
+      )
+
+  # install CMakelists.txt
+  INSTALL(
+    FILES ${PROJECT_BINARY_DIR}/examples/nvector/serial/CMakeLists.txt
+    DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/serial
+    )
+
+  # On UNIX-type platforms, we also  generate and install a makefile for 
+  # building the examples. This makefile can then be used as a template 
+  # for the user's own programs.
+
+  IF(UNIX)
+    # generate Makefile and place it in the binary dir
+    CONFIGURE_FILE(
+      ${PROJECT_SOURCE_DIR}/examples/templates/makefile_serial_C_ex.in
+      ${PROJECT_BINARY_DIR}/examples/nvector/serial/Makefile_ex
+      @ONLY
+      )
+    # install the configured Makefile_ex as Makefile
+    INSTALL(
+      FILES ${PROJECT_BINARY_DIR}/examples/nvector/serial/Makefile_ex 
+      DESTINATION ${EXAMPLES_INSTALL_PATH}/nvector/serial
+      RENAME Makefile
+      )
+  ENDIF(UNIX)
+
+ENDIF(EXAMPLES_INSTALL)
diff --git a/examples/nvector/serial/test_nvector_serial.c b/examples/nvector/serial/test_nvector_serial.c
new file mode 100644
index 0000000..a2e1979
--- /dev/null
+++ b/examples/nvector/serial/test_nvector_serial.c
@@ -0,0 +1,153 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4790 $
+ * $Date: 2016-06-29 14:47:05 -0700 (Wed, 29 Jun 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the testing routine to check the NVECTOR Serial module 
+ * implementation. 
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sundials/sundials_types.h>
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_math.h>
+#include "test_nvector.h"
+
+
+/* ----------------------------------------------------------------------
+ * Main NVector Testing Routine
+ * --------------------------------------------------------------------*/
+int main(int argc, char *argv[]) 
+{
+  int      fails = 0;  /* counter for test failures  */
+  long int veclen;     /* vector length              */
+  N_Vector W, X, Y, Z; /* test vectors               */
+  int      print_timing;
+
+
+  /* check input and set vector length */
+  if (argc < 3){
+    printf("ERROR: ONE (1) Input required: vector length, print timing \n");
+    return(-1);
+  }
+
+  veclen = atol(argv[1]); 
+  if (veclen <= 0) {
+    printf("ERROR: length of vector must be a positive integer \n");
+    return(-1); 
+  }
+
+  print_timing = atoi(argv[2]);
+  SetTiming(print_timing);
+
+
+  printf("\nRunning with vector length %ld \n \n", veclen);
+
+  /* Create vectors */
+  W = N_VNewEmpty_Serial(veclen);
+  X = N_VNew_Serial(veclen);
+  Y = N_VNew_Serial(veclen);
+  Z = N_VNew_Serial(veclen);
+
+  if(N_VGetVectorID(W) == SUNDIALS_NVEC_SERIAL) {
+    /*printf("Testing serial variant of N_Vector...\n");*/
+  }
+  
+  /* NVector Tests */
+  fails += Test_N_VSetArrayPointer(W, veclen, 0);
+  fails += Test_N_VGetArrayPointer(X, veclen, 0);
+  fails += Test_N_VLinearSum(X, Y, Z, veclen, 0);
+  fails += Test_N_VConst(X, veclen, 0);
+  fails += Test_N_VProd(X, Y, Z, veclen, 0);
+  fails += Test_N_VDiv(X, Y, Z, veclen, 0);
+  fails += Test_N_VScale(X, Z, veclen, 0);
+  fails += Test_N_VAbs(X, Z, veclen, 0);
+  fails += Test_N_VInv(X, Z, veclen, 0);
+  fails += Test_N_VAddConst(X, Z, veclen, 0);
+  fails += Test_N_VDotProd(X, Y, veclen, veclen, 0);
+  fails += Test_N_VMaxNorm(X, veclen, 0);
+  fails += Test_N_VWrmsNorm(X, Y, veclen, 0);
+  fails += Test_N_VWrmsNormMask(X, Y, Z, veclen, veclen, 0);
+  fails += Test_N_VMin(X, veclen, 0);
+  fails += Test_N_VWL2Norm(X, Y, veclen, veclen, 0);
+  fails += Test_N_VL1Norm(X, veclen, veclen, 0);
+  fails += Test_N_VCompare(X, Z, veclen, 0);
+  fails += Test_N_VInvTest(X, Z, veclen, 0);
+  fails += Test_N_VConstrMask(X, Y, Z, veclen, 0);
+  fails += Test_N_VMinQuotient(X, Y, veclen, 0);
+  fails += Test_N_VCloneVectorArray(5, X, veclen, 0);
+  fails += Test_N_VCloneEmptyVectorArray(5, X, 0);
+  fails += Test_N_VCloneEmpty(X, 0);
+  fails += Test_N_VClone(X, veclen, 0);
+
+  /* Free vectors */
+  N_VDestroy_Serial(W);
+  N_VDestroy_Serial(X);
+  N_VDestroy_Serial(Y);
+  N_VDestroy_Serial(Z);
+
+  /* Print result */
+  if (fails) {
+    printf("FAIL: NVector module failed %i tests \n \n", fails);
+  } else {
+    printf("SUCCESS: NVector module passed all tests \n \n");
+  }
+
+  return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * Check vector
+ * --------------------------------------------------------------------*/
+int check_ans(realtype ans, N_Vector X, long int local_length)
+{
+  int      failure = 0;
+  long int i;
+  realtype *Xdata;
+  
+  Xdata = N_VGetArrayPointer(X);
+
+  /* check vector data */
+  for(i=0; i < local_length; i++){
+    failure += FNEQ(Xdata[i], ans);
+  }
+
+  if (failure > ZERO)
+    return(1);
+  else
+    return(0);
+}
+
+booleantype has_data(N_Vector X)
+{
+  realtype *Xdata = N_VGetArrayPointer(X);
+  if (Xdata == NULL)
+    return FALSE;
+  else
+    return TRUE;
+}
+
+void set_element(N_Vector X, long int i, realtype val)
+{
+  NV_Ith_S(X,i) = val;    
+}
+
+realtype get_element(N_Vector X, long int i)
+{
+  return NV_Ith_S(X,i);    
+}
diff --git a/examples/nvector/test_nvector.c b/examples/nvector/test_nvector.c
new file mode 100644
index 0000000..4da2886
--- /dev/null
+++ b/examples/nvector/test_nvector.c
@@ -0,0 +1,1842 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4652 $
+ * $Date: 2016-02-11 10:22:15 -0800 (Thu, 11 Feb 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner and Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * Acknowledgements: These testing routines are based on an
+ *                   NVECTOR testing routine by Daniel R. Reynolds
+ *                   @ SMU.
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * These test functions are designed to check an NVECTOR module 
+ * implementation. 
+ *
+ * NOTE: Many of these tests rely on the N_VGetArrayPointer routine 
+ *       to get a pointer to the data component of an N_Vector. This 
+ *       assumes the internal data is stored in a contiguous 
+ *       realtype array.
+ * -----------------------------------------------------------------
+ */
+
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_math.h>
+
+#include <math.h> /* include isnan */
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "test_nvector.h"
+
+#if defined( SUNDIALS_HAVE_POSIX_TIMERS) && defined(_POSIX_TIMERS)
+#include <time.h>
+#include <unistd.h>
+#endif
+
+
+/* private functions */
+static double get_time();
+
+int print_time = 0;
+
+#define PRINT_TIME(format, time) if(print_time) printf(format, time)
+
+/* ----------------------------------------------------------------------
+ * N_VCloneVectorArray Test
+ *
+ * NOTE: This routine depends on N_VConst to check vector data.
+ * --------------------------------------------------------------------*/
+int Test_N_VCloneVectorArray(int count, N_Vector W, long int local_length, int myid)
+{
+  int      i, failure;
+  double   start_time, stop_time;
+  N_Vector *vs;
+  
+  /* clone array of vectors */
+  start_time = get_time(); 
+  vs = N_VCloneVectorArray(count, W);
+  stop_time = get_time(); 
+  
+  /* check array of vectors */
+  if (count <= 0 && vs != NULL) {
+    printf(">>> FAILED test -- N_VCloneVectorArray, Proc %d \n", myid);
+    printf("    count = %d, expected *vs = NULL \n \n",count);
+    return(1);
+  } 
+  
+  /* check vectors in array */
+  for(i=0; i<count; i++) {
+    if (vs[i] == NULL) {
+      printf(">>> FAILED test -- N_VCloneVectorArray, Proc %d \n", myid);
+      printf("    Vector[%d] = NULL \n \n",i);
+      N_VDestroyVectorArray(vs, count);
+      return(1);
+    }    
+    
+    N_VConst(ONE,vs[i]);
+    failure = check_ans(ONE, vs[i], local_length);
+    if (failure) {
+      printf(">>> FAILED test -- N_VCloneVectorArray, Proc %d \n", myid);
+      printf("    Vector[%d] failed N_VConst check \n \n",i);
+      N_VDestroyVectorArray(vs, count);
+      return(1);
+    }    
+  }
+
+  N_VDestroyVectorArray(vs, count);
+  
+  if (myid == 0) {
+    printf("    PASSED test -- N_VCloneVectorArray \n");
+    PRINT_TIME("    N_VCloneVectorArray Time: %22.15e \n \n", stop_time - start_time);
+  }
+
+  return(0);
+}
+
+/* ----------------------------------------------------------------------
+ * N_VCloneVectorArrayEmpty Test
+ * --------------------------------------------------------------------*/
+int Test_N_VCloneEmptyVectorArray(int count, N_Vector W, int myid)
+{
+  int      i;
+  double   start_time, stop_time;
+  N_Vector *vs;
+
+  /* clone empty array */
+  start_time = get_time(); 
+  vs = N_VCloneEmptyVectorArray(count, W);
+  stop_time = get_time(); 
+  
+  /* check array of vectors */
+  if (count <= 0 && vs != NULL) {
+    printf(">>> FAILED test -- N_VCloneEmptyVectorArray, Proc %d \n", myid);
+    printf("    count = %d, expected *vs = NULL \n \n",count);
+    return(1);
+  } 
+
+  /* check vectors in array */
+  for(i=0; i<count; i++) {
+    if (vs[i] == NULL) {
+      printf(">>> FAILED test -- N_VCloneEmptyVectorArray, Proc %d \n", myid);
+      printf("    Vector[%d] = NULL \n \n",i);
+      N_VDestroyVectorArray(vs, count);
+      return(1);
+    }    
+
+    if (has_data(vs[i])) {
+      printf(">>> FAILED test -- N_VCloneEmptyVectorArray, Proc %d \n", myid);
+      printf("    Vector[%d] data != NULL \n \n",i);
+      N_VDestroyVectorArray(vs, count);
+      return(1);
+    }    
+  }
+
+  N_VDestroyVectorArray(vs, count);
+  
+  if (myid == 0) {
+    printf("    PASSED test -- N_VCloneEmptyVectorArray \n");
+    PRINT_TIME("    N_VCloneEmptyVectorArray Time: %22.15e \n \n", stop_time - start_time);
+  }
+
+  return(0);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VCloneEmpty Test
+ * --------------------------------------------------------------------*/
+int Test_N_VCloneEmpty(N_Vector W, int myid)
+{
+  double   start_time, stop_time;
+  N_Vector X;
+
+  /* clone empty vector */
+  start_time = get_time();   
+  X = N_VCloneEmpty(W);
+  stop_time = get_time(); 
+
+  /* check vector */
+  if (X == NULL) {
+    printf(">>> FAILED test -- N_VCloneEmpty, Proc %d \n", myid);
+    printf("    After N_VCloneEmpty, X == NULL \n \n");
+    return(1);
+  } 
+
+  /* check vector data */
+  if (has_data(X)) {
+    printf(">>> FAILED test -- N_VCloneEmpty, Proc %d \n", myid);
+    printf("    Vector data != NULL \n \n");
+    N_VDestroy(X);
+    return(1);
+  }    
+
+  N_VDestroy(X); 
+
+  if (myid == 0) {
+    printf("    PASSED test -- N_VCloneEmpty \n");
+    PRINT_TIME("    N_VCloneEmpty Time: %22.15e \n \n", stop_time - start_time);
+  }
+
+  return(0);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VClone Test
+ *
+ * NOTE: This routine depends on N_VConst to check vector data.
+ * --------------------------------------------------------------------*/
+int Test_N_VClone(N_Vector W, long int local_length, int myid)
+{
+  int      failure;
+  double   start_time, stop_time;
+  N_Vector X;
+
+  /* clone vector */
+  start_time = get_time();   
+  X = N_VClone(W);
+  stop_time = get_time();   
+
+  /* check cloned vector */
+  if (X == NULL) {
+    printf(">>> FAILED test -- N_VClone, Proc %d \n", myid);
+    printf("    After N_VCloneEmpty, X == NULL \n \n");
+    return(1);
+  } 
+
+  /* check cloned vector data */
+  if (!has_data(X)) {
+    printf(">>> FAILED test -- N_VClone, Proc %d \n", myid);
+    printf("    Vector data == NULL \n \n");
+    N_VDestroy(X);
+    return(1);
+  }    
+
+  N_VConst(ONE,X);
+  failure = check_ans(ONE, X, local_length);
+  if (failure) {
+    printf(">>> FAILED test -- N_VClone, Proc %d \n", myid);
+    printf("    Failed N_VConst check \n \n");
+    N_VDestroy(X);
+    return(1);
+  }    
+
+  N_VDestroy(X); 
+
+  if (myid == 0) {
+    printf("    PASSED test -- N_VClone \n");
+    PRINT_TIME("    N_VClone Time: %22.15e \n \n", stop_time - start_time);
+  }
+
+  return(0);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VGetArrayPointer Test
+ * 
+ * For now commenting this out to surpress warning messages (pointer set,
+ * but not used). Do we really need to time access to the vector 
+ * data pointer? 
+ *
+ * NOTE: This routine depends on N_VConst to check vector data.
+ * --------------------------------------------------------------------*/
+int Test_N_VGetArrayPointer(N_Vector W, long int local_length, int myid)
+{
+  int      failure = 0;
+  double   start_time, stop_time;
+  realtype *Wdata;
+
+  /* get vector data, time it and set it to NULL */
+  start_time = get_time();   
+  Wdata = N_VGetArrayPointer(W);
+  stop_time = get_time();
+  Wdata++; Wdata=NULL; /* Do something with pointer to surpress warning */
+  
+  /* check vector data */
+  if (!has_data(W)) {
+    printf(">>> FAILED test -- N_VGetArrayPointer, Proc %d \n", myid);
+    printf("    Vector data == NULL \n \n");
+    return(1);
+  }    
+
+  N_VConst(NEG_HALF,W);
+  failure = check_ans(NEG_HALF, W, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VGetArrayPointer, Proc %d \n", myid);
+    printf("    Failed N_VConst check \n \n");
+    return(1);
+  }
+
+  if (myid == 0) {
+    printf("    PASSED test -- N_VGetArrayPointer \n");
+    PRINT_TIME("    N_VGetArrayPointer Time: %22.15e \n \n", stop_time - start_time);
+  }
+  
+  return(0);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VSetArrayPointer Test
+ *
+ * NOTE: This routine depends on N_VConst to check vector data.
+ * --------------------------------------------------------------------*/
+int Test_N_VSetArrayPointer(N_Vector W, long int local_length, int myid)
+{
+  int      failure = 0;
+  long int i;  
+  double   start_time, stop_time;
+  realtype *Wdata;
+
+  /* create vector data */
+  Wdata = malloc(local_length * sizeof(realtype));
+  for(i=0; i < local_length; i++){
+    Wdata[i] = ONE;
+  }
+  
+  /* attach data to vector */
+  start_time = get_time();   
+  N_VSetArrayPointer(Wdata, W);
+  stop_time = get_time();   
+
+  /* check vector data */
+  N_VConst(NEG_HALF,W);
+  for(i=0; i < local_length; i++){
+    failure += FNEQ(Wdata[i], NEG_HALF);
+  }
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VSetArrayPointer, Proc %d \n", myid);
+    printf("    Failed N_VConst check \n \n");
+    free(Wdata);
+    return(1);
+  }
+
+  free(Wdata);
+
+  if (myid == 0) {
+    printf("    PASSED test -- N_VSetArrayPointer \n");
+    PRINT_TIME("    N_VSetArrayPointer Time: %22.15e \n \n", stop_time - start_time);
+  }
+  
+  return(0);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VLinearSum Tests
+ * --------------------------------------------------------------------*/
+int Test_N_VLinearSum(N_Vector X, N_Vector Y, N_Vector Z, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  
+  /* 
+   * Case 1a: y = x + y, (Vaxpy Case 1) 
+   */
+
+  /* fill vector data */
+  N_VConst(ONE, X);
+  N_VConst(NEG_TWO, Y);
+
+  start_time = get_time(); 
+  N_VLinearSum(ONE, X, ONE, Y, Y);
+  stop_time = get_time(); 
+  
+  /* Y should be vector of -1 */
+  failure = check_ans(NEG_ONE, Y, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 1a, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 1a \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /*
+   * Case 1b: y = -x + y, (Vaxpy Case 2)
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(ONE, X);
+  N_VConst(TWO, Y);
+
+  start_time = get_time(); 
+  N_VLinearSum(NEG_ONE, X, ONE, Y, Y);
+  stop_time = get_time(); 
+  
+  /* Y should be vector of +1 */
+  failure = check_ans(ONE, Y, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 1b, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 1b \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /*
+   * Case 1c: y = ax + y, (Vaxpy Case 3)
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(NEG_TWO, Y);
+
+  start_time = get_time(); 
+  N_VLinearSum(HALF, X, ONE, Y, Y);
+  stop_time = get_time(); 
+  
+  /* Y should be vector of -1 */
+  failure = check_ans(NEG_ONE, Y, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 1c, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 1c \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /*
+   * Case 2a: x = x + y, (Vaxpy Case 1)
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(NEG_ONE, Y);
+
+  start_time = get_time(); 
+  N_VLinearSum(ONE, X, ONE, Y, X);
+  stop_time = get_time(); 
+  
+  /* Y should be vector of +1 */
+  failure = check_ans(ONE, X, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 2a, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 2a \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /*
+   * Case 2b: x = x - y, (Vaxpy Case 2)
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(ONE, X);
+  N_VConst(TWO, Y);
+
+  start_time = get_time(); 
+  N_VLinearSum(ONE, X, NEG_ONE, Y, X);
+  stop_time = get_time(); 
+  
+  /* Y should be vector of -1 */
+  failure = check_ans(NEG_ONE, X, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 2b, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 2b \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /* 
+   * Case 2c: x = x + by, (Vaxpy Case 3) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(NEG_HALF, Y);
+
+  start_time = get_time(); 
+  N_VLinearSum(ONE, X, TWO, Y, X);
+  stop_time = get_time(); 
+  
+  /* X should be vector of +1 */
+  failure = check_ans(ONE, X, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 2c, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 2c \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /* 
+   * Case 3: z = x + y, (VSum) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(NEG_TWO, X);
+  N_VConst(ONE, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(ONE, X, ONE, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 3, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 3 \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /* 
+   * Case 4a: z = x - y, (VDiff) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(ONE, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(ONE, X, NEG_ONE, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of +1 */
+  failure = check_ans(ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 4a, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 4a \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /* 
+   * Case 4b: z = -x + y, (VDiff) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(ONE, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(NEG_ONE, X, ONE, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 4b, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 4b \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /* 
+   * Case 5a: z = x + by, (VLin1) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(NEG_HALF, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(ONE, X, TWO, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of +1 */
+  failure = check_ans(ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 5a, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 5a \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 5b: z = ax + y, (VLin1) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(HALF, X);
+  N_VConst(NEG_TWO, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(TWO, X, ONE, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 5b, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 5b \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 6a: z = -x + by, (VLin2) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(NEG_TWO, X);
+  N_VConst(NEG_HALF, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(NEG_ONE, X, TWO, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of +1 */
+  failure = check_ans(ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 6a, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 6a \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 6b: z = ax - y, (VLin2) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(HALF, X);
+  N_VConst(TWO, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(TWO, X, NEG_ONE, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 6b, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 6b \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 7: z = a(x + y), (VScaleSum) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(ONE, X);
+  N_VConst(NEG_HALF, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(TWO, X, TWO, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of +1 */
+  failure = check_ans(ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 7, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 7 \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 8: z = a(x - y), (VScaleDiff) 
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(HALF, X);
+  N_VConst(ONE, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(TWO, X, NEG_TWO, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 8, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 8 \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 9: z = ax + by, All Other Cases
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(ONE, X);
+  N_VConst(NEG_TWO, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time(); 
+  N_VLinearSum(TWO, X, HALF, Y, Z);
+  stop_time = get_time(); 
+  
+  /* Z should be vector of +1 */
+  failure = check_ans(ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VLinearSum Case 9, Proc %d \n", myid);
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VLinearSum Case 9 \n");
+    PRINT_TIME("    N_VLinearSum Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VConst Test
+ * --------------------------------------------------------------------*/
+int Test_N_VConst(N_Vector X, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  long int i;
+
+  /* fill vector data */
+  for(i=0; i < local_length; i++){
+    set_element(X, i, ZERO);
+  }
+
+  start_time = get_time();
+  N_VConst(ONE,X);
+  stop_time = get_time(); 
+
+  /* X should be vector of +1 */
+  failure = check_ans(ONE, X, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VConst, Proc %d \n", myid);
+    PRINT_TIME("    N_VConst Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VConst \n");
+    PRINT_TIME("    N_VConst Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VProd Test
+ * --------------------------------------------------------------------*/
+int Test_N_VProd(N_Vector X, N_Vector Y, N_Vector Z, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(NEG_HALF, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VProd(X, Y, Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VProd, Proc %d \n", myid);
+    PRINT_TIME("    N_VProd Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VProd \n");
+    PRINT_TIME("    N_VProd Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VDiv Test
+ * --------------------------------------------------------------------*/
+int Test_N_VDiv(N_Vector X, N_Vector Y, N_Vector Z, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+
+  /* fill vector data */
+  N_VConst(ONE, X);
+  N_VConst(TWO, Y);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VDiv(X, Y, Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of +1/2 */
+  failure = check_ans(HALF, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VDiv, Proc %d \n", myid);
+    PRINT_TIME("    N_VDiv Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VDiv \n");
+    PRINT_TIME("    N_VDiv Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VScale Tests
+ * --------------------------------------------------------------------*/
+int Test_N_VScale(N_Vector X, N_Vector Z, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+
+  /* 
+   * Case 1: x = cx, VScaleBy
+   */
+
+  /* fill vector data */
+  N_VConst(HALF, X);
+
+  start_time = get_time();
+  N_VScale(TWO, X, X);
+  stop_time = get_time(); 
+
+  /* X should be vector of +1 */
+  failure = check_ans(ONE, X, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VScale Case 1, Proc %d \n", myid);
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VScale Case 1 \n");
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 2: z = x, VCopy
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(NEG_ONE, X);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VScale(ONE, X, Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VScale Case 2, Proc %d \n", myid);
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VScale Case 2 \n");
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 3: z = -x, VNeg
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(NEG_ONE, X);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VScale(NEG_ONE, X, Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of +1 */
+  failure = check_ans(ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VScale Case 3, Proc %d \n", myid);
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VScale Case 3 \n");
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 4: z = cx, All other cases
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(NEG_HALF, X);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VScale(TWO, X, Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VScale Case 4, Proc %d \n", myid);
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VScale Case 4 \n");
+    PRINT_TIME("    N_VScale Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VAbs Test
+ * --------------------------------------------------------------------*/
+int Test_N_VAbs(N_Vector X, N_Vector Z, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+
+  /* fill vector data */
+  N_VConst(NEG_ONE, X);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VAbs(X,Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of +1 */
+  failure = check_ans(ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VAbs, Proc %d \n", myid);
+    PRINT_TIME("    N_VAbs Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VAbs \n");
+    PRINT_TIME("    N_VAbs Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VInv Test
+ * --------------------------------------------------------------------*/
+int Test_N_VInv(N_Vector X, N_Vector Z, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VInv(X,Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of +1/2 */
+  failure = check_ans(HALF, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VInv, Proc %d \n", myid);
+    PRINT_TIME("    N_VInv Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VInv \n");
+    PRINT_TIME("    N_VInv Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VAddConst Test
+ * --------------------------------------------------------------------*/
+int Test_N_VAddConst(N_Vector X, N_Vector Z, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+
+  /* fill vector data */
+  N_VConst(ONE, X);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  N_VAddConst(X,NEG_TWO,Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of -1 */
+  failure = check_ans(NEG_ONE, Z, local_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VAddConst, Proc %d \n", myid);
+    PRINT_TIME("    N_VAddConst Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VAddConst \n");
+    PRINT_TIME("    N_VAddConst Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VDotProd Test
+ * --------------------------------------------------------------------*/
+int Test_N_VDotProd(N_Vector X, N_Vector Y, 
+                    long int local_length, long int global_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  N_VConst(HALF, Y);
+
+  start_time = get_time();
+  ans = N_VDotProd(X,Y);
+  stop_time = get_time(); 
+
+  /* ans should equal global vector length */
+  failure = FNEQ(ans, global_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VDotProd, Proc %d \n", myid);
+    PRINT_TIME("    N_VDotProd Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VDotProd \n");
+    PRINT_TIME("    N_VDotProd Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VMaxNorm Test
+ * --------------------------------------------------------------------*/
+int Test_N_VMaxNorm(N_Vector X, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /* fill vector data */
+  N_VConst(NEG_ONE, X);
+  set_element(X, local_length-1, NEG_TWO);
+  
+  start_time = get_time();
+  ans = N_VMaxNorm(X);
+  stop_time = get_time(); 
+
+  /* ans should equal 2 */
+  failure = (ans < ZERO) ? 1 : FNEQ(ans, TWO);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VMaxNorm, Proc %d \n", myid);
+    PRINT_TIME("    N_VMaxNorm Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VMaxNorm \n");
+    PRINT_TIME("    N_VMaxNorm Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VWrmsNorm Test
+ * --------------------------------------------------------------------*/
+int Test_N_VWrmsNorm(N_Vector X, N_Vector W, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /* fill vector data */
+  N_VConst(NEG_HALF, X);
+  N_VConst(HALF, W);
+
+  start_time = get_time();
+  ans = N_VWrmsNorm(X, W);
+  stop_time = get_time(); 
+
+  /* ans should equal 1/4 */
+  failure = (ans < ZERO) ? 1 : FNEQ(ans, HALF*HALF);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VWrmsNorm, Proc %d \n", myid);
+    PRINT_TIME("    N_VWrmsNorm Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VWrmsNorm \n");
+    PRINT_TIME("    N_VWrmsNorm Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VWrmsNormMask Test
+ * --------------------------------------------------------------------*/
+int Test_N_VWrmsNormMask(N_Vector X, N_Vector W, N_Vector ID, 
+			 long int local_length, long int global_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /* 
+   * Case 1: use all elements, ID = 1
+   */
+
+  /* fill vector data */
+  N_VConst(NEG_HALF, X);
+  N_VConst(HALF, W);
+  N_VConst(ONE, ID);
+
+  start_time = get_time();
+  ans = N_VWrmsNormMask(X, W, ID);
+  stop_time = get_time(); 
+  
+  /* ans equals 1/4 (same as wrms norm) */
+  failure = (ans < ZERO) ? 1 : FNEQ(ans, HALF*HALF);
+    
+  if (failure) {
+    printf(">>> FAILED test -- N_VWrmsNormMask Case 1, Proc %d \n", myid);
+    PRINT_TIME("    N_VWrmsNormMask Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VWrmsNormMask Case 1 \n");
+    PRINT_TIME("    N_VWrmsNormMask Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /* 
+   * Case 2: use no elements, ID = 0
+   */
+  
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(NEG_HALF, X);
+  N_VConst(HALF, W);
+  N_VConst(ZERO, ID);
+
+  start_time = get_time();
+  ans = N_VWrmsNormMask(X, W, ID);
+  stop_time = get_time(); 
+  
+  /* ans equals 0 (skips all elements) */
+  failure = (ans < ZERO) ? 1 : FNEQ(ans, ZERO);
+    
+  if (failure) {
+    printf(">>> FAILED test -- N_VWrmsNormMask Case 2, Proc %d \n", myid);
+    PRINT_TIME("    N_VWrmsNormMask Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VWrmsNormMask Case 2 \n");
+    PRINT_TIME("    N_VWrmsNormMask Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VMin Test
+ * --------------------------------------------------------------------*/
+int Test_N_VMin(N_Vector X, long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /* fill vector data */
+  N_VConst(TWO, X);
+  set_element(X, local_length-1, NEG_ONE);
+
+  start_time = get_time();
+  ans = N_VMin(X);
+  stop_time = get_time(); 
+
+  /* ans should equal -1 */
+  failure = FNEQ(ans, NEG_ONE);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VMin, Proc %d \n", myid);
+    PRINT_TIME("    N_VMin Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VMin \n");
+    PRINT_TIME("    N_VMin Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VWL2Norm Test
+ * --------------------------------------------------------------------*/
+int Test_N_VWL2Norm(N_Vector X, N_Vector W, 
+                    long int local_length, long int global_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /* fill vector data */
+  N_VConst(NEG_HALF, X);
+  N_VConst(HALF, W);
+
+  start_time = get_time();
+  ans = N_VWL2Norm(X, W);
+  stop_time = get_time(); 
+
+  /* ans should equal 1/4 * sqrt(global_length) */
+  failure = (ans < ZERO) ? 1 : FNEQ(ans, HALF*HALF*SUNRsqrt((realtype) global_length));
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VWL2Norm, Proc %d \n", myid);
+    PRINT_TIME("    N_VWL2Norm Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VWL2Norm \n");
+    PRINT_TIME("    N_VWL2Norm Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VL1Norm Test
+ * --------------------------------------------------------------------*/
+int Test_N_VL1Norm(N_Vector X, long int local_length, 
+                   long int global_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /* fill vector data */
+  N_VConst(NEG_ONE, X);
+
+  start_time = get_time();
+  ans = N_VL1Norm(X);
+  stop_time = get_time(); 
+
+  /* ans should equal global_length */
+  failure = (ans < ZERO) ? 1 : FNEQ(ans, global_length);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VL1Norm, Proc %d \n", myid);
+    PRINT_TIME("    N_VL1Norm Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VL1Norm \n");
+    PRINT_TIME("    N_VL1Norm Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VCompare
+ * --------------------------------------------------------------------*/
+int Test_N_VCompare(N_Vector X, N_Vector Z, long int local_length, int myid)
+{
+  int      mask, fails = 0, failure = 0;
+  double   start_time, stop_time;
+  long int i;
+
+  if (local_length < 3) {
+    printf("Error Test_N_VCompare: Local vector length is %ld, length must be >= 3", local_length);
+    return(-1);
+  }
+
+  /* fill vector data */
+  for(i=0; i < local_length; i++){
+    set_element(Z, i, NEG_ONE);
+
+    mask = i % 3;
+    switch(mask) {
+
+    case 0 :
+      /* abs(X[i]) < c */
+      set_element(X, i, ZERO);
+      break;
+
+    case 1 :
+      /* abs(X[i]) = c */
+      set_element(X, i, NEG_ONE);
+      break;
+      
+    case 2 :
+      /* abs(X[i]) > c */
+      set_element(X, i, NEG_TWO);
+      break;
+    }
+  }
+
+  start_time = get_time();
+  N_VCompare(ONE, X, Z);
+  stop_time = get_time(); 
+
+  /* check return vector */
+  for(i=0; i < local_length; i++){
+    mask = i % 3;
+
+    switch(mask) {
+
+    case 0 :
+      /* Z[i] == 0 */
+      if (get_element(Z, i) != ZERO)
+        failure = 1;
+      break;
+
+    case 1 :
+      /* Z[i] == 1 */
+      if (get_element(Z, i) != ONE)
+        failure = 1;
+      break;
+      
+    case 2 :
+      /* Z[i] == 1 */
+      if (get_element(Z, i) != ONE)
+        failure = 1;
+      break;
+    }
+  }
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VCompare, Proc %d \n", myid);
+    PRINT_TIME("    N_VCompare Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VCompare \n");
+    PRINT_TIME("    N_VCompare Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VInvTest
+ * --------------------------------------------------------------------*/
+int Test_N_VInvTest(N_Vector X, N_Vector Z, long int local_length, int myid)
+{
+  int         mask, fails = 0, failure = 0;
+  double      start_time, stop_time;
+  long int    i;
+  booleantype test;
+
+  if (local_length < 2) {
+    printf("Error Test_N_VCompare: Local vector length is %ld, length must be >= 2", local_length);
+    return(-1);
+  }
+
+  /*
+   * Case 1: All elements Nonzero, z[i] = 1/x[i], return True
+   */
+
+  /* fill vector data */
+  N_VConst(HALF, X);
+  N_VConst(ZERO, Z);
+
+  start_time = get_time();
+  test = N_VInvTest(X, Z);
+  stop_time = get_time(); 
+
+  /* Z should be vector of +2 */
+  failure = check_ans(TWO, Z, local_length);
+
+  if (failure || !test) {
+    printf(">>> FAILED test -- N_VInvTest Case 1, Proc %d \n", myid);
+    PRINT_TIME("    N_VInvTest Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VInvTest Case 1 \n");
+    PRINT_TIME("    N_VInvTest Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /*
+   * Case 2: Some elements Zero, z[i] = 1/x[i] for x[i] != 0, return False
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(ZERO, Z);
+  for(i=0; i < local_length; i++){
+    mask = i % 2;   
+    if (mask)
+      set_element(X, i, HALF);
+    else
+      set_element(X, i, ZERO);
+  }
+
+  start_time = get_time();
+  test = N_VInvTest(X, Z);
+  stop_time = get_time();
+
+  /* check return vector */
+  for(i=0; i < local_length; i++){
+    mask = i % 2;
+
+    if (mask) {
+      if (get_element(Z, i) != TWO) 
+        failure = 1;
+    } else {
+      if (get_element(Z, i) != ZERO) 
+        failure = 1;
+    }
+  }
+
+  if (failure || test) {
+    printf(">>> FAILED test -- N_VInvTest Case 2, Proc %d \n", myid);
+    PRINT_TIME("    N_VInvTest Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VInvTest Case 2 \n");
+    PRINT_TIME("    N_VInvTest Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VConstrMask
+ * --------------------------------------------------------------------*/
+int Test_N_VConstrMask(N_Vector C, N_Vector X, N_Vector M, 
+                       long int local_length, int myid)
+{
+  int         mask, fails = 0, failure = 0;
+  double      start_time, stop_time;
+  long int    i;
+  booleantype test;
+
+  if (local_length < 7) {
+    printf("Error Test_N_VCompare: Local vector length is %ld, length must be >= 7", local_length);
+    return(-1);
+  }
+
+  /*
+   * Case 1: Return True
+   */
+
+  /* fill vector data */
+  for(i=0; i < local_length; i++){
+    set_element(M, i, NEG_ONE);
+
+    mask = i % 7;  
+    switch(mask) {
+    case 0 :
+      /* c = -2, test for < 0*/
+      set_element(C, i, NEG_TWO);
+      set_element(X, i, NEG_TWO);
+      break;
+      
+    case 1 :
+      /* c = -1, test for <= 0 */
+      set_element(C, i, NEG_ONE);
+      set_element(X, i, NEG_ONE);	
+      break;
+      
+    case 2 :
+      /* c = -1, test for == 0 */
+      set_element(C, i, NEG_ONE);
+      set_element(X, i, ZERO); 
+      break;
+      
+    case 3 :
+      /* c = 0, no test */
+      set_element(C, i, ZERO);
+      set_element(X, i, HALF);
+      break;
+      
+    case 4 :
+      /* c = 1, test for == 0*/
+      set_element(C, i, ONE);
+      set_element(X, i, ZERO);
+      break;
+      
+    case 5 :
+      /* c = 1, test for >= 0*/
+      set_element(C, i, ONE);
+      set_element(X, i, ONE);
+      break;
+      
+    case 6:
+      /* c = 2, test for > 0 */
+      set_element(C, i, TWO);
+      set_element(X, i, TWO);
+      break;
+    }
+  }
+
+  start_time = get_time(); 
+  test = N_VConstrMask(C, X, M);
+  stop_time = get_time();
+
+  /* M should be vector of 0 */
+  failure = check_ans(ZERO, M, local_length);
+
+  if (failure || !test) {
+    printf(">>> FAILED test -- N_VConstrMask Case 1, Proc %d \n", myid);
+    PRINT_TIME("    N_VConstrMask Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VConstrMask Case 1 \n");
+    PRINT_TIME("    N_VConstrMask Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  /*
+   * Case 2: Return False
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  for(i=0; i < local_length; i++){
+    set_element(M, i, NEG_ONE);
+    
+    mask = i % 5;  
+    switch(mask) {
+    case 0 :
+      /* c = -2, test for < 0*/
+      set_element(C, i, NEG_TWO);
+      set_element(X, i, TWO);
+      break;
+
+    case 1 :
+      /* c = -1, test for <= 0 */
+      set_element(C, i, NEG_ONE);
+      set_element(X, i, ONE);	
+      break;
+      
+    case 2 :
+      /* c = 0, no test */
+      set_element(C, i, ZERO);
+      set_element(X, i, HALF);
+      break;
+
+    case 3 :
+      /* c = 1, test for >= 0*/
+      set_element(C, i, ONE);
+      set_element(X, i, NEG_ONE);
+      break;
+
+    case 4 :
+      /* c = 2, test for > 0 */
+      set_element(C, i, TWO);
+      set_element(X, i, NEG_TWO);
+      break;
+    }
+  }
+
+  start_time = get_time();  
+  test = N_VConstrMask(C, X, M);
+  stop_time = get_time();
+
+  /* check mask vector */
+  for(i=0; i < local_length; i++){
+    mask = i % 5;
+    
+    if (mask == 2){
+      if (get_element(M, i) != ZERO) 
+        failure = 1;
+    } else {
+      if (get_element(M, i) != ONE)
+        failure = 1;
+    }
+  }
+  
+  if (failure || test) {
+    printf(">>> FAILED test -- N_VConstrMask Case 2, Proc %d \n", myid);
+    PRINT_TIME("    N_VConstrMask Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VConstrMask Case 2 \n");
+    PRINT_TIME("    N_VConstrMask Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ----------------------------------------------------------------------
+ * N_VMinQuotient Test
+ * --------------------------------------------------------------------*/
+int Test_N_VMinQuotient(N_Vector NUM, N_Vector DENOM, 
+                        long int local_length, int myid)
+{
+  int      fails = 0, failure = 0;
+  double   start_time, stop_time;
+  realtype ans;
+
+  /*
+   * Case 1: Pass
+   */
+
+  /* fill vector data */
+  N_VConst(TWO, NUM);
+  N_VConst(TWO, DENOM);
+  set_element(NUM, local_length-1, ONE);
+
+  start_time = get_time();
+  ans = N_VMinQuotient(NUM, DENOM);
+  stop_time = get_time(); 
+
+  /* ans should equal 1/2 */
+  failure = FNEQ(ans, HALF);
+  
+  if (failure) {
+    printf(">>> FAILED test -- N_VMinQuotient Case 1, Proc %d \n", myid);
+    PRINT_TIME("    N_VMinQuotient Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VMinQuotient Case 1 \n");
+    PRINT_TIME("    N_VMinQuotient Time: %22.15e \n \n", stop_time - start_time);
+  }    
+  
+  /*
+   * Case 2: Fail
+   */
+
+  /* reset failure */
+  failure = 0;
+
+  /* fill vector data */
+  N_VConst(TWO, NUM);
+  N_VConst(ZERO, DENOM);
+
+  start_time = get_time();
+  ans = N_VMinQuotient(NUM, DENOM);
+  stop_time = get_time(); 
+  
+  /* ans should equal BIG_REAL */
+  failure = FNEQ(ans, BIG_REAL);
+
+  if (failure) {
+    printf(">>> FAILED test -- N_VMinQuotient Case 2, Proc %d \n", myid);
+    PRINT_TIME("    N_VMinQuotient Time: %22.15e \n \n", stop_time - start_time);
+    fails++;
+  }
+  else if (myid == 0) {
+    printf("    PASSED test -- N_VMinQuotient Case 2 \n");
+    PRINT_TIME("    N_VMinQuotient Time: %22.15e \n \n", stop_time - start_time);
+  }    
+
+  return(fails);
+}
+
+
+/* ======================================================================
+ * Private functions
+ * ====================================================================*/
+
+#if defined( SUNDIALS_HAVE_POSIX_TIMERS) && defined(_POSIX_TIMERS)
+time_t base_time_tv_sec = 0; /* Base time; makes time values returned
+                                by get_time easier to read when
+                                printed since they will be zero
+                                based.
+                              */
+#endif
+
+void SetTiming(int onoff)
+{
+   print_time = onoff;
+
+#if defined( SUNDIALS_HAVE_POSIX_TIMERS) && defined(_POSIX_TIMERS)
+  struct timespec spec;  
+  clock_gettime( CLOCK_MONOTONIC_RAW, &spec );
+  base_time_tv_sec = spec.tv_sec;
+#endif
+}
+
+/* ----------------------------------------------------------------------
+ * Timer
+ * --------------------------------------------------------------------*/
+static double get_time()
+{
+#if defined( SUNDIALS_HAVE_POSIX_TIMERS) && defined(_POSIX_TIMERS)
+  struct timespec spec;  
+  clock_gettime( CLOCK_MONOTONIC_RAW, &spec );
+  double time = (double)(spec.tv_sec - base_time_tv_sec) + ((double)(spec.tv_nsec) / 1E9);
+#else
+  double time = 0;
+#endif
+  return time;
+}
+
+
diff --git a/examples/nvector/test_nvector.h b/examples/nvector/test_nvector.h
new file mode 100644
index 0000000..81852c9
--- /dev/null
+++ b/examples/nvector/test_nvector.h
@@ -0,0 +1,87 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 1.0 $
+ * $Date: 2013/08/31 12:25:00 $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file contains the prototypes for functions to 
+ * test an NVECTOR module implementation. 
+ * -----------------------------------------------------------------
+ */
+
+#include <math.h>
+
+/* define constatnts */
+#define NEG_TWO  RCONST(-2.0)
+#define NEG_ONE  RCONST(-1.0)
+#define NEG_HALF RCONST(-0.5)
+#define ZERO     RCONST(0.0)
+#define HALF     RCONST(0.5)
+#define ONE      RCONST(1.0)
+#define TWO      RCONST(2.0)
+
+/* NAN and floating point "equality" check, failure update macro */
+#if __STDC_VERSION__ >= 199901L
+#define FNEQ(a,b) (isnan(a) ? 1 : ( SUNRabs((a)-(b))/SUNRabs(b) > 1.0e-15 ))
+#else
+#define FNEQ(a,b) (( SUNRabs((a)-(b))/SUNRabs(b) > 1.0e-15 ))
+#endif
+
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+  /* Forward declarations for implementation specific utility functions */
+  int check_ans(realtype ans, N_Vector X, long int local_length);
+  booleantype has_data(N_Vector X);
+  void set_element(N_Vector X, long int i, realtype val);
+  realtype get_element(N_Vector X, long int i);
+
+  /* Test function declarations */
+  int Test_N_VCloneVectorArray(int count, N_Vector W, long int local_length, int myid);
+  int Test_N_VCloneEmptyVectorArray(int count, N_Vector W, int myid);
+  int Test_N_VCloneEmpty(N_Vector W, int myid);
+  int Test_N_VClone(N_Vector W, long int local_length, int myid);
+  int Test_N_VGetArrayPointer(N_Vector W, long int local_length, int myid);
+  int Test_N_VSetArrayPointer(N_Vector W, long int local_length, int myid);
+  int Test_N_VLinearSum(N_Vector X, N_Vector Y, N_Vector Z, 
+                        long int local_length, int myid);
+  int Test_N_VConst(N_Vector X, long int local_length, int myid);
+  int Test_N_VProd(N_Vector X, N_Vector Y, N_Vector Z, long int local_length, int myid);
+  int Test_N_VDiv(N_Vector X, N_Vector Y, N_Vector Z, long int local_length, int myid);
+  int Test_N_VScale(N_Vector X, N_Vector Z, long int local_length, int myid);
+  int Test_N_VAbs(N_Vector X, N_Vector Z, long int local_length, int myid);
+  int Test_N_VInv(N_Vector X, N_Vector Z, long int local_length, int myid);
+  int Test_N_VAddConst(N_Vector X, N_Vector Z, long int local_length, int myid);
+  int Test_N_VDotProd(N_Vector X, N_Vector Y, 
+                      long int local_length, long int global_length, int myid);
+  int Test_N_VMaxNorm(N_Vector X, long int local_length, int myid); 
+  int Test_N_VWrmsNorm(N_Vector X, N_Vector W, long int local_length, int myid);
+  int Test_N_VWrmsNormMask(N_Vector X, N_Vector W, N_Vector ID, 
+                           long int local_length, long int global_length, int myid);
+  int Test_N_VMin(N_Vector X, long int local_length, int myid); 
+  int Test_N_VWL2Norm(N_Vector X, N_Vector W, 
+                      long int local_length, long int global_length, int myid);
+  int Test_N_VL1Norm(N_Vector X, long int local_length, long int global_length, int myid);
+  int Test_N_VCompare(N_Vector X, N_Vector Z, long int local_length, int myid);
+  int Test_N_VInvTest(N_Vector X, N_Vector Z, long int local_length, int myid);
+  int Test_N_VConstrMask(N_Vector C, N_Vector X, N_Vector M, 
+                         long int local_length, int myid);
+  int Test_N_VMinQuotient(N_Vector NUM, N_Vector DENOM, long int local_length, int myid);
+
+  void SetTiming(int onoff);
+  
+#ifdef __cplusplus
+}
+#endif
diff --git a/examples/templates/cmakelists_openmp_C_ex.in b/examples/templates/cmakelists_openmp_C_ex.in
new file mode 100644
index 0000000..c12b5e3
--- /dev/null
+++ b/examples/templates/cmakelists_openmp_C_ex.in
@@ -0,0 +1,111 @@
+# -----------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ OpenMP examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(@SOLVER at _openmp_examples C)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+LIST(REMOVE_DUPLICATES examples)
+
+# Set names of examples specific dependency source files
+SET(examples_dependencies @EXAMPLES_DEPENDENCIES@)
+
+# Specify path to SUNDIALS header files
+SET(SUNDIALS_INC_DIR
+  @includedir@
+  CACHE STRING
+  "Location of SUNDIALS header files")
+  
+# Add path to SUNDIALS header files
+INCLUDE_DIRECTORIES(${SUNDIALS_INC_DIR})
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecopenmp ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
+FIND_PACKAGE(OpenMP)
+IF(OPENMP_FOUND)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+  # Use C flags for linker as well.
+  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+ELSE(OPENMP_FOUND)
+  message(STATUS "Disabling OpenMP support, could not determine compiler flags")
+ENDIF(OPENMP_FOUND)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.c ${examples_dependencies})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
+ 
diff --git a/examples/templates/cmakelists_openmp_F77_ex.in b/examples/templates/cmakelists_openmp_F77_ex.in
new file mode 100644
index 0000000..3fba4e9
--- /dev/null
+++ b/examples/templates/cmakelists_openmp_F77_ex.in
@@ -0,0 +1,107 @@
+# -----------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ openmp examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(F at SOLVER@_openmp_examples Fortran C)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+LIST(REMOVE_DUPLICATES examples)
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+FIND_LIBRARY(SUNDIALS_SOLVER_FLIB
+  @SOLVER_FLIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ F77-C library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecopenmp ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+FIND_LIBRARY(SUNDIALS_NVEC_FLIB
+  sundials_fnvecopenmp ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR F77-C library")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
+
+FIND_PACKAGE(OpenMP)
+IF(OPENMP_FOUND)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+  # Use C flags for linker as well.
+  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+ELSE(OPENMP_FOUND)
+  message(STATUS "Disabling OpenMP support, could not determine compiler flags")
+ENDIF(OPENMP_FOUND)
+
+# List of all libraries
+SET(SUNDIALS_LIBS 
+  ${SUNDIALS_SOLVER_FLIB} ${SUNDIALS_SOLVER_LIB}
+  ${SUNDIALS_NVEC_FLIB} ${SUNDIALS_NVEC_LIB}
+  ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.f)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
+
diff --git a/examples/templates/cmakelists_parallel_CXX_ex.in b/examples/templates/cmakelists_parallel_CXX_ex.in
new file mode 100644
index 0000000..381a8ca
--- /dev/null
+++ b/examples/templates/cmakelists_parallel_CXX_ex.in
@@ -0,0 +1,100 @@
+# -----------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ parallel examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(@SOLVER at _CXX_parallel_examples CXX)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@)
+
+# Set name of MPI compiler to be used (CXX or MPICXX)
+SET(MPI_MPICXX @MPICXX@ CACHE STRING "MPICXX compiler script")
+SET(CMAKE_CXX_COMPILER ${MPI_MPICXX})
+
+# Specify path to SUNDIALS header files
+SET(SUNDIALS_INC_DIR
+  @includedir@
+  CACHE STRING
+  "Location of SUNDIALS header files")
+
+# Add path to SUNDIALS header files
+INCLUDE_DIRECTORIES(${SUNDIALS_INC_DIR})
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecparallel ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.cpp)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
diff --git a/examples/templates/cmakelists_parallel_C_ex.in b/examples/templates/cmakelists_parallel_C_ex.in
index 25e8569..0f8b9f5 100644
--- a/examples/templates/cmakelists_parallel_C_ex.in
+++ b/examples/templates/cmakelists_parallel_C_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.2 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -30,6 +30,8 @@
 #
 # -----------------------------------------------------------------
 
+cmake_minimum_required(VERSION 2.8)
+
 # Specify project name
 PROJECT(@SOLVER at _parallel_examples C)
 
@@ -37,6 +39,10 @@ MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
 
 # Set the names of the examples to be built
 SET(examples @EXAMPLES@)
+LIST(REMOVE_DUPLICATES examples)
+
+# Set names of examples specific dependency source files
+SET(examples_dependencies @EXAMPLES_DEPENDENCIES@)
 
 # Set name of MPI compiler to be used (CC or MPICC)
 SET(MPI_MPICC @MPICC@ CACHE STRING "MPICC compiler script")
@@ -67,17 +73,32 @@ FIND_LIBRARY(SUNDIALS_NVEC_LIB
 # Set additional libraries
 SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
 
-# Set Blas/Lapack libraries
+# Set other libraries libraries
 SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIESY@ CACHE STRING "PETSC libraries")
 
 # List of all libraries
 SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
 IF(LAPACK_LIBRARIES)
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_LIBRARIES)
 
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
 # Build each example one by one
 FOREACH(example ${examples})
-  ADD_EXECUTABLE(${example} ${example}.c)
+  ADD_EXECUTABLE(${example} ${example}.c ${examples_dependencies})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
 ENDFOREACH(example ${examples})
diff --git a/examples/templates/cmakelists_parallel_F77_ex.in b/examples/templates/cmakelists_parallel_F77_ex.in
index c77c0c1..dc88376 100644
--- a/examples/templates/cmakelists_parallel_F77_ex.in
+++ b/examples/templates/cmakelists_parallel_F77_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.2 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -30,6 +30,8 @@
 #
 # -----------------------------------------------------------------
 
+cmake_minimum_required(VERSION 2.8)
+
 # Specify project name
 PROJECT(F at SOLVER@_parallel_examples Fortran)
 
@@ -66,8 +68,11 @@ FIND_LIBRARY(SUNDIALS_NVEC_FLIB
 # Set additional libraries
 SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
 
-# Set Blas/Lapack libraries
+# Set other libraries libraries
 SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
 
 # List of all libraries
 SET(SUNDIALS_LIBS 
@@ -75,11 +80,23 @@ SET(SUNDIALS_LIBS
   ${SUNDIALS_NVEC_FLIB} ${SUNDIALS_NVEC_LIB} 
   ${SUNDIALS_EXTRA_LIB})
 IF(LAPACK_LIBRARIES)
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_LIBRARIES)
 
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
 # Build each example one by one
 FOREACH(example ${examples})
   ADD_EXECUTABLE(${example} ${example}.f)
-  TARGET_LINK_LIBRARIES(${example} ${LIBS}) 
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS}) 
 ENDFOREACH(example ${examples})
diff --git a/examples/templates/cmakelists_parallel_F90_ex.in b/examples/templates/cmakelists_parallel_F90_ex.in
new file mode 100644
index 0000000..3bd95fe
--- /dev/null
+++ b/examples/templates/cmakelists_parallel_F90_ex.in
@@ -0,0 +1,97 @@
+# -----------------------------------------------------------------
+# $Revision: 4944 $
+# $Date: 2016-09-21 21:48:35 -0700 (Wed, 21 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ Fortran parallel examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(F90 at SOLVER@_parallel_examples Fortran)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@)
+
+# Set name of MPI compiler to be used (F90 or MPIF90)
+SET(MPI_MPIF90 @MPIF90@ CACHE STRING "MPIF90 compiler script")
+SET(CMAKE_Fortran_COMPILER ${MPI_MPIF90})
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+FIND_LIBRARY(SUNDIALS_SOLVER_FLIB
+  @SOLVER_FLIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ Fortran-C library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecparallel ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+FIND_LIBRARY(SUNDIALS_NVEC_FLIB
+  sundials_fnvecparallel ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR F90-C library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS 
+  ${SUNDIALS_SOLVER_FLIB} ${SUNDIALS_SOLVER_LIB} 
+  ${SUNDIALS_NVEC_FLIB} ${SUNDIALS_NVEC_LIB} 
+  ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.f90)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS}) 
+ENDFOREACH(example ${examples})
diff --git a/examples/templates/cmakelists_parhyp_C_ex.in b/examples/templates/cmakelists_parhyp_C_ex.in
new file mode 100644
index 0000000..7c683fd
--- /dev/null
+++ b/examples/templates/cmakelists_parhyp_C_ex.in
@@ -0,0 +1,110 @@
+# -----------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ parhyp examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(@SOLVER at _parhyp_examples C)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@)
+
+# Set names of examples specific dependency source files
+SET(examples_dependencies @EXAMPLES_DEPENDENCIES@)
+
+# Set name of MPI compiler to be used (CC or MPICC)
+SET(MPI_MPICC @MPICC@ CACHE STRING "MPICC compiler script")
+SET(CMAKE_C_COMPILER ${MPI_MPICC})
+
+# Specify path to SUNDIALS header files
+SET(SUNDIALS_INC_DIR
+  @includedir@
+  CACHE STRING
+  "Location of SUNDIALS header files")
+
+SET(HYPRE_INC_DIR
+  @HYPRE_INCLUDE_DIR@
+  CACHE STRING
+  "Location of HYPRE header files")
+
+# Add path to SUNDIALS header files
+INCLUDE_DIRECTORIES(${SUNDIALS_INC_DIR})
+INCLUDE_DIRECTORIES(${HYPRE_INC_DIR})
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecparhyp ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(HYPRE_LIBRARIES @HYPRE_LIBS@ CACHE STRING "HYPRE libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
+
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(HYPRE_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${HYPRE_LIBRARIES})
+ENDIF(HYPRE_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.c ${examples_dependencies})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
diff --git a/examples/templates/cmakelists_petsc_C_ex.in b/examples/templates/cmakelists_petsc_C_ex.in
new file mode 100644
index 0000000..4e3d9bd
--- /dev/null
+++ b/examples/templates/cmakelists_petsc_C_ex.in
@@ -0,0 +1,109 @@
+# -----------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ petsc examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(@SOLVER at _petsc_examples C)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@)
+
+# Set names of examples specific dependency source files
+SET(examples_dependencies @EXAMPLES_DEPENDENCIES@)
+
+# Set name of MPI compiler to be used (CC or MPICC)
+SET(MPI_MPICC @MPICC@ CACHE STRING "MPICC compiler script")
+SET(CMAKE_C_COMPILER ${MPI_MPICC})
+
+# Specify path to SUNDIALS header files
+SET(SUNDIALS_INC_DIR
+  @includedir@
+  CACHE STRING
+  "Location of SUNDIALS header files")
+
+SET(PETSC_INC_DIR
+  @PETSC_INCLUDE_DIR@
+  CACHE STRING
+  "Location of NVector PETSC header files")
+
+# Add path to SUNDIALS header files
+INCLUDE_DIRECTORIES(${SUNDIALS_INC_DIR})
+INCLUDE_DIRECTORIES(${PETSC_INC_DIR})
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+# Find the NVECTOR PETSC library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecpetsc ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.c ${examples_dependencies})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
diff --git a/examples/templates/cmakelists_pthreads_C_ex.in b/examples/templates/cmakelists_pthreads_C_ex.in
new file mode 100644
index 0000000..fea6cbd
--- /dev/null
+++ b/examples/templates/cmakelists_pthreads_C_ex.in
@@ -0,0 +1,85 @@
+# -----------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ serial examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(@SOLVER at _pthreads_examples C)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+
+# Set names of examples specific dependency source files
+SET(examples_dependencies @EXAMPLES_DEPENDENCIES@)
+
+# Specify path to SUNDIALS header files
+SET(SUNDIALS_INC_DIR
+  @includedir@
+  CACHE STRING
+  "Location of SUNDIALS header files")
+
+# Add path to SUNDIALS header files
+INCLUDE_DIRECTORIES(${SUNDIALS_INC_DIR})
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecserial ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set Blas/Lapack libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.c ${examples_dependencies})
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
+ 
diff --git a/examples/templates/cmakelists_pthreads_F77_ex.in b/examples/templates/cmakelists_pthreads_F77_ex.in
new file mode 100644
index 0000000..280bba4
--- /dev/null
+++ b/examples/templates/cmakelists_pthreads_F77_ex.in
@@ -0,0 +1,100 @@
+# -----------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ pthreads examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(F at SOLVER@_pthreads_examples Fortran)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+FIND_LIBRARY(SUNDIALS_SOLVER_FLIB
+  @SOLVER_FLIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ F77-C library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecpthreads ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+FIND_LIBRARY(SUNDIALS_NVEC_FLIB
+  sundials_fnvecpthreads ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR F77-C library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS 
+  ${SUNDIALS_SOLVER_FLIB} ${SUNDIALS_SOLVER_LIB}
+  ${SUNDIALS_NVEC_FLIB} ${SUNDIALS_NVEC_LIB}
+  ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.f)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
+
diff --git a/examples/templates/cmakelists_serial_CXX_ex.in b/examples/templates/cmakelists_serial_CXX_ex.in
new file mode 100644
index 0000000..43b224b
--- /dev/null
+++ b/examples/templates/cmakelists_serial_CXX_ex.in
@@ -0,0 +1,93 @@
+# -----------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ serial examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(@SOLVER at _CXX_serial_examples CXX)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+
+# Specify path to SUNDIALS header files
+SET(SUNDIALS_INC_DIR
+  @includedir@
+  CACHE STRING
+  "Location of SUNDIALS header files")
+
+# Add path to SUNDIALS header files
+INCLUDE_DIRECTORIES(${SUNDIALS_INC_DIR})
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecserial ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.cpp)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
+ 
diff --git a/examples/templates/cmakelists_serial_C_ex.in b/examples/templates/cmakelists_serial_C_ex.in
index c0523fd..d13301f 100644
--- a/examples/templates/cmakelists_serial_C_ex.in
+++ b/examples/templates/cmakelists_serial_C_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.3 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -30,6 +30,8 @@
 #
 # -----------------------------------------------------------------
 
+cmake_minimum_required(VERSION 2.8)
+
 # Specify project name
 PROJECT(@SOLVER at _serial_examples C)
 
@@ -37,6 +39,10 @@ MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
 
 # Set the names of the examples to be built
 SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+LIST(REMOVE_DUPLICATES examples)
+
+# Set names of examples specific dependency source files
+SET(examples_dependencies @EXAMPLES_DEPENDENCIES@)
 
 # Specify path to SUNDIALS header files
 SET(SUNDIALS_INC_DIR
@@ -63,18 +69,33 @@ FIND_LIBRARY(SUNDIALS_NVEC_LIB
 # Set additional libraries
 SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
 
-# Set Blas/Lapack libraries
+# Set other libraries libraries
 SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
 
 # List of all libraries
 SET(SUNDIALS_LIBS ${SUNDIALS_SOLVER_LIB} ${SUNDIALS_NVEC_LIB} ${SUNDIALS_EXTRA_LIB})
 IF(LAPACK_LIBRARIES)
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_LIBRARIES)
 
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
 # Build each example one by one
 FOREACH(example ${examples})
-  ADD_EXECUTABLE(${example} ${example}.c)
+  ADD_EXECUTABLE(${example} ${example}.c ${examples_dependencies})
   TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
 ENDFOREACH(example ${examples})
  
diff --git a/examples/templates/cmakelists_serial_F77_ex.in b/examples/templates/cmakelists_serial_F77_ex.in
index 2288c40..9b39fff 100644
--- a/examples/templates/cmakelists_serial_F77_ex.in
+++ b/examples/templates/cmakelists_serial_F77_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.3 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -30,6 +30,8 @@
 #
 # -----------------------------------------------------------------
 
+cmake_minimum_required(VERSION 2.8)
+
 # Specify project name
 PROJECT(F at SOLVER@_serial_examples Fortran)
 
@@ -37,6 +39,7 @@ MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
 
 # Set the names of the examples to be built
 SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+LIST(REMOVE_DUPLICATES examples)
 
 # Set search path for SUNDIALS libraries 
 SET(SUNDIALS_LIB_DIR @libdir@)
@@ -62,8 +65,11 @@ FIND_LIBRARY(SUNDIALS_NVEC_FLIB
 # Set additional libraries
 SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
 
-# Set Blas/Lapack libraries
+# Set other libraries libraries
 SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+SET(PETSC_LIBRARIES @PETSC_LIBRARIES@ CACHE STRING "PETSC libraries")
 
 # List of all libraries
 SET(SUNDIALS_LIBS 
@@ -71,9 +77,21 @@ SET(SUNDIALS_LIBS
   ${SUNDIALS_NVEC_FLIB} ${SUNDIALS_NVEC_LIB}
   ${SUNDIALS_EXTRA_LIB})
 IF(LAPACK_LIBRARIES)
-  SET(SUNDIALS_LIBS "${SUNDIALS_LIBS} ${LAPACK_LIBRARIES}")
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
 ENDIF(LAPACK_LIBRARIES)
 
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+IF(PETSC_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${PETSC_LIBRARIES})
+ENDIF(PETSC_LIBRARIES)
+
 # Build each example one by one
 FOREACH(example ${examples})
   ADD_EXECUTABLE(${example} ${example}.f)
diff --git a/examples/templates/cmakelists_serial_F90_ex.in b/examples/templates/cmakelists_serial_F90_ex.in
new file mode 100644
index 0000000..8641fa9
--- /dev/null
+++ b/examples/templates/cmakelists_serial_F90_ex.in
@@ -0,0 +1,93 @@
+# -----------------------------------------------------------------
+# $Revision: 4824 $
+# $Date: 2016-07-24 16:39:04 -0700 (Sun, 24 Jul 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# CMakeLists.txt for @SOLVER@ serial examples
+#
+# This file is generated from a template using  various variables
+# set at configuration time. It can be used as a template for
+# other user CMakeLists configuration files.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LAPACK_LIBRARIES. Otherwise, this variable should contain
+# an empty string or LAPACK_LIBRARIES-NOTFOUND. If this variable 
+# contains a valid library entry, we add it to each example traget
+# whether they use the Lapack module or not. This is done in order
+# to address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+#
+# -----------------------------------------------------------------
+cmake_minimum_required(VERSION 2.8)
+
+# Specify project name
+PROJECT(F90 at SOLVER@_serial_examples Fortran)
+
+MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
+
+# Set the names of the examples to be built
+SET(examples @EXAMPLES@ @EXAMPLES_BL@)
+
+# Set search path for SUNDIALS libraries 
+SET(SUNDIALS_LIB_DIR @libdir@)
+
+# Find the SUNDIALS solver's library
+FIND_LIBRARY(SUNDIALS_SOLVER_LIB
+  @SOLVER_LIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ library")
+
+FIND_LIBRARY(SUNDIALS_SOLVER_FLIB
+  @SOLVER_FLIB@ ${SUNDIALS_LIB_DIR}
+  DOC "@SOLVER@ Fortran-C library")
+
+# Find the NVECTOR library
+FIND_LIBRARY(SUNDIALS_NVEC_LIB
+  sundials_nvecserial ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR library")
+
+FIND_LIBRARY(SUNDIALS_NVEC_FLIB
+  sundials_fnvecserial ${SUNDIALS_LIB_DIR}
+  DOC "NVECTOR Fortran-C library")
+
+# Set additional libraries
+SET(SUNDIALS_EXTRA_LIB @LIBS@ CACHE STRING "Additional libraries")
+
+# Set other libraries libraries
+SET(LAPACK_LIBRARIES @BLAS_LAPACK_LIBS@ CACHE STRING "Lapack libraries")
+SET(SUPERLUMT_LIBRARIES @SUPERLUMT_LIBRARIES@ CACHE STRING "SuperLUMT libraries")
+SET(KLU_LIBRARIES @KLU_LIBRARIES@ CACHE STRING "KLU libraries")
+
+# List of all libraries
+SET(SUNDIALS_LIBS 
+  ${SUNDIALS_SOLVER_FLIB} ${SUNDIALS_SOLVER_LIB}
+  ${SUNDIALS_NVEC_FLIB} ${SUNDIALS_NVEC_LIB}
+  ${SUNDIALS_EXTRA_LIB})
+IF(LAPACK_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${LAPACK_LIBRARIES})
+ENDIF(LAPACK_LIBRARIES)
+
+IF(SUPERLUMT_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${SUPERLUMT_LIBRARIES})
+ENDIF(SUPERLUMT_LIBRARIES)
+
+IF(KLU_LIBRARIES)
+  LIST(APPEND SUNDIALS_LIBS ${KLU_LIBRARIES})
+ENDIF(KLU_LIBRARIES)
+
+# Build each example one by one
+FOREACH(example ${examples})
+  ADD_EXECUTABLE(${example} ${example}.f90)
+  TARGET_LINK_LIBRARIES(${example} ${SUNDIALS_LIBS})
+ENDFOREACH(example ${examples})
+
diff --git a/examples/templates/makefile_openmp_C_ex.in b/examples/templates/makefile_openmp_C_ex.in
new file mode 100644
index 0000000..2469d86
--- /dev/null
+++ b/examples/templates/makefile_openmp_C_ex.in
@@ -0,0 +1,83 @@
+# -----------------------------------------------------------------
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Steven Smith @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ pthreads examples.
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, whether they use the Lapack module or not, to
+# address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+CPP      = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CC       = @CC@
+CFLAGS   = @CFLAGS@ @OpenMP_C_FLAGS@
+LDFLAGS  = @LDFLAGS@ @OpenMP_C_FLAGS@
+LIBS     = @LIBS@
+
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+INCLUDES = -I${includedir}
+LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecopenmp ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+LIBRARIES_PETSC = @PETSC_LIBRARIES@
+
+EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
+EXAMPLES_DEPENDENCIES = @EXAMPLES_DEPENDENCIES@
+
+OBJECTS = ${EXAMPLES:=.o}
+OBJECTS_DEPENDENCIES = ${EXAMPLES_DEPENDENCIES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .c
+
+.c.o :
+	${CC} ${CPPFLAGS} ${CFLAGS} ${INCLUDES} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${CC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS}" ; \
+	  ${CC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS} ; \
+	done
+	
+${OBJECTS}: ${OBJECTS_DEPENDENCIES}
+
+clean:
+	rm -f ${OBJECTS_DEPENDENCIES}
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
+
diff --git a/examples/templates/makefile_openmp_F77_ex.in b/examples/templates/makefile_openmp_F77_ex.in
new file mode 100644
index 0000000..599e093
--- /dev/null
+++ b/examples/templates/makefile_openmp_F77_ex.in
@@ -0,0 +1,76 @@
+# -----------------------------------------------------------------
+# $Revision: 4074 $
+# $Date: 2014-04-23 14:13:52 -0700 (Wed, 23 Apr 2014) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2014, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ Fortran OpenMP examples
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, whether they use the Lapack module or not, to
+# address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+F77         = @F77@
+FFLAGS      = @FFLAGS@ @OpenMP_C_FLAGS@
+F77_LNKR    = @F77_LNKR@ @OpenMP_C_FLAGS@
+F77_LDFLAGS = @F77_LDFLAGS@
+F77_LIBS    = @F77_LIBS@
+
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+LIBRARIES = -l at SOLVER_FLIB@ -l at SOLVER_LIB@ -lsundials_fnvecopenmp -lsundials_nvecopenmp ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+LIBRARIES_PETSC = @PETSC_LIBRARIES@
+
+EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
+
+OBJECTS = ${EXAMPLES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .f
+
+.f.o :
+	${F77} ${FFLAGS} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS}" ; \
+	  ${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS} ; \
+	done
+
+clean:
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
+
diff --git a/examples/templates/makefile_parallel_CXX_ex.in b/examples/templates/makefile_parallel_CXX_ex.in
new file mode 100644
index 0000000..aef617d
--- /dev/null
+++ b/examples/templates/makefile_parallel_CXX_ex.in
@@ -0,0 +1,82 @@
+# -----------------------------------------------------------------
+# $Revision: 4824 $
+# $Date: 2016-07-24 16:39:04 -0700 (Sun, 24 Jul 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ parallel examples
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, even the parallel ones which obviously cannot 
+# use the Lapack linear solver modules simply to address the case 
+# in which the SUNDIALS libraries are shared objects. In that case, 
+# the solver library references Lapack  symbols which must be 
+# always resolved by linking against the Blas/Lapack libraries. 
+# If only static SUNDIALS libraries have been built, it is not 
+# required to link the Blas/Lapack libraries for the parallel 
+# examples...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+CPP         = @CPP@
+CPPFLAGS    = @CPPFLAGS@ -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX -DLAM_BUILDING
+CXX         = @CXX@
+CXXFLAGS    = @CXXFLAGS@
+LDFLAGS     = @LDFLAGS@
+LIBS        = @LIBS@
+MPICXX      = @MPICXX@
+MPI_INC_DIR = @MPI_INC_DIR@
+MPI_LIB_DIR = @MPI_LIB_DIR@
+MPI_LIBS    = @MPI_LIBS@
+MPI_FLAGS   = @MPI_FLAGS@
+
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+INCLUDES = -I${includedir} -I${MPI_INC_DIR}
+LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecparallel ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+
+EXAMPLES = @EXAMPLES@
+
+OBJECTS = ${EXAMPLES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .cpp
+
+.cpp.o :
+	${MPICXX} ${CPPFLAGS} ${CXXFLAGS} ${MPI_FLAGS} ${INCLUDES} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${MPICXX} -o $${i} $${i}.o ${MPI_FLAGS} ${CXXFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS}" ; \
+	  ${MPICXX} -o $${i} $${i}.o ${MPI_FLAGS} ${CXXFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS} ; \
+	done
+
+clean:
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
diff --git a/examples/templates/makefile_parallel_C_ex.in b/examples/templates/makefile_parallel_C_ex.in
index d55656b..802d459 100644
--- a/examples/templates/makefile_parallel_C_ex.in
+++ b/examples/templates/makefile_parallel_C_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.2 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -42,6 +42,7 @@ CC          = @CC@
 CFLAGS      = @CFLAGS@
 LDFLAGS     = @LDFLAGS@
 LIBS        = @LIBS@
+LINKFLAGS = -Wl,-rpath, at libdir@
 MPICC       = @MPICC@
 MPI_INC_DIR = @MPI_INC_DIR@
 MPI_LIB_DIR = @MPI_LIB_DIR@
@@ -51,10 +52,15 @@ MPI_FLAGS   = @MPI_FLAGS@
 INCLUDES = -I${includedir} -I${MPI_INC_DIR}
 LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecparallel ${LIBS}
 LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+LIBRARIES_PETSC = @PETSC_LIBRARIES@
 
 EXAMPLES = @EXAMPLES@
+EXAMPLES_DEPENDENCIES = @EXAMPLES_DEPENDENCIES@
 
 OBJECTS = ${EXAMPLES:=.o}
+OBJECTS_DEPENDENCIES = ${EXAMPLES_DEPENDENCIES:=.o}
 
 # -----------------------------------------------------------------------------------------
 
@@ -67,11 +73,14 @@ OBJECTS = ${EXAMPLES:=.o}
 
 all: ${OBJECTS}
 	@for i in ${EXAMPLES} ; do \
-	  echo "${MPICC} -o $${i} $${i}.o ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL}" ; \
-	  ${MPICC} -o $${i} $${i}.o ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL}; \
+	  echo "${MPICC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS}" ; \
+	  ${MPICC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS} ; \
 	done
 
+${OBJECTS}: ${OBJECTS_DEPENDENCIES}
+
 clean:
+	rm -f ${OBJECTS_DEPENDENCIES}
 	rm -f ${OBJECTS}
 	rm -f ${EXAMPLES}
 
diff --git a/examples/templates/makefile_parallel_F77_ex.in b/examples/templates/makefile_parallel_F77_ex.in
index 8a7b34a..df4a8b3 100644
--- a/examples/templates/makefile_parallel_F77_ex.in
+++ b/examples/templates/makefile_parallel_F77_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.2 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -41,6 +41,8 @@ FFLAGS       = @FFLAGS@
 F77_LDFLAGS  = @F77_LDFLAGS@
 F77_LIBS     = @F77_LIBS@
 
+LINKFLAGS = -Wl,-rpath, at libdir@
+
 MPIF77       = @MPIF77@
 MPI_INC_DIR  = @MPI_INC_DIR@
 MPI_FLAGS    = @MPI_FLAGS@
@@ -50,6 +52,9 @@ MPI_LIBS     = @MPI_LIBS@
 
 LIBRARIES = -l at SOLVER_FLIB@ -l at SOLVER_LIB@ -lsundials_fnvecparallel -lsundials_nvecparallel ${LIBS}
 LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+LIBRARIES_PETSC = @PETSC_LIBRARIES@
 
 EXAMPLES = @EXAMPLES@
 
@@ -66,8 +71,8 @@ OBJECTS = ${EXAMPLES:=.o}
 
 all: ${OBJECTS}
 	@for i in ${EXAMPLES} ; do \
-	  echo "${MPIF77_LNKR} -o $${i} $${i}.o ${MPI_FLAGS} ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL}" ; \
-	  ${MPIF77_LNKR} -o $${i} $${i}.o ${MPI_FLAGS} ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL}; \
+	  echo "${MPIF77_LNKR} -o $${i} $${i}.o ${MPI_FLAGS} ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS}" ; \
+	  ${MPIF77_LNKR} -o $${i} $${i}.o ${MPI_FLAGS} ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS} ; \
 	done
 
 clean:
diff --git a/examples/templates/makefile_parallel_F90_ex.in b/examples/templates/makefile_parallel_F90_ex.in
new file mode 100644
index 0000000..b5bee6c
--- /dev/null
+++ b/examples/templates/makefile_parallel_F90_ex.in
@@ -0,0 +1,80 @@
+# -----------------------------------------------------------------
+# $Revision: 4824 $
+# $Date: 2016-07-24 16:39:04 -0700 (Sun, 24 Jul 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ fortran parallel examples
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, even the parallel ones which obviously cannot 
+# use the Lapack linear solver modules simply to address the case 
+# in which the SUNDIALS libraries are shared objects. In that case, 
+# the solver library references Lapack  symbols which must be 
+# always resolved by linking against the Blas/Lapack libraries. 
+# If only static SUNDIALS libraries have been built, it is not 
+# required to link the Blas/Lapack libraries for the parallel 
+# examples...
+#
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+F90FLAGS     = @F90FLAGS@
+F90_LDFLAGS  = @F90_LDFLAGS@
+F90_LIBS     = @F90_LIBS@
+
+MPIF90       = @MPIF90@
+MPI_INC_DIR  = @MPI_INC_DIR@
+MPI_FLAGS    = @MPI_FLAGS@
+MPI_LIB_DIR  = @MPI_LIB_DIR@
+MPI_LIBS     = @MPI_LIBS@
+
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+LIBRARIES = -l at SOLVER_FLIB@ -l at SOLVER_LIB@ -lsundials_fnvecparallel -lsundials_nvecparallel ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+
+EXAMPLES = @EXAMPLES@
+
+OBJECTS = ${EXAMPLES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .f90
+
+.f90.o :
+	${MPIF90} ${F90FLAGS} ${MPI_FLAGS} -I${MPI_INC_DIR} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${MPIF90} -o $${i} $${i}.o ${MPI_FLAGS} ${F90_LDFLAGS} ${F90_LIBS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS}" ; \
+	  ${MPIF90} -o $${i} $${i}.o ${MPI_FLAGS} ${F90_LDFLAGS} ${F90_LIBS} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS} ; \
+	done
+
+clean:
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
diff --git a/examples/templates/makefile_parhyp_C_ex.in b/examples/templates/makefile_parhyp_C_ex.in
new file mode 100644
index 0000000..9e56fdd
--- /dev/null
+++ b/examples/templates/makefile_parhyp_C_ex.in
@@ -0,0 +1,90 @@
+# -----------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ parhyp examples
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, even the parhyp ones which obviously cannot 
+# use the Lapack linear solver modules simply to address the case 
+# in which the SUNDIALS libraries are shared objects. In that case, 
+# the solver library references Lapack  symbols which must be 
+# always resolved by linking against the Blas/Lapack libraries. 
+# If only static SUNDIALS libraries have been built, it is not 
+# required to link the Blas/Lapack libraries for the parhyp 
+# examples...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+CPP         = @CPP@
+CPPFLAGS    = @CPPFLAGS@
+CC          = @CC@
+CFLAGS      = @CFLAGS@ @OpenMP_C_FLAGS@
+LDFLAGS     = @LDFLAGS@ @OpenMP_C_FLAGS@
+LIBS        = @LIBS@
+LINKFLAGS = -Wl,-rpath, at libdir@
+MPICC       = @MPICC@
+MPI_INC_DIR = @MPI_INC_DIR@
+MPI_LIB_DIR = @MPI_LIB_DIR@
+MPI_LIBS    = @MPI_LIBS@
+MPI_FLAGS   = @MPI_FLAGS@
+HYPRE_INC_DIR = @HYPRE_INCLUDE_DIR@
+HYPRE_LIB_DIR = @HYPRE_LIB_DIR@
+HYPRE_LIBS    = @HYPRE_LIBRARIES@
+HYPRE_FLAGS   = @HYPRE_FLAGS@
+
+INCLUDES = -I${includedir} -I${MPI_INC_DIR} -I${HYPRE_INC_DIR}
+LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecparhyp ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+
+EXAMPLES = @EXAMPLES@
+EXAMPLES_DEPENDENCIES = @EXAMPLES_DEPENDENCIES@
+
+OBJECTS = ${EXAMPLES:=.o}
+OBJECTS_DEPENDENCIES = ${EXAMPLES_DEPENDENCIES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .c
+
+.c.o :
+	${MPICC} ${CPPFLAGS} ${CFLAGS} ${MPI_FLAGS} ${INCLUDES} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${MPICC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${HYPRE_LIBS} ${LINKFLAGS}" ; \
+	  ${MPICC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${HYPRE_LIBS} ${LINKFLAGS} ; \
+	done
+
+${OBJECTS}: ${OBJECTS_DEPENDENCIES}
+
+clean:
+	rm -f ${OBJECTS_DEPENDENCIES}
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
diff --git a/examples/templates/makefile_petsc_C_ex.in b/examples/templates/makefile_petsc_C_ex.in
new file mode 100644
index 0000000..07ced4e
--- /dev/null
+++ b/examples/templates/makefile_petsc_C_ex.in
@@ -0,0 +1,89 @@
+# -----------------------------------------------------------------
+# $Revision: 4456 $
+# $Date: 2015-03-28 20:22:03 -0700 (Sat, 28 Mar 2015) $
+# -----------------------------------------------------------------
+# Programmer: Radu Serban @ LLNL
+#             Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2007, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ parallel examples
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, even the parallel ones which obviously cannot 
+# use the Lapack linear solver modules simply to address the case 
+# in which the SUNDIALS libraries are shared objects. In that case, 
+# the solver library references Lapack  symbols which must be 
+# always resolved by linking against the Blas/Lapack libraries. 
+# If only static SUNDIALS libraries have been built, it is not 
+# required to link the Blas/Lapack libraries for the parallel 
+# examples...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+CPP         = @CPP@
+CPPFLAGS    = @CPPFLAGS@
+CC          = @CC@
+CFLAGS      = @CFLAGS@
+LDFLAGS     = @LDFLAGS@
+LIBS        = @LIBS@
+LINKFLAGS = -Wl,-rpath, at libdir@
+MPICC       = @MPICC@
+MPI_INC_DIR = @MPI_INC_DIR@
+MPI_LIB_DIR = @MPI_LIB_DIR@
+MPI_LIBS    = @MPI_LIBS@
+MPI_FLAGS   = @MPI_FLAGS@
+PETSC_LIBS = @PETSC_LIBRARIES@
+PETSC_INC_DIR = @PETSC_INCLUDE_DIR@
+
+INCLUDES = -I${includedir} -I${MPI_INC_DIR} -I${PETSC_INC_DIR}
+LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecpetsc ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+
+EXAMPLES = @EXAMPLES@
+EXAMPLES_DEPENDENCIES = @EXAMPLES_DEPENDENCIES@
+
+OBJECTS = ${EXAMPLES:=.o}
+OBJECTS_DEPENDENCIES = ${EXAMPLES_DEPENDENCIES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .c
+
+.c.o :
+	${MPICC} ${CPPFLAGS} ${CFLAGS} ${MPI_FLAGS} ${INCLUDES} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${MPICC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${PETSC_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS}" ; \
+	  ${MPICC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${MPI_FLAGS} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} -L${MPI_LIB_DIR} ${MPI_LIBS} ${PETSC_LIBS} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS} ; \
+	done
+
+${OBJECTS}: ${OBJECTS_DEPENDENCIES}
+
+clean:
+	rm -f ${OBJECTS_DEPENDENCIES}
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
diff --git a/examples/templates/makefile_pthreads_C_ex.in b/examples/templates/makefile_pthreads_C_ex.in
new file mode 100644
index 0000000..9b80b69
--- /dev/null
+++ b/examples/templates/makefile_pthreads_C_ex.in
@@ -0,0 +1,81 @@
+# -----------------------------------------------------------------
+# $Revision: 4824 $
+# $Date: 2016-07-24 16:39:04 -0700 (Sun, 24 Jul 2016) $
+# -----------------------------------------------------------------
+# Programmer: Steven Smith @ LLNL
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ pthreads examples.
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, whether they use the Lapack module or not, to
+# address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+CPP      = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CC       = @CC@
+CFLAGS   = @CFLAGS@
+LDFLAGS  = @LDFLAGS@ @CMAKE_THREAD_LIBS_INIT@
+LIBS     = @LIBS@
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+INCLUDES = -I${includedir}
+LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecpthreads ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+
+EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
+EXAMPLES_DEPENDENCIES = @EXAMPLES_DEPENDENCIES@
+
+OBJECTS = ${EXAMPLES:=.o}
+OBJECTS_DEPENDENCIES = ${EXAMPLES_DEPENDENCIES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .c
+
+.c.o :
+	${CC} ${CPPFLAGS} ${CFLAGS} ${INCLUDES} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${CC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS}" ; \
+	  ${CC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS} ; \
+	done
+
+${OBJECTS}: ${OBJECTS_DEPENDENCIES}
+
+clean:
+	rm -f ${OBJECTS_DEPENDENCIES}
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
+
diff --git a/examples/templates/makefile_pthreads_F77_ex.in b/examples/templates/makefile_pthreads_F77_ex.in
new file mode 100644
index 0000000..3ee0acd
--- /dev/null
+++ b/examples/templates/makefile_pthreads_F77_ex.in
@@ -0,0 +1,76 @@
+# -----------------------------------------------------------------
+# $Revision: 4074 $
+# $Date: 2014-04-23 14:13:52 -0700 (Wed, 23 Apr 2014) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2014, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ Fortran pthreads examples
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, whether they use the Lapack module or not, to
+# address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+F77         = @F77@
+FFLAGS      = @FFLAGS@
+F77_LNKR    = @F77_LNKR@
+F77_LDFLAGS = @F77_LDFLAGS@ @CMAKE_THREAD_LIBS_INIT@
+F77_LIBS    = @F77_LIBS@
+
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+LIBRARIES = -l at SOLVER_FLIB@ -l at SOLVER_LIB@ -lsundials_fnvecpthreads -lsundials_nvecpthreads ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+LIBRARIES_PETSC = @PETSC_LIBRARIES@
+
+EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
+
+OBJECTS = ${EXAMPLES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .f
+
+.f.o :
+	${F77} ${FFLAGS} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS}" ; \
+	  ${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS} ; \
+	done
+
+clean:
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
+
diff --git a/examples/templates/makefile_serial_CXX_ex.in b/examples/templates/makefile_serial_CXX_ex.in
new file mode 100644
index 0000000..7c7586d
--- /dev/null
+++ b/examples/templates/makefile_serial_CXX_ex.in
@@ -0,0 +1,77 @@
+# -----------------------------------------------------------------
+# $Revision: 4944 $
+# $Date: 2016-09-21 21:48:35 -0700 (Wed, 21 Sep 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ serial examples.
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, whether they use the Lapack module or not, to
+# address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+CPP      = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX      = @CXX@
+CXXFLAGS   = @CXXFLAGS@
+LDFLAGS  = @LDFLAGS@
+LIBS     = @LIBS@
+
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+INCLUDES = -I${includedir}
+LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecserial ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+
+EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
+
+OBJECTS = ${EXAMPLES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .cpp
+
+.cpp.o :
+	${CXX} ${CPPFLAGS} ${CXXFLAGS} ${INCLUDES} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${CXX} -o $${i} $${i}.o ${CXXFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS}" ; \
+	  ${CXX} -o $${i} $${i}.o ${CXXFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS} ; \
+	done
+
+clean:
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
+
diff --git a/examples/templates/makefile_serial_C_ex.in b/examples/templates/makefile_serial_C_ex.in
index a9b9382..5a5460b 100644
--- a/examples/templates/makefile_serial_C_ex.in
+++ b/examples/templates/makefile_serial_C_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.3 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -42,13 +42,20 @@ CFLAGS   = @CFLAGS@
 LDFLAGS  = @LDFLAGS@
 LIBS     = @LIBS@
 
+LINKFLAGS = -Wl,-rpath, at libdir@
+
 INCLUDES = -I${includedir}
 LIBRARIES = -l at SOLVER_LIB@ -lsundials_nvecserial ${LIBS}
 LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+LIBRARIES_PETSC = @PETSC_LIBRARIES@
 
 EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
+EXAMPLES_DEPENDENCIES = @EXAMPLES_DEPENDENCIES@
 
 OBJECTS = ${EXAMPLES:=.o}
+OBJECTS_DEPENDENCIES = ${EXAMPLES_DEPENDENCIES:=.o}
 
 # -----------------------------------------------------------------------------------------
 
@@ -61,11 +68,14 @@ OBJECTS = ${EXAMPLES:=.o}
 
 all: ${OBJECTS}
 	@for i in ${EXAMPLES} ; do \
-	  echo "${CC} -o $${i} $${i}.o ${CFLAGS} ${LDFLAGS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL}" ; \
-	  ${CC} -o $${i} $${i}.o ${CFLAGS} ${LDFLAGS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL}; \
+	  echo "${CC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS}" ; \
+	  ${CC} -o $${i} $${i}.o ${OBJECTS_DEPENDENCIES} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS} ; \
 	done
 
+${OBJECTS}: ${OBJECTS_DEPENDENCIES}
+
 clean:
+	rm -f ${OBJECTS_DEPENDENCIES}
 	rm -f ${OBJECTS}
 	rm -f ${EXAMPLES}
 
diff --git a/examples/templates/makefile_serial_F77_ex.in b/examples/templates/makefile_serial_F77_ex.in
index 863f354..a31e37d 100644
--- a/examples/templates/makefile_serial_F77_ex.in
+++ b/examples/templates/makefile_serial_F77_ex.in
@@ -1,6 +1,6 @@
 # -----------------------------------------------------------------
-# $Revision: 1.3 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4958 $
+# $Date: 2016-09-23 14:02:13 -0700 (Fri, 23 Sep 2016) $
 # -----------------------------------------------------------------
 # Programmer: Radu Serban @ LLNL
 # -----------------------------------------------------------------
@@ -41,8 +41,13 @@ F77_LNKR    = @F77_LNKR@
 F77_LDFLAGS = @F77_LDFLAGS@
 F77_LIBS    = @F77_LIBS@
 
+LINKFLAGS = -Wl,-rpath, at libdir@
+
 LIBRARIES = -l at SOLVER_FLIB@ -l at SOLVER_LIB@ -lsundials_fnvecserial -lsundials_nvecserial ${LIBS}
 LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+LIBRARIES_PETSC = @PETSC_LIBRARIES@
 
 EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
 
@@ -59,8 +64,8 @@ OBJECTS = ${EXAMPLES:=.o}
 
 all: ${OBJECTS}
 	@for i in ${EXAMPLES} ; do \
-	  echo "${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL}" ; \
-	  ${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ; \
+	  echo "${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS}" ; \
+	  ${F77_LNKR} -o $${i} $${i}.o ${F77_LDFLAGS} ${F77_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LIBRARIES_PETSC} ${LINKFLAGS} ; \
 	done
 
 clean:
diff --git a/examples/templates/makefile_serial_F90_ex.in b/examples/templates/makefile_serial_F90_ex.in
new file mode 100644
index 0000000..faeebdc
--- /dev/null
+++ b/examples/templates/makefile_serial_F90_ex.in
@@ -0,0 +1,74 @@
+# -----------------------------------------------------------------
+# $Revision: 4824 $
+# $Date: 2016-07-24 16:39:04 -0700 (Sun, 24 Jul 2016) $
+# -----------------------------------------------------------------
+# Programmer: Daniel R. Reynolds @ SMU
+# -----------------------------------------------------------------
+# Copyright (c) 2013, The Regents of the University of California.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# -----------------------------------------------------------------
+# Makefile for @SOLVER@ Fortran90 serial examples
+#
+# This file is generated from a template using various variables
+# set at configuration time. It can be used as a template for
+# other user Makefiles.
+#
+# Note: if the solver was successfully configured with Blas/Lapack
+# support, the Blas/Lapack libraries are specified through the 
+# variable LIBRARIES_BL. Otherwise, this variable should contain
+# an empty string. We include LIBRARIES_BL in the link line for
+# all examples, whether they use the Lapack module or not, to
+# address the case in which the SUNDIALS libraries are shared 
+# objects. In that case, the solver library references Lapack 
+# symbols which must be always resolved by linking against the
+# Blas/Lapack libraries. If only static SUNDIALS libraries have 
+# been built, it is not required to link the Blas/Lapack libraries
+# for examples that do not use that module...
+# -----------------------------------------------------------------
+
+SHELL = @SHELL@
+
+prefix       = @prefix@
+exec_prefix  = @exec_prefix@
+includedir   = @includedir@
+libdir       = @libdir@
+
+F90         = @F90@
+F90FLAGS    = @F90FLAGS@
+F90_LDFLAGS = @F90_LDFLAGS@
+F90_LIBS    = @F90_LIBS@
+
+LINKFLAGS = -Wl,-rpath, at libdir@
+
+LIBRARIES = -l at SOLVER_FLIB@ -l at SOLVER_LIB@ -lsundials_fnvecserial -lsundials_nvecserial ${LIBS}
+LIBRARIES_BL = @BLAS_LAPACK_LIBS@
+LIBRARIES_SLUMT = @SUPERLUMT_LIBS@
+LIBRARIES_KLU = @KLU_LIBS@
+
+EXAMPLES = @EXAMPLES@ @EXAMPLES_BL@
+
+OBJECTS = ${EXAMPLES:=.o}
+
+# -----------------------------------------------------------------------------------------
+
+.SUFFIXES : .o .f90
+
+.f90.o :
+	${F90} ${F90FLAGS} -c $<
+
+# -----------------------------------------------------------------------------------------
+
+all: ${OBJECTS}
+	@for i in ${EXAMPLES} ; do \
+	  echo "${F90} -o $${i} $${i}.o ${F90_LDFLAGS} ${F90_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS}" ; \
+	  ${F90} -o $${i} $${i}.o ${F90_LDFLAGS} ${F90_LIBS} -L${libdir} ${LIBRARIES} ${LIBRARIES_BL} ${LIBRARIES_SLUMT} ${LIBRARIES_KLU} ${LINKFLAGS} ; \
+	done
+
+clean:
+	rm -f ${OBJECTS}
+	rm -f ${EXAMPLES}
+
+# -----------------------------------------------------------------------------------------
+
diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h
new file mode 100644
index 0000000..1a7123c
--- /dev/null
+++ b/include/arkode/arkode.h
@@ -0,0 +1,1380 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the interface file for the main ARKODE integrator.
+ *---------------------------------------------------------------
+ * ARKODE is used to solve numerically the ordinary initial value
+ * problem:
+ *              M(t)*y' = f(t,y),
+ *                y(t0) = y0,
+ * where t0, y0 in R^N, M(t)*y: R x R^N -> R^N, and 
+ * f: R x R^N -> R^N are given.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKODE_H
+#define _ARKODE_H
+
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*===============================================================
+                         ARKODE CONSTANTS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Enumerations for inputs to ARKodeCreate and ARKode.
+-----------------------------------------------------------------
+ Symbolic constants for the iter parameter to 
+ ARKodeCreate and the input parameter itask to ARKode, are given 
+ below.
+ 
+ itask: The itask input parameter to ARKode indicates the job
+        of the solver for the next user step. The ARK_NORMAL
+        itask is to have the solver take internal steps until
+        it has reached or just passed the user specified tout
+        parameter. The solver then interpolates in order to
+        return an approximate value of y(tout). The ARK_ONE_STEP
+        option tells the solver to just take one internal step
+        and return the solution at the point reached by that 
+	step.  If fixed time steps are desired, then the user 
+	can run in ARK_ONE_STEP mode, and set hmin and hmax to
+	be the desired time step -- this will effectively 
+	disable all temporal error control, and the user may
+	need to increase the iteration counts for the nonlinear 
+	and linear solvers to guarantee convergence for larger 
+	step sizes.
+---------------------------------------------------------------*/
+
+/* max number of overall stages allowed */
+#define ARK_S_MAX          15
+#define ARK_A(A,i,j)       (A[i*ARK_S_MAX + j])
+
+/* itask */
+#define ARK_NORMAL         1
+#define ARK_ONE_STEP       2
+
+
+/* Butcher table accessors -- explicit */
+#define HEUN_EULER_2_1_2         0
+#define BOGACKI_SHAMPINE_4_2_3   1
+#define ARK324L2SA_ERK_4_2_3     2
+#define ZONNEVELD_5_3_4          3
+#define ARK436L2SA_ERK_6_3_4     4
+#define SAYFY_ABURUB_6_3_4       5
+#define CASH_KARP_6_4_5          6
+#define FEHLBERG_6_4_5           7
+#define DORMAND_PRINCE_7_4_5     8
+#define ARK548L2SA_ERK_8_4_5     9
+#define VERNER_8_5_6            10
+#define FEHLBERG_13_7_8         11
+
+#define DEFAULT_ERK_2           HEUN_EULER_2_1_2
+#define DEFAULT_ERK_3           BOGACKI_SHAMPINE_4_2_3
+#define DEFAULT_ERK_4           ZONNEVELD_5_3_4
+#define DEFAULT_ERK_5           CASH_KARP_6_4_5
+#define DEFAULT_ERK_6           VERNER_8_5_6
+#define DEFAULT_ERK_8           FEHLBERG_13_7_8
+
+#define MIN_ERK_NUM              0
+#define MAX_ERK_NUM             11
+
+/* Butcher table accessors -- implicit */
+#define SDIRK_2_1_2             12
+#define BILLINGTON_3_3_2        13
+#define TRBDF2_3_3_2            14
+#define KVAERNO_4_2_3           15
+#define ARK324L2SA_DIRK_4_2_3   16
+#define CASH_5_2_4              17
+#define CASH_5_3_4              18
+#define SDIRK_5_3_4             19
+#define KVAERNO_5_3_4           20
+#define ARK436L2SA_DIRK_6_3_4   21
+#define KVAERNO_7_4_5           22
+#define ARK548L2SA_DIRK_8_4_5   23
+
+#define DEFAULT_DIRK_2          SDIRK_2_1_2
+#define DEFAULT_DIRK_3          ARK324L2SA_DIRK_4_2_3
+#define DEFAULT_DIRK_4          SDIRK_5_3_4
+#define DEFAULT_DIRK_5          ARK548L2SA_DIRK_8_4_5
+
+#define MIN_DIRK_NUM            12
+#define MAX_DIRK_NUM            23
+
+/* Butcher table accessors -- ImEx */
+#define DEFAULT_ARK_ETABLE_3    ARK324L2SA_ERK_4_2_3
+#define DEFAULT_ARK_ETABLE_4    ARK436L2SA_ERK_6_3_4
+#define DEFAULT_ARK_ETABLE_5    ARK548L2SA_ERK_8_4_5
+#define DEFAULT_ARK_ITABLE_3    ARK324L2SA_DIRK_4_2_3
+#define DEFAULT_ARK_ITABLE_4    ARK436L2SA_DIRK_6_3_4
+#define DEFAULT_ARK_ITABLE_5    ARK548L2SA_DIRK_8_4_5
+
+
+/* ARKODE return flags */
+#define ARK_SUCCESS               0
+#define ARK_TSTOP_RETURN          1
+#define ARK_ROOT_RETURN           2
+
+#define ARK_WARNING              99
+
+#define ARK_TOO_MUCH_WORK        -1
+#define ARK_TOO_MUCH_ACC         -2
+#define ARK_ERR_FAILURE          -3
+#define ARK_CONV_FAILURE         -4
+
+#define ARK_LINIT_FAIL           -5
+#define ARK_LSETUP_FAIL          -6
+#define ARK_LSOLVE_FAIL          -7
+#define ARK_RHSFUNC_FAIL         -8
+#define ARK_FIRST_RHSFUNC_ERR    -9
+#define ARK_REPTD_RHSFUNC_ERR    -10
+#define ARK_UNREC_RHSFUNC_ERR    -11
+#define ARK_RTFUNC_FAIL          -12
+#define ARK_LFREE_FAIL           -13
+#define ARK_MASSINIT_FAIL        -14
+#define ARK_MASSSETUP_FAIL       -15
+#define ARK_MASSSOLVE_FAIL       -16
+#define ARK_MASSFREE_FAIL        -17
+#define ARK_MASSMULT_FAIL        -18
+
+#define ARK_MEM_FAIL             -20
+#define ARK_MEM_NULL             -21
+#define ARK_ILL_INPUT            -22
+#define ARK_NO_MALLOC            -23
+#define ARK_BAD_K                -24
+#define ARK_BAD_T                -25
+#define ARK_BAD_DKY              -26
+#define ARK_TOO_CLOSE            -27
+
+#define ARK_POSTPROCESS_FAIL     -28
+
+
+/*===============================================================
+                          FUNCTION TYPES
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Type : ARKRhsFn
+-----------------------------------------------------------------
+ The f functions which define the right hand side of the ODE
+ system M*y' = fe(t,y) + fi(t,y) must have type ARKRhsFn.
+ f takes as input the independent variable value t, and the
+ dependent variable vector y.  It stores the result of fe(t,y) 
+ or fi(t,y) in the vector ydot.  The y and ydot arguments are of 
+ type N_Vector.
+ (Allocation of memory for ydot is handled within ARKODE)
+ The user_data parameter is the same as the user_data
+ parameter set by the user through the ARKodeSetUserData routine.
+ This user-supplied pointer is passed to the user's fe or fi
+ function every time it is called.
+
+ A ARKRhsFn should return 0 if successful, a negative value if
+ an unrecoverable error occured, and a positive value if a 
+ recoverable error (e.g. invalid y values) occured. 
+ If an unrecoverable occured, the integration is halted. 
+ If a recoverable error occured, then (in most cases) ARKODE
+ will try to correct and retry.
+---------------------------------------------------------------*/
+typedef int (*ARKRhsFn)(realtype t, N_Vector y,
+			N_Vector ydot, void *user_data);
+
+/*---------------------------------------------------------------
+ Type : ARKRootFn
+-----------------------------------------------------------------
+ A function g, which defines a set of functions g_i(t,y) whose
+ roots are sought during the integration, must have type 
+ ARKRootFn. The function g takes as input the independent 
+ variable value t, and the dependent variable vector y.  It 
+ stores the nrtfn values g_i(t,y) in the realtype array gout.
+ (Allocation of memory for gout is handled within ARKODE.)
+ The user_data parameter is the same as that passed by the user
+ to the ARKodeSetUserData routine.  This user-supplied pointer 
+ is passed to the user's g function every time it is called.
+
+ A ARKRootFn should return 0 if successful or a non-zero value
+ if an error occured (in which case the integration will be 
+ halted).
+---------------------------------------------------------------*/
+typedef int (*ARKRootFn)(realtype t, N_Vector y, 
+			 realtype *gout, void *user_data);
+
+/*---------------------------------------------------------------
+ Type : ARKEwtFn
+-----------------------------------------------------------------
+ A function e, which sets the error weight vector ewt, must have
+ type ARKEwtFn.  The function e takes as input the current 
+ dependent variable y. It must set the vector of error weights 
+ used in the WRMS norm:
+ 
+   ||y||_WRMS = sqrt [ 1/N * sum ( ewt_i * y_i)^2 ]
+
+ Typically, the vector ewt has components:
+ 
+   ewt_i = 1 / (reltol * |y_i| + abstol_i)
+
+ The user_data parameter is the same as that passed by the user
+ to the ARKodeSetUserData routine.  This user-supplied pointer 
+ is passed to the user's e function every time it is called.
+ A ARKEwtFn e must return 0 if the error weight vector has been
+ successfuly set and a non-zero value otherwise.
+---------------------------------------------------------------*/
+typedef int (*ARKEwtFn)(N_Vector y, N_Vector ewt, void *user_data);
+
+/*---------------------------------------------------------------
+ Type : ARKRwtFn
+-----------------------------------------------------------------
+ A function r, which sets the residual weight vector rwt, must 
+ have type ARKRwtFn.  The function r takes as input the current 
+ dependent variable y.  It must set the vector of residual 
+ weights used in the WRMS norm:
+ 
+   ||v||_WRMS = sqrt [ 1/N * sum ( rwt_i * v_i)^2 ]
+
+ Typically, the vector rwt has components:
+ 
+   rwt_i = 1 / (reltol * |(M*y)_i| + rabstol_i)
+
+ The user_data parameter is the same as that passed by the user
+ to the ARKodeSetUserData routine.  This user-supplied pointer 
+ is passed to the user's r function every time it is called.
+ A ARKRwtFn e must return 0 if the residual weight vector has 
+ been successfuly set and a non-zero value otherwise.
+---------------------------------------------------------------*/
+typedef int (*ARKRwtFn)(N_Vector y, N_Vector rwt, void *user_data);
+
+/*---------------------------------------------------------------
+ Type : ARKErrHandlerFn
+-----------------------------------------------------------------
+ A function eh, which handles error messages, must have type
+ ARKErrHandlerFn.  The function eh takes as input the error code, 
+ the name of the module reporting the error, the error message, 
+ and a pointer to user data, the same as that passed to 
+ ARKodeSetUserData.
+ 
+ All error codes are negative, except ARK_WARNING which indicates 
+ a warning (the solver continues).
+
+ A ARKErrHandlerFn has no return value.
+---------------------------------------------------------------*/
+typedef void (*ARKErrHandlerFn)(int error_code, const char *module, 
+				const char *function, char *msg, 
+				void *user_data); 
+
+/*---------------------------------------------------------------
+ Type : ARKAdaptFn
+-----------------------------------------------------------------
+ A function which sets the new time step h, must have type 
+ ARKAdaptFn.  The function takes as input the current dependent 
+ variable y, the current time t, the last 3 step sizes h, 
+ the last 3 error estimates, the method order q, the embedding 
+ order p, and a pointer to user data. The function must set the 
+ scalar step size for the upcoming time step.  This value will 
+ subsequently be bounded by the user-supplied values for the 
+ minimum and maximum allowed time step, and the time step 
+ satisfying the explicit stability restriction.  The user_data 
+ parameter is the same as that passed by the user to the 
+ ARKodeSetUserData routine.  This user-supplied pointer is passed 
+ to the function every time it is called.
+
+ A ARKAdaptFn must return 0 if the new time step has been
+ successfuly set and a non-zero value otherwise.
+---------------------------------------------------------------*/
+typedef int (*ARKAdaptFn)(N_Vector y, realtype t, realtype h1, 
+			  realtype h2, realtype h3, 
+			  realtype e1, realtype e2, 
+			  realtype e3, int q, int p, 
+			  realtype *hnew, void *user_data);
+
+/*---------------------------------------------------------------
+ Type : ARKExpStabFn
+-----------------------------------------------------------------
+ A function which returns the time step satisfying the stability 
+ restriction for the explicit portion of the ODE.  The function 
+ takes as input the current dependent variable y, the current 
+ time t, and a pointer to user data. The function must set the 
+ scalar step size satisfying the stability restriction for the 
+ upcoming time step.  This value will subsequently be bounded by 
+ the user-supplied values for the minimum and maximum allowed 
+ time step, and the accuracy-based time step.  The user_data 
+ parameter is the same as that passed by the user to the 
+ ARKodeSetUserData routine.  This user-supplied pointer is passed
+ to the function every time it is called.
+
+ If this function is not supplied (NULL), or if it returns a
+ negative time step size, then ARKode will assume that there is
+ no explicit stability restriction on the time step size.
+
+ A ARKExpStabFn must return 0 if the step size limit has been
+ successfuly set and a non-zero value otherwise.
+---------------------------------------------------------------*/
+typedef int (*ARKExpStabFn)(N_Vector y, realtype t, 
+			    realtype *hstab, void *user_data);
+
+/*---------------------------------------------------------------
+ Type : ARKVecResizeFn
+-----------------------------------------------------------------
+ When calling ARKodeResize, the user may specify a vector resize
+ function to be used to convert any existing N_Vectors in the 
+ ARKode memory structure to the new problem size.  This would 
+ typically be used if there is a user-supplied N_Vector module 
+ that allows dynamic resizing of the vector data structures 
+ without the need to delete/allocate memory on each call.  
+
+ The default behavior will be to delete the vector memory and 
+ re-clone from the new vector; if this is the desired behavior 
+ then specification of the ARKVecResizeFn is not recommended.
+
+ The first argument, 'y', is the vector to be resized.
+
+ The second argument, 'ytemplate', is the user-provided vector 
+ with the "new" size, that may be used as a template.
+
+ The third argument, 'user_data', is a user-provided data 
+ structure to ARKodeResize, in case additional data is 
+ necessary for the resize operation.
+
+ A ARKVecResizeFn should return 0 if successful, and a nonzero 
+ value if an error occurred.
+---------------------------------------------------------------*/
+typedef int (*ARKVecResizeFn)(N_Vector y, N_Vector ytemplate, 
+			      void *user_data);
+
+/*---------------------------------------------------------------
+ Type : ARKPostProcessStepFn
+-----------------------------------------------------------------
+ A function that is used to process the results of each timestep
+ solution, in preparation for subsequent steps.  A routine of 
+ this type is designed for tasks such as inter-processor 
+ communication, computation of derived quantities, etc..
+
+ IF THIS IS USED TO MODIFY ANY OF THE ACTIVE STATE DATA, THEN ALL
+ THEORETICAL GUARANTEES OF SOLUTION ACCURACY AND STABILITY ARE 
+ LOST.
+
+ Inputs: 
+   t          current time of ARKode solution
+   y          current ARKode solution N_Vector for processing
+   user_data  the structure passed by the user to the 
+              ARKodeSetUserData routine.
+---------------------------------------------------------------*/
+typedef int (*ARKPostProcessStepFn)(realtype t, N_Vector y, 
+				    void *user_data);
+
+
+/*===============================================================
+                       USER-CALLABLE ROUTINES
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Function : ARKodeCreate
+-----------------------------------------------------------------
+ ARKodeCreate creates an internal memory block for a problem to
+ be solved by ARKODE.
+
+ If successful, ARKodeCreate returns a pointer to initialized
+ problem memory. This pointer should be passed to ARKodeInit.
+ If an initialization error occurs, ARKodeCreate prints an error
+ message to standard err and returns NULL.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT void *ARKodeCreate();
+
+/*---------------------------------------------------------------
+ Integrator optional input specification functions
+-----------------------------------------------------------------
+ The following functions can be called to set optional inputs
+ to values other than the defaults given below.  
+
+
+ Function                 |  Optional input / [ default value ]
+-----------------------------------------------------------------
+ ARKodeSetDefaults        | resets all optional inputs to ARKode 
+                          | default values.  Does not change 
+                          | problem-defining function pointers 
+                          | fe and fi or user_data pointer.  Also
+                          | leaves alone any data structures or 
+                          | options related to root-finding 
+                          | (those can be reset using 
+                          ! ARKodeRootInit).
+                          | [internal]
+                          |
+ ARKodeSetOptimalParams   | sets all adaptivity and solver 
+                          | parameters to our 'best guess' values, 
+                          | for a given integration method (ERK, 
+                          | DIRK, ARK) and a given method order.  
+                          | Should only be called after the method
+                          | order and integration method have been 
+                          ! set.
+                          | [internal]
+                          |
+ ARKodeSetErrHandlerFn    | user-provided ErrHandler function.
+                          | [internal]
+                          |
+ ARKodeSetErrFile         | the file pointer for an error file
+                          | where all ARKODE warning and error
+                          | messages will be written if the 
+                          | default internal error handling 
+                          | function is used. This parameter can 
+                          | be stdout (standard output), stderr 
+                          | (standard error), or a file pointer 
+                          | (corresponding to a user error file 
+                          | opened for writing) returned by fopen.
+                          | If not called, then all messages will
+                          | be written to stderr.
+                          | [stderr]
+                          |
+ ARKodeSetUserData        | a pointer to user data that will be
+                          | passed to the user's f function every
+                          | time f is called.
+                          | [NULL]
+                          |
+ ARKodeSetDiagnostics     | the file pointer for a diagnostics file 
+                          | where all ARKODE step adaptivity and solver 
+                          | information is written.  This parameter can 
+                          | be stdout or stderr, though the preferred 
+                          | approach is to specify a file pointer 
+                          | (corresponding to a user diagnostics file 
+                          | opened for writing) returned by fopen.  If 
+                          | not called, or if called with a NULL file
+                          | pointer, all diagnostics output is disabled.
+                          | NOTE: when run in parallel, only one process 
+                          | should set a non-NULL value for this pointer, 
+                          | since statistics from all processes would be 
+                          | identical.
+                          | [NULL]
+                          |
+ ARKodeSetOrder           | method order to be used by the solver.
+                          | [4]
+                          |
+ ARKodeSetDenseOrder      | polynomial order to be used for dense 
+                          | output.  Allowed values are between 0
+                          | and min(q,5) (where q is the order of
+                          | the integrator)
+                          | [3]
+                          |
+ ARKodeSetLinear          | specifies that the implicit portion of 
+                          | the problem is linear, and to tighten 
+                          | the linear solver tolerances while 
+                          | taking only one Newton iteration.
+                          | [FALSE]
+                          |
+ ARKodeSetNonlinear       | specifies that the implicit portion of 
+                          | the problem is nonlinear.  Used to undo
+                          | a previous call to ARKodeSetLinear.
+                          | [TRUE]
+                          |
+ ARKodeSetFixedPoint      | specifies that the implicit portion of 
+                          | the problem should use the accelerated 
+                          | fixed-point solver.
+                          | [FALSE]
+                          |
+ ARKodeSetNewton          | specifies that the implicit portion of 
+                          | the problem should use the modified Newton 
+                          | solver.  Used to undo a previous call to
+                          | ARKodeSetFixedPoint.
+                          | [TRUE]
+                          |
+ ARKodeSetExplicit        | specifies that implicit portion of 
+                          | problem is disabled, and to use an 
+                          | explicit RK method.
+                          | [FALSE]
+                          |
+ ARKodeSetImplicit        | specifies that explicit portion of 
+                          | problem is disabled, and to use an 
+                          | implicit RK method.
+                          | [FALSE]
+                          |
+ ARKodeSetImEx            | specifies that problem has both 
+                          | implicit and explicit parts, and to 
+                          | use an ARK method.
+                          | [TRUE]
+                          |
+ ARKodeSetERKTable        | specifies to use a customized Butcher 
+                          | table for the explicit portion of the 
+                          | system.  This automatically calls 
+                          ! ARKodeSetExplicit.
+                          | [determined by ARKODE based on order]
+                          |
+ ARKodeSetIRKTable        | specifies to use a customized Butcher 
+                          | table for the implicit portion of the 
+                          | system. This automatically calls 
+                          ! ARKodeSetImplicit.
+                          | [determined by ARKODE based on order]
+                          |
+ ARKodeSetARKTables       | specifies to use customized Butcher 
+                          | tables for the IMEX system.  This 
+                          ! automatically calls ARKodeSetImEx.
+                          | [determined by ARKODE based on order]
+                          |
+ ARKodeSetERKTableNum     | specifies to use a built-in Butcher 
+                          | table for the explicit portion of the 
+                          | system.  The integer argument should 
+                          | match an existing method in 
+                          | ARKodeLoadButcherTable() within the file
+                          | arkode_butcher.c.  Error-checking is
+                          | performed to ensure that the table
+                          | exists, and is not implicit.  This 
+                          ! automatically calls ARKodeSetExplicit.
+                          | [determined by ARKODE based on order]
+                          |
+ ARKodeSetIRKTableNum     | specifies to use a built-in Butcher 
+                          | table for the implicit portion of the 
+                          | system.  The integer argument should 
+                          | match an existing method in 
+                          | ARKodeLoadButcherTable() within the file
+                          | arkode_butcher.c.  Error-checking is
+                          | performed to ensure that the table
+                          | exists, and is not explicit.  This 
+                          ! automatically calls ARKodeSetImplicit.
+                          | [determined by ARKODE based on order]
+                          |
+ ARKodeSetARKTableNum     | specifies to use a built-in Butcher 
+                          | tables for the ImEx system.  The 
+                          ! integer arguments should match existing 
+                          | methods in ARKodeLoadButcherTable() 
+                          | within the file arkode_butcher.c.  
+                          | Error-checking is performed to ensure 
+                          | that the tables exist.  Subsequent 
+                          | error-checking is automatically performed
+                          | to ensure that the tables' stage times 
+                          | and solution coefficients match.  This 
+                          ! automatically calls ARKodeSetImEx.
+                          | [determined by ARKODE based on order]
+                          |
+ ARKodeSetMaxNumSteps     | maximum number of internal steps to be
+                          | taken by the solver in its attempt to
+                          | reach tout.
+                          | [500]
+                          |
+ ARKodeSetMaxHnilWarns    | maximum number of warning messages
+                          | issued by the solver that t+h==t on 
+                          | the next internal step. A value of -1 
+                          | means no such messages are issued.
+                          | [10]
+                          |
+ ARKodeSetInitStep        | initial step size.
+                          | [estimated by ARKODE]
+                          |
+ ARKodeSetMinStep         | minimum absolute value of step size
+                          | allowed.
+                          | [0.0]
+                          |
+ ARKodeSetMaxStep         | maximum absolute value of step size
+                          | allowed.
+                          | [infinity]
+                          |
+ ARKodeSetStopTime        | the independent variable value past
+                          | which the solution is not to proceed.
+                          | [infinity]
+                          |
+ ARKodeSetFixedStep       | specifies to use a fixed step size 
+                          | throughout integration
+                          | [off]
+                          |
+ ARKodeSetCFLFraction     | safety factor to use for explicitly 
+                          ! stable steps
+                          | [0.5]
+                          |
+ ARKodeSetSafetyFactor    | safety factor to use for error-based 
+                          ! step adaptivity
+                          | [0.96]
+                          |
+ ARKodeSetErrorBias       | error bias factor to use in error-based
+                          ! step adaptivity
+                          | [1.5]
+                          |
+ ARKodeSetMaxGrowth       | maximum growth factor for successive 
+                          ! time steps (not including the first step).
+                          | [20.0]
+                          |
+ ARKodeSetMaxFirstGrowth  | maximum growth factor for first step.
+                          | [10000.0]
+                          |
+ ARKodeSetMaxEFailGrowth  | maximum growth factor after an error failure.
+                          | [0.3]
+                          |
+ ARKodeSetSmallNumEFails  | maximum number of error failures before 
+                          ! MaxFailGrowth factor is used.
+                          | [2]
+                          |
+ ARKodeSetMaxCFailGrowth  | maximum growth factor after a convergence failure.
+                          | [0.25]
+                          |
+ ARKodeSetFixedStepBounds | step growth interval to force retention of 
+                          ! the same step size
+                          | [1.0 1.5]
+                          |
+ ARKodeSetAdaptivityMethod | Method to use for time step adaptivity
+                          | [0]
+                          |
+ ARKodeSetAdaptivityFn    | user-provided time step adaptivity 
+                          | function.
+                          | [internal]
+                          |
+ ARKodeSetNonlinCRDown    | user-provided nonlinear convergence
+                          | rate constant.
+                          | [0.3]
+                          |
+ ARKodeSetNonlinRDiv      | user-provided nonlinear divergence ratio.
+                          | [2.3]
+                          |
+ ARKodeSetDeltaGammaMax   | user-provided linear setup decision
+                          | constant.
+                          | [0.2]
+                          |
+ ARKodeSetMaxStepsBetweenLSet | user-provided linear setup decision
+                          | constant.
+                          | [20]
+                          |
+ ARKodeSetPredictorMethod | Method to use for predicting implicit 
+                          | solutions.
+                          | [0]
+                          |
+ ARKodeSetStabilityFn     | user-provided explicit time step 
+                          | stability function.
+                          | [internal]
+                          |
+ ARKodeSetMaxErrTestFails | Maximum number of error test failures
+                          | in attempting one step.
+                          | [7]
+                          |
+ ARKodeSetMaxNonlinIters  | Maximum number of nonlinear solver
+                          | iterations at one stage solution.
+                          | [3]
+                          |
+ ARKodeSetMaxConvFails    | Maximum number of convergence failures
+                          | allowed in attempting one step.
+                          | [10]
+                          |
+ ARKodeSetNonlinConvCoef  | Coefficient in the nonlinear
+                          | convergence test.
+                          | [0.1]
+                          |
+-----------------------------------------------------------------
+ ARKodeSetRootDirection      | Specifies the direction of zero
+                             | crossings to be monitored
+                             | [both directions]
+                             |
+ ARKodeSetNoInactiveRootWarn | disable warning about possible
+                             | g==0 at beginning of integration
+-----------------------------------------------------------------
+ Return flag:
+   ARK_SUCCESS   if successful
+   ARK_MEM_NULL  if the arkode memory is NULL
+   ARK_ILL_INPUT if an argument has an illegal value
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeSetDefaults(void *arkode_mem);
+SUNDIALS_EXPORT int ARKodeSetOptimalParams(void *arkode_mem);
+SUNDIALS_EXPORT int ARKodeSetErrHandlerFn(void *arkode_mem, 
+					  ARKErrHandlerFn ehfun, 
+					  void *eh_data);
+SUNDIALS_EXPORT int ARKodeSetErrFile(void *arkode_mem, 
+				     FILE *errfp);
+SUNDIALS_EXPORT int ARKodeSetUserData(void *arkode_mem, 
+				      void *user_data);
+SUNDIALS_EXPORT int ARKodeSetDiagnostics(void *arkode_mem, 
+					 FILE *diagfp);
+SUNDIALS_EXPORT int ARKodeSetOrder(void *arkode_mem, int maxord);
+SUNDIALS_EXPORT int ARKodeSetDenseOrder(void *arkode_mem, int dord);
+SUNDIALS_EXPORT int ARKodeSetLinear(void *arkode_mem, int timedepend);
+SUNDIALS_EXPORT int ARKodeSetNonlinear(void *arkode_mem);
+SUNDIALS_EXPORT int ARKodeSetFixedPoint(void *arkode_mem, long int fp_m);
+SUNDIALS_EXPORT int ARKodeSetNewton(void *arkode_mem);
+SUNDIALS_EXPORT int ARKodeSetExplicit(void *arkode_mem);
+SUNDIALS_EXPORT int ARKodeSetImplicit(void *arkode_mem);
+SUNDIALS_EXPORT int ARKodeSetImEx(void *arkode_mem);
+SUNDIALS_EXPORT int ARKodeSetERKTable(void *arkode_mem, int s, 
+				      int q, int p, realtype *c, 
+				      realtype *A, realtype *b, 
+				      realtype *bembed);
+SUNDIALS_EXPORT int ARKodeSetIRKTable(void *arkode_mem, int s, 
+				      int q, int p, realtype *c, 
+				      realtype *A, realtype *b, 
+				      realtype *bembed);
+SUNDIALS_EXPORT int ARKodeSetARKTables(void *arkode_mem, int s, 
+				       int q, int p, 
+				       realtype *ci, realtype *ce, 
+				       realtype *Ai, realtype *Ae, 
+				       realtype *bi, realtype *be, 
+				       realtype *b2i, realtype *b2e);
+SUNDIALS_EXPORT int ARKodeSetERKTableNum(void *arkode_mem, int itable);
+SUNDIALS_EXPORT int ARKodeSetIRKTableNum(void *arkode_mem, int itable);
+SUNDIALS_EXPORT int ARKodeSetARKTableNum(void *arkode_mem, 
+					 int itable, int etable);
+SUNDIALS_EXPORT int ARKodeSetMaxNumSteps(void *arkode_mem, 
+					 long int mxsteps);
+SUNDIALS_EXPORT int ARKodeSetMaxHnilWarns(void *arkode_mem, 
+					  int mxhnil);
+SUNDIALS_EXPORT int ARKodeSetInitStep(void *arkode_mem, 
+				      realtype hin);
+SUNDIALS_EXPORT int ARKodeSetMinStep(void *arkode_mem, 
+				     realtype hmin);
+SUNDIALS_EXPORT int ARKodeSetMaxStep(void *arkode_mem, 
+				     realtype hmax);
+SUNDIALS_EXPORT int ARKodeSetStopTime(void *arkode_mem, 
+				      realtype tstop);
+SUNDIALS_EXPORT int ARKodeSetFixedStep(void *arkode_mem, 
+				       realtype hfixed);
+SUNDIALS_EXPORT int ARKodeSetCFLFraction(void *arkode_mem, 
+					 realtype cfl_frac);
+SUNDIALS_EXPORT int ARKodeSetSafetyFactor(void *arkode_mem, 
+					  realtype safety);
+SUNDIALS_EXPORT int ARKodeSetErrorBias(void *arkode_mem, 
+				       realtype bias);
+SUNDIALS_EXPORT int ARKodeSetMaxGrowth(void *arkode_mem, 
+				       realtype mx_growth);
+SUNDIALS_EXPORT int ARKodeSetFixedStepBounds(void *arkode_mem, 
+					     realtype lb, realtype ub);
+SUNDIALS_EXPORT int ARKodeSetAdaptivityMethod(void *arkode_mem, 
+					      int imethod, 
+					      int idefault, int pq, 
+					      realtype *adapt_params);
+SUNDIALS_EXPORT int ARKodeSetAdaptivityFn(void *arkode_mem, 
+					  ARKAdaptFn hfun, 
+					  void *h_data);
+SUNDIALS_EXPORT int ARKodeSetMaxFirstGrowth(void *arkode_mem, 
+					    realtype etamx1);
+SUNDIALS_EXPORT int ARKodeSetMaxEFailGrowth(void *arkode_mem, 
+					    realtype etamxf);
+SUNDIALS_EXPORT int ARKodeSetSmallNumEFails(void *arkode_mem, 
+					    int small_nef);
+SUNDIALS_EXPORT int ARKodeSetMaxCFailGrowth(void *arkode_mem, 
+					    realtype etacf);
+SUNDIALS_EXPORT int ARKodeSetNonlinCRDown(void *arkode_mem, 
+					  realtype crdown);
+SUNDIALS_EXPORT int ARKodeSetNonlinRDiv(void *arkode_mem, 
+					realtype rdiv);
+SUNDIALS_EXPORT int ARKodeSetDeltaGammaMax(void *arkode_mem, 
+					   realtype dgmax);
+SUNDIALS_EXPORT int ARKodeSetMaxStepsBetweenLSet(void *arkode_mem, 
+						 int msbp);
+SUNDIALS_EXPORT int ARKodeSetPredictorMethod(void *arkode_mem, 
+					     int method);
+SUNDIALS_EXPORT int ARKodeSetStabilityFn(void *arkode_mem, 
+					 ARKExpStabFn EStab, 
+					 void *estab_data);
+SUNDIALS_EXPORT int ARKodeSetMaxErrTestFails(void *arkode_mem, 
+					     int maxnef);
+SUNDIALS_EXPORT int ARKodeSetMaxNonlinIters(void *arkode_mem, 
+					    int maxcor);
+SUNDIALS_EXPORT int ARKodeSetMaxConvFails(void *arkode_mem, 
+					  int maxncf);
+SUNDIALS_EXPORT int ARKodeSetNonlinConvCoef(void *arkode_mem, 
+					    realtype nlscoef);
+
+SUNDIALS_EXPORT int ARKodeSetRootDirection(void *arkode_mem, 
+					   int *rootdir);
+SUNDIALS_EXPORT int ARKodeSetNoInactiveRootWarn(void *arkode_mem);
+
+SUNDIALS_EXPORT int ARKodeSetPostprocessStepFn(void *arkode_mem,
+					       ARKPostProcessStepFn ProcessStep);
+
+/*---------------------------------------------------------------
+ Function : ARKodeInit
+-----------------------------------------------------------------
+ ARKodeInit allocates and initializes memory for a problem to
+ to be solved by ARKODE.
+
+ arkode_mem is pointer to ARKODE memory returned by ARKodeCreate.
+
+ fe      is the name of the C function defining the explicit 
+         portion of the right-hand side function in 
+                y' = fe(t,y) + fi(t,y).
+
+ fi      is the name of the C function defining the implicit 
+         portion of the right-hand side function in 
+                y' = fe(t,y) + fi(t,y).
+
+ t0      is the initial value of t.
+
+ y0      is the initial condition vector y(t0).
+
+ Return flag:
+  ARK_SUCCESS   if successful
+  ARK_MEM_NULL  if the arkode memory was NULL
+  ARK_MEM_FAIL  if a memory allocation failed
+  ARK_ILL_INPUT if an argument has an illegal value.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeInit(void *arkode_mem, ARKRhsFn fe, 
+			       ARKRhsFn fi, realtype t0, N_Vector y0);
+
+/*---------------------------------------------------------------
+ Function : ARKodeReInit
+-----------------------------------------------------------------
+ ARKodeReInit re-initializes ARKode for the solution of a problem,
+ where a prior call to ARKodeInit has been made with the same
+ problem size N. ARKodeReInit performs the same input checking
+ and initializations that ARKodeInit does, but it does no memory
+ allocation, since the basic data structures initialized in 
+ ARKodeInit may be reused.
+
+ All of the arguments to ARKodeReInit have names and meanings
+ identical to those of ARKodeInit.
+
+ The return value of ARKodeReInit is equal to ARK_SUCCESS = 0 if
+ there were no errors; otherwise it is a negative int equal to:
+   ARK_MEM_NULL     indicating arkode_mem was NULL (i.e.,
+                    ARKodeCreate has not been called).
+   ARK_NO_MALLOC    indicating that arkode_mem has not been
+                    allocated (i.e., ARKodeInit has not been
+                    called).
+   ARK_ILL_INPUT    indicating an input argument was illegal
+                    (including an attempt to increase maxord).
+ In case of an error return, an error message is also printed.
+ --------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeReInit(void *arkode_mem, ARKRhsFn fe, 
+				 ARKRhsFn fi, realtype t0, N_Vector y0);
+
+/*---------------------------------------------------------------
+ Function : ARKodeResize
+-----------------------------------------------------------------
+ ARKodeResize re-initializes ARKODE's memory for a problem with a
+ changing vector size.  It is assumed that the problem dynamics 
+ before and after the vector resize will be comparable, so that 
+ all time-stepping heuristics prior to calling ARKodeResize 
+ remain valid after the call.  If instead the dynamics should be 
+ re-calibrated, the ARKode memory structure should be deleted 
+ with a call to ARKodeFree, and re-created with calls to 
+ ARKodeCreate and ARKodeInit.
+
+ To aid in the vector-resize operation, the user can supply a 
+ vector resize function, that will take as input an N_Vector with
+ the previous size, and return as output a corresponding vector 
+ of the new size.  If this function (of type ARKVecResizeFn) is 
+ not supplied (i.e. is set to NULL), then all existing N_Vectors 
+ will be destroyed and re-cloned from the input vector.
+
+ In the case that the dynamical time scale should be modified 
+ slightly from the previous time scale, an input "hscale" is 
+ allowed, that will re-scale the upcoming time step by the 
+ specified factor.  If a value <= 0 is specified, the default of 
+ 1.0 will be used.
+
+ Other arguments:
+   arkode_mem       Existing ARKode memory data structure.
+   ynew             The newly-sized solution vector, holding 
+                    the current dependent variable values.
+   t0               The current value of the independent 
+                    variable.
+   resize_data      User-supplied data structure that will be 
+                    passed to the supplied resize function.
+
+ The return value of ARKodeResize is equal to ARK_SUCCESS = 0 if
+ there were no errors; otherwise it is a negative int equal to:
+   ARK_MEM_NULL     indicating arkode_mem was NULL (i.e.,
+                    ARKodeCreate has not been called).
+   ARK_NO_MALLOC    indicating that arkode_mem has not been
+                    allocated (i.e., ARKodeInit has not been
+                    called).
+   ARK_ILL_INPUT    indicating an input argument was illegal
+                    (including an error from the supplied 
+		    resize function).
+ In case of an error return, an error message is also printed.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeResize(void *arkode_mem, N_Vector ynew, 
+				 realtype hscale, realtype t0,
+				 ARKVecResizeFn resize, 
+				 void *resize_data);
+
+/*---------------------------------------------------------------
+ Functions : ARKodeSStolerances
+             ARKodeSVtolerances
+             ARKodeWFtolerances
+-----------------------------------------------------------------
+ These functions specify the integration tolerances. One of them
+ SHOULD be called before the first call to ARKode; otherwise 
+ default values of reltol=1e-4 and abstol=1e-9 will be used, 
+ which may be entirely incorrect for a specific problem.
+
+ ARKodeSStolerances specifies scalar relative and absolute 
+   tolerances.
+ ARKodeSVtolerances specifies scalar relative tolerance and a 
+   vector absolute tolerance (a potentially different absolute 
+   tolerance for each vector component).
+ ARKodeWFtolerances specifies a user-provided function (of type 
+   ARKEwtFn) which will be called to set the error weight vector.
+
+ The tolerances reltol and abstol define a vector of error 
+ weights, ewt, with components
+   ewt[i] = 1/(reltol*abs(y[i]) + abstol)      (in SS case), or
+   ewt[i] = 1/(reltol*abs(y[i]) + abstol[i])   (in SV case).
+ This vector is used in all error and convergence tests, which
+ use a weighted RMS norm on all error-like vectors v:
+    WRMSnorm(v) = sqrt( (1/N) sum(i=1..N) (v[i]*ewt[i])^2 ),
+ where N is the problem dimension.
+
+ The return value of these functions is equal to ARK_SUCCESS=0 
+ if there were no errors; otherwise it is a negative int equal 
+ to:
+   ARK_MEM_NULL     indicating arkode_mem was NULL (i.e.,
+                    ARKodeCreate has not been called).
+   ARK_NO_MALLOC    indicating that arkode_mem has not been
+                    allocated (i.e., ARKodeInit has not been
+                    called).
+   ARK_ILL_INPUT    indicating an input argument was illegal
+                    (e.g. a negative tolerance)
+ In case of an error return, an error message is also printed.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeSStolerances(void *arkode_mem, 
+				       realtype reltol, 
+				       realtype abstol);
+SUNDIALS_EXPORT int ARKodeSVtolerances(void *arkode_mem, 
+				       realtype reltol, 
+				       N_Vector abstol);
+SUNDIALS_EXPORT int ARKodeWFtolerances(void *arkode_mem, 
+				       ARKEwtFn efun);
+
+/*---------------------------------------------------------------
+ Functions : ARKodeResStolerance
+             ARKodeResVtolerance
+             ARKodeResFtolerance
+-----------------------------------------------------------------
+ These functions specify the absolute residual tolerance. 
+ Specification of the absolute residual tolerance is only 
+ necessary for problems with non-identity mass matrices in which
+ the units of the solution vector y dramatically differ from the 
+ units of My, where M is the user-supplied mass matrix.  If this
+ occurs, one of these routines SHOULD be called before the first 
+ call to ARKode; otherwise the default value of rabstol=1e-9 will 
+ be used, which may be entirely incorrect for a specific problem.
+
+ ARKodeResStolerances specifies a scalar residual tolerance.
+
+ ARKodeResVtolerances specifies a vector residual tolerance 
+  (a potentially different absolute residual tolerance for 
+   each vector component).
+
+ ARKodeResFtolerances specifies a user-provides function (of 
+   type ARKRwtFn) which will be called to set the residual 
+   weight vector.
+
+ The tolerances reltol (defined for both the solution and 
+ residual) and rabstol define a vector of residual weights, 
+ rwt, with components
+   rwt[i] = 1/(reltol*abs(My[i]) + abstol)     (in S case), or
+   rwt[i] = 1/(reltol*abs(My[i]) + abstol[i])  (in V case).
+ This vector is used in all solver convergence tests, which
+ use a weighted RMS norm on all residual-like vectors v:
+    WRMSnorm(v) = sqrt( (1/N) sum(i=1..N) (v[i]*rwt[i])^2 ),
+ where N is the problem dimension.
+
+ The return value of these functions is equal to ARK_SUCCESS=0 
+ if there were no errors; otherwise it is a negative int equal 
+ to:
+   ARK_MEM_NULL     indicating arkode_mem was NULL (i.e.,
+                    ARKodeCreate has not been called).
+   ARK_NO_MALLOC    indicating that arkode_mem has not been
+                    allocated (i.e., ARKodeInit has not been
+                    called).
+   ARK_ILL_INPUT    indicating an input argument was illegal
+                    (e.g. a negative tolerance)
+ In case of an error return, an error message is also printed.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeResStolerance(void *arkode_mem, 
+					realtype rabstol);
+SUNDIALS_EXPORT int ARKodeResVtolerance(void *arkode_mem, 
+					N_Vector rabstol);
+SUNDIALS_EXPORT int ARKodeResFtolerance(void *arkode_mem, 
+					ARKRwtFn rfun);
+
+/*---------------------------------------------------------------
+ Function : ARKodeRootInit
+-----------------------------------------------------------------
+ ARKodeRootInit initializes a rootfinding problem to be solved
+ during the integration of the ODE system.  It must be called
+ after ARKodeCreate, and before ARKode.  The arguments are:
+
+ arkode_mem = pointer to ARKODE memory returned by ARKodeCreate.
+
+ nrtfn      = number of functions g_i, an integer >= 0.
+
+ g          = name of user-supplied function, of type ARKRootFn,
+              defining the functions g_i whose roots are sought.
+
+ If a new problem is to be solved with a call to ARKodeReInit,
+ where the new problem has no root functions but the prior one
+ did, then call ARKodeRootInit with nrtfn = 0.
+
+ The return value of ARKodeRootInit is ARK_SUCCESS = 0 if there 
+ were no errors; otherwise it is a negative int equal to:
+   ARK_MEM_NULL    indicating arkode_mem was NULL, or
+   ARK_MEM_FAIL    indicating a memory allocation failed.
+                   (including an attempt to increase maxord).
+   ARK_ILL_INPUT   indicating nrtfn > 0 but g = NULL.
+ In case of an error return, an error message is also printed.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeRootInit(void *arkode_mem, 
+				   int nrtfn, 
+				   ARKRootFn g);
+
+/*---------------------------------------------------------------
+ Function : ARKode
+-----------------------------------------------------------------
+ ARKode integrates the ODE over an interval in t.
+
+ ARKode may be run in one of two modes (ARK_NORMAL or 
+ ARK_ONE_STEP), as determined by the itask argument:
+
+ If itask is ARK_NORMAL, then the solver integrates from its
+ current internal t value to a point at or beyond tout, then
+ interpolates to t = tout and returns y(tout) in the user-
+ allocated vector yout.  This interpolation is typically less 
+ accurate than the full time step solutions produced by the 
+ solver, since the interpolating polynomial relies on the 
+ internal stage solutions, that may have reduced accuracy in 
+ comparison with the full time step solutions.  If the user 
+ wishes that this returned value have full method accuracy, they 
+ may issue a call to ARKodeSetStopTime before the call to ARKode 
+ to specify a fixed stop time to end the time step and return to 
+ the user.  Once the integrator returns at a tstop time, any 
+ future testing for tstop is disabled (and can be reenabled only 
+ though a new call to ARKodeSetStopTime).
+
+ If itask is ARK_ONE_STEP, then the solver takes one internal 
+ time step and returns in yout the value of y at the new internal 
+ time. In this case, tout is used only during the first call to 
+ ARKode to determine the direction of integration and the rough 
+ scale of the t variable.  As with the ARK_NORMAL mode, a user 
+ may specify a specific stop time for output of this step, 
+ assuming that the requested step is smaller than the step taken 
+ by the method. 
+
+ The time reached by the solver is placed in (*tret). The
+ user is responsible for allocating the memory for this value.
+
+ arkode_mem is the pointer to ARKODE memory returned by
+            ARKodeCreate.
+
+ tout  is the next time at which a computed solution is desired.
+
+ yout  is the computed solution vector. In ARK_NORMAL mode with no
+       errors and no roots found, yout=y(tout).
+
+ tret  is a pointer to a real location. ARKode sets (*tret) to
+       the time reached by the solver and returns
+       yout=y(*tret).
+
+ itask is ARK_NORMAL or ARK_ONE_STEP, as described above.
+
+ Here is a brief description of each return value:
+
+ ARK_SUCCESS:      ARKode succeeded and no roots were found.
+
+ ARK_ROOT_RETURN:  ARKode succeeded, and found one or more roots.
+                   If nrtfn > 1, call ARKodeGetRootInfo to see
+                   which g_i were found to have a root at (*tret).
+
+ ARK_TSTOP_RETURN: ARKode succeeded and returned at tstop.
+
+ ARK_MEM_NULL:     The arkode_mem argument was NULL.
+
+ ARK_NO_MALLOC:    arkode_mem was not allocated.
+
+ ARK_ILL_INPUT:    One of the inputs to ARKode is illegal. This
+                   includes the situation when a component of the
+                   error weight vectors becomes < 0 during
+                   internal time-stepping.  It also includes the
+                   situation where a root of one of the root
+                   functions was found both at t0 and very near t0.
+                   The ILL_INPUT flag will also be returned if the
+                   linear solver routine ARK--- (called by the user
+                   after calling ARKodeCreate) failed to set one of
+                   the linear solver-related fields in arkode_mem or
+                   if the linear solver's init routine failed. In
+                   any case, the user should see the printed
+                   error message for more details.
+
+ ARK_TOO_MUCH_WORK: The solver took mxstep internal steps but
+                   could not reach tout prior to the maximum number
+		   of steps (ark_mxstep).
+
+ ARK_TOO_MUCH_ACC: The solver could not satisfy the accuracy
+                   demanded by the user for some internal step.
+
+ ARK_ERR_FAILURE:  Error test failures occurred too many times
+                   (= ark_maxnef) during one internal time step 
+                   or occurred with |h| = hmin.
+
+ ARK_CONV_FAILURE: Convergence test failures occurred too many
+                   times (= ark_maxncf) during one internal time
+                   step or occurred with |h| = hmin.
+
+ ARK_LINIT_FAIL:   The linear solver's initialization function 
+                   failed.
+
+ ARK_LSETUP_FAIL:  The linear solver's setup routine failed in an
+                   unrecoverable manner.
+
+ ARK_LSOLVE_FAIL:  The linear solver's solve routine failed in an
+                   unrecoverable manner.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKode(void *arkode_mem, realtype tout, 
+			   N_Vector yout, realtype *tret, int itask);
+
+/*---------------------------------------------------------------
+ Function : ARKodeGetDky
+-----------------------------------------------------------------
+ ARKodeGetDky computes the kth derivative of the y function at
+ time t, where tn-hu <= t <= tn, tn denotes the current
+ internal time reached, and hu is the last internal step size
+ successfully used by the solver. The user may request
+ k=0, 1, ..., d, where d = min(5,q), with q the order of accuracy 
+ for the time integration method. The derivative vector is 
+ returned in dky. This vector must be allocated by the caller. It 
+ is only legal to call this function after a successful return 
+ from ARKode.
+
+ arkode_mem is the pointer to ARKODE memory returned by
+            ARKodeCreate.
+
+ t   is the time at which the kth derivative of y is evaluated.
+     The legal range for t is [tn-hu,tn] as described above.
+
+ k   is the order of the derivative of y to be computed. The
+     legal range for k is [0,min(q,3)] as described above.
+
+ dky is the output derivative vector [((d/dy)^k)y](t).
+
+ The return value for ARKodeGetDky is one of:
+
+   ARK_SUCCESS:  ARKodeGetDky succeeded.
+
+   ARK_BAD_K:    k is not in the range 0, 1, ..., s-1.
+
+   ARK_BAD_T:    t is not in the interval [tn-hu,tn].
+
+   ARK_BAD_DKY:  The dky argument was NULL.
+
+   ARK_MEM_NULL: The arkode_mem argument was NULL.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeGetDky(void *arkode_mem, realtype t, 
+				 int k, N_Vector dky);
+
+/*---------------------------------------------------------------
+ Integrator optional output extraction functions
+-----------------------------------------------------------------
+ The following functions can be called to get optional outputs
+ and statistics related to the main integrator.
+-----------------------------------------------------------------
+ ARKodeGetWorkSpace returns the ARKODE real and integer workspaces
+
+ ARKodeGetNumSteps returns the cumulative number of internal
+                   steps taken by the solver
+
+ ARKodeGetNumExpSteps returns the cumulative number of stability 
+                      limited steps taken by the solver
+
+ ARKodeGetNumAccSteps returns the cumulative number of accuracy 
+                      limited steps taken by the solver
+
+ ARKodeGetNumStepAttempts returns the total number of steps
+                          attempted by the solver
+
+ ARKodeGetNumRhsEvals returns the number of calls to the user's
+                      fe and fi functions
+
+ ARKodeGetNumLinSolvSetups returns the number of calls made to
+                           the linear solver's setup routine
+
+ ARKodeGetNumMassSolves returns the number of calls made to
+                           the mass matrix solve routine
+
+ ARKodeGetNumMassMultiplies returns the number of calls made to
+                            the mass matrix times vector routine
+
+ ARKodeGetNumErrTestFails returns the number of local error test
+                          failures that have occured
+
+ ARKodeGetActualInitStep returns the actual initial step size
+                         used by ARKODE
+
+ ARKodeGetLastStep returns the step size for the last internal
+                   step
+
+ ARKodeGetCurrentStep returns the step size to be attempted on
+                      the next internal step
+
+ ARKodeGetCurrentTime returns the current internal time reached
+                      by the solver
+
+ ARKodeGetCurrentButcherTables returns the explicit and implicit
+                               Butcher tables currently in use
+
+ ARKodeGetTolScaleFactor returns a suggested factor by which the
+                         user's tolerances should be scaled when
+                         too much accuracy has been requested for
+                         some internal step
+
+ ARKodeGetErrWeights returns the current error weight vector.
+                     The user must allocate space for eweight.
+
+ ARKodeGetEstLocalErrors returns the vector of estimated local
+                         errors. The user must allocate space
+                         for ele.
+
+ ARKodeGetNumGEvals returns the number of calls to the user's
+                    g function (for rootfinding)
+
+ ARKodeGetRootInfo returns the indices for which g_i was found to 
+                   have a root. The user must allocate space for 
+                   rootsfound. For i = 0 ... nrtfn-1, 
+                   rootsfound[i] = 1 if g_i has a root, and = 0 
+		   if not.
+
+ ARKodeGet* return values:
+   ARK_SUCCESS   if succesful
+   ARK_MEM_NULL  if the arkode memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeGetWorkSpace(void *arkode_mem, 
+				       long int *lenrw, 
+				       long int *leniw);
+SUNDIALS_EXPORT int ARKodeGetNumSteps(void *arkode_mem, 
+				      long int *nsteps);
+SUNDIALS_EXPORT int ARKodeGetNumExpSteps(void *arkode_mem, 
+					 long int *expsteps);
+SUNDIALS_EXPORT int ARKodeGetNumAccSteps(void *arkode_mem, 
+					 long int *accsteps);
+SUNDIALS_EXPORT int ARKodeGetNumStepAttempts(void *arkode_mem, 
+					     long int *step_attempts);
+SUNDIALS_EXPORT int ARKodeGetNumRhsEvals(void *arkode_mem, 
+					 long int *nfe_evals, 
+					 long int *nfi_evals);
+SUNDIALS_EXPORT int ARKodeGetNumLinSolvSetups(void *arkode_mem, 
+					      long int *nlinsetups);
+SUNDIALS_EXPORT int ARKodeGetNumMassSolves(void *arkode_mem, 
+					   long int *nMassSolves);
+SUNDIALS_EXPORT int ARKodeGetNumMassMultiplies(void *arkode_mem, 
+					       long int *nMassMult);
+SUNDIALS_EXPORT int ARKodeGetNumErrTestFails(void *arkode_mem, 
+					     long int *netfails);
+SUNDIALS_EXPORT int ARKodeGetActualInitStep(void *arkode_mem, 
+					    realtype *hinused);
+SUNDIALS_EXPORT int ARKodeGetLastStep(void *arkode_mem, 
+				      realtype *hlast);
+SUNDIALS_EXPORT int ARKodeGetCurrentStep(void *arkode_mem, 
+					 realtype *hcur);
+SUNDIALS_EXPORT int ARKodeGetCurrentTime(void *arkode_mem, 
+					 realtype *tcur);
+SUNDIALS_EXPORT int ARKodeGetCurrentButcherTables(void *arkode_mem, 
+						  int *s, int *q, int *p, 
+						  realtype *Ai, realtype *Ae, 
+						  realtype *ci, realtype *ce, 
+						  realtype *bi, realtype *be, 
+						  realtype *b2i, realtype *b2e);
+SUNDIALS_EXPORT int ARKodeGetTolScaleFactor(void *arkode_mem, 
+					    realtype *tolsfac);
+SUNDIALS_EXPORT int ARKodeGetErrWeights(void *arkode_mem, 
+					N_Vector eweight);
+SUNDIALS_EXPORT int ARKodeGetEstLocalErrors(void *arkode_mem, 
+					    N_Vector ele);
+SUNDIALS_EXPORT int ARKodeGetNumGEvals(void *arkode_mem, 
+				       long int *ngevals);
+SUNDIALS_EXPORT int ARKodeGetRootInfo(void *arkode_mem, 
+				      int *rootsfound);
+
+/*---------------------------------------------------------------
+ As a convenience, the following functions provides the
+ optional outputs in one group.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeGetIntegratorStats(void *arkode_mem, 
+					     long int *nsteps,
+					     long int *expsteps, 
+					     long int *accsteps, 
+					     long int *step_attempts, 
+					     long int *nfe_evals, 
+					     long int *nfi_evals, 
+					     long int *nlinsetups, 
+					     long int *netfails,
+					     realtype *hinused, 
+					     realtype *hlast, 
+					     realtype *hcur, 
+					     realtype *tcur);
+
+/*---------------------------------------------------------------
+ Nonlinear solver optional output extraction functions
+-----------------------------------------------------------------
+ The following functions can be called to get optional outputs
+ and statistics related to the nonlinear solver.
+-----------------------------------------------------------------
+ ARKodeGetNumNonlinSolvIters returns the number of nonlinear
+                             solver iterations performed.
+
+ ARKodeGetNumNonlinSolvConvFails returns the number of nonlinear
+                                 convergence failures.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeGetNumNonlinSolvIters(void *arkode_mem, 
+						long int *nniters);
+SUNDIALS_EXPORT int ARKodeGetNumNonlinSolvConvFails(void *arkode_mem, 
+						    long int *nncfails);
+
+/*---------------------------------------------------------------
+ As a convenience, the following function provides the
+ nonlinear solver optional outputs in a group.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeGetNonlinSolvStats(void *arkode_mem, 
+					     long int *nniters,
+					     long int *nncfails);
+
+/*---------------------------------------------------------------
+ As a convenience, the following function may be used to retrieve
+ Butcher tables from arkode_butcher.c.  The array A must be 
+ declared of type A[ARK_S_MAX][ARK_S_MAX], and the arrays c, b 
+ and b2 should all have length at least ARK_S_MAX.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeLoadButcherTable(int imethod, int *s, 
+					   int *q, int *p, 
+					   realtype *A, realtype *b, 
+					   realtype *c, realtype *b2);
+
+/*---------------------------------------------------------------
+ The following function returns the name of the constant 
+ associated with a ARKODE return flag
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT char *ARKodeGetReturnFlagName(long int flag);
+
+/*---------------------------------------------------------------
+ Function : ARKodeWriteParameters
+-----------------------------------------------------------------
+ ARKodeWriteParameters outputs all solver parameters to the 
+ provided file pointer.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeWriteParameters(void *arkode_mem, FILE *fp);
+
+/*---------------------------------------------------------------
+ Function : ARKodeWriteButcher
+-----------------------------------------------------------------
+ ARKodeWriteButcher outputs the Butcher tables to the 
+ provided file pointer.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKodeWriteButcher(void *arkode_mem, FILE *fp);
+
+/*---------------------------------------------------------------
+ Function : ARKodeFree
+-----------------------------------------------------------------
+ ARKodeFree frees the problem memory arkode_mem allocated by
+ ARKodeCreate and ARKodeInit. Its only argument is the pointer
+ arkode_mem returned by ARKodeCreate.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT void ARKodeFree(void **arkode_mem);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_band.h b/include/arkode/arkode_band.h
new file mode 100644
index 0000000..c96f764
--- /dev/null
+++ b/include/arkode/arkode_band.h
@@ -0,0 +1,94 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Header file for the ARKODE band linear solver, ARKBAND.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKBAND_H
+#define _ARKBAND_H
+
+#include <arkode/arkode_direct.h>
+#include <sundials/sundials_band.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ ARKBand:
+
+ A call to the ARKBand function links the main ARKODE integrator
+ with the ARKBAND linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ mupper is the upper bandwidth of the band Jacobian
+        approximation.
+
+ mlower is the lower bandwidth of the band Jacobian
+        approximation.
+
+ The return value of ARKBand is one of:
+    ARKDLS_SUCCESS   if successful
+    ARKDLS_MEM_NULL  if the arkode memory was NULL
+    ARKDLS_MEM_FAIL  if there was a memory allocation failure
+    ARKDLS_ILL_INPUT if a required vector operation is missing or
+                       if a bandwidth has an illegal value.
+---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int ARKBand(void *arkode_mem, long int N, 
+			    long int mupper, long int mlower);
+
+/*---------------------------------------------------------------
+ ARKMassBand:
+
+ A call to the ARKMassBand function links the mass matrix solve
+ with the ARKBAND linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ mupper is the upper bandwidth of the band Jacobian
+        approximation.
+
+ mlower is the lower bandwidth of the band Jacobian
+        approximation.
+
+ bmass is the user-supplied band mass matrix setup routine.
+
+ The return value of ARKBand is one of:
+    ARKDLS_SUCCESS   if successful
+    ARKDLS_MEM_NULL  if the arkode memory was NULL
+    ARKDLS_MEM_FAIL  if there was a memory allocation failure
+    ARKDLS_ILL_INPUT if a required vector operation is missing or
+                       if a bandwidth has an illegal value.
+---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int ARKMassBand(void *arkode_mem, long int N, 
+				long int mupper, long int mlower,
+				ARKDlsBandMassFn bmass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_bandpre.h b/include/arkode/arkode_bandpre.h
new file mode 100644
index 0000000..0b905f8
--- /dev/null
+++ b/include/arkode/arkode_bandpre.h
@@ -0,0 +1,149 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for the ARKBANDPRE module, which
+ * provides a banded difference quotient Jacobian-based
+ * preconditioner and solver routines for use with ARKSPGMR,
+ * ARKSPBCG, ARKSPTFQMR, ARKSPFGMR or ARKPCG.
+ *
+ * Summary:
+ * These routines provide a band matrix preconditioner based on
+ * difference quotients of the implicit portion of the ODE 
+ * right-hand side function f.  The user supplies parameters
+ *   mu = upper half-bandwidth (number of super-diagonals)
+ *   ml = lower half-bandwidth (number of sub-diagonals)
+ * The routines generate a band matrix of bandwidth ml + mu + 1
+ * and use this to form a preconditioner for use with the Krylov
+ * linear solver in ARKSP*. Although this matrix is intended to
+ * approximate the Jacobian dfi/dy, it may be a very crude
+ * approximation. The true Jacobian need not be banded, or its
+ * true bandwith may be larger than ml + mu + 1, as long as the
+ * banded approximation generated here is sufficiently accurate
+ * to speed convergence as a preconditioner.
+ *
+ * Usage:
+ *   The following is a summary of the usage of this module.
+ *   Details of the calls to ARKodeCreate, ARKSp*,
+ *   and ARKode are available in the User Guide.
+ *   To use these routines, the sequence of calls in the user
+ *   main program should be as follows:
+ *
+ *   #include <arkode/arkode_bandpre.h>
+ *   #include <nvector_serial.h>
+ *   ...
+ *   Set y0
+ *   ...
+ *   arkode_mem = ARKodeCreate();
+ *   ier = ARKodeInit(...);
+ *   ...
+ *   flag = ARKSptfqmr(arkode_mem, pretype, maxl);
+ *     -or-
+ *   flag = ARKSpgmr(arkode_mem, pretype, maxl);
+ *     -or-
+ *   flag = ARKSpbcg(arkode_mem, pretype, maxl);
+ *     -or-
+ *   flag = ARKSpfgmr(arkode_mem, pretype, maxl);
+ *     -or-
+ *   flag = ARKPcg(arkode_mem, pretype, maxl);
+ *   ...
+ *   flag = ARKBandPrecInit(arkode_mem, N, mu, ml);
+ *   ...
+ *   flag = ARKode(...);
+ *   ...
+ *   Free y0
+ *   ...
+ *   ARKodeFree(&arkode_mem);
+ *
+ * Notes:
+ * (1) Include this file for the ARKBandPrecData type definition.
+ * (2) In the ARKBandPrecAlloc call, the arguments N is the
+ *     problem dimension.
+ * (3) In the ARKBPSp* call, the user is free to specify
+ *     the input pretype and the optional input maxl.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKBANDPRE_H
+#define _ARKBANDPRE_H
+
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ ARKBandPrecInit:
+
+ ARKBandPrecInit allocates and initializes the BANDPRE preconditioner
+ module. This functino must be called AFTER one of the SPILS linear
+ solver modules has been attached to the ARKODE integrator.
+
+ The parameters of ARKBandPrecInit are as follows:
+
+ arkode_mem is the pointer to ARKODE memory returned by ARKodeCreate.
+
+ N is the problem size.
+
+ mu is the upper half bandwidth.
+
+ ml is the lower half bandwidth.
+
+ The return value of ARKBandPrecInit is one of:
+   ARKSPILS_SUCCESS if no errors occurred
+   ARKSPILS_MEM_NULL if the integrator memory is NULL
+   ARKSPILS_LMEM_NULL if the linear solver memory is NULL
+   ARKSPILS_ILL_INPUT if an input has an illegal value
+   ARKSPILS_MEM_FAIL if a memory allocation request failed
+
+ NOTE: The band preconditioner assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKBandPrecInit will
+       first test for a compatible N_Vector internal
+       representation by checking for required functions.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKBandPrecInit(void *arkode_mem, long int N, 
+				    long int mu, long int ml);
+
+/*---------------------------------------------------------------
+ Optional output functions : ARKBandPrecGet*
+
+ ARKBandPrecGetWorkSpace returns the real and integer work space used
+                        by ARKBANDPRE.
+
+ ARKBandPrecGetNumRhsEvals returns the number of calls made from
+                          ARKBANDPRE to the user's right-hand side
+                          routine f.
+
+ The return value of ARKBandPrecGet* is one of:
+   ARKSPILS_SUCCESS if no errors occurred
+   ARKSPILS_MEM_NULL if the integrator memory is NULL
+   ARKSPILS_LMEM_NULL if the linear solver memory is NULL
+   ARKSPILS_PMEM_NULL if the preconditioner memory is NULL
+---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int ARKBandPrecGetWorkSpace(void *arkode_mem, 
+					    long int *lenrwLS, 
+					    long int *leniwLS);
+SUNDIALS_EXPORT int ARKBandPrecGetNumRhsEvals(void *arkode_mem, 
+					      long int *nfevalsBP);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_bbdpre.h b/include/arkode/arkode_bbdpre.h
new file mode 100644
index 0000000..363c80c
--- /dev/null
+++ b/include/arkode/arkode_bbdpre.h
@@ -0,0 +1,271 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for the ARKBBDPRE module, for a
+ * band-block-diagonal preconditioner, i.e. a block-diagonal
+ * matrix with banded blocks, for use with ARKSPGMR, ARKSPBCG, 
+ * ARKSPTFQMR, ARKSPFGMR or ARKPCG, and the parallel implementation 
+ * of the NVECTOR module.
+ *
+ * Summary:
+ *
+ * These routines provide a preconditioner matrix that is
+ * block-diagonal with banded blocks. The blocking corresponds
+ * to the distribution of the dependent variable vector y among
+ * the processors. Each preconditioner block is generated from
+ * the Jacobian of the local part (on the current processor) of a
+ * given function g(t,y) approximating f(t,y). The blocks are
+ * generated by a difference quotient scheme on each processor
+ * independently. This scheme utilizes an assumed banded
+ * structure with given half-bandwidths, mudq and mldq.
+ * However, the banded Jacobian block kept by the scheme has
+ * half-bandwiths mukeep and mlkeep, which may be smaller.
+ *
+ * The user's calling program should have the following form:
+ *
+ *   #include <nvector_parallel.h>
+ *   #include <arkode/arkode_bbdpre.h>
+ *   ...
+ *   void *arkode_mem;
+ *   ...
+ *   Set y0
+ *   ...
+ *   arkode_mem = ARKodeCreate();
+ *   ier = ARKodeInit(...);
+ *   ...
+ *   flag = ARKSpgmr(arkode_mem, pretype, maxl);
+ *      -or-
+ *   flag = ARKSpbcg(arkode_mem, pretype, maxl);
+ *      -or-
+ *   flag = ARKSptfqmr(arkode_mem, pretype, maxl);
+ *      -or-
+ *   flag = ARKSpfgmr(arkode_mem, pretype, maxl);
+ *      -or-
+ *   flag = ARKPcg(arkode_mem, pretype, maxl);
+ *   ...
+ *   flag = ARKBBDPrecInit(arkode_mem, Nlocal, mudq ,mldq,
+ *                         mukeep, mlkeep, dqrely, gloc, cfn);
+ *   ...
+ *   ier = ARKode(...);
+ *   ...
+ *   ARKodeFree(&arkode_mem);
+ * 
+ *   Free y0
+ *
+ * The user-supplied routines required are:
+ *
+ *   f    = function defining the ODE right-hand side f(t,y).
+ *
+ *   gloc = function defining the approximation g(t,y).
+ *
+ *   cfn  = function to perform communication need for gloc.
+ *
+ * Notes:
+ *
+ * 1) This header file is included by the user for the definition
+ *    of the ARKBBDData type and for needed function prototypes.
+ *
+ * 2) The ARKBBDPrecInit call includes half-bandwiths mudq and mldq
+ *    to be used in the difference quotient calculation of the
+ *    approximate Jacobian. They need not be the true
+ *    half-bandwidths of the Jacobian of the local block of g,
+ *    when smaller values may provide a greater efficiency.
+ *    Also, the half-bandwidths mukeep and mlkeep of the retained
+ *    banded approximate Jacobian block may be even smaller,
+ *    to reduce storage and computation costs further.
+ *    For all four half-bandwidths, the values need not be the
+ *    same on every processor.
+ *
+ * 3) The actual name of the user's f function is passed to
+ *    ARKodeInit, and the names of the user's gloc and cfn
+ *    functions are passed to ARKBBDPrecInit.
+ *
+ * 4) The pointer to the user-defined data block user_data, which is
+ *    set through ARKodeSetUserData is also available to the user in
+ *    gloc and cfn.
+ *
+ * 5) Optional outputs specific to this module are available by
+ *    way of routines listed below. These include work space sizes
+ *    and the cumulative number of gloc calls. The costs
+ *    associated with this module also include nsetups banded LU
+ *    factorizations, nlinsetups cfn calls, and npsolves banded
+ *    backsolve calls, where nlinsetups and npsolves are
+ *    integrator/ARKSPGMR/ARKSPBCG/ARKSPTFQMR/ARKSPFGMR/ARKPCG 
+ *    optional outputs.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKBBDPRE_H
+#define _ARKBBDPRE_H
+
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ Type: ARKLocalFn
+
+ The user must supply a function g(t,y) which approximates the
+ right-hand side function f for the system y'=f(t,y), and which
+ is computed locally (without interprocess communication).
+ (The case where g is mathematically identical to f is allowed.)
+ The implementation of this function must have type ARKLocalFn.
+
+ This function takes as input the local vector size Nlocal, the
+ independent variable value t, the local real dependent
+ variable vector y, and a pointer to the user-defined data
+ block user_data. It is to compute the local part of g(t,y) and
+ store this in the vector g.
+ (Allocation of memory for y and g is handled within the
+ preconditioner module.)
+ The user_data parameter is the same as that specified by the user
+ through the ARKodeSetFdata routine.
+
+ A ARKLocalFn should return 0 if successful, a positive value if 
+ a recoverable error occurred, and a negative value if an 
+ unrecoverable error occurred.
+---------------------------------------------------------------*/
+typedef int (*ARKLocalFn)(long int Nlocal, realtype t, N_Vector y,
+                          N_Vector g, void *user_data);
+
+
+/*---------------------------------------------------------------
+ Type: ARKCommFn
+
+ The user may supply a function of type ARKCommFn which performs
+ all interprocess communication necessary to evaluate the
+ approximate right-hand side function described above.
+
+ This function takes as input the local vector size Nlocal,
+ the independent variable value t, the dependent variable
+ vector y, and a pointer to the user-defined data block user_data.
+ The user_data parameter is the same as that specified by the user
+ through the ARKodeSetUserData routine. The ARKCommFn cfn is
+ expected to save communicated data in space defined within the
+ structure user_data. Note: A ARKCommFn cfn does not have a return value.
+
+ Each call to the ARKCommFn cfn is preceded by a call to the
+ ARKRhsFn f with the same (t,y) arguments. Thus cfn can omit any
+ communications done by f if relevant to the evaluation of g.
+ If all necessary communication was done by f, the user can
+ pass NULL for cfn in ARKBBDPrecInit (see below).
+
+ A ARKCommFn should return 0 if successful, a positive value if 
+ a recoverable error occurred, and a negative value if an 
+ unrecoverable error occurred.
+---------------------------------------------------------------*/
+typedef int (*ARKCommFn)(long int Nlocal, realtype t, 
+			 N_Vector y, void *user_data);
+
+
+/*---------------------------------------------------------------
+ ARKBBDPrecInit:
+
+ ARKBBDPrecInit allocates and initializes the BBD preconditioner.
+
+ The parameters of ARKBBDPrecInit are as follows:
+
+ arkode_mem is the pointer to the integrator memory.
+
+ Nlocal is the length of the local block of the vectors y etc.
+        on the current processor.
+
+ mudq, mldq are the upper and lower half-bandwidths to be used
+            in the difference quotient computation of the local
+            Jacobian block.
+
+ mukeep, mlkeep are the upper and lower half-bandwidths of the
+                retained banded approximation to the local Jacobian
+                block.
+
+ dqrely is an optional input. It is the relative increment
+        in components of y used in the difference quotient
+        approximations. To specify the default, pass 0.
+        The default is dqrely = sqrt(unit roundoff).
+
+ gloc is the name of the user-supplied function g(t,y) that
+      approximates f and whose local Jacobian blocks are
+      to form the preconditioner.
+
+ cfn is the name of the user-defined function that performs
+     necessary interprocess communication for the
+     execution of gloc.
+
+ The return value of ARKBBDPrecInit is one of:
+   ARKSPILS_SUCCESS if no errors occurred
+   ARKSPILS_MEM_NULL if the integrator memory is NULL
+   ARKSPILS_LMEM_NULL if the linear solver memory is NULL
+   ARKSPILS_ILL_INPUT if an input has an illegal value
+   ARKSPILS_MEM_FAIL if a memory allocation request failed
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKBBDPrecInit(void *arkode_mem, long int Nlocal, 
+				   long int mudq, long int mldq, 
+				   long int mukeep, long int mlkeep, 
+				   realtype dqrely,
+				   ARKLocalFn gloc, ARKCommFn cfn);
+
+
+/*---------------------------------------------------------------
+ ARKBBDPrecReInit:
+
+ ARKBBDPrecReInit re-initializes the BBDPRE module when solving a
+ sequence of problems of the same size with ARKSPGMR/ARKBBDPRE or
+ ARKSPBCG/ARKBBDPRE or ARKSPTFQMR/ARKBBDPRE or ARKSPFGMR/ARKBBDPRE
+ or ARKPCG/ARKBBDPRE provided there is no change in Nlocal, 
+ mukeep, or mlkeep. After solving one problem, and after calling 
+ ARKodeReInit to re-initialize the integrator for a subsequent 
+ problem, call ARKBBDPrecReInit.
+
+ All arguments have the same names and meanings as those
+ of ARKBBDPrecInit.
+
+ The return value of ARKBBDPrecReInit is one of:
+   ARKSPILS_SUCCESS if no errors occurred
+   ARKSPILS_MEM_NULL if the integrator memory is NULL
+   ARKSPILS_LMEM_NULL if the linear solver memory is NULL
+   ARKSPILS_PMEM_NULL if the preconditioner memory is NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKBBDPrecReInit(void *arkode_mem, long int mudq, 
+				     long int mldq, realtype dqrely);
+
+
+/*---------------------------------------------------------------
+ BBDPRE optional output extraction routines:
+
+ ARKBBDPrecGetWorkSpace returns the BBDPRE real and integer work 
+                       space sizes.
+ ARKBBDPrecGetNumGfnEvals returns the number of calls to gfn.
+
+ The return value of ARKBBDPrecGet* is one of:
+   ARKSPILS_SUCCESS if no errors occurred
+   ARKSPILS_MEM_NULL if the integrator memory is NULL
+   ARKSPILS_LMEM_NULL if the linear solver memory is NULL
+   ARKSPILS_PMEM_NULL if the preconditioner memory is NULL
+---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int ARKBBDPrecGetWorkSpace(void *arkode_mem, 
+					   long int *lenrwLS, 
+					   long int *leniwLS);
+SUNDIALS_EXPORT int ARKBBDPrecGetNumGfnEvals(void *arkode_mem, 
+					     long int *ngevalsBBDP);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_dense.h b/include/arkode/arkode_dense.h
new file mode 100644
index 0000000..83da464
--- /dev/null
+++ b/include/arkode/arkode_dense.h
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Header file for the ARKODE dense linear solver, ARKDENSE.
+ *---------------------------------------------------------------*/
+
+#ifndef _ARKDENSE_H
+#define _ARKDENSE_H
+
+#include <arkode/arkode_direct.h>
+#include <sundials/sundials_dense.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ Function: ARKDense
+-----------------------------------------------------------------
+ A call to the ARKDense function links the main integrator with
+ the ARKDENSE linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+            ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ The return value of ARKDense is one of:
+    ARKDLS_SUCCESS   if successful
+    ARKDLS_MEM_NULL  if the arkode memory was NULL
+    ARKDLS_MEM_FAIL  if there was a memory allocation failure
+    ARKDLS_ILL_INPUT if a required vector operation is missing
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKDense(void *arkode_mem, long int N);
+
+/*---------------------------------------------------------------
+ Function: ARKMassDense
+-----------------------------------------------------------------
+ A call to the ARKMassDense function links the mass matrix solve
+ with the ARKDENSE linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+            ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ dmass is the user-supplied dense mass matrix setup function.
+
+ The return value of ARKMassDense is one of:
+    ARKDLS_SUCCESS   if successful
+    ARKDLS_MEM_NULL  if the arkode memory was NULL
+    ARKDLS_MEM_FAIL  if there was a memory allocation failure
+    ARKDLS_ILL_INPUT if a required vector operation is missing
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassDense(void *arkode_mem, long int N, 
+				 ARKDlsDenseMassFn dmass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_direct.h b/include/arkode/arkode_direct.h
new file mode 100644
index 0000000..c919583
--- /dev/null
+++ b/include/arkode/arkode_direct.h
@@ -0,0 +1,373 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Common header file for the direct linear solvers in ARKODE.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKDLS_H
+#define _ARKDLS_H
+
+#include <sundials/sundials_direct.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*===============================================================
+  ARKDIRECT CONSTANTS
+===============================================================*/
+
+/* ARKDLS return values */
+#define ARKDLS_SUCCESS          0
+#define ARKDLS_MEM_NULL        -1
+#define ARKDLS_LMEM_NULL       -2
+#define ARKDLS_ILL_INPUT       -3
+#define ARKDLS_MEM_FAIL        -4
+#define ARKDLS_MASSMEM_NULL    -5
+
+/* Additional last_flag values */
+#define ARKDLS_JACFUNC_UNRECVR  -6
+#define ARKDLS_JACFUNC_RECVR    -7
+#define ARKDLS_MASSFUNC_UNRECVR -8
+#define ARKDLS_MASSFUNC_RECVR   -9
+
+
+/*===============================================================
+  FUNCTION TYPES
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Type: ARKDlsDenseJacFn
+
+ A dense Jacobian approximation function Jac must be of type 
+ ARKDlsDenseJacFn. Its parameters are:
+
+ N   is the problem size.
+
+ Jac is the dense matrix (of type DlsMat) that will be loaded
+     by a ARKDlsDenseJacFn with an approximation to the Jacobian 
+     matrix J = (df_i/dy_j) at the point (t,y). 
+
+ t   is the current value of the independent variable.
+
+ y   is the current value of the dependent variable vector,
+     namely the predicted value of y(t).
+
+ fy  is the vector f(t,y).
+
+ user_data is a pointer to user data - the same as the user_data
+     parameter passed to ARKodeSetFdata.
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated for
+ vectors of length N which can be used by a ARKDlsDenseJacFn
+ as temporary storage or work space.
+
+ A ARKDlsDenseJacFn should return 0 if successful, a positive 
+ value if a recoverable error occurred, and a negative value if 
+ an unrecoverable error occurred.
+
+ NOTE: The following are two efficient ways to load a dense Jac:         
+ (1) (with macros - no explicit data structure references)      
+     for (j=0; j < Neq; j++) {                                  
+       col_j = DENSE_COL(Jac,j);                                 
+       for (i=0; i < Neq; i++) {                                
+         generate J_ij = the (i,j)th Jacobian element           
+         col_j[i] = J_ij;                                       
+       }                                                        
+     }                                                          
+ (2) (without macros - explicit data structure references)      
+     for (j=0; j < Neq; j++) {                                  
+       col_j = (Jac->data)[j];                                   
+       for (i=0; i < Neq; i++) {                                
+         generate J_ij = the (i,j)th Jacobian element           
+         col_j[i] = J_ij;                                       
+       }                                                        
+     }                                                          
+ A third way, using the DENSE_ELEM(A,i,j) macro, is much less   
+ efficient in general.  It is only appropriate for use in small 
+ problems in which efficiency of access is NOT a major concern. 
+                                                                
+ NOTE: If the user's Jacobian routine needs other quantities,   
+     they are accessible as follows: hcur (the current stepsize)
+     and ewt (the error weight vector) are accessible through   
+     ARKodeGetCurrentStep and ARKodeGetErrWeights, respectively 
+     (see arkode.h). The unit roundoff is available as 
+     UNIT_ROUNDOFF defined in sundials_types.h.
+
+---------------------------------------------------------------*/
+typedef int (*ARKDlsDenseJacFn)(long int N, realtype t,
+				N_Vector y, N_Vector fy, 
+				DlsMat Jac, void *user_data,
+				N_Vector tmp1, N_Vector tmp2, 
+				N_Vector tmp3);
+  
+
+/*---------------------------------------------------------------
+ Type: ARKDlsDenseMassFn
+
+ A dense mass matrix approximation function Mass must be of type 
+ ARKDlsDenseMassFn. Its parameters are:
+
+ N   is the problem size.
+
+ t   is the current value of the independent variable.
+
+ M   is the dense matrix (of type DlsMat) that will be loaded
+     by a ARKDlsDenseMassFn with an approximation to the mass matrix.
+
+ user_data is a pointer to user data - the same as the user_data
+     parameter passed to ARKodeSetFdata.
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated for
+ vectors of length N which can be used by a ARKDlsDenseMassFn
+ as temporary storage or work space.
+
+ A ARKDlsDenseMassFn should return 0 if successful, and a 
+ negative value if an unrecoverable error occurred.
+
+---------------------------------------------------------------*/
+typedef int (*ARKDlsDenseMassFn)(long int N, realtype t, DlsMat M, 
+				 void *user_data, N_Vector tmp1, 
+				 N_Vector tmp2, N_Vector tmp3);
+  
+
+/*---------------------------------------------------------------
+ Type: ARKDlsBandJacFn
+
+ A band Jacobian approximation function Jac must have the
+ prototype given below. Its parameters are:
+
+ N is the length of all vector arguments.
+
+ mupper is the upper half-bandwidth of the approximate banded
+ Jacobian. This parameter is the same as the mupper parameter
+ passed by the user to the linear solver initialization function.
+
+ mlower is the lower half-bandwidth of the approximate banded
+ Jacobian. This parameter is the same as the mlower parameter
+ passed by the user to the linear solver initialization function.
+
+ t is the current value of the independent variable.
+
+ y is the current value of the dependent variable vector,
+      namely the predicted value of y(t).
+
+ fy is the vector f(t,y).
+
+ Jac is the band matrix (of type DlsMat) that will be loaded
+ by a ARKDlsBandJacFn with an approximation to the Jacobian matrix
+ Jac = (df_i/dy_j) at the point (t,y).
+ Three efficient ways to load J are:
+
+ (1) (with macros - no explicit data structure references)
+    for (j=0; j < n; j++) {
+       col_j = BAND_COL(Jac,j);
+       for (i=j-mupper; i <= j+mlower; i++) {
+         generate J_ij = the (i,j)th Jacobian element
+         BAND_COL_ELEM(col_j,i,j) = J_ij;
+       }
+     }
+
+ (2) (with BAND_COL macro, but without BAND_COL_ELEM macro)
+    for (j=0; j < n; j++) {
+       col_j = BAND_COL(Jac,j);
+       for (k=-mupper; k <= mlower; k++) {
+         generate J_ij = the (i,j)th Jacobian element, i=j+k
+         col_j[k] = J_ij;
+       }
+     }
+
+ (3) (without macros - explicit data structure references)
+     offset = Jac->smu;
+     for (j=0; j < n; j++) {
+       col_j = ((Jac->data)[j])+offset;
+       for (k=-mupper; k <= mlower; k++) {
+         generate J_ij = the (i,j)th Jacobian element, i=j+k
+         col_j[k] = J_ij;
+       }
+     }
+ Caution: Jac->smu is generally NOT the same as mupper.
+
+ The BAND_ELEM(A,i,j) macro is appropriate for use in small
+ problems in which efficiency of access is NOT a major concern.
+
+ user_data is a pointer to user data - the same as the user_data
+          parameter passed to ARKodeSetFdata.
+
+ NOTE: If the user's Jacobian routine needs other quantities,
+     they are accessible as follows: hcur (the current stepsize)
+     and ewt (the error weight vector) are accessible through
+     ARKodeGetCurrentStep and ARKodeGetErrWeights, respectively
+     (see arkode.h). The unit roundoff is available as
+     UNIT_ROUNDOFF defined in sundials_types.h
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated for
+ vectors of length N which can be used by a ARKDlsBandJacFn
+ as temporary storage or work space.
+
+ A ARKDlsBandJacFn should return 0 if successful, a positive value
+ if a recoverable error occurred, and a negative value if an 
+ unrecoverable error occurred.
+---------------------------------------------------------------*/
+typedef int (*ARKDlsBandJacFn)(long int N, long int mupper, 
+			       long int mlower, realtype t, 
+			       N_Vector y, N_Vector fy, 
+			       DlsMat Jac, void *user_data,
+			       N_Vector tmp1, N_Vector tmp2, 
+			       N_Vector tmp3);
+
+/*---------------------------------------------------------------
+ Type: ARKDlsBandMassFn
+
+ A band mass matrix approximation function Mass must have the
+ prototype given below. Its parameters are:
+
+ N is the length of all vector arguments.
+
+ mupper is the upper half-bandwidth of the approximate banded
+ Jacobian. This parameter is the same as the mupper parameter
+ passed by the user to the linear solver initialization function.
+
+ mlower is the lower half-bandwidth of the approximate banded
+ Jacobian. This parameter is the same as the mlower parameter
+ passed by the user to the linear solver initialization function.
+
+ t is the current value of the independent variable.
+
+ M is the band matrix (of type DlsMat) that will be loaded
+ by a ARKDlsBandMassFn with an approximation to the mass matrix
+
+ user_data is a pointer to user data - the same as the user_data
+     parameter passed to ARKodeSetFdata.
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated for
+ vectors of length N which can be used by a ARKDlsBandMassFn
+ as temporary storage or work space.
+
+ A ARKDlsBandMassFn should return 0 if successful, and a negative 
+ value if an unrecoverable error occurred.
+---------------------------------------------------------------*/
+typedef int (*ARKDlsBandMassFn)(long int N, long int mupper, 
+				long int mlower, realtype t, 
+				DlsMat M, void *user_data, 
+				N_Vector tmp1, N_Vector tmp2, 
+				N_Vector tmp3);
+
+
+/*===============================================================
+  EXPORTED FUNCTIONS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Optional inputs to the ARKDLS linear solver:
+
+ ARKDlsSetDenseJacFn specifies the dense Jacobian approximation
+ routine to be used for a direct dense linear solver.
+
+ ARKDlsSetBandJacFn specifies the band Jacobian approximation
+ routine to be used for a direct band linear solver.
+
+ By default, a difference quotient approximation, supplied with
+ the solver is used.
+
+ The return value is one of:
+    ARKDLS_SUCCESS   if successful
+    ARKDLS_MEM_NULL  if the ARKODE memory was NULL
+    ARKDLS_LMEM_NULL if the linear solver memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKDlsSetDenseJacFn(void *arkode_mem, 
+					ARKDlsDenseJacFn jac);
+SUNDIALS_EXPORT int ARKDlsSetBandJacFn(void *arkode_mem, 
+				       ARKDlsBandJacFn jac);
+
+
+/*---------------------------------------------------------------
+ Optional inputs to the ARKDLS linear solver:
+
+ ARKDlsSetDenseMassFn specifies the dense mass matrix 
+ approximation routine to be used for a direct dense solver.
+
+ ARKDlsSetBandMassFn specifies the band mass matrix approximation
+ routine to be used for a direct band solver.
+
+ The return value is one of:
+    ARKDLS_SUCCESS      if successful
+    ARKDLS_MEM_NULL     if the ARKODE memory was NULL
+    ARKDLS_MASSMEM_NULL if the mass matrix solver memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKDlsSetDenseMassFn(void *arkode_mem, 
+					 ARKDlsDenseMassFn mass);
+SUNDIALS_EXPORT int ARKDlsSetBandMassFn(void *arkode_mem, 
+					ARKDlsBandMassFn mass);
+
+
+/*---------------------------------------------------------------
+ Optional outputs from the ARKDLS linear solver:
+
+ ARKDlsGetWorkSpace   returns the real and integer workspace used
+                     by the direct linear solver.
+ ARKDlsGetMassWorkSpace   returns the real and integer workspace used
+                     by the mass matrix direct linear solver.
+ ARKDlsGetNumJacEvals returns the number of calls made to the
+                     Jacobian evaluation routine jac.
+ ARKDlsGetNumMassEvals returns the number of calls made to the
+                     mass matrix evaluation routine Mass.
+ ARKDlsGetNumRhsEvals returns the number of calls to the user
+                     f routine due to finite difference Jacobian
+                     evaluation.
+ ARKDlsGetLastFlag    returns the last error flag set by any of
+                     the ARKDLS interface functions.
+ ARKDlsGetLastMassFlag  returns the last error flag set by any of
+                     the ARKDLS interface mass matrix functions.
+
+ The return value of ARKDlsGet* is one of:
+    ARKDLS_SUCCESS   if successful
+    ARKDLS_MEM_NULL  if the ARKODE memory was NULL
+    ARKDLS_LMEM_NULL if the linear solver memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKDlsGetWorkSpace(void *arkode_mem, 
+				       long int *lenrwLS, 
+				       long int *leniwLS);
+SUNDIALS_EXPORT int ARKDlsGetMassWorkSpace(void *arkode_mem, 
+					   long int *lenrwMLS, 
+					   long int *leniwMLS);
+SUNDIALS_EXPORT int ARKDlsGetNumJacEvals(void *arkode_mem, 
+					 long int *njevals);
+SUNDIALS_EXPORT int ARKDlsGetNumMassEvals(void *arkode_mem, 
+					  long int *nmevals);
+SUNDIALS_EXPORT int ARKDlsGetNumRhsEvals(void *arkode_mem, 
+					 long int *nfevalsLS);
+SUNDIALS_EXPORT int ARKDlsGetLastFlag(void *arkode_mem, 
+				      long int *flag);
+SUNDIALS_EXPORT int ARKDlsGetLastMassFlag(void *arkode_mem, 
+					  long int *flag);
+
+
+/*---------------------------------------------------------------
+ The following function returns the name of the constant 
+ associated with a ARKDLS return flag
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT char *ARKDlsGetReturnFlagName(long int flag);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_klu.h b/include/arkode/arkode_klu.h
new file mode 100644
index 0000000..54269ac
--- /dev/null
+++ b/include/arkode/arkode_klu.h
@@ -0,0 +1,195 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Header file for the ARKKLU linear solver module.
+ *---------------------------------------------------------------*/
+
+#ifndef _ARKKLU_H
+#define _ARKKLU_H
+
+#include "arkode/arkode_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ Function: ARKKLU
+-----------------------------------------------------------------
+ A call to the ARKKLU function links the main integrator with 
+ the ARKKLU linear solver module.
+                                                                
+ arkode_mem is the pointer to integrator memory returned by        
+            ARKodeCreate.             
+
+ n is the size of the linear system (nrows = ncols = n)
+
+ nnz is the maximum number of nonzeros in the sparse matrix
+     A = M + gamma*J
+                                                                
+ The return value of ARKKLU is one of:
+     ARKSLS_SUCCESS   if successful
+     ARKSLS_MEM_NULL  if the ARKode memory was NULL
+     ARKSLS_MEM_FAIL  if there was a memory allocation failure   
+     ARKSLS_ILL_INPUT if a required vector operation is missing
+                                                                
+ NOTE: The KLU linear solver assumes a serial implementation  
+       of the NVECTOR package. Therefore, ARKKLU will first
+       test for a compatible N_Vector internal representation
+       by checking that the function N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKKLU(void *arkode_mem, int n, int nnz, int sparsetype); 
+
+
+/*---------------------------------------------------------------
+ Function: ARKMassKLU
+-----------------------------------------------------------------
+ A call to the ARKMassKLU function links the mass matrix solve
+ with the ARKKLU linear solver module.
+                                                                
+ arkode_mem is the pointer to integrator memory returned by        
+            ARKodeCreate.             
+
+ n is the size of the linear system (nrows = ncols = n)
+
+ nnz is the maximum number of nonzeros in the sparse mass matrix
+                                                                
+ smass is the user-supplied sparse mass matrix setup function.
+
+ The return value of ARKMassKLU is one of:
+     ARKSLS_SUCCESS   if successful
+     ARKSLS_MEM_NULL  if the ARKode memory was NULL
+     ARKSLS_MEM_FAIL  if there was a memory allocation failure   
+     ARKSLS_ILL_INPUT if a required vector operation is missing
+                                                                
+ NOTE: The KLU linear solver assumes a serial implementation  
+       of the NVECTOR package. Therefore, ARKKLU will first
+       test for a compatible N_Vector internal representation
+       by checking that the function N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassKLU(void *arkode_mem, int n, int nnz, int sparsetype,
+			       ARKSlsSparseMassFn smass); 
+
+
+/*
+ * -----------------------------------------------------------------
+ * ARKKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to CVKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is ARKSLS_SUCCESS = 0, ARKSLS_MEM_NULL = -1, 
+ * ARKSLS_LMEM_NULL = -2, ARKSLS_ILL_INPUT = -3, or ARKSLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int ARKKLUReInit(void *arkode_mem, int n, int nnz, 
+				   int reinit_type);
+
+
+/*
+ * -----------------------------------------------------------------
+ * ARKMassKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to CVKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is ARKSLS_SUCCESS = 0, ARKSLS_MEM_NULL = -1, 
+ * ARKSLS_MASSMEM_NULL = -8, ARKSLS_ILL_INPUT = -3, or ARKSLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int ARKMassKLUReInit(void *arkode_mem, int n, 
+				       int nnz, int reinit_type);
+
+/*================================================================
+ Optional Input Specification Functions
+=================================================================*/
+
+/*---------------------------------------------------------------
+ Function: ARKKLUSetOrdering 
+-----------------------------------------------------------------
+ This routine sets the ordering used by KLU for reducing fill in 
+ the system matrix solve.  Options for ordering_choice are: 
+        0 for AMD, 
+	1 for COLAMD, and 
+	2 for the natural ordering.
+ The default used in ARKODE is 1 for COLAMD.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKKLUSetOrdering(void *arkode_mem, 
+				      int ordering_choice); 
+
+
+/*---------------------------------------------------------------
+ Function: ARKMassKLUSetOrdering 
+-----------------------------------------------------------------
+ This routine sets the ordering used by KLU for reducing fill in 
+ the mass matrix solve.  Options for ordering_choice are: 
+        0 for AMD, 
+	1 for COLAMD, and 
+	2 for the natural ordering.
+ The default used in ARKODE is 1 for COLAMD.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassKLUSetOrdering(void *arkode_mem, 
+					  int ordering_choice); 
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_lapack.h b/include/arkode/arkode_lapack.h
new file mode 100644
index 0000000..6f18050
--- /dev/null
+++ b/include/arkode/arkode_lapack.h
@@ -0,0 +1,134 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Header file for the ARKODE dense linear solver ARKLAPACK.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKLAPACK_H
+#define _ARKLAPACK_H
+
+#include <arkode/arkode_direct.h>
+#include <sundials/sundials_lapack.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*===============================================================
+  EXPORTED FUNCTIONS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ ARKLapackDense:
+
+ A call to the ARKLapackDense function links the main integrator
+ with the ARKLAPACK linear solver using dense Jacobians.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ The return value of ARKLapackDense is one of:
+    ARKLAPACK_SUCCESS   if successful
+    ARKLAPACK_MEM_NULL  if the ARKODE memory was NULL
+    ARKLAPACK_MEM_FAIL  if there was a memory allocation failure
+    ARKLAPACK_ILL_INPUT if a required vector operation is missing
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKLapackDense(void *arkode_mem, int N);
+
+
+/*---------------------------------------------------------------
+ ARKMassLapackDense:
+
+ A call to the ARKMassLapackDense function links the mass matrix 
+ solve with the ARKLAPACK linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ dmass is the user-supplied dense mass matrix setup routine.
+
+ The return value of ARKMassLapackDense is one of:
+    ARKLAPACK_SUCCESS   if successful
+    ARKLAPACK_MEM_NULL  if the ARKODE memory was NULL
+    ARKLAPACK_MEM_FAIL  if there was a memory allocation failure
+    ARKLAPACK_ILL_INPUT if a required vector operation is missing
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassLapackDense(void *arkode_mem, int N, 
+				       ARKDlsDenseMassFn dmass);
+
+
+/*---------------------------------------------------------------
+ ARKLapackBand:
+
+ A call to the ARKLapackBand function links the main integrator
+ with the ARKLAPACK linear solver using banded Jacobians. 
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ mupper is the upper bandwidth of the band Jacobian approximation.
+
+ mlower is the lower bandwidth of the band Jacobian approximation.
+
+ The return value of ARKLapackBand is one of:
+    ARKLAPACK_SUCCESS   if successful
+    ARKLAPACK_MEM_NULL  if the ARKODE memory was NULL
+    ARKLAPACK_MEM_FAIL  if there was a memory allocation failure
+    ARKLAPACK_ILL_INPUT if a required vector operation is missing 
+                        or if a bandwidth has an illegal value.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKLapackBand(void *arkode_mem, int N, int mupper, int mlower);
+
+/*---------------------------------------------------------------
+ ARKMassLapackBand:
+
+ A call to the ARKMassLapackBand function links the mass matrix 
+ solve with the ARKLAPACK linear solver. 
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ N is the size of the ODE system.
+
+ mupper is the upper bandwidth of the band Jacobian approximation.
+
+ mlower is the lower bandwidth of the band Jacobian approximation.
+
+ bmass is the user-supplied band mass matrix setup routine.
+
+ The return value of ARKLapackBand is one of:
+    ARKLAPACK_SUCCESS   if successful
+    ARKLAPACK_MEM_NULL  if the ARKODE memory was NULL
+    ARKLAPACK_MEM_FAIL  if there was a memory allocation failure
+    ARKLAPACK_ILL_INPUT if a required vector operation is missing 
+                        or if a bandwidth has an illegal value.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassLapackBand(void *arkode_mem, int N, int mupper, 
+				      int mlower, ARKDlsBandMassFn bmass);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_pcg.h b/include/arkode/arkode_pcg.h
new file mode 100644
index 0000000..545f4ca
--- /dev/null
+++ b/include/arkode/arkode_pcg.h
@@ -0,0 +1,116 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for the ARKODE scaled preconditioned 
+ * CG linear solver, ARKPCG.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKPCG_H
+#define _ARKPCG_H
+
+#include <arkode/arkode.h>
+#include <arkode/arkode_spils.h>
+#include <sundials/sundials_pcg.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ ARKPcg:
+
+ A call to the ARKPcg function links the main ARKODE integrator
+ with the ARKPCG linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined
+           in iterative.h. These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.  However, since PCG requires a symmetric 
+	   linear operator, this flag is checked for any one of 
+	   PREC_LEFT, PREC_RIGHT and PREC_BOTH -- if any are 
+	   found then preconditioning is used.  It is assumed 
+	   that the preconditioner implements a symmetric linear 
+	   operator.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKPCG solver. Pass 0 to
+           use the default value ARKPCG_MAXL=5.
+
+ The return value of ARKPcg is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKPcg(void *arkode_mem, int pretype, int maxl);
+
+
+/*---------------------------------------------------------------
+ ARKMassPcg:
+
+ A call to the ARKMassPcg function links the mass matrix solve
+ with the ARKPCG linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined
+           in iterative.h. These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.  However, since PCG requires a symmetric 
+	   linear operator, this flag is checked for any one of 
+	   PREC_LEFT, PREC_RIGHT and PREC_BOTH -- if any are 
+	   found then preconditioning is used.  It is assumed 
+	   that the preconditioner implements a symmetric linear 
+	   operator.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKPCG solver. Pass 0 to
+           use the default value ARKPCG_MAXL=5.
+
+ mtimes    is the user-supplied mass-matrix-vector product 
+           routine.
+
+ The return value of ARKMassPcg is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassPcg(void *arkode_mem, int pretype, int maxl, 
+			       ARKSpilsMassTimesVecFn mtimes,
+			       void *mtimes_data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_sparse.h b/include/arkode/arkode_sparse.h
new file mode 100644
index 0000000..f0b279e
--- /dev/null
+++ b/include/arkode/arkode_sparse.h
@@ -0,0 +1,216 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Header file for the generic ARKSLS linear solver module.
+ *---------------------------------------------------------------*/
+
+#ifndef _ARKSPARSE_H
+#define _ARKSPARSE_H
+
+#include <sundials/sundials_sparse.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*===============================================================
+  ARKSPARSE CONSTANTS
+===============================================================*/
+
+/* ARKSLS return values */
+#define ARKSLS_SUCCESS           0
+#define ARKSLS_MEM_NULL         -1
+#define ARKSLS_LMEM_NULL        -2
+#define ARKSLS_ILL_INPUT        -3
+#define ARKSLS_MEM_FAIL         -4
+#define ARKSLS_JAC_NOSET        -5
+#define ARKSLS_MASS_NOSET       -6
+#define ARKSLS_PACKAGE_FAIL     -7
+#define ARKSLS_MASSMEM_NULL     -8
+
+/* Additional last_flag values */
+#define ARKSLS_JACFUNC_UNRECVR  -9
+#define ARKSLS_JACFUNC_RECVR    -10
+#define ARKSLS_MASSFUNC_UNRECVR -11
+#define ARKSLS_MASSFUNC_RECVR   -12
+
+
+/*===============================================================
+  FUNCTION TYPES
+===============================================================*/
+
+/*-----------------------------------------------------------------
+ Types : ARKSlsSparseJacFn
+
+ A sparse Jacobian approximation function Jac must be of type
+ ARKSlsSparseJacFn.  Its parameters are:
+
+ t   is the current value of the independent variable t.
+                                                                
+ y   is the current value of the dependent variable vector,
+     namely the predicted value of y(t)
+                                                                
+ fy  is the vector f(t,y).
+     namely the predicted value of y'(t)
+                                                                
+ JacMat is the compressed sparse column matrix (of type SlsMat)
+     to be loaded by an ARKSlsSparseJacFn routine with an 
+     approximation to the system Jacobian matrix
+            J = (df_i/dy_j) at the point (t,y). 
+     Note that JacMat is NOT preset to zero!
+     Matrix data is for the nonzero entries of the Jacobian stored 
+     in compressed column format.  Row indices of entries in 
+     column j are stored in JacMat->rowvals[colptrs[j]] 
+     through JacMat->rowvals[colptrs[j+i]-1]
+     and corresponding numerical values of the Jacobian are stored 
+     in the same entries of JacMat->data.
+
+ J_data is a pointer to user Jacobian data - the same as the
+     user_data parameter passed to ARKodeSetFdata.
+                                                                
+ tmp1, tmp2, tmp3 are pointers to memory allocated for
+     N_Vectors which can be used by an ARKSparseJacFn routine
+     as temporary storage or work space.
+                                                                
+ A ARKSlsSparseJacFn should return 0 if successful, a positive 
+ value if a recoverable error occurred, and a negative value if 
+ a nonrecoverable error occurred. 
+
+ NOTE: If the user's Jacobian routine needs other quantities,
+     they are accessible as follows: hcur (the current stepsize)
+     and ewt (the error weight vector) are accessible through
+     ARKodeGetCurrentStep and ARKodeGetErrWeights, respectively
+     (see arkode.h). The unit roundoff is available as
+     UNIT_ROUNDOFF defined in sundials_types.h.
+
+---------------------------------------------------------------*/
+typedef int (*ARKSlsSparseJacFn)(realtype t,
+				 N_Vector y, N_Vector fy, 
+				 SlsMat JacMat, void *user_data,
+				 N_Vector tmp1, N_Vector tmp2, 
+				 N_Vector tmp3);
+
+/*-----------------------------------------------------------------
+ Types : ARKSlsSparseMassFn
+
+ A sparse mass matrix approximation function Mass must be of type
+ ARKSlsSparseMassFn.  Its parameters are:
+
+ t   is the current value of the independent variable t.
+                                                                
+ MassMat is the compressed sparse column matrix (of type SlsMat)
+     to be loaded by an ARKSlsSparseJacFn routine with an 
+     approximation to the system mass matrix.  Note that MassMat 
+     is NOT preset to zero! Matrix data is for the nonzero entries 
+     of the mass matrix stored in compressed column format.  Row 
+     indices of entries in column j are stored in 
+     MassMat->rowvals[colptrs[j]] through 
+     MassMat->rowvals[colptrs[j+i]-1]
+     and corresponding numerical values of the mass matrix are 
+     stored in the same entries of MassMat->data.
+
+ M_data is a pointer to user mass matrix data - the same as the
+     user_data parameter passed to ARKodeSetFdata.
+                                                                
+ tmp1, tmp2, tmp3 are pointers to memory allocated for
+     N_Vectors which can be used by an ARKSparseJacFn routine
+     as temporary storage or work space.
+                                                                
+ A ARKSlsSparseMassFn should return 0 if successful, a positive 
+ value if a recoverable error occurred, and a negative int if a
+ nonrecoverable error occurred. 
+
+---------------------------------------------------------------*/
+typedef int (*ARKSlsSparseMassFn)(realtype t, SlsMat MassMat, 
+				  void *user_data, N_Vector tmp1, 
+				  N_Vector tmp2, N_Vector tmp3);
+
+
+/*===============================================================
+  EXPORTED FUNCTIONS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Optional inputs to the ARKSLS linear solver:
+
+ ARKSlsSetSparseJacFn specifies the Jacobian approximation
+ routine to be used for a sparse direct linear solver.
+
+ The return value is one of:
+    ARKSLS_SUCCESS   if successful
+    ARKSLS_MEM_NULL  if the ARKODE memory was NULL
+    ARKSLS_LMEM_NULL if the linear solver memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSlsSetSparseJacFn(void *arkode_mem, 
+					 ARKSlsSparseJacFn jac);
+
+/*---------------------------------------------------------------
+ Optional inputs to the ARKSLS linear solver:
+
+ ARKSlsSetSparseMassFn specifies the sparse mass matrix 
+ approximation routine to be used for a sparse direct linear 
+ solver.
+
+ The return value is one of:
+    ARKSLS_SUCCESS   if successful
+    ARKSLS_MEM_NULL  if the ARKODE memory was NULL
+    ARKSLS_MASSMEM_NULL if the mass matrix solver memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSlsSetSparseMassFn(void *arkode_mem, 
+					  ARKSlsSparseMassFn mass);
+
+/*---------------------------------------------------------------
+ Optional outputs from the ARKSLS linear solver:
+
+ ARKSlsGetNumJacEvals returns the number of calls made to the
+                      Jacobian evaluation routine jac.
+ ARKSlsGetNumMassEvals returns the number of calls made to the
+                      mass matrix evaluation routine Mass.
+ ARKSlsGetLastFlag    returns the last error flag set by any of
+                      the ARKSLS interface functions.
+ ARKSlsGetLastMassFlag returns the last error flag set by any of 
+                      the ARKSLS interface mass matrix functions.
+
+ The return value of ARKSlsGet* is one of:
+    ARKSLS_SUCCESS   if successful
+    ARKSLS_MEM_NULL  if the IDA memory was NULL
+    ARKSLS_LMEM_NULL if the linear solver memory was NULL
+    ARKSLS_MASSMEM_NULL if the linear solver memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSlsGetNumJacEvals(void *arkode_mem, 
+					 long int *njevals);
+SUNDIALS_EXPORT int ARKSlsGetNumMassEvals(void *arkode_mem, 
+					  long int *nmevals);
+SUNDIALS_EXPORT int ARKSlsGetLastFlag(void *arkode_mem, 
+				      long int *flag);
+SUNDIALS_EXPORT int ARKSlsGetLastMassFlag(void *arkode_mem, 
+					  long int *flag);
+
+/*---------------------------------------------------------------
+ The following function returns the name of the constant 
+ associated with a ARKSLS return flag
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT char *ARKSlsGetReturnFlagName(long int flag);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_spbcgs.h b/include/arkode/arkode_spbcgs.h
new file mode 100644
index 0000000..2151d7b
--- /dev/null
+++ b/include/arkode/arkode_spbcgs.h
@@ -0,0 +1,106 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for the ARKODE scaled preconditioned 
+ * Bi-CGSTAB linear solver, ARKSPBCG.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKSPBCG_H
+#define _ARKSPBCG_H
+
+#include <arkode/arkode.h>
+#include <arkode/arkode_spils.h>
+#include <sundials/sundials_spbcgs.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ ARKSpbcg:
+
+ A call to the ARKSpbcg function links the main ARKODE integrator
+ with the ARKSPBCG linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined
+           in iterative.h. These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPBCG solver. Pass 0 to
+           use the default value ARKSPBCG_MAXL=5.
+
+ The return value of ARKSpbcg is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSpbcg(void *arkode_mem, int pretype, int maxl);
+
+
+/*---------------------------------------------------------------
+ ARKMassSpbcg:
+
+ A call to the ARKMassSpbcg function links the mass matrix solve
+ with the ARKSPBCG linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined
+           in iterative.h. These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPBCG solver. Pass 0 to
+           use the default value ARKSPBCG_MAXL=5.
+
+ mtimes    is the user-supplied mass-matrix-vector product 
+           routine.
+
+ The return value of ARKMassSpbcg is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassSpbcg(void *arkode_mem, int pretype, int maxl, 
+				 ARKSpilsMassTimesVecFn mtimes,
+				 void *mtimes_data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_spfgmr.h b/include/arkode/arkode_spfgmr.h
new file mode 100644
index 0000000..cd8f36d
--- /dev/null
+++ b/include/arkode/arkode_spfgmr.h
@@ -0,0 +1,115 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for the ARKODE scaled preconditioned 
+ * FGMRES linear solver, ARKSPFGMR.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKSPFGMR_H
+#define _ARKSPFGMR_H
+
+#include <arkode/arkode.h>
+#include <arkode/arkode_spils.h>
+#include <sundials/sundials_spfgmr.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ ARKSpfgmr:
+
+ A call to ARKSpfgmr links the main ARKODE integrator with the 
+ ARKSPFGMR linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined 
+           in sundials_iterative.h.
+           These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively. ARKSPFGMR only implements right 
+	   preconditioning, so if any one of PREC_LEFT, 
+	   PREC_RIGHT or PREC_BOTH are defined, it will default 
+	   to using the right preconditioner only.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPFGMR solver. Pass 0 to
+           use the default value ARKSPFGMR_MAXL=5.
+
+ The return value of ARKSpfgmr is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSpfgmr(void *arkode_mem, int pretype, int maxl);
+
+
+/*---------------------------------------------------------------
+ ARKMassSpfgmr:
+
+ A call to ARKMassSpfgmr links the mass matrix solve
+ with the ARKSPFGMR linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined 
+           in sundials_iterative.h.
+           These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively. ARKSPFGMR only implements right 
+	   preconditioning, so if any one of PREC_LEFT, 
+	   PREC_RIGHT or PREC_BOTH are defined, it will default 
+	   to using the right preconditioner only.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPFGMR solver. Pass 0 to
+           use the default value ARKSPFGMR_MAXL=5.
+
+ mtimes    is the user-supplied mass-matrix-vector product 
+           routine.
+
+ The return value of ARKMassSpfgmr is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassSpfgmr(void *arkode_mem, int pretype, int maxl, 
+				  ARKSpilsMassTimesVecFn mtimes,
+				  void *mtimes_data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_spgmr.h b/include/arkode/arkode_spgmr.h
new file mode 100644
index 0000000..336e74a
--- /dev/null
+++ b/include/arkode/arkode_spgmr.h
@@ -0,0 +1,109 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for the ARKODE scaled preconditioned 
+ * GMRES linear solver, ARKSPGMR.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKSPGMR_H
+#define _ARKSPGMR_H
+
+#include <arkode/arkode.h>
+#include <arkode/arkode_spils.h>
+#include <sundials/sundials_spgmr.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ ARKSpgmr:
+
+ A call to the ARKSpgmr function links the main ARKODE integrator
+ with the ARKSPGMR linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined 
+           in sundials_iterative.h.
+           These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPGMR solver. Pass 0 to
+           use the default value ARKSPGMR_MAXL=5.
+
+ The return value of ARKSpgmr is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSpgmr(void *arkode_mem, int pretype, int maxl);
+
+
+/*---------------------------------------------------------------
+ ARKMassSpgmr:
+
+ A call to the ARKMassSpgmr function links the mass matrix solve
+ with the ARKSPGMR linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined 
+           in sundials_iterative.h.
+           These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPGMR solver. Pass 0 to
+           use the default value ARKSPGMR_MAXL=5.
+
+ mtimes    is the user-supplied mass-matrix-vector product 
+           routine.
+
+ The return value of ARKMassSpgmr is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassSpgmr(void *arkode_mem, int pretype, int maxl, 
+				 ARKSpilsMassTimesVecFn mtimes,
+				 void *mtimes_data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_spils.h b/include/arkode/arkode_spils.h
new file mode 100644
index 0000000..54040f0
--- /dev/null
+++ b/include/arkode/arkode_spils.h
@@ -0,0 +1,529 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the common header file for the Scaled, Preconditioned
+ * Iterative Linear Solvers in ARKODE.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKSPILS_H
+#define _ARKSPILS_H
+
+#include <sundials/sundials_iterative.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ ARKSPILS return values 
+---------------------------------------------------------------*/
+#define ARKSPILS_SUCCESS       0
+#define ARKSPILS_MEM_NULL     -1
+#define ARKSPILS_LMEM_NULL    -2
+#define ARKSPILS_ILL_INPUT    -3
+#define ARKSPILS_MEM_FAIL     -4
+#define ARKSPILS_PMEM_NULL    -5
+#define ARKSPILS_MASSMEM_NULL -6
+
+
+/*---------------------------------------------------------------
+ ARKSPILS solver constants:
+
+ ARKSPILS_MAXL   : default value for the maximum Krylov
+                   dimension
+
+ ARKSPILS_MSBPRE : maximum number of steps between
+                   preconditioner evaluations
+
+ ARKSPILS_DGMAX  : maximum change in gamma between
+                   preconditioner evaluations
+
+ ARKSPILS_EPLIN  : default value for factor by which the
+                   tolerance on the nonlinear iteration is
+                   multiplied to get a tolerance on the linear
+                   iteration
+---------------------------------------------------------------*/
+#define ARKSPILS_MAXL   5
+#define ARKSPILS_MSBPRE 50
+#define ARKSPILS_DGMAX  RCONST(0.2)
+#define ARKSPILS_EPLIN  RCONST(0.05)
+
+
+/*---------------------------------------------------------------
+ Type: ARKSpilsPrecSetupFn
+
+ The user-supplied preconditioner setup function PrecSetup and
+ the user-supplied preconditioner solve function PrecSolve
+ together must define left and right preconditoner matrices
+ P1 and P2 (either of which may be trivial), such that the
+ product P1*P2 is an approximation to the Newton matrix
+ M = I - gamma*J.  Here J is the system Jacobian J = df/dy,
+ and gamma is a scalar proportional to the integration step
+ size h.  The solution of systems P z = r, with P = P1 or P2,
+ is to be carried out by the PrecSolve function, and PrecSetup
+ is to do any necessary setup operations.
+
+ The user-supplied preconditioner setup function PrecSetup
+ is to evaluate and preprocess any Jacobian-related data
+ needed by the preconditioner solve function PrecSolve.
+ This might include forming a crude approximate Jacobian,
+ and performing an LU factorization on the resulting
+ approximation to M.  This function will not be called in
+ advance of every call to PrecSolve, but instead will be called
+ only as often as necessary to achieve convergence within the
+ Newton iteration.  If the PrecSolve function needs no
+ preparation, the PrecSetup function can be NULL.
+
+ For greater efficiency, the PrecSetup function may save
+ Jacobian-related data and reuse it, rather than generating it
+ from scratch.  In this case, it should use the input flag jok
+ to decide whether to recompute the data, and set the output
+ flag *jcurPtr accordingly.
+
+ Each call to the PrecSetup function is preceded by a call to
+ the RhsFn f with the same (t,y) arguments.  Thus the PrecSetup
+ function can use any auxiliary data that is computed and
+ saved by the f function and made accessible to PrecSetup.
+
+ A function PrecSetup must have the prototype given below.
+ Its parameters are as follows:
+
+ t       is the current value of the independent variable.
+
+ y       is the current value of the dependent variable vector,
+          namely the predicted value of y(t).
+
+ fy      is the vector f(t,y).
+
+ jok     is an input flag indicating whether Jacobian-related
+         data needs to be recomputed, as follows:
+           jok == FALSE means recompute Jacobian-related data
+                  from scratch.
+           jok == TRUE  means that Jacobian data, if saved from
+                  the previous PrecSetup call, can be reused
+                  (with the current value of gamma).
+         A Precset call with jok == TRUE can only occur after
+         a call with jok == FALSE.
+
+ jcurPtr is a pointer to an output integer flag which is
+         to be set by PrecSetup as follows:
+         Set *jcurPtr = TRUE if Jacobian data was recomputed.
+         Set *jcurPtr = FALSE if Jacobian data was not recomputed,
+                        but saved data was reused.
+
+ gamma   is the scalar appearing in the Newton matrix.
+
+ user_data  is a pointer to user data - the same as the user_data
+         parameter passed to the ARKodeSetUserData function.
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated
+                      for N_Vectors which can be used by
+                      ARKSpilsPrecSetupFn as temporary storage or
+                      work space.
+
+ NOTE: If the user's preconditioner needs other quantities,
+       they are accessible as follows: hcur (the current stepsize)
+       and ewt (the error weight vector) are accessible through
+       ARKodeGetCurrentStep and ARKodeGetErrWeights, respectively).
+       The unit roundoff is available as UNIT_ROUNDOFF defined in
+       sundials_types.h.
+
+ Returned value:
+ The value to be returned by the PrecSetup function is a flag
+ indicating whether it was successful.  This value should be
+   0   if successful,
+   > 0 for a recoverable error (step will be retried),
+   < 0 for an unrecoverable error (integration is halted).
+---------------------------------------------------------------*/
+typedef int (*ARKSpilsPrecSetupFn)(realtype t, N_Vector y, 
+				   N_Vector fy, booleantype jok, 
+				   booleantype *jcurPtr,
+				   realtype gamma, void *user_data,
+				   N_Vector tmp1, N_Vector tmp2,
+				   N_Vector tmp3);
+
+
+/*---------------------------------------------------------------
+ Type: ARKSpilsPrecSolveFn
+
+ The user-supplied preconditioner solve function PrecSolve
+ is to solve a linear system P z = r in which the matrix P is
+ one of the preconditioner matrices P1 or P2, depending on the
+ type of preconditioning chosen.
+
+ A function PrecSolve must have the prototype given below.
+ Its parameters are as follows:
+
+ t      is the current value of the independent variable.
+
+ y      is the current value of the dependent variable vector.
+
+ fy     is the vector f(t,y).
+
+ r      is the right-hand side vector of the linear system.
+
+ z      is the output vector computed by PrecSolve.
+
+ gamma  is the scalar appearing in the Newton matrix.
+
+ delta  is an input tolerance for use by PSolve if it uses
+        an iterative method in its solution.  In that case,
+        the residual vector Res = r - P z of the system
+        should be made less than delta in weighted L2 norm,
+        i.e., sqrt [ Sum (Res[i]*ewt[i])^2 ] < delta.
+        Note: the error weight vector ewt can be obtained
+        through a call to the routine ARKodeGetErrWeights.
+
+ lr     is an input flag indicating whether PrecSolve is to use
+        the left preconditioner P1 or right preconditioner
+        P2: lr = 1 means use P1, and lr = 2 means use P2.
+
+ user_data  is a pointer to user data - the same as the user_data
+         parameter passed to the ARKodeSetUserData function.
+
+ tmp    is a pointer to memory allocated for an N_Vector
+        which can be used by PSolve for work space.
+
+ Returned value:
+ The value to be returned by the PrecSolve function is a flag
+ indicating whether it was successful.  This value should be
+   0 if successful,
+   positive for a recoverable error (step will be retried),
+   negative for an unrecoverable error (integration is halted).
+---------------------------------------------------------------*/
+typedef int (*ARKSpilsPrecSolveFn)(realtype t, N_Vector y, 
+				   N_Vector fy, N_Vector r, 
+				   N_Vector z, realtype gamma, 
+				   realtype delta, int lr, 
+				   void *user_data, N_Vector tmp);
+
+
+/*---------------------------------------------------------------
+ Type: ARKSpilsJacTimesVecFn
+
+ The user-supplied function jtimes is to generate the product
+ J*v for given v, where J is the Jacobian df/dy, or an
+ approximation to it, and v is a given vector. It should return
+ 0 if successful a positive value for a recoverable error or 
+ a negative value for an unrecoverable failure.
+
+ A function jtimes must have the prototype given below. Its
+ parameters are as follows:
+
+   v        is the N_Vector to be multiplied by J.
+
+   Jv       is the output N_Vector containing J*v.
+
+   t        is the current value of the independent variable.
+
+   y        is the current value of the dependent variable
+            vector.
+
+   fy       is the vector f(t,y).
+
+   user_data   is a pointer to user data, the same as the user_data
+            parameter passed to the ARKodeSetUserData function.
+
+   tmp      is a pointer to memory allocated for an N_Vector
+            which can be used by Jtimes for work space.
+---------------------------------------------------------------*/
+typedef int (*ARKSpilsJacTimesVecFn)(N_Vector v, N_Vector Jv, 
+				     realtype t, N_Vector y, 
+				     N_Vector fy, void *user_data, 
+				     N_Vector tmp);
+
+
+/*---------------------------------------------------------------
+ Type: ARKSpilsMassTimesVecFn
+
+ The user-supplied function mtimes is to generate the product
+ M*v for given v, where M is the mass matrix, or an 
+ approximation to it, and v is a given vector. It should return 
+ 0 if successful or a negative value for an unrecoverable failure.
+
+ A function mtimes must have the prototype given below. Its
+ parameters are as follows:
+
+   v        is the N_Vector to be multiplied by M.
+
+   Mv       is the output N_Vector containing M*v.
+
+   t        is the current value of the independent variable.
+
+   user_data   is a pointer to user data, the same as the user_data
+            parameter passed to the ARKodeSetUserData function.
+---------------------------------------------------------------*/
+typedef int (*ARKSpilsMassTimesVecFn)(N_Vector v, N_Vector Mv, 
+				      realtype t, void *user_data);
+
+
+
+/*---------------------------------------------------------------
+ Type: ARKSpilsMassPrecSetupFn
+
+ The user-supplied mass matrix preconditioner setup function 
+ MPrecSetup and the user-supplied mass matrix preconditioner solve 
+ function PrecSolve together must define left and right 
+ preconditoner matrices P1 and P2 (either of which may be 
+ trivial), such that the product P1*P2 is an approximation to 
+ the mass matrix M.  The solution of systems P z = r, with P = P1 
+ or P2, is to be carried out by the PrecSolve function, and 
+ MPrecSetup is to do any necessary setup operations.
+
+ The user-supplied preconditioner setup function MPrecSetup
+ is to evaluate and preprocess any mass-matrix-related data
+ needed by the preconditioner solve function PrecSolve.
+
+ A function MPrecSetup must have the prototype given below.
+ Its parameters are as follows:
+
+ t       is the current value of the independent variable.
+
+ user_data  is a pointer to user data - the same as the user_data
+         parameter passed to the ARKodeSetUserData function.
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated
+                      for N_Vectors which can be used by
+                      ARKSpilsMassPrecSetupFn as temporary 
+                      storage or work space.
+
+ Returned value:
+ The value to be returned by the MPrecSetup function is a flag
+ indicating whether it was successful.  This value should be
+   0   if successful,
+   < 0 for an unrecoverable error (integration is halted).
+---------------------------------------------------------------*/
+typedef int (*ARKSpilsMassPrecSetupFn)(realtype t, void *user_data, 
+				       N_Vector tmp1, N_Vector tmp2, 
+				       N_Vector tmp3);
+
+
+/*---------------------------------------------------------------
+ Type: ARKSpilsMassPrecSolveFn
+
+ The user-supplied mass matrix preconditioner solve function 
+ MPrecSolve is to solve a linear system P z = r in which the 
+ matrix P is one of the preconditioner matrices P1 or P2, 
+ depending on the type of preconditioning chosen.
+
+ A function MPrecSolve must have the prototype given below.
+ Its parameters are as follows:
+
+ t      is the current value of the independent variable.
+
+ r      is the right-hand side vector of the linear system.
+
+ z      is the output vector computed by MPrecSolve.
+
+ delta  is an input tolerance for use by PSolve if it uses
+        an iterative method in its solution.  In that case,
+        the residual vector Res = r - P z of the system
+        should be made less than delta in weighted L2 norm,
+        i.e., sqrt [ Sum (Res[i]*ewt[i])^2 ] < delta.
+        Note: the error weight vector ewt can be obtained
+        through a call to the routine ARKodeGetErrWeights.
+
+ lr     is an input flag indicating whether MPrecSolve is to use
+        the left preconditioner P1 or right preconditioner
+        P2: lr = 1 means use P1, and lr = 2 means use P2.
+
+ user_data  is a pointer to user data - the same as the user_data
+         parameter passed to the ARKodeSetUserData function.
+
+ tmp    is a pointer to memory allocated for an N_Vector
+        which can be used by PSolve for work space.
+
+ Returned value:
+ The value to be returned by the MPrecSolve function is a flag
+ indicating whether it was successful.  This value should be
+   0 if successful,
+   negative for an unrecoverable error (integration is halted).
+---------------------------------------------------------------*/
+typedef int (*ARKSpilsMassPrecSolveFn)(realtype t, N_Vector r, 
+				       N_Vector z, realtype delta, 
+				       int lr, void *user_data, 
+				       N_Vector tmp);
+
+
+/*---------------------------------------------------------------
+ Optional inputs to the ARKSPILS linear solver:
+
+ ARKSpilsSetPrecType resets the type of preconditioner, pretype,
+                from the value previously set.
+                This must be one of PREC_NONE, PREC_LEFT, 
+                PREC_RIGHT, or PREC_BOTH.
+
+ ARKSpilsSetGSType specifies the type of Gram-Schmidt
+                orthogonalization to be used. This must be one of
+                the two enumeration constants MODIFIED_GS or
+                CLASSICAL_GS defined in iterative.h. These 
+                correspond to using modified Gram-Schmidt and 
+                classical Gram-Schmidt, respectively.
+                Default value is MODIFIED_GS.
+
+ ARKSpilsSetMaxl resets the maximum Krylov subspace size, maxl,
+                from the value previously set.
+                An input value <= 0, gives the default value.
+
+ ARKSpilsSetEpsLin specifies the factor by which the tolerance on
+                the nonlinear iteration is multiplied to get a
+                tolerance on the linear iteration.
+                Default value is 0.05.
+
+ ARKSpilsSetPreconditioner specifies the PrecSetup and PrecSolve 
+                functions.  Default is NULL for both arguments 
+                (no preconditioning)
+
+ ARKSpilsSetMassPreconditioner specifies the mass matrix MPrecSetup
+                and MPrecSolve functions.  Default is NULL for 
+                both arguments (no preconditioning)
+
+ ARKSpilsSetJacTimesVecFn specifies the jtimes function. Default 
+                is to use an internal finite difference 
+		approximation routine.
+
+ ARKSpilsSetMassTimesVecFn specifies the mtimes function. No Default.
+
+ The return value of ARKSpilsSet* is one of:
+    ARKSPILS_SUCCESS      if successful
+    ARKSPILS_MEM_NULL     if the arkode memory was NULL
+    ARKSPILS_LMEM_NULL    if the linear solver memory was NULL
+    ARKSPILS_MASSMEM_NULL if the mass matrix solver memory was NULL
+    ARKSPILS_ILL_INPUT    if an input has an illegal value
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSpilsSetPrecType(void *arkode_mem, int pretype);
+SUNDIALS_EXPORT int ARKSpilsSetMassPrecType(void *arkode_mem, int pretype);
+SUNDIALS_EXPORT int ARKSpilsSetGSType(void *arkode_mem, int gstype);
+SUNDIALS_EXPORT int ARKSpilsSetMassGSType(void *arkode_mem, int gstype);
+SUNDIALS_EXPORT int ARKSpilsSetMaxl(void *arkode_mem, int maxl);
+SUNDIALS_EXPORT int ARKSpilsSetMassMaxl(void *arkode_mem, int maxl);
+SUNDIALS_EXPORT int ARKSpilsSetEpsLin(void *arkode_mem, realtype eplifac);
+SUNDIALS_EXPORT int ARKSpilsSetMassEpsLin(void *arkode_mem, realtype eplifac);
+SUNDIALS_EXPORT int ARKSpilsSetPreconditioner(void *arkode_mem, 
+					      ARKSpilsPrecSetupFn pset,
+					      ARKSpilsPrecSolveFn psolve);
+SUNDIALS_EXPORT int ARKSpilsSetMassPreconditioner(void *arkode_mem, 
+						  ARKSpilsMassPrecSetupFn pset,
+						  ARKSpilsMassPrecSolveFn psolve);
+SUNDIALS_EXPORT int ARKSpilsSetJacTimesVecFn(void *arkode_mem, 
+					     ARKSpilsJacTimesVecFn jtv);
+SUNDIALS_EXPORT int ARKSpilsSetMassTimesVecFn(void *arkode_mem, 
+					      ARKSpilsMassTimesVecFn mtv,
+					      void *mtimes_data);
+
+
+/*---------------------------------------------------------------
+ Optional outputs from the ARKSPILS linear solver:
+
+ ARKSpilsGetWorkSpace returns the real and integer workspace used
+                by the SPILS module.
+
+ ARKSpilsGetMassWorkSpace returns the real and integer workspace used
+                by the mass matrix SPILS module.
+
+ ARKSpilsGetNumPrecEvals returns the number of preconditioner
+                 evaluations, i.e. the number of calls made
+                 to PrecSetup with jok==FALSE.
+
+ ARKSpilsGetNumMassPrecEvals returns the number of mass matrix 
+                 preconditioner evaluations, i.e. the number of 
+                 calls made to MPrecSetup.
+
+ ARKSpilsGetNumPrecSolves returns the number of calls made to
+                 PrecSolve.
+
+ ARKSpilsGetNumMassPrecSolves returns the number of calls made to
+                 MPrecSolve.
+
+ ARKSpilsGetNumLinIters returns the number of linear iterations.
+
+ ARKSpilsGetNumMassIters returns the number of mass matrix solver
+                  iterations.
+
+ ARKSpilsGetNumConvFails returns the number of linear
+                 convergence failures.
+
+ ARKSpilsGetNumMassConvFails returns the number of mass matrix solver
+                 convergence failures.
+
+ ARKSpilsGetNumJtimesEvals returns the number of calls to jtimes.
+
+ ARKSpilsGetNumMtimesEvals returns the number of calls to mtimes.
+
+ ARKSpilsGetNumRhsEvals returns the number of calls to the user
+                 f routine due to finite difference Jacobian
+                 times vector evaluation.
+
+ ARKSpilsGetLastFlag returns the last error flag set by any of
+                 the ARKSPILS interface functions.
+
+ ARKSpilsGetLastMassFlag returns the last error flag set by any of
+                 the ARKSPILS interface functions on the mass 
+		 matrix solve.
+
+ The return value of ARKSpilsGet* is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_LMEM_NULL if the linear solver memory was NULL
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSpilsGetWorkSpace(void *arkode_mem, 
+					 long int *lenrwLS, 
+					 long int *leniwLS);
+SUNDIALS_EXPORT int ARKSpilsGetMassWorkSpace(void *arkode_mem, 
+					     long int *lenrwMLS, 
+					     long int *leniwMLS);
+SUNDIALS_EXPORT int ARKSpilsGetNumPrecEvals(void *arkode_mem, 
+					    long int *npevals);
+SUNDIALS_EXPORT int ARKSpilsGetNumMassPrecEvals(void *arkode_mem, 
+						long int *nmpevals);
+SUNDIALS_EXPORT int ARKSpilsGetNumPrecSolves(void *arkode_mem, 
+					     long int *npsolves);
+SUNDIALS_EXPORT int ARKSpilsGetNumMassPrecSolves(void *arkode_mem, 
+						 long int *nmpsolves);
+SUNDIALS_EXPORT int ARKSpilsGetNumLinIters(void *arkode_mem, 
+					   long int *nliters);
+SUNDIALS_EXPORT int ARKSpilsGetNumMassIters(void *arkode_mem, 
+					    long int *nmiters);
+SUNDIALS_EXPORT int ARKSpilsGetNumConvFails(void *arkode_mem, 
+					    long int *nlcfails);
+SUNDIALS_EXPORT int ARKSpilsGetNumMassConvFails(void *arkode_mem, 
+						long int *nmcfails);
+SUNDIALS_EXPORT int ARKSpilsGetNumJtimesEvals(void *arkode_mem, 
+					      long int *njvevals);
+SUNDIALS_EXPORT int ARKSpilsGetNumMtimesEvals(void *arkode_mem, 
+					      long int *nmvevals);
+SUNDIALS_EXPORT int ARKSpilsGetNumRhsEvals(void *arkode_mem, 
+					   long int *nfevalsLS); 
+SUNDIALS_EXPORT int ARKSpilsGetLastFlag(void *arkode_mem, 
+					long int *flag);
+SUNDIALS_EXPORT int ARKSpilsGetLastMassFlag(void *arkode_mem, 
+					    long int *flag);
+
+
+/*---------------------------------------------------------------
+ The following function returns the name of the constant 
+ associated with a ARKSPILS return flag
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT char *ARKSpilsGetReturnFlagName(long int flag);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_sptfqmr.h b/include/arkode/arkode_sptfqmr.h
new file mode 100644
index 0000000..946cebe
--- /dev/null
+++ b/include/arkode/arkode_sptfqmr.h
@@ -0,0 +1,104 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for the ARKODE scaled preconditioned 
+ * TFQMR linear solver, ARKSPTFQMR.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKSPTFQMR_H
+#define _ARKSPTFQMR_H
+
+#include <arkode/arkode.h>
+#include <arkode/arkode_spils.h>
+#include <sundials/sundials_sptfqmr.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ ARKSptfqmr:
+
+ A call to the ARKSptfqmr function links the main ARKODE integrator
+ with the ARKSPTFQMR linear solver.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined
+           in iterative.h. These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPTFQMR solver. Pass 0 to
+           use the default value ARKSPILS_MAXL=5.
+
+ The return value of ARKSptfqmr is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSptfqmr(void *arkode_mem, int pretype, int maxl);
+
+
+/*---------------------------------------------------------------
+ ARKMassSptfqmr:
+
+ A call to the ARKMassSptfqmr function links the mass matrix solve
+ with the ARKSPTFQMR linear solver module.
+
+ arkode_mem is the pointer to the integrator memory returned by
+           ARKodeCreate.
+
+ pretype   is the type of user preconditioning to be done.
+           This must be one of the four enumeration constants
+           PREC_NONE, PREC_LEFT, PREC_RIGHT, or PREC_BOTH defined
+           in iterative.h. These correspond to no preconditioning,
+           left preconditioning only, right preconditioning
+           only, and both left and right preconditioning,
+           respectively.
+
+ maxl      is the maximum Krylov dimension. This is an
+           optional input to the ARKSPTFQMR solver. Pass 0 to
+           use the default value ARKSPILS_MAXL=5.
+
+ mtimes    is the user-supplied mass-matrix-vector product 
+           routine.
+
+ The return value of ARKMassSptfqmr is one of:
+    ARKSPILS_SUCCESS   if successful
+    ARKSPILS_MEM_NULL  if the arkode memory was NULL
+    ARKSPILS_MEM_FAIL  if there was a memory allocation failure
+    ARKSPILS_ILL_INPUT if a required vector operation is missing
+ The above constants are defined in arkode_spils.h
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassSptfqmr(void *arkode_mem, int pretype, int maxl, 
+				   ARKSpilsMassTimesVecFn mtimes,
+				   void *mtimes_data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/arkode/arkode_superlumt.h b/include/arkode/arkode_superlumt.h
new file mode 100644
index 0000000..5d980ce
--- /dev/null
+++ b/include/arkode/arkode_superlumt.h
@@ -0,0 +1,138 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Header file for the ARKSUPERLUMT linear solver module.
+ *---------------------------------------------------------------*/
+
+#ifndef _ARKSUPERLUMT_H
+#define _ARKSUPERLUMT_H
+
+#include "arkode/arkode_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ Function: ARKSuperLUMT
+-----------------------------------------------------------------
+ A call to the ARKSuperLUMT function links the main integrator
+ with the ARKSUPERLUMT linear solver module.
+
+ arkode_mem is the pointer to integrator memory returned by
+            ARKodeCreate.
+
+ num_threads is the number of hardware threads to use
+
+ n is the number of rows in the linear system
+
+ nnz is the maximum number of nonzeros in the sparse matrix
+     A = M + gamma*J
+
+ The return value of ARKSuperLUMT is one of:
+     ARKSLS_SUCCESS   if successful
+     ARKSLS_MEM_NULL  if the ARKode memory was NULL
+     ARKSLS_MEM_FAIL  if there was a memory allocation failure
+     ARKSLS_ILL_INPUT if a required vector operation is missing
+
+ NOTE: The ARKSUPERLUMT linear solver assumes a serial 
+       implementation of the NVECTOR package. Therefore, 
+       ARKSuperLUMT will first test for a compatible N_Vector
+       internal representation by checking that the function
+       N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSuperLUMT(void *arkode_mem, 
+				 int num_threads,
+				 int n, int nnz); 
+
+
+/*---------------------------------------------------------------
+ Function: ARKMassSuperLUMT
+-----------------------------------------------------------------
+ A call to the ARKMassSuperLUMT function links the mass matrix
+ solve with the ARKSUPERLUMT linear solver module.
+
+ arkode_mem is the pointer to integrator memory returned by
+            ARKodeCreate.
+
+ num_threads is the number of hardware threads to use
+
+ n is the number of rows in the sparse mass matrix
+
+ nnz is the maximum number of nonzeros in the sparse mass matrix
+
+ smass is the user-supplied sparse mass matrix setup function.
+
+ The return value of ARKMassSuperLUMT is one of:
+     ARKSLS_SUCCESS   if successful
+     ARKSLS_MEM_NULL  if the ARKode memory was NULL
+     ARKSLS_MEM_FAIL  if there was a memory allocation failure
+     ARKSLS_ILL_INPUT if a required vector operation is missing
+
+ NOTE: The ARKSUPERLUMT linear solver assumes a serial 
+       implementation of the NVECTOR package. Therefore, 
+       ARKMassSuperLUMT will first test for a compatible 
+       N_Vector internal representation by checking that the 
+       function N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassSuperLUMT(void *arkode_mem, 
+				     int num_threads,
+				     int n, int nnz,
+				     ARKSlsSparseMassFn smass); 
+
+
+/*================================================================
+ Optional Input Specification Functions
+=================================================================*/
+
+/*---------------------------------------------------------------
+ Function: ARKSuperLUMTSetOrdering 
+-----------------------------------------------------------------
+ Sets the ordering used by ARKSuperLUMT for reducing fill in the 
+ system matrix solve.  Options for ordering_choice are:
+     0 for natural ordering
+     1 for minimal degree ordering on A'*A
+     2 for minimal degree ordering on A'+A
+     3 for AMD ordering for unsymmetric matrices
+ The default used in ARKODE is 3 for COLAMD.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKSuperLUMTSetOrdering(void *ark_mem, 
+					    int ordering_choice); 
+
+
+/*---------------------------------------------------------------
+ Function: ARKMassSuperLUMTSetOrdering 
+-----------------------------------------------------------------
+ Sets the ordering used by ARKMassSuperLUMT for reducing fill in 
+ the mass matrix solve.  Options for ordering_choice are:
+     0 for natural ordering
+     1 for minimal degree ordering on A'*A
+     2 for minimal degree ordering on A'+A
+     3 for AMD ordering for unsymmetric matrices
+ The default used in ARKODE is 3 for COLAMD.
+---------------------------------------------------------------*/
+SUNDIALS_EXPORT int ARKMassSuperLUMTSetOrdering(void *ark_mem, 
+						int ordering_choice); 
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/cvode/cvode.h b/include/cvode/cvode.h
index e783256..13bac37 100644
--- a/include/cvode/cvode.h
+++ b/include/cvode/cvode.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban
  *                and Dan Shumaker @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the interface file for the main CVODE integrator.
  * -----------------------------------------------------------------
@@ -28,14 +33,13 @@
 #ifndef _CVODE_H
 #define _CVODE_H
 
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <stdio.h>
-
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  *              C V O D E     C O N S T A N T S
diff --git a/include/cvode/cvode_band.h b/include/cvode/cvode_band.h
index 7da3be9..c80ae87 100644
--- a/include/cvode/cvode_band.h
+++ b/include/cvode/cvode_band.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODE band linear solver, CVBAND.
  * -----------------------------------------------------------------
@@ -18,13 +23,13 @@
 #ifndef _CVBAND_H
 #define _CVBAND_H
 
+#include <cvode/cvode_direct.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_direct.h>
-#include <sundials/sundials_band.h>
- 
 /*
  * -----------------------------------------------------------------
  * Function : CVBand
diff --git a/include/cvode/cvode_bandpre.h b/include/cvode/cvode_bandpre.h
index 0e15244..771a1d5 100644
--- a/include/cvode/cvode_bandpre.h
+++ b/include/cvode/cvode_bandpre.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVBANDPRE module, which
  * provides a banded difference quotient Jacobian-based
@@ -32,7 +37,7 @@
  *
  * Usage:
  *   The following is a summary of the usage of this module.
- *   Details of the calls to CVodeCreate, CVodeMalloc, CVSp*,
+ *   Details of the calls to CVodeCreate, CVodeInit, CVSp*,
  *   and CVode are available in the User Guide.
  *   To use these routines, the sequence of calls in the user
  *   main program should be as follows:
@@ -43,7 +48,7 @@
  *   Set y0
  *   ...
  *   cvode_mem = CVodeCreate(...);
- *   ier = CVodeMalloc(...);
+ *   ier = CVodeInit(...);
  *   ...
  *   flag = CVSptfqmr(cvode_mem, pretype, maxl);
  *     -or-
@@ -71,12 +76,12 @@
 #ifndef _CVBANDPRE_H
 #define _CVBANDPRE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 
 /*
  * -----------------------------------------------------------------
diff --git a/include/cvode/cvode_bbdpre.h b/include/cvode/cvode_bbdpre.h
index d350c87..15535b0 100644
--- a/include/cvode/cvode_bbdpre.h
+++ b/include/cvode/cvode_bbdpre.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Michael Wittman, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVBBDPRE module, for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -40,7 +45,7 @@
  *   Set y0
  *   ...
  *   cvode_mem = CVodeCreate(...);
- *   ier = CVodeMalloc(...);
+ *   ier = CVodeInit(...);
  *   ...
  *   flag = CVSpgmr(cvode_mem, pretype, maxl);
  *      -or-
@@ -102,12 +107,12 @@
 #ifndef _CVBBDPRE_H
 #define _CVBBDPRE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /*
  * -----------------------------------------------------------------
  * Type : CVLocalFn
diff --git a/include/cvode/cvode_dense.h b/include/cvode/cvode_dense.h
index 0a59ec9..d9636f5 100644
--- a/include/cvode/cvode_dense.h
+++ b/include/cvode/cvode_dense.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODE dense linear solver, CVDENSE.
  * -----------------------------------------------------------------
@@ -18,13 +23,13 @@
 #ifndef _CVDENSE_H
 #define _CVDENSE_H
 
+#include <cvode/cvode_direct.h>
+#include <sundials/sundials_dense.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_direct.h>
-#include <sundials/sundials_dense.h>
-
 /*
  * -----------------------------------------------------------------
  * Function: CVDense
diff --git a/include/cvode/cvode_diag.h b/include/cvode/cvode_diag.h
index 1b4c93d..e3d1ba9 100644
--- a/include/cvode/cvode_diag.h
+++ b/include/cvode/cvode_diag.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODE diagonal linear solver, CVDIAG.
  * -----------------------------------------------------------------
@@ -18,12 +23,12 @@
 #ifndef _CVDIAG_H
 #define _CVDIAG_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : CVDiag
diff --git a/include/cvode/cvode_direct.h b/include/cvode/cvode_direct.h
index 224e5ce..79e96e4 100644
--- a/include/cvode/cvode_direct.h
+++ b/include/cvode/cvode_direct.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common header file for the direct linear solvers in CVODE.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _CVDLS_H
 #define _CVDLS_H
 
+#include <sundials/sundials_direct.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_direct.h>
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  *              C V D I R E C T     C O N S T A N T S
diff --git a/include/cvode/cvode_klu.h b/include/cvode/cvode_klu.h
new file mode 100644
index 0000000..f0259d5
--- /dev/null
+++ b/include/cvode/cvode_klu.h
@@ -0,0 +1,111 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the CVKLU linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVKLU_H
+#define _CVKLU_H
+
+#include "cvode/cvode_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVKLU
+ * -----------------------------------------------------------------
+ * A call to the CVKLU function links the main integrator      
+ * with the CVKLU linear solver module.                        
+ *                                                                
+ * cv_mem is the pointer to integrator memory returned by        
+ *     CVCreate.             
+ *
+ *                                                                
+ * CVKLU returns:                                              
+ *     CVSLU_SUCCESS   = 0  if successful                              
+ *     CVSLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     CVSLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The KLU linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, CVKLU will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLU(void *cv_mem, int n, int nnz, int sparsetype); 
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to CVKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_MEM_NULL = -1,
+ * CVSLS_LMEM_NULL = -2, CVSLS_ILL_INPUT = -3, or CVSLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLUReInit(void *cv_mem_v, int n, int nnz, 
+				  int reinit_type);
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in CVODE is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLUSetOrdering(void *cv_mem, int ordering_choice); 
+
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/cvode/cvode_lapack.h b/include/cvode/cvode_lapack.h
index e0e8d74..96495a5 100644
--- a/include/cvode/cvode_lapack.h
+++ b/include/cvode/cvode_lapack.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2006/11/29 00:05:06 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Header file for the CVODE dense linear solver CVLAPACK.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _CVLAPACK_H
 #define _CVLAPACK_H
 
+#include <cvode/cvode_direct.h>
+#include <sundials/sundials_lapack.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_direct.h>
-#include <sundials/sundials_lapack.h>
-
 /*
  * =================================================================
  *            E X P O R T E D    F U N C T I O N S 
diff --git a/include/cvode/cvode_sparse.h b/include/cvode/cvode_sparse.h
new file mode 100644
index 0000000..a4a1511
--- /dev/null
+++ b/include/cvode/cvode_sparse.h
@@ -0,0 +1,182 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the Sparse linear solver module in IDA.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSPARSE_H
+#define _CVSPARSE_H
+
+#include <sundials/sundials_sparse.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * C V S P A R S E    C O N S T A N T S
+ * =================================================================
+ */
+
+/* 
+ * -----------------------------------------------------------------
+ * CVSLS return values 
+ * -----------------------------------------------------------------
+ */
+
+#define CVSLS_SUCCESS           0
+#define CVSLS_MEM_NULL         -1
+#define CVSLS_LMEM_NULL        -2
+#define CVSLS_ILL_INPUT        -3
+#define CVSLS_MEM_FAIL         -4
+#define CVSLS_JAC_NOSET        -5
+#define CVSLS_PACKAGE_FAIL     -6
+
+/* Additional last_flag values */
+
+#define CVSLS_JACFUNC_UNRECVR  -7
+#define CVSLS_JACFUNC_RECVR    -8
+
+/* Return values for the adjoint module */
+#define CVSLS_NO_ADJ           -101
+#define CVSLS_LMEMB_NULL       -102
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : CVSlsSparseJacFn
+ * -----------------------------------------------------------------
+ *
+ * A sparse Jacobian approximation function jac must be of type 
+ * CVSlsSparseJacFn.
+ * Its parameters are:                     
+ *                                                                
+ * t   is the current value of the independent variable t.        
+ *                                                                
+ * y   is the current value of the dependent variable vector,     
+ *     namely the predicted value of y(t).                     
+ *                                                                
+ * fy  is the vector f(t,y).
+ *     namely the predicted value of y'(t).                    
+ *                                                                
+ * JacMat is the compressed sparse column matrix (of type SlsMat)
+ *     to be loaded by an CVSlsSparseJacFn routine with an approximation
+ *     to the system Jacobian matrix
+ *            J = J = (df_i/dy_j) at the point (t,y). 
+ *     Note that JacMat is NOT preset to zero!
+ *     Matrix data is for the nonzero entries of the Jacobian stored in
+ *     compressed column format.  Row indices of entries in 
+ *     column j are stored in J->rowvals[colptrs[j]] 
+ *     through J->rowvals[colptrs[j+i]-1]
+ *     and corresponding numerical values of the Jacobian are stored 
+ *     in the same entries of J->data.
+ * 
+ * J_data is a pointer to user Jacobian data - the same as the    
+ *     user_data parameter passed to CVodeSetFdata.                     
+ *                                                                
+ * tmp1, tmp2, tmp3 are pointers to memory allocated for          
+ *     N_Vectors which can be used by an CVSparseJacFn routine 
+ *     as temporary storage or work space.                     
+ *                                                                
+ * A CVSlsSparseJacFn should return                                
+ *     0 if successful,                                           
+ *     a positive int if a recoverable error occurred, or         
+ *     a negative int if a nonrecoverable error occurred.         
+ *
+ * -----------------------------------------------------------------
+ *
+  * NOTE: If the user's Jacobian routine needs other quantities,   
+ *     they are accessible as follows: hcur (the current stepsize)
+ *     and ewt (the error weight vector) are accessible through   
+ *     CVodeGetCurrentStep and CVodeGetErrWeights, respectively 
+ *     (see cvode.h). The unit roundoff is available as 
+ *     UNIT_ROUNDOFF defined in sundials_types.h.
+ *
+ * -----------------------------------------------------------------
+ */
+  
+  
+typedef int (*CVSlsSparseJacFn)(realtype t,
+		     N_Vector y, N_Vector fy, 
+		     SlsMat JacMat, void *user_data,
+		     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/*
+ * =================================================================
+ *            E X P O R T E D    F U N C T I O N S 
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Optional inputs to the CVSPARSE linear solver
+ * -----------------------------------------------------------------
+ * CVSlsSetSparseJacFn specifies the Jacobian approximation
+ * routine to be used for a sparse direct linear solver.
+ *
+ * The return value is one of:
+ *    CVSLS_SUCCESS   if successful
+ *    CVSLS_MEM_NULL  if the CVODE memory was NULL
+ *    CVSLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVSlsSetSparseJacFn(void *cvode_mem, CVSlsSparseJacFn jac);
+
+/*
+ * -----------------------------------------------------------------
+ * Optional outputs from the CVSLS linear solver
+ * -----------------------------------------------------------------
+ *
+ * CVSlsGetNumJacEvals returns the number of calls made to the
+ *                      Jacobian evaluation routine jac.
+ * CVSlsGetLastFlag    returns the last error flag set by any of
+ *                      the IDADLS interface functions.
+ *
+ * The return value of IDADlsGet* is one of:
+ *    CVSLS_SUCCESS   if successful
+ *    CVSLS_MEM_NULL  if the IDA memory was NULL
+ *    CVSLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVSlsGetNumJacEvals(void *ida_mem, long int *njevals);
+SUNDIALS_EXPORT int CVSlsGetLastFlag(void *ida_mem, long int *flag);
+
+/*
+ * -----------------------------------------------------------------
+ * The following function returns the name of the constant 
+ * associated with a CVSLS return flag
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT char *CVSlsGetReturnFlagName(long int flag);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/cvode/cvode_spbcgs.h b/include/cvode/cvode_spbcgs.h
index 278acf8..f6c1714 100644
--- a/include/cvode/cvode_spbcgs.h
+++ b/include/cvode/cvode_spbcgs.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:06 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODE scaled preconditioned 
  * Bi-CGSTAB linear solver, CVSPBCG.
@@ -18,13 +23,13 @@
 #ifndef _CVSPBCG_H
 #define _CVSPBCG_H
 
+#include <cvode/cvode_spils.h>
+#include <sundials/sundials_spbcgs.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_spils.h>
-#include <sundials/sundials_spbcgs.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : CVSpbcg
diff --git a/include/cvode/cvode_spgmr.h b/include/cvode/cvode_spgmr.h
index 2b8499c..10c05a1 100644
--- a/include/cvode/cvode_spgmr.h
+++ b/include/cvode/cvode_spgmr.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2006/11/29 00:05:06 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODE scaled preconditioned GMRES 
  * linear solver, CVSPGMR.
@@ -19,13 +24,13 @@
 #ifndef _CVSPGMR_H
 #define _CVSPGMR_H
 
+#include <cvode/cvode_spils.h>
+#include <sundials/sundials_spgmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_spils.h>
-#include <sundials/sundials_spgmr.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : CVSpgmr
diff --git a/include/cvode/cvode_spils.h b/include/cvode/cvode_spils.h
index 531bd0b..9207b5b 100644
--- a/include/cvode/cvode_spils.h
+++ b/include/cvode/cvode_spils.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2010/12/01 22:10:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common header file for the Scaled, Preconditioned
  * Iterative Linear Solvers in CVODE.
@@ -19,13 +24,13 @@
 #ifndef _CVSPILS_H
 #define _CVSPILS_H
 
+#include <sundials/sundials_iterative.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_iterative.h>
-#include <sundials/sundials_nvector.h>
-
 
 /*
  * -----------------------------------------------------------------
diff --git a/include/cvode/cvode_sptfqmr.h b/include/cvode/cvode_sptfqmr.h
index c19e67b..179d818 100644
--- a/include/cvode/cvode_sptfqmr.h
+++ b/include/cvode/cvode_sptfqmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2006/11/29 00:05:06 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODE scaled preconditioned TFQMR 
  * linear solver, CVSPTFQMR.
@@ -18,13 +23,13 @@
 #ifndef _CVSPTFQMR_H
 #define _CVSPTFQMR_H
 
+#include <cvode/cvode_spils.h>
+#include <sundials/sundials_sptfqmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_spils.h>
-#include <sundials/sundials_sptfqmr.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : CVSptfqmr
diff --git a/include/cvode/cvode_superlumt.h b/include/cvode/cvode_superlumt.h
new file mode 100644
index 0000000..1638876
--- /dev/null
+++ b/include/cvode/cvode_superlumt.h
@@ -0,0 +1,84 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4177 $
+ * $Date: 2014-07-23 11:56:06 -0700 (Wed, 23 Jul 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the IDASuperLUMT linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSUPERLUMT_H
+#define _CVSUPERLUMT_H
+
+#include "cvode/cvode_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVSuperLUMT
+ * -----------------------------------------------------------------
+ * A call to the CVSuperLUMT function links the main integrator      
+ * with the CVSuperLUMT linear solver module.                        
+ *                                                                
+ * cv_mem is the pointer to integrator memory returned by        
+ *     CVCreate.             
+ *
+ *                                                                
+ * CVSuperLUMT returns:                                              
+ *     CVSLU_SUCCESS   = 0  if successful                              
+ *     CVSLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     CVSLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The CVSuperLUMT linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, CVSuperLUMT will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVSuperLUMT(void *cv_mem, int num_threads,
+				  int n, int nnz); 
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVSuperLUMTSetOrdering sets the ordering used by CVSuperLUMT for 
+ * reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVSuperLUMTSetOrdering(void *cv_mem, 
+					     int ordering_choice); 
+
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/cvodes/cvodes.h b/include/cvodes/cvodes.h
index ad067bf..7c32757 100644
--- a/include/cvodes/cvodes.h
+++ b/include/cvodes/cvodes.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.23 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the interface file for the main CVODES integrator.
  * -----------------------------------------------------------------
@@ -88,14 +93,13 @@
 #ifndef _CVODES_H
 #define _CVODES_H
 
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <stdio.h>
-
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  *
diff --git a/include/cvodes/cvodes_band.h b/include/cvodes/cvodes_band.h
index 071f881..59f0bb4 100644
--- a/include/cvodes/cvodes_band.h
+++ b/include/cvodes/cvodes_band.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the band linear solver CSVBAND.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _CVSBAND_H
 #define _CVSBAND_H
 
+#include <cvodes/cvodes_direct.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_direct.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : CVBand
@@ -59,6 +64,7 @@ SUNDIALS_EXPORT int CVBand(void *cvode_mem, long int N, long int mupper, long in
  * -----------------------------------------------------------------
  * CVBandB links the main CVODE integrator with the CVSBAND
  * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/cvodes/cvodes_bandpre.h b/include/cvodes/cvodes_bandpre.h
index a612d30..bd2f196 100644
--- a/include/cvodes/cvodes_bandpre.h
+++ b/include/cvodes/cvodes_bandpre.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVSBANDPRE module, which
  * provides a banded difference quotient Jacobian-based
@@ -26,12 +31,12 @@
 #ifndef _CVSBANDPRE_H
 #define _CVSBANDPRE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /* 
  * =================================================================
  * PART I - forward problems
@@ -59,7 +64,7 @@ extern "C" {
  *
  * Usage:
  *   The following is a summary of the usage of this module.
- *   Details of the calls to CVodeCreate, CVodeMalloc, CVSp*,
+ *   Details of the calls to CVodeCreate, CVodeInit, CVSp*,
  *   and CVode are available in the User Guide.
  *   To use these routines, the sequence of calls in the user
  *   main program should be as follows:
@@ -70,7 +75,7 @@ extern "C" {
  *   Set y0
  *   ...
  *   cvode_mem = CVodeCreate(...);
- *   ier = CVodeMalloc(...);
+ *   ier = CVodeInit(...);
  *   ...
  *   flag = CVSptfqmr(cvode_mem, pretype, maxl);
  *     -or-
@@ -166,6 +171,7 @@ SUNDIALS_EXPORT int CVBandPrecGetNumRhsEvals(void *cvode_mem, long int *nfevalsB
  *
  * CVBandPrecInitB interfaces to the CVBANDPRE preconditioner
  * for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/cvodes/cvodes_bbdpre.h b/include/cvodes/cvodes_bbdpre.h
index 73d3a7e..bd711ed 100644
--- a/include/cvodes/cvodes_bbdpre.h
+++ b/include/cvodes/cvodes_bbdpre.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVBBDPRE module, for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -27,12 +32,12 @@
 #ifndef _CVSBBDPRE_H
 #define _CVSBBDPRE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /* 
  * =================================================================
  * PART I - forward problems
@@ -66,7 +71,7 @@ extern "C" {
  *   Set y0
  *   ...
  *   cvode_mem = CVodeCreate(...);
- *   ier = CVodeMalloc(...);
+ *   ier = CVodeInit(...);
  *   ...
  *   flag = CVSpgmr(cvode_mem, pretype, maxl);
  *      -or-
@@ -311,6 +316,7 @@ typedef int (*CVCommFnB)(long int NlocalB, realtype t,
  * -----------------------------------------------------------------
  * Interface functions for the CVBBDPRE preconditioner to be used on
  * the backward phase.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/cvodes/cvodes_dense.h b/include/cvodes/cvodes_dense.h
index d840f27..60a91e2 100644
--- a/include/cvodes/cvodes_dense.h
+++ b/include/cvodes/cvodes_dense.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the dense linear solver CVSDENSE.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _CVSDENSE_H
 #define _CVSDENSE_H
 
+#include <cvodes/cvodes_direct.h>
+#include <sundials/sundials_dense.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_direct.h>
-#include <sundials/sundials_dense.h>
-
 /*
  * -----------------------------------------------------------------
  * Function: CVDense
@@ -52,6 +57,7 @@ SUNDIALS_EXPORT int CVDense(void *cvode_mem, long int N);
  * -----------------------------------------------------------------
  * CVDenseB links the main CVODE integrator with the CVSDENSE
  * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/cvodes/cvodes_diag.h b/include/cvodes/cvodes_diag.h
index 55d52d1..2e67ea8 100644
--- a/include/cvodes/cvodes_diag.h
+++ b/include/cvodes/cvodes_diag.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the diagonal linear solver CVSDIAG.
  *
@@ -24,12 +29,12 @@
 #ifndef _CVSDIAG_H
 #define _CVSDIAG_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /*
  * -----------------------------------------------------------------
  * CVDIAG return values
@@ -127,6 +132,7 @@ SUNDIALS_EXPORT char *CVDiagGetReturnFlagName(long int flag);
  * -----------------------------------------------------------------
  * CVDiagB links the main CVODE integrator with the CVDIAG
  * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
   
diff --git a/include/cvodes/cvodes_direct.h b/include/cvodes/cvodes_direct.h
index 13aa1cf..ccd99a5 100644
--- a/include/cvodes/cvodes_direct.h
+++ b/include/cvodes/cvodes_direct.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common header file for the direct linear solvers in CVODES.
  *
@@ -24,13 +29,13 @@
 #ifndef _CVSDLS_H
 #define _CVSDLS_H
 
+#include <sundials/sundials_direct.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_direct.h>
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  * C V S D I R E C T     C O N S T A N T S
@@ -324,6 +329,22 @@ typedef int (*CVDlsDenseJacFnB)(long int nB, realtype t,
 
 /*
  * -----------------------------------------------------------------
+ * Type: CVDlsDenseJacFnBS
+ * -----------------------------------------------------------------
+ * A dense Jacobian approximation function jacBS for the adjoint
+ * (backward) problem, sensitivity-dependent case,  must have the
+ *  prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVDlsDenseJacFnBS)(long int nB, realtype t,
+				N_Vector y, N_Vector *yS,
+				N_Vector yB, N_Vector fyB,
+				DlsMat JB, void *user_dataB, 
+				N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+/*
+ * -----------------------------------------------------------------
  * Type : CVDlsBandJacFnB
  * -----------------------------------------------------------------
  * A band Jacobian approximation function jacB for the adjoint 
@@ -339,25 +360,52 @@ typedef int (*CVDlsBandJacFnB)(long int nB, long int mupperB, long int mlowerB,
 
 /*
  * -----------------------------------------------------------------
+ * Type : CVDlsBandJacFnBS
+ * -----------------------------------------------------------------
+ * A band Jacobian approximation function jacBS for the adjoint 
+ * (backward) problem, sensitivity-dependent case, must have the
+ * prototype given below.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVDlsBandJacFnBS)(long int nB, long int mupperB, long int mlowerB,
+			       realtype t, N_Vector y, N_Vector *yS,
+			       N_Vector yB, N_Vector fyB,
+			       DlsMat JB, void *user_dataB,
+			       N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+/*
+ * -----------------------------------------------------------------
  * EXPORTED FUNCTIONS 
  * -----------------------------------------------------------------
  */
 
 /*
  * -----------------------------------------------------------------
- * Functions: CVDlsSetJacFnB
+ * Functions: CVDlsSet*JacFnB and CVDlsSet*JacFnBS
  * -----------------------------------------------------------------
  * CVDlsSetDenseJacFnB and CVDlsSetBandJacFnB specify the dense and
- * band, respectively, Jacobian functions to be used by a
- * CVSDIRECT linear solver for the bacward integration phase.
+ * band Jacobian functions, respectively, to be used by a
+ * CVSDIRECT linear solver for the backward integration phase, when
+ * the backward problem does not depend on forward sensitivities.
+ * CVDlsSetDenseJacFnBS and CVDlsSetBandJacFnBS specify the Jacobian
+ * functions when the backward problem does depend on sensitivities.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
 
 SUNDIALS_EXPORT int CVDlsSetDenseJacFnB(void *cvode_mem, int which,
                                         CVDlsDenseJacFnB jacB);
+
+SUNDIALS_EXPORT int CVDlsSetDenseJacFnBS(void *cvode_mem, int which,
+                                         CVDlsDenseJacFnBS jacBS);
+
 SUNDIALS_EXPORT int CVDlsSetBandJacFnB(void *cvode_mem, int which,
                                        CVDlsBandJacFnB jacB);
 
+SUNDIALS_EXPORT int CVDlsSetBandJacFnBS(void *cvode_mem, int which,
+                                        CVDlsBandJacFnBS jacBS);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/cvodes/cvodes_klu.h b/include/cvodes/cvodes_klu.h
new file mode 100644
index 0000000..5aecedc
--- /dev/null
+++ b/include/cvodes/cvodes_klu.h
@@ -0,0 +1,156 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the CVKLU linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSKLU_H
+#define _CVSKLU_H
+
+#include "cvodes/cvodes_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVKLU
+ * -----------------------------------------------------------------
+ * A call to the CVKLU function links the main integrator      
+ * with the CVKLU linear solver module.                        
+ *                                                                
+ * cv_mem is the pointer to integrator memory returned by        
+ *     CVCreate.             
+ *
+ *                                                                
+ * CVKLU returns:                                              
+ *     CVSLU_SUCCESS   = 0  if successful                              
+ *     CVSLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     CVSLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The KLU linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, CVKLU will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLU(void *cv_mem, int n, int nnz, int sparsetype); 
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to CVKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_MEM_NULL = -1,
+ * CVSLS_LMEM_NULL = -2, CVSLS_ILL_INPUT = -3, or CVSLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLUReInit(void *cv_mem_v, int n, int nnz, 
+				  int reinit_type);
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in CVODE is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLUSetOrdering(void *cv_mem, int ordering_choice); 
+
+/* 
+ * ================================================================
+ *
+ *                   PART II - backward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function: CVKLUB
+ * -----------------------------------------------------------------
+ * CVKLUB is a wrapper around CVKLU. It attaches the CVKLU linear
+ * solver to the backward problem memory block.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLUB(void *cvode_mem, int which, int n, int nnz, int sparsetype);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: CVKLUReInitB
+ * -----------------------------------------------------------------
+ * CVKLUReInitB is a wrapper around CVKLUReInit. 
+ * CVKLUReInitB pulls off the memory block associated with the
+ * which parameter and reinitializes the KLU solver associated with that block.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLUReInitB(void *cvode_mem, int which, int n, int nnz, int reinit_type);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: CVKLUSetOrderingB
+ * -----------------------------------------------------------------
+ * CVKLUSetOrderingB is a wrapper around CVKLUSetOrdering. 
+ * CVKLUSetOrderingB pulls off the memory block associated with the
+ * which parameter and sets the ordering for the solver associated with that block.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVKLUSetOrderingB(void *cv_mem, int which, int ordering_choice); 
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/cvodes/cvodes_lapack.h b/include/cvodes/cvodes_lapack.h
index 20eedf8..49304e7 100644
--- a/include/cvodes/cvodes_lapack.h
+++ b/include/cvodes/cvodes_lapack.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2008/04/18 19:42:37 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Header file for the CVODES dense linear solver CVSLAPACK.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _CVSLAPACK_H
 #define _CVSLAPACK_H
 
+#include <cvodes/cvodes_direct.h>
+#include <sundials/sundials_lapack.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_direct.h>
-#include <sundials/sundials_lapack.h>
-
 /*
  * -----------------------------------------------------------------
  * Function: CVLapackDense
@@ -79,6 +84,7 @@ SUNDIALS_EXPORT int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
  * -----------------------------------------------------------------
  * CVLapackDenseB links the main CVODE integrator with the dense
  * CVSLAPACK linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
 
@@ -90,6 +96,7 @@ SUNDIALS_EXPORT int CVLapackDenseB(void *cvode_mem, int which, int nB);
  * -----------------------------------------------------------------
  * CVLapackBandB links the main CVODE integrator with the band
  * CVSLAPACK linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/cvodes/cvodes_sparse.h b/include/cvodes/cvodes_sparse.h
new file mode 100644
index 0000000..432840c
--- /dev/null
+++ b/include/cvodes/cvodes_sparse.h
@@ -0,0 +1,255 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer: Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the Sparse linear solver module in CVODES.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSSPARSE_H
+#define _CVSSPARSE_H
+
+#include <sundials/sundials_sparse.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * C V S S P A R S E     C O N S T A N T S
+ * =================================================================
+ */
+
+/* 
+ * -----------------------------------------------------------------
+ * CVSSPARSE return values 
+ * -----------------------------------------------------------------
+ */
+
+#define CVSLS_SUCCESS           0
+#define CVSLS_MEM_NULL         -1
+#define CVSLS_LMEM_NULL        -2
+#define CVSLS_ILL_INPUT        -3
+#define CVSLS_MEM_FAIL         -4
+#define CVSLS_JAC_NOSET        -5
+#define CVSLS_PACKAGE_FAIL     -6
+
+/* Additional last_flag values */
+
+#define CVSLS_JACFUNC_UNRECVR  -7
+#define CVSLS_JACFUNC_RECVR    -8
+
+/* Return values for the adjoint module */
+
+#define CVSLS_NO_ADJ           -101
+#define CVSLS_LMEMB_NULL       -102
+
+/*
+ * =================================================================
+ * PART I:  F O R W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : CVSlsSparseJacFn
+ * -----------------------------------------------------------------
+ *
+ * A sparse Jacobian approximation function jac must be of type 
+ * CVSlsSparseJacFn.
+ * Its parameters are:                     
+ *                                                                
+ * t   is the current value of the independent variable t.        
+ *                                                                
+ * y   is the current value of the dependent variable vector,     
+ *     namely the predicted value of y(t).                     
+ *                                                                
+ * fy  is the vector f(t,y).
+ *     namely the predicted value of y'(t).                    
+ *                                                                
+ * JacMat is the compressed sparse column matrix (of type SlsMat)
+ *     to be loaded by an CVSlsSparseJacFn routine with an approximation
+ *     to the system Jacobian matrix
+ *            J = J = (df_i/dy_j) at the point (t,y). 
+ *     Note that JacMat is NOT preset to zero!
+ *     Matrix data is for the nonzero entries of the Jacobian stored in
+ *     compressed column format.  Row indices of entries in 
+ *     column j are stored in J->rowvals[colptrs[j]] 
+ *     through J->rowvals[colptrs[j+i]-1]
+ *     and corresponding numerical values of the Jacobian are stored 
+ *     in the same entries of J->data.
+ * 
+ * J_data is a pointer to user Jacobian data - the same as the    
+ *     user_data parameter passed to CVodeSetFdata.                     
+ *                                                                
+ * tmp1, tmp2, tmp3 are pointers to memory allocated for          
+ *     N_Vectors which can be used by an CVSparseJacFn routine 
+ *     as temporary storage or work space.                     
+ *                                                                
+ * A CVSlsSparseJacFn should return                                
+ *     0 if successful,                                           
+ *     a positive int if a recoverable error occurred, or         
+ *     a negative int if a nonrecoverable error occurred.         
+ *
+ * -----------------------------------------------------------------
+ *
+  * NOTE: If the user's Jacobian routine needs other quantities,   
+ *     they are accessible as follows: hcur (the current stepsize)
+ *     and ewt (the error weight vector) are accessible through   
+ *     CVodeGetCurrentStep and CVodeGetErrWeights, respectively 
+ *     (see cvode.h). The unit roundoff is available as 
+ *     UNIT_ROUNDOFF defined in sundials_types.h.
+ *
+ * -----------------------------------------------------------------
+ */
+  
+  
+typedef int (*CVSlsSparseJacFn)(realtype t,
+		     N_Vector y, N_Vector fy, 
+		     SlsMat JacMat, void *user_data,
+		     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+
+/*
+ * =================================================================
+ *            E X P O R T E D    F U N C T I O N S 
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Optional inputs to the CVSPARSE linear solver
+ * -----------------------------------------------------------------
+ * CVSlsSetSparseJacFn specifies the Jacobian approximation
+ * routine to be used for a sparse direct linear solver.
+ *
+ * The return value is one of:
+ *    CVSLS_SUCCESS   if successful
+ *    CVSLS_MEM_NULL  if the CVODE memory was NULL
+ *    CVSLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVSlsSetSparseJacFn(void *cvode_mem, CVSlsSparseJacFn jac);
+
+/*
+ * -----------------------------------------------------------------
+ * Optional outputs from the CVSLS linear solver
+ * -----------------------------------------------------------------
+ *
+ * CVSlsGetNumJacEvals returns the number of calls made to the
+ *                      Jacobian evaluation routine jac.
+ * CVSlsGetLastFlag    returns the last error flag set by any of
+ *                      the CVSLS interface functions.
+ *
+ * The return value of CVSlsGet* is one of:
+ *    CVSLS_SUCCESS   if successful
+ *    CVSLS_MEM_NULL  if the IDA memory was NULL
+ *    CVSLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVSlsGetNumJacEvals(void *cvode_mem, long int *njevals);
+SUNDIALS_EXPORT int CVSlsGetLastFlag(void *cvode_mem, long int *flag);
+
+/*
+ * -----------------------------------------------------------------
+ * The following function returns the name of the constant 
+ * associated with a CVSLS return flag
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT char *CVSlsGetReturnFlagName(long int flag);
+
+/*
+ * =================================================================
+ * PART II:  B A C K W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Type: CVSlsSparseJacFnB
+ * -----------------------------------------------------------------
+ * A sparse Jacobian approximation function jacB for the adjoint
+ * (backward) problem must have the prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVSlsSparseJacFnB)(realtype t, N_Vector y, 
+				 N_Vector yB, N_Vector fyB,
+				 SlsMat JB, void *user_dataB, 
+				 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+/*
+ * -----------------------------------------------------------------
+ * Type: CVSlsSparseJacFnBS
+ * -----------------------------------------------------------------
+ * A sparse Jacobian approximation function jacBS for the adjoint
+ * (backward) problem, sensitivity-dependent case,  must have the
+ *  prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVSlsSparseJacFnBS)(realtype t,
+				  N_Vector y, N_Vector *yS,
+				  N_Vector yB, N_Vector fyB,
+				  SlsMat JB, void *user_dataB, 
+				  N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+/*
+ * -----------------------------------------------------------------
+ * EXPORTED FUNCTIONS 
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: CVSlsSetSparseJacFnB and CVSlsSetSparseJacFnBS
+ * -----------------------------------------------------------------
+ * CVSlsSetSparseJacFnB specifies the sparse Jacobian functions to 
+ * be used by a CVSPARSE linear solver for the backward integration phase
+ * when the backward problem does not depend on forward sensitivities.
+ * CVSlsSetSparseJacFnBS specifies the Jacobian
+ * functions when the backward problem does depend on sensitivities.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int CVSlsSetSparseJacFnB(void *cv_mem, int which, 
+					 CVSlsSparseJacFnB jacB);
+SUNDIALS_EXPORT int CVSlsSetSparseJacFnBS(void *cv_mem, int which, 
+					  CVSlsSparseJacFnBS jacBS);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/cvodes/cvodes_spbcgs.h b/include/cvodes/cvodes_spbcgs.h
index acc56c9..da87907 100644
--- a/include/cvodes/cvodes_spbcgs.h
+++ b/include/cvodes/cvodes_spbcgs.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2007/03/22 18:05:50 $
+ * $Revision: 4490 $
+ * $Date: 2015-04-30 16:55:37 -0700 (Thu, 30 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODES scaled preconditioned 
  * Bi-CGSTAB linear solver, CVSPBCG.
@@ -24,13 +29,13 @@
 #ifndef _CVSSPBCG_H
 #define _CVSSPBCG_H
 
+#include <cvodes/cvodes_spils.h>
+#include <sundials/sundials_spbcgs.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_spils.h>
-#include <sundials/sundials_spbcgs.h>
-
 /* 
  * -----------------------------------------------------------------
  * PART I - forward problems
@@ -76,6 +81,16 @@ SUNDIALS_EXPORT int CVSpbcg(void *cvode_mem, int pretype, int maxl);
  * -----------------------------------------------------------------
  */
 
+/*
+ * -----------------------------------------------------------------
+ * Function: CVSpbcgB
+ * -----------------------------------------------------------------
+ * CVSpbcgB links the main CVODES integrator with the CVSpbcg
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+
 SUNDIALS_EXPORT int CVSpbcgB(void *cvode_mem, int which,
                              int pretypeB, int maxlB);
 
diff --git a/include/cvodes/cvodes_spgmr.h b/include/cvodes/cvodes_spgmr.h
index 73f2420..ff79405 100644
--- a/include/cvodes/cvodes_spgmr.h
+++ b/include/cvodes/cvodes_spgmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2007/03/22 18:05:50 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODES scaled preconditioned 
  * GMRES linear solver, CVSPGMR.
@@ -24,13 +29,13 @@
 #ifndef _CVSSPGMR_H
 #define _CVSSPGMR_H
 
+#include <cvodes/cvodes_spils.h>
+#include <sundials/sundials_spgmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_spils.h>
-#include <sundials/sundials_spgmr.h>
-
 /* 
  * -----------------------------------------------------------------
  * PART I - forward problems
@@ -76,6 +81,16 @@ SUNDIALS_EXPORT int CVSpgmr(void *cvode_mem, int pretype, int maxl);
  * -----------------------------------------------------------------
  */
 
+/*
+ * -----------------------------------------------------------------
+ * Function: CVSpgmrB
+ * -----------------------------------------------------------------
+ * CVSpgmrB links the main CVODES integrator with the CVSpgmr
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+
 SUNDIALS_EXPORT int CVSpgmrB(void *cvode_mem, int which,
                              int pretypeB, int maxlB);
   
diff --git a/include/cvodes/cvodes_spils.h b/include/cvodes/cvodes_spils.h
index aa63072..252d911 100644
--- a/include/cvodes/cvodes_spils.h
+++ b/include/cvodes/cvodes_spils.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2010/12/01 22:13:10 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common header file for the Scaled, Preconditioned
  * Iterative Linear Solvers in CVODES.
@@ -25,13 +30,13 @@
 #ifndef _CVSSPILS_H
 #define _CVSSPILS_H
 
+#include <sundials/sundials_iterative.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_iterative.h>
-#include <sundials/sundials_nvector.h>
-
 /*
  * -----------------------------------------------------------------
  * CVSPILS return values
@@ -390,12 +395,30 @@ SUNDIALS_EXPORT char *CVSpilsGetReturnFlagName(long int flag);
  */
 
 typedef int (*CVSpilsPrecSetupFnB)(realtype t, N_Vector y,
-				   N_Vector yB, N_Vector fyB,
-				   booleantype jokB,
-				   booleantype *jcurPtrB, realtype gammaB,
-				   void *user_dataB,
-				   N_Vector tmp1B, N_Vector tmp2B,
-				   N_Vector tmp3B);
+                                   N_Vector yB, N_Vector fyB,
+                                   booleantype jokB,
+                                   booleantype *jcurPtrB, realtype gammaB,
+                                   void *user_dataB,
+                                   N_Vector tmp1B, N_Vector tmp2B,
+                                   N_Vector tmp3B);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVSpilsPrecSetupFnBS
+ * -----------------------------------------------------------------
+ * A function PrecSetupBS for the adjoint (backward) problem must have 
+ * the prototype given below.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVSpilsPrecSetupFnBS)(realtype t, N_Vector y, N_Vector *yS,
+                                    N_Vector yB, N_Vector fyB,
+                                    booleantype jokB,
+                                    booleantype *jcurPtrB, realtype gammaB,
+                                    void *user_dataB,
+                                    N_Vector tmp1B, N_Vector tmp2B,
+                                    N_Vector tmp3B);
 
 
 /*
@@ -408,10 +431,25 @@ typedef int (*CVSpilsPrecSetupFnB)(realtype t, N_Vector y,
  */
 
 typedef int (*CVSpilsPrecSolveFnB)(realtype t, N_Vector y,
-				   N_Vector yB, N_Vector fyB,
-				   N_Vector rB, N_Vector zB,
-				   realtype gammaB, realtype deltaB,
-				   int lrB, void *user_dataB, N_Vector tmpB);
+                                   N_Vector yB, N_Vector fyB,
+                                   N_Vector rB, N_Vector zB,
+                                   realtype gammaB, realtype deltaB,
+                                   int lrB, void *user_dataB, N_Vector tmpB);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVSpilsPrecSolveFnBS
+ * -----------------------------------------------------------------
+ * A function PrecSolveBS for the adjoint (backward) problem  must 
+ * have the prototype given below.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVSpilsPrecSolveFnBS)(realtype t, N_Vector y, N_Vector *yS,
+                                    N_Vector yB, N_Vector fyB,
+                                    N_Vector rB, N_Vector zB,
+                                    realtype gammaB, realtype deltaB,
+                                    int lrB, void *user_dataB, N_Vector tmpB);
 
 /*
  * -----------------------------------------------------------------
@@ -423,8 +461,22 @@ typedef int (*CVSpilsPrecSolveFnB)(realtype t, N_Vector y,
  */
 
 typedef int (*CVSpilsJacTimesVecFnB)(N_Vector vB, N_Vector JvB, realtype t,
-				     N_Vector y, N_Vector yB, N_Vector fyB,
-				     void *jac_dataB, N_Vector tmpB);
+                                     N_Vector y, N_Vector yB, N_Vector fyB,
+                                     void *jac_dataB, N_Vector tmpB);
+
+/*
+ * -----------------------------------------------------------------
+ * Type : CVSpilsJacTimesVecFnBS
+ * -----------------------------------------------------------------
+ * A function jtimesBS for the adjoint (backward) problem must have 
+ * the prototype given below.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*CVSpilsJacTimesVecFnBS)(N_Vector vB, N_Vector JvB,
+                                      realtype t, N_Vector y, N_Vector *yS,
+                                      N_Vector yB, N_Vector fyB,
+                                      void *jac_dataB, N_Vector tmpB);
 
 /*
  * -----------------------------------------------------------------
@@ -432,15 +484,31 @@ typedef int (*CVSpilsJacTimesVecFnB)(N_Vector vB, N_Vector JvB, realtype t,
  * -----------------------------------------------------------------
  */
 
+/*
+ * -----------------------------------------------------------------
+ * Each CVSpilsSet***B or CVSpilsSet***BS function below links the
+ * main CVODES integrator with the corresponding CVSpilsSet***
+ * optional input function for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+
 SUNDIALS_EXPORT int CVSpilsSetPrecTypeB(void *cvode_mem, int which, int pretypeB);
 SUNDIALS_EXPORT int CVSpilsSetGSTypeB(void *cvode_mem, int which, int gstypeB);
-SUNDIALS_EXPORT int CVSpilsSetEpslinB(void *cvode_mem, int which, realtype eplifacB);
+SUNDIALS_EXPORT int CVSpilsSetEpsLinB(void *cvode_mem, int which, realtype eplifacB);
 SUNDIALS_EXPORT int CVSpilsSetMaxlB(void *cvode_mem, int which, int maxlB);
+
 SUNDIALS_EXPORT int CVSpilsSetPreconditionerB(void *cvode_mem, int which, 
                                               CVSpilsPrecSetupFnB psetB,
 					      CVSpilsPrecSolveFnB psolveB);
+SUNDIALS_EXPORT int CVSpilsSetPreconditionerBS(void *cvode_mem, int which, 
+                                               CVSpilsPrecSetupFnBS psetBS,
+					       CVSpilsPrecSolveFnBS psolveBS);
+
 SUNDIALS_EXPORT int CVSpilsSetJacTimesVecFnB(void *cvode_mem, int which, 
                                              CVSpilsJacTimesVecFnB jtvB);
+SUNDIALS_EXPORT int CVSpilsSetJacTimesVecFnBS(void *cvode_mem, int which, 
+                                              CVSpilsJacTimesVecFnBS jtvBS);
 
 
 #ifdef __cplusplus
diff --git a/include/cvodes/cvodes_sptfqmr.h b/include/cvodes/cvodes_sptfqmr.h
index 2b91a3a..f898eda 100644
--- a/include/cvodes/cvodes_sptfqmr.h
+++ b/include/cvodes/cvodes_sptfqmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2007/03/22 18:05:50 $
+ * $Revision: 4488 $
+ * $Date: 2015-04-29 16:39:48 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the CVODES scaled preconditioned TFQMR 
  * linear solver, CVSPTFQMR.
@@ -24,13 +29,13 @@
 #ifndef _CVSSPTFQMR_H
 #define _CVSSPTFQMR_H
 
+#include <cvodes/cvodes_spils.h>
+#include <sundials/sundials_sptfqmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_spils.h>
-#include <sundials/sundials_sptfqmr.h>
-
 /* 
  * -----------------------------------------------------------------
  * PART I - forward problems
@@ -77,6 +82,16 @@ SUNDIALS_EXPORT int CVSptfqmr(void *cvode_mem, int pretype, int maxl);
  * -----------------------------------------------------------------
  */
 
+/*
+ * -----------------------------------------------------------------
+ * Function: CVSptfqmrB
+ * -----------------------------------------------------------------
+ * CVSptfqmrB links the main CVODES integrator with the CVSptfqmr
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+
 SUNDIALS_EXPORT int CVSptfqmrB(void *cvode_mem, int which,
                                int pretypeB, int maxlB);
 
diff --git a/include/cvodes/cvodes_superlumt.h b/include/cvodes/cvodes_superlumt.h
new file mode 100644
index 0000000..2f437cc
--- /dev/null
+++ b/include/cvodes/cvodes_superlumt.h
@@ -0,0 +1,111 @@
+/*
+ * -----------------------------------------------------------------
+ * $Rev $
+ * $Date $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the CVSuperLUMT linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSSUPERLUMT_H
+#define _CVSSUPERLUMT_H
+
+#include "cvodes/cvodes_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : CVSuperLUMT
+ * -----------------------------------------------------------------
+ * A call to the CVSuperLUMT function links the main integrator      
+ * with the CVSuperLUMT linear solver module.                        
+ *                                                                
+ * cv_mem is the pointer to integrator memory returned by        
+ *     CVCreate.             
+ *
+ *                                                                
+ * CVSuperLUMT returns:                                              
+ *     CVSLU_SUCCESS   = 0  if successful                              
+ *     CVSLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     CVSLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The CVSuperLUMT linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, CVSuperLUMT will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVSuperLUMT(void *cv_mem, int num_threads,
+				  int n, int nnz); 
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVSuperLUMTSetOrdering sets the ordering used by CVSuperLUMT for 
+ * reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int CVSuperLUMTSetOrdering(void *cv_mem, 
+					     int ordering_choice); 
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: CVSuperLUMTB
+ * -----------------------------------------------------------------
+ * CVSuperLUMTB links the main CVODES integrator with the CVSuperLUMT
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+ 
+  SUNDIALS_EXPORT int CVSuperLUMTB(void *cvode_mem, int which, int num_threads, 
+				   int nB, int nnzB);
+ 
+ 
+/*
+ * -----------------------------------------------------------------
+ * Function: CVSuperLUMTSetOrderingB
+ * -----------------------------------------------------------------
+ * CVSuperLUMTSetOrderingB pulls off the memory block associated with the
+ * which parameter and sets the ordering for the solver associated with that block.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ * -----------------------------------------------------------------
+ */
+ 
+  SUNDIALS_EXPORT int CVSuperLUMTSetOrderingB(void *cvode_mem, int which, 
+					      int ordering_choice);
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/ida/ida.h b/include/ida/ida.h
index 85f5a4d..c9ceab1 100644
--- a/include/ida/ida.h
+++ b/include/ida/ida.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.14 $
- * $Date: 2010/12/01 22:14:08 $
+ * $Revision: 4845 $
+ * $Date: 2016-08-03 15:45:09 -0700 (Wed, 03 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Allan G. Taylor, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header (include) file for the main IDA solver.
  * -----------------------------------------------------------------
@@ -27,14 +32,13 @@
 #ifndef _IDA_H
 #define _IDA_H
 
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus     /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <stdio.h>
-
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  *              I D A     C O N S T A N T S
@@ -93,6 +97,8 @@ extern "C" {
 #define IDA_BAD_T           -26
 #define IDA_BAD_DKY         -27
 
+#define IDA_UNRECOGNISED_ERROR -99
+
 /*
  * ----------------------------------------------------------------
  * Type : IDAResFn                                                   
@@ -107,7 +113,7 @@ extern "C" {
  * respect to t) of the yy vector, yp.  It stores the result of   
  * F(t,y,y') in the vector rr. The yy, yp, and rr arguments are of 
  * type N_Vector. The user_data parameter is the pointer user_data 
- * passed by the user to the IDASetRdata routine. This user-supplied 
+ * passed by the user to the IDASetUserData routine. This user-supplied 
  * pointer is passed to the user's res function every time it is called, 
  * to provide access in res to user data.                                    
  *                                                                
@@ -133,7 +139,7 @@ typedef int (*IDAResFn)(realtype tt, N_Vector yy, N_Vector yp,
  * It stores the nrtfn values g_i(t,y,y') in the realtype array gout.
  * (Allocation of memory for gout is handled within IDA.)
  * The user_data parameter is the same as that passed by the user
- * to the IDASetRdata routine.  This user-supplied pointer is
+ * to the IDASetUserData routine.  This user-supplied pointer is
  * passed to the user's g function every time it is called.
  *
  * An IDARootFn should return 0 if successful or a non-zero value
@@ -160,7 +166,7 @@ typedef int (*IDARootFn)(realtype t, N_Vector y, N_Vector yp,
  *   ewt_i = 1 / (reltol * |y_i| + abstol_i)
  *
  * The user_data parameter is the same as that passed by the user
- * to the IDASetRdata routine.  This user-supplied pointer is
+ * to the IDASetUserData routine.  This user-supplied pointer is
  * passed to the user's e function every time it is called.
  * An IDAEwtFn e must return 0 if the error weight vector has been
  * successfuly set and a non-zero value otherwise.
@@ -177,7 +183,7 @@ typedef int (*IDAEwtFn)(N_Vector y, N_Vector ewt, void *user_data);
  * IDAErrHandlerFn.
  * The function eh takes as input the error code, the name of the
  * module reporting the error, the error message, and a pointer to
- * user data, the same as that passed to IDASetRdata.
+ * user data, the same as that passed to IDASetUserData.
  * 
  * All error codes are negative, except IDA_WARNING which indicates 
  * a warning (the solver continues).
diff --git a/include/ida/ida_band.h b/include/ida/ida_band.h
index aecbf4d..1f2242d 100644
--- a/include/ida/ida_band.h
+++ b/include/ida/ida_band.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:14:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDABAND linear solver module.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _IDABAND_H
 #define _IDABAND_H
 
+#include <ida/ida_direct.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_direct.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDABand
diff --git a/include/ida/ida_bbdpre.h b/include/ida/ida_bbdpre.h
index 2a4f646..4c790fc 100644
--- a/include/ida/ida_bbdpre.h
+++ b/include/ida/ida_bbdpre.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:14:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDABBDPRE module, for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -103,12 +108,12 @@
 #ifndef _IDABBDPRE_H
 #define _IDABBDPRE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus     /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /*
  * -----------------------------------------------------------------
  * Type : IDABBDLocalFn
@@ -129,7 +134,7 @@ extern "C" {
  * space defined by the user, and made available to the
  * preconditioner function for the problem. The user_data
  * parameter is the same as that passed by the user to the
- * IDASetRdata routine.
+ * IDASetUserdata routine.
  *
  * An IDABBDLocalFn Gres is to return an int, defined in the same
  * way as for the residual function: 0 (success), +1 or -1 (fail).
diff --git a/include/ida/ida_dense.h b/include/ida/ida_dense.h
index 20b3b4a..3ea763e 100644
--- a/include/ida/ida_dense.h
+++ b/include/ida/ida_dense.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:14:09 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDADENSE linear solver module.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _IDADENSE_H
 #define _IDADENSE_H
 
+#include <ida/ida_direct.h>
+#include <sundials/sundials_dense.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_direct.h>
-#include <sundials/sundials_dense.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDADense
diff --git a/include/ida/ida_direct.h b/include/ida/ida_direct.h
index 2b68306..401b719 100644
--- a/include/ida/ida_direct.h
+++ b/include/ida/ida_direct.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:14:09 $
+ * $Revision: 4525 $
+ * $Date: 2015-08-12 16:28:00 -0700 (Wed, 12 Aug 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common header file for the direct linear solvers in IDA.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _IDADLS_H
 #define _IDADLS_H
 
+#include <sundials/sundials_direct.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_direct.h>
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  *              I D A D I R E C T     C O N S T A N T S
@@ -72,18 +77,18 @@ extern "C" {
  * yp  is the current value of the derivative vector y',          
  *     namely the predicted value of y'(t).                    
  *                                                                
- * f   is the residual vector F(tt,yy,yp).                     
+ * r   is the residual vector F(tt,yy,yp).                     
  *                                                                
  * c_j is the scalar in the system Jacobian, proportional to 
  *     the inverse of the step size h.
  *                                                                
  * user_data is a pointer to user Jacobian data - the same as the    
- *     user_data parameter passed to IDASetRdata.                     
+ *     user_data parameter passed to IDASetUserData.                     
  *                                                                
  * Jac is the dense matrix (of type DlsMat) to be loaded by  
  *     an IDADlsDenseJacFn routine with an approximation to the   
  *     system Jacobian matrix                                  
- *            J = dF/dy' + gamma*dF/dy                            
+ *            J = dF/dy + c_j *dF/dy'                            
  *     at the given point (t,y,y'), where the ODE system is    
  *     given by F(t,y,y') = 0.
  *     Note that Jac is NOT preset to zero!
@@ -97,7 +102,7 @@ extern "C" {
  *     a positive int if a recoverable error occurred, or         
  *     a negative int if a nonrecoverable error occurred.         
  * In the case of a recoverable error return, the integrator will 
- * attempt to recover by reducing the stepsize (which changes cj).
+ * attempt to recover by reducing the stepsize (which changes c_j).
  *
  * -----------------------------------------------------------------
  *
@@ -125,9 +130,10 @@ extern "C" {
  * NOTE: If the user's Jacobian routine needs other quantities,   
  *     they are accessible as follows: hcur (the current stepsize)
  *     and ewt (the error weight vector) are accessible through   
- *     IDAGetCurrentStep and IDAGetErrWeights, respectively 
- *     (see ida.h). The unit roundoff is available as 
- *     UNIT_ROUNDOFF defined in sundials_types.h.
+ *     IDAGetCurrentStep and IDAGetErrWeights, respectively, but this
+ *     requires including in user_data a pointer to the solver memory.
+ *     The unit roundoff is available as UNIT_ROUNDOFF defined in
+ *     sundials_types.h.
  *
  * -----------------------------------------------------------------
  */
@@ -164,12 +170,12 @@ typedef int (*IDADlsDenseJacFn)(long int N, realtype t, realtype c_j,
  * c_j is the scalar in the system Jacobian, proportional to 1/hh.
  *                                                                
  * user_data  is a pointer to user Jacobian data - the same as the    
- *    user_data parameter passed to IDASetRdata.                      
+ *    user_data parameter passed to IDASetUserData.                      
  *                                                                
  * Jac is the band matrix (of type BandMat) to be loaded by    
  *     an IDADlsBandJacFn routine with an approximation to the    
  *     system Jacobian matrix                                  
- *            J = dF/dy + cj*dF/dy'                             
+ *            J = dF/dy + c_j *dF/dy'                             
  *     at the given point (t,y,y'), where the DAE system is    
  *     given by F(t,y,y') = 0.  Jac is preset to zero, so only 
  *     the nonzero elements need to be loaded.  See note below.
@@ -183,7 +189,7 @@ typedef int (*IDADlsDenseJacFn)(long int N, realtype t, realtype c_j,
  *     a positive int if a recoverable error occurred, or         
  *     a negative int if a nonrecoverable error occurred.         
  * In the case of a recoverable error return, the integrator will 
- * attempt to recover by reducing the stepsize (which changes cj).
+ * attempt to recover by reducing the stepsize (which changes c_j).
  *
  * -----------------------------------------------------------------
  *
@@ -214,9 +220,10 @@ typedef int (*IDADlsDenseJacFn)(long int N, realtype t, realtype c_j,
  * NOTE: If the user's Jacobian routine needs other quantities,   
  *       they are accessible as follows: hcur (the current stepsize)
  *       and ewt (the error weight vector) are accessible through   
- *       IDAGetCurrentStep and IDAGetErrWeights, respectively (see  
- *       ida.h). The unit roundoff is available as                  
- *       UNIT_ROUNDOFF defined in sundials_types.h                   
+ *       IDAGetCurrentStep and IDAGetErrWeights, respectively, but this
+ *       requires including in user_data a pointer to the solver memory.
+ *       The unit roundoff is available as UNIT_ROUNDOFF defined in
+ *       sundials_types.h                   
  *                                                                
  * -----------------------------------------------------------------
  */
@@ -266,7 +273,7 @@ SUNDIALS_EXPORT int IDADlsSetBandJacFn(void *ida_mem, IDADlsBandJacFn jac);
  * IDADlsGetNumJacEvals returns the number of calls made to the
  *                      Jacobian evaluation routine jac.
  * IDADlsGetNumResEvals returns the number of calls to the user
- *                      f routine due to finite difference Jacobian
+ *                      F routine due to finite difference Jacobian
  *                      evaluation.
  * IDADlsGetLastFlag    returns the last error flag set by any of
  *                      the IDADLS interface functions.
diff --git a/include/ida/ida_klu.h b/include/ida/ida_klu.h
new file mode 100644
index 0000000..79c03b3
--- /dev/null
+++ b/include/ida/ida_klu.h
@@ -0,0 +1,122 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the IDAKLU linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDAKLU_H
+#define _IDAKLU_H
+
+#include "ida/ida_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : IDAKLU
+ * -----------------------------------------------------------------
+ * A call to the IDAKLU function links the main integrator      
+ * with the IDAKLU linear solver module.                        
+ *                                                                
+ * ida_mem is the pointer to integrator memory returned by        
+ *     IDACreate.             
+ *
+ *                                                                
+ * IDAKLU returns:                                              
+ *     IDASLU_SUCCESS   = 0  if successful                              
+ *     IDASLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     IDASLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The KLU linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, IDAKLU will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLU(void *ida_mem, int n, int nnz, int sparesetype); 
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to IDAKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_MEM_NULL = -1, 
+ * IDASLS_LMEM_NULL = -2, IDASLS_ILL_INPUT = -3, or IDASLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int IDAKLUReInit(void *ida_mem_v, int n, int nnz, 
+				 int reinit_type);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: IDAKLUB
+ * -----------------------------------------------------------------
+ * IDAKLUB links the main IDAS integrator with the IDAKLU
+ * linear solver for the backward integration.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLUB(void *ida_mem, int which, int nB, int nnzB);
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDAKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in IDA is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLUSetOrdering(void *ida_mem, int ordering_choice); 
+
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/ida/ida_lapack.h b/include/ida/ida_lapack.h
index a50ed5c..2a16130 100644
--- a/include/ida/ida_lapack.h
+++ b/include/ida/ida_lapack.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2008/04/18 19:42:37 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Header file for the IDA dense linear solver IDALAPACK.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _IDALAPACK_H
 #define _IDALAPACK_H
 
+#include <ida/ida_direct.h>
+#include <sundials/sundials_lapack.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_direct.h>
-#include <sundials/sundials_lapack.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDALapackDense
diff --git a/include/ida/ida_sparse.h b/include/ida/ida_sparse.h
new file mode 100644
index 0000000..0aae45f
--- /dev/null
+++ b/include/ida/ida_sparse.h
@@ -0,0 +1,268 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4423 $
+ * $Date: 2015-03-08 17:23:10 -0700 (Sun, 08 Mar 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the Sparse linear solver module in IDA.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDASPARSE_H
+#define _IDASPARSE_H
+
+#include <sundials/sundials_sparse.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * I D A S S P A R S E    C O N S T A N T S
+ * =================================================================
+ */
+
+/* 
+ * -----------------------------------------------------------------
+ * IDASLS return values 
+ * -----------------------------------------------------------------
+ */
+
+#define IDASLS_SUCCESS           0
+#define IDASLS_MEM_NULL         -1
+#define IDASLS_LMEM_NULL        -2
+#define IDASLS_ILL_INPUT        -3
+#define IDASLS_MEM_FAIL         -4
+#define IDASLS_JAC_NOSET        -5
+#define IDASLS_PACKAGE_FAIL     -6
+
+/* Additional last_flag values */
+
+#define IDASLS_JACFUNC_UNRECVR  -7
+#define IDASLS_JACFUNC_RECVR    -8
+
+/* Return values for the adjoint module */
+#define IDASLS_NO_ADJ           -101
+#define IDASLS_LMEMB_NULL       -102
+
+/*
+ * =================================================================
+ * PART I:  F O R W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : IDASlsSparseJacFn
+ * -----------------------------------------------------------------
+ *
+ * A sparse Jacobian approximation function jaceval must be of type 
+ * IDASlsSparseJacFn.
+ * Its parameters are:                     
+ *                                                                
+ * t   is the current value of the independent variable t.        
+ *                                                                
+ * c_j is the scalar in the system Jacobian, proportional to 
+ *     the inverse of the step size h.
+ *                                                                
+ * y   is the current value of the dependent variable vector,     
+ *     namely the predicted value of y(t).                     
+ *                                                                
+ * yp  is the current value of the derivative vector y',          
+ *     namely the predicted value of y'(t).                    
+ *                                                                
+ * r   is the residual vector F(tt,yy,yp).                     
+ *                                                                
+ * JacMat is the compressed sparse column matrix (of type SlsMat)
+ *     to be loaded by an IDASlsSparseJacFn routine with an approximation
+ *     to the system Jacobian matrix
+ *            J = dF/dy' + c_j*dF/dy                            
+ *     at the given point (t,y,y'), where the ODE system is    
+ *     given by F(t,y,y') = 0.
+ *     Note that JacMat is NOT preset to zero!
+ *     Matrix data is for the nonzero entries of the Jacobian are stored in
+ *     compressed column format.  Row indices of entries in 
+ *     column j are stored in J->data[colptrs[j]] 
+ *     through J->data[colptrs[j+i]-1]
+ *     and corresponding numerical values of the Jacobian are stored 
+ *     in the same entries of a.
+ * 
+ * user_data is a pointer to user Jacobian data - the same as the    
+ *     user_data parameter passed to IDASetRdata.                     
+ *                                                                
+ * tmp1, tmp2, tmp3 are pointers to memory allocated for          
+ *     N_Vectors which can be used by an IDASparseJacFn routine 
+ *     as temporary storage or work space.                     
+ *                                                                
+ * A IDASlsSparseJacFn should return                                
+ *     0 if successful,                                           
+ *     a positive int if a recoverable error occurred, or         
+ *     a negative int if a nonrecoverable error occurred.         
+ * In the case of a recoverable error return, the integrator will 
+ * attempt to recover by reducing the stepsize (which changes cj).
+ *
+ * -----------------------------------------------------------------
+ *
+  * NOTE: If the user's Jacobian routine needs other quantities,   
+ *     they are accessible as follows: hcur (the current stepsize)
+ *     and ewt (the error weight vector) are accessible through   
+ *     IDAGetCurrentStep and IDAGetErrWeights, respectively 
+ *     (see ida.h). The unit roundoff is available as 
+ *     UNIT_ROUNDOFF defined in sundials_types.h.
+ *
+ * -----------------------------------------------------------------
+ */
+  
+  
+typedef int (*IDASlsSparseJacFn)(realtype t, realtype c_j,
+		     N_Vector y, N_Vector yp, N_Vector r, 
+		     SlsMat JacMat, void *user_data,
+		     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/*
+ * =================================================================
+ *            E X P O R T E D    F U N C T I O N S 
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Optional inputs to the IDASPARSE linear solver
+ * -----------------------------------------------------------------
+ * IDASlsSetSparseJacFn specifies the Jacobian approximation
+ * routine to be used for a sparse direct linear solver.
+ *
+ * The return value is one of:
+ *    IDASLS_SUCCESS   if successful
+ *    IDASLS_MEM_NULL  if the IDA memory was NULL
+ *    IDASLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int IDASlsSetSparseJacFn(void *ida_mem, IDASlsSparseJacFn jac);
+
+/*
+ * -----------------------------------------------------------------
+ * Optional outputs from the IDASLS linear solver
+ * -----------------------------------------------------------------
+ *
+ * IDASlsGetWorkSpace   returns the real and integer workspace used
+ *                      by the direct linear solver.
+ * IDASlsGetNumJacEvals returns the number of calls made to the
+ *                      Jacobian evaluation routine jac.
+ * IDASlsGetLastFlag    returns the last error flag set by any of
+ *                      the IDADLS interface functions.
+ *
+ * The return value of IDADlsGet* is one of:
+ *    IDASLS_SUCCESS   if successful
+ *    IDASLS_MEM_NULL  if the IDA memory was NULL
+ *    IDASLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int IDASlsGetNumJacEvals(void *ida_mem, long int *njevals);
+SUNDIALS_EXPORT int IDASlsGetLastFlag(void *ida_mem, long int *flag);
+
+/*
+ * -----------------------------------------------------------------
+ * The following function returns the name of the constant 
+ * associated with a IDASLS return flag
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT char *IDASlsGetReturnFlagName(long int flag);
+
+/*
+ * =================================================================
+ * PART II:  B A C K W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Type: IDASlsSparseJacFnB
+ * -----------------------------------------------------------------
+ * A sparse Jacobian approximation function JacB for the adjoint
+ * (backward) problem must have the prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*IDASlsSparseJacFnB)(realtype tt, realtype c_jB, 
+	      	     N_Vector yy, N_Vector yp,
+		     N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+		     SlsMat JacMatB, void *user_dataB, 
+		     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Type: IDASlsSparseJacFnBS
+ * -----------------------------------------------------------------
+ * A dense Jacobian approximation function JacBS for the adjoint
+ * (backward) problem, sensitivity-dependent case, must have the
+ *  prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*IDASlsSparseJacFnBS)(realtype tt, realtype c_jB, 
+	      	     N_Vector yy, N_Vector yp,
+		     N_Vector *yS, N_Vector *ypS,
+		     N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+		     SlsMat JacMatB, void *user_dataB, 
+		     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+
+/*
+ * -----------------------------------------------------------------
+ * EXPORTED FUNCTIONS 
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: IDASlsSetSparseJacFnB and IDASlsSetSparseJacFnBS
+ * -----------------------------------------------------------------
+ * IDASlsSetSparseJacFnB specifies the sparse Jacobian functions to 
+ * be used by a IDASPARSE linear solver for the backward integration phase
+ * when the backward problem does not depend on forward sensitivities.
+ * IDASlsSetSparseJacFnBS specifies the Jacobian
+ * functions when the backward problem does depend on sensitivities.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int IDASlsSetSparseJacFnB(void *ida_mem, int which, 
+					  IDASlsSparseJacFnB jacB);
+SUNDIALS_EXPORT int IDASlsSetSparseJacFnBS(void *ida_mem, int which, 
+					  IDASlsSparseJacFnBS jacBS);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/ida/ida_spbcgs.h b/include/ida/ida_spbcgs.h
index f733a11..9b49c35 100644
--- a/include/ida/ida_spbcgs.h
+++ b/include/ida/ida_spbcgs.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:06 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the public header file for the IDA scaled preconditioned
  * Bi-CGSTAB linear solver module, IDASPBCG.
@@ -18,13 +23,13 @@
 #ifndef _IDASPBCG_H
 #define _IDASPBCG_H
 
+#include <ida/ida_spils.h>
+#include <sundials/sundials_spbcgs.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_spils.h>
-#include <sundials/sundials_spbcgs.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDASpbcg
diff --git a/include/ida/ida_spgmr.h b/include/ida/ida_spgmr.h
index 3604028..2a4247a 100644
--- a/include/ida/ida_spgmr.h
+++ b/include/ida/ida_spgmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:06 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDA Scaled Preconditioned GMRES     
  * linear solver module, IDASPGMR.                                 
@@ -18,13 +23,13 @@
 #ifndef _IDASPGMR_H
 #define _IDASPGMR_H
 
+#include <ida/ida_spils.h>
+#include <sundials/sundials_spgmr.h>
+
 #ifdef __cplusplus     /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_spils.h>
-#include <sundials/sundials_spgmr.h>
-
 /*
  * -----------------------------------------------------------------
  *                                                                
diff --git a/include/ida/ida_spils.h b/include/ida/ida_spils.h
index 3b53b01..d99ad93 100644
--- a/include/ida/ida_spils.h
+++ b/include/ida/ida_spils.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:14:09 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan Hindmarsh, Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common header file for the Scaled and Preconditioned
  * Iterative Linear Solvers in IDA.
@@ -18,13 +23,13 @@
 #ifndef _IDASPILS_H
 #define _IDASPILS_H
 
+#include <sundials/sundials_iterative.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_iterative.h>
-#include <sundials/sundials_nvector.h>
-
 /* 
  * -----------------------------------------------------------------
  * IDASPILS return values 
diff --git a/include/ida/ida_sptfqmr.h b/include/ida/ida_sptfqmr.h
index a7a32b5..50f0325 100644
--- a/include/ida/ida_sptfqmr.h
+++ b/include/ida/ida_sptfqmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the public header file for the IDA scaled preconditioned
  * TFQMR linear solver module, IDASPTFQMR.
@@ -18,13 +23,13 @@
 #ifndef _IDASPTFQMR_H
 #define _IDASPTFQMR_H
 
+#include <ida/ida_spils.h>
+#include <sundials/sundials_sptfqmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_spils.h>
-#include <sundials/sundials_sptfqmr.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDASptfqmr
diff --git a/include/ida/ida_superlumt.h b/include/ida/ida_superlumt.h
new file mode 100644
index 0000000..3269991
--- /dev/null
+++ b/include/ida/ida_superlumt.h
@@ -0,0 +1,99 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4179 $
+ * $Date: 2014-07-23 12:16:01 -0700 (Wed, 23 Jul 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the IDASuperLUMT linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDASUPERLUMT_H
+#define _IDASUPERLUMT_H
+
+#include "ida/ida_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+/*
+ * -----------------------------------------------------------------
+ * Function : IDASuperLUMT
+ * -----------------------------------------------------------------
+ * A call to the IDASuperLUMT function links the main integrator      
+ * with the IDASuperLUMT linear solver module.                        
+ *                                                                
+ * ida_mem is the pointer to integrator memory returned by        
+ *     IDACreate.             
+ *
+ * num_threads is the number of threads that SuperLUMT should invoke     
+ *                                                                
+ * IDASuperLUMT returns:                                              
+ *     IDASLU_SUCCESS   = 0  if successful                              
+ *     IDASLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     IDASLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, IDASuperLUMT will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDASuperLUMT(void *ida_mem, int num_threads, 
+				   int n, int nnz); 
+
+/*
+ * -----------------------------------------------------------------
+ * Function: IDASuperLUMTB
+ * -----------------------------------------------------------------
+ * IDASuperLUMTB links the main IDAS integrator with the IDASuperLUMT
+ * linear solver for the backward integration.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDASuperLUMTB(void *ida_mem, int num_threads, 
+				    int which, int mB, int nB, int nnzB);
+
+
+
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDASuperLUMTSetOrdering sets the ordering used by SuperLUMT for 
+ * reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDASuperLUMTSetOrdering(void *ida_mem, 
+					      int ordering_choice); 
+
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/idas/idas.h b/include/idas/idas.h
index 6f1ac11..19509a1 100644
--- a/include/idas/idas.h
+++ b/include/idas/idas.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.26 $
- * $Date: 2010/12/01 22:15:15 $
+ * $Revision: 4845 $
+ * $Date: 2016-08-03 15:45:09 -0700 (Wed, 03 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header (include) file for the main IDAS solver.
  * -----------------------------------------------------------------
@@ -28,13 +33,13 @@
 #ifndef _IDAS_H
 #define _IDAS_H
 
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus     /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <stdio.h>
-#include <sundials/sundials_nvector.h>
-
 /* * =================================================================
  *              I D A S     C O N S T A N T S
  * =================================================================
@@ -125,6 +130,8 @@ extern "C" {
 #define IDA_FIRST_QSRHS_ERR -52
 #define IDA_REP_QSRHS_ERR   -53
 
+#define IDA_UNRECONGISED_ERROR -99
+
 /*
  * -----------------------------------------
  * IDAA return flags
@@ -1913,13 +1920,13 @@ SUNDIALS_EXPORT int IDASolveB(void *ida_mem, realtype tBout, int itaskB);
 
 /*
  * -----------------------------------------------------------------
- * IDASetAdjNoSensi
+ * IDAAdjSetNoSensi
  * -----------------------------------------------------------------
  * Disables the forward sensitivity analysis in IDASolveF.
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT int IDASetAdjNoSensi(void *ida_mem);
+SUNDIALS_EXPORT int IDAAdjSetNoSensi(void *ida_mem);
 
 /*
  * -----------------------------------------------------------------
diff --git a/include/idas/idas_band.h b/include/idas/idas_band.h
index 6d4d23d..774c379 100644
--- a/include/idas/idas_band.h
+++ b/include/idas/idas_band.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:15:15 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDAS band linear solver
  * module, IDABAND. It interfaces between the band module and the
@@ -25,13 +30,13 @@
 #ifndef _IDASBAND_H
 #define _IDASBAND_H
 
+#include <idas/idas_direct.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_direct.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDABand
@@ -67,6 +72,7 @@ SUNDIALS_EXPORT int IDABand(void *ida_mem,
  * -----------------------------------------------------------------
  * IDABandB links the main IDAS integrator with the IDABAND
  * linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/idas/idas_bbdpre.h b/include/idas/idas_bbdpre.h
index 70adaff..50d6d6d 100644
--- a/include/idas/idas_bbdpre.h
+++ b/include/idas/idas_bbdpre.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:15:15 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDABBDPRE module, for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -20,12 +25,12 @@
 #ifndef _IDASBBDPRE_H
 #define _IDASBBDPRE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus     /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /* 
  * =================================================================
  * PART I - forward problems
@@ -308,6 +313,7 @@ typedef int (*IDABBDCommFnB)(long int NlocalB, realtype tt,
  * -----------------------------------------------------------------
  * Interface functions for the IDABBDPRE preconditioner to be used
  * on the backward phase.
+ * The 'which' argument is the int returned by IDACreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/idas/idas_dense.h b/include/idas/idas_dense.h
index 73c1340..2fb2ec7 100644
--- a/include/idas/idas_dense.h
+++ b/include/idas/idas_dense.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:15:15 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDADENSE linear solver module.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _IDASDENSE_H
 #define _IDASDENSE_H
 
+#include <idas/idas_direct.h>
+#include <sundials/sundials_dense.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_direct.h>
-#include <sundials/sundials_dense.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDADense
@@ -57,6 +62,7 @@ SUNDIALS_EXPORT int IDADense(void *ida_mem, long int Neq);
  * -----------------------------------------------------------------
  * IDADenseB links the main IDAS integrator with the IDADENSE
  * linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
  * -----------------------------------------------------------------
  */
 
diff --git a/include/idas/idas_direct.h b/include/idas/idas_direct.h
index da20021..d26833b 100644
--- a/include/idas/idas_direct.h
+++ b/include/idas/idas_direct.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:15:15 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common header file for the direct linear solvers in IDAS.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _IDADLS_H
 #define _IDADLS_H
 
+#include <sundials/sundials_direct.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_direct.h>
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  * I D A S D I R E C T     C O N S T A N T S
@@ -89,7 +94,7 @@ extern "C" {
  *     the inverse of the step size h.
  *                                                                
  * user_data is a pointer to user Jacobian data - the same as the    
- *     user_data parameter passed to IDASetRdata.                     
+ *     user_data parameter passed to IDASetUserData.                     
  *                                                                
  * Jac is the dense matrix (of type DlsMat) to be loaded by  
  *     an IDADlsDenseJacFn routine with an approximation to the   
@@ -175,7 +180,7 @@ typedef int (*IDADlsDenseJacFn)(long int N, realtype t, realtype c_j,
  * c_j is the scalar in the system Jacobian, proportional to 1/hh.
  *                                                                
  * user_data  is a pointer to user Jacobian data - the same as the    
- *    user_data parameter passed to IDASetRdata.                      
+ *    user_data parameter passed to IDASetUserData.                      
  *                                                                
  * Jac is the band matrix (of type BandMat) to be loaded by    
  *     an IDADlsBandJacFn routine with an approximation to the    
@@ -333,6 +338,24 @@ typedef int (*IDADlsDenseJacFnB)(long int NeqB, realtype tt, realtype c_jB,
 
 /*
  * -----------------------------------------------------------------
+ * Type: IDADlsDenseJacFnBS
+ * -----------------------------------------------------------------
+ * A dense Jacobian approximation function JacBS for the adjoint
+ * (backward) problem, sensitivity-dependent case, must have the
+ *  prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*IDADlsDenseJacFnBS)(long int NeqB, realtype tt, realtype c_jB, 
+				 N_Vector yy, N_Vector yp,
+				 N_Vector *yS, N_Vector *ypS,
+				 N_Vector yyB, N_Vector ypB, N_Vector rrB,
+				 DlsMat JacB, void *user_dataB, 
+				 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+
+/*
+ * -----------------------------------------------------------------
  * Type : IDADlsBandJacFnB
  * -----------------------------------------------------------------
  * A band Jacobian approximation function JacB for the adjoint 
@@ -349,22 +372,47 @@ typedef int (*IDADlsBandJacFnB)(long int NeqB, long int mupperB, long int mlower
   
 /*
  * -----------------------------------------------------------------
- * EXPORTED FUNCTIONS 
+ * Type : IDADlsBandJacFnBS
+ * -----------------------------------------------------------------
+ * A band Jacobian approximation function JacBS for the adjoint 
+ * (backward) problem, sensitivity-dependent case, must have the
+ *  prototype given below. 
  * -----------------------------------------------------------------
  */
 
+typedef int (*IDADlsBandJacFnBS)(long int NeqB, long int mupperB, long int mlowerB, 
+				realtype tt, realtype c_jB, 
+				N_Vector yy, N_Vector yp,
+				N_Vector *yS, N_Vector *ypS,
+				N_Vector yyB, N_Vector ypB, N_Vector rrB,
+				DlsMat JacB, void *user_dataB,
+				N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+  
 /*
  * -----------------------------------------------------------------
- * Functions: IDADlsSetJacFnB
+ * EXPORTED FUNCTIONS 
  * -----------------------------------------------------------------
+ */
+
+/*
+ * --------------------------------------------------------------------
+ * Functions: IDADlsSet*JacFnB and IDADlsSet*JacFnBS
+ * --------------------------------------------------------------------
  * IDADlsSetDenseJacFnB and IDADlsSetBandJacFnB specify the dense
- * and band, respectively, Jacobian functions to be used by a
- * IDASDIRECT linear solver for the bacward integration phase.
- * -----------------------------------------------------------------
+ * and band Jacobian functions, respectively, to be used by a
+ * IDASDIRECT linear solver for the backward integration phase, when
+ * the backward problem does not depend on forward sensitivities.
+ * IDADlsSetDenseJacFnBS and IDADlsSetBandJacFnBS specify the Jacobian
+ * functions when the backward problem does depend on sensitivities.
+ * The 'which' argument is the int returned by IDACreateB.
+ * --------------------------------------------------------------------
  */
 
 SUNDIALS_EXPORT int IDADlsSetDenseJacFnB(void *ida_mem, int which, IDADlsDenseJacFnB jacB);
+SUNDIALS_EXPORT int IDADlsSetDenseJacFnBS(void *ida_mem, int which, IDADlsDenseJacFnBS jacBS);
+
 SUNDIALS_EXPORT int IDADlsSetBandJacFnB(void *idaa_mem, int which, IDADlsBandJacFnB jacB);
+SUNDIALS_EXPORT int IDADlsSetBandJacFnBS(void *idaa_mem, int which, IDADlsBandJacFnBS jacBS);
 
 
 #ifdef __cplusplus
diff --git a/include/idas/idas_klu.h b/include/idas/idas_klu.h
new file mode 100644
index 0000000..8db561a
--- /dev/null
+++ b/include/idas/idas_klu.h
@@ -0,0 +1,157 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the IDAKLU linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDASKLU_H
+#define _IDASKLU_H
+
+#include "idas/idas_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : IDAKLU
+ * -----------------------------------------------------------------
+ * A call to the IDAKLU function links the main integrator      
+ * with the IDAKLU linear solver module.                        
+ *                                                                
+ * ida_mem is the pointer to integrator memory returned by        
+ *     IDACreate.             
+ *
+ *                                                                
+ * IDAKLU returns:                                              
+ *     IDASLU_SUCCESS   = 0  if successful                              
+ *     IDASLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     IDASLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The KLU linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, IDAKLU will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLU(void *ida_mem, int n, int nnz, int sparesetype); 
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to IDAKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_MEM_NULL = -1, 
+ * IDASLS_LMEM_NULL = -2, IDASLS_ILL_INPUT = -3, or IDASLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLUReInit(void *ida_mem_v, int n, int nnz, 
+				   int reinit_type);
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDAKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in KINSOL is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLUSetOrdering(void *ida_mem, int ordering_choice); 
+
+/* 
+ * ================================================================
+ *
+ *                   PART II - backward problems
+ *
+ * ================================================================
+ */
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: IDAKLUB
+ * -----------------------------------------------------------------
+ * IDAKLUB links the main IDAS integrator with the IDAKLU
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLUB(void *ida_mem, int which, int nB, int nnzB, int sparsetype);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: IDAKLUReInitB
+ * -----------------------------------------------------------------
+ * IDAKLUReInitB pulls off the memory block associated with the which parameter
+ * and reinitializes the KLU solver associated with that memory block.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLUReInitB(void *ida_mem, int which, int nB, int nnzB, int reinit_type);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: IDAKLUSetOrderingB
+ * -----------------------------------------------------------------
+ * IDAKLUSetOrderingB pulls off the memory block associated with the which parameter
+ * and sets the ordering for the KLU solver associated with that memory block.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDAKLUSetOrderingB(void *ida_mem, int which, int ordering_choiceB);
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/idas/idas_lapack.h b/include/idas/idas_lapack.h
index d94f94e..8e5b778 100644
--- a/include/idas/idas_lapack.h
+++ b/include/idas/idas_lapack.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2008/04/18 19:42:38 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Header file for the IDAS dense linear solver IDASLAPACK.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _IDALAPACK_H
 #define _IDALAPACK_H
 
+#include <idas/idas_direct.h>
+#include <sundials/sundials_lapack.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_direct.h>
-#include <sundials/sundials_lapack.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : IDALapackDense
@@ -79,10 +84,11 @@ SUNDIALS_EXPORT int IDALapackBand(void *ida_mem, int N, int mupper, int mlower);
  * -----------------------------------------------------------------
  * IDALapackDenseB links the main IDAS integrator with the dense
  * IDALAPACK linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT int IDALapackDenseB(void *ida_mem, int NeqB);
+  SUNDIALS_EXPORT int IDALapackDenseB(void *ida_mem, int which, int NeqB);
 
 /*
  * -----------------------------------------------------------------
@@ -90,10 +96,11 @@ SUNDIALS_EXPORT int IDALapackDenseB(void *ida_mem, int NeqB);
  * -----------------------------------------------------------------
  * IDALapackBandB links the main IDAS integrator with the band
  * IDALAPACK linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT int IDALapackBandB(void *ida_mem, int NeqB, int mupperB, int mlowerB);
+  SUNDIALS_EXPORT int IDALapackBandB(void *ida_mem, int which, int NeqB, int mupperB, int mlowerB);
 
 
 #ifdef __cplusplus
diff --git a/include/idas/idas_sparse.h b/include/idas/idas_sparse.h
new file mode 100644
index 0000000..9ddd7b3
--- /dev/null
+++ b/include/idas/idas_sparse.h
@@ -0,0 +1,269 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the Sparse linear solver module in IDAS.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDASSPARSE_H
+#define _IDASSPARSE_H
+
+#include <sundials/sundials_sparse.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * I D A S S P A R S E    C O N S T A N T S
+ * =================================================================
+ */
+
+/* 
+ * -----------------------------------------------------------------
+ * IDASSLS return values 
+ * -----------------------------------------------------------------
+ */
+
+#define IDASLS_SUCCESS           0
+#define IDASLS_MEM_NULL         -1
+#define IDASLS_LMEM_NULL        -2
+#define IDASLS_ILL_INPUT        -3
+#define IDASLS_MEM_FAIL         -4
+#define IDASLS_JAC_NOSET        -5
+#define IDASLS_PACKAGE_FAIL     -6
+
+/* Additional last_flag values */
+
+#define IDASLS_JACFUNC_UNRECVR  -7
+#define IDASLS_JACFUNC_RECVR    -8
+
+/* Return values for the adjoint module */
+#define IDASLS_NO_ADJ           -101
+#define IDASLS_LMEMB_NULL       -102
+
+/*
+ * =================================================================
+ * PART I:  F O R W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : IDASlsSparseJacFn
+ * -----------------------------------------------------------------
+ *
+ * A sparse Jacobian approximation function jaceval must be of type 
+ * IDASlsSparseJacFn.
+ * Its parameters are:                     
+ *                                                                
+ * t   is the current value of the independent variable t.        
+ *                                                                
+ * c_j is the scalar in the system Jacobian, proportional to 
+ *     the inverse of the step size h.
+ *                                                                
+ * y   is the current value of the dependent variable vector,     
+ *     namely the predicted value of y(t).                     
+ *                                                                
+ * yp  is the current value of the derivative vector y',          
+ *     namely the predicted value of y'(t).                    
+ *                                                                
+ * f   is the residual vector F(tt,yy,yp).                     
+ *                                                                
+ * JacMat is the compressed sparse column matrix (of type SlsMat)
+ *     to be loaded by an IDASlsSparseJacFn routine with an approximation
+ *     to the system Jacobian matrix
+ *            J = dF/dy' + gamma*dF/dy                            
+ *     at the given point (t,y,y'), where the ODE system is    
+ *     given by F(t,y,y') = 0.
+ *     Note that JacMat is NOT preset to zero!
+ *     Matrix data is for the nonzero entries of the Jacobian are stored in
+ *     compressed column format.  Row indices of entries in 
+ *     column j are stored in J->data[colptrs[j]] 
+ *     through J->data[colptrs[j+i]-1]
+ *     and corresponding numerical values of the Jacobian are stored 
+ *     in the same entries of a.
+ * 
+ * user_data is a pointer to user Jacobian data - the same as the    
+ *     user_data parameter passed to IDASetRdata.                     
+ *                                                                
+ * tmp1, tmp2, tmp3 are pointers to memory allocated for          
+ *     N_Vectors which can be used by an IDASparseJacFn routine 
+ *     as temporary storage or work space.                     
+ *                                                                
+ * A IDASlsSparseJacFn should return                                
+ *     0 if successful,                                           
+ *     a positive int if a recoverable error occurred, or         
+ *     a negative int if a nonrecoverable error occurred.         
+ * In the case of a recoverable error return, the integrator will 
+ * attempt to recover by reducing the stepsize (which changes cj).
+ *
+ * -----------------------------------------------------------------
+ *
+  * NOTE: If the user's Jacobian routine needs other quantities,   
+ *     they are accessible as follows: hcur (the current stepsize)
+ *     and ewt (the error weight vector) are accessible through   
+ *     IDAGetCurrentStep and IDAGetErrWeights, respectively 
+ *     (see ida.h). The unit roundoff is available as 
+ *     UNIT_ROUNDOFF defined in sundials_types.h.
+ *
+ * -----------------------------------------------------------------
+ */
+  
+  
+typedef int (*IDASlsSparseJacFn)(realtype t, realtype c_j,
+		     N_Vector y, N_Vector yp, N_Vector r, 
+		     SlsMat JacMat, void *user_data,
+		     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/*
+ * =================================================================
+ *            E X P O R T E D    F U N C T I O N S 
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Optional inputs to the IDASSPARSE linear solver
+ * -----------------------------------------------------------------
+ * IDASlsSetSparseJacFn specifies the Jacobian approximation
+ * routine to be used for a sparse direct linear solver.
+ *
+ * The return value is one of:
+ *    IDASLS_SUCCESS   if successful
+ *    IDASLS_MEM_NULL  if the IDA memory was NULL
+ *    IDASLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int IDASlsSetSparseJacFn(void *ida_mem, IDASlsSparseJacFn jac);
+
+/*
+ * -----------------------------------------------------------------
+ * Optional outputs from the IDASLS linear solver
+ * -----------------------------------------------------------------
+ *
+ * IDASlsGetWorkSpace   returns the real and integer workspace used
+ *                      by the direct linear solver.
+ * IDASlsGetNumJacEvals returns the number of calls made to the
+ *                      Jacobian evaluation routine jac.
+ * IDASlsGetLastFlag    returns the last error flag set by any of
+ *                      the IDADLS interface functions.
+ *
+ * The return value of IDADlsGet* is one of:
+ *    IDASLS_SUCCESS   if successful
+ *    IDASLS_MEM_NULL  if the IDA memory was NULL
+ *    IDASLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int IDASlsGetNumJacEvals(void *ida_mem, long int *njevals);
+SUNDIALS_EXPORT int IDASlsGetLastFlag(void *ida_mem, long int *flag);
+
+/*
+ * -----------------------------------------------------------------
+ * The following function returns the name of the constant 
+ * associated with a IDASLS return flag
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT char *IDASlsGetReturnFlagName(long int flag);
+
+/*
+ * =================================================================
+ * PART II:  B A C K W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Type: IDASlsSparseJacFnB
+ * -----------------------------------------------------------------
+ * A sparse Jacobian approximation function JacB for the adjoint
+ * (backward) problem must have the prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*IDASlsSparseJacFnB)(realtype tt, realtype c_jB, 
+	      	     N_Vector yy, N_Vector yp,
+		     N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+		     SlsMat JacMatB, void *user_dataB, 
+		     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Type: IDASlsSparseJacFnBS
+ * -----------------------------------------------------------------
+ * A dense Jacobian approximation function JacBS for the adjoint
+ * (backward) problem, sensitivity-dependent case, must have the
+ *  prototype given below. 
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*IDASlsSparseJacFnBS)(realtype tt, realtype c_jB, 
+	      	     N_Vector yy, N_Vector yp,
+		     N_Vector *yS, N_Vector *ypS,
+		     N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+		     SlsMat JacMatB, void *user_dataB, 
+		     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+
+/*
+ * -----------------------------------------------------------------
+ * EXPORTED FUNCTIONS 
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: IDASlsSetSparseJacFnB and IDASlsSetSparseJacFnBS
+ * -----------------------------------------------------------------
+ * IDASlsSetSparseJacFnB specifies the sparse Jacobian functions to 
+ * be used by a IDASSPARSE linear solver for the backward integration phase
+ * when the backward problem does not depend on forward sensitivities.
+ * IDASlsSetSparseJacFnBS specifies the Jacobian
+ * functions when the backward problem does depend on sensitivities.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int IDASlsSetSparseJacFnB(void *ida_mem, int which, 
+					  IDASlsSparseJacFnB jacB);
+SUNDIALS_EXPORT int IDASlsSetSparseJacFnBS(void *ida_mem, int which, 
+					  IDASlsSparseJacFnBS jacBS);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/idas/idas_spbcgs.h b/include/idas/idas_spbcgs.h
index 1e45c38..4264504 100644
--- a/include/idas/idas_spbcgs.h
+++ b/include/idas/idas_spbcgs.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/07/05 19:10:36 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the public header file for the IDAS scaled preconditioned
  * Bi-CGSTAB linear solver module, IDASPBCG.
@@ -24,13 +29,13 @@
 #ifndef _IDASSPBCG_H
 #define _IDASSPBCG_H
 
+#include <idas/idas_spils.h>
+#include <sundials/sundials_spbcgs.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_spils.h>
-#include <sundials/sundials_spbcgs.h>
-
 /* 
  * -----------------------------------------------------------------
  * PART I - forward problems
@@ -69,6 +74,16 @@ SUNDIALS_EXPORT int IDASpbcg(void *ida_mem, int maxl);
  * -----------------------------------------------------------------
  */
 
+/*
+ * -----------------------------------------------------------------
+ * Function: IDASpbcgB
+ * -----------------------------------------------------------------
+ * IDASpbcgB links the main IDAS integrator with the IDASpbcg
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
 SUNDIALS_EXPORT int IDASpbcgB(void *ida_mem, int which, int maxlB);
 
 
diff --git a/include/idas/idas_spgmr.h b/include/idas/idas_spgmr.h
index d85aa97..9b15566 100644
--- a/include/idas/idas_spgmr.h
+++ b/include/idas/idas_spgmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/07/05 19:10:36 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the IDAS Scaled Preconditioned GMRES     
  * linear solver module, IDASPGMR.                                 
@@ -24,13 +29,13 @@
 #ifndef _IDASSPGMR_H
 #define _IDASSPGMR_H
 
+#include <idas/idas_spils.h>
+#include <sundials/sundials_spgmr.h>
+
 #ifdef __cplusplus     /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_spils.h>
-#include <sundials/sundials_spgmr.h>
-
 /* 
  * -----------------------------------------------------------------
  * PART I - forward problems
@@ -71,6 +76,16 @@ SUNDIALS_EXPORT int IDASpgmr(void *ida_mem, int maxl);
  * -----------------------------------------------------------------
  */
 
+/*
+ * -----------------------------------------------------------------
+ * Function: IDASpgmrB
+ * -----------------------------------------------------------------
+ * IDASpgmrB links the main IDAS integrator with the IDASpgmr
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
 SUNDIALS_EXPORT int IDASpgmrB(void *ida_mem, int which, int maxlB);
 
 #ifdef __cplusplus
diff --git a/include/idas/idas_spils.h b/include/idas/idas_spils.h
index b7469dd..58ac018 100644
--- a/include/idas/idas_spils.h
+++ b/include/idas/idas_spils.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2010/12/01 22:15:15 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmers: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common header file for the Scaled and Preconditioned
  * Iterative Linear Solvers in IDAS.
@@ -18,13 +23,13 @@
 #ifndef _IDASSPILS_H
 #define _IDASSPILS_H
 
+#include <sundials/sundials_iterative.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_iterative.h>
-#include <sundials/sundials_nvector.h>
-
 /* 
  * -----------------------------------------------------------------
  * IDASPILS return values 
@@ -351,6 +356,22 @@ typedef int (*IDASpilsPrecSetupFnB)(realtype tt,
 
 /*
  * -----------------------------------------------------------------
+ * Type : IDASpilsPrecSetupFnBS
+ * -----------------------------------------------------------------
+ * A function PrecSetupBS for the adjoint (backward) problem must have 
+ * the prototype given below.
+ * -----------------------------------------------------------------
+ */
+typedef int (*IDASpilsPrecSetupFnBS)(realtype tt,
+                                     N_Vector yy, N_Vector yp,
+                                     N_Vector *yyS, N_Vector *ypS,
+                                     N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                     realtype c_jB, void *user_dataB,
+                                     N_Vector tmp1B, N_Vector tmp2B,
+                                     N_Vector tmp3B);
+
+/*
+ * -----------------------------------------------------------------
  * Type : IDASpilsPrecSolveFnB
  * -----------------------------------------------------------------
  * A function PrecSolveB for the adjoint (backward) problem  must 
@@ -367,6 +388,23 @@ typedef int (*IDASpilsPrecSolveFnB)(realtype tt,
 
 /*
  * -----------------------------------------------------------------
+ * Type : IDASpilsPrecSolveFnBS
+ * -----------------------------------------------------------------
+ * A function PrecSolveBS for the adjoint (backward) problem  must 
+ * have the prototype given below.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*IDASpilsPrecSolveFnBS)(realtype tt,
+                                     N_Vector yy, N_Vector yp,
+                                     N_Vector *yyS, N_Vector *ypS,
+                                     N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                     N_Vector rvecB, N_Vector zvecB,
+                                     realtype c_jB, realtype deltaB,
+                                     void *user_dataB, N_Vector tmpB);
+
+/*
+ * -----------------------------------------------------------------
  * Type : IDASpilsJacTimesVecFnB
  * -----------------------------------------------------------------
  * A function jtimesB for the adjoint (backward) problem must have 
@@ -383,26 +421,54 @@ typedef int (*IDASpilsJacTimesVecFnB)(realtype t,
 
 /*
  * -----------------------------------------------------------------
+ * Type : IDASpilsJacTimesVecFnBS
+ * -----------------------------------------------------------------
+ * A function jtimesBS for the adjoint (backward) problem must have 
+ * the prototype given below.
+ * -----------------------------------------------------------------
+ */
+
+typedef int (*IDASpilsJacTimesVecFnBS)(realtype t,
+                                       N_Vector yy, N_Vector yp,
+                                       N_Vector *yyS, N_Vector *ypS,
+                                       N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                       N_Vector vB, N_Vector JvB, 
+                                       realtype c_jB, void *user_dataB, 
+                                       N_Vector tmp1B, N_Vector tmp2B);
+
+/*
+ * -----------------------------------------------------------------
  * Functions
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT int IDASpilsSetGSTypeB(void *ida_mem, int which, int gstypeB);
+/*
+ * -----------------------------------------------------------------
+ * Each IDASpilsSet***B or IDASpilsSet***BS function below links the
+ * main IDAS integrator with the corresponding IDASpilsSet***
+ * optional input function for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
 
+SUNDIALS_EXPORT int IDASpilsSetGSTypeB(void *ida_mem, int which, int gstypeB);
 SUNDIALS_EXPORT int IDASpilsSetMaxRestartsB(void *ida_mem, int which, int maxrsB);
-
 SUNDIALS_EXPORT int IDASpilsSetEpsLinB(void *ida_mem, int which, realtype eplifacB);
-
 SUNDIALS_EXPORT int IDASpilsSetMaxlB(void *ida_mem, int which, int maxlB);
-
 SUNDIALS_EXPORT int IDASpilsSetIncrementFactorB(void *ida_mem, int which, 
                                                 realtype dqincfacB);
 
 SUNDIALS_EXPORT int IDASpilsSetPreconditionerB(void *ida_mem, int which,
                                                IDASpilsPrecSetupFnB psetB,
 					       IDASpilsPrecSolveFnB psolveB);
+SUNDIALS_EXPORT int IDASpilsSetPreconditionerBS(void *ida_mem, int which,
+                                                IDASpilsPrecSetupFnBS psetBS,
+                                                IDASpilsPrecSolveFnBS psolveBS);
+
 SUNDIALS_EXPORT int IDASpilsSetJacTimesVecFnB(void *ida_mem, int which,
                                               IDASpilsJacTimesVecFnB jtvB);
+SUNDIALS_EXPORT int IDASpilsSetJacTimesVecFnBS(void *ida_mem, int which,
+                                               IDASpilsJacTimesVecFnBS jtvBS);
 
 
 
diff --git a/include/idas/idas_sptfqmr.h b/include/idas/idas_sptfqmr.h
index 18d931e..0d22174 100644
--- a/include/idas/idas_sptfqmr.h
+++ b/include/idas/idas_sptfqmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/07/05 19:10:36 $
+ * $Revision: 4489 $
+ * $Date: 2015-04-29 17:15:44 -0700 (Wed, 29 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the public header file for the IDAS scaled preconditioned
  * TFQMR linear solver module, IDASPTFQMR.
@@ -24,13 +29,13 @@
 #ifndef _IDASSPTFQMR_H
 #define _IDASSPTFQMR_H
 
+#include <idas/idas_spils.h>
+#include <sundials/sundials_sptfqmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_spils.h>
-#include <sundials/sundials_sptfqmr.h>
-
 /* 
  * -----------------------------------------------------------------
  * PART I - forward problems
@@ -69,6 +74,17 @@ SUNDIALS_EXPORT int IDASptfqmr(void *ida_mem, int maxl);
  * -----------------------------------------------------------------
  */
 
+/*
+ * -----------------------------------------------------------------
+ * Function: IDASptfqmrB
+ * -----------------------------------------------------------------
+ * IDASptfqmrB links the main IDAS integrator with the IDASptfqmr
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
+
 SUNDIALS_EXPORT int IDASptfqmrB(void *ida_mem, int which, int maxlB);
 
 #ifdef __cplusplus
diff --git a/include/idas/idas_superlumt.h b/include/idas/idas_superlumt.h
new file mode 100644
index 0000000..2606b7d
--- /dev/null
+++ b/include/idas/idas_superlumt.h
@@ -0,0 +1,112 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4491 $
+ * $Date: 2015-04-30 16:56:10 -0700 (Thu, 30 Apr 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the IDASuperLUMT linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDASSUPERLUMT_H
+#define _IDASSUPERLUMT_H
+
+#include "idas/idas_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+/*
+ * -----------------------------------------------------------------
+ * Function : IDASuperLUMT
+ * -----------------------------------------------------------------
+ * A call to the IDASuperLUMT function links the main integrator      
+ * with the IDASuperLUMT linear solver module.                        
+ *                                                                
+ * ida_mem is the pointer to integrator memory returned by        
+ *     IDACreate.             
+ *
+ * num_threads is the number of threads that SuperLUMT should invoke     
+ *                                                                
+ * IDASuperLUMT returns:                                              
+ *     IDASLU_SUCCESS   = 0  if successful                              
+ *     IDASLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     IDASLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, IDASuperLUMT will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDASuperLUMT(void *ida_mem, int num_threads, 
+				   int n, int nnz); 
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDASuperLUMTSetOrdering sets the ordering used by SuperLUMT for 
+ * reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDASuperLUMTSetOrdering(void *ida_mem, 
+					      int ordering_choice); 
+
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: IDASuperLUMTB
+ * -----------------------------------------------------------------
+ * IDASuperLUMTB links the main IDAS integrator with the IDASuperLUMT
+ * linear solver for the backward integration.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int IDASuperLUMTB(void *ida_mem, int which, int num_threads, 
+				    int nB, int nnzB);
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function: IDASuperLUMTSetOrderingB
+ * -----------------------------------------------------------------
+ * IDASuperLUMTSetOrderingB pulls off the memory block associated with the which parameter
+ * and sets the ordering for the KLU solver associated with that memory block.
+ * The 'which' argument is the int returned by IDACreateB.
+ * -----------------------------------------------------------------
+ */
+  SUNDIALS_EXPORT int IDASuperLUMTSetOrderingB(void *ida_mem, int which, 
+					      int ordering_choiceB); 
+
+
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/kinsol/kinsol.h b/include/kinsol/kinsol.h
index 3bace44..4ea5604 100644
--- a/include/kinsol/kinsol.h
+++ b/include/kinsol/kinsol.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:16:17 $
+ * $Revision: 4423 $
+ * $Date: 2015-03-08 17:23:10 -0700 (Sun, 08 Mar 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * KINSOL solver module header file
  * -----------------------------------------------------------------
@@ -18,14 +23,13 @@
 #ifndef _KINSOL_H
 #define _KINSOL_H
 
+#include <stdio.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <stdio.h>
-
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  *              K I N S O L     C O N S T A N T S
@@ -122,12 +126,12 @@ extern "C" {
  * -----------------------------------------------------------------
  * Enumeration for global strategy
  * -----------------------------------------------------------------
- * Choices are KIN_NONE and KIN_LINESEARCH.
- * -----------------------------------------------------------------
  */
   
 #define KIN_NONE       0
 #define KIN_LINESEARCH 1
+#define KIN_PICARD     2
+#define KIN_FP         3
 
 /*
  * =================================================================
@@ -454,6 +458,8 @@ SUNDIALS_EXPORT int KINSetInfoHandlerFn(void *kinmem, KINInfoHandlerFn ihfun, vo
 SUNDIALS_EXPORT int KINSetInfoFile(void *kinmem, FILE *infofp);
 SUNDIALS_EXPORT int KINSetUserData(void *kinmem, void *user_data);
 SUNDIALS_EXPORT int KINSetPrintLevel(void *kinmemm, int printfl);
+SUNDIALS_EXPORT int KINSetMAA(void *kinmem, long int maa);
+  /* SUNDIALS_EXPORT int KINSetAAStopCrit(void *kinmem, booleantype setstop); */
 SUNDIALS_EXPORT int KINSetNumMaxIters(void *kinmem, long int mxiter);
 SUNDIALS_EXPORT int KINSetNoInitSetup(void *kinmem, booleantype noInitSetup);
 SUNDIALS_EXPORT int KINSetNoResMon(void *kinmem, booleantype noNNIResMon);
diff --git a/include/kinsol/kinsol_band.h b/include/kinsol/kinsol_band.h
index 73c3a3d..c79b111 100644
--- a/include/kinsol/kinsol_band.h
+++ b/include/kinsol/kinsol_band.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:16:17 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the KINSOL band linear solver, KINBAND.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _KINBAND_H
 #define _KINBAND_H
 
+#include <kinsol/kinsol_direct.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <kinsol/kinsol_direct.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : KINBand
diff --git a/include/kinsol/kinsol_bbdpre.h b/include/kinsol/kinsol_bbdpre.h
index 6ca9aad..3df7cd3 100644
--- a/include/kinsol/kinsol_bbdpre.h
+++ b/include/kinsol/kinsol_bbdpre.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:16:17 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Alan Hindmarsh, Radu Serban, and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the KINBBDPRE module, for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -98,12 +103,12 @@
 #ifndef _KINBBDPRE_H
 #define _KINBBDPRE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /* KINBBDPRE return values */
 
 #define KINBBDPRE_SUCCESS          0
diff --git a/include/kinsol/kinsol_dense.h b/include/kinsol/kinsol_dense.h
index abf808b..c44196b 100644
--- a/include/kinsol/kinsol_dense.h
+++ b/include/kinsol/kinsol_dense.h
@@ -1,20 +1,28 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:16:17 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the KINSOL dense linear solver module, 
  * KINDENSE.
  * -----------------------------------------------------------------
  */
 
+#include <kinsol/kinsol_direct.h>
+#include <sundials/sundials_dense.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
@@ -22,9 +30,6 @@ extern "C" {
 #ifndef _KINDENSE_H
 #define _KINDENSE_H
 
-#include <kinsol/kinsol_direct.h>
-#include <sundials/sundials_dense.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : KINDense
diff --git a/include/kinsol/kinsol_direct.h b/include/kinsol/kinsol_direct.h
index 953e26f..288ab8a 100644
--- a/include/kinsol/kinsol_direct.h
+++ b/include/kinsol/kinsol_direct.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:16:17 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common header file for the direct linear solvers in KINSOL.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _KINDLS_H
 #define _KINDLS_H
 
+#include <sundials/sundials_direct.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_direct.h>
-#include <sundials/sundials_nvector.h>
-
 /*
  * =================================================================
  *              K I N D I R E C T     C O N S T A N T S
diff --git a/include/kinsol/kinsol_klu.h b/include/kinsol/kinsol_klu.h
new file mode 100644
index 0000000..d023d34
--- /dev/null
+++ b/include/kinsol/kinsol_klu.h
@@ -0,0 +1,111 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the KINKLU linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _KINKLU_H
+#define _KINKLU_H
+
+#include "kinsol/kinsol_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINKLU
+ * -----------------------------------------------------------------
+ * A call to the KINKLU function links the main integrator      
+ * with the KINKLU linear solver module.                        
+ *                                                                
+ * kin_mem is the pointer to integrator memory returned by        
+ *     KINCreate.             
+ *
+ *                                                                
+ * KINKLU returns:                                              
+ *     KINSLU_SUCCESS   = 0  if successful                              
+ *     KINSLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     KINSLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The KLU linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, KINKLU will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int KINKLU(void *kin_mem, int n, int nnz, int sparsetype); 
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to KINKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is KINSLS_SUCCESS = 0, KINSLS_MEM_NULL = -1, 
+ * KINSLS_LMEM_NULL = -2, KINSLS_ILL_INPUT = -3, or KINSLS_MEM_FAIL = -4.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int KINKLUReInit(void *kin_mem, int n, int nnz, 
+				   int reinit_type); 
+
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * KINKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in KINSOL is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int KINKLUSetOrdering(void *kin_mem, int ordering_choice); 
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/kinsol/kinsol_lapack.h b/include/kinsol/kinsol_lapack.h
index bebfc80..03aa4af 100644
--- a/include/kinsol/kinsol_lapack.h
+++ b/include/kinsol/kinsol_lapack.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2008/04/18 19:42:38 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Header file for the KINSOL dense linear solver KINLAPACK.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _KINLAPACK_H
 #define _KINLAPACK_H
 
+#include <kinsol/kinsol_direct.h>
+#include <sundials/sundials_lapack.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <kinsol/kinsol_direct.h>
-#include <sundials/sundials_lapack.h>
-
 /*
  * =================================================================
  *            E X P O R T E D    F U N C T I O N S 
diff --git a/include/kinsol/kinsol_sparse.h b/include/kinsol/kinsol_sparse.h
new file mode 100644
index 0000000..92ca1a4
--- /dev/null
+++ b/include/kinsol/kinsol_sparse.h
@@ -0,0 +1,165 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4268 $
+ * $Date: 2014-11-14 16:37:06 -0800 (Fri, 14 Nov 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the Sparse linear solver module in KINSOL.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _KINSOLSPARSE_H
+#define _KINSOLSPARSE_H
+
+#include "sundials/sundials_sparse.h"
+#include "sundials/sundials_nvector.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * K I N S O L S P A R S E    C O N S T A N T S
+ * =================================================================
+ */
+
+/* 
+ * -----------------------------------------------------------------
+ * KINSLS return values 
+ * -----------------------------------------------------------------
+ */
+
+#define KINSLS_SUCCESS           0
+#define KINSLS_MEM_NULL         -1
+#define KINSLS_LMEM_NULL        -2
+#define KINSLS_ILL_INPUT        -3
+#define KINSLS_MEM_FAIL         -4
+#define KINSLS_JAC_NOSET        -5
+#define KINSLS_PACKAGE_FAIL     -6
+
+/* Additional last_flag values */
+
+#define KINSLS_JACFUNC_UNRECVR  -7
+#define KINSLS_JACFUNC_RECVR    -8
+
+/*
+ * -----------------------------------------------------------------
+ * FUNCTION TYPES
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : KINSlsSparseJacFn
+ * -----------------------------------------------------------------
+ *
+ * A sparse Jacobian approximation function jaceval must be of type 
+ * KINSlsSparseJacFn.
+ * Its parameters are:                     
+ *                                                                
+ * u   is the current value of the dependent variable vector     
+ *                                                                
+ * fval is the residual vector F(tt,yy,yp).                     
+ *                                                                
+ * JacMat is the compressed sparse column matrix (of type SlsMat)
+ *     to be loaded by an KINSlsSparseJacFn routine with an approximation
+ *     to the system Jacobian matrix
+ *            J = dF/dy
+ *     Note that JacMat is NOT preset to zero!
+ *     Matrix data is for the nonzero entries of the Jacobian are stored in
+ *     compressed column format.  Row indices of entries in 
+ *     column j are stored in J->data[colptrs[j]] 
+ *     through J->data[colptrs[j+i]-1]
+ *     and corresponding numerical values of the Jacobian are stored 
+ *     in the same entries of a.
+ * 
+ * user_data is a pointer to user Jacobian data 
+ *                                                                
+ * vtemp1 and vtemp2 are pointers to memory allocated for          
+ *     N_Vectors which can be used by an KINSparseJacFn routine 
+ *     as temporary storage or work space.                     
+ *                                                                
+ * A KINSlsSparseJacFn should return                                
+ *     0 if successful,                      
+ *     1 if successful but the user code indicates a new factorization
+ *       of the Jacobian is required
+ *     a positive int if a recoverable error occurred, or         
+ *     a negative int if a nonrecoverable error occurred.         
+ *
+ * -----------------------------------------------------------------
+ */
+  
+  
+typedef int (*KINSlsSparseJacFn)(N_Vector u, N_Vector fval, 
+		     SlsMat JacMat, void *user_data,
+		     N_Vector vtemp1, N_Vector vtemp2);
+
+/*
+ * =================================================================
+ *            E X P O R T E D    F U N C T I O N S 
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Optional inputs to the KINSPARSE linear solver
+ * -----------------------------------------------------------------
+ * KINSlsSetSparseJacFn specifies the Jacobian approximation
+ * routine to be used for a sparse direct linear solver.
+ *
+ * The return value is one of:
+ *    KINSLS_SUCCESS   if successful
+ *    KINSLS_MEM_NULL  if the IDA memory was NULL
+ *    KINSLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int KINSlsSetSparseJacFn(void *kin_mem_v, KINSlsSparseJacFn jac);
+
+/*
+ * -----------------------------------------------------------------
+ * Optional outputs from the KINSLS linear solver
+ * -----------------------------------------------------------------
+ *
+ * KINSlsGetNumJacEvals returns the number of calls made to the
+ *                      Jacobian evaluation routine jac.
+ * KINSlsGetLastFlag    returns the last error flag set by any of
+ *                      the KINSLS interface functions.
+ *
+ * The return value of KINSlsGet* is one of:
+ *    KINSLS_SUCCESS   if successful
+ *    KINSLS_MEM_NULL  if the KINSOL memory was NULL
+ *    KINSLS_LMEM_NULL if the linear solver memory was NULL
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int KINSlsGetNumJacEvals(void *kin_mem, long int *njevals);
+SUNDIALS_EXPORT int KINSlsGetLastFlag(void *kin_mem, long int *flag);
+
+/*
+ * -----------------------------------------------------------------
+ * The following function returns the name of the constant 
+ * associated with a IDASLS return flag
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT char *KINSlsGetReturnFlagName(long int flag);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/kinsol/kinsol_spbcgs.h b/include/kinsol/kinsol_spbcgs.h
index 1869abe..07cd9ad 100644
--- a/include/kinsol/kinsol_spbcgs.h
+++ b/include/kinsol/kinsol_spbcgs.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the public header file for the KINSOL scaled preconditioned
  * Bi-CGSTAB linear solver module, KINSPBCG.
@@ -18,13 +23,13 @@
 #ifndef _KINSPBCG_H
 #define _KINSPBCG_H
 
+#include <kinsol/kinsol_spils.h>
+#include <sundials/sundials_spbcgs.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <kinsol/kinsol_spils.h>
-#include <sundials/sundials_spbcgs.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : KINSpbcg
diff --git a/include/kinsol/kinsol_spfgmr.h b/include/kinsol/kinsol_spfgmr.h
new file mode 100644
index 0000000..4639a4d
--- /dev/null
+++ b/include/kinsol/kinsol_spfgmr.h
@@ -0,0 +1,90 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL, based on kinsol_spgmr.h
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the KINSOL Scaled Preconditioned GMRES     
+ * linear solver module, KINSPFGMR.    
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _KINSPFGMR_H
+#define _KINSPFGMR_H
+
+#include <kinsol/kinsol_spils.h>
+#include <sundials/sundials_spfgmr.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSpfgmr
+ * -----------------------------------------------------------------
+ * KINSpfgmr links the main KINSOL solver module with the SPFGMR
+ * linear solver module. The routine establishes the inter-module
+ * interface by setting the generic KINSOL pointers linit, lsetup,
+ * lsolve, and lfree to KINSpfgmrInit, KINSpfgmrSetup, KINSpfgmrSolve,
+ * and KINSpfgmrFree, respectively.
+ *
+ *  kinmem  pointer to an internal memory block allocated during a
+ *          prior call to KINCreate
+ *
+ *  maxl  maximum allowable dimension of Krylov subspace (passing
+ *        a value of 0 (zero) will cause the default value
+ *        KINSPILS_MAXL (predefined constant) to be used)
+ *
+ * -----------------------------------------------------------------
+ * KINSpfgmr Return Values
+ * -----------------------------------------------------------------
+ *
+ * The possible return values for the KINSpfgmr subroutine are the
+ * following:
+ *
+ * KINSPILS_SUCCESS : means the KINSPFGMR linear solver module
+ *                    (implementation of the GMRES method) was
+ *                    successfully initialized - allocated system
+ *                    memory and set shared variables to default
+ *                    values [0]
+ *
+ * KINSPILS_MEM_NULL : means a NULL KINSOL memory block pointer was
+ *                     given (must call the KINCreate and KINMalloc
+ *                     memory allocation subroutines prior to
+ *                     calling KINSpfgmr) [-1]
+ *
+ * KINSPILS_MEM_FAIL : means either insufficient system resources
+ *                     were available to allocate memory for the main
+ *                     KINSPFGMR data structure (type KINSpfgmrMemRec),
+ *                     or the SpfgmrMalloc subroutine failed (unable
+ *                     to allocate enough system memory for vector
+ *                     storage and/or the main SPFGMR data structure
+ *                     (type SpfgmrMemRec)) [-4]
+ *
+ * KINSPILS_ILL_INPUT : means a supplied parameter was invalid
+ *                      (check error message) [-3]
+ *
+ * The above constants are defined in kinsol_spils.h
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int KINSpfgmr(void *kinmem, int maxl);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/kinsol/kinsol_spgmr.h b/include/kinsol/kinsol_spgmr.h
index b117046..a6faf68 100644
--- a/include/kinsol/kinsol_spgmr.h
+++ b/include/kinsol/kinsol_spgmr.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the KINSOL Scaled Preconditioned GMRES     
  * linear solver module, KINSPGMR.    
@@ -19,13 +24,13 @@
 #ifndef _KINSPGMR_H
 #define _KINSPGMR_H
 
+#include <kinsol/kinsol_spils.h>
+#include <sundials/sundials_spgmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <kinsol/kinsol_spils.h>
-#include <sundials/sundials_spgmr.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : KINSpgmr
diff --git a/include/kinsol/kinsol_spils.h b/include/kinsol/kinsol_spils.h
index 90ccd2d..2597f48 100644
--- a/include/kinsol/kinsol_spils.h
+++ b/include/kinsol/kinsol_spils.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:16:17 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common header file for the Scaled Preconditioned
  * Iterative Linear Solvers in KINSOL.
@@ -19,13 +24,12 @@
 #ifndef _KINSPILS_H
 #define _KINSPILS_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <sundials/sundials_iterative.h>
 #include <sundials/sundials_nvector.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
 
 /*
  * -----------------------------------------------------------------
diff --git a/include/kinsol/kinsol_sptfqmr.h b/include/kinsol/kinsol_sptfqmr.h
index 1fd3ec2..cda1d89 100644
--- a/include/kinsol/kinsol_sptfqmr.h
+++ b/include/kinsol/kinsol_sptfqmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the public header file for the KINSOL scaled preconditioned
  * TFQMR linear solver module, KINSPTFQMR.
@@ -18,13 +23,13 @@
 #ifndef _KINSPTFQMR_H
 #define _KINSPTFQMR_H
 
+#include <kinsol/kinsol_spils.h>
+#include <sundials/sundials_sptfqmr.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <kinsol/kinsol_spils.h>
-#include <sundials/sundials_sptfqmr.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : KINSptfqmr
diff --git a/include/kinsol/kinsol_superlumt.h b/include/kinsol/kinsol_superlumt.h
new file mode 100644
index 0000000..89cb8e9
--- /dev/null
+++ b/include/kinsol/kinsol_superlumt.h
@@ -0,0 +1,87 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4181 $
+ * $Date: 2014-07-23 12:43:06 -0700 (Wed, 23 Jul 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the KINSuperLUMT linear solver module.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _KINSUPERLUMT_H
+#define _KINSUPERLUMT_H
+
+#include "kinsol/kinsol_sparse.h"
+#include "sundials/sundials_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSuperLUMT
+ * -----------------------------------------------------------------
+ * A call to the KINSuperLUMT function links the main integrator      
+ * with the KINSuperLUMT linear solver module.                        
+ *                                                                
+ * kin_mem is the pointer to integrator memory returned by        
+ *     KINCreate.       
+ *
+ * num_threads is the number of threads that SuperLUMT should invoke         
+ *
+ *                                                                
+ * KINSuperLUMT returns:                                              
+ *     KINSLU_SUCCESS   = 0  if successful                              
+ *     KINSLU_LMEM_FAIL = -1 if there was a memory allocation failure   
+ *     KINSLU_ILL_INPUT = -2 if NVECTOR found incompatible           
+ *                                                                
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation  
+ *       of the NVECTOR package. Therefore, KINSuperLUMT will first
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the functions N_VGetArrayPointer and
+ *       N_VSetArrayPointer exist.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int KINSuperLUMT(void *kin_mem, int num_threads,
+				   int n, int nnz); 
+
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * KINSuperLUMTSetOrdering sets the ordering used by SuperLUMT for 
+ * reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+  SUNDIALS_EXPORT int KINSuperLUMTSetOrdering(void *kin_mem, 
+					      int ordering_choice); 
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/nvector/nvector_openmp.h b/include/nvector/nvector_openmp.h
new file mode 100644
index 0000000..d9cf4c8
--- /dev/null
+++ b/include/nvector/nvector_openmp.h
@@ -0,0 +1,289 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4869 $
+ * $Date: 2016-08-19 10:34:20 -0700 (Fri, 19 Aug 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner and Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * Acknowledgements: This NVECTOR module is based on the NVECTOR 
+ *                   Serial module by Scott D. Cohen, Alan C. 
+ *                   Hindmarsh, Radu Serban, and Aaron Collier 
+ *                   @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the OpenMP implementation of the
+ * NVECTOR module.
+ *
+ * Part I contains declarations specific to the OpenMP
+ * implementation of the supplied NVECTOR module.
+ *
+ * Part II defines accessor macros that allow the user to
+ * efficiently use the type N_Vector without making explicit
+ * references to the underlying data structure.
+ *
+ * Part III contains the prototype for the constructor N_VNew_OpenMP
+ * as well as implementation-specific prototypes for various useful
+ * vector operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic N_Vector structure can be found
+ *     in the header file sundials_nvector.h.
+ *
+ *   - The definition of the type 'realtype' can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type 'booleantype'.
+ *
+ *   - N_Vector arguments to arithmetic vector operations need not
+ *     be distinct. For example, the following call:
+ *
+ *       N_VLinearSum_OpenMP(a,x,b,y,y);
+ *
+ *     (which stores the result of the operation a*x+b*y in y)
+ *     is legal.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _NVECTOR_OPENMP_H
+#define _NVECTOR_OPENMP_H
+
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: OPENMP implementation of N_Vector
+ * -----------------------------------------------------------------
+ */
+
+/* OpenMP implementation of the N_Vector 'content' structure
+   contains the length of the vector, a pointer to an array
+   of 'realtype' components, and a flag indicating ownership of
+   the data */
+
+struct _N_VectorContent_OpenMP {
+  long int length;
+  booleantype own_data;
+  realtype *data;
+  int num_threads;
+};
+
+typedef struct _N_VectorContent_OpenMP *N_VectorContent_OpenMP;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: macros NV_CONTENT_OMP, NV_DATA_OMP, NV_OWN_DATA_OMP,
+ *          NV_LENGTH_OMP, and NV_Ith_OMP
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * N_Vector v;
+ * long int i;
+ *
+ * (1) NV_CONTENT_OMP
+ *
+ *     This routines gives access to the contents of the OpenMP
+ *     vector N_Vector.
+ *
+ *     The assignment v_cont = NV_CONTENT_OMP(v) sets v_cont to be
+ *     a pointer to the OpenMP N_Vector content structure.
+ *
+ * (2) NV_DATA_OMP NV_OWN_DATA_OMP and NV_LENGTH_OMP
+ *
+ *     These routines give access to the individual parts of
+ *     the content structure of a OpenMP N_Vector.
+ *
+ *     The assignment v_data = NV_DATA_OMP(v) sets v_data to be
+ *     a pointer to the first component of v. The assignment
+ *     NV_DATA_OMP(v) = data_V sets the component array of v to
+ *     be data_v by storing the pointer data_v.
+ *
+ *     The assignment v_len = NV_LENGTH_OMP(v) sets v_len to be
+ *     the length of v. The call NV_LENGTH_OMP(v) = len_v sets
+ *     the length of v to be len_v.
+ *
+ * (3) NV_Ith_OMP
+ *
+ *     In the following description, the components of an
+ *     N_Vector are numbered 0..n-1, where n is the length of v.
+ *
+ *     The assignment r = NV_Ith_OMP(v,i) sets r to be the value of
+ *     the ith component of v. The assignment NV_Ith_OMP(v,i) = r
+ *     sets the value of the ith component of v to be r.
+ *
+ * Note: When looping over the components of an N_Vector v, it is
+ * more efficient to first obtain the component array via
+ * v_data = NV_DATA_OMP(v) and then access v_data[i] within the
+ * loop than it is to use NV_Ith_OMP(v,i) within the loop.
+ * -----------------------------------------------------------------
+ */
+
+#define NV_CONTENT_OMP(v)  ( (N_VectorContent_OpenMP)(v->content) )
+
+#define NV_LENGTH_OMP(v)   ( NV_CONTENT_OMP(v)->length )
+
+#define NV_NUM_THREADS_OMP(v)   ( NV_CONTENT_OMP(v)->num_threads )
+
+#define NV_OWN_DATA_OMP(v) ( NV_CONTENT_OMP(v)->own_data )
+
+#define NV_DATA_OMP(v)     ( NV_CONTENT_OMP(v)->data )
+
+#define NV_Ith_OMP(v,i)    ( NV_DATA_OMP(v)[i] )
+
+/*
+ * -----------------------------------------------------------------
+ * PART III: functions exported by nvector_OpenMP
+ * 
+ * CONSTRUCTORS:
+ *    N_VNew_OpenMP
+ *    N_VNewEmpty_OpenMP
+ *    N_VMake_OpenMP
+ *    N_VCloneVectorArray_OpenMP
+ *    N_VCloneVectorArrayEmpty_OpenMP
+ * DESTRUCTORS:
+ *    N_VDestroy_OpenMP
+ *    N_VDestroyVectorArray_OpenMP
+ * OTHER:
+ *    N_VGetLength_OpenMP
+ *    N_VPrint_OpenMP
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNew_OpenMP
+ * -----------------------------------------------------------------
+ * This function creates and allocates memory for a OpenMP vector.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNew_OpenMP(long int vec_length, int num_threads);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNewEmpty_OpenMP
+ * -----------------------------------------------------------------
+ * This function creates a new OpenMP N_Vector with an empty (NULL)
+ * data array.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNewEmpty_OpenMP(long int vec_length, int num_threads);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VMake_OpenMP
+ * -----------------------------------------------------------------
+ * This function creates and allocates memory for a OpenMP vector
+ * with a user-supplied data array.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VMake_OpenMP(long int vec_length, realtype *v_data, int num_threads);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArray_OpenMP
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' OPENMP vectors by
+ * cloning a given vector w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_OpenMP(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArrayEmpty_OpenMP
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' OPENMP vectors each
+ * with an empty (NULL) data array by cloning w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_OpenMP(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VDestroyVectorArray_OpenMP
+ * -----------------------------------------------------------------
+ * This function frees an array of OPENMP vectors created with 
+ * N_VCloneVectorArray_OpenMP or N_VCloneVectorArrayEmpty_OpenMP.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VDestroyVectorArray_OpenMP(N_Vector *vs, int count);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VGetLength_OpenMP
+ * -----------------------------------------------------------------
+ * This function returns number of vector elements.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT long int N_VGetLength_OpenMP(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VPrint_OpenMP
+ * -----------------------------------------------------------------
+ * This function prints the content of a OpenMP vector to stdout.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VPrint_OpenMP(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * OpenMP implementations of various useful vector operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_OpenMP(N_Vector v);
+SUNDIALS_EXPORT N_Vector N_VCloneEmpty_OpenMP(N_Vector w);
+SUNDIALS_EXPORT N_Vector N_VClone_OpenMP(N_Vector w);
+SUNDIALS_EXPORT void N_VDestroy_OpenMP(N_Vector v);
+SUNDIALS_EXPORT void N_VSpace_OpenMP(N_Vector v, long int *lrw, long int *liw);
+SUNDIALS_EXPORT realtype *N_VGetArrayPointer_OpenMP(N_Vector v);
+SUNDIALS_EXPORT void N_VSetArrayPointer_OpenMP(realtype *v_data, N_Vector v);
+SUNDIALS_EXPORT void N_VLinearSum_OpenMP(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VConst_OpenMP(realtype c, N_Vector z);
+SUNDIALS_EXPORT void N_VProd_OpenMP(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VDiv_OpenMP(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VScale_OpenMP(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAbs_OpenMP(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VInv_OpenMP(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAddConst_OpenMP(N_Vector x, realtype b, N_Vector z);
+SUNDIALS_EXPORT realtype N_VDotProd_OpenMP(N_Vector x, N_Vector y);
+SUNDIALS_EXPORT realtype N_VMaxNorm_OpenMP(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWrmsNorm_OpenMP(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VWrmsNormMask_OpenMP(N_Vector x, N_Vector w, N_Vector id);
+SUNDIALS_EXPORT realtype N_VMin_OpenMP(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWL2Norm_OpenMP(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VL1Norm_OpenMP(N_Vector x);
+SUNDIALS_EXPORT void N_VCompare_OpenMP(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VInvTest_OpenMP(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VConstrMask_OpenMP(N_Vector c, N_Vector x, N_Vector m);
+SUNDIALS_EXPORT realtype N_VMinQuotient_OpenMP(N_Vector num, N_Vector denom);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/nvector/nvector_parallel.h b/include/nvector/nvector_parallel.h
index f8a006c..e725451 100644
--- a/include/nvector/nvector_parallel.h
+++ b/include/nvector/nvector_parallel.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4867 $
+ * $Date: 2016-08-19 10:05:14 -0700 (Fri, 19 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the main header file for the MPI-enabled implementation
  * of the NVECTOR module.
@@ -49,14 +54,13 @@
 #ifndef _NVECTOR_PARALLEL_H
 #define _NVECTOR_PARALLEL_H
 
+#include <mpi.h>
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <mpi.h>
-
-#include <sundials/sundials_nvector.h>
-
 
 /*
  * -----------------------------------------------------------------
@@ -189,6 +193,8 @@ typedef struct _N_VectorContent_Parallel *N_VectorContent_Parallel;
  *    N_VDestroy_Parallel
  *    N_VDestroyVectorArray_Parallel
  * OTHER:
+ *    N_VGetLength_Parallel
+ *    N_VGetLocalLength_Parallel
  *    N_VPrint_Parallel
  * -----------------------------------------------------------------
  */
@@ -202,8 +208,8 @@ typedef struct _N_VectorContent_Parallel *N_VectorContent_Parallel;
  */
 
 SUNDIALS_EXPORT N_Vector N_VNew_Parallel(MPI_Comm comm, 
-					 long int local_length,
-					 long int global_length);
+                                         long int local_length,
+                                         long int global_length);
 
 /*
  * -----------------------------------------------------------------
@@ -215,8 +221,8 @@ SUNDIALS_EXPORT N_Vector N_VNew_Parallel(MPI_Comm comm,
  */
 
 SUNDIALS_EXPORT N_Vector N_VNewEmpty_Parallel(MPI_Comm comm, 
-					      long int local_length,
-					      long int global_length);
+                                              long int local_length,
+                                              long int global_length);
 
 /*
  * -----------------------------------------------------------------
@@ -228,9 +234,9 @@ SUNDIALS_EXPORT N_Vector N_VNewEmpty_Parallel(MPI_Comm comm,
  */
 
 SUNDIALS_EXPORT N_Vector N_VMake_Parallel(MPI_Comm comm, 
-					  long int local_length,
-					  long int global_length,
-					  realtype *v_data);
+                                          long int local_length,
+                                          long int global_length,
+                                          realtype *v_data);
 
 /*
  * -----------------------------------------------------------------
@@ -267,6 +273,28 @@ SUNDIALS_EXPORT void N_VDestroyVectorArray_Parallel(N_Vector *vs, int count);
 
 /*
  * -----------------------------------------------------------------
+ * Function : N_VGetLength_Parallel
+ * -----------------------------------------------------------------
+ * This function returns number of vector elements (global vector 
+ * length). It returns locally stored integer, and is therefore 
+ * a local call.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT long int N_VGetLength_Parallel(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VGetLocalLength_Parallel
+ * -----------------------------------------------------------------
+ * This function returns local vector length.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT long int N_VGetLocalLength_Parallel(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
  * Function : N_VPrint_Parallel
  * -----------------------------------------------------------------
  * This function prints the content of a parallel vector to stdout.
@@ -281,6 +309,7 @@ SUNDIALS_EXPORT void N_VPrint_Parallel(N_Vector v);
  * -----------------------------------------------------------------
  */
 
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Parallel(N_Vector v);
 SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Parallel(N_Vector w);
 SUNDIALS_EXPORT N_Vector N_VClone_Parallel(N_Vector w);
 SUNDIALS_EXPORT void N_VDestroy_Parallel(N_Vector v);
diff --git a/include/nvector/nvector_parhyp.h b/include/nvector/nvector_parhyp.h
new file mode 100644
index 0000000..e3777ca
--- /dev/null
+++ b/include/nvector/nvector_parhyp.h
@@ -0,0 +1,237 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Jean M. Sexton @ SMU
+ *                Slaven Peles @ LLNL
+ * ----------------------------------------------------------------- 
+ * Based on work by: Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
+ *                   and Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the main header file for the MPI-enabled implementation
+ * of the NVECTOR module.
+ *
+ * Part I contains declarations specific to the parallel
+ * implementation of the supplied NVECTOR module.
+ *
+ * Part II contains the prototype for the constructor
+ * N_VNew_ParHyp as well as implementation-specific prototypes
+ * for various useful vector operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic N_Vector structure can be
+ *     found in the header file sundials_nvector.h.
+ *
+ *   - The definition of the type realtype can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type booleantype.
+ *
+ *   - N_Vector arguments to arithmetic vector operations need not
+ *     be distinct. For example, the following call:
+ *
+ *        N_VLinearSum_ParHyp(a,x,b,y,y);
+ *
+ *     (which stores the result of the operation a*x+b*y in y)
+ *     is legal.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _NVECTOR_PARHYP_H
+#define _NVECTOR_PARHYP_H
+
+#include <mpi.h>
+#include <sundials/sundials_nvector.h>
+
+/* hypre header files */
+#include <_hypre_parcsr_mv.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: PARALLEL implementation of N_Vector               
+ * -----------------------------------------------------------------
+ */
+
+/* define MPI data types */
+
+#if defined(SUNDIALS_SINGLE_PRECISION)
+  #define PVEC_REAL_MPI_TYPE MPI_FLOAT
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+  #define PVEC_REAL_MPI_TYPE MPI_DOUBLE
+#elif defined(SUNDIALS_EXTENDED_PRECISION)
+  #define PVEC_REAL_MPI_TYPE MPI_LONG_DOUBLE
+#endif
+
+#define PVEC_INTEGER_MPI_TYPE MPI_LONG
+
+/* 
+ * Parallel implementation of the N_Vector 'content' structure
+ * contains the global and local lengths of the vector, a pointer
+ * to an array of 'realtype components', the MPI communicator,
+ * and a flag indicating ownership of the data. 
+ */
+struct _N_VectorContent_ParHyp {
+  long int local_length;      /* local vector length         */
+  long int global_length;     /* global vector length        */
+  booleantype own_parvector;  /* ownership of HYPRE vector   */
+  MPI_Comm comm;              /* pointer to MPI communicator */
+
+  hypre_ParVector *x;   /* The actual hypre_ParVector object */
+};
+
+typedef struct _N_VectorContent_ParHyp *N_VectorContent_ParHyp;
+
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by nvector_ParHyp
+ * 
+ * CONSTRUCTORS:
+ *    N_VNewEmpty_ParHyp
+ *    N_VMake_ParHyp
+ *    N_VCloneVectorArray_ParHyp
+ *    N_VCloneVectorArrayEmpty_ParHyp
+ * DESTRUCTORS:
+ *    N_VDestroy_ParHyp
+ *    N_VDestroyVectorArray_ParHyp
+ * ACCESSOR FUNCTIONS:
+ *    N_VGetVector_ParHyp
+ * OTHER:
+ *    N_VPrint_ParHyp
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNewEmpty_ParHyp
+ * -----------------------------------------------------------------
+ * This function creates a new hypre vector wrapper without the 
+ * hypre vector itself.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, 
+                                            long int local_length,
+                                            long int global_length);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VMake_ParHyp
+ * -----------------------------------------------------------------
+ * This function creates a hypre vector wrapper around user-supplied 
+ * hypre vector.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VMake_ParHyp(hypre_ParVector *x);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArray_ParHyp
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' N_Vectors by cloning a 
+ * given vector w. Both, the wrapper and the underlying hypre vector
+ * are cloned.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_ParHyp(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArrayEmpty_ParHyp
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' empty hypre vector
+ * wrappers by cloning w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_ParHyp(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VDestroyVectorArray_ParHyp
+ * -----------------------------------------------------------------
+ * This function frees an array of N_Vector created with 
+ * N_VCloneVectorArray_ParHyp or N_VCloneVectorArrayEmpty_ParHyp.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VDestroyVectorArray_ParHyp(N_Vector *vs, int count);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VGetVector_ParHyp
+ * -----------------------------------------------------------------
+ * Extracts underlying HYPRE vector.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT hypre_ParVector *N_VGetVector_ParHyp(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VPrint_ParHyp
+ * -----------------------------------------------------------------
+ * This function prints the content of a parallel vector to stdout.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VPrint_ParHyp(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * parallel implementations of the vector operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_ParHyp(N_Vector v);
+SUNDIALS_EXPORT N_Vector N_VCloneEmpty_ParHyp(N_Vector w);
+SUNDIALS_EXPORT N_Vector N_VClone_ParHyp(N_Vector w);
+SUNDIALS_EXPORT void N_VDestroy_ParHyp(N_Vector v);
+SUNDIALS_EXPORT void N_VSpace_ParHyp(N_Vector v, long int *lrw, long int *liw);
+SUNDIALS_EXPORT realtype *N_VGetArrayPointer_ParHyp(N_Vector v);
+SUNDIALS_EXPORT void N_VSetArrayPointer_ParHyp(realtype *v_data, N_Vector v);
+SUNDIALS_EXPORT void N_VLinearSum_ParHyp(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VConst_ParHyp(realtype c, N_Vector z);
+SUNDIALS_EXPORT void N_VProd_ParHyp(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VDiv_ParHyp(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VScale_ParHyp(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAbs_ParHyp(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VInv_ParHyp(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAddConst_ParHyp(N_Vector x, realtype b, N_Vector z);
+SUNDIALS_EXPORT realtype N_VDotProd_ParHyp(N_Vector x, N_Vector y);
+SUNDIALS_EXPORT realtype N_VMaxNorm_ParHyp(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWrmsNorm_ParHyp(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VWrmsNormMask_ParHyp(N_Vector x, N_Vector w, N_Vector id);
+SUNDIALS_EXPORT realtype N_VMin_ParHyp(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWL2Norm_ParHyp(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VL1Norm_ParHyp(N_Vector x);
+SUNDIALS_EXPORT void N_VCompare_ParHyp(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VInvTest_ParHyp(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VConstrMask_ParHyp(N_Vector c, N_Vector x, N_Vector m);
+SUNDIALS_EXPORT realtype N_VMinQuotient_ParHyp(N_Vector num, N_Vector denom);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/nvector/nvector_petsc.h b/include/nvector/nvector_petsc.h
new file mode 100644
index 0000000..0690129
--- /dev/null
+++ b/include/nvector/nvector_petsc.h
@@ -0,0 +1,240 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision:$
+ * $Date:$
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the main header file for the PETSc vector wrapper 
+ * for NVECTOR module.
+ *
+ * Part I contains declarations specific to the PETSc vector wrapper
+ * implementation.
+ *
+ * Part II contains the prototype for the constructor
+ * N_VMake_Petsc as well as PETSc-specific prototypes
+ * for various useful vector operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic N_Vector structure can be
+ *     found in the header file sundials_nvector.h.
+ *
+ *   - The definition of the type realtype can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     build configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type booleantype.
+ *
+ *   - N_Vector arguments to arithmetic vector operations need not
+ *     be distinct. For example, the following call:
+ *
+ *        N_VLinearSum_Petsc(a,x,b,y,y);
+ *
+ *     (which stores the result of the operation a*x+b*y in y)
+ *     is legal.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _NVECTOR_PETSC_H
+#define _NVECTOR_PETSC_H
+
+#include <mpi.h>
+#include <petscvec.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: PARALLEL implementation of N_Vector               
+ * -----------------------------------------------------------------
+ */
+
+/* define MPI data types */
+
+#if defined(SUNDIALS_SINGLE_PRECISION)
+
+#define PVEC_REAL_MPI_TYPE MPI_FLOAT
+
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+
+#define PVEC_REAL_MPI_TYPE MPI_DOUBLE
+
+#elif defined(SUNDIALS_EXTENDED_PRECISION)
+
+#define PVEC_REAL_MPI_TYPE MPI_LONG_DOUBLE
+
+#endif
+
+#define PVEC_INTEGER_MPI_TYPE MPI_LONG
+
+/* parallel implementation of the N_Vector 'content' structure
+   contains the global and local lengths of the vector, a pointer
+   to the underlying PETSc vector, the MPI communicator,
+   and a flag indicating ownership of the PETSc vector */
+
+struct _N_VectorContent_Petsc {
+  long int local_length;   /* copy of local vector length  */
+  long int global_length;  /* copy of global vector length */
+  booleantype own_data;    /* ownership of data            */
+  Vec *pvec;               /* pointer to PETSc vector      */
+  MPI_Comm comm;           /* copy of MPI communicator     */
+};
+
+typedef struct _N_VectorContent_Petsc *N_VectorContent_Petsc;
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: functions exported by nvector_Petsc
+ * 
+ * CONSTRUCTORS:
+ *    N_VNewEmpty_Petsc
+ *    N_VMake_Petsc
+ *    N_VCloneVectorArray_Petsc
+ *    N_VCloneVectorArrayEmpty_Petsc
+ * DESTRUCTORS:
+ *    N_VDestroyVectorArray_Petsc
+ * OTHER:
+ *    N_VGetVector_Petsc
+ *    N_VPrint_Petsc
+ * -----------------------------------------------------------------
+ */
+
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNewEmpty_Petsc
+ * -----------------------------------------------------------------
+ * This function creates a new N_Vector wrapper around an empty
+ * (NULL) PETSc vector.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNewEmpty_Petsc(MPI_Comm comm, 
+                                           long int local_length,
+                                           long int global_length);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VMake_Petsc
+ * -----------------------------------------------------------------
+ * This function is not supported for PETSc vector wrapper.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VMake_Petsc(Vec *v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VGetArrayPointer_Petsc
+ * -----------------------------------------------------------------
+ * This function is not supported for PETSc vector wrapper.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT realtype *N_VGetArrayPointer_Petsc(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArray_Petsc
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' PARALLEL vectors by
+ * cloning a given vector w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_Petsc(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArrayEmpty_Petsc
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' PARALLEL vectors each 
+ * with an empty (NULL) data array by cloning w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_Petsc(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VDestroyVectorArray_Petsc
+ * -----------------------------------------------------------------
+ * This function frees an array of N_Vector created with 
+ * N_VCloneVectorArray_Petsc or N_VCloneVectorArrayEmpty_Petsc.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VDestroyVectorArray_Petsc(N_Vector *vs, int count);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VGetVector_Petsc
+ * -----------------------------------------------------------------
+ * Extracts PETSc vector from N_Vector wrapper.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT Vec *N_VGetVector_Petsc(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VPrint_Petsc
+ * -----------------------------------------------------------------
+ * This function prints the content of a parallel vector to stdout.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VPrint_Petsc(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * PETSc implementations of the vector operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Petsc(N_Vector v);
+SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Petsc(N_Vector w);
+SUNDIALS_EXPORT N_Vector N_VClone_Petsc(N_Vector w);
+SUNDIALS_EXPORT void N_VDestroy_Petsc(N_Vector v);
+SUNDIALS_EXPORT void N_VSpace_Petsc(N_Vector v, long int *lrw, long int *liw);
+SUNDIALS_EXPORT void N_VSetArrayPointer_Petsc(realtype *v_data, N_Vector v);
+SUNDIALS_EXPORT void N_VLinearSum_Petsc(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VConst_Petsc(realtype c, N_Vector z);
+SUNDIALS_EXPORT void N_VProd_Petsc(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VDiv_Petsc(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VScale_Petsc(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAbs_Petsc(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VInv_Petsc(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAddConst_Petsc(N_Vector x, realtype b, N_Vector z);
+SUNDIALS_EXPORT realtype N_VDotProd_Petsc(N_Vector x, N_Vector y);
+SUNDIALS_EXPORT realtype N_VMaxNorm_Petsc(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWrmsNorm_Petsc(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VWrmsNormMask_Petsc(N_Vector x, N_Vector w, N_Vector id);
+SUNDIALS_EXPORT realtype N_VMin_Petsc(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWL2Norm_Petsc(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VL1Norm_Petsc(N_Vector x);
+SUNDIALS_EXPORT void N_VCompare_Petsc(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VInvTest_Petsc(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VConstrMask_Petsc(N_Vector c, N_Vector x, N_Vector m);
+SUNDIALS_EXPORT realtype N_VMinQuotient_Petsc(N_Vector num, N_Vector denom);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _NVECTOR_PETSC_H */
diff --git a/include/nvector/nvector_pthreads.h b/include/nvector/nvector_pthreads.h
new file mode 100644
index 0000000..e73d839
--- /dev/null
+++ b/include/nvector/nvector_pthreads.h
@@ -0,0 +1,310 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4869 $
+ * $Date: 2016-08-19 10:34:20 -0700 (Fri, 19 Aug 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner @ LLNL
+ * -----------------------------------------------------------------
+ * Acknowledgements: This NVECTOR module is based on the NVECTOR 
+ *                   Serial module by Scott D. Cohen, Alan C. 
+ *                   Hindmarsh, Radu Serban, and Aaron Collier 
+ *                   @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the header file for the POSIX Threads (Pthreads) 
+ * implementation of the NVECTOR module using LOCAL data structs
+ * to share data between threads.
+ *
+ * Part I contains declarations specific to the pthreads
+ * implementation of the supplied NVECTOR module.
+ *
+ * Part II defines accessor macros that allow the user to
+ * efficiently use the type N_Vector without making explicit
+ * references to the underlying data structure.
+ *
+ * Part III contains the prototype for the constructor N_VNew_Pthreads
+ * as well as implementation-specific prototypes for various useful
+ * vector operations.
+ *
+ * Notes:
+ *
+ *   - The definition of the generic N_Vector structure can be found
+ *     in the header file sundials_nvector.h.
+ *
+ *   - The definition of the type 'realtype' can be found in the
+ *     header file sundials_types.h, and it may be changed (at the 
+ *     configuration stage) according to the user's needs. 
+ *     The sundials_types.h file also contains the definition
+ *     for the type 'booleantype'.
+ *
+ *   - N_Vector arguments to arithmetic vector operations need not
+ *     be distinct. For example, the following call:
+ *
+ *       N_VLinearSum_Pthreads(a,x,b,y,y);
+ *
+ *     (which stores the result of the operation a*x+b*y in y)
+ *     is legal.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _NVECTOR_PTHREADS_H
+#define _NVECTOR_PTHREADS_H
+
+#include <pthread.h>
+#include <sundials/sundials_nvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * PART I: PTHREADS implementation of N_Vector
+ * -----------------------------------------------------------------
+ */
+
+/* pthreads implementation of the N_Vector 'content' structure
+   contains the length of the vector, number of threads, a pointer 
+   to an array of 'realtype' components, and a flag indicating 
+   ownership of the data */
+
+struct _N_VectorContent_Pthreads {
+  long int length;
+  booleantype own_data;
+  realtype *data;
+  int num_threads;
+};
+
+typedef struct _N_VectorContent_Pthreads *N_VectorContent_Pthreads;
+
+
+/* structure to allow threads to share data */
+struct _Pthreads_Data{
+  long int start;                /* starting index for loop  */ 
+  long int end;                  /* ending index for loop    */
+  realtype c1, c2;               /* scaler values            */
+  realtype *v1, *v2, *v3;        /* vector data              */
+  realtype *global_val;          /* shared global variable   */
+  pthread_mutex_t *global_mutex; /* lock for shared variable */ 
+};
+
+typedef struct _Pthreads_Data Pthreads_Data;
+
+
+/*
+ * -----------------------------------------------------------------
+ * PART II: macros NV_CONTENT_PT, NV_DATA_PT, NV_OWN_DATA_PT,
+ *          NV_LENGTH_PT, and NV_Ith_PT
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * N_Vector v;
+ * long int i;
+ *
+ * (1) NV_CONTENT_PT
+ *
+ *     This routines gives access to the contents of the pthreads
+ *     vector N_Vector.
+ *
+ *     The assignment v_cont = NV_CONTENT_PT(v) sets v_cont to be
+ *     a pointer to the pthreads N_Vector content structure.
+ *
+ * (2) NV_DATA_PT NV_OWN_DATA_PT NV_LENGTH_PT and NV_NUM_THREADS_PT
+ *
+ *     These routines give access to the individual parts of
+ *     the content structure of a pthreads N_Vector.
+ *
+ *     The assignment v_data = NV_DATA_PT(v) sets v_data to be
+ *     a pointer to the first component of v. The assignment
+ *     NV_DATA_PT(v) = data_V sets the component array of v to
+ *     be data_v by storing the pointer data_v.
+ *
+ *     The assignment v_len = NV_LENGTH_PT(v) sets v_len to be
+ *     the length of v. The call NV_LENGTH_PT(v) = len_v sets
+ *     the length of v to be len_v.
+ *
+ *     The assignment v_nthreads = NV_NUM_THREADS(v) sets v_nthreads
+ *     to be the number of threads that operate on v. The call 
+ *     NV_NUM_THREADS(v) = nthreads_v sets the number of threads that 
+ *     operate on v to be nthreads_v.
+ *
+ * (3) NV_Ith_PT
+ *
+ *     In the following description, the components of an
+ *     N_Vector are numbered 0..n-1, where n is the length of v.
+ *
+ *     The assignment r = NV_Ith_PT(v,i) sets r to be the value of
+ *     the ith component of v. The assignment NV_Ith_PT(v,i) = r
+ *     sets the value of the ith component of v to be r.
+ *
+ * Note: When looping over the components of an N_Vector v, it is
+ * more efficient to first obtain the component array via
+ * v_data = NV_DATA_PT(v) and then access v_data[i] within the
+ * loop than it is to use NV_Ith_PT(v,i) within the loop.
+ * -----------------------------------------------------------------
+ */
+
+#define NV_CONTENT_PT(v)       ( (N_VectorContent_Pthreads)(v->content) )
+
+#define NV_LENGTH_PT(v)        ( NV_CONTENT_PT(v)->length )
+
+#define NV_NUM_THREADS_PT(v)   ( NV_CONTENT_PT(v)->num_threads )
+
+#define NV_OWN_DATA_PT(v)      ( NV_CONTENT_PT(v)->own_data )
+
+#define NV_DATA_PT(v)          ( NV_CONTENT_PT(v)->data )
+
+#define NV_Ith_PT(v,i)         ( NV_DATA_PT(v)[i] )
+
+/*
+ * -----------------------------------------------------------------
+ * PART III: functions exported by nvector_Pthreads
+ * 
+ * CONSTRUCTORS:
+ *    N_VNew_Pthreads
+ *    N_VNewEmpty_Pthreads
+ *    N_VMake_Pthreads
+ *    N_VCloneVectorArray_Pthreads
+ *    N_VCloneVectorArrayEmpty_Pthreads
+ * DESTRUCTORS:
+ *    N_VDestroy_Pthreads
+ *    N_VDestroyVectorArray_Pthreads
+ * OTHER:
+ *    N_VGetLength_Pthreads
+ *    N_VPrint_Pthreads
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNew_Pthreads
+ * -----------------------------------------------------------------
+ * This function creates and allocates memory for a pthreads vector.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNew_Pthreads(long int vec_length, int n_threads);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VNewEmpty_Pthreads
+ * -----------------------------------------------------------------
+ * This function creates a new pthreads N_Vector with an empty (NULL)
+ * data array.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VNewEmpty_Pthreads(long int vec_length, int n_threads);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VMake_Pthreads
+ * -----------------------------------------------------------------
+ * This function creates and allocates memory for a pthreads vector
+ * with a user-supplied data array.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector N_VMake_Pthreads(long int vec_length, int n_threads, realtype *v_data);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArray_Pthreads
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' PTHREADS vectors by
+ * cloning a given vector w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_Pthreads(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VCloneVectorArrayEmpty_Pthreads
+ * -----------------------------------------------------------------
+ * This function creates an array of 'count' PTHREADS vectors each
+ * with an empty (NULL) data array by cloning w.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_Pthreads(int count, N_Vector w);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VDestroyVectorArray_Pthreads
+ * -----------------------------------------------------------------
+ * This function frees an array of PTHREADS vectors created with 
+ * N_VCloneVectorArray_Pthreads or N_VCloneVectorArrayEmpty_Pthreads.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VDestroyVectorArray_Pthreads(N_Vector *vs, int count);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VGetLength_Pthreads
+ * -----------------------------------------------------------------
+ * This function returns number of vector elements.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT long int N_VGetLength_Pthreads(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : N_VPrint_Pthreads
+ * -----------------------------------------------------------------
+ * This function prints the content of a pthreads vector to stdout.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void N_VPrint_Pthreads(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
+ * pthreads implementations of various useful vector operations
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Pthreads(N_Vector v);
+SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Pthreads(N_Vector w);
+SUNDIALS_EXPORT N_Vector N_VClone_Pthreads(N_Vector w);
+SUNDIALS_EXPORT void N_VDestroy_Pthreads(N_Vector v);
+SUNDIALS_EXPORT void N_VSpace_Pthreads(N_Vector v, long int *lrw, long int *liw);
+SUNDIALS_EXPORT realtype *N_VGetArrayPointer_Pthreads(N_Vector v);
+SUNDIALS_EXPORT void N_VSetArrayPointer_Pthreads(realtype *v_data, N_Vector v);
+SUNDIALS_EXPORT void N_VLinearSum_Pthreads(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VConst_Pthreads(realtype c, N_Vector z);
+SUNDIALS_EXPORT void N_VProd_Pthreads(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VDiv_Pthreads(N_Vector x, N_Vector y, N_Vector z);
+SUNDIALS_EXPORT void N_VScale_Pthreads(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAbs_Pthreads(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VInv_Pthreads(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT void N_VAddConst_Pthreads(N_Vector x, realtype b, N_Vector z);
+SUNDIALS_EXPORT realtype N_VDotProd_Pthreads(N_Vector x, N_Vector y);
+SUNDIALS_EXPORT realtype N_VMaxNorm_Pthreads(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWrmsNorm_Pthreads(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VWrmsNormMask_Pthreads(N_Vector x, N_Vector w, N_Vector id);
+SUNDIALS_EXPORT realtype N_VMin_Pthreads(N_Vector x);
+SUNDIALS_EXPORT realtype N_VWL2Norm_Pthreads(N_Vector x, N_Vector w);
+SUNDIALS_EXPORT realtype N_VL1Norm_Pthreads(N_Vector x);
+SUNDIALS_EXPORT void N_VCompare_Pthreads(realtype c, N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VInvTest_Pthreads(N_Vector x, N_Vector z);
+SUNDIALS_EXPORT booleantype N_VConstrMask_Pthreads(N_Vector c, N_Vector x, N_Vector m);
+SUNDIALS_EXPORT realtype N_VMinQuotient_Pthreads(N_Vector num, N_Vector denom);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/nvector/nvector_serial.h b/include/nvector/nvector_serial.h
index 4301a68..a943707 100644
--- a/include/nvector/nvector_serial.h
+++ b/include/nvector/nvector_serial.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4867 $
+ * $Date: 2016-08-19 10:05:14 -0700 (Fri, 19 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the serial implementation of the
  * NVECTOR module.
@@ -49,12 +54,12 @@
 #ifndef _NVECTOR_SERIAL_H
 #define _NVECTOR_SERIAL_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 /*
  * -----------------------------------------------------------------
  * PART I: SERIAL implementation of N_Vector
@@ -147,6 +152,7 @@ typedef struct _N_VectorContent_Serial *N_VectorContent_Serial;
  *    N_VDestroy_Serial
  *    N_VDestroyVectorArray_Serial
  * OTHER:
+ *    N_VGetLength_Serial
  *    N_VPrint_Serial
  * -----------------------------------------------------------------
  */
@@ -218,6 +224,16 @@ SUNDIALS_EXPORT void N_VDestroyVectorArray_Serial(N_Vector *vs, int count);
 
 /*
  * -----------------------------------------------------------------
+ * Function : N_VGetLength_Serial
+ * -----------------------------------------------------------------
+ * This function returns number of vector elements.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT long int N_VGetLength_Serial(N_Vector v);
+
+/*
+ * -----------------------------------------------------------------
  * Function : N_VPrint_Serial
  * -----------------------------------------------------------------
  * This function prints the content of a serial vector to stdout.
@@ -232,6 +248,7 @@ SUNDIALS_EXPORT void N_VPrint_Serial(N_Vector v);
  * -----------------------------------------------------------------
  */
 
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Serial(N_Vector v);
 SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Serial(N_Vector w);
 SUNDIALS_EXPORT N_Vector N_VClone_Serial(N_Vector w);
 SUNDIALS_EXPORT void N_VDestroy_Serial(N_Vector v);
diff --git a/include/sundials/sundials_band.h b/include/sundials/sundials_band.h
index a4d9109..e6593c0 100644
--- a/include/sundials/sundials_band.h
+++ b/include/sundials/sundials_band.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:17:18 $
+ * $Revision: 4780 $
+ * $Date: 2016-06-22 17:28:19 -0700 (Wed, 22 Jun 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for a generic BAND linear solver
  * package, based on the DlsMat type defined in sundials_direct.h.
@@ -24,12 +29,12 @@
 #ifndef _SUNDIALS_BAND_H
 #define _SUNDIALS_BAND_H
 
+#include <sundials/sundials_direct.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_direct.h>
-
 /*
  * -----------------------------------------------------------------
  * Function : BandGBTRF
@@ -71,8 +76,8 @@ extern "C" {
  * handled by the BandGBTRF routine.
  *
  * BandGBTRF is only a wrapper around bandGBTRF. All work is done
- * in bandGBTRF works directly on the data in the DlsMat A (i.e.,
- * the field cols).
+ * in bandGBTRF, which works directly on the data in the DlsMat A
+ * (i.e. in the field A->cols).
  * -----------------------------------------------------------------
  */
 
@@ -93,12 +98,13 @@ SUNDIALS_EXPORT long int bandGBTRF(realtype **a, long int n, long int mu, long i
  * did not fail.
  *
  * BandGBTRS is only a wrapper around bandGBTRS which does all the
- * work directly on the data in the DlsMat A (i.e., the field cols).
+ * work directly on the data in the DlsMat A (i.e. in A->cols).
  * -----------------------------------------------------------------
  */
 
 SUNDIALS_EXPORT void BandGBTRS(DlsMat A, long int *p, realtype *b);
-SUNDIALS_EXPORT void bandGBTRS(realtype **a, long int n, long int smu, long int ml, long int *p, realtype *b);
+SUNDIALS_EXPORT void bandGBTRS(realtype **a, long int n, long int smu,
+                               long int ml, long int *p, realtype *b);
 
 /*
  * -----------------------------------------------------------------
@@ -111,12 +117,13 @@ SUNDIALS_EXPORT void bandGBTRS(realtype **a, long int n, long int smu, long int
  * band matrix B.
  * 
  * BandCopy is a wrapper around bandCopy which accesses the data
- * in the DlsMat A and B (i.e. the fields cols)
+ * in the DlsMat A and DlsMat B (i.e. the fields cols)
  * -----------------------------------------------------------------
  */
 
 SUNDIALS_EXPORT void BandCopy(DlsMat A, DlsMat B, long int copymu, long int copyml);
-SUNDIALS_EXPORT void bandCopy(realtype **a, realtype **b, long int n, long int a_smu, long int b_smu,
+SUNDIALS_EXPORT void bandCopy(realtype **a, realtype **b, long int n,
+                              long int a_smu, long int b_smu,
 			      long int copymu, long int copyml);
 
 /*
@@ -129,7 +136,7 @@ SUNDIALS_EXPORT void bandCopy(realtype **a, realtype **b, long int n, long int a
  *
  * BandScale is a wrapper around bandScale which performs the actual
  * scaling by accessing the data in the DlsMat A (i.e. the field
- * cols).
+ * A->cols).
  * -----------------------------------------------------------------
  */
 
@@ -147,6 +154,25 @@ SUNDIALS_EXPORT void bandScale(realtype c, realtype **a, long int n, long int mu
 
 SUNDIALS_EXPORT void bandAddIdentity(realtype **a, long int n, long int smu);
 
+
+/*
+ * -----------------------------------------------------------------
+ * Function: BandMatvec
+ * -----------------------------------------------------------------
+ * BandMatvec computes the matrix-vector product y = A*x, where A 
+ * is an M-by-N band matrix, x is a vector of length N, and y is a 
+ * vector of length M.  No error checking is performed on the length 
+ * of the arrays x and y.  Only y is modified in this routine.
+ *
+ * BandMatvec is a wrapper around bandMatvec which performs the 
+ * actual product by accessing the data in the DlsMat A.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void BandMatvec(DlsMat A, realtype *x, realtype *y);
+SUNDIALS_EXPORT void bandMatvec(realtype **a, realtype *x, realtype *y, long int n, 
+		long int mu, long int ml, long int smu);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/sundials/sundials_config.in b/include/sundials/sundials_config.in
index 8a10b7e..1e06ccd 100644
--- a/include/sundials/sundials_config.in
+++ b/include/sundials/sundials_config.in
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/15 22:45:17 $
+ * $Revision: 4895 $
+ * $Date: 2016-09-05 16:57:24 -0700 (Mon, 05 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
@@ -47,15 +47,31 @@
  * If it was decided that generic math functions can be used, then
  *     #define SUNDIALS_USE_GENERIC_MATH
  */
- at GENERIC_MATH_LIB@
+#cmakedefine SUNDIALS_USE_GENERIC_MATH
+
+/* Use POSIX timers if available.
+ *     #define SUNDIALS_HAVE_POSIX_TIMERS
+ */
+#cmakedefine SUNDIALS_HAVE_POSIX_TIMERS
 
 /* Blas/Lapack available
  * If working libraries for Blas/lapack support were found, then
- *     #define SUNDIALS_BLAS_LAPACK 1
- * otherwise
- *     #define SUNDIALS_BLAS_LAPACK 0
+ *     #define SUNDIALS_BLAS_LAPACK
+ */
+#cmakedefine SUNDIALS_BLAS_LAPACK
+
+/* SUPERLUMT available
+ * If working libraries for SUPERLUMT support were found, then
+ *     #define SUNDIALS_SUPERLUMT 
+ */
+#cmakedefine SUNDIALS_SUPERLUMT
+#cmakedefine SUNDIALS_SUPERLUMT_THREAD_TYPE "@SUPERLUMT_THREAD_TYPE@"
+
+/* KLU available
+ * If working libraries for KLU support were found, then
+ *     #define SUNDIALS_KLU 
  */
- at BLAS_LAPACK_MACRO@
+#cmakedefine SUNDIALS_KLU
 
 /* FNVECTOR: Allow user to specify different MPI communicator
  * If it was found that the MPI implementation supports MPI_Comm_f2c, then
diff --git a/include/sundials/sundials_dense.h b/include/sundials/sundials_dense.h
index f2ddeb0..30411a1 100644
--- a/include/sundials/sundials_dense.h
+++ b/include/sundials/sundials_dense.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:17:18 $
+ * $Revision: 4780 $
+ * $Date: 2016-06-22 17:28:19 -0700 (Wed, 22 Jun 2016) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for a generic package of DENSE matrix
  * operations, based on the DlsMat type defined in sundials_direct.h.
@@ -24,12 +29,12 @@
 #ifndef _SUNDIALS_DENSE_H
 #define _SUNDIALS_DENSE_H
 
+#include <sundials/sundials_direct.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_direct.h>
-
 /*
  * -----------------------------------------------------------------
  * Functions: DenseGETRF and DenseGETRS
@@ -52,7 +57,7 @@ extern "C" {
  *     (including its diagonal) contains U and the strictly lower
  *     trapezoidal part of A contains the multipliers, I-L.
  *
- * For square matrices (M=N), L is unit lower triangular.
+ * For square matrices (M = N), L is unit lower triangular.
  *
  * DenseGETRF returns 0 if successful. Otherwise it encountered
  * a zero diagonal element during the factorization. In this case
@@ -69,7 +74,7 @@ extern "C" {
  * -----------------------------------------------------------------
  * DenseGETRF and DenseGETRS are simply wrappers around denseGETRF
  * and denseGETRS, respectively, which perform all the work by
- * directly accessing the data in the DlsMat A (i.e. the field cols)
+ * directly accessing the data in the DlsMat A (i.e. in A->cols).
  * -----------------------------------------------------------------
  */
 
@@ -118,7 +123,7 @@ SUNDIALS_EXPORT void densePOTRS(realtype **a, long int m, realtype *b);
  *        Q = H(1) H(2) . . . H(k)
  *
  * as returned by DenseGEQRF. Q is an M-by-N matrix, v is a vector
- * of length N and w is a vector of length M (with M>=N).
+ * of length N and w is a vector of length M (with M >= N).
  *
  * DenseORMQR requires a temporary work vector wrk of length M.
  *
@@ -133,7 +138,8 @@ SUNDIALS_EXPORT int DenseGEQRF(DlsMat A, realtype *beta, realtype *wrk);
 SUNDIALS_EXPORT int DenseORMQR(DlsMat A, realtype *beta, realtype *vn, realtype *vm, 
 			       realtype *wrk);
 
-SUNDIALS_EXPORT int denseGEQRF(realtype **a, long int m, long int n, realtype *beta, realtype *v);
+SUNDIALS_EXPORT int denseGEQRF(realtype **a, long int m, long int n, realtype *beta,
+                               realtype *wrk);
 SUNDIALS_EXPORT int denseORMQR(realtype **a, long int m, long int n, realtype *beta,
 			       realtype *v, realtype *w, realtype *wrk);
 
@@ -145,7 +151,7 @@ SUNDIALS_EXPORT int denseORMQR(realtype **a, long int m, long int n, realtype *b
  * M-by-N matrix B.
  * 
  * DenseCopy is a wrapper around denseCopy which accesses the data
- * in the DlsMat A and B (i.e. the fields cols)
+ * in the DlsMat A and DlsMat B (i.e. the fields cols)
  * -----------------------------------------------------------------
  */
 
@@ -160,8 +166,7 @@ SUNDIALS_EXPORT void denseCopy(realtype **a, realtype **b, long int m, long int
  * constant c and stores the result back in A.
  *
  * DenseScale is a wrapper around denseScale which performs the actual
- * scaling by accessing the data in the DlsMat A (i.e. the field
- * cols).
+ * scaling by accessing the data in the DlsMat A (i.e. in A->cols).
  * -----------------------------------------------------------------
  */
 
@@ -174,12 +179,31 @@ SUNDIALS_EXPORT void denseScale(realtype c, realtype **a, long int m, long int n
  * Function: denseAddIdentity
  * -----------------------------------------------------------------
  * denseAddIdentity adds the identity matrix to the n-by-n matrix
- * stored in the realtype** arrays.
+ * stored in a realtype** array.
  * -----------------------------------------------------------------
  */
 
 SUNDIALS_EXPORT void denseAddIdentity(realtype **a, long int n);
 
+
+/*
+ * -----------------------------------------------------------------
+ * Function: DenseMatvec
+ * -----------------------------------------------------------------
+ * DenseMatvec computes the matrix-vector product y = A*x, where A 
+ * is an M-by-N matrix, x is a vector of length N, and y is a vector
+ * of length M.  No error checking is performed on the length of the
+ * arrays x and y.  Only y is modified in this routine.
+ *
+ * DenseMatvec is a wrapper around denseMatvec which performs the 
+ * actual product by accessing the data in the DlsMat A.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void DenseMatvec(DlsMat A, realtype *x, realtype *y);
+SUNDIALS_EXPORT void denseMatvec(realtype **a, realtype *x, realtype *y, long int m, long int n);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/sundials/sundials_direct.h b/include/sundials/sundials_direct.h
index da99f2b..23984b4 100644
--- a/include/sundials/sundials_direct.h
+++ b/include/sundials/sundials_direct.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/22 22:18:49 $
+ * $Revision: 4780 $
+ * $Date: 2016-06-22 17:28:19 -0700 (Wed, 22 Jun 2016) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This header file contains definitions and declarations for use by
  * generic direct linear solvers for Ax = b. It defines types for
@@ -19,12 +24,12 @@
 #ifndef _SUNDIALS_DIRECT_H
 #define _SUNDIALS_DIRECT_H
 
+#include <sundials/sundials_types.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_types.h>
-
 /*
  * =================================================================
  *                C O N S T A N T S
@@ -67,7 +72,7 @@ extern "C" {
  *    cols  - array of pointers. cols[j] points to the first element 
  *            of the j-th column of the matrix in the array data.
  *
- * The elements of a dense matrix are stored columnwise (i.e columns 
+ * The elements of a dense matrix are stored columnwise (i.e. columns 
  * are stored one on top of the other in memory). 
  * If A is of type DlsMat, then the (i,j)th element of A (with 
  * 0 <= i < M and 0 <= j < N) is given by (A->data)[j*n+i]. 
@@ -137,9 +142,9 @@ typedef struct _DlsMat {
  *
  * DENSE_COL(A,j) references the jth column of the M-by-N dense
  * matrix A, 0 <= j < N. The type of the expression DENSE_COL(A,j) 
- * is (realtype *). After the assignment in the usage above, col_j 
- * may be treated as an array indexed from 0 to M-1. The (i,j)-th 
- * element of A is thus referenced by col_j[i].
+ * is (realtype *). After the assignment col_j = DENSE_COL(A,j),
+ * col_j may be treated as an array indexed from 0 to M-1.
+ * The (i,j)-th element of A is thus referenced by col_j[i].
  *
  * DENSE_ELEM(A,i,j) references the (i,j)th element of the dense 
  * M-by-N matrix A, 0 <= i < M ; 0 <= j < N.
@@ -279,7 +284,7 @@ SUNDIALS_EXPORT void DestroyArray(void *p);
  * -----------------------------------------------------------------
  * Function : AddIdentity
  * -----------------------------------------------------------------
- * AddIdentity adds 1.0 to the main diagonal (A_ii, i=1,2,...,N-1) of
+ * AddIdentity adds 1.0 to the main diagonal (A_ii, i=0,1,...,N-1) of
  * the M-by-N matrix A (M>= N) and stores the result back in A.
  * AddIdentity is typically used with square matrices.
  * AddIdentity does not check for M >= N and therefore a segmentation
diff --git a/include/sundials/sundials_fnvector.h b/include/sundials/sundials_fnvector.h
index bbc9a95..0128266 100644
--- a/include/sundials/sundials_fnvector.h
+++ b/include/sundials/sundials_fnvector.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/07/05 15:27:52 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file (companion of nvector.h) contains definitions 
  * needed for the initialization of vector operations in Fortran.
@@ -19,20 +24,21 @@
 #ifndef _FNVECTOR_H
 #define _FNVECTOR_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #ifndef _SUNDIALS_CONFIG_H
 #define _SUNDIALS_CONFIG_H
 #include <sundials/sundials_config.h>
 #endif
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* SUNDIALS solver IDs */
 
 #define FCMIX_CVODE   1
 #define FCMIX_IDA     2
 #define FCMIX_KINSOL  3
+#define FCMIX_ARKODE  4
 
 #ifdef __cplusplus
 }
diff --git a/include/sundials/sundials_iterative.h b/include/sundials/sundials_iterative.h
index 5e7e4bf..fe4118a 100644
--- a/include/sundials/sundials_iterative.h
+++ b/include/sundials/sundials_iterative.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen and Alan C. Hindmarsh @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This header file contains declarations intended for use by
  * generic iterative solvers of Ax = b. The enumeration gives
@@ -24,12 +29,12 @@
 #ifndef _ITERATIVE_H
 #define _ITERATIVE_H
 
+#include <sundials/sundials_nvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-
 
 /*
  * -----------------------------------------------------------------
@@ -121,7 +126,7 @@ typedef int (*PSolveFn)(void *P_data, N_Vector r, N_Vector z, int lr);
  * This matrix must be allocated row-wise so that the (i,j)th     
  * entry is h[i][j]. The inner products (v[i],v[k]),              
  * i=i0, i0+1, ..., k-1, are stored at h[i][k-1]. Here            
- * i0=MAX(0,k-p).                                                 
+ * i0=SUNMAX(0,k-p).
  *                                                                
  * k is the index of the vector in the v array that needs to be   
  * orthogonalized against previous vectors in the v array.        
diff --git a/include/sundials/sundials_klu_impl.h b/include/sundials/sundials_klu_impl.h
new file mode 100644
index 0000000..3271bc5
--- /dev/null
+++ b/include/sundials/sundials_klu_impl.h
@@ -0,0 +1,57 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the Sundials interface to 
+ * the KLU linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNKLU_IMPL_H
+#define _SUNKLU_IMPL_H
+
+#ifndef _S_KLU_H
+#define _S_KLU_H
+#include "klu.h"
+#endif
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Definition of KLUData
+ * -----------------------------------------------------------------
+ */
+ 
+typedef struct KLUDataRec {
+ 
+  /* Structure for KLU-specific data */
+ 
+  klu_symbolic *s_Symbolic;
+  klu_numeric  *s_Numeric;
+  klu_common    s_Common;
+  int           s_ordering;
+  int          (*sun_klu_solve)(klu_symbolic*, klu_numeric*, int, int, double*, klu_common*);
+ 
+} *KLUData;
+ 
+#ifdef __cplusplus
+} 
+#endif 
+ 
+#endif 
diff --git a/include/sundials/sundials_lapack.h b/include/sundials/sundials_lapack.h
index 4af89df..08fcdaf 100644
--- a/include/sundials/sundials_lapack.h
+++ b/include/sundials/sundials_lapack.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2009/02/17 02:39:26 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for a generic package of direct matrix
  * operations for use with BLAS/LAPACK.
diff --git a/include/sundials/sundials_math.h b/include/sundials/sundials_math.h
index 99de085..7e25d3e 100644
--- a/include/sundials/sundials_math.h
+++ b/include/sundials/sundials_math.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for a simple C-language math library. The
  * routines listed here work with the type realtype as defined in
@@ -20,12 +25,12 @@
 #ifndef _SUNDIALSMATH_H
 #define _SUNDIALSMATH_H
 
+#include <sundials/sundials_types.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_types.h>
-
 /*
  * -----------------------------------------------------------------
  * Macros : MIN and MAX
@@ -38,99 +43,88 @@ extern "C" {
  * -----------------------------------------------------------------
  */
 
-#ifndef MIN
-#define MIN(A, B) ((A) < (B) ? (A) : (B))
-#endif
-
-#ifndef MAX
-#define MAX(A, B) ((A) > (B) ? (A) : (B))
+#ifndef SUNMIN
+#define SUNMIN(A, B) ((A) < (B) ? (A) : (B))
 #endif
 
-#ifndef SQR
-#define SQR(A) ((A)*(A))
+#ifndef SUNMAX
+#define SUNMAX(A, B) ((A) > (B) ? (A) : (B))
 #endif
 
-#ifndef ABS
-#define ABS RAbs
+#ifndef SUNSQR
+#define SUNSQR(A) ((A)*(A))
 #endif
 
-#ifndef SQRT
-#define SQRT RSqrt
-#endif
-
-#ifndef EXP
-#define EXP RExp
-#endif
 
 /*
  * -----------------------------------------------------------------
- * Function : RPowerI
+ * Function : SUNRpowerI
  * -----------------------------------------------------------------
  * Usage : int exponent;
  *         realtype base, ans;
- *         ans = RPowerI(base,exponent);
+ *         ans = SUNRpowerI(base,exponent);
  * -----------------------------------------------------------------
- * RPowerI returns the value of base^exponent, where base is of type
+ * SUNRpowerI returns the value of base^exponent, where base is of type
  * realtype and exponent is of type int.
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT realtype RPowerI(realtype base, int exponent);
+SUNDIALS_EXPORT realtype SUNRpowerI(realtype base, int exponent);
 
 /*
  * -----------------------------------------------------------------
- * Function : RPowerR
+ * Function : SUNRpowerR
  * -----------------------------------------------------------------
  * Usage : realtype base, exponent, ans;
- *         ans = RPowerR(base,exponent);
+ *         ans = SUNRpowerR(base,exponent);
  * -----------------------------------------------------------------
- * RPowerR returns the value of base^exponent, where both base and
- * exponent are of type realtype. If base < ZERO, then RPowerR
+ * SUNRpowerR returns the value of base^exponent, where both base and
+ * exponent are of type realtype. If base < ZERO, then SUNRpowerR
  * returns ZERO.
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT realtype RPowerR(realtype base, realtype exponent);
+SUNDIALS_EXPORT realtype SUNRpowerR(realtype base, realtype exponent);
 
 /*
  * -----------------------------------------------------------------
- * Function : RSqrt
+ * Function : SUNRsqrt
  * -----------------------------------------------------------------
  * Usage : realtype sqrt_x;
- *         sqrt_x = RSqrt(x);
+ *         sqrt_x = SUNRsqrt(x);
  * -----------------------------------------------------------------
- * RSqrt(x) returns the square root of x. If x < ZERO, then RSqrt
- * returns ZERO.
+ * SUNRsqrt(x) returns the square root of x. If x < ZERO, then
+ * SUNRsqrt returns ZERO.
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT realtype RSqrt(realtype x);
+SUNDIALS_EXPORT realtype SUNRsqrt(realtype x);
 
 /*
  * -----------------------------------------------------------------
- * Function : RAbs (a.k.a. ABS)
+ * Function : SUNRabs
  * -----------------------------------------------------------------
  * Usage : realtype abs_x;
- *         abs_x = RAbs(x);
+ *         abs_x = SUNRabs(x);
  * -----------------------------------------------------------------
- * RAbs(x) returns the absolute value of x.
+ * SUNRabs(x) returns the absolute value of x.
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT realtype RAbs(realtype x);
+SUNDIALS_EXPORT realtype SUNRabs(realtype x);
 
 /*
  * -----------------------------------------------------------------
- * Function : RExp (a.k.a. EXP)
+ * Function : SUNRexp
  * -----------------------------------------------------------------
  * Usage : realtype exp_x;
- *         exp_x = RExp(x);
+ *         exp_x = SUNRexp(x);
  * -----------------------------------------------------------------
- * RExp(x) returns e^x (base-e exponential function).
+ * SUNRexp(x) returns e^x (base-e exponential function).
  * -----------------------------------------------------------------
  */
 
-SUNDIALS_EXPORT realtype RExp(realtype x);
+SUNDIALS_EXPORT realtype SUNRexp(realtype x);
 
 #ifdef __cplusplus
 }
diff --git a/include/sundials/sundials_nvector.h b/include/sundials/sundials_nvector.h
index 6142b32..7fe88e1 100644
--- a/include/sundials/sundials_nvector.h
+++ b/include/sundials/sundials_nvector.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4803 $
+ * $Date: 2016-07-08 14:01:04 -0700 (Fri, 08 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for a generic NVECTOR package.
  * It defines the N_Vector structure (_generic_N_Vector) which
@@ -43,12 +48,29 @@
 #ifndef _NVECTOR_H
 #define _NVECTOR_H
 
+#include <sundials/sundials_types.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_types.h>
-
+  
+/*
+ * -----------------------------------------------------------------
+ * Implemented N_Vector types
+ * -----------------------------------------------------------------
+ */
+  
+typedef enum {
+  SUNDIALS_NVEC_SERIAL, 
+  SUNDIALS_NVEC_PARALLEL, 
+  SUNDIALS_NVEC_OPENMP, 
+  SUNDIALS_NVEC_PTHREADS, 
+  SUNDIALS_NVEC_PARHYP, 
+  SUNDIALS_NVEC_PETSC,
+  SUNDIALS_NVEC_CUSTOM
+} N_Vector_ID;
+  
 /*
  * -----------------------------------------------------------------
  * Generic definition of N_Vector
@@ -66,6 +88,7 @@ typedef N_Vector *N_Vector_S;
 
 /* Structure containing function pointers to vector operations  */  
 struct _generic_N_Vector_Ops {
+  N_Vector_ID (*nvgetvectorid)(N_Vector);
   N_Vector    (*nvclone)(N_Vector);
   N_Vector    (*nvcloneempty)(N_Vector);
   void        (*nvdestroy)(N_Vector);
@@ -114,6 +137,10 @@ struct _generic_N_Vector {
 
 /*
  * -----------------------------------------------------------------
+ * N_VGetVectorID
+ *   Returns an identifier for the vector type from enumeration 
+ *   N_Vector_ID.
+ *
  * N_VClone
  *   Creates a new vector of the same type as an existing vector.
  *   It does not copy the vector, but rather allocates storage for
@@ -261,6 +288,8 @@ struct _generic_N_Vector {
  * NVECTOR          ------------------------------------------------
  * FUNCTIONS          CVODE/CVODES          IDA             KINSOL    
  * -----------------------------------------------------------------
+ * N_VGetVectorID     
+ * -----------------------------------------------------------------
  * N_VClone           S Di I                S I BBDP        S I BBDP
  * -----------------------------------------------------------------
  * N_VCloneEmpty      F                     F               F
@@ -313,6 +342,7 @@ struct _generic_N_Vector {
  * -----------------------------------------------------------------
  */
   
+SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID(N_Vector w);
 SUNDIALS_EXPORT N_Vector N_VClone(N_Vector w);
 SUNDIALS_EXPORT N_Vector N_VCloneEmpty(N_Vector w);
 SUNDIALS_EXPORT void N_VDestroy(N_Vector v);
diff --git a/include/sundials/sundials_pcg.h b/include/sundials/sundials_pcg.h
new file mode 100644
index 0000000..8ec24f2
--- /dev/null
+++ b/include/sundials/sundials_pcg.h
@@ -0,0 +1,156 @@
+/*---------------------------------------------------------------
+ Programmer(s): Daniel R. Reynolds @ SMU
+ ----------------------------------------------------------------
+ Copyright (c) 2013, Southern Methodist University.
+ All rights reserved.
+ For details, see the LICENSE file.
+ ----------------------------------------------------------------
+ This is the header for the preconditioned conjugate gradient 
+ solver in SUNDIALS.
+ ---------------------------------------------------------------*/
+
+#ifndef _PCG_H
+#define _PCG_H
+
+#include <sundials/sundials_iterative.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ Types: struct PcgMemRec and struct *PcgMem
+ ----------------------------------------------------------------
+ A variable declaration of type struct *PcgMem denotes a pointer
+ to a data structure of type struct PcgMemRec. The PcgMemRec
+ structure contains numerous fields that must be accessed by the
+ PCG linear solver module.
+  * l_max  maximum Krylov subspace dimension that PcgSolve will
+       be permitted to use
+  * r  vector (type N_Vector) which holds the preconditioned 
+       linear system residual
+  * p, z and Ap vectors (type N_Vector) used for workspace by
+       the PCG algorithm
+  * vtemp  scratch vector (type N_Vector) used as temporary 
+       vector storage
+ --------------------------------------------------------------*/
+typedef struct {
+  int l_max;
+  N_Vector r;
+  N_Vector p;
+  N_Vector z;
+  N_Vector Ap;
+} PcgMemRec, *PcgMem;
+
+/*---------------------------------------------------------------
+ Function : PcgMalloc
+ ----------------------------------------------------------------
+ PcgMalloc allocates additional memory needed by the PCG linear 
+ solver module.
+
+   l_max  maximum Krylov subspace dimension that PcgSolve will
+          be permitted to use
+
+   vec_tmpl implementation-specific template vector (of type 
+          N_Vector)
+
+ If successful, PcgMalloc returns a non-NULL memory pointer. If
+ an error occurs, then a NULL pointer is returned.
+ --------------------------------------------------------------*/
+
+SUNDIALS_EXPORT PcgMem PcgMalloc(int l_max, N_Vector vec_tmpl);
+
+/*---------------------------------------------------------------
+ Function : PcgSolve
+ ----------------------------------------------------------------
+ PcgSolve solves the linear system Ax = b by means of a 
+ preconditioned Conjugate-Gradient (PCG) iterative method.
+
+  mem  pointer to an internal memory block allocated during a
+       prior call to PcgMalloc
+
+  A_data  pointer to a data structure containing information
+       about the coefficient matrix A (passed to user-supplied
+       function referenced by atimes (function pointer))
+
+  x  vector (type N_Vector) containing initial guess x_0 upon
+       entry, but which upon return contains an approximate 
+       solution of the linear system Ax = b (solution only 
+       valid if return value is either PCG_SUCCESS or 
+       PCG_RES_REDUCED)
+
+  b  vector (type N_Vector) set to the right-hand side vector b
+       of the linear system (unchanged by function)
+
+  pretype  variable (type int) indicating the type of
+       preconditioning to be used (see sundials_iterative.h);
+       Note: since CG is for symmetric problems, preconditioning 
+       is applied symmetrically by default, so any nonzero flag 
+       will indicate to use the preconditioner.
+
+  delta  tolerance on the L2 norm of the residual (if the 
+       return value == PCG_SUCCESS, then ||b-Ax||_L2 <= delta)
+
+  P_data  pointer to a data structure containing preconditioner
+       information (passed to user-supplied function referenced
+       by psolve (function pointer))
+
+  w  vector (type N_Vector) used in computing the residual norm 
+       for stopping solver (unchanged by function).  This is 
+       needed since PCG cannot utilize the same scaling vectors 
+       as used in the other SUNDIALS solvers, due to 
+       symmetry-breaking nature of scaling operators.
+
+  atimes  user-supplied routine responsible for computing the
+       matrix-vector product Ax (see sundials_iterative.h)
+
+  psolve  user-supplied routine responsible for solving the
+       preconditioned linear system Pz = r (ignored if
+       pretype == PREC_NONE) (see sundials_iterative.h)
+
+  res_norm  pointer (type realtype*) to the L2 norm of the
+       residual (if return value is either PCG_SUCCESS or 
+       PCG_RES_REDUCED, then
+            *res_norm = ||b-Ax||_L2, where x is
+       the computed approximate solution)
+
+  nli  pointer (type int*) to the total number of linear
+       iterations performed
+
+  nps  pointer (type int*) to the total number of calls made
+       to the psolve routine
+ --------------------------------------------------------------*/
+
+SUNDIALS_EXPORT int PcgSolve(PcgMem mem, void *A_data, N_Vector x, N_Vector b,
+			     int pretype, realtype delta, void *P_data, 
+			     N_Vector w, ATimesFn atimes, PSolveFn psolve,
+			     realtype *res_norm, int *nli, int *nps);
+
+/* Return values for PcgSolve */
+#define PCG_SUCCESS            0  /* PCG algorithm converged          */
+#define PCG_RES_REDUCED        1  /* PCG did NOT converge, but the
+				       residual was reduced           */
+#define PCG_CONV_FAIL          2  /* PCG algorithm failed to converge */
+#define PCG_PSOLVE_FAIL_REC    3  /* psolve failed recoverably        */
+#define PCG_ATIMES_FAIL_REC    4  /* atimes failed recoverably        */
+#define PCG_PSET_FAIL_REC      5  /* pset faild recoverably           */
+
+#define PCG_MEM_NULL          -1  /* mem argument is NULL             */
+#define PCG_ATIMES_FAIL_UNREC -2  /* atimes returned failure flag     */
+#define PCG_PSOLVE_FAIL_UNREC -3  /* psolve failed unrecoverably      */
+#define PCG_PSET_FAIL_UNREC   -4  /* pset failed unrecoverably        */
+
+/*---------------------------------------------------------------
+ Function : PcgFree
+ ----------------------------------------------------------------
+ PcgFree frees the memory allocated by a call to PcgMalloc.
+ It is illegal to use the pointer mem after a call to PcgFree.
+ ---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT void PcgFree(PcgMem mem);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sundials/sundials_sparse.h b/include/sundials/sundials_sparse.h
new file mode 100644
index 0000000..358f273
--- /dev/null
+++ b/include/sundials/sundials_sparse.h
@@ -0,0 +1,237 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4771 $
+ * $Date: 2016-06-03 13:21:57 -0700 (Fri, 03 Jun 2016) $
+ * -----------------------------------------------------------------
+ * Programmer: Carol Woodward, Slaven Peles @ LLNL,
+ *             Daniel R. Reynolds @ SMU.
+ * -----------------------------------------------------------------
+ * For details, see the LICENSE file.
+ * -----------------------------------------------------------------
+ * This header file contains definitions and declarations for use by
+ * sparse linear solvers for Ax = b. 
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNDIALS_SPARSE_H
+#define _SUNDIALS_SPARSE_H
+
+#include <stdio.h>
+
+#include <sundials/sundials_types.h>
+#include <sundials/sundials_direct.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * ==================================================================
+ * Type definitions
+ * ==================================================================
+ */
+
+#define CSC_MAT 0
+#define CSR_MAT 1
+
+/*
+ * -----------------------------------------------------------------
+ * Type : SlsMat
+ * -----------------------------------------------------------------
+ * The type SlsMat is defined to be a pointer to a structure
+ * with various sizes, a data field, and arrays for the row and 
+ * column information for the sparse matrix entries.
+ * The M and N fields indicates the number 
+ * of rows and columns, respectively. The data field is a one 
+ * dimensional array used for component storage. The NNZ field indicates
+ * the number of nonzero entries in the matrix. The integer array, asub, 
+ * holds the row index for each of the matrix entries.  The integer
+ * array, xa, holds the index entry for the starting value of each column.
+ * -----------------------------------------------------------------
+ * The relevant fields in DlsMat are:
+ *    M     - number of rows
+ *    N     - number of columns
+ *    NNZ   - the number of nonzero entries in the matrix
+ *    NP    - number of index pointers
+ *    data  - pointer to a contiguous block of realtype variables
+ *    sparsetype - type of sparse matrix: compressed sparse column or row
+ *    indexvals  - indices of each nonzero entry (columns or rows)
+ *    indexptrs  - starting index of the first entry in data for each slice
+ *    rowvals - pointer to row indices of each nonzero entry
+ *    colptrs - pointer to starting indices in data array for each column
+ *    colvals - pointer to column indices of each nonzero entry
+ *    rowptrs - pointer to starting indices in data array for each row
+ *
+ * The nonzero entries of the matrix are stored in
+ * compressed column format.  Row indices of entries in 
+ * column j are stored in rowvals[colptrs[j]] through rowvals[colptrs[j+i]-1]
+ * and corresponding numerical values of the matrix are stored 
+ * in the same entries of data.
+ * -----------------------------------------------------------------
+ */
+
+typedef struct _SlsMat {
+  int M;
+  int N;
+  int NNZ;
+  int NP;
+  realtype *data;
+  int sparsetype;
+  int *indexvals;
+  int *indexptrs;
+  /* CSC indices */
+  int **rowvals;
+  int **colptrs;
+  /* CSR indices */
+  int **colvals;
+  int **rowptrs;
+} *SlsMat;
+
+/*
+ * ==================================================================
+ * Exported function prototypes (functions working on SlsMat)
+ * ==================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SparseNewMat
+ * -----------------------------------------------------------------
+ * SparseNewMat allocates memory for a compressed column sparse
+ * matrix with M rows, N columns, NNZ nonzeros and of sparsetype 
+ * type (CSC or CSR matrix). SparseNewMat returns NULL if the 
+ * request for matrix storage cannot be satisfied. See the above 
+ * documentation for the type SlsMat for matrix storage details.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SlsMat SparseNewMat(int M, int N, int NNZ, int sparsetype);
+
+/*
+ * -----------------------------------------------------------------
+ * Function: SparseFromDenseMat
+ * -----------------------------------------------------------------
+ * SlsConvertDense creates a new CSC matrix from an existing
+ * dense/band matrix by copying all nonzero values into the sparse 
+ * matrix structure.  SlsConvertDense returns NULL if the request 
+ * for matrix storage cannot be satisfied. 
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT SlsMat SparseFromDenseMat(const DlsMat A, int sparsetype);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseDestroyMat
+ * -----------------------------------------------------------------
+ * SparseDestroyMat frees the memory allocated by SparseNewMat
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseDestroyMat(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Function : SparseSetMatToZero
+ * -----------------------------------------------------------------
+ * SetToZero sets all the elements of the sparse matrix A to 0.0.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseSetMatToZero(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseCopyMat
+ * -----------------------------------------------------------------
+ * This function copies sparse matrix A into sparse matrix B.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseCopyMat(const SlsMat A, SlsMat B);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseScaleMat
+ * -----------------------------------------------------------------
+ * This function scales all data entries of a sparse matrix A 
+ * by the realtype number in b.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseScaleMat(realtype b, SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseAddIdentityMat
+ * -----------------------------------------------------------------
+ * This function adds 1 to every diagonal entry of A.
+ * Note that the resulting matrix may have more nonzero entries than 
+ * the original.  This is accounted for, so that the return matrix 
+ * may be larger than the one sent in.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseAddIdentityMat(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseAddMat
+ * -----------------------------------------------------------------
+ * This function adds two sparse matrices: A = A+B.
+ * Note that the resulting matrix may have more nonzero entries than
+ * either of the original matrices.  This is accounted for, so that 
+ * the return matrix may be larger than the ones sent in.  Upon 
+ * successful completion, the return value is zero; otherwise 1 is 
+ * returned.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseAddMat(SlsMat A, const SlsMat B);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseReallocMat
+ * -----------------------------------------------------------------
+ * This function reallocs internal arrays so that the resulting matrix 
+ * holds colptrs[N] nonzeros.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseReallocMat(SlsMat A);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseMatvec
+ * -----------------------------------------------------------------
+ * This function computes the matrix-vector product, y=A*x, where A
+ * is a sparse matrix of dimension MxN, x is a realtype array of 
+ * length N, and y is a realtype array of length M. Upon successful
+ * completion, the return value is zero; otherwise 1 is returned.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT int SparseMatvec(const SlsMat A, const realtype *x, realtype *y);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparsePrintMat
+ * -----------------------------------------------------------------
+ * This function prints the compressed column matrix information for 
+ * matrix A to standard output.
+ * It is intended as a debugging tool with small values of NNZ.
+ * The elements are printed using the %g/%lg/%Lg option. 
+ * A blank line is printed before and after the matrix.
+ * -----------------------------------------------------------------
+ */
+
+SUNDIALS_EXPORT void SparsePrintMat(const SlsMat A, FILE* outfile);
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sundials/sundials_spbcgs.h b/include/sundials/sundials_spbcgs.h
index d569d1d..9c6b6a6 100644
--- a/include/sundials/sundials_spbcgs.h
+++ b/include/sundials/sundials_spbcgs.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Peter Brown and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the implementation of the scaled,
  * preconditioned Bi-CGSTAB (SPBCG) iterative linear solver.
@@ -18,12 +23,12 @@
 #ifndef _SPBCG_H
 #define _SPBCG_H
 
+#include <sundials/sundials_iterative.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_iterative.h>
-
 /*
  * -----------------------------------------------------------------
  * Types: struct SpbcgMemRec and struct *SpbcgMem
diff --git a/include/sundials/sundials_spfgmr.h b/include/sundials/sundials_spfgmr.h
new file mode 100644
index 0000000..847a650
--- /dev/null
+++ b/include/sundials/sundials_spfgmr.h
@@ -0,0 +1,284 @@
+/* -----------------------------------------------------------------
+ Programmer(s): Daniel R. Reynolds and Hilari C. Tiedeman @ SMU
+ -------------------------------------------------------------------
+ Copyright (c) 2011, Southern Methodist University.
+ All rights reserved.
+ For details, see the LICENSE file.
+ -------------------------------------------------------------------
+ This is the header file for the implementation of SPFGMR Krylov
+ iterative linear solver.  The SPFGMR algorithm is based on the
+ Scaled Preconditioned Flexible GMRES (Generalized Minimal Residual)
+ method [Y. Saad, SIAM J. Sci. Comput., 1993].
+
+ The SPFGMR algorithm solves a linear system A x = b.
+ Preconditioning is only allowed on the right.
+ Scaling is allowed on the right, and restarts are also allowed.
+ We denote the preconditioner and scaling matrices as follows:
+   P = right preconditioner
+   S1 = diagonal matrix of scale factors for P-inverse b
+   S2 = diagonal matrix of scale factors for x
+ The matrices A and P are not required explicitly; only
+ routines that provide A and P-inverse as operators are required.
+
+ In this notation, SPFGMR applies the underlying FGMRES method to
+ the equivalent transformed system
+   Abar xbar = bbar , where
+   Abar = S1 A (P-inverse) (S2-inverse),
+   bbar = S1 b , and   xbar = S2 P x .
+
+ The scaling matrix must be chosen so that the vectors S1 b and 
+ S2 P x have dimensionless components.  If preconditioning is not 
+ performed (P = I), then S2 must be a scaling for x, while S1 is a
+ scaling for b.  Similarly, if preconditioning is performed, then S1
+ must be a scaling for b, while S2 is a scaling for P x, and may 
+ also be taken as a scaling for b. 
+
+ The stopping test for the SPFGMR iterations is on the L2 norm of
+ the scaled preconditioned residual:
+      || bbar - Abar xbar ||_2  <  delta
+ with an input test constant delta.
+
+ The usage of this SPFGMR solver involves supplying two routines
+ and making three calls.  The user-supplied routines are
+    atimes (A_data, x, y) to compute y = A x, given x,
+ and
+    psolve (P_data, y, x, lr)
+                to solve P x = y for x, given y.
+ The three user calls are:
+    mem  = SpfgmrMalloc(lmax, vec_tmpl);
+           to initialize memory,
+    flag = SpfgmrSolve(mem,A_data,x,b,...,
+                       P_data,s1,s2,atimes,psolve,...);
+           to solve the system, and
+    SpfgmrFree(mem);
+           to free the memory created by SpfgmrMalloc.
+ Complete details for specifying atimes and psolve and for the
+ usage calls are given in the paragraphs below and in iterative.h.
+ -----------------------------------------------------------------*/
+
+#ifndef _SPFGMR_H
+#define _SPFGMR_H
+
+#include <sundials/sundials_iterative.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* -----------------------------------------------------------------
+ Types: SpfgmrMemRec, SpfgmrMem
+ -------------------------------------------------------------------
+ SpfgmrMem is a pointer to an SpfgmrMemRec which contains
+ the memory needed by SpfgmrSolve. The SpfgmrMalloc routine
+ returns a pointer of type SpfgmrMem which should then be passed
+ in subsequent calls to SpfgmrSolve. The SpfgmrFree routine frees
+ the memory allocated by SpfgmrMalloc.
+
+ l_max is the maximum Krylov dimension that SpfgmrSolve will be
+ permitted to use.
+
+ V is the array of Krylov basis vectors v_1, ..., v_(l_max+1),
+ stored in V[0], ..., V[l_max], where l_max is the second
+ parameter to SpfgmrMalloc. Each v_i is a vector of type
+ N_Vector.
+
+ Z is the array of preconditioned basis vectors z_1, ..., 
+ z_(l_max+1), stored in Z[0], ..., Z[l_max], where l_max is the 
+ second parameter to SpfgmrMalloc. Each z_i is a vector of type
+ N_Vector.
+
+ Hes is the (l_max+1) x l_max Hessenberg matrix. It is stored
+ row-wise so that the (i,j)th element is given by Hes[i][j].
+
+ givens is a length 2*l_max array which represents the
+ Givens rotation matrices that arise in the algorithm. The
+ Givens rotation matrices F_0, F_1, ..., F_j, where F_i is
+
+             1
+               1
+                 c_i  -s_i      <--- row i
+                 s_i   c_i
+                           1
+                             1
+
+ are represented in the givens vector as
+ givens[0]=c_0, givens[1]=s_0, givens[2]=c_1, givens[3]=s_1,
+ ..., givens[2j]=c_j, givens[2j+1]=s_j.
+
+ xcor is a vector (type N_Vector) which holds the scaled,
+ preconditioned correction to the initial guess.
+
+ yg is a length (l_max+1) array of realtype used to hold "short"
+ vectors (e.g. y and g).
+
+ vtemp is a vector (type N_Vector) used as temporary vector
+ storage during calculations.
+ -----------------------------------------------------------------*/
+typedef struct _SpfgmrMemRec {
+  int l_max;
+  N_Vector *V;
+  N_Vector *Z;
+  realtype **Hes;
+  realtype *givens;
+  N_Vector xcor;
+  realtype *yg;
+  N_Vector vtemp;
+} SpfgmrMemRec, *SpfgmrMem;
+
+/*----------------------------------------------------------------
+ Function : SpfgmrMalloc
+ -----------------------------------------------------------------
+ SpfgmrMalloc allocates the memory used by SpfgmrSolve. It
+ returns a pointer of type SpfgmrMem which the user of the
+ SPGMR package should pass to SpfgmrSolve. The parameter l_max
+ is the maximum Krylov dimension that SpfgmrSolve will be
+ permitted to use. The parameter vec_tmpl is a pointer to an
+ N_Vector used as a template to create new vectors by duplication.
+ This routine returns NULL if there is a memory request failure.
+ ---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT SpfgmrMem SpfgmrMalloc(int l_max, N_Vector vec_tmpl);
+
+/*----------------------------------------------------------------
+ Function : SpfgmrSolve
+ -----------------------------------------------------------------
+ SpfgmrSolve solves the linear system Ax = b using the SPFGMR
+ method. The return values are given by the symbolic constants
+ below. The first SpfgmrSolve parameter is a pointer to memory
+ allocated by a prior call to SpfgmrMalloc.
+
+ mem is the pointer returned by SpfgmrMalloc to the structure
+ containing the memory needed by SpfgmrSolve.
+
+ A_data is a pointer to information about the coefficient
+ matrix A. This pointer is passed to the user-supplied function
+ atimes.
+
+ x is the initial guess x_0 upon entry and the solution
+ N_Vector upon exit with return value SPFGMR_SUCCESS or
+ SPFGMR_RES_REDUCED. For all other return values, the output x
+ is undefined.
+
+ b is the right hand side N_Vector. It is undisturbed by this
+ function.
+
+ pretype is the type of preconditioning to be used. Its
+ legal possible values are enumerated in iterative.h. These
+ values are PREC_NONE, PREC_LEFT, PREC_RIGHT and PREC_BOTH; 
+ however since this solver can only precondition on the right, 
+ then right-preconditioning will be done if any of the values 
+ PREC_LEFT, PREC_RIGHT or PREC_BOTH are provided..
+
+ gstype is the type of Gram-Schmidt orthogonalization to be
+ used. Its legal values are enumerated in iterativ.h. These
+ values are MODIFIED_GS=0 and CLASSICAL_GS=1.
+
+ delta is the tolerance on the L2 norm of the scaled,
+ preconditioned residual. On return with value SPFGMR_SUCCESS,
+ this residual satisfies || s1 P1_inv (b - Ax) ||_2 <= delta.
+
+ max_restarts is the maximum number of times the algorithm is
+ allowed to restart.
+
+ maxit is the maximum number of iterations allowed within the 
+ solve.  This value must be less than or equal to the "l_max" 
+ value previously supplied to SpfgmrMalloc.  If maxit is too 
+ large, l_max will be used instead.
+
+ P_data is a pointer to preconditioner information. This
+ pointer is passed to the user-supplied function psolve.
+
+ s1 is an N_Vector of positive scale factors for b. (Not 
+ tested for positivity.)  Pass NULL if no scaling on b is 
+ required.
+
+ s2 is an N_Vector of positive scale factors for P x, where
+ P is the right preconditioner. (Not tested for positivity.)
+ Pass NULL if no scaling on P x is required.
+
+ atimes is the user-supplied function which performs the
+ operation of multiplying A by a given vector. Its description
+ is given in iterative.h.
+
+ psolve is the user-supplied function which solves a
+ preconditioner system Pz = r, where P is P1 or P2. Its full
+ description is given in iterative.h. The psolve function will
+ not be called if pretype is NONE; in that case, the user
+ should pass NULL for psolve.
+
+ res_norm is a pointer to the L2 norm of the scaled,
+ preconditioned residual. On return with value SPFGMR_SUCCESS or
+ SPFGMR_RES_REDUCED, (*res_norm) contains the value
+ || s1 (b - Ax) ||_2 for the computed solution x.
+ For all other return values, (*res_norm) is undefined. The
+ caller is responsible for allocating the memory (*res_norm)
+ to be filled in by SpfgmrSolve.
+
+ nli is a pointer to the number of linear iterations done in
+ the execution of SpfgmrSolve. The caller is responsible for
+ allocating the memory (*nli) to be filled in by SpfgmrSolve.
+
+ nps is a pointer to the number of calls made to psolve during
+ the execution of SpfgmrSolve. The caller is responsible for
+ allocating the memory (*nps) to be filled in by SpfgmrSolve.
+
+ Note: Repeated calls can be made to SpfgmrSolve with varying
+ input arguments. If, however, the problem size N or the
+ maximum Krylov dimension l_max changes, then a call to
+ SpfgmrMalloc must be made to obtain new memory for SpfgmrSolve
+ to use.
+ ---------------------------------------------------------------*/
+     
+SUNDIALS_EXPORT int SpfgmrSolve(SpfgmrMem mem, void *A_data, N_Vector x, 
+				N_Vector b, int pretype, int gstype, 
+				realtype delta, int max_restarts, 
+				int maxit, void *P_data, N_Vector s1, 
+				N_Vector s2, ATimesFn atimes, PSolveFn psolve, 
+				realtype *res_norm, int *nli, int *nps);
+
+
+/* Return values for SpfgmrSolve */
+#define SPFGMR_SUCCESS            0  /* Converged                     */
+#define SPFGMR_RES_REDUCED        1  /* Did not converge, but reduced
+                                        norm of residual              */
+#define SPFGMR_CONV_FAIL          2  /* Failed to converge            */
+#define SPFGMR_QRFACT_FAIL        3  /* QRfact found singular matrix  */
+#define SPFGMR_PSOLVE_FAIL_REC    4  /* psolve failed recoverably     */
+#define SPFGMR_ATIMES_FAIL_REC    5  /* atimes failed recoverably     */
+#define SPFGMR_PSET_FAIL_REC      6  /* pset faild recoverably        */
+
+#define SPFGMR_MEM_NULL          -1  /* mem argument is NULL          */
+#define SPFGMR_ATIMES_FAIL_UNREC -2  /* atimes returned failure flag  */
+#define SPFGMR_PSOLVE_FAIL_UNREC -3  /* psolve failed unrecoverably   */
+#define SPFGMR_GS_FAIL           -4  /* Gram-Schmidt routine faiuled  */        
+#define SPFGMR_QRSOL_FAIL        -5  /* QRsol found singular R        */
+#define SPFGMR_PSET_FAIL_UNREC   -6  /* pset failed unrecoverably     */
+
+/*----------------------------------------------------------------
+ Function : SpfgmrFree
+ -----------------------------------------------------------------
+ SpfgmrMalloc frees the memory allocated by SpfgmrMalloc. It is
+ illegal to use the pointer mem after a call to SpfgmrFree.
+ ---------------------------------------------------------------*/
+
+SUNDIALS_EXPORT void SpfgmrFree(SpfgmrMem mem);
+
+/*----------------------------------------------------------------
+ Macro: SPFGMR_VTEMP
+ -----------------------------------------------------------------
+ This macro provides access to the work vector vtemp in the
+ memory block of the SPFGMR module.  The argument mem is the
+ memory pointer returned by SpfgmrMalloc, of type SpfgmrMem,
+ and the macro value is of type N_Vector.
+ On a return from SpfgmrSolve with *nli = 0, this vector
+ contains the scaled preconditioned initial residual,
+ s1 * P1_inverse * (b - A x_0).
+ ---------------------------------------------------------------*/
+
+#define SPFGMR_VTEMP(mem) (mem->vtemp)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sundials/sundials_spgmr.h b/include/sundials/sundials_spgmr.h
index 880c1c5..07b0910 100644
--- a/include/sundials/sundials_spgmr.h
+++ b/include/sundials/sundials_spgmr.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2011/06/23 00:17:51 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the implementation of SPGMR Krylov
  * iterative linear solver.  The SPGMR algorithm is based on the
@@ -70,12 +75,12 @@
 #ifndef _SPGMR_H
 #define _SPGMR_H
 
+#include <sundials/sundials_iterative.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_iterative.h>
-
 /*
  * -----------------------------------------------------------------
  * Types: SpgmrMemRec, SpgmrMem
diff --git a/include/sundials/sundials_sptfqmr.h b/include/sundials/sundials_sptfqmr.h
index 6502101..3dc2dfb 100644
--- a/include/sundials/sundials_sptfqmr.h
+++ b/include/sundials/sundials_sptfqmr.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2011/06/23 00:17:51 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the implementation of the scaled
  * preconditioned Transpose-Free Quasi-Minimal Residual (SPTFQMR)
@@ -71,12 +76,12 @@
 #ifndef _SPTFQMR_H
 #define _SPTFQMR_H
 
+#include <sundials/sundials_iterative.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_iterative.h>
-
 /*
  * -----------------------------------------------------------------
  * Types: struct SptfqmrMemRec and struct *SptfqmrMem
diff --git a/include/sundials/sundials_superlumt_impl.h b/include/sundials/sundials_superlumt_impl.h
new file mode 100644
index 0000000..d823baa
--- /dev/null
+++ b/include/sundials/sundials_superlumt_impl.h
@@ -0,0 +1,61 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4741 $
+ * $Date: 2016-04-20 11:36:18 -0700 (Wed, 20 Apr 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the SUNDIALS interface to the 
+ * SuperLUMT linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _SUNSLUMT_IMPL_H
+#define _SUNSLUMT_IMPL_H
+
+#ifndef _SLUMT_H
+#define _SLUMT_H
+/* #include "pdsp_defs.h" */
+#include "slu_mt_ddefs.h"
+#endif
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * -----------------------------------------------------------------
+ * Definition of SLUMTData
+ * -----------------------------------------------------------------
+ */
+ 
+typedef struct SLUMTDataRec {
+ 
+  /* Structure for SuperLUMT-specific data */
+ 
+  SuperMatrix *s_A, *s_AC, *s_L, *s_U, *s_B;
+  Gstat_t *Gstat;
+  int *perm_r, *perm_c;
+  int num_threads;
+  double diag_pivot_thresh; 
+  superlumt_options_t *superlumt_options;
+
+  int s_ordering;
+ 
+} *SLUMTData;
+ 
+#ifdef __cplusplus
+} 
+#endif 
+ 
+#endif 
diff --git a/include/sundials/sundials_types.h b/include/sundials/sundials_types.h
index 953f6e0..844d5f9 100644
--- a/include/sundials/sundials_types.h
+++ b/include/sundials/sundials_types.h
@@ -1,7 +1,7 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2006/11/29 00:05:07 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott Cohen, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
@@ -41,10 +41,6 @@
 #ifndef _SUNDIALSTYPES_H
 #define _SUNDIALSTYPES_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #ifndef _SUNDIALS_CONFIG_H
 #define _SUNDIALS_CONFIG_H
 #include <sundials/sundials_config.h>
@@ -52,6 +48,10 @@ extern "C" {
 
 #include <float.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /*
  *------------------------------------------------------------------
  * Type realtype
diff --git a/src/arkode/CMakeLists.txt b/src/arkode/CMakeLists.txt
new file mode 100644
index 0000000..cfed8e6
--- /dev/null
+++ b/src/arkode/CMakeLists.txt
@@ -0,0 +1,161 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# LLNS/SMU Copyright Start
+# Copyright (c) 2015, Southern Methodist University and 
+# Lawrence Livermore National Security
+#
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Southern Methodist University and Lawrence Livermore 
+# National Laboratory under Contract DE-AC52-07NA27344.
+# Produced at Southern Methodist University and the Lawrence 
+# Livermore National Laboratory.
+#
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS/SMU Copyright End
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the ARKODE library
+
+INSTALL(CODE "MESSAGE(\"\nInstall ARKODE\n\")")
+
+# Add variable arkode_SOURCES with the sources for the ARKODE library
+SET(arkode_SOURCES
+  arkode.c
+  arkode_band.c
+  arkode_bandpre.c
+  arkode_bbdpre.c
+  arkode_butcher.c
+  arkode_dense.c
+  arkode_direct.c        
+  arkode_io.c
+  arkode_pcg.c
+  arkode_spbcgs.c
+  arkode_spfgmr.c
+  arkode_spgmr.c
+  arkode_spils.c
+  arkode_sptfqmr.c
+  arkode_sparse.c
+  )
+
+IF(KLU_FOUND)
+    LIST(APPEND arkode_SOURCES arkode_klu.c)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND arkode_SOURCES arkode_superlumt.c)
+ENDIF()
+
+# Add variable shared_SOURCES with the common SUNDIALS sources which will
+# also be included in the ARKODE library
+SET(shared_SOURCES
+  sundials_nvector.c
+  sundials_math.c
+  sundials_direct.c
+  sundials_band.c
+  sundials_dense.c
+  sundials_iterative.c
+  sundials_pcg.c
+  sundials_spbcgs.c
+  sundials_spfgmr.c
+  sundials_spgmr.c
+  sundials_sptfqmr.c
+  sundials_sparse.c
+  )
+
+# Add prefix with complete path to the common SUNDIALS sources
+ADD_PREFIX(${sundials_SOURCE_DIR}/src/sundials/ shared_SOURCES)
+
+# Add variable arkode_HEADERS with the exported ARKODE header files
+SET(arkode_HEADERS
+  arkode.h
+  arkode_band.h
+  arkode_bandpre.h
+  arkode_bbdpre.h
+  arkode_dense.h
+  arkode_direct.h
+  arkode_pcg.h
+  arkode_spbcgs.h
+  arkode_spfgmr.h
+  arkode_spgmr.h
+  arkode_spils.h
+  arkode_sptfqmr.h
+  arkode_sparse.h
+  )
+
+IF(KLU_FOUND)
+    LIST(APPEND arkode_HEADERS arkode_klu.h)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND arkode_HEADERS arkode_superlumt.h)
+ENDIF()
+
+# Add prefix with complete path to the ARKODE header files
+ADD_PREFIX(${sundials_SOURCE_DIR}/include/arkode/ arkode_HEADERS)
+
+# If Blas/Lapack support was enabled, set-up additional file lists
+IF(LAPACK_FOUND)
+  SET(arkode_BL_SOURCES arkode_lapack.c)
+  SET(arkode_BL_HEADERS arkode_lapack.h)
+  ADD_PREFIX(${sundials_SOURCE_DIR}/include/arkode/ arkode_BL_HEADERS)
+ELSE(LAPACK_FOUND)
+  SET(arkode_BL_SOURCES "")
+  SET(arkode_BL_HEADERS "")
+ENDIF(LAPACK_FOUND)
+
+# Add source directories to include directories for access to
+# implementation only header files.
+INCLUDE_DIRECTORIES(.)
+INCLUDE_DIRECTORIES(../sundials)
+
+# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY 
+ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+
+# Build the static library
+IF(BUILD_STATIC_LIBS)
+
+  # Add the build target for the static ARKODE library
+  ADD_LIBRARY(sundials_arkode_static STATIC 
+    ${arkode_SOURCES}  ${arkode_BL_SOURCES} ${shared_SOURCES})
+
+  # Set the library name and make sure it is not deleted
+  SET_TARGET_PROPERTIES(sundials_arkode_static
+    PROPERTIES OUTPUT_NAME sundials_arkode CLEAN_DIRECT_OUTPUT 1)
+
+  # Install the ARKODE library
+  INSTALL(TARGETS sundials_arkode_static DESTINATION lib)
+
+ENDIF(BUILD_STATIC_LIBS)
+
+# Build the shared library
+IF(BUILD_SHARED_LIBS)
+
+  # Add the build target for the ARKODE library
+  ADD_LIBRARY(sundials_arkode_shared SHARED 
+    ${arkode_SOURCES}  ${arkode_BL_SOURCES}  ${shared_SOURCES})
+
+  # Set the library name and make sure it is not deleted
+  SET_TARGET_PROPERTIES(sundials_arkode_shared
+    PROPERTIES OUTPUT_NAME sundials_arkode CLEAN_DIRECT_OUTPUT 1)
+
+  # Set VERSION and SOVERSION for shared libraries
+  SET_TARGET_PROPERTIES(sundials_arkode_shared
+    PROPERTIES VERSION ${arkodelib_VERSION} SOVERSION ${arkodelib_SOVERSION})
+
+  # Install the ARKODE library
+  INSTALL(TARGETS sundials_arkode_shared DESTINATION lib)
+
+ENDIF(BUILD_SHARED_LIBS)
+
+# Install the ARKODE header files
+INSTALL(FILES ${arkode_HEADERS} ${arkode_BL_HEADERS} DESTINATION include/arkode)
+
+# Install the ARKODE implementation header file
+INSTALL(FILES arkode_impl.h DESTINATION include/arkode)
+
+#
+MESSAGE(STATUS "Added ARKODE module")
diff --git a/src/arkode/LICENSE b/src/arkode/LICENSE
new file mode 100644
index 0000000..4909357
--- /dev/null
+++ b/src/arkode/LICENSE
@@ -0,0 +1,32 @@
+Copyright (c) 2013, Southern Methodist University
+Written by D. R. Reynolds, D. J. Gardner and J. M. Sexton.
+LLNL-CODE-667205
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met: 
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer. 
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the
+   distribution.
+
+3. Neither the name of Southern Methodist University nor the names of
+   its contributors may be used to endorse or promote products derived
+   from this software without specific prior written permission.  
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
diff --git a/src/arkode/README b/src/arkode/README
new file mode 100644
index 0000000..e56be67
--- /dev/null
+++ b/src/arkode/README
@@ -0,0 +1,72 @@
+                             ARKODE
+                   Release 1.1.0, September, 2016
+                       Daniel R. Reynolds
+                  Department of Mathematics, SMU
+
+ARKODE is a solver for multi-rate ODE systems (initial value problems) 
+given in explicit form M*dy/dt = f(t,y). It is written in ANSI standard C.
+
+ARKODE can be used both on serial and parallel (MPI) computers.  The main
+difference is in the NVECTOR module of vector kernels.  The desired
+version is obtained when compiling the example files by linking the
+appropriate library of NVECTOR kernels.  In the parallel version,
+communication between processors is done with the MPI (Message Passage
+Interface) system, with OpenMP, or with Pthreads.
+
+When used with the serial NVECTOR module, ARKODE provides both direct (dense 
+and band) and preconditioned Krylov (iterative) linear solvers. Many different
+iterative solvers are available: scaled preconditioned GMRES (SPGMR), 
+scaled preconditioned Flexible GMRES (SPFGMR), scaled preconditioned 
+conjugate gradient, scaled preconditioned BiCGStab (SPBCG), 
+and scaled preconditioned TFQMR (SPTFQMR). When ARKODE is used with 
+the parallel NVECTOR module, only the Krylov linear solvers are available. 
+(An approximate diagonal Jacobian option is available with both versions.)  
+For the serial version, there is a banded preconditioner module called 
+ARKBANDPRE available for use with the Krylov solvers, while for the 
+parallel version there is a preconditioner module called ARKBBDPRE 
+which provides a band-block-diagonal preconditioner.
+
+ARKODE is part of a software family called SUNDIALS: SUite of Nonlinear
+and DIfferential/ALgebraic equation Solvers.  This suite consists of
+ARKODE, CVODE, CVODES, KINSOL, IDAS, and IDA.  The directory structure 
+of the package supplied reflects this family relationship. 
+
+For use with Fortran applications, a set of Fortran/C interface routines,
+called FARKODE, is also supplied.  These are written in C, but assume that
+the user calling program and all user-supplied routines are in Fortran.
+
+The notes below provide the location of documentation, directions for the 
+installation of the ARKode package, and relevant references. Following that 
+is a brief history of revisions to the package.
+
+
+A. Documentation
+----------------
+
+/sundials/doc/arkode/ contains PDF files for the ARKODE User Guide [1]
+(ark_guide.pdf) and the ARKODE Examples [2] (ark_examples.pdf) documents.
+
+
+B. Installation
+---------------
+
+For basic installation instructions see the file /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see the "Installation Procedure"
+chapter in the ARKODE User Guide.
+
+
+C. References
+-------------
+
+[1] Daniel R. Reynolds, "User Documentation for ARKode v1.1.0," 
+    Southern Methodist University, March 2016.
+
+
+D. Releases
+-----------
+
+v. 1.1.0 - Sep. 2016
+v. 1.0.2 - Aug. 2015
+v. 1.0.1 - Mar. 2015
+v. 1.0.0 - Mar. 2015
+
diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c
new file mode 100644
index 0000000..cf4a7f3
--- /dev/null
+++ b/src/arkode/arkode.c
@@ -0,0 +1,6396 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the main ARKODE integrator.
+ * It is independent of the ARKODE linear solver in use.
+ *--------------------------------------------------------------*/
+
+/*===============================================================
+             Import Header Files                                 
+===============================================================*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "arkode_impl.h"
+#include <sundials/sundials_math.h>
+#include <sundials/sundials_types.h>
+
+#define NO_DEBUG_OUTPUT
+#ifdef DEBUG_OUTPUT
+#include <nvector/nvector_serial.h>
+#endif
+
+#define FIXED_LIN_TOL
+
+#ifdef __GNUC__
+#define SUNDIALS_UNUSED __attribute__ ((unused))
+#else
+#define SUNDIALS_UNUSED
+#endif
+
+/*===============================================================
+             Private Functions Prototypes
+===============================================================*/
+static void arkPrintMem(ARKodeMem ark_mem) SUNDIALS_UNUSED;
+static booleantype arkCheckNvector(N_Vector tmpl);
+static booleantype arkAllocVectors(ARKodeMem ark_mem, 
+				   N_Vector tmpl);
+static int arkAllocRKVectors(ARKodeMem ark_mem);
+static void arkFreeVectors(ARKodeMem ark_mem);
+
+static int arkAllocFPData(ARKodeMem ark_mem);
+static int arkResizeFPData(ARKodeMem ark_mem, 
+			   ARKVecResizeFn resize,
+			   void *resize_data,
+			   long int lrw_diff,
+			   long int liw_diff);
+static void arkFreeFPData(ARKodeMem ark_mem);
+
+static int arkInitialSetup(ARKodeMem ark_mem);
+static int arkHin(ARKodeMem ark_mem, realtype tout);
+static realtype arkUpperBoundH0(ARKodeMem ark_mem, 
+				realtype tdist);
+static int arkYddNorm(ARKodeMem ark_mem, realtype hg, 
+		      realtype *yddnrm);
+static int arkSetButcherTables(ARKodeMem ark_mem);
+static int arkCheckButcherTables(ARKodeMem ark_mem);
+
+static int arkStep(ARKodeMem ark_mem);
+static int arkPredict(ARKodeMem ark_mem, int istage);
+static int arkSet(ARKodeMem ark_mem);
+static int arkComputeSolutions(ARKodeMem ark_mem, realtype *dsm);
+static int arkDoErrorTest(ARKodeMem ark_mem, int *nflagPtr,
+			  realtype saved_t, int *nefPtr, 
+			  realtype dsm);
+static int arkCompleteStep(ARKodeMem ark_mem, realtype dsm);
+static int arkPrepareNextStep(ARKodeMem ark_mem);
+
+static int arkNls(ARKodeMem ark_mem, int nflag);
+static int arkNlsResid(ARKodeMem ark_mem, N_Vector y, 
+			N_Vector fy, N_Vector r);
+static int arkNlsNewton(ARKodeMem ark_mem, int nflag);
+static int arkNlsAccelFP(ARKodeMem ark_mem, int nflag);
+static int arkAndersonAcc(ARKodeMem ark_mem, N_Vector gval, 
+			  N_Vector fv, N_Vector x, N_Vector xold, 
+			  int iter, realtype *R, realtype *gamma);
+static int arkLs(ARKodeMem ark_mem, int nflag);
+static int arkHandleNFlag(ARKodeMem ark_mem, int *nflagPtr, 
+			  realtype saved_t, int *ncfPtr);
+
+static int arkHandleFailure(ARKodeMem ark_mem,int flag);
+
+static int arkDenseEval(ARKodeMem ark_mem, realtype tau,
+			int d, int order, N_Vector yout);
+
+static int arkFullRHS(ARKodeMem ark_mem, realtype t, 
+		      N_Vector y, N_Vector tmp, N_Vector f);
+
+static int arkEwtSetSS(ARKodeMem ark_mem, N_Vector ycur, 
+		       N_Vector weight);
+static int arkEwtSetSV(ARKodeMem ark_mem, N_Vector ycur, 
+		       N_Vector weight);
+static int arkRwtSetSS(ARKodeMem ark_mem, N_Vector My, 
+		       N_Vector weight);
+static int arkRwtSetSV(ARKodeMem ark_mem, N_Vector My, 
+		       N_Vector weight);
+
+static int arkAdapt(ARKodeMem ark_mem);
+static int arkAdaptPID(ARKodeMem ark_mem, realtype *hnew);
+static int arkAdaptPI(ARKodeMem ark_mem, realtype *hnew);
+static int arkAdaptI(ARKodeMem ark_mem, realtype *hnew);
+static int arkAdaptExpGus(ARKodeMem ark_mem, realtype *hnew);
+static int arkAdaptImpGus(ARKodeMem ark_mem, realtype *hnew);
+static int arkAdaptImExGus(ARKodeMem ark_mem, realtype *hnew);
+
+static int arkRootCheck1(ARKodeMem ark_mem);
+static int arkRootCheck2(ARKodeMem ark_mem);
+static int arkRootCheck3(ARKodeMem ark_mem);
+static int arkRootfind(ARKodeMem ark_mem);
+
+
+
+
+/*===============================================================
+  EXPORTED FUNCTIONS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ ARKodeCreate:
+
+ ARKodeCreate creates an internal memory block for a problem to 
+ be solved by ARKODE.  If successful, ARKodeCreate returns a 
+ pointer to the problem memory. This pointer should be passed to
+ ARKodeInit. If an initialization error occurs, ARKodeCreate 
+ prints an error message to standard err and returns NULL. 
+---------------------------------------------------------------*/
+void *ARKodeCreate()
+{
+  int i, j, iret;
+  ARKodeMem ark_mem;
+
+  ark_mem = NULL;
+  ark_mem = (ARKodeMem) malloc(sizeof(struct ARKodeMemRec));
+  if (ark_mem == NULL) {
+    arkProcessError(NULL, 0, "ARKODE", "ARKodeCreate", 
+		    MSGARK_ARKMEM_FAIL);
+    return(NULL);
+  }
+
+  /* Zero out ark_mem */
+  memset(ark_mem, 0, sizeof(struct ARKodeMemRec));
+
+  /* Set uround */
+  ark_mem->ark_uround = UNIT_ROUNDOFF;
+
+  /* Set default values for integrator optional inputs */
+  iret = ARKodeSetDefaults((void *)ark_mem);
+  if (iret != ARK_SUCCESS) {
+    arkProcessError(NULL, 0, "ARKODE", "ARKodeCreate", 
+		    "Error setting default solver options");
+    return(NULL);
+  }
+
+  /* Initialize internal RK parameters and coefficients */
+  ark_mem->ark_stages = 0;
+  ark_mem->ark_istage = 0;
+  ark_mem->ark_p = 0;
+  for (i=0; i<ARK_S_MAX; i++) {
+    for (j=0; j<ARK_S_MAX; j++) {
+      ARK_A(ark_mem->ark_Ae,i,j) = ZERO;
+      ARK_A(ark_mem->ark_Ai,i,j) = ZERO;
+    }
+    ark_mem->ark_ce[i]  = ZERO;
+    ark_mem->ark_ci[i]  = ZERO;
+    ark_mem->ark_be[i]  = ZERO;
+    ark_mem->ark_bi[i]  = ZERO;
+    ark_mem->ark_b2e[i] = ZERO;
+    ark_mem->ark_b2i[i] = ZERO;
+    ark_mem->ark_Fi[i]  = NULL;
+    ark_mem->ark_Fe[i]  = NULL;
+  }
+
+  /* Initialize root finding variables */
+  ark_mem->ark_glo     = NULL;
+  ark_mem->ark_ghi     = NULL;
+  ark_mem->ark_grout   = NULL;
+  ark_mem->ark_iroots  = NULL;
+  ark_mem->ark_rootdir = NULL;
+  ark_mem->ark_gfun    = NULL;
+  ark_mem->ark_nrtfn   = 0;
+  ark_mem->ark_gactive = NULL;
+  ark_mem->ark_mxgnull = 1;
+
+  /* Set default nonlinear solver choice to Newton,
+     initialize fixed-point solver variables */
+  ark_mem->ark_use_fp   = FALSE;
+  ark_mem->ark_fp_R     = NULL;
+  ark_mem->ark_fp_gamma = NULL;
+  ark_mem->ark_fp_df    = NULL;
+  ark_mem->ark_fp_dg    = NULL;
+  ark_mem->ark_fp_q     = NULL;
+  ark_mem->ark_fp_fval  = NULL;
+  ark_mem->ark_fp_fold  = NULL;
+  ark_mem->ark_fp_gold  = NULL;
+
+  /* Initialize diagnostics reporting variables */
+  ark_mem->ark_report  = FALSE;
+  ark_mem->ark_diagfp  = NULL;
+
+  /* Initialize lrw and liw */
+  ark_mem->ark_lrw = 58;   /* to be updated */
+  ark_mem->ark_liw = 40;   /* to be updated */
+
+  /* No mallocs have been done yet */
+  ark_mem->ark_VabstolMallocDone  = FALSE;
+  ark_mem->ark_VRabstolMallocDone = FALSE;
+  ark_mem->ark_MallocDone         = FALSE;
+
+  /* No user-supplied step postprocessing function yet */
+  ark_mem->ark_ProcessStep = NULL;
+
+  /* Return pointer to ARKODE memory block */
+  return((void *)ark_mem);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeInit:
+ 
+ ARKodeInit allocates and initializes memory for a problem. All 
+ inputs are checked for errors. If any error occurs during 
+ initialization, it is reported to the file whose file pointer 
+ is errfp and an error flag is returned. Otherwise, it returns 
+ ARK_SUCCESS.  This routine must be called prior to calling 
+ ARKode to evolve the problem.
+---------------------------------------------------------------*/
+int ARKodeInit(void *arkode_mem, ARKRhsFn fe, ARKRhsFn fi, 
+	       realtype t0, N_Vector y0)
+{
+  ARKodeMem ark_mem;
+  booleantype nvectorOK, allocOK;
+  long int lrw1, liw1;
+
+  /* Check arkode_mem */
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "ARKodeInit", 
+		    MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check for legal input parameters */
+  if (y0==NULL) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeInit", MSGARK_NULL_Y0);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Set implicit/explicit problem based on function pointers */
+  if (fe == NULL) ark_mem->ark_implicit = TRUE;
+  if (fi == NULL) ark_mem->ark_explicit = TRUE;
+
+  /* Check that at least one of fe,fi is supplied and is to be used */
+  if (ark_mem->ark_implicit && ark_mem->ark_explicit) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE",
+  		    "ARKodeInit", MSGARK_NULL_F);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Test if all required vector operations are implemented */
+  nvectorOK = arkCheckNvector(y0);
+  if (!nvectorOK) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeInit", MSGARK_BAD_NVECTOR);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Set space requirements for one N_Vector */
+  if (y0->ops->nvspace != NULL) {
+    N_VSpace(y0, &lrw1, &liw1);
+  } else {
+    lrw1 = 0;
+    liw1 = 0;
+  }
+  ark_mem->ark_lrw1 = lrw1;
+  ark_mem->ark_liw1 = liw1;
+
+
+  /* Allocate the solver vectors (using y0 as a template) */
+  allocOK = arkAllocVectors(ark_mem, y0);
+  if (!allocOK) {
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		    "ARKodeInit", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+
+  /* All error checking is complete at this point */
+
+  /* Copy the input parameters into ARKODE state */
+  ark_mem->ark_fe = fe;
+  ark_mem->ark_fi = fi;
+  ark_mem->ark_tn = t0;
+  ark_mem->ark_tnew = t0;
+
+  /* Set step parameters */
+  ark_mem->ark_hold  = ZERO;
+  ark_mem->ark_tolsf = ONE;
+
+  /* Set the linear solver addresses to NULL.
+     (We check != NULL later, in ARKode.) */
+  ark_mem->ark_linit  = NULL;
+  ark_mem->ark_lsetup = NULL;
+  ark_mem->ark_lsolve = NULL;
+  ark_mem->ark_lfree  = NULL;
+  ark_mem->ark_lmem   = NULL;
+  ark_mem->ark_lsolve_type = -1;
+
+  /* Set the mass matrix to identity, and mass matrix solver 
+     addresses to NULL. (We check != NULL later, in ARKode.) */
+  ark_mem->ark_mass_matrix = FALSE;
+  ark_mem->ark_minit       = NULL;
+  ark_mem->ark_msetup      = NULL;
+  ark_mem->ark_msolve      = NULL;
+  ark_mem->ark_mfree       = NULL;
+  ark_mem->ark_mtimes      = NULL;
+  ark_mem->ark_mtimes_data = NULL;
+  ark_mem->ark_mass_mem    = NULL;
+  ark_mem->ark_msolve_type = -1;
+
+  /* Initialize ycur */
+  N_VScale(ONE, y0, ark_mem->ark_ycur);
+
+  /* Initialize error history (1.0 => met target accuracy) */
+  ark_mem->ark_hadapt_ehist[0] = ONE;
+  ark_mem->ark_hadapt_ehist[1] = ONE;
+  ark_mem->ark_hadapt_ehist[2] = ONE;
+  ark_mem->ark_eRNrm = 1.0;
+
+  /* Initialize step history */
+  ark_mem->ark_hadapt_hhist[0] = ZERO;
+  ark_mem->ark_hadapt_hhist[1] = ZERO;
+  ark_mem->ark_hadapt_hhist[2] = ZERO;
+
+  /* Initialize all the counters */
+  ark_mem->ark_nst          = 0;
+  ark_mem->ark_nst_acc      = 0;
+  ark_mem->ark_nst_exp      = 0;
+  ark_mem->ark_nst_attempts = 0;
+  ark_mem->ark_nfe          = 0;
+  ark_mem->ark_nfi          = 0;
+  ark_mem->ark_ncfn         = 0;
+  ark_mem->ark_nmassfails   = 0;
+  ark_mem->ark_netf         = 0;
+  ark_mem->ark_nni          = 0;
+  ark_mem->ark_nsetups      = 0;
+  ark_mem->ark_nhnil        = 0;
+  ark_mem->ark_nstlp        = 0;
+  ark_mem->ark_nge          = 0;
+  ark_mem->ark_irfnd        = 0;
+  ark_mem->ark_mass_solves  = 0;
+  ark_mem->ark_mass_mult    = 0;
+
+  /* Initialize other integrator optional outputs */
+  ark_mem->ark_h0u    = ZERO;
+  ark_mem->ark_next_h = ZERO;
+
+  /* Initially, rwt should point to ewt */
+  ark_mem->ark_rwt_is_ewt = TRUE;
+
+  /* Indicate that problem size is new */
+  ark_mem->ark_resized = TRUE;
+  ark_mem->ark_firststage = TRUE;
+
+  /* Problem has been successfully initialized */
+  ark_mem->ark_MallocDone = TRUE;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeReInit:
+
+ ARKodeReInit re-initializes ARKODE's memory for a problem, 
+ assuming it has already been allocated in a prior ARKodeInit 
+ call.  All problem specification inputs are checked for errors.
+ If any error occurs during initialization, it is reported to 
+ the file whose file pointer is errfp.  This routine should only
+ be called after ARKodeInit, and only when the problem dynamics 
+ or desired solvers have changed dramatically, so that the
+ problem integration should resume as if started from scratch.
+
+ The return value is ARK_SUCCESS = 0 if no errors occurred, or
+ a negative value otherwise.
+---------------------------------------------------------------*/
+int ARKodeReInit(void *arkode_mem, ARKRhsFn fe, ARKRhsFn fi, 
+		 realtype t0, N_Vector y0)
+{
+  ARKodeMem ark_mem;
+ 
+  /* Check arkode_mem */
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeReInit", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if arkode_mem was allocated */
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeReInit", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Check for legal input parameters */
+  if (y0 == NULL) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeReInit", MSGARK_NULL_Y0);
+    return(ARK_ILL_INPUT);
+  }
+  
+  /* Set implicit/explicit problem based on function pointers */
+  ark_mem->ark_implicit = ark_mem->ark_explicit = FALSE;
+  if (fe == NULL) ark_mem->ark_implicit = TRUE;
+  if (fi == NULL) ark_mem->ark_explicit = TRUE;
+
+  /* Check that at least one of fe,fi is supplied and is to be used */
+  if (ark_mem->ark_implicit && ark_mem->ark_explicit) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE",
+  		    "ARKodeInit", MSGARK_NULL_F);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Copy the input parameters into ARKODE state */
+  ark_mem->ark_fe = fe;
+  ark_mem->ark_fi = fi;
+  ark_mem->ark_tn = t0;
+  ark_mem->ark_tnew = t0;
+  
+  /* Set step parameters */
+  ark_mem->ark_hold  = ZERO;
+  ark_mem->ark_tolsf = ONE;
+
+  /* Do not reset the linear solver addresses to NULL.  This means 
+     that if the user does not re-set these manually, we'll re-use 
+     the linear solver routines that were set during ARKodeInit. */
+
+  /* Initialize ycur */
+  N_VScale(ONE, y0, ark_mem->ark_ycur);
+ 
+  /* Initialize error history (1.0 => met target accuracy) */
+  ark_mem->ark_hadapt_ehist[0] = ONE;
+  ark_mem->ark_hadapt_ehist[1] = ONE;
+  ark_mem->ark_hadapt_ehist[2] = ONE;
+  ark_mem->ark_eRNrm = 1.0;
+
+  /* Initialize step history */
+  ark_mem->ark_hadapt_hhist[0] = ZERO;
+  ark_mem->ark_hadapt_hhist[1] = ZERO;
+  ark_mem->ark_hadapt_hhist[2] = ZERO;
+
+  /* Initialize all the counters */
+  ark_mem->ark_nst          = 0;
+  ark_mem->ark_nst_acc      = 0;
+  ark_mem->ark_nst_exp      = 0;
+  ark_mem->ark_nst_attempts = 0;
+  ark_mem->ark_nfe          = 0;
+  ark_mem->ark_nfi          = 0;
+  ark_mem->ark_ncfn         = 0;
+  ark_mem->ark_nmassfails   = 0;
+  ark_mem->ark_netf         = 0;
+  ark_mem->ark_nni          = 0;
+  ark_mem->ark_nsetups      = 0;
+  ark_mem->ark_nhnil        = 0;
+  ark_mem->ark_nstlp        = 0;
+  ark_mem->ark_nge          = 0;
+  ark_mem->ark_irfnd        = 0;
+  ark_mem->ark_mass_solves  = 0;
+  ark_mem->ark_mass_mult    = 0;
+
+  /* Indicate that problem size is new */
+  ark_mem->ark_resized = TRUE;
+  ark_mem->ark_firststage = TRUE;
+
+  /* Initialize other integrator optional outputs */
+  ark_mem->ark_h0u    = ZERO;
+  ark_mem->ark_next_h = ZERO;
+
+  /* Problem has been successfully re-initialized */
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeResize:
+
+ ARKodeResize re-initializes ARKODE's memory for a problem with a
+ changing vector size.  It is assumed that the problem dynamics 
+ before and after the vector resize will be comparable, so that 
+ all time-stepping heuristics prior to calling ARKodeResize 
+ remain valid after the call.  If instead the dynamics should be 
+ re-calibrated, the ARKode memory structure should be deleted 
+ with a call to ARKodeFree, and re-created with calls to 
+ ARKodeCreate and ARKodeInit.
+
+ To aid in the vector-resize operation, the user can supply a 
+ vector resize function, that will take as input an N_Vector with
+ the previous size, and return as output a corresponding vector 
+ of the new size.  If this function (of type ARKVecResizeFn) is 
+ not supplied (i.e. is set to NULL), then all existing N_Vectors 
+ will be destroyed and re-cloned from the input vector.
+
+ In the case that the dynamical time scale should be modified 
+ slightly from the previous time scale, an input "hscale" is 
+ allowed, that will re-scale the upcoming time step by the 
+ specified factor.  If a value <= 0 is specified, the default of 
+ 1.0 will be used.
+
+ Other arguments:
+   arkode_mem       Existing ARKode memory data structure.
+   ynew             The newly-sized solution vector, holding 
+                    the current dependent variable values.
+   t0               The current value of the independent 
+                    variable.
+   resize_data      User-supplied data structure that will be 
+                    passed to the supplied resize function.
+
+ The return value is ARK_SUCCESS = 0 if no errors occurred, or
+ a negative value otherwise.
+---------------------------------------------------------------*/
+int ARKodeResize(void *arkode_mem, N_Vector y0, 
+		 realtype hscale, realtype t0, 
+		 ARKVecResizeFn resize, void *resize_data)
+{
+  ARKodeMem ark_mem;
+  long int lrw1=0, liw1=0;
+  long int lrw_diff, liw_diff;
+  int ier, i;
+ 
+  /* Check arkode_mem */
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeResize", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if arkode_mem was allocated */
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeResize", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Check for legal input parameters */
+  if (y0 == NULL) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeResize", MSGARK_NULL_Y0);
+    return(ARK_ILL_INPUT);
+  }
+  
+  /* Copy the input parameters into ARKODE state */
+  ark_mem->ark_tn = t0;
+  ark_mem->ark_tnew = t0;
+
+  /* Update time-stepping parameters */
+  /*   adjust upcoming step size depending on hscale */
+  if (hscale < 0.0)  hscale = 1.0;
+  if (hscale != 1.0) {
+
+    /* Encode hscale into ark_mem structure */
+    ark_mem->ark_eta = hscale;
+    ark_mem->ark_hprime *= hscale;
+
+    /* If next step would overtake tstop, adjust stepsize */
+    if ( ark_mem->ark_tstopset ) 
+      if ( (ark_mem->ark_tn+ark_mem->ark_hprime-ark_mem->ark_tstop)*ark_mem->ark_hprime > ZERO ) {
+	ark_mem->ark_hprime = (ark_mem->ark_tstop-ark_mem->ark_tn)*(ONE-FOUR*ark_mem->ark_uround);
+	ark_mem->ark_eta = ark_mem->ark_hprime/ark_mem->ark_h;
+      }
+
+  }
+
+  /* Determing change in vector sizes */
+  if (y0->ops->nvspace != NULL) 
+    N_VSpace(y0, &lrw1, &liw1);
+  lrw_diff = lrw1 - ark_mem->ark_lrw1;
+  liw_diff = liw1 - ark_mem->ark_liw1;
+  ark_mem->ark_lrw1 = lrw1;
+  ark_mem->ark_liw1 = liw1;
+
+  /* Resize the ARKode vectors */
+  /*     Vabstol */
+  if (ark_mem->ark_Vabstol != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_Vabstol);
+      ark_mem->ark_Vabstol = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_Vabstol, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     VRabstol */
+  if (ark_mem->ark_VRabstol != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_VRabstol);
+      ark_mem->ark_VRabstol = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_VRabstol, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     ark_Fe */
+  for (i=0; i<ARK_S_MAX; i++) {
+    if (ark_mem->ark_Fe[i] != NULL) {
+      if (resize == NULL) {
+	N_VDestroy(ark_mem->ark_Fe[i]);
+	ark_mem->ark_Fe[i] = N_VClone(y0);
+      } else {
+	if (resize(ark_mem->ark_Fe[i], y0, resize_data)) {
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "ARKodeResize", MSGARK_RESIZE_FAIL);
+	  return(ARK_ILL_INPUT);
+	}
+      }
+      ark_mem->ark_lrw += lrw_diff;
+      ark_mem->ark_liw += liw_diff;
+    }
+  }
+  /*     ark_Fi */
+  for (i=0; i<ARK_S_MAX; i++) {
+    if (ark_mem->ark_Fi[i] != NULL) {
+      if (resize == NULL) {
+	N_VDestroy(ark_mem->ark_Fi[i]);
+	ark_mem->ark_Fi[i] = N_VClone(y0);
+      } else {
+	if (resize(ark_mem->ark_Fi[i], y0, resize_data)) {
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "ARKodeResize", MSGARK_RESIZE_FAIL);
+	  return(ARK_ILL_INPUT);
+	}
+      }
+      ark_mem->ark_lrw += lrw_diff;
+      ark_mem->ark_liw += liw_diff;
+    }
+  }
+  /*     ewt */
+  if (ark_mem->ark_ewt != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_ewt);
+      ark_mem->ark_ewt = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_ewt, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     rwt  */
+  if (ark_mem->ark_rwt_is_ewt) {      /* update pointer to ewt */
+    ark_mem->ark_rwt = ark_mem->ark_ewt;
+  } else {                            /* resize if distinct from ewt */
+    if (ark_mem->ark_rwt != NULL) {
+      if (resize == NULL) {
+	N_VDestroy(ark_mem->ark_rwt);
+	ark_mem->ark_rwt = N_VClone(y0);
+      } else {
+	if (resize(ark_mem->ark_rwt, y0, resize_data)) {
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "ARKodeResize", MSGARK_RESIZE_FAIL);
+	  return(ARK_ILL_INPUT);
+	}
+      }
+      ark_mem->ark_lrw += lrw_diff;
+      ark_mem->ark_liw += liw_diff;
+    }
+  }
+  /*     ycur */
+  if (ark_mem->ark_ycur != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_ycur);
+      ark_mem->ark_ycur = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_ycur, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     acor */
+  if (ark_mem->ark_acor != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_acor);
+      ark_mem->ark_acor = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_acor, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     sdata */
+  if (ark_mem->ark_sdata != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_sdata);
+      ark_mem->ark_sdata = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_sdata, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     tempv */
+  if (ark_mem->ark_tempv != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_tempv);
+      ark_mem->ark_tempv = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_tempv, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     ftemp */
+  if (ark_mem->ark_ftemp != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_ftemp);
+      ark_mem->ark_ftemp = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_ftemp, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     fold */
+  if (ark_mem->ark_fold != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_fold);
+      ark_mem->ark_fold = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_fold, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     fnew */
+  if (ark_mem->ark_fnew != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_fnew);
+      ark_mem->ark_fnew = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_fnew, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     yold */
+  if (ark_mem->ark_yold != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_yold);
+      ark_mem->ark_yold = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_yold, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+  /*     ynew */
+  if (ark_mem->ark_ynew != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_ynew);
+      ark_mem->ark_ynew = N_VClone(y0);
+    } else {
+      if (resize(ark_mem->ark_ynew, y0, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+
+
+  /* Resize fixed-point solver memory */
+  if (ark_mem->ark_use_fp) {
+    ier = arkResizeFPData(ark_mem, resize, resize_data, 
+			  lrw_diff, liw_diff);
+    if (ier != ARK_SUCCESS) {
+      arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		      "ARKodeResize", MSGARK_MEM_FAIL);
+      return(ARK_MEM_FAIL);
+    }
+  }
+
+
+  /* Copy y0 into ark_ycur to set the current solution */
+  N_VScale(ONE, y0, ark_mem->ark_ycur);
+
+  /* Indicate that problem size is new */
+  ark_mem->ark_resized = TRUE;
+  ark_mem->ark_firststage = TRUE;
+  
+  /* Problem has been successfully re-sized */
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSStolerances:
+ ARKodeSVtolerances:
+ ARKodeWFtolerances:
+
+ These functions specify the integration tolerances. One of them
+ SHOULD be called before the first call to ARKode; otherwise 
+ default values of reltol=1e-4 and abstol=1e-9 will be used, 
+ which may be entirely incorrect for a specific problem.
+
+ ARKodeSStolerances specifies scalar relative and absolute 
+   tolerances.
+
+ ARKodeSVtolerances specifies scalar relative tolerance and a 
+   vector absolute tolerance (a potentially different absolute 
+   tolerance for each vector component).
+
+ ARKodeWFtolerances specifies a user-provides function (of type
+   ARKEwtFn) which will be called to set the error weight vector.
+---------------------------------------------------------------*/
+int ARKodeSStolerances(void *arkode_mem, realtype reltol, 
+		       realtype abstol)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSStolerances", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeSStolerances", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Check inputs */
+  if (reltol < ZERO) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSStolerances", MSGARK_BAD_RELTOL);
+    return(ARK_ILL_INPUT);
+  }
+  if (abstol < ZERO) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSStolerances", MSGARK_BAD_ABSTOL);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Copy tolerances into memory */
+  ark_mem->ark_reltol  = reltol;
+  ark_mem->ark_Sabstol = abstol;
+  ark_mem->ark_itol    = ARK_SS;
+
+  /* enforce use of arkEwtSet */
+  ark_mem->ark_user_efun = FALSE;
+  ark_mem->ark_efun      = arkEwtSet;
+  ark_mem->ark_e_data    = ark_mem;
+
+  return(ARK_SUCCESS);
+}
+
+int ARKodeSVtolerances(void *arkode_mem, realtype reltol, 
+		       N_Vector abstol)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSVtolerances", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeSVtolerances", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Check inputs */
+  if (reltol < ZERO) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSVtolerances", MSGARK_BAD_RELTOL);
+    return(ARK_ILL_INPUT);
+  }
+  if (N_VMin(abstol) < ZERO) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSVtolerances", MSGARK_BAD_ABSTOL);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Copy tolerances into memory */
+  if ( !(ark_mem->ark_VabstolMallocDone) ) {
+    ark_mem->ark_Vabstol = N_VClone(ark_mem->ark_ewt);
+    ark_mem->ark_lrw += ark_mem->ark_lrw1;
+    ark_mem->ark_liw += ark_mem->ark_liw1;
+    ark_mem->ark_VabstolMallocDone = TRUE;
+  }
+  N_VScale(ONE, abstol, ark_mem->ark_Vabstol);
+  ark_mem->ark_reltol = reltol;
+  ark_mem->ark_itol   = ARK_SV;
+
+  /* enforce use of arkEwtSet */
+  ark_mem->ark_user_efun = FALSE;
+  ark_mem->ark_efun      = arkEwtSet;
+  ark_mem->ark_e_data    = ark_mem;
+
+  return(ARK_SUCCESS);
+}
+
+int ARKodeWFtolerances(void *arkode_mem, ARKEwtFn efun)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeWFtolerances", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeWFtolerances", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Copy tolerance data into memory */
+  ark_mem->ark_itol      = ARK_WF;
+  ark_mem->ark_user_efun = TRUE;
+  ark_mem->ark_efun      = efun;
+  ark_mem->ark_e_data    = NULL; /* set to user_data in InitialSetup */
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeResStolerance:
+ ARKodeResVtolerance:
+ ARKodeResFtolerance:
+
+ These functions specify the absolute residual tolerance. 
+ Specification of the absolute residual tolerance is only 
+ necessary for problems with non-identity mass matrices in which
+ the units of the solution vector y dramatically differ from the 
+ units of the ODE right-hand side f(t,y).  If this occurs, one 
+ of these routines SHOULD be called before the first call to 
+ ARKode; otherwise the default value of rabstol=1e-9 will be 
+ used, which may be entirely incorrect for a specific problem.
+
+ ARKodeResStolerances specifies a scalar residual tolerance.
+
+ ARKodeResVtolerances specifies a vector residual tolerance 
+  (a potentially different absolute residual tolerance for 
+   each vector component).
+
+ ARKodeResFtolerances specifies a user-provides function (of 
+   type ARKRwtFn) which will be called to set the residual 
+   weight vector.
+---------------------------------------------------------------*/
+int ARKodeResStolerance(void *arkode_mem, realtype rabstol)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeResStolerances", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeResStolerances", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Check inputs */
+  if (rabstol < ZERO) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeResStolerances", MSGARK_BAD_RABSTOL);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Allocate space for rwt if necessary */
+  if (ark_mem->ark_rwt_is_ewt) {
+    ark_mem->ark_rwt_is_ewt = FALSE;
+    ark_mem->ark_rwt = N_VClone(ark_mem->ark_ewt);
+    ark_mem->ark_lrw += ark_mem->ark_lrw1;
+    ark_mem->ark_liw += ark_mem->ark_liw1;
+  }
+
+  /* Copy tolerances into memory */
+  ark_mem->ark_SRabstol = rabstol;
+  ark_mem->ark_ritol    = ARK_SS;
+
+  /* enforce use of arkRwtSet */
+  ark_mem->ark_user_efun = FALSE;
+  ark_mem->ark_rfun      = arkRwtSet;
+  ark_mem->ark_r_data    = ark_mem;
+
+  return(ARK_SUCCESS);
+}
+
+int ARKodeResVtolerance(void *arkode_mem, N_Vector rabstol)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeResVtolerances", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeResVtolerances", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Check inputs */
+  if (N_VMin(rabstol) < ZERO) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeResVtolerances", MSGARK_BAD_RABSTOL);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Allocate space for rwt if necessary */
+  if (ark_mem->ark_rwt_is_ewt) {
+    ark_mem->ark_rwt_is_ewt = FALSE;
+    ark_mem->ark_rwt = N_VClone(ark_mem->ark_ewt);
+    ark_mem->ark_lrw += ark_mem->ark_lrw1;
+    ark_mem->ark_liw += ark_mem->ark_liw1;
+  }
+
+  /* Copy tolerances into memory */
+  if ( !(ark_mem->ark_VRabstolMallocDone) ) {
+    ark_mem->ark_VRabstol = N_VClone(ark_mem->ark_rwt);
+    ark_mem->ark_lrw += ark_mem->ark_lrw1;
+    ark_mem->ark_liw += ark_mem->ark_liw1;
+    ark_mem->ark_VRabstolMallocDone = TRUE;
+  }
+  N_VScale(ONE, rabstol, ark_mem->ark_VRabstol);
+  ark_mem->ark_ritol = ARK_SV;
+
+
+  /* enforce use of arkRwtSet */
+  ark_mem->ark_user_efun = FALSE;
+  ark_mem->ark_rfun      = arkRwtSet;
+  ark_mem->ark_r_data    = ark_mem;
+
+  return(ARK_SUCCESS);
+}
+
+int ARKodeResFtolerance(void *arkode_mem, ARKRwtFn rfun)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeResFtolerances", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", 
+		    "ARKodeResFtolerances", MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+
+  /* Allocate space for rwt if necessary */
+  if (ark_mem->ark_rwt_is_ewt) {
+    ark_mem->ark_rwt_is_ewt = FALSE;
+    ark_mem->ark_rwt = N_VClone(ark_mem->ark_ewt);
+    ark_mem->ark_lrw += ark_mem->ark_lrw1;
+    ark_mem->ark_liw += ark_mem->ark_liw1;
+  }
+
+  /* Copy tolerance data into memory */
+  ark_mem->ark_ritol     = ARK_WF;
+  ark_mem->ark_user_rfun = TRUE;
+  ark_mem->ark_rfun      = rfun;
+  ark_mem->ark_r_data    = NULL; /* set to user_data in InitialSetup */
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKode:
+
+ This routine is the main driver of the ARKODE package. 
+
+ It integrates over a time interval defined by the user, by 
+ calling arkStep to do internal time steps.
+
+ The first time that ARKode is called for a successfully 
+ initialized problem, it computes a tentative initial step size.
+
+ ARKode supports two modes as specified by itask: ARK_NORMAL and
+ ARK_ONE_STEP.  In the ARK_NORMAL mode, the solver steps until 
+ it reaches or passes tout and then interpolates to obtain 
+ y(tout).  In the ARK_ONE_STEP mode, it takes one internal step 
+ and returns.  The behavior of both modes can be over-rided 
+ through user-specification of ark_tstop (through the
+ ARKodeSetStopTime function), in which case if a solver step 
+ would pass tstop, the step is shortened so that it stops at
+ exactly the specified stop time, and hence interpolation of 
+ y(tout) is not required.
+---------------------------------------------------------------*/
+int ARKode(void *arkode_mem, realtype tout, N_Vector yout, 
+	   realtype *tret, int itask)
+{
+  ARKodeMem ark_mem;
+  long int nstloc;
+  int retval, hflag, kflag, istate, ir, ier, irfndp;
+  int ewtsetOK;
+  realtype troundoff, tout_hin, rh, nrm;
+  booleantype inactive_roots;
+
+
+  /*-------------------------------------
+    1. Check and process inputs
+  -------------------------------------*/
+
+  /* Check if arkode_mem exists */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "ARKode", 
+		    MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if arkode_mem was allocated */
+  if (ark_mem->ark_MallocDone == FALSE) {
+    arkProcessError(ark_mem, ARK_NO_MALLOC, "ARKODE", "ARKode", 
+		    MSGARK_NO_MALLOC);
+    return(ARK_NO_MALLOC);
+  }
+  
+  /* Check for yout != NULL */
+  if ((ark_mem->ark_y = yout) == NULL) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+		    MSGARK_YOUT_NULL);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Check for tret != NULL */
+  if (tret == NULL) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+		    MSGARK_TRET_NULL);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Check for valid itask */
+  if ( (itask != ARK_NORMAL) && (itask != ARK_ONE_STEP) ) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+		    MSGARK_BAD_ITASK);
+    return(ARK_ILL_INPUT);
+  }
+
+  if (itask == ARK_NORMAL) ark_mem->ark_toutc = tout;
+  ark_mem->ark_taskc = itask;
+
+
+  /*----------------------------------------
+    2. Initializations performed only at
+       the first step (nst=0):
+       - initial setup
+       - compute initial step size
+       - check for approach to tstop
+       - check for approach to a root
+  ----------------------------------------*/
+  if (ark_mem->ark_nst == 0) {
+
+    /* initialize tret values to initialization time */
+    ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+
+    /* Temporarily set ark_h and perform initial integrator setup */
+    ark_mem->ark_h = SUNRabs(tout - ark_mem->ark_tn);
+    if (ark_mem->ark_h == ZERO)  ark_mem->ark_h = ONE;
+    ier = arkInitialSetup(ark_mem);
+    if (ier!= ARK_SUCCESS) return(ier);
+    
+    /* Copy f(t0,y0) into ark_fold */
+    /*   if (!ark_mem->ark_explicit)*/
+    N_VScale(ONE, ark_mem->ark_fnew, ark_mem->ark_fold);
+    
+    /* Test input tstop for legality. */
+    if ( ark_mem->ark_tstopset ) {
+      if ( (ark_mem->ark_tstop - ark_mem->ark_tn)*(tout - ark_mem->ark_tn) <= ZERO ) {
+        arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKVODE", "ARKode", 
+			MSGARK_BAD_TSTOP, ark_mem->ark_tstop, ark_mem->ark_tn);
+        return(ARK_ILL_INPUT);
+      }
+    }
+
+    /* Set initial h (from H0 or arkHin). */
+    ark_mem->ark_h = ark_mem->ark_hin;
+    if ( (ark_mem->ark_h != ZERO) && 
+	 ((tout-ark_mem->ark_tn)*ark_mem->ark_h < ZERO) ) {
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+		      MSGARK_BAD_H0);
+      return(ARK_ILL_INPUT);
+    }
+    if (ark_mem->ark_h == ZERO) {
+      /* Again, temporarily set ark_h for estimating an optimal value */
+      ark_mem->ark_h = SUNRabs(tout - ark_mem->ark_tn);
+      if (ark_mem->ark_h == ZERO)  ark_mem->ark_h = ONE;
+      /* Estimate the first step size */
+      tout_hin = tout;
+      if ( ark_mem->ark_tstopset && 
+	   (tout-ark_mem->ark_tn)*(tout-ark_mem->ark_tstop) > ZERO ) 
+	tout_hin = ark_mem->ark_tstop; 
+      hflag = arkHin(ark_mem, tout_hin);
+      if (hflag != ARK_SUCCESS) {
+        istate = arkHandleFailure(ark_mem, hflag);
+        return(istate);
+      }
+    }
+    rh = SUNRabs(ark_mem->ark_h)*ark_mem->ark_hmax_inv;
+    if (rh > ONE) ark_mem->ark_h /= rh;
+    if (SUNRabs(ark_mem->ark_h) < ark_mem->ark_hmin)
+      ark_mem->ark_h *= ark_mem->ark_hmin/SUNRabs(ark_mem->ark_h);
+
+    /* Check for approach to tstop */
+    if (ark_mem->ark_tstopset) {
+      if ( (ark_mem->ark_tn + ark_mem->ark_h - ark_mem->ark_tstop)*ark_mem->ark_h > ZERO ) {
+        ark_mem->ark_h = (ark_mem->ark_tstop - ark_mem->ark_tn)*(ONE-FOUR*ark_mem->ark_uround);
+      }
+    }
+
+    /* Set initial time step factors */
+    ark_mem->ark_h0u    = ark_mem->ark_h;
+    ark_mem->ark_hprime = ark_mem->ark_h;
+
+    /* Check for zeros of root function g at and near t0. */
+    if (ark_mem->ark_nrtfn > 0) {
+      retval = arkRootCheck1(ark_mem);
+
+      if (retval == ARK_RTFUNC_FAIL) {
+        arkProcessError(ark_mem, ARK_RTFUNC_FAIL, "ARKODE", "arkRootCheck1", 
+			MSGARK_RTFUNC_FAILED, ark_mem->ark_tn);
+        return(ARK_RTFUNC_FAIL);
+      }
+    }
+
+  } /* end of first call block */
+
+
+  /*----------------------------------------
+    2b. Initializations performed only in 
+        the first step after the problem has
+        been resized:
+       - re-initialize the linear solver
+       - fills ynew, fnew and fold arrays
+       - checks for approach to tstop
+       - checks for root near t0
+  ----------------------------------------*/
+  if (ark_mem->ark_nst > 0 && ark_mem->ark_resized) {
+
+    /* Re-initialize the linear solver (assumes that solver 
+       memory has already been resized appropriately) */
+    if (!ark_mem->ark_explicit) {
+      if (ark_mem->ark_linit != NULL) {
+	ier = ark_mem->ark_linit(ark_mem);
+	if (ier != 0) {
+	  arkProcessError(ark_mem, ARK_LINIT_FAIL, "ARKODE", 
+			  "ARKode", MSGARK_LINIT_FAIL);
+	  return(ARK_LINIT_FAIL);
+	}
+      }
+    }
+
+    /* Re-initialize the mass matrix solver (assumes that solver 
+       memory has already been resized appropriately) */
+    if (ark_mem->ark_minit != NULL) {
+      ier = ark_mem->ark_minit(ark_mem);
+      if (ier != 0) {
+	arkProcessError(ark_mem, ARK_MASSINIT_FAIL, "ARKODE", 
+			"ARKode", MSGARK_MASSINIT_FAIL);
+	return(ARK_MASSINIT_FAIL);
+      }
+    }
+
+    /* Fill initial ynew and fnew arrays */
+    N_VScale(ONE, ark_mem->ark_ycur, ark_mem->ark_ynew);
+    ier = arkFullRHS(ark_mem, ark_mem->ark_tn, ark_mem->ark_ycur,
+		     ark_mem->ark_ftemp, ark_mem->ark_fnew);
+
+    /* Load updated error weights */
+    ier = ark_mem->ark_efun(ark_mem->ark_ycur,
+			    ark_mem->ark_ewt, 
+			    ark_mem->ark_e_data);
+    if (ier != 0) {
+      if (ark_mem->ark_itol == ARK_WF) 
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_EWT_FAIL);
+      else 
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeResize", MSGARK_BAD_EWT);
+      return(ARK_ILL_INPUT);
+    }
+
+    /* Load updated residual weights */
+    if (!ark_mem->ark_rwt_is_ewt) {
+      ier = ark_mem->ark_rfun(ark_mem->ark_ycur,
+			      ark_mem->ark_rwt, 
+			      ark_mem->ark_r_data);
+      if (ier != 0) {
+	if (ark_mem->ark_itol == ARK_WF) 
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "ARKodeResize", MSGARK_RWT_FAIL);
+	else 
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "ARKodeResize", MSGARK_BAD_RWT);
+	return(ARK_ILL_INPUT);
+      }
+    }
+
+    /* if the problem involves a non-identity mass matrix, update fnew here */
+    if (ark_mem->ark_mass_matrix) {
+      N_VScale(ark_mem->ark_h, ark_mem->ark_fnew, ark_mem->ark_fnew);   /* scale RHS */
+      retval = ark_mem->ark_msolve(ark_mem, ark_mem->ark_fnew, ark_mem->ark_rwt); 
+      /* retval = ark_mem->ark_msolve(ark_mem, ark_mem->ark_fnew, ark_mem->ark_ewt);  */
+      N_VScale(ONE/ark_mem->ark_h, ark_mem->ark_fnew, ark_mem->ark_fnew);   /* scale result */
+      ark_mem->ark_mass_solves++;
+      if (retval != ARK_SUCCESS) {
+	ark_mem->ark_nmassfails++;
+	arkProcessError(ark_mem, ARK_MASSSOLVE_FAIL, "ARKODE", 
+			"ARKode", "Mass matrix solver failure");
+	return(ARK_MASSSOLVE_FAIL);
+      }
+    }
+  
+    /* Copy f(t0,y0) into ark_fold */
+    /* if (!ark_mem->ark_explicit) */
+    N_VScale(ONE, ark_mem->ark_fnew, ark_mem->ark_fold);
+
+    /* Check for legal tstop (correct direction of integration) */
+    if (ark_mem->ark_tstopset) {
+      if ( (ark_mem->ark_tstop - ark_mem->ark_tn)*ark_mem->ark_h < ZERO ) {
+        arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+			MSGARK_BAD_TSTOP, ark_mem->ark_tstop, ark_mem->ark_tn);
+        return(ARK_ILL_INPUT);
+      }
+    }
+
+    /* Check for zeros of root function g at and near t0. */
+    if (ark_mem->ark_nrtfn > 0) {
+      retval = arkRootCheck1(ark_mem);
+
+      if (retval == ARK_RTFUNC_FAIL) {
+        arkProcessError(ark_mem, ARK_RTFUNC_FAIL, "ARKODE", "arkRootCheck1", 
+			MSGARK_RTFUNC_FAILED, ark_mem->ark_tn);
+        return(ARK_RTFUNC_FAIL);
+      }
+    }
+
+  } /* end of first-step-after-resize call block */
+
+
+  /*------------------------------------------------------
+    3. At following steps, perform stop tests:
+       - check for root in last step
+       - check if we passed tstop
+       - check if we passed tout (NORMAL mode)
+       - check if current tn was returned (ONE_STEP mode)
+       - check if we are close to tstop
+         (adjust step size if needed)
+  -------------------------------------------------------*/
+  if (ark_mem->ark_nst > 0 && !ark_mem->ark_resized) {
+
+    /* Estimate an infinitesimal time interval to be used as
+       a roundoff for time quantities (based on current time 
+       and step size) */
+    troundoff = FUZZ_FACTOR*ark_mem->ark_uround *
+      (SUNRabs(ark_mem->ark_tn) + SUNRabs(ark_mem->ark_h));
+
+    /* First, check for a root in the last step taken, other than the
+       last root found, if any.  If itask = ARK_ONE_STEP and y(tn) was not
+       returned because of an intervening root, return y(tn) now.     */
+    if (ark_mem->ark_nrtfn > 0) {
+
+      irfndp = ark_mem->ark_irfnd;
+      
+      retval = arkRootCheck2(ark_mem);
+
+      if (retval == CLOSERT) {
+        arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkRootCheck2", 
+			MSGARK_CLOSE_ROOTS, ark_mem->ark_tlo);
+        return(ARK_ILL_INPUT);
+      } else if (retval == ARK_RTFUNC_FAIL) {
+        arkProcessError(ark_mem, ARK_RTFUNC_FAIL, "ARKODE", "arkRootCheck2", 
+			MSGARK_RTFUNC_FAILED, ark_mem->ark_tlo);
+        return(ARK_RTFUNC_FAIL);
+      } else if (retval == RTFOUND) {
+        ark_mem->ark_tretlast = *tret = ark_mem->ark_tlo;
+        return(ARK_ROOT_RETURN);
+      }
+
+      /* If tn is distinct from tretlast (within roundoff),
+         check remaining interval for roots */
+      if ( SUNRabs(ark_mem->ark_tn - ark_mem->ark_tretlast) > troundoff ) {
+
+        retval = arkRootCheck3(ark_mem);
+
+        if (retval == ARK_SUCCESS) {     /* no root found */
+          ark_mem->ark_irfnd = 0;
+          if ((irfndp == 1) && (itask == ARK_ONE_STEP)) {
+            ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+            N_VScale(ONE, ark_mem->ark_ycur, yout);
+            return(ARK_SUCCESS);
+          }
+        } else if (retval == RTFOUND) {  /* a new root was found */
+          ark_mem->ark_irfnd = 1;
+          ark_mem->ark_tretlast = *tret = ark_mem->ark_tlo;
+          return(ARK_ROOT_RETURN);
+        } else if (retval == ARK_RTFUNC_FAIL) {  /* g failed */
+          arkProcessError(ark_mem, ARK_RTFUNC_FAIL, "ARKODE", "arkRootCheck3", 
+			  MSGARK_RTFUNC_FAILED, ark_mem->ark_tlo);
+          return(ARK_RTFUNC_FAIL);
+        }
+
+      }
+
+    } /* end of root stop check */
+
+    /* In ARK_NORMAL mode, test if tout was reached */
+    if ( (itask == ARK_NORMAL) && 
+	 ((ark_mem->ark_tn-tout)*ark_mem->ark_h >= ZERO) ) {
+      ark_mem->ark_tretlast = *tret = tout;
+      ier =  ARKodeGetDky(ark_mem, tout, 0, yout);
+      if (ier != ARK_SUCCESS) {
+        arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKode", MSGARK_BAD_TOUT, tout);
+        return(ARK_ILL_INPUT);
+      }
+      return(ARK_SUCCESS);
+    }
+
+    /* In ARK_ONE_STEP mode, test if tn was returned */
+    if ( itask == ARK_ONE_STEP && 
+	 SUNRabs(ark_mem->ark_tn - ark_mem->ark_tretlast) > troundoff ) {
+      ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+      N_VScale(ONE, ark_mem->ark_ycur, yout);
+      return(ARK_SUCCESS);
+    }
+
+    /* Test for tn at tstop or near tstop */
+    if ( ark_mem->ark_tstopset ) {
+
+      if ( SUNRabs(ark_mem->ark_tn - ark_mem->ark_tstop) <= troundoff) {
+        ier =  ARKodeGetDky(ark_mem, ark_mem->ark_tstop, 0, yout);
+        if (ier != ARK_SUCCESS) {
+          arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+			  MSGARK_BAD_TSTOP, ark_mem->ark_tstop, ark_mem->ark_tn);
+          return(ARK_ILL_INPUT);
+        }
+        ark_mem->ark_tretlast = *tret = ark_mem->ark_tstop;
+        ark_mem->ark_tstopset = FALSE;
+        return(ARK_TSTOP_RETURN);
+      }
+      
+      /* If next step would overtake tstop, adjust stepsize */
+      if ( (ark_mem->ark_tn + ark_mem->ark_hprime - ark_mem->ark_tstop)*ark_mem->ark_h > ZERO ) {
+        ark_mem->ark_hprime = (ark_mem->ark_tstop - ark_mem->ark_tn)*(ONE-FOUR*ark_mem->ark_uround);
+        ark_mem->ark_eta = ark_mem->ark_hprime/ark_mem->ark_h;
+      }
+    }
+  } /* end stopping tests block */  
+
+
+  /*--------------------------------------------------
+    4. Looping point for internal steps
+ 
+       - update the ewt vector for the next step
+       - check for errors (too many steps, too much
+         accuracy requested, step size too small)
+       - take a new step (via arkStep); stop on error 
+       - perform stop tests:
+         - check for root in last step taken
+         - check if tout was passed
+         - check if close to tstop
+         - check if in ONE_STEP mode (must return)
+  --------------------------------------------------*/
+  nstloc = 0;
+  for(;;) {
+   
+    ark_mem->ark_next_h = ark_mem->ark_h;
+    
+    /* Reset and check ewt */
+    if (ark_mem->ark_nst > 0 && !ark_mem->ark_resized) {
+      ewtsetOK = ark_mem->ark_efun(ark_mem->ark_ycur,
+				   ark_mem->ark_ewt, 
+				   ark_mem->ark_e_data);
+      if (ewtsetOK != 0) {
+        if (ark_mem->ark_itol == ARK_WF) 
+          arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+			  MSGARK_EWT_NOW_FAIL, ark_mem->ark_tn);
+        else 
+          arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+			  MSGARK_EWT_NOW_BAD, ark_mem->ark_tn);
+	
+        istate = ARK_ILL_INPUT;
+        ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+        N_VScale(ONE, ark_mem->ark_ycur, yout);
+        break;
+      }
+    }
+    
+    /* Reset and check rwt */
+    if (!ark_mem->ark_rwt_is_ewt) {
+      if (ark_mem->ark_nst > 0 && !ark_mem->ark_resized) {
+	ewtsetOK = ark_mem->ark_rfun(ark_mem->ark_ycur,
+				     ark_mem->ark_rwt,
+				     ark_mem->ark_r_data);
+	if (ewtsetOK != 0) {
+	  if (ark_mem->ark_itol == ARK_WF) 
+	    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+			    MSGARK_RWT_NOW_FAIL, ark_mem->ark_tn);
+	  else 
+	    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "ARKode", 
+			    MSGARK_RWT_NOW_BAD, ark_mem->ark_tn);
+	
+	  istate = ARK_ILL_INPUT;
+	  ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+	  N_VScale(ONE, ark_mem->ark_ycur, yout);
+	  break;
+	}
+      }
+    }
+    
+    /* Check for too many steps */
+    if ( (ark_mem->ark_mxstep>0) && (nstloc >= ark_mem->ark_mxstep) ) {
+      arkProcessError(ark_mem, ARK_TOO_MUCH_WORK, "ARKODE", "ARKode", 
+		      MSGARK_MAX_STEPS, ark_mem->ark_tn);
+      istate = ARK_TOO_MUCH_WORK;
+      ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+      N_VScale(ONE, ark_mem->ark_ycur, yout);
+      break;
+    }
+
+    /* Check for too much accuracy requested */
+    nrm = N_VWrmsNorm(ark_mem->ark_ycur, ark_mem->ark_ewt);
+    ark_mem->ark_tolsf = ark_mem->ark_uround * nrm;
+    if (ark_mem->ark_tolsf > ONE) {
+      arkProcessError(ark_mem, ARK_TOO_MUCH_ACC, "ARKODE", "ARKode", 
+		      MSGARK_TOO_MUCH_ACC, ark_mem->ark_tn);
+      istate = ARK_TOO_MUCH_ACC;
+      ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+      N_VScale(ONE, ark_mem->ark_ycur, yout);
+      ark_mem->ark_tolsf *= TWO;
+      break;
+    } else {
+      ark_mem->ark_tolsf = ONE;
+    }
+
+    /* Check for h below roundoff level in tn */
+    if (ark_mem->ark_tn + ark_mem->ark_h == ark_mem->ark_tn) {
+      ark_mem->ark_nhnil++;
+      if (ark_mem->ark_nhnil <= ark_mem->ark_mxhnil) 
+        arkProcessError(ark_mem, ARK_WARNING, "ARKODE", "ARKode", 
+			MSGARK_HNIL, ark_mem->ark_tn, ark_mem->ark_h);
+      if (ark_mem->ark_nhnil == ark_mem->ark_mxhnil) 
+        arkProcessError(ark_mem, ARK_WARNING, "ARKODE", "ARKode", 
+			MSGARK_HNIL_DONE);
+    }
+
+    /* Update parameter for upcoming step size */
+    if ((ark_mem->ark_nst > 0) && (ark_mem->ark_hprime != ark_mem->ark_h)) {
+      ark_mem->ark_h = ark_mem->ark_h * ark_mem->ark_eta;
+      ark_mem->ark_next_h = ark_mem->ark_h;
+    }
+    if (ark_mem->ark_fixedstep) {
+      ark_mem->ark_h = ark_mem->ark_hin;
+      ark_mem->ark_next_h = ark_mem->ark_h;
+    }
+
+    /* Call arkStep to take a step */
+    kflag = arkStep(ark_mem);
+
+    /* Process failed step cases, and exit loop */
+    if (kflag != ARK_SUCCESS) {
+      istate = arkHandleFailure(ark_mem, kflag);
+      ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+      N_VScale(ONE, ark_mem->ark_ycur, yout);
+      break;
+    }
+    
+    nstloc++;
+
+    /* Check for root in last step taken. */
+    if (ark_mem->ark_nrtfn > 0) {
+
+      retval = arkRootCheck3(ark_mem);
+      if (retval == RTFOUND) {  /* A new root was found */
+        ark_mem->ark_irfnd = 1;
+        istate = ARK_ROOT_RETURN;
+        ark_mem->ark_tretlast = *tret = ark_mem->ark_tlo;
+        break;
+      } else if (retval == ARK_RTFUNC_FAIL) { /* g failed */
+        arkProcessError(ark_mem, ARK_RTFUNC_FAIL, "ARKODE", "arkRootCheck3", 
+			MSGARK_RTFUNC_FAILED, ark_mem->ark_tlo);
+        istate = ARK_RTFUNC_FAIL;
+        break;
+      }
+
+      /* If we are at the end of the first step and we still have
+       * some event functions that are inactive, issue a warning
+       * as this may indicate a user error in the implementation
+       * of the root function. */
+      if (ark_mem->ark_nst==1) {
+        inactive_roots = FALSE;
+        for (ir=0; ir<ark_mem->ark_nrtfn; ir++) { 
+          if (!ark_mem->ark_gactive[ir]) {
+            inactive_roots = TRUE;
+            break;
+          }
+        }
+        if ((ark_mem->ark_mxgnull > 0) && inactive_roots) {
+          arkProcessError(ark_mem, ARK_WARNING, "ARKODES", "ARKode", 
+			  MSGARK_INACTIVE_ROOTS);
+        }
+      }
+    }
+
+    /* In NORMAL mode, check if tout reached */
+    if ( (itask == ARK_NORMAL) &&
+	 (ark_mem->ark_tn-tout)*ark_mem->ark_h >= ZERO ) {
+      istate = ARK_SUCCESS;
+      ark_mem->ark_tretlast = *tret = tout;
+      (void) ARKodeGetDky(ark_mem, tout, 0, yout);
+      ark_mem->ark_next_h = ark_mem->ark_hprime;
+      break;
+    }
+
+    /* Check if tn is at tstop or near tstop */
+    if ( ark_mem->ark_tstopset ) {
+      troundoff = FUZZ_FACTOR*ark_mem->ark_uround * 
+	(SUNRabs(ark_mem->ark_tn) + SUNRabs(ark_mem->ark_h));
+      if ( SUNRabs(ark_mem->ark_tn - ark_mem->ark_tstop) <= troundoff) {
+        (void) ARKodeGetDky(ark_mem, ark_mem->ark_tstop, 0, yout);
+        ark_mem->ark_tretlast = *tret = ark_mem->ark_tstop;
+        ark_mem->ark_tstopset = FALSE;
+        istate = ARK_TSTOP_RETURN;
+        break;
+      }
+      if ( (ark_mem->ark_tn + ark_mem->ark_hprime - ark_mem->ark_tstop)*ark_mem->ark_h > ZERO ) {
+        ark_mem->ark_hprime = (ark_mem->ark_tstop - ark_mem->ark_tn)*(ONE-FOUR*ark_mem->ark_uround);
+        ark_mem->ark_eta = ark_mem->ark_hprime/ark_mem->ark_h;
+      }
+    }
+
+    /* In ONE_STEP mode, copy y and exit loop */
+    if (itask == ARK_ONE_STEP) {
+      istate = ARK_SUCCESS;
+      ark_mem->ark_tretlast = *tret = ark_mem->ark_tn;
+      N_VScale(ONE, ark_mem->ark_ycur, yout);
+      ark_mem->ark_next_h = ark_mem->ark_hprime;
+      break;
+    }
+
+  } /* end looping for internal steps */
+
+  return(istate);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetDky:
+
+ This routine computes the k-th derivative of the interpolating
+ polynomial at the time t and stores the result in the vector 
+ dky. This routine internally calls arkDenseEval to perform the
+ interpolation.  We have the restriction that 0 <= k <= 3.  This 
+ routine uses an interpolating polynomial of degree 
+ max(ark_dense_q, k), i.e. it will form a polynomial of the
+ degree requested by the user through ark_dense_q, unless 
+ higher-order derivatives are requested.
+
+ This function is called by ARKode with k=0 and t=tout to perform
+ interpolation of outputs, but may also be called directly by the
+ user.  Note: in all cases it will be called after ark_tn has 
+ been updated to correspond with the end time of the last 
+ successful step.
+---------------------------------------------------------------*/
+int ARKodeGetDky(void *arkode_mem, realtype t, int k, N_Vector dky)
+{
+  realtype s, tfuzz, tp, tn1;
+  int retval, degree;
+  ARKodeMem ark_mem;
+  
+  /* Check all inputs for legality */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", "ARKodeGetDky", 
+		    MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+  if (dky == NULL) {
+    arkProcessError(ark_mem, ARK_BAD_DKY, "ARKODE", "ARKodeGetDky", 
+		    MSGARK_NULL_DKY);
+    return(ARK_BAD_DKY);
+  }
+  if ((k < 0) || (k > 3)) {
+    arkProcessError(ark_mem, ARK_BAD_K, "ARKODE", "ARKodeGetDky", 
+		    MSGARK_BAD_K);
+    return(ARK_BAD_K);
+  }
+  
+  /* Allow for some slack */
+  tfuzz = FUZZ_FACTOR * ark_mem->ark_uround * 
+    (SUNRabs(ark_mem->ark_tn) + SUNRabs(ark_mem->ark_hold));
+  if (ark_mem->ark_hold < ZERO) tfuzz = -tfuzz;
+  tp = ark_mem->ark_tn - ark_mem->ark_hold - tfuzz;
+  tn1 = ark_mem->ark_tn + tfuzz;
+  if ((t-tp)*(t-tn1) > ZERO) {
+    arkProcessError(ark_mem, ARK_BAD_T, "ARKODE", "ARKodeGetDky", 
+		    MSGARK_BAD_T, t, ark_mem->ark_tn-ark_mem->ark_hold, 
+		    ark_mem->ark_tn);
+    return(ARK_BAD_T);
+  }
+
+  /* call arkDenseEval to evaluate result */
+  s = (t - ark_mem->ark_tn) / ark_mem->ark_h;
+  degree = (k > ark_mem->ark_dense_q) ? k : ark_mem->ark_dense_q;
+  retval = arkDenseEval(ark_mem, s, k, degree, dky);
+  if (retval != ARK_SUCCESS) 
+    arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, "ARKODE", "arkDenseEval", 
+		    MSGARK_RHSFUNC_FAILED, t);
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeFree:
+
+ This routine frees the problem memory allocated by ARKodeInit.
+ Such memory includes all the vectors allocated by 
+ arkAllocVectors, and arkAllocRKVectors, and the memory lmem for
+ the linear solver (deallocated by a call to lfree).
+---------------------------------------------------------------*/
+void ARKodeFree(void **arkode_mem)
+{
+  ARKodeMem ark_mem;
+
+  if (*arkode_mem == NULL) return;
+
+  ark_mem = (ARKodeMem) (*arkode_mem);
+  
+  arkFreeVectors(ark_mem);
+
+  arkFreeFPData(ark_mem);
+
+  if (ark_mem->ark_lfree != NULL) 
+    ark_mem->ark_lfree(ark_mem);
+
+  if (ark_mem->ark_mfree != NULL) 
+    ark_mem->ark_mfree(ark_mem);
+
+  if (ark_mem->ark_nrtfn > 0) {
+    free(ark_mem->ark_glo);     ark_mem->ark_glo     = NULL;
+    free(ark_mem->ark_ghi);     ark_mem->ark_ghi     = NULL;
+    free(ark_mem->ark_grout);   ark_mem->ark_grout   = NULL;
+    free(ark_mem->ark_iroots);  ark_mem->ark_iroots  = NULL;
+    free(ark_mem->ark_rootdir); ark_mem->ark_rootdir = NULL;
+    free(ark_mem->ark_gactive); ark_mem->ark_gactive = NULL;
+  }
+
+  free(*arkode_mem);
+  *arkode_mem = NULL;
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeRootInit:
+
+ ARKodeRootInit initializes a rootfinding problem to be solved
+ during the integration of the ODE system.  It loads the root
+ function pointer and the number of root functions, and allocates
+ workspace memory.  The return value is ARK_SUCCESS = 0 if no 
+ errors occurred, or a negative value otherwise.
+---------------------------------------------------------------*/
+int ARKodeRootInit(void *arkode_mem, int nrtfn, ARKRootFn g)
+{
+  ARKodeMem ark_mem;
+  int i, nrt;
+
+  /* Check arkode_mem pointer */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeRootInit", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  nrt = (nrtfn < 0) ? 0 : nrtfn;
+
+  /* If rerunning ARKodeRootInit() with a different number of root
+     functions (changing number of gfun components), then free
+     currently held memory resources */
+  if ((nrt != ark_mem->ark_nrtfn) && (ark_mem->ark_nrtfn > 0)) {
+    free(ark_mem->ark_glo);     ark_mem->ark_glo     = NULL;
+    free(ark_mem->ark_ghi);     ark_mem->ark_ghi     = NULL;
+    free(ark_mem->ark_grout);   ark_mem->ark_grout   = NULL;
+    free(ark_mem->ark_iroots);  ark_mem->ark_iroots  = NULL;
+    free(ark_mem->ark_rootdir); ark_mem->ark_rootdir = NULL;
+    free(ark_mem->ark_gactive); ark_mem->ark_gactive = NULL;
+
+    ark_mem->ark_lrw -= 3 * (ark_mem->ark_nrtfn);
+    ark_mem->ark_liw -= 3 * (ark_mem->ark_nrtfn);
+  }
+
+  /* If ARKodeRootInit() was called with nrtfn == 0, then set 
+     ark_nrtfn to zero and ark_gfun to NULL before returning */
+  if (nrt == 0) {
+    ark_mem->ark_nrtfn = nrt;
+    ark_mem->ark_gfun = NULL;
+    return(ARK_SUCCESS);
+  }
+
+  /* If rerunning ARKodeRootInit() with the same number of root 
+     functions (not changing number of gfun components), then 
+     check if the root function argument has changed */
+  /* If g != NULL then return as currently reserved memory 
+     resources will suffice */
+  if (nrt == ark_mem->ark_nrtfn) {
+    if (g != ark_mem->ark_gfun) {
+      if (g == NULL) {
+        free(ark_mem->ark_glo);     ark_mem->ark_glo     = NULL;
+        free(ark_mem->ark_ghi);     ark_mem->ark_ghi     = NULL;
+        free(ark_mem->ark_grout);   ark_mem->ark_grout   = NULL;
+        free(ark_mem->ark_iroots);  ark_mem->ark_iroots  = NULL;
+        free(ark_mem->ark_rootdir); ark_mem->ark_rootdir = NULL;
+        free(ark_mem->ark_gactive); ark_mem->ark_gactive = NULL;
+
+        ark_mem->ark_lrw -= 3*nrt;
+        ark_mem->ark_liw -= 3*nrt;
+
+        arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"ARKodeRootInit", MSGARK_NULL_G);
+        return(ARK_ILL_INPUT);
+      }
+      else {
+        ark_mem->ark_gfun = g;
+        return(ARK_SUCCESS);
+      }
+    }
+    else return(ARK_SUCCESS);
+  }
+
+  /* Set variable values in ARKode memory block */
+  ark_mem->ark_nrtfn = nrt;
+  if (g == NULL) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeRootInit", MSGARK_NULL_G);
+    return(ARK_ILL_INPUT);
+  }
+  else ark_mem->ark_gfun = g;
+
+  /* Allocate necessary memory and return */
+  ark_mem->ark_glo = NULL;
+  ark_mem->ark_glo = (realtype *) malloc(nrt*sizeof(realtype));
+  if (ark_mem->ark_glo == NULL) {
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		    "ARKodeRootInit", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+  ark_mem->ark_ghi = NULL;
+  ark_mem->ark_ghi = (realtype *) malloc(nrt*sizeof(realtype));
+  if (ark_mem->ark_ghi == NULL) {
+    free(ark_mem->ark_glo); ark_mem->ark_glo = NULL;
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		    "ARKodeRootInit", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+  ark_mem->ark_grout = NULL;
+  ark_mem->ark_grout = (realtype *) malloc(nrt*sizeof(realtype));
+  if (ark_mem->ark_grout == NULL) {
+    free(ark_mem->ark_glo); ark_mem->ark_glo = NULL;
+    free(ark_mem->ark_ghi); ark_mem->ark_ghi = NULL;
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		    "ARKodeRootInit", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+  ark_mem->ark_iroots = NULL;
+  ark_mem->ark_iroots = (int *) malloc(nrt*sizeof(int));
+  if (ark_mem->ark_iroots == NULL) {
+    free(ark_mem->ark_glo); ark_mem->ark_glo = NULL; 
+    free(ark_mem->ark_ghi); ark_mem->ark_ghi = NULL;
+    free(ark_mem->ark_grout); ark_mem->ark_grout = NULL;
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		    "ARKodeRootInit", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+  ark_mem->ark_rootdir = NULL;
+  ark_mem->ark_rootdir = (int *) malloc(nrt*sizeof(int));
+  if (ark_mem->ark_rootdir == NULL) {
+    free(ark_mem->ark_glo); ark_mem->ark_glo = NULL; 
+    free(ark_mem->ark_ghi); ark_mem->ark_ghi = NULL;
+    free(ark_mem->ark_grout); ark_mem->ark_grout = NULL;
+    free(ark_mem->ark_iroots); ark_mem->ark_iroots = NULL;
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		    "ARKodeRootInit", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+  ark_mem->ark_gactive = NULL;
+  ark_mem->ark_gactive = (booleantype *) malloc(nrt*sizeof(booleantype));
+  if (ark_mem->ark_gactive == NULL) {
+    free(ark_mem->ark_glo); ark_mem->ark_glo = NULL; 
+    free(ark_mem->ark_ghi); ark_mem->ark_ghi = NULL;
+    free(ark_mem->ark_grout); ark_mem->ark_grout = NULL;
+    free(ark_mem->ark_iroots); ark_mem->ark_iroots = NULL;
+    free(ark_mem->ark_rootdir); ark_mem->ark_rootdir = NULL;
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODES", 
+		    "ARKodeRootInit", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+
+  /* Set default values for rootdir (both directions) */
+  for(i=0; i<nrt; i++) ark_mem->ark_rootdir[i] = 0;
+
+  /* Set default values for gactive (all active) */
+  for(i=0; i<nrt; i++) ark_mem->ark_gactive[i] = TRUE;
+
+  ark_mem->ark_lrw += 3*nrt;
+  ark_mem->ark_liw += 3*nrt;
+
+  return(ARK_SUCCESS);
+}
+
+
+
+/*===============================================================
+  Internal functions that may be replaced by the user
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkEwtSet
+
+ This routine is responsible for setting the error weight vector ewt,
+ according to tol_type, as follows:
+
+ (1) ewt[i] = 1 / (reltol * SUNRabs(ycur[i]) + abstol), i=0,...,neq-1
+     if tol_type = ARK_SS
+ (2) ewt[i] = 1 / (reltol * SUNRabs(ycur[i]) + abstol[i]), i=0,...,neq-1
+     if tol_type = ARK_SV
+
+ arkEwtSet returns 0 if ewt is successfully set as above to a
+ positive vector and -1 otherwise. In the latter case, ewt is
+ considered undefined.
+
+ All the real work is done in the routines arkEwtSetSS, arkEwtSetSV.
+---------------------------------------------------------------*/
+int arkEwtSet(N_Vector ycur, N_Vector weight, void *data)
+{
+  ARKodeMem ark_mem;
+  int flag = 0;
+
+  /* data points to ark_mem here */
+  ark_mem = (ARKodeMem) data;
+
+  switch(ark_mem->ark_itol) {
+  case ARK_SS: 
+    flag = arkEwtSetSS(ark_mem, ycur, weight);
+    break;
+  case ARK_SV: 
+    flag = arkEwtSetSV(ark_mem, ycur, weight);
+    break;
+  }
+  
+  return(flag);
+}
+
+
+/*---------------------------------------------------------------
+ arkRwtSet
+
+ This routine is responsible for setting the residual weight 
+ vector rwt, according to tol_type, as follows:
+
+ (1) rwt[i] = 1 / (reltol * SUNRabs(M*ycur[i]) + rabstol), i=0,...,neq-1
+     if tol_type = ARK_SS
+ (2) rwt[i] = 1 / (reltol * SUNRabs(M*ycur[i]) + rabstol[i]), i=0,...,neq-1
+     if tol_type = ARK_SV
+ (3) unset if tol_type is any other value (occurs rwt=ewt)
+
+ arkRwtSet returns 0 if rwt is successfully set as above to a
+ positive vector and -1 otherwise. In the latter case, rwt is
+ considered undefined.
+
+ All the real work is done in the routines arkRwtSetSS, arkRwtSetSV.
+---------------------------------------------------------------*/
+int arkRwtSet(N_Vector y, N_Vector weight, void *data)
+{
+  ARKodeMem ark_mem;
+  N_Vector My;
+  int flag = 0;
+
+  /* data points to ark_mem here */
+  ark_mem = (ARKodeMem) data;
+
+  /* return if rwt is just ewt */
+  if (ark_mem->ark_rwt_is_ewt)  return(0);
+
+  /* put M*y into ark_ftemp */
+  My = ark_mem->ark_ftemp;
+  if (ark_mem->ark_mass_matrix) {
+    flag = ark_mem->ark_mtimes(y, My, ark_mem->ark_tn, 
+			       ark_mem->ark_mtimes_data);
+    ark_mem->ark_mass_mult++;
+    if (flag != ARK_SUCCESS)  return (ARK_MASSMULT_FAIL);
+  } else {  /* this condition should not apply, but just in case */
+    N_VScale(ONE, y, My);
+  }
+
+  /* call appropriate routine to fill rwt */
+  switch(ark_mem->ark_ritol) {
+  case ARK_SS: 
+    flag = arkRwtSetSS(ark_mem, My, weight);
+    break;
+  case ARK_SV: 
+    flag = arkRwtSetSV(ark_mem, My, weight);
+    break;
+  }
+  
+  return(flag);
+}
+
+
+/*---------------------------------------------------------------
+ arkErrHandler is the default error handling function.
+   It sends the error message to the stream pointed to by ark_errfp 
+---------------------------------------------------------------*/
+void arkErrHandler(int error_code, const char *module,
+		   const char *function, char *msg, void *data)
+{
+  ARKodeMem ark_mem;
+  char err_type[10];
+
+  /* data points to ark_mem here */
+  ark_mem = (ARKodeMem) data;
+
+  if (error_code == ARK_WARNING)
+    sprintf(err_type,"WARNING");
+  else
+    sprintf(err_type,"ERROR");
+
+#ifndef NO_FPRINTF_OUTPUT
+  if (ark_mem->ark_errfp!=NULL) {
+    fprintf(ark_mem->ark_errfp,"\n[%s %s]  %s\n",module,err_type,function);
+    fprintf(ark_mem->ark_errfp,"  %s\n\n",msg);
+  }
+#endif
+
+  return;
+}
+
+
+
+/*===============================================================
+   Private Helper Functions
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkPrintMem:
+
+ This routine outputs the ark_mem structure to stdout.
+---------------------------------------------------------------*/
+static void arkPrintMem(ARKodeMem ark_mem)
+{
+  int i, j;
+
+  /* output integer quantities */
+  printf("ark_itol = %i\n", ark_mem->ark_itol);
+  printf("ark_ritol = %i\n", ark_mem->ark_ritol);
+  printf("ark_q = %i\n", ark_mem->ark_q);
+  printf("ark_p = %i\n", ark_mem->ark_p);
+  printf("ark_istage = %i\n", ark_mem->ark_istage);
+  printf("ark_stages = %i\n", ark_mem->ark_stages);
+  printf("ark_dense_q = %i\n", ark_mem->ark_dense_q);
+  printf("ark_mnewt = %i\n", ark_mem->ark_mnewt);
+  printf("ark_hadapt_imethod = %i\n", ark_mem->ark_hadapt_imethod);
+  printf("ark_maxcor = %i\n", ark_mem->ark_maxcor);
+  printf("ark_mxhnil = %i\n", ark_mem->ark_mxhnil);
+  printf("ark_maxnef = %i\n", ark_mem->ark_maxnef);
+  printf("ark_maxncf = %i\n", ark_mem->ark_maxncf);
+  printf("ark_small_nef = %i\n", ark_mem->ark_small_nef);
+  printf("ark_msbp = %i\n", ark_mem->ark_msbp);
+  printf("ark_predictor = %i\n", ark_mem->ark_predictor);
+  printf("ark_nhnil = %i\n", ark_mem->ark_nhnil);
+  printf("ark_lsolve_type = %i\n", ark_mem->ark_lsolve_type);
+  printf("ark_msolve_type = %i\n", ark_mem->ark_msolve_type);
+  printf("ark_nrtfn = %i\n", ark_mem->ark_nrtfn);
+  if (ark_mem->ark_iroots != NULL) 
+    for (i=0; i<ark_mem->ark_nrtfn; i++)
+      printf("ark_iroots[%i] = %i\n", i, ark_mem->ark_iroots[i]);
+  if (ark_mem->ark_rootdir != NULL) 
+    for (i=0; i<ark_mem->ark_nrtfn; i++)
+      printf("ark_rootdir[%i] = %i\n", i, ark_mem->ark_rootdir[i]);
+  printf("ark_taskc = %i\n", ark_mem->ark_taskc);
+  printf("ark_irfnd = %i\n", ark_mem->ark_irfnd);
+  printf("ark_mxgnull = %i\n", ark_mem->ark_mxgnull);
+
+  /* output long integer quantities */
+  printf("ark_mxstep = %li\n", ark_mem->ark_mxstep);
+  printf("ark_nst = %li\n", ark_mem->ark_nst);
+  printf("ark_nst_acc = %li\n", ark_mem->ark_nst_acc);
+  printf("ark_nst_exp = %li\n", ark_mem->ark_nst_exp);
+  printf("ark_nst_attempts = %li\n", ark_mem->ark_nst_attempts);
+  printf("ark_nfe = %li\n", ark_mem->ark_nfe);
+  printf("ark_nfi = %li\n", ark_mem->ark_nfi);
+  printf("ark_ncfn = %li\n", ark_mem->ark_ncfn);
+  printf("ark_nmassfails = %li\n", ark_mem->ark_nmassfails);
+  printf("ark_netf = %li\n", ark_mem->ark_netf);
+  printf("ark_nni = %li\n", ark_mem->ark_nni);
+  printf("ark_nsetups = %li\n", ark_mem->ark_nsetups);
+  printf("ark_lrw1 = %li\n", ark_mem->ark_lrw1);
+  printf("ark_liw1 = %li\n", ark_mem->ark_liw1);
+  printf("ark_lrw = %li\n", ark_mem->ark_lrw);
+  printf("ark_liw = %li\n", ark_mem->ark_liw);
+  printf("ark_fp_m = %li\n", ark_mem->ark_fp_m);
+  if (ark_mem->ark_fp_imap != NULL)
+    for (i=0; i<ark_mem->ark_fp_m; i++)
+      printf("ark_fp_imap[%i] = %li\n", i, ark_mem->ark_fp_imap[i]);
+  printf("ark_mass_solves = %li\n", ark_mem->ark_mass_solves);
+  printf("ark_mass_mult = %li\n", ark_mem->ark_mass_mult);
+  printf("ark_nstlp = %li\n", ark_mem->ark_nstlp);
+  printf("ark_nge = %li\n", ark_mem->ark_nge);
+
+  /* output boolean quantities */
+  printf("ark_user_efun = %i\n", ark_mem->ark_user_efun);
+  printf("ark_user_linear = %i\n", ark_mem->ark_linear);
+  printf("ark_user_linear_timedep = %i\n", ark_mem->ark_linear_timedep);
+  printf("ark_user_explicit = %i\n", ark_mem->ark_explicit);
+  printf("ark_user_implicit = %i\n", ark_mem->ark_implicit);
+  printf("ark_tstopset = %i\n", ark_mem->ark_tstopset);
+  printf("ark_hadapt_pq = %i\n", ark_mem->ark_hadapt_pq);
+  printf("ark_report = %i\n", ark_mem->ark_report);
+  printf("ark_use_fp = %i\n", ark_mem->ark_use_fp);
+  printf("ark_mass_matrix = %i\n", ark_mem->ark_mass_matrix);
+  printf("ark_jcur = %i\n", ark_mem->ark_jcur);
+  printf("ark_setupNonNull = %i\n", ark_mem->ark_setupNonNull);
+  printf("ark_MassSetupNonNull = %i\n", ark_mem->ark_MassSetupNonNull);
+  printf("ark_VabstolMallocDone = %i\n", ark_mem->ark_VabstolMallocDone);
+  printf("ark_MallocDone = %i\n", ark_mem->ark_MallocDone);
+  printf("ark_resized = %i\n", ark_mem->ark_resized);
+  printf("ark_firststage = %i\n", ark_mem->ark_firststage);
+  if (ark_mem->ark_gactive != NULL)
+    for (i=0; i<ark_mem->ark_nrtfn; i++)
+      printf("ark_gactive[%i] = %i\n", i, ark_mem->ark_gactive[i]);
+
+  /* output realtype quantities */
+  printf("ark_uround = %.16g\n", ark_mem->ark_uround);
+  printf("ark_reltol = %.16g\n", ark_mem->ark_reltol);
+  printf("ark_Sabstol = %.16g\n", ark_mem->ark_Sabstol);
+  printf("ark_tstop = %.16g\n", ark_mem->ark_tstop);
+  printf("ark_Ae = \n");
+  for (i=0; i<ARK_S_MAX; i++) {
+    printf("    ");
+    for (j=0; j<ARK_S_MAX; j++)
+      printf("%.16g  ", ARK_A(ark_mem->ark_Ae,i,j));
+    printf("\n");
+  }
+  printf("ark_Ai = \n");
+  for (i=0; i<ARK_S_MAX; i++) {
+    printf("    ");
+    for (j=0; j<ARK_S_MAX; j++)
+      printf("%.16g  ", ARK_A(ark_mem->ark_Ai,i,j));
+    printf("\n");
+  }
+  printf("ark_ce = ");
+  for (i=0; i<ARK_S_MAX; i++) 
+    printf("%.16g  ", ark_mem->ark_ce[i]);
+  printf("\n");
+  printf("ark_ci = ");
+  for (i=0; i<ARK_S_MAX; i++) 
+    printf("%.16g  ", ark_mem->ark_ci[i]);
+  printf("\n");
+  printf("ark_be = ");
+  for (i=0; i<ARK_S_MAX; i++) 
+    printf("%.16g  ", ark_mem->ark_be[i]);
+  printf("\n");
+  printf("ark_bi = ");
+  for (i=0; i<ARK_S_MAX; i++) 
+    printf("%.16g  ", ark_mem->ark_bi[i]);
+  printf("\n");
+  printf("ark_b2e = ");
+  for (i=0; i<ARK_S_MAX; i++) 
+    printf("%.16g  ", ark_mem->ark_b2e[i]);
+  printf("\n");
+  printf("ark_b2i = ");
+  for (i=0; i<ARK_S_MAX; i++) 
+    printf("%.16g  ", ark_mem->ark_b2i[i]);
+  printf("\n");
+  printf("ark_hin = %.16g\n", ark_mem->ark_hin);
+  printf("ark_h = %.16g\n", ark_mem->ark_h);
+  printf("ark_hprime = %.16g\n", ark_mem->ark_hprime);
+  printf("ark_next_h = %.16g\n", ark_mem->ark_next_h);
+  printf("ark_eta = %.16g\n", ark_mem->ark_eta);
+  printf("ark_tn = %.16g\n", ark_mem->ark_tn);
+  printf("ark_tretlast = %.16g\n", ark_mem->ark_tretlast);
+  printf("ark_gamma = %.16g\n", ark_mem->ark_gamma);
+  printf("ark_gammap = %.16g\n", ark_mem->ark_gammap);
+  printf("ark_gamrat = %.16g\n", ark_mem->ark_gamrat);
+  printf("ark_crate = %.16g\n", ark_mem->ark_crate);
+  printf("ark_eRNrm = %.16g\n", ark_mem->ark_eRNrm);
+  printf("ark_nlscoef = %.16g\n", ark_mem->ark_nlscoef);
+  printf("ark_fixedstep = %i\n", ark_mem->ark_fixedstep);
+  printf("ark_hadapt_ehist =  %.16g  %.16g  %.16g\n",
+	 ark_mem->ark_hadapt_ehist[0], ark_mem->ark_hadapt_ehist[1], ark_mem->ark_hadapt_ehist[2]);
+  printf("ark_hadapt_hhist =  %.16g  %.16g  %.16g\n",
+	 ark_mem->ark_hadapt_hhist[0], ark_mem->ark_hadapt_hhist[1], ark_mem->ark_hadapt_hhist[2]);
+  printf("ark_hadapt_cfl = %.16g\n", ark_mem->ark_hadapt_cfl);
+  printf("ark_hadapt_safety = %.16g\n", ark_mem->ark_hadapt_safety);
+  printf("ark_hadapt_bias = %.16g\n", ark_mem->ark_hadapt_bias);
+  printf("ark_hadapt_growth = %.16g\n", ark_mem->ark_hadapt_growth);
+  printf("ark_hadapt_lbound = %.16g\n", ark_mem->ark_hadapt_lbound);
+  printf("ark_hadapt_ubound = %.16g\n", ark_mem->ark_hadapt_ubound);
+  printf("ark_hadapt_k1 = %.16g\n", ark_mem->ark_hadapt_k1);
+  printf("ark_hadapt_k2 = %.16g\n", ark_mem->ark_hadapt_k2);
+  printf("ark_hadapt_k3 = %.16g\n", ark_mem->ark_hadapt_k3);
+  printf("ark_hmin = %.16g\n", ark_mem->ark_hmin);
+  printf("ark_hmax_inv = %.16g\n", ark_mem->ark_hmax_inv);
+  printf("ark_etamax = %.16g\n", ark_mem->ark_etamax);
+  printf("ark_etamx1 = %.16g\n", ark_mem->ark_etamx1);
+  printf("ark_etamxf = %.16g\n", ark_mem->ark_etamxf);
+  printf("ark_etacf = %.16g\n", ark_mem->ark_etacf);
+  printf("ark_crdown = %.16g\n", ark_mem->ark_crdown);
+  printf("ark_rdiv = %.16g\n", ark_mem->ark_rdiv);
+  printf("ark_dgmax = %.16g\n", ark_mem->ark_dgmax);
+  if (ark_mem->ark_fp_R != NULL) {
+    printf("ark_fp_R =  ");
+    for (i=0; i<ark_mem->ark_fp_m*ark_mem->ark_fp_m; i++)
+      printf("%.16g  ", ark_mem->ark_fp_R[i]);
+    printf("\n");
+  }
+  if (ark_mem->ark_fp_gamma != NULL) {
+    printf("ark_fp_gamma =  ");
+    for (i=0; i<ark_mem->ark_fp_m; i++)
+      printf("%.16g  ", ark_mem->ark_fp_gamma[i]);
+    printf("\n");
+  }
+  printf("ark_h0u = %.16g\n", ark_mem->ark_h0u);
+  printf("ark_tnew = %.16g\n", ark_mem->ark_tnew);
+  printf("ark_hold = %.16g\n", ark_mem->ark_hold);
+  printf("ark_tolsf = %.16g\n", ark_mem->ark_tolsf);
+  printf("ark_tlo = %.16g\n", ark_mem->ark_tlo);
+  printf("ark_thi = %.16g\n", ark_mem->ark_thi);
+  printf("ark_trout = %.16g\n", ark_mem->ark_trout);
+  if (ark_mem->ark_glo != NULL) 
+    for (i=0; i<ark_mem->ark_nrtfn; i++)
+      printf("ark_glo[%i] = %.16g\n", i, ark_mem->ark_glo[i]);
+  if (ark_mem->ark_ghi != NULL) 
+    for (i=0; i<ark_mem->ark_nrtfn; i++)
+      printf("ark_ghi[%i] = %.16g\n", i, ark_mem->ark_ghi[i]);
+  if (ark_mem->ark_grout != NULL) 
+    for (i=0; i<ark_mem->ark_nrtfn; i++)
+      printf("ark_grout[%i] = %.16g\n", i, ark_mem->ark_grout[i]);
+  printf("ark_toutc = %.16g\n", ark_mem->ark_toutc);
+  printf("ark_ttol = %.16g\n", ark_mem->ark_ttol);
+
+#ifdef DEBUG_OUTPUT
+  /* output vector quantities */  
+  if (ark_mem->ark_Vabstol != NULL) {
+    printf("ark_Vapbsol:\n");
+    N_VPrint_Serial(ark_mem->ark_Vabstol);
+  }
+  for (i=0; i<ARK_S_MAX; i++) 
+    if (ark_mem->ark_Fe[i] != NULL) {
+      printf("ark_Fe[%i]:\n", i);
+      N_VPrint_Serial(ark_mem->ark_Fe[i]);
+    }
+  for (i=0; i<ARK_S_MAX; i++) 
+    if (ark_mem->ark_Fi[i] != NULL) {
+      printf("ark_Fi[%i]:\n", i);
+      N_VPrint_Serial(ark_mem->ark_Fi[i]);
+    }
+  if (ark_mem->ark_ewt != NULL) {
+    printf("ark_ewt:\n");
+    N_VPrint_Serial(ark_mem->ark_ewt);
+  }
+  if (!ark_mem->ark_rwt_is_ewt && ark_mem->ark_rwt != NULL) {
+    printf("ark_rwt:\n");
+    N_VPrint_Serial(ark_mem->ark_rwt);
+  }
+  if (ark_mem->ark_y != NULL) {
+    printf("ark_y:\n");
+    N_VPrint_Serial(ark_mem->ark_y);
+  }
+  if (ark_mem->ark_ycur != NULL) {
+    printf("ark_ycur:\n");
+    N_VPrint_Serial(ark_mem->ark_ycur);
+  }
+  if (ark_mem->ark_sdata != NULL) {
+    printf("ark_sdata:\n");
+    N_VPrint_Serial(ark_mem->ark_sdata);
+  }
+  if (ark_mem->ark_tempv != NULL) {
+    printf("ark_tempv:\n");
+    N_VPrint_Serial(ark_mem->ark_tempv);
+  }
+  if (ark_mem->ark_acor != NULL) {
+    printf("ark_acor:\n");
+    N_VPrint_Serial(ark_mem->ark_acor);
+  }
+  if (ark_mem->ark_ftemp != NULL) {
+    printf("ark_ftemp:\n");
+    N_VPrint_Serial(ark_mem->ark_ftemp);
+  }
+  if (ark_mem->ark_fold != NULL) {
+    printf("ark_fold:\n");
+    N_VPrint_Serial(ark_mem->ark_fold);
+  }
+  if (ark_mem->ark_fnew != NULL) {
+    printf("ark_fnew:\n");
+    N_VPrint_Serial(ark_mem->ark_fnew);
+  }
+  if (ark_mem->ark_yold != NULL) {
+    printf("ark_yold:\n");
+    N_VPrint_Serial(ark_mem->ark_yold);
+  }
+  if (ark_mem->ark_ynew != NULL) {
+    printf("ark_ynew:\n");
+    N_VPrint_Serial(ark_mem->ark_ynew);
+  }
+  if (ark_mem->ark_fp_df != NULL) 
+    for (i=0; i<ark_mem->ark_fp_m; i++)
+      if (ark_mem->ark_fp_df[i] != NULL) {
+	printf("ark_fp_df[%i]:\n", i);
+	N_VPrint_Serial(ark_mem->ark_fp_df[i]);
+      }
+  if (ark_mem->ark_fp_dg != NULL) 
+    for (i=0; i<ark_mem->ark_fp_m; i++)
+      if (ark_mem->ark_fp_dg[i] != NULL) {
+	printf("ark_fp_dg[%i]:\n", i);
+	N_VPrint_Serial(ark_mem->ark_fp_dg[i]);
+      }
+  if (ark_mem->ark_fp_q != NULL) 
+    for (i=0; i<ark_mem->ark_fp_m; i++)
+      if (ark_mem->ark_fp_q[i] != NULL) {
+	printf("ark_fp_q[%i]:\n", i);
+	N_VPrint_Serial(ark_mem->ark_fp_q[i]);
+      }
+  if (ark_mem->ark_fp_fval != NULL) {
+    printf("ark_fp_fval:\n");
+    N_VPrint_Serial(ark_mem->ark_fp_fval);
+  }
+  if (ark_mem->ark_fp_fold != NULL) {
+    printf("ark_fp_fold:\n");
+    N_VPrint_Serial(ark_mem->ark_fp_fold);
+  }
+  if (ark_mem->ark_fp_gold != NULL) {
+    printf("ark_fp_gold:\n");
+    N_VPrint_Serial(ark_mem->ark_fp_gold);
+  }
+#endif
+
+}
+
+
+/*---------------------------------------------------------------
+ arkCheckNvector:
+
+ This routine checks if all required vector operations are 
+ present.  If any of them is missing it returns FALSE.
+---------------------------------------------------------------*/
+static booleantype arkCheckNvector(N_Vector tmpl)  /* to be updated?? */
+{
+  if ((tmpl->ops->nvclone     == NULL) ||
+      (tmpl->ops->nvdestroy   == NULL) ||
+      (tmpl->ops->nvlinearsum == NULL) ||
+      (tmpl->ops->nvconst     == NULL) ||
+      (tmpl->ops->nvdiv       == NULL) ||
+      (tmpl->ops->nvscale     == NULL) ||
+      (tmpl->ops->nvabs       == NULL) ||
+      (tmpl->ops->nvinv       == NULL) ||
+      (tmpl->ops->nvaddconst  == NULL) ||
+      (tmpl->ops->nvmaxnorm   == NULL) ||
+      (tmpl->ops->nvwrmsnorm  == NULL) ||
+      (tmpl->ops->nvmin       == NULL))
+    return(FALSE);
+  else
+    return(TRUE);
+}
+
+
+/*---------------------------------------------------------------
+ arkAllocVectors:
+
+ This routine allocates the ARKODE vectors ewt, acor, ycur, 
+ sdata, tempv, ftemp, fold, fnew, yold, and ynew.  If any of 
+ these vectors already exist, they are left alone.  Otherwise, it
+ will allocate each vector by cloning the input vector. If all 
+ memory allocations are successful, arkAllocVectors returns TRUE. 
+ Otherwise all vector memory is freed and arkAllocVectors 
+ returns FALSE. This routine also updates the optional outputs 
+ lrw and liw, which are (respectively) the lengths of the real 
+ and integer work spaces.
+---------------------------------------------------------------*/
+static booleantype arkAllocVectors(ARKodeMem ark_mem, N_Vector tmpl)
+{
+  /* Allocate ewt if needed */
+  if (ark_mem->ark_ewt == NULL) {
+    ark_mem->ark_ewt = N_VClone(tmpl);
+    if (ark_mem->ark_ewt == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Set rwt to point at ewt */
+  if (ark_mem->ark_rwt_is_ewt) 
+    ark_mem->ark_rwt = ark_mem->ark_ewt;
+
+  /* Allocate acor if needed */
+  if (ark_mem->ark_acor == NULL) {
+    ark_mem->ark_acor = N_VClone(tmpl);
+    if (ark_mem->ark_acor == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ycur if needed */
+  if (ark_mem->ark_ycur == NULL) {
+    ark_mem->ark_ycur = N_VClone(tmpl);
+    if (ark_mem->ark_ycur == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate sdata if needed */
+  if (ark_mem->ark_sdata == NULL) {
+    ark_mem->ark_sdata = N_VClone(tmpl);
+    if (ark_mem->ark_sdata == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate tempv if needed */
+  if (ark_mem->ark_tempv == NULL) {
+    ark_mem->ark_tempv = N_VClone(tmpl);
+    if (ark_mem->ark_tempv == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ftemp if needed */
+  if (ark_mem->ark_ftemp == NULL) {
+    ark_mem->ark_ftemp = N_VClone(tmpl);
+    if (ark_mem->ark_ftemp == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate fold if needed */
+  if (ark_mem->ark_fold == NULL) {
+    ark_mem->ark_fold = N_VClone(tmpl);
+    if (ark_mem->ark_fold == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate fnew if needed */
+  if (ark_mem->ark_fnew == NULL) {
+    ark_mem->ark_fnew = N_VClone(tmpl);
+    if (ark_mem->ark_fnew == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate yold if needed */
+  if (ark_mem->ark_yold == NULL) {
+    ark_mem->ark_yold = N_VClone(tmpl);
+    if (ark_mem->ark_yold == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ynew if needed */
+  if (ark_mem->ark_ynew == NULL) {
+    ark_mem->ark_ynew = N_VClone(tmpl);
+    if (ark_mem->ark_ynew == NULL) {
+      arkFreeVectors(ark_mem);
+      return(FALSE);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  return(TRUE);
+}
+
+
+/*---------------------------------------------------------------
+ arkAllocRKVectors
+
+ This routine allocates the ARKODE vectors 
+ Fe[0], ..., Fe[stages-1], Fi[0], ..., Fi[stages-1], and fa and 
+ fb (if necessary).
+
+ If any of these vectors already exist, they are left alone.  
+ Otherwise, it will allocate each vector by cloning the input 
+ vector. If all memory allocations are successful, 
+ arkAllocRKVectors returns TRUE.  Otherwise all vector memory is 
+ freed and arkAllocRKVectors returns FALSE. This routine also 
+ updates the optional outputs lrw and liw, which are 
+ (respectively) the lengths of the real and integer work spaces.
+
+ NOTE: this routine is separate from arkAllocVectors, since that
+ routine is called in ARKodeInit, which may be called by a user
+ prior to setting their desired method order, 
+ implicit/explicit/imex problem, and number of RK stages.  Hence
+ this routine is called during arkInitialStep, which is called 
+ on the first call to the ARKode() integrator.
+---------------------------------------------------------------*/
+static int arkAllocRKVectors(ARKodeMem ark_mem)
+{
+  int j;
+
+  /* Allocate Fe[0] ... Fe[stages-1] if needed */
+  if (!ark_mem->ark_implicit) {
+    for (j=0; j<ark_mem->ark_stages; j++) {
+      if (ark_mem->ark_Fe[j] == NULL) {
+	ark_mem->ark_Fe[j] = N_VClone(ark_mem->ark_ewt);
+	if (ark_mem->ark_Fe[j] == NULL) {
+	  arkFreeVectors(ark_mem);
+	  return(ARK_MEM_FAIL);
+	} else {
+	  ark_mem->ark_lrw += ark_mem->ark_lrw1;
+	  ark_mem->ark_liw += ark_mem->ark_liw1;
+	}
+      }
+    }
+  }
+
+  /* Allocate Fi[0] ... Fi[stages-1] if needed */
+  if (!ark_mem->ark_explicit) {
+    for (j=0; j<ark_mem->ark_stages; j++) {
+      if (ark_mem->ark_Fi[j] == NULL) {
+	ark_mem->ark_Fi[j] = N_VClone(ark_mem->ark_ewt);
+	if (ark_mem->ark_Fi[j] == NULL) {
+	  arkFreeVectors(ark_mem);
+	  return(ARK_MEM_FAIL);
+	} else {
+	  ark_mem->ark_lrw += ark_mem->ark_lrw1;
+	  ark_mem->ark_liw += ark_mem->ark_liw1;
+	}
+      }
+    }
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkFreeVectors
+
+ This routine frees the ARKODE vectors allocated in both
+ arkAllocVectors and arkAllocRKVectors.
+---------------------------------------------------------------*/
+static void arkFreeVectors(ARKodeMem ark_mem)
+{
+  int j;
+  if (ark_mem->ark_ewt != NULL) {
+    N_VDestroy(ark_mem->ark_ewt);
+    ark_mem->ark_ewt = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if ((!ark_mem->ark_rwt_is_ewt) && (ark_mem->ark_rwt != NULL)) {
+    N_VDestroy(ark_mem->ark_rwt);
+    ark_mem->ark_rwt = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_acor != NULL) {
+    N_VDestroy(ark_mem->ark_acor);
+    ark_mem->ark_acor = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_ycur != NULL) {
+    N_VDestroy(ark_mem->ark_ycur);
+    ark_mem->ark_ycur = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_sdata != NULL) {
+    N_VDestroy(ark_mem->ark_sdata);
+    ark_mem->ark_sdata = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_tempv != NULL) {
+    N_VDestroy(ark_mem->ark_tempv);
+    ark_mem->ark_tempv = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_ftemp != NULL) {
+    N_VDestroy(ark_mem->ark_ftemp);
+    ark_mem->ark_ftemp = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_fold != NULL) {
+    N_VDestroy(ark_mem->ark_fold);
+    ark_mem->ark_fold = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_fnew != NULL) {
+    N_VDestroy(ark_mem->ark_fnew);
+    ark_mem->ark_fnew = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_yold != NULL) {
+    N_VDestroy(ark_mem->ark_yold);
+    ark_mem->ark_yold = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  if (ark_mem->ark_ynew != NULL) {
+    N_VDestroy(ark_mem->ark_ynew);
+    ark_mem->ark_ynew = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+  /* if (ark_mem->ark_fa != NULL) { */
+  /*   N_VDestroy(ark_mem->ark_fa); */
+  /*   ark_mem->ark_fa = NULL; */
+  /*   ark_mem->ark_lrw -= ark_mem->ark_lrw1; */
+  /*   ark_mem->ark_liw -= ark_mem->ark_liw1; */
+  /* } */
+  /* if (ark_mem->ark_fb != NULL) { */
+  /*   N_VDestroy(ark_mem->ark_fb); */
+  /*   ark_mem->ark_fb = NULL; */
+  /*   ark_mem->ark_lrw -= ark_mem->ark_lrw1; */
+  /*   ark_mem->ark_liw -= ark_mem->ark_liw1; */
+  /* } */
+  for(j=0; j<ARK_S_MAX; j++) {
+    if (ark_mem->ark_Fe[j] != NULL) {
+      N_VDestroy(ark_mem->ark_Fe[j]);
+      ark_mem->ark_Fe[j] = NULL;
+      ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+      ark_mem->ark_liw -= ark_mem->ark_liw1;
+    }
+    if (ark_mem->ark_Fi[j] != NULL) {
+      N_VDestroy(ark_mem->ark_Fi[j]);
+      ark_mem->ark_Fi[j] = NULL;
+      ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+      ark_mem->ark_liw -= ark_mem->ark_liw1;
+    }
+  }
+  if (ark_mem->ark_Vabstol != NULL) {
+    N_VDestroy(ark_mem->ark_Vabstol);
+    ark_mem->ark_Vabstol = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+}
+
+
+/*---------------------------------------------------------------
+ arkAllocFPData
+
+ This routine allocates all required memory for performing the 
+ accelerated fixed-point solver.
+---------------------------------------------------------------*/
+static int arkAllocFPData(ARKodeMem ark_mem)
+{
+  long int maa = ark_mem->ark_fp_m;
+
+  /* ensure that DotProd function is defined */
+  if (ark_mem->ark_ewt->ops->nvdotprod == NULL) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "arkAllocFPData", MSGARK_BAD_NVECTOR);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Allocate ark_fp_fval if needed */
+  if (ark_mem->ark_fp_fval == NULL) {
+    ark_mem->ark_fp_fval = N_VClone(ark_mem->ark_ewt);
+    if (ark_mem->ark_fp_fval == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ark_fp_fold if needed */
+  if (ark_mem->ark_fp_fold == NULL) {
+    ark_mem->ark_fp_fold = N_VClone(ark_mem->ark_ewt);
+    if (ark_mem->ark_fp_fold == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ark_fp_gold if needed */
+  if (ark_mem->ark_fp_gold == NULL) {
+    ark_mem->ark_fp_gold = N_VClone(ark_mem->ark_ewt);
+    if (ark_mem->ark_fp_gold == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += ark_mem->ark_lrw1;
+      ark_mem->ark_liw += ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ark_fp_df if needed */
+  if ((ark_mem->ark_fp_df == NULL) && (maa > 0)) {
+    ark_mem->ark_fp_df = N_VCloneVectorArray(maa, ark_mem->ark_ewt);
+    if (ark_mem->ark_fp_df == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += maa*ark_mem->ark_lrw1;
+      ark_mem->ark_liw += maa*ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ark_fp_dg if needed */
+  if ((ark_mem->ark_fp_dg == NULL) && (maa > 0)) {
+    ark_mem->ark_fp_dg = N_VCloneVectorArray(maa, ark_mem->ark_ewt);
+    if (ark_mem->ark_fp_dg == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += maa*ark_mem->ark_lrw1;
+      ark_mem->ark_liw += maa*ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ark_fp_q if needed */
+  if ((ark_mem->ark_fp_q == NULL) && (maa > 0)) {
+    ark_mem->ark_fp_q = N_VCloneVectorArray(maa, ark_mem->ark_ewt);
+    if (ark_mem->ark_fp_q == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += maa*ark_mem->ark_lrw1;
+      ark_mem->ark_liw += maa*ark_mem->ark_liw1;
+    }
+  }
+
+  /* Allocate ark_fp_R if needed */
+  if ((ark_mem->ark_fp_R == NULL) && (maa > 0)) {
+    ark_mem->ark_fp_R = (realtype *) malloc((maa*maa) * sizeof(realtype));
+    if (ark_mem->ark_fp_R == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += maa*maa;
+    }
+  }
+
+  /* Allocate ark_fp_gamma if needed */
+  if ((ark_mem->ark_fp_gamma == NULL) && (maa > 0)) {
+    ark_mem->ark_fp_gamma = (realtype *) malloc(maa * sizeof(realtype));
+    if (ark_mem->ark_fp_gamma == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_lrw += maa;
+    }
+  }
+
+  /* Allocate ark_fp_imap if needed */
+  if ((ark_mem->ark_fp_imap == NULL) && (maa > 0)) {
+    ark_mem->ark_fp_imap = (long int *) malloc(maa * sizeof(long int));
+    if (ark_mem->ark_fp_imap == NULL) {
+      arkFreeFPData(ark_mem);
+      return(ARK_MEM_FAIL);
+    } else {
+      ark_mem->ark_liw += maa;
+    }
+  }
+
+  return(ARK_SUCCESS);
+}
+
+/*---------------------------------------------------------------
+ arkResizeFPData
+
+ This routine resizes all required memory for the accelerated
+ fixed-point solver (called from ARKodeResize()).
+---------------------------------------------------------------*/
+static int arkResizeFPData(ARKodeMem ark_mem, ARKVecResizeFn resize,
+			   void *resize_data, long int lrw_diff, 
+			   long int liw_diff)
+{
+  long int i;
+  long int maa = ark_mem->ark_fp_m;
+
+  /* Resize ark_fp_fval if needed */
+  if (ark_mem->ark_fp_fval != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_fp_fval);
+      ark_mem->ark_fp_fval = N_VClone(ark_mem->ark_ewt);
+    } else {
+      if (resize(ark_mem->ark_fp_fval, ark_mem->ark_ewt, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"arkResizeFPData", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+
+  /* Resize ark_fp_fold if needed */
+  if (ark_mem->ark_fp_fold != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_fp_fold);
+      ark_mem->ark_fp_fold = N_VClone(ark_mem->ark_ewt);
+    } else {
+      if (resize(ark_mem->ark_fp_fold, ark_mem->ark_ewt, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"arkResizeFPData", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+
+  /* Resize ark_fp_gold if needed */
+  if (ark_mem->ark_fp_gold != NULL) {
+    if (resize == NULL) {
+      N_VDestroy(ark_mem->ark_fp_gold);
+      ark_mem->ark_fp_gold = N_VClone(ark_mem->ark_ewt);
+    } else {
+      if (resize(ark_mem->ark_fp_gold, ark_mem->ark_ewt, resize_data)) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"arkResizeFPData", MSGARK_RESIZE_FAIL);
+	return(ARK_ILL_INPUT);
+      }
+    }
+    ark_mem->ark_lrw += lrw_diff;
+    ark_mem->ark_liw += liw_diff;
+  }
+
+  /* Resize ark_fp_df if needed */
+  if ((ark_mem->ark_fp_df != NULL) && (maa > 0)) {
+    for (i=0; i<maa; i++) {
+      if (resize == NULL) {
+	N_VDestroy(ark_mem->ark_fp_df[i]);
+	ark_mem->ark_fp_df[i] = N_VClone(ark_mem->ark_ewt);
+      } else {
+	if (resize(ark_mem->ark_fp_df[i], ark_mem->ark_ewt, resize_data)) {
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "arkResizeFPData", MSGARK_RESIZE_FAIL);
+	  return(ARK_ILL_INPUT);
+	}
+      }
+    }
+    ark_mem->ark_lrw += maa*lrw_diff;
+    ark_mem->ark_liw += maa*liw_diff;
+  }
+
+  /* Resize ark_fp_dg if needed */
+  if ((ark_mem->ark_fp_dg != NULL) && (maa > 0)) {
+    for (i=0; i<maa; i++) {
+      if (resize == NULL) {
+	N_VDestroy(ark_mem->ark_fp_dg[i]);
+	ark_mem->ark_fp_dg[i] = N_VClone(ark_mem->ark_ewt);
+      } else {
+	if (resize(ark_mem->ark_fp_dg[i], ark_mem->ark_ewt, resize_data)) {
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "arkResizeFPData", MSGARK_RESIZE_FAIL);
+	  return(ARK_ILL_INPUT);
+	}
+      }
+    }
+    ark_mem->ark_lrw += maa*lrw_diff;
+    ark_mem->ark_liw += maa*liw_diff;
+  }
+
+  /* Resize ark_fp_q if needed */
+  if ((ark_mem->ark_fp_q != NULL) && (maa > 0)) {
+    for (i=0; i<maa; i++) {
+      if (resize == NULL) {
+	N_VDestroy(ark_mem->ark_fp_q[i]);
+	ark_mem->ark_fp_q[i] = N_VClone(ark_mem->ark_ewt);
+      } else {
+	if (resize(ark_mem->ark_fp_q[i], ark_mem->ark_ewt, resize_data)) {
+	  arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			  "arkResizeFPData", MSGARK_RESIZE_FAIL);
+	  return(ARK_ILL_INPUT);
+	}
+      }
+    }
+    ark_mem->ark_lrw += maa*lrw_diff;
+    ark_mem->ark_liw += maa*liw_diff;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkFreeFPData
+
+ This routine frees all memory allocated by arkAllocFPData.
+---------------------------------------------------------------*/
+static void arkFreeFPData(ARKodeMem ark_mem)
+{
+  long int maa = ark_mem->ark_fp_m;
+
+  /* free ark_fp_fval if needed */
+  if (ark_mem->ark_fp_fval != NULL) {
+    N_VDestroy(ark_mem->ark_fp_fval);
+    ark_mem->ark_fp_fval = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+
+  /* free ark_fp_fold if needed */
+  if (ark_mem->ark_fp_fold != NULL) {
+    N_VDestroy(ark_mem->ark_fp_fold);
+    ark_mem->ark_fp_fold = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+
+  /* free ark_fp_gold if needed */
+  if (ark_mem->ark_fp_gold != NULL) {
+    N_VDestroy(ark_mem->ark_fp_gold);
+    ark_mem->ark_fp_gold = NULL;
+    ark_mem->ark_lrw -= ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= ark_mem->ark_liw1;
+  }
+
+  /* free ark_fp_df if needed */
+  if ((ark_mem->ark_fp_df != NULL) && (maa>0)) {
+    N_VDestroyVectorArray(ark_mem->ark_fp_df, maa);
+    ark_mem->ark_fp_df = NULL;
+    ark_mem->ark_lrw -= maa*ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= maa*ark_mem->ark_liw1;
+  }
+
+  /* free ark_fp_dg if needed */
+  if ((ark_mem->ark_fp_dg != NULL) && (maa>0)) {
+    N_VDestroyVectorArray(ark_mem->ark_fp_dg, maa);
+    ark_mem->ark_fp_dg = NULL;
+    ark_mem->ark_lrw -= maa*ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= maa*ark_mem->ark_liw1;
+  }
+
+  /* free ark_fp_q if needed */
+  if ((ark_mem->ark_fp_q != NULL) && (maa>0)) {
+    N_VDestroyVectorArray(ark_mem->ark_fp_q, maa);
+    ark_mem->ark_fp_q = NULL;
+    ark_mem->ark_lrw -= maa*ark_mem->ark_lrw1;
+    ark_mem->ark_liw -= maa*ark_mem->ark_liw1;
+  }
+
+  /* free ark_fp_R if needed */
+  if (ark_mem->ark_fp_R != NULL) {
+    free(ark_mem->ark_fp_R);
+    ark_mem->ark_fp_R = NULL;
+    ark_mem->ark_lrw -= maa*maa;
+  }
+
+  /* free ark_fp_gamma if needed */
+  if (ark_mem->ark_fp_gamma != NULL) {
+    free(ark_mem->ark_fp_gamma);
+    ark_mem->ark_fp_gamma = NULL;
+    ark_mem->ark_lrw -= maa;
+  }
+
+  /* free ark_fp_imap if needed */
+  if (ark_mem->ark_fp_imap != NULL) {
+    free(ark_mem->ark_fp_imap);
+    ark_mem->ark_fp_imap = NULL;
+    ark_mem->ark_liw -= maa;
+  }
+}
+
+
+/*---------------------------------------------------------------
+ arkInitialSetup
+
+ This routine performs input consistency checks at the first step.
+ If needed, it also checks the linear solver module and calls the
+ linear solver initialization routine.
+---------------------------------------------------------------*/
+static int arkInitialSetup(ARKodeMem ark_mem)
+{
+  int ier;
+
+  /* Set first step growth factor */
+  ark_mem->ark_etamax = ark_mem->ark_etamx1;
+
+  /* Create Butcher tables (if not already set) */
+  ier = arkSetButcherTables(ark_mem);
+  if (ier != ARK_SUCCESS) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "arkInitialStep", "Could not create Butcher table");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Check that Butcher tables are OK */
+  ier = arkCheckButcherTables(ark_mem);
+  if (ier != ARK_SUCCESS) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "arkInitialStep", "Error in Butcher tables");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Check that user has supplied an initial step size if fixedstep mode is on */ 
+  if ( (ark_mem->ark_fixedstep) && (ark_mem->ark_hin == ZERO) ) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "arkInitialStep", "Fixed step mode enabled, but no step size set");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Allocate ARK RHS vector memory */
+  ier = arkAllocRKVectors(ark_mem);
+  if (ier != ARK_SUCCESS) {
+    arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		    "arkInitialSetup", MSGARK_MEM_FAIL);
+    return(ARK_MEM_FAIL);
+  }
+
+  /* Check for consistency between linear system modules 
+     (if lsolve is direct, msolve needs to match) */
+  if (ark_mem->ark_mass_matrix) {  /* M != I */
+    if (ark_mem->ark_lsolve_type != 0) { /* non-iterative */
+      if (ark_mem->ark_lsolve_type != ark_mem->ark_msolve_type) {
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"arkInitialSetup", 
+			"Incompatible linear and mass matrix solvers");
+	return(ARK_MEM_FAIL);
+      }
+    }
+  }
+
+  /* Set data for efun (if left unspecified) */
+  if (ark_mem->ark_user_efun) 
+    ark_mem->ark_e_data = ark_mem->ark_user_data;
+  else                        
+    ark_mem->ark_e_data = ark_mem;
+
+  /* Load initial error weights */
+  ier = ark_mem->ark_efun(ark_mem->ark_ycur,
+			  ark_mem->ark_ewt, 
+			  ark_mem->ark_e_data);
+  if (ier != 0) {
+    if (ark_mem->ark_itol == ARK_WF) 
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		      "arkInitialSetup", MSGARK_EWT_FAIL);
+    else 
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		      "arkInitialSetup", MSGARK_BAD_EWT);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* Set data for rfun (if left unspecified) */
+  if (ark_mem->ark_user_rfun) 
+    ark_mem->ark_r_data = ark_mem->ark_user_data;
+  else                        
+    ark_mem->ark_r_data = ark_mem;
+
+  /* Load initial residual weights */
+  if (ark_mem->ark_rwt_is_ewt) {      /* update pointer to ewt */
+    ark_mem->ark_rwt = ark_mem->ark_ewt;
+  } else { 
+    ier = ark_mem->ark_rfun(ark_mem->ark_ycur,
+			    ark_mem->ark_rwt, 
+			    ark_mem->ark_r_data);
+    if (ier != 0) {
+      if (ark_mem->ark_itol == ARK_WF) 
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"arkInitialSetup", MSGARK_RWT_FAIL);
+      else 
+	arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+			"arkInitialSetup", MSGARK_BAD_RWT);
+      return(ARK_ILL_INPUT);
+    }
+  }
+
+  /* Check if lsolve function exists and call linit (if it exists) */
+  if (!ark_mem->ark_explicit && !ark_mem->ark_use_fp) {
+    if (ark_mem->ark_lsolve == NULL) {
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		      "arkInitialSetup", MSGARK_LSOLVE_NULL);
+      return(ARK_ILL_INPUT);
+    }
+    if (ark_mem->ark_linit != NULL) {
+      ier = ark_mem->ark_linit(ark_mem);
+      if (ier != 0) {
+	arkProcessError(ark_mem, ARK_LINIT_FAIL, "ARKODE", 
+			"arkInitialSetup", MSGARK_LINIT_FAIL);
+	return(ARK_LINIT_FAIL);
+      }
+    }
+  }
+
+  /* Call minit (if it exists) */
+  if (ark_mem->ark_minit != NULL) {
+    ier = ark_mem->ark_minit(ark_mem);
+    if (ier != 0) {
+      arkProcessError(ark_mem, ARK_MASSINIT_FAIL, "ARKODE", 
+		      "arkInitialSetup", MSGARK_MASSINIT_FAIL);
+      return(ARK_MASSINIT_FAIL);
+    }
+  }
+  
+  /* Call msetup (if necessary) */
+  if (ark_mem->ark_mass_matrix && ark_mem->ark_MassSetupNonNull) {
+    ier = ark_mem->ark_msetup(ark_mem, ark_mem->ark_ewt, 
+			      ark_mem->ark_acor, ark_mem->ark_sdata);
+    if (ier != 0) {
+      arkProcessError(ark_mem, ARK_MASSSETUP_FAIL, "ARKODE", 
+		      "arkInitialSetup", MSGARK_MASSSETUP_FAIL);
+      return(ARK_MASSSETUP_FAIL);
+    }
+  }
+
+  /* Allocate fixed-point solver memory */
+  if (ark_mem->ark_use_fp) {
+    ier = arkAllocFPData(ark_mem);
+    if (ier != ARK_SUCCESS) {
+      arkProcessError(ark_mem, ARK_MEM_FAIL, "ARKODE", 
+		      "arkInitialSetup", MSGARK_MEM_FAIL);
+      return(ARK_MEM_FAIL);
+    }
+  }
+
+  /* Fill initial ynew and fnew arrays */
+  N_VScale(ONE, ark_mem->ark_ycur, ark_mem->ark_ynew);
+  ier = arkFullRHS(ark_mem, ark_mem->ark_tn, ark_mem->ark_ycur,
+		   ark_mem->ark_ftemp, ark_mem->ark_fnew);
+  if (ier != 0)  return(ARK_RHSFUNC_FAIL);
+
+  /* if the problem involves a non-identity mass matrix, update fnew here */
+  if (ark_mem->ark_mass_matrix) {
+    N_VScale(ark_mem->ark_h, ark_mem->ark_fnew, ark_mem->ark_fnew);   /* scale RHS */
+    ier = ark_mem->ark_msolve(ark_mem, ark_mem->ark_fnew, ark_mem->ark_rwt); 
+    N_VScale(ONE/ark_mem->ark_h, ark_mem->ark_fnew, ark_mem->ark_fnew);   /* scale result */
+    ark_mem->ark_mass_solves++;
+    if (ier != ARK_SUCCESS) {
+      ark_mem->ark_nmassfails++;
+      arkProcessError(ark_mem, ARK_MASSSOLVE_FAIL, "ARKODE", 
+		      "arkInitialSetup", "Mass matrix solver failure");
+      return(ARK_MASSSOLVE_FAIL);
+    }
+  }
+  
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkHin
+
+ This routine computes a tentative initial step size h0. 
+ If tout is too close to tn (= t0), then arkHin returns 
+ ARK_TOO_CLOSE and h remains uninitialized. Note that here tout 
+ is either the value passed to ARKode at the first call or the 
+ value of tstop (if tstop is enabled and it is closer to t0=tn 
+ than tout). If the RHS function fails unrecoverably, arkHin 
+ returns ARK_RHSFUNC_FAIL. If the RHS function fails recoverably 
+ too many times and recovery is not possible, arkHin returns 
+ ARK_REPTD_RHSFUNC_ERR. Otherwise, arkHin sets h to the chosen 
+ value h0 and returns ARK_SUCCESS.
+
+ The algorithm used seeks to find h0 as a solution of
+       (WRMS norm of (h0^2 ydd / 2)) = 1, 
+ where ydd = estimated second derivative of y.  Although this 
+ choice is based on an error expansion of the Backward Euler
+ method, and hence results in an overly-conservative time step 
+ for our higher-order ARK methods, it does find an order-of-
+ magnitude estimate of the initial time scale of the solution.
+ Since this method is only used on the first time step, the
+ additional caution will not overly hinder solver efficiency.
+
+ We start with an initial estimate equal to the geometric mean 
+ of the lower and upper bounds on the step size.
+
+ Loop up to H0_ITERS times to find h0.
+ Stop if new and previous values differ by a factor < 2.
+ Stop if hnew/hg > 2 after one iteration, as this probably 
+ means that the ydd value is bad because of cancellation error.        
+  
+ For each new proposed hg, we allow H0_ITERS attempts to
+ resolve a possible recoverable failure from f() by reducing
+ the proposed stepsize by a factor of 0.2. If a legal stepsize
+ still cannot be found, fall back on a previous value if 
+ possible, or else return ARK_REPTD_RHSFUNC_ERR.
+
+ Finally, we apply a bias (0.5) and verify that h0 is within 
+ bounds.
+---------------------------------------------------------------*/
+static int arkHin(ARKodeMem ark_mem, realtype tout)
+{
+  int retval, sign, count1, count2;
+  realtype tdiff, tdist, tround, hlb, hub;
+  realtype hg, hgs, hs, hnew, hrat, h0, yddnrm;
+  booleantype hgOK, hnewOK;
+
+  /* If tout is too close to tn, give up */
+  if ((tdiff = tout-ark_mem->ark_tn) == ZERO) return(ARK_TOO_CLOSE);
+  
+  sign = (tdiff > ZERO) ? 1 : -1;
+  tdist = SUNRabs(tdiff);
+  tround = ark_mem->ark_uround * SUNMAX(SUNRabs(ark_mem->ark_tn), SUNRabs(tout));
+
+  if (tdist < TWO*tround) return(ARK_TOO_CLOSE);
+  
+  /* Set lower and upper bounds on h0, and take geometric mean 
+     as first trial value.
+     Exit with this value if the bounds cross each other. */
+  hlb = H0_LBFACTOR * tround;
+  hub = arkUpperBoundH0(ark_mem, tdist);
+
+  hg  = SUNRsqrt(hlb*hub);
+
+  if (hub < hlb) {
+    if (sign == -1) ark_mem->ark_h = -hg;
+    else            ark_mem->ark_h =  hg;
+    return(ARK_SUCCESS);
+  }
+  
+  /* Outer loop */
+  hnewOK = FALSE;
+  hs = hg;     /* safeguard against 'uninitialized variable' warning */
+  for(count1 = 1; count1 <= H0_ITERS; count1++) {
+
+    /* Attempts to estimate ydd */
+    hgOK = FALSE;
+
+    for (count2 = 1; count2 <= H0_ITERS; count2++) {
+      hgs = hg*sign;
+      retval = arkYddNorm(ark_mem, hgs, &yddnrm);
+      /* If f() failed unrecoverably, give up */
+      if (retval < 0) return(ARK_RHSFUNC_FAIL);
+      /* If successful, we can use ydd */
+      if (retval == ARK_SUCCESS) {hgOK = TRUE; break;}
+      /* f() failed recoverably; cut step size and test it again */
+      hg *= POINT2;
+    }
+
+    /* If f() failed recoverably H0_ITERS times */
+    if (!hgOK) {
+      /* Exit if this is the first or second pass. No recovery possible */
+      if (count1 <= 2) return(ARK_REPTD_RHSFUNC_ERR);
+      /* We have a fall-back option. The value hs is a previous hnew which
+         passed through f(). Use it and break */
+      hnew = hs;
+      break;
+    }
+
+    /* The proposed step size is feasible. Save it. */
+    hs = hg;
+
+    /* If stopping criteria was met, or if this is the last pass, stop */
+    if ( (hnewOK) || (count1 == H0_ITERS))  {hnew = hg; break;}
+
+    /* Propose new step size */
+    hnew = (yddnrm*hub*hub > TWO) ? SUNRsqrt(TWO/yddnrm) : SUNRsqrt(hg*hub);
+    hrat = hnew/hg;
+    
+    /* Accept hnew if it does not differ from hg by more than a factor of 2 */
+    if ((hrat > HALF) && (hrat < TWO))  hnewOK = TRUE;
+
+    /* After one pass, if ydd seems to be bad, use fall-back value. */
+    if ((count1 > 1) && (hrat > TWO)) {
+      hnew = hg;
+      hnewOK = TRUE;
+    }
+
+    /* Send this value back through f() */
+    hg = hnew;
+  }
+
+  /* Apply bounds, bias factor, and attach sign */
+  h0 = H0_BIAS*hnew;
+  if (h0 < hlb) h0 = hlb;
+  if (h0 > hub) h0 = hub;
+  if (sign == -1) h0 = -h0;
+  ark_mem->ark_h = h0;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkUpperBoundH0
+
+ This routine sets an upper bound on abs(h0) based on
+ tdist = tn - t0 and the values of y[i]/y'[i].
+---------------------------------------------------------------*/
+static realtype arkUpperBoundH0(ARKodeMem ark_mem, realtype tdist)
+{
+  realtype hub_inv, hub;
+  N_Vector temp1, temp2;
+
+  /* Bound based on |y0|/|y0'| -- allow at most an increase of
+   * H0_UBFACTOR in y0 (based on a forward Euler step). The weight 
+   * factor is used as a safeguard against zero components in y0. */
+  temp1 = ark_mem->ark_tempv;
+  temp2 = ark_mem->ark_acor;
+
+  N_VAbs(ark_mem->ark_ynew, temp2);
+  ark_mem->ark_efun(ark_mem->ark_ynew, temp1, ark_mem->ark_e_data);
+  N_VInv(temp1, temp1);
+  N_VLinearSum(H0_UBFACTOR, temp2, ONE, temp1, temp1);
+
+  N_VAbs(ark_mem->ark_fnew, temp2);
+
+  N_VDiv(temp2, temp1, temp1);
+  hub_inv = N_VMaxNorm(temp1);
+
+  /* bound based on tdist -- allow at most a step of magnitude
+   * H0_UBFACTOR * tdist */
+  hub = H0_UBFACTOR*tdist;
+
+  /* Use the smaller of the two */
+  if (hub*hub_inv > ONE) hub = ONE/hub_inv;
+
+  return(hub);
+}
+
+
+/*---------------------------------------------------------------
+ arkYddNorm
+
+ This routine computes an estimate of the second derivative of y
+ using a difference quotient, and returns its WRMS norm.
+---------------------------------------------------------------*/
+static int arkYddNorm(ARKodeMem ark_mem, realtype hg, realtype *yddnrm)
+{
+  int retval;
+
+  /* increment y with a multiple of f */
+  N_VLinearSum(hg, ark_mem->ark_fnew, ONE, 
+	       ark_mem->ark_ynew, ark_mem->ark_y);
+
+  /* compute y', via the ODE RHS routine */
+  retval = arkFullRHS(ark_mem, ark_mem->ark_tn+hg, ark_mem->ark_y, 
+		      ark_mem->ark_ftemp, ark_mem->ark_tempv);
+  if (retval != 0) return(ARK_RHSFUNC_FAIL);
+
+  /* if using a non-identity mass matrix, update fnew here to get y' */
+  if (ark_mem->ark_mass_matrix) {
+    N_VScale(ark_mem->ark_h, ark_mem->ark_tempv, ark_mem->ark_tempv);
+    retval = ark_mem->ark_msolve(ark_mem, ark_mem->ark_tempv, ark_mem->ark_rwt); 
+    /* retval = ark_mem->ark_msolve(ark_mem, ark_mem->ark_tempv, ark_mem->ark_ewt);  */
+    N_VScale(ONE/ark_mem->ark_h, ark_mem->ark_tempv, ark_mem->ark_tempv);
+    ark_mem->ark_mass_solves++;
+    if (retval != ARK_SUCCESS) {
+      ark_mem->ark_nmassfails++;
+      arkProcessError(ark_mem, ARK_MASSSOLVE_FAIL, "ARKODE", 
+		      "arkYddNorm", "Mass matrix solver failure");
+      return(ARK_MASSSOLVE_FAIL);
+    }
+  }
+
+  /* difference new f and original f to estimate y'' */
+  N_VLinearSum(ONE, ark_mem->ark_tempv, -ONE, 
+	       ark_mem->ark_fnew, ark_mem->ark_tempv);
+  N_VScale(ONE/hg, ark_mem->ark_tempv, ark_mem->ark_tempv);
+
+  /* compute norm of y'' */
+  *yddnrm = N_VWrmsNorm(ark_mem->ark_tempv, ark_mem->ark_ewt);
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkSetButcherTables
+
+ This routine determines the ERK/DIRK/ARK method to use, based 
+ on the desired accuracy and information on whether the problem
+ is explicit, implicit or imex.
+---------------------------------------------------------------*/
+static int arkSetButcherTables(ARKodeMem ark_mem)
+{
+
+  /* if tables have already been specified, just return */
+  int i,j,q, etable=-1, itable=-1;
+  booleantype A_set = FALSE;
+  for (i=0; i<ARK_S_MAX; i++) {
+    for (j=0; j<ARK_S_MAX; j++) {
+      if (SUNRabs(ARK_A(ark_mem->ark_Ae,i,j)) > TINY)  A_set = TRUE;
+      if (SUNRabs(ARK_A(ark_mem->ark_Ai,i,j)) > TINY)  A_set = TRUE;
+    }
+    if (SUNRabs(ark_mem->ark_be[i]) > TINY)  A_set = TRUE;
+    if (SUNRabs(ark_mem->ark_bi[i]) > TINY)  A_set = TRUE;
+    if (SUNRabs(ark_mem->ark_ce[i]) > TINY)  A_set = TRUE;
+    if (SUNRabs(ark_mem->ark_ci[i]) > TINY)  A_set = TRUE;
+  }
+  if (A_set)  return (ARK_SUCCESS);
+
+  /**** explicit methods ****/
+  if (ark_mem->ark_explicit) {
+
+    switch (ark_mem->ark_q) {
+    case(2):
+      etable = DEFAULT_ERK_2;
+      break;
+    case(3):
+      etable = DEFAULT_ERK_3;
+      break;
+    case(4):
+      etable = DEFAULT_ERK_4;
+      break;
+    case(5):
+      etable = DEFAULT_ERK_5;
+      break;
+    case(6):
+      etable = DEFAULT_ERK_6;
+      break;
+    case(7):
+    case(8):
+      etable = DEFAULT_ERK_8;
+      break;
+    default:    /* no available method, set default */
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		      "arkSetButcherTables", 
+		      "No explicit method at requested order, using q=6.");
+      etable = DEFAULT_ERK_6;
+      break;
+    }
+
+  /**** implicit methods ****/
+  } else if (ark_mem->ark_implicit) {
+
+    switch (ark_mem->ark_q) {
+    case(2):
+      itable = DEFAULT_DIRK_2;
+      break;
+    case(3):
+      itable = DEFAULT_DIRK_3;
+      break;
+    case(4):
+      itable = DEFAULT_DIRK_4;
+      break;
+    case(5):
+      itable = DEFAULT_DIRK_5;;
+      break;
+    default:    /* no available method, set default */
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		      "arkSetButcherTables", 
+		      "No implicit method at requested order, using q=5.");
+      itable = DEFAULT_DIRK_5;
+      break;
+    }
+
+  /**** ImEx methods ****/
+  } else {
+
+    switch (ark_mem->ark_q) {
+
+    case(2):
+    case(3):
+      etable = DEFAULT_ARK_ETABLE_3;
+      itable = DEFAULT_ARK_ITABLE_3;
+      break;
+    case(4):
+      etable = DEFAULT_ARK_ETABLE_4;
+      itable = DEFAULT_ARK_ITABLE_4;
+      break;
+    case(5):
+      etable = DEFAULT_ARK_ETABLE_5;
+      itable = DEFAULT_ARK_ITABLE_5;
+      break;
+    default:    /* no available method, set default */
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		      "arkSetButcherTables", 
+		      "No ImEx method at requested order, using q=5.");
+      etable = DEFAULT_ARK_ETABLE_5;
+      itable = DEFAULT_ARK_ITABLE_5;
+      break;
+    }
+  }
+
+  if (etable > -1)
+    ARKodeLoadButcherTable(etable, 
+			   &ark_mem->ark_stages, 
+			   &q, 
+			   &ark_mem->ark_p, 
+			   ark_mem->ark_Ae, 
+			   ark_mem->ark_be, 
+			   ark_mem->ark_ce, 
+			   ark_mem->ark_b2e);
+  if (itable > -1)
+    ARKodeLoadButcherTable(itable, 
+			   &ark_mem->ark_stages, 
+			   &q, 
+			   &ark_mem->ark_p, 
+			   ark_mem->ark_Ai, 
+			   ark_mem->ark_bi, 
+			   ark_mem->ark_ci, 
+			   ark_mem->ark_b2i);
+
+  /* if requested method order does not match actual, update here */
+  ark_mem->ark_q = q;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkCheckButcherTables
+
+ This routine runs through the explicit and/or implicit Butcher 
+ tables to ensure that they meet all necessary requirements, 
+ including:
+     strictly lower-triangular (ERK)
+     lower-triangular with some nonzeros on diagonal (IRK)
+     method order q > 0 (all)
+     embedding order q > 0 (all -- if adaptive time-stepping enabled)
+     stages > 0 (all)
+
+Returns ARK_SUCCESS if tables pass, ARK_ILL_INPUT otherwise.
+---------------------------------------------------------------*/
+static int arkCheckButcherTables(ARKodeMem ark_mem)
+{
+  int i, j;
+  booleantype okay;
+  realtype tol = RCONST(1.0e-12);
+
+  /* check that ERK table is strictly lower triangular */
+  if (!ark_mem->ark_implicit) {
+    okay = TRUE;
+    for (i=0; i<ark_mem->ark_stages; i++)
+      for (j=i; j<ark_mem->ark_stages; j++)
+	if (SUNRabs(ARK_A(ark_mem->ark_Ae,i,j)) > tol)
+	  okay = FALSE;
+    if (!okay) {
+      arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		      "arkCheckButcherTables",
+		      "Ae Butcher table is implicit!");
+      return(ARK_ILL_INPUT);
+    }
+  }
+
+  /* check that IRK table is implicit */
+  if (!ark_mem->ark_explicit) {
+    okay = FALSE;
+    for (i=0; i<ark_mem->ark_stages; i++)
+      if (SUNRabs(ARK_A(ark_mem->ark_Ai,i,i)) > tol)
+	okay = TRUE;
+    if (!okay) {
+      arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		      "arkCheckButcherTables",
+		      "Ai Butcher table is explicit!");
+      return(ARK_ILL_INPUT);
+    }
+  }
+
+  /* check that IRK table is lower triangular */
+  if (!ark_mem->ark_explicit) {
+    okay = TRUE;
+    for (i=0; i<ark_mem->ark_stages; i++)
+      for (j=i+1; j<ark_mem->ark_stages; j++)
+	if (SUNRabs(ARK_A(ark_mem->ark_Ai,i,j)) > tol)
+	  okay = FALSE;
+    if (!okay) {
+      arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		      "arkCheckButcherTables",
+		      "Ai Butcher table has entries above diagonal!");
+      return(ARK_ILL_INPUT);
+    }
+  }
+
+  /* check that method order q > 0 */
+  if (ark_mem->ark_q < 1) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "arkCheckButcherTables",
+		    "method order < 1!");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* check that embedding order p > 0 */
+  if ((ark_mem->ark_p < 1) && (!ark_mem->ark_fixedstep)) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "arkCheckButcherTables",
+		    "embedding order < 1!");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* check that stages > 0 */
+  if (ark_mem->ark_stages < 1) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "arkCheckButcherTables",
+		    "stages < 1!");
+    return(ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkStep
+
+ This routine performs one internal arkode step, from tn to tn + h.
+ It calls other routines to do all the work.
+
+ The main operations done here are as follows:
+ - preliminary adjustments if a new step size was chosen;
+ - loop over internal time step stages:
+   - predict stage solution (if implicit);
+   - set up RHS data using old solutions;
+   - solve the implicit system, or evaluate explicit update;
+ - testing the local error;
+ - reset stepsize for the next step.
+ On a failure in the linear/nonlinear solvers or error test, the
+ step may be reattempted, depending on the nature of the failure.
+---------------------------------------------------------------*/
+static int arkStep(ARKodeMem ark_mem)
+{
+  realtype saved_t, dsm, tn_explicit;
+  int retval, ncf, nef, is, nflag, kflag, eflag;
+  
+  saved_t = ark_mem->ark_tn;
+  ncf = nef = 0;
+  nflag = FIRST_CALL;
+  eflag = ARK_SUCCESS;
+  kflag = SOLVE_SUCCESS;
+
+  /* Looping point for attempts to take a step */
+  for(;;) {  
+
+    /* increment attempt counter */
+    ark_mem->ark_nst_attempts++;
+
+    /* Loop over internal stages to the step */
+    for (is=0; is<ark_mem->ark_stages; is++) {
+
+      /* store current stage index */
+      ark_mem->ark_istage = is;
+
+      /* Set current stage time(s) */
+      ark_mem->ark_tn = ark_mem->ark_tnew + ark_mem->ark_ci[is]*ark_mem->ark_h;
+      tn_explicit = ark_mem->ark_tnew + ark_mem->ark_ce[is]*ark_mem->ark_h;
+      /* if (ark_mem->ark_tstopset) { */
+      /* 	if ((ark_mem->ark_tn - ark_mem->ark_tstop)*ark_mem->ark_h > ZERO) */
+      /* 	  ark_mem->ark_tn = ark_mem->ark_tstop; */
+      /* 	if ((tn_explicit - ark_mem->ark_tstop)*ark_mem->ark_h > ZERO) */
+      /* 	  tn_explicit = ark_mem->ark_tstop; */
+      /* } */
+
+#ifdef DEBUG_OUTPUT
+ printf("step %li,  stage %i,  h = %19.16g,  t_n = %19.16g\n", 
+	 ark_mem->ark_nst, is, ark_mem->ark_h, ark_mem->ark_tn);
+#endif
+      
+      /* Call predictor for current stage solution (result placed in ycur) */
+      if (arkPredict(ark_mem, is) != ARK_SUCCESS)
+        return (ARK_MASSSOLVE_FAIL);
+
+#ifdef DEBUG_OUTPUT
+ printf("predictor:\n");
+ N_VPrint_Serial(ark_mem->ark_ycur);
+#endif
+      
+      /* Set up data for evaluation of ARK stage residual (data stored in ark_sdata) */
+      if (arkSet(ark_mem) != ARK_SUCCESS)  
+	return (ARK_MASSMULT_FAIL);
+
+#ifdef DEBUG_OUTPUT
+ printf("rhs data:\n");
+ N_VPrint_Serial(ark_mem->ark_sdata);
+#endif
+
+      /* Solver diagnostics reporting */
+      if (ark_mem->ark_report) 	
+	fprintf(ark_mem->ark_diagfp, "step  %li  %19.16g  %i  %19.16g\n",
+		ark_mem->ark_nst, ark_mem->ark_h, is, ark_mem->ark_tn);
+
+      /* solve implicit problem (if required) */
+      if (SUNRabs(ARK_A(ark_mem->ark_Ai,is,is)) > TINY) {
+
+	/* perform implicit solve */
+	nflag = arkNls(ark_mem, nflag);
+
+#ifdef DEBUG_OUTPUT
+ printf("nonlinear solution:\n");
+ N_VPrint_Serial(ark_mem->ark_y);
+#endif
+
+	/* check for convergence (on failure, h will have been modified) */
+	kflag = arkHandleNFlag(ark_mem, &nflag, saved_t, &ncf);
+
+	/* If fixed time-stepping is used, then anything other than a 
+	   successful solve must result in an error */
+	if (ark_mem->ark_fixedstep && (kflag != SOLVE_SUCCESS)) 
+	  return(kflag);
+
+	/* If h reduced and step needs to be retried, break loop */
+	if (kflag == PREDICT_AGAIN) break;
+
+	/* Return if nonlinear solve failed and recovery not possible. */
+	if (kflag != SOLVE_SUCCESS) return(kflag);
+
+      /* otherwise no nonlinear solve is needed */
+      } else {
+
+	/* if M!=I, solve with M to compute update (place back in sdata) */
+	if (ark_mem->ark_mass_matrix) {
+
+	  /* perform mass matrix solve */
+	  /* nflag = ark_mem->ark_msolve(ark_mem, ark_mem->ark_sdata,  */
+	  /* 			      ark_mem->ark_ewt);  */
+	  nflag = ark_mem->ark_msolve(ark_mem, ark_mem->ark_sdata, 
+				      ark_mem->ark_rwt); 
+	  ark_mem->ark_mass_solves++;
+	  
+	  /* check for convergence (on failure, h will have been modified) */
+	  kflag = arkHandleNFlag(ark_mem, &nflag, saved_t, &ncf);
+
+	  /* increment failure counter if necessary */
+	  if (kflag != SOLVE_SUCCESS)
+	    ark_mem->ark_nmassfails++;
+
+	  /* If fixed time-stepping is used, then anything other than a 
+	     successful solve must result in an error */
+	  if (ark_mem->ark_fixedstep && (kflag != SOLVE_SUCCESS)) 
+	    return(kflag);
+
+	  /* If h reduced and step needs to be retried, break loop */
+	  if (kflag == PREDICT_AGAIN) break;
+
+	  /* Return if solve failed and recovery not possible. */
+	  if (kflag != SOLVE_SUCCESS) return(kflag);
+
+      	/* if M==I, set y to be ycur + RHS data computed in arkSet */
+	} else {
+	  N_VLinearSum(ONE, ark_mem->ark_sdata, ONE, 
+		       ark_mem->ark_ycur, ark_mem->ark_y);
+	}
+
+#ifdef DEBUG_OUTPUT
+ printf("explicit solution:\n");
+ N_VPrint_Serial(ark_mem->ark_y);
+#endif
+
+      }
+
+      /* successful stage solve, fill in implicit and explicit RHS for this stage */
+      if (!ark_mem->ark_explicit) {
+	retval = ark_mem->ark_fi(ark_mem->ark_tn, ark_mem->ark_y,
+				 ark_mem->ark_Fi[is], ark_mem->ark_user_data);
+	ark_mem->ark_nfi++; 
+	if (retval < 0)  return(ARK_RHSFUNC_FAIL);
+	if (retval > 0)  return(ARK_UNREC_RHSFUNC_ERR);
+      }
+      if (!ark_mem->ark_implicit) {
+	retval = ark_mem->ark_fe(tn_explicit, ark_mem->ark_y, 
+				 ark_mem->ark_Fe[is], ark_mem->ark_user_data);
+	ark_mem->ark_nfe++;
+	if (retval < 0)  return(ARK_RHSFUNC_FAIL);
+	if (retval > 0)  return(ARK_UNREC_RHSFUNC_ERR);
+      }
+
+    } /* loop over stages */
+
+    /* if h has changed due to convergence failure and a new 
+       prediction is needed, continue to next attempt at step
+       (cannot occur if fixed time stepping is enabled) */
+    if (kflag == PREDICT_AGAIN)  continue;
+      
+    /* compute time-evolved solution (in ark_y), error estimate (in dsm) */
+    retval = arkComputeSolutions(ark_mem, &dsm);
+    if (retval < 0)  return(retval);    /* msetup failure */
+
+#ifdef DEBUG_OUTPUT
+ printf("error estimate = %19.16g\n", dsm);
+#endif
+
+    /* Solver diagnostics reporting */
+    if (ark_mem->ark_report) 
+      fprintf(ark_mem->ark_diagfp, "  etest  %li  %19.16g  %19.16g\n", 
+	      ark_mem->ark_nst, ark_mem->ark_h, dsm);
+
+    /* Perform time accuracy error test (if failure, updates h for next try) */
+    if (!ark_mem->ark_fixedstep) 
+      eflag = arkDoErrorTest(ark_mem, &nflag, saved_t, &nef, dsm);
+	
+#ifdef DEBUG_OUTPUT
+ printf("error test flag = %i\n", eflag);
+#endif
+
+    /* Restart step attempt (recompute all stages) if error test fails recoverably */
+    if (eflag == TRY_AGAIN)  continue;
+	
+    /* Return if error test failed and recovery not possible. */
+    if (eflag != ARK_SUCCESS)  return(eflag);
+	
+    /* Error test passed (eflag=ARK_SUCCESS), break from loop */
+    break;
+
+  } /* loop over step attempts */
+
+
+  /* Nonlinear system solves and error test were all successful, clean up */
+
+  /*    Update current time to step end */
+  ark_mem->ark_tn = saved_t + ark_mem->ark_h;
+  if (ark_mem->ark_tstopset)
+    if ((ark_mem->ark_tn - ark_mem->ark_tstop)*ark_mem->ark_h > ZERO)
+      ark_mem->ark_tn = ark_mem->ark_tstop;
+
+  /*    Update current solution data */
+  eflag = arkCompleteStep(ark_mem, dsm); 
+  if (eflag != ARK_SUCCESS)  return(eflag);
+
+  /*    Consider change of step size */
+  retval = arkPrepareNextStep(ark_mem); 
+  if (retval != ARK_SUCCESS)  return(retval);
+
+  /*    Reset growth factor for subsequent time step */
+  ark_mem->ark_etamax = ark_mem->ark_hadapt_growth;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkPredict
+
+ This routine computes the prediction for a specific internal 
+ stage solution, storing the result in ark_mem->ark_ycur.  The 
+ prediction is done using the dense output routine in 
+ extrapolation mode, hence stages "far" from the previous time 
+ interval are predicted using lower order polynomials than the
+ "nearby" stages.
+---------------------------------------------------------------*/
+static int arkPredict(ARKodeMem ark_mem, int istage)
+{
+  int i, retval, ord, jstage;
+  realtype tau;
+  realtype tau_tol = 0.5;
+  realtype tau_tol2 = 0.75;
+  realtype h, a0, a1, a2, hA;
+  N_Vector yguess = ark_mem->ark_ycur;
+
+  /* if the first step (or if resized), use initial condition as guess */
+  if (ark_mem->ark_nst == 0 || ark_mem->ark_resized) {
+    N_VScale(ONE, ark_mem->ark_ynew, yguess);
+    return(ARK_SUCCESS);
+  }
+
+  /* set evaluation time tau relative shift from previous successful time */
+  tau = ark_mem->ark_ci[istage]*ark_mem->ark_h/ark_mem->ark_hold;
+
+  /* use requested predictor formula */
+  switch (ark_mem->ark_predictor) {
+
+  case 1:
+
+    /***** Dense Output Predictor 1 -- all to max order *****/
+    retval = arkDenseEval(ark_mem, tau, 0, ark_mem->ark_dense_q, yguess);
+    if (retval == ARK_SUCCESS)  return(ARK_SUCCESS);
+    break;
+
+  case 2:
+
+    /***** Dense Output Predictor 2 -- decrease order w/ increasing stage *****/
+    /* ord = SUNMAX(ark_mem->ark_dense_q - istage, 1); */
+    if (tau <= tau_tol) {
+      ord = 3;
+    } else if (tau <= tau_tol2) {
+      ord = 2;
+    } else {
+      ord = 1;
+    }
+    retval = arkDenseEval(ark_mem, tau, 0, ord, yguess);
+    if (retval == ARK_SUCCESS)  return(ARK_SUCCESS);
+    break;
+
+  case 3:
+
+    /***** Cutoff predictor: max order dense output for stages "close" to previous 
+	   step, first-order dense output predictor for subsequent stages *****/
+    if (tau <= tau_tol) {
+      retval = arkDenseEval(ark_mem, tau, 0, ark_mem->ark_dense_q, yguess);
+    } else {
+      retval = arkDenseEval(ark_mem, tau, 0, 1, yguess);
+    }
+    if (retval == ARK_SUCCESS)  return(ARK_SUCCESS);
+    break;
+
+  case 4:
+
+    /***** Bootstrap predictor: if any previous stage in step has nonzero c_i, 
+	   construct a quadratic Hermite interpolant for prediction; otherwise 
+	   use the trivial predictor. *****/
+
+    /* this approach will not work (for now) when using a non-identity mass matrix */
+    if (ark_mem->ark_mass_matrix)  break;
+
+    /* determine if any previous stages in step meet criteria */
+    jstage = -1;
+    for (i=0; i<istage; i++)
+      jstage = (ark_mem->ark_ci[i] != ZERO) ? i : jstage;
+
+    /* if using the trivial predictor, break */
+    if (jstage == -1)  break;
+    
+    /* find the "optimal" previous stage to use */
+    for (i=0; i<istage; i++) 
+      if ((ark_mem->ark_ci[i] > ark_mem->ark_ci[jstage]) && (ark_mem->ark_ci[i] != ZERO))
+	jstage = i;
+
+    /* evaluate the quadratic Hermite interpolant for the prediction */
+    h = ark_mem->ark_h * ark_mem->ark_ci[jstage];
+    tau = ark_mem->ark_h * ark_mem->ark_ci[istage];
+    a0 = ONE;
+    a2 = tau*tau/TWO/h;
+    a1 = tau - a2;
+
+    N_VLinearSum(a0, ark_mem->ark_ynew, a1, ark_mem->ark_fnew, yguess);
+    if (!ark_mem->ark_explicit) 
+      N_VLinearSum(a2, ark_mem->ark_Fi[jstage], ONE, yguess, yguess);
+    if (!ark_mem->ark_implicit) 
+      N_VLinearSum(a2, ark_mem->ark_Fe[jstage], ONE, yguess, yguess);
+    return(ARK_SUCCESS);
+    break;
+
+  case 5:
+
+    /***** Minimal correction predictor: use all previous stage 
+           information in this step *****/
+
+    /* this approach will not work (for now) when using a non-identity mass matrix */
+    if (ark_mem->ark_mass_matrix)  break;
+
+    /* yguess = h*sum_{j=0}^{i-1} (Ae(i,j)*Fe(j) + Ai(i,j)*Fi(j)) */
+    N_VConst(ZERO, yguess);
+    if (!ark_mem->ark_implicit)
+      for (jstage=0; jstage<istage; jstage++) {
+        hA = ark_mem->ark_h * ARK_A(ark_mem->ark_Ae,istage,jstage);
+        N_VLinearSum(hA, ark_mem->ark_Fe[jstage], ONE, yguess, yguess);
+      }
+    if (!ark_mem->ark_explicit)
+      for (jstage=0; jstage<istage; jstage++) {
+        hA = ark_mem->ark_h * ARK_A(ark_mem->ark_Ai,istage,jstage);
+        N_VLinearSum(hA, ark_mem->ark_Fi[jstage], ONE, yguess, yguess);
+    }
+
+    /* yguess = ynew + h*sum_{j=0}^{i-1}(Ae(i,j)*Fe(j) + Ai(i,j)*Fi(j)) */ 
+    N_VLinearSum(ONE, ark_mem->ark_ynew, ONE, yguess, yguess);
+    return(ARK_SUCCESS);
+    break;
+
+  }
+
+  /* if we made it here, use the trivial predictor (previous step solution) */
+  N_VScale(ONE, ark_mem->ark_ynew, yguess);
+  return(ARK_SUCCESS);
+
+}
+
+
+/*---------------------------------------------------------------
+ arkSet
+
+ This routine sets up the stage data for computing the RK 
+ residual, along with the step- and method-related factors 
+ gamma, gammap and gamrat.
+---------------------------------------------------------------*/
+static int arkSet(ARKodeMem ark_mem)
+{
+  /* local data */
+  realtype hA;
+  int retval, j, i = ark_mem->ark_istage;
+  N_Vector tmp = ark_mem->ark_tempv;
+
+  /* If ark_predictor==5, then sdata=0, otherwise set sdata appropriately */
+  if (ark_mem->ark_predictor == 5 && !ark_mem->ark_mass_matrix) {
+
+    N_VConst(ZERO, ark_mem->ark_sdata);
+
+  } else {
+
+    /* Initialize sdata to ynew - ycur (ycur holds guess) */
+    N_VLinearSum(ONE, ark_mem->ark_ynew, -ONE, ark_mem->ark_ycur, 
+                 ark_mem->ark_sdata);
+
+    /* If M!=I, replace sdata with M*sdata, so that sdata = M*(yn-ycur) */
+    if (ark_mem->ark_mass_matrix) {
+      N_VScale(ONE, ark_mem->ark_sdata, tmp);
+      retval = ark_mem->ark_mtimes(tmp, ark_mem->ark_sdata, ark_mem->ark_tn, 
+                                   ark_mem->ark_mtimes_data);
+      ark_mem->ark_mass_mult++;
+      if (retval != ARK_SUCCESS)  return (ARK_MASSMULT_FAIL);
+    }
+
+    /* Iterate over each prior stage updating rhs */
+    /*    Explicit pieces */
+    if (!ark_mem->ark_implicit)
+      for (j=0; j<i; j++) {
+        hA = ark_mem->ark_h * ARK_A(ark_mem->ark_Ae,i,j);
+        N_VLinearSum(hA, ark_mem->ark_Fe[j], ONE, 
+                     ark_mem->ark_sdata, ark_mem->ark_sdata);
+      }
+    /*    Implicit pieces */
+    if (!ark_mem->ark_explicit)
+      for (j=0; j<i; j++) {
+        hA = ark_mem->ark_h * ARK_A(ark_mem->ark_Ai,i,j);
+        N_VLinearSum(hA, ark_mem->ark_Fi[j], ONE, 
+                     ark_mem->ark_sdata, ark_mem->ark_sdata);
+      }
+
+  }
+
+  /* Update gamma */
+  ark_mem->ark_gamma = ark_mem->ark_h * ARK_A(ark_mem->ark_Ai,i,i);
+  if (ark_mem->ark_firststage)  
+    ark_mem->ark_gammap = ark_mem->ark_gamma;
+  ark_mem->ark_gamrat = (ark_mem->ark_firststage) ? 
+    ONE : ark_mem->ark_gamma / ark_mem->ark_gammap;  /* protect x/x != 1.0 */
+
+  /* return with success */
+  return (ARK_SUCCESS);
+
+}
+
+
+/*---------------------------------------------------------------
+ arkComputeSolutions
+
+ This routine calculates the final RK solution using the existing 
+ data.  This solution is placed directly in ark_y.  This routine 
+ also computes the error estimate ||y-ytilde||_WRMS, where ytilde 
+ is the embedded solution, and the norm weights come from 
+ ark_ewt.  This norm value is returned.  The vector form of this 
+ estimated error (y-ytilde) is stored in ark_tempv, in case the 
+ calling routine wishes to examine the error locations.
+
+ Note: at this point in the step, the vectors ark_tempv, 
+ ark_sdata and ark_ycur may all be used as temporary vectors.
+---------------------------------------------------------------*/
+static int arkComputeSolutions(ARKodeMem ark_mem, realtype *dsm)
+{
+  /* local data */
+  realtype hb;
+  int ier, j;
+  N_Vector y    = ark_mem->ark_y;
+  N_Vector yerr = ark_mem->ark_tempv;
+  N_Vector tmp1 = ark_mem->ark_sdata;
+  N_Vector tmp2 = ark_mem->ark_ycur;
+
+  /* Compute updated solution and error estimate based on whether
+     a non-identity mass matrix is present */
+  if (ark_mem->ark_mass_matrix) {   /* M != I */
+
+    /* setup mass matrix, using y, tmp1, tmp2 as temporaries */
+    if (ark_mem->ark_MassSetupNonNull) {
+      ier = ark_mem->ark_msetup(ark_mem, y, tmp1, tmp2);
+      if (ier != ARK_SUCCESS)  return(ARK_MASSSETUP_FAIL);
+    }
+
+    /* compute y RHS (store in y) */
+    N_VConst(ZERO, y);
+    for (j=0; j<ark_mem->ark_stages; j++) {
+      if (!ark_mem->ark_implicit) {
+	hb = ark_mem->ark_h * ark_mem->ark_be[j];
+	N_VLinearSum(hb, ark_mem->ark_Fe[j], ONE, y, y);
+      }
+      if (!ark_mem->ark_explicit) {
+	hb = ark_mem->ark_h * ark_mem->ark_bi[j];
+	N_VLinearSum(hb, ark_mem->ark_Fi[j], ONE, y, y);
+      }
+    }
+    
+    /* solve for y update (stored in y) */
+    /* ier = ark_mem->ark_msolve(ark_mem, y, ark_mem->ark_ewt);  */
+    ier = ark_mem->ark_msolve(ark_mem, y, ark_mem->ark_rwt); 
+    ark_mem->ark_mass_solves++;
+    if (ier < 0) {
+      ark_mem->ark_nmassfails++;
+      *dsm = 2.0;         /* indicate too much error, step with smaller step */
+      N_VScale(ONE, ark_mem->ark_ynew, y);      /* place old solution into y */
+      return(CONV_FAIL);
+    }
+
+    /* compute y = ynew + update */
+    N_VLinearSum(ONE, ark_mem->ark_ynew, ONE, y, y);
+
+
+    /* compute yerr (if step adaptivity enabled) */
+    N_VConst(ZERO, yerr);
+    if (!ark_mem->ark_fixedstep) {
+
+      /* compute yerr RHS vector (store in yerr) */
+      for (j=0; j<ark_mem->ark_stages; j++) {
+	if (!ark_mem->ark_implicit) {
+	  hb = ark_mem->ark_h * (ark_mem->ark_be[j] - ark_mem->ark_b2e[j]);
+	  N_VLinearSum(hb, ark_mem->ark_Fe[j], ONE, yerr, yerr);
+	}
+	if (!ark_mem->ark_explicit) {
+	  hb = ark_mem->ark_h * (ark_mem->ark_bi[j] - ark_mem->ark_b2i[j]);
+	  N_VLinearSum(hb, ark_mem->ark_Fi[j], ONE, yerr, yerr);
+	}
+      }
+
+      /* solve for yerr */
+      /* ier = ark_mem->ark_msolve(ark_mem, yerr, ark_mem->ark_ewt);  */
+      ier = ark_mem->ark_msolve(ark_mem, yerr, ark_mem->ark_rwt); 
+      ark_mem->ark_mass_solves++;
+      if (ier < 0) {
+	ark_mem->ark_nmassfails++;
+	*dsm = 2.0;         /* indicate too much error, step with smaller step */
+	return(CONV_FAIL);
+      }
+
+    }
+
+  } else {                          /* M == I */
+
+    /* Initialize solution to yn, error estimate to zero */
+    N_VScale(ONE, ark_mem->ark_ynew, y);
+    N_VConst(ZERO, yerr);
+
+    /* Compute time step solution */
+    for (j=0; j<ark_mem->ark_stages; j++) {
+      
+      if (!ark_mem->ark_implicit) {
+	hb = ark_mem->ark_h * ark_mem->ark_be[j];
+	N_VLinearSum(hb, ark_mem->ark_Fe[j], ONE, y, y);
+      }
+      if (!ark_mem->ark_explicit) {
+	hb = ark_mem->ark_h * ark_mem->ark_bi[j];
+	N_VLinearSum(hb, ark_mem->ark_Fi[j], ONE, y, y);
+      }
+
+    }
+
+    /* Compute yerr (if step adaptivity enabled) */
+    if (!ark_mem->ark_fixedstep) {
+      for (j=0; j<ark_mem->ark_stages; j++) {
+	if (!ark_mem->ark_implicit) {
+	  hb = ark_mem->ark_h * (ark_mem->ark_be[j] - ark_mem->ark_b2e[j]);
+	  N_VLinearSum(hb, ark_mem->ark_Fe[j], ONE, yerr, yerr);
+	}
+	if (!ark_mem->ark_explicit) {
+	  hb = ark_mem->ark_h * (ark_mem->ark_bi[j] - ark_mem->ark_b2i[j]);
+	  N_VLinearSum(hb, ark_mem->ark_Fi[j], ONE, yerr, yerr);
+	}
+      }
+    }
+
+  }
+
+  /* fill error norm and return */
+  *dsm = N_VWrmsNorm(yerr, ark_mem->ark_ewt);
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkDoErrorTest
+
+ This routine performs the local error test for the ARK method. 
+ The weighted local error norm dsm is passed in, and 
+ the test dsm ?<= 1 is made.
+
+ If the test passes, arkDoErrorTest returns ARK_SUCCESS. 
+
+ If the test fails, we revert to the last successful solution 
+ time, and:
+   - if maxnef error test failures have occurred or if 
+     SUNRabs(h) = hmin, we return ARK_ERR_FAILURE.
+   - otherwise: update time step factor eta based on local error 
+     estimate and reduce h.  Then set *nflagPtr to PREV_ERR_FAIL, 
+     and return TRY_AGAIN. 
+---------------------------------------------------------------*/
+static int arkDoErrorTest(ARKodeMem ark_mem, int *nflagPtr,
+			  realtype saved_t, int *nefPtr, realtype dsm)
+{
+  realtype ehist2, hhist2;
+  int retval;
+
+  /* If est. local error norm dsm passes test, return ARK_SUCCESS */  
+  if (dsm <= ONE) return(ARK_SUCCESS);
+  
+  /* Test failed; increment counters, set nflag, and restore tn */
+  (*nefPtr)++;
+  ark_mem->ark_netf++;
+  *nflagPtr = PREV_ERR_FAIL;
+  ark_mem->ark_tn = saved_t;
+
+  /* At maxnef failures or |h| = hmin, return ARK_ERR_FAILURE */
+  if ((SUNRabs(ark_mem->ark_h) <= ark_mem->ark_hmin*ONEPSM) ||
+      (*nefPtr == ark_mem->ark_maxnef)) return(ARK_ERR_FAILURE);
+
+  /* Set etamax=1 to prevent step size increase at end of this step */
+  ark_mem->ark_etamax = ONE;
+
+  /* Temporarily update error history array for recomputation of h */
+  ehist2 = ark_mem->ark_hadapt_ehist[2];
+  ark_mem->ark_hadapt_ehist[2] = ark_mem->ark_hadapt_ehist[1];
+  ark_mem->ark_hadapt_ehist[1] = ark_mem->ark_hadapt_ehist[0];
+  ark_mem->ark_hadapt_ehist[0] = dsm*ark_mem->ark_hadapt_bias;
+
+  /* Temporarily update step history array for recomputation of h */
+  hhist2 = ark_mem->ark_hadapt_hhist[2];
+  ark_mem->ark_hadapt_hhist[2] = ark_mem->ark_hadapt_hhist[1];
+  ark_mem->ark_hadapt_hhist[1] = ark_mem->ark_hadapt_hhist[0];
+  ark_mem->ark_hadapt_hhist[0] = ark_mem->ark_h;
+
+  /* Compute accuracy-based time step estimate (updated ark_eta) */
+  retval = arkAdapt(ark_mem);
+  if (retval != ARK_SUCCESS)  return(ARK_ERR_FAILURE);
+
+  /* Revert error history array */
+  ark_mem->ark_hadapt_ehist[0] = ark_mem->ark_hadapt_ehist[1];
+  ark_mem->ark_hadapt_ehist[1] = ark_mem->ark_hadapt_ehist[2];
+  ark_mem->ark_hadapt_ehist[2] = ehist2;
+
+  /* Revert step history array */
+  ark_mem->ark_hadapt_hhist[0] = ark_mem->ark_hadapt_hhist[1];
+  ark_mem->ark_hadapt_hhist[1] = ark_mem->ark_hadapt_hhist[2];
+  ark_mem->ark_hadapt_hhist[2] = hhist2;
+
+  /* Enforce failure bounds on eta, update h, and return for retry of step */
+  if (*nefPtr >= ark_mem->ark_small_nef) 
+    ark_mem->ark_eta = SUNMIN(ark_mem->ark_eta, ark_mem->ark_etamxf);
+  ark_mem->ark_h *= ark_mem->ark_eta;
+  ark_mem->ark_next_h = ark_mem->ark_h;
+  return(TRY_AGAIN);
+}
+
+
+/*---------------------------------------------------------------
+ arkCompleteStep
+
+ This routine performs various update operations when the step 
+ solution has passed the local error test.  We update the current
+ time, increment the step counter nst, record the values hold and
+ tnew, reset the resized flag, update the error and time step 
+ history arrays, update ycur to hold the current solution, and 
+ update the yold, ynew, fold and fnew arrays.
+---------------------------------------------------------------*/
+static int arkCompleteStep(ARKodeMem ark_mem, realtype dsm)
+{
+  int retval;
+  booleantype recomputeRHS;
+  N_Vector tempvec;
+
+  /* Set current time to the end of the step (in case the last 
+     stage time does not coincide with the step solution time).  
+     If tstop is enabled, it is possible for tn + h to be past 
+     tstop by roundoff, and in that case, we reset tn (after 
+     incrementing by h) to tstop. */
+  ark_mem->ark_tn = ark_mem->ark_tnew + ark_mem->ark_h;
+  if (ark_mem->ark_tstopset) {
+    if ((ark_mem->ark_tn - ark_mem->ark_tstop)*ark_mem->ark_h > ZERO) 
+      ark_mem->ark_tn = ark_mem->ark_tstop;
+  }
+
+  /* update scalar quantities */
+  ark_mem->ark_nst++;
+  ark_mem->ark_hold = ark_mem->ark_h;
+  ark_mem->ark_tnew = ark_mem->ark_tn;
+
+  /* turn off flag regarding resized problem */
+  ark_mem->ark_resized = FALSE;
+
+  /* update error history array */
+  ark_mem->ark_hadapt_ehist[2] = ark_mem->ark_hadapt_ehist[1];
+  ark_mem->ark_hadapt_ehist[1] = ark_mem->ark_hadapt_ehist[0];
+  ark_mem->ark_hadapt_ehist[0] = dsm*ark_mem->ark_hadapt_bias;
+
+  /* update step history array */
+  ark_mem->ark_hadapt_hhist[2] = ark_mem->ark_hadapt_hhist[1];
+  ark_mem->ark_hadapt_hhist[1] = ark_mem->ark_hadapt_hhist[0];
+  ark_mem->ark_hadapt_hhist[0] = ark_mem->ark_h;
+
+  /* apply user-supplied step postprocessing function (if supplied) */
+  if (ark_mem->ark_ProcessStep != NULL) {
+    retval = ark_mem->ark_ProcessStep(ark_mem->ark_tn, 
+				      ark_mem->ark_y,
+				      ark_mem->ark_user_data);
+
+    if (retval != 0) return(ARK_POSTPROCESS_FAIL);
+  }
+
+  /* update ycur to current solution */
+  N_VScale(ONE, ark_mem->ark_y, ark_mem->ark_ycur);
+
+  /* swap yold and ynew arrays */
+  tempvec = ark_mem->ark_yold;
+  ark_mem->ark_yold = ark_mem->ark_ynew;
+  ark_mem->ark_ynew = tempvec;
+
+  /* swap fold and fnew arrays */
+  tempvec = ark_mem->ark_fold;
+  ark_mem->ark_fold = ark_mem->ark_fnew;
+  ark_mem->ark_fnew = tempvec;
+
+  /* update fnew array using explicit and implicit RHS:
+     if ce[s-1] = 1.0 and ci[s-1] = 1.0 and no post-processing, use already-computed 
+     RHS values, otherwise compute from scratch */
+  N_VConst(ZERO, ark_mem->ark_fnew);
+  recomputeRHS = FALSE;
+  if (ark_mem->ark_ProcessStep != NULL) 
+    recomputeRHS = TRUE;
+  if ((!ark_mem->ark_implicit) && (SUNRabs(ark_mem->ark_ce[ark_mem->ark_stages-1]-ONE)>TINY))
+    recomputeRHS = TRUE;
+  if ((!ark_mem->ark_explicit) && (SUNRabs(ark_mem->ark_ci[ark_mem->ark_stages-1]-ONE)>TINY))
+    recomputeRHS = TRUE;
+  if (recomputeRHS) {
+    retval = arkFullRHS(ark_mem, ark_mem->ark_tn, ark_mem->ark_y, 
+			ark_mem->ark_ftemp, ark_mem->ark_fnew);
+    if (retval != 0) return(ARK_RHSFUNC_FAIL);
+  } else {
+    if (!ark_mem->ark_explicit) 
+      N_VLinearSum(ONE, ark_mem->ark_Fi[ark_mem->ark_stages-1], 
+		   ONE, ark_mem->ark_fnew, ark_mem->ark_fnew);
+    if (!ark_mem->ark_implicit) 
+      N_VLinearSum(ONE, ark_mem->ark_Fe[ark_mem->ark_stages-1], 
+		   ONE, ark_mem->ark_fnew, ark_mem->ark_fnew);
+  }
+
+  /* if M!=I, update fnew with M^{-1}*fnew (note, mass matrix already current) */
+  if (ark_mem->ark_mass_matrix) {   /* M != I */
+    N_VScale(ark_mem->ark_h, ark_mem->ark_fnew, ark_mem->ark_fnew);      /* scale RHS */
+    retval = ark_mem->ark_msolve(ark_mem, ark_mem->ark_fnew, ark_mem->ark_rwt); 
+    N_VScale(ONE/ark_mem->ark_h, ark_mem->ark_fnew, ark_mem->ark_fnew);  /* scale result */
+    ark_mem->ark_mass_solves++;
+    if (retval != ARK_SUCCESS) {
+      ark_mem->ark_nmassfails++;
+      arkProcessError(ark_mem, ARK_MASSSOLVE_FAIL, "ARKODE", 
+		      "arkCompleteStep", "Mass matrix solver failure");
+      return(ARK_MASSSOLVE_FAIL);
+    }
+  }
+
+  /* update ynew (cannot swap since ark_y is a pointer to user-supplied data) */
+  N_VScale(ONE, ark_mem->ark_y, ark_mem->ark_ynew);
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkPrepareNextStep
+
+ This routine handles the setting of stepsize, hprime, for the 
+ next step.  Along with hprime, it sets the ratio eta=hprime/h.
+ It also updates other state variables related to a change of 
+ step size.
+---------------------------------------------------------------*/
+ static int arkPrepareNextStep(ARKodeMem ark_mem)
+{
+  int retval;
+
+  /* If etamax = 1, or if fixed time-stepping requesetd, defer 
+     step size changes until next step */
+  if ((ark_mem->ark_etamax == ONE) || ark_mem->ark_fixedstep){
+    ark_mem->ark_hprime = ark_mem->ark_h;
+    ark_mem->ark_eta = ONE;
+    return(ARK_SUCCESS);
+  }
+
+  /* Adjust ark_eta in arkAdapt */
+  retval = arkAdapt(ark_mem);
+  
+  /* set hprime value for next step size */
+  ark_mem->ark_hprime = ark_mem->ark_h * ark_mem->ark_eta;
+
+  if (retval != ARK_SUCCESS)  return(ARK_ERR_FAILURE);
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkNls
+
+ This routine attempts to solve the nonlinear system associated
+ with a single implicit step of the linear multistep method.
+ It calls one of arkNlsAccelFP, arkLs or arkNlsNewton to do the 
+ work.
+
+ Upon a successful solve, the solution is held in ark_mem->ark_y.
+---------------------------------------------------------------*/
+static int arkNls(ARKodeMem ark_mem, int nflag)
+{
+
+  /* call the appropriate solver */
+
+  /*   fixed point */
+  if (ark_mem->ark_use_fp)
+    return(arkNlsAccelFP(ark_mem, nflag));
+
+  /*   linearly implicit (one Newton iteration) */
+  if (ark_mem->ark_linear)
+    return(arkLs(ark_mem, nflag));
+  
+  /*   Newton */
+  return(arkNlsNewton(ark_mem, nflag));
+
+}
+
+
+/*---------------------------------------------------------------
+ arkNlsResid
+
+ This routine evaluates the negative nonlinear residual for the 
+ additive Runge-Kutta method.  It assumes that any data from 
+ previous time steps/stages is contained in ark_mem, and merely 
+ combines this old data with the current ODE RHS vector, 
+ fy = f(t,y), to compute the nonlinear residual r.
+
+ At the ith stage, we compute 
+    r = -M*zi + M*yn + h*sum_{j=0}^{i-1} Ae(i,j)*Fe(j) 
+                     + h*sum_{j=0}^{i} Ai(i,j)*Fi(j)
+    r = -M*zi + gamma*Fi(zi) + M*yn + data
+ where
+    zi is stored in y
+    Fi(zi) is stored in fy
+    (M*yn+data) is stored in ark_mem->ark_sdata,
+ so we really just compute
+    r = -M*y + gamma*fy + ark_mem->ark_sdata
+
+ Possible return values:  ARK_SUCCESS  or  ARK_RHSFUNC_FAIL
+---------------------------------------------------------------*/
+static int arkNlsResid(ARKodeMem ark_mem, N_Vector y, 
+		       N_Vector fy, N_Vector r)
+{
+
+  /* temporary variables */
+  int retval;
+
+  /* put M*y in r */
+  if (ark_mem->ark_mass_matrix) {
+    retval = ark_mem->ark_mtimes(y, r, ark_mem->ark_tn, 
+				 ark_mem->ark_mtimes_data);
+    ark_mem->ark_mass_mult++;
+    if (retval != ARK_SUCCESS)  
+      return (ARK_MASSMULT_FAIL);
+  } else {
+    N_VScale(ONE, y, r);
+  }
+
+  /* update with sdata */
+  N_VLinearSum(-ONE, r, ONE, ark_mem->ark_sdata, r);
+
+  /* update with gamma*fy */
+  N_VLinearSum(ark_mem->ark_gamma, fy, ONE, r, r);
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkNlsNewton
+
+ This routine handles the Newton iteration for implicit portions 
+ of the ARK and DIRK methods. It calls lsetup if indicated, 
+ performs a modified Newton iteration (using a fixed 
+ Jacobian / precond), and retries a failed attempt at Newton 
+ iteration if that is indicated. 
+
+ Upon entry, the predicted solution is held in ark_mem->ark_ycur; 
+ this array is never changed throughout this routine.  If an 
+ initial attempt at solving the nonlinear system fail (e.g. due to 
+ a stale Jacobian), this allows for new attempts that first revert 
+ ark_mem->ark_y back to this initial guess before trying again. 
+
+ Upon a successful solve, the solution is held in ark_mem->ark_y.
+
+ Possible return values:
+
+   ARK_SUCCESS       ---> continue with error test
+
+   ARK_RHSFUNC_FAIL  -+  
+   ARK_LSETUP_FAIL    |-> halt the integration 
+   ARK_LSOLVE_FAIL   -+
+
+   CONV_FAIL        -+
+   RHSFUNC_RECVR    -+-> predict again or stop if too many
+---------------------------------------------------------------*/
+static int arkNlsNewton(ARKodeMem ark_mem, int nflag)
+{
+  N_Vector vtemp1, vtemp2, vtemp3, b;
+  int convfail, retval, ier, m;
+  booleantype callSetup;
+  realtype del, delp, dcon;
+  
+  vtemp1 = ark_mem->ark_acor;  /* rename acor as vtemp1 for readability  */
+  vtemp2 = ark_mem->ark_y;     /* rename y as vtemp2 for readability     */
+  vtemp3 = ark_mem->ark_tempv; /* rename tempv as vtemp3 for readability */
+  b      = ark_mem->ark_tempv; /* also rename tempv as b for readability */
+
+  /* Set flag convfail, input to lsetup for its evaluation decision */
+  convfail = ((nflag == FIRST_CALL) || (nflag == PREV_ERR_FAIL)) ?
+    ARK_NO_FAILURES : ARK_FAIL_OTHER;
+
+  /* Decide whether or not to call setup routine (if one exists) */
+  if (ark_mem->ark_setupNonNull) {      
+    callSetup = (nflag == PREV_CONV_FAIL) || (nflag == PREV_ERR_FAIL) ||
+      (ark_mem->ark_firststage) || (ark_mem->ark_msbp < 0) ||
+      (ark_mem->ark_nst >= ark_mem->ark_nstlp + abs(ark_mem->ark_msbp)) || 
+      (SUNRabs(ark_mem->ark_gamrat-ONE) > ark_mem->ark_dgmax);
+  } else {  
+    ark_mem->ark_crate = ONE;
+    callSetup = FALSE;
+  }
+  
+  /* Looping point for attempts at solution of the nonlinear system:
+       Evaluate f at predicted y, store result in ark_mem->ark_ftemp.
+       Call lsetup if indicated, setting statistics and gamma factors.
+       Zero out the correction array (ark_mem->ark_acor).
+       Copy the predicted y (ycur) into the output (ark_mem->ark_y).
+       Performs the modified Newton iteration using the existing lsetup.
+       Repeat process if a recoverable failure occurred (convergence
+	  failure with stale Jacobian). */
+  for(;;) {
+
+    if (!ark_mem->ark_explicit) {
+      retval = ark_mem->ark_fi(ark_mem->ark_tn, ark_mem->ark_ycur, 
+			       ark_mem->ark_ftemp, ark_mem->ark_user_data);
+      ark_mem->ark_nfi++; 
+      if (retval < 0) return(ARK_RHSFUNC_FAIL);
+      if (retval > 0) return(RHSFUNC_RECVR);
+    }
+    
+    if (callSetup) {
+
+      /* Solver diagnostics reporting */
+      if (ark_mem->ark_report)  fprintf(ark_mem->ark_diagfp, "  lsetup\n");
+
+      ier = ark_mem->ark_lsetup(ark_mem, convfail, ark_mem->ark_ycur, 
+				ark_mem->ark_ftemp, &ark_mem->ark_jcur, 
+				vtemp1, vtemp2, vtemp3);
+      ark_mem->ark_nsetups++;
+      callSetup = FALSE;
+      ark_mem->ark_firststage = FALSE;
+      ark_mem->ark_gamrat = ark_mem->ark_crate = ONE; 
+      ark_mem->ark_gammap = ark_mem->ark_gamma;
+      ark_mem->ark_nstlp  = ark_mem->ark_nst;
+
+      /* Return if lsetup failed */
+      if (ier < 0) return(ARK_LSETUP_FAIL);
+      if (ier > 0) return(CONV_FAIL);
+    }
+
+    /* Set acor to zero and load prediction into y vector */
+    N_VConst(ZERO, ark_mem->ark_acor);
+    N_VScale(ONE, ark_mem->ark_ycur, ark_mem->ark_y);
+
+
+    /***********************************
+     Do the modified Newton iteration:
+     - Reuses a single call to ark_mem->ark_lsetup (called by the enclosing loop). 
+     - Upon entry, the predicted solution is held in ark_mem->ark_ycur.
+     - Here, ark_mem->ark_acor accumulates the difference between the predictor 
+       and the final solution to the time step.
+     - Upon a successful solve, the solution is held in ark_mem->ark_y. 
+    */
+
+    /* Initialize temporary variables for use in iteration */
+    ark_mem->ark_mnewt = m = 0;
+    del = delp = ZERO;
+
+    /* Reset the stored residual norm (for iterative linear solvers) */
+    ark_mem->ark_eRNrm = RCONST(0.1) * ark_mem->ark_nlscoef;
+
+    /* Looping point for Newton iteration */
+    for(;;) {
+
+      /* Evaluate the nonlinear system residual, put result into b */
+      retval = arkNlsResid(ark_mem, ark_mem->ark_acor, 
+			   ark_mem->ark_ftemp, b);
+      if (retval != ARK_SUCCESS) {
+	ier = ARK_RHSFUNC_FAIL;
+	break;
+      }
+
+      /* Call the lsolve function */
+      retval = ark_mem->ark_lsolve(ark_mem, b, ark_mem->ark_rwt, 
+				   ark_mem->ark_y, ark_mem->ark_ftemp); 
+      ark_mem->ark_nni++;
+    
+      if (retval < 0) {
+	ier = ARK_LSOLVE_FAIL;
+	break;
+      }
+    
+      /* If lsolve had a recoverable failure and Jacobian data is
+	 not current, signal to try the solution again */
+      if (retval > 0) { 
+	if ((!ark_mem->ark_jcur) && (ark_mem->ark_setupNonNull)) 
+	  ier = TRY_AGAIN;
+	else 
+	  ier = CONV_FAIL;
+	break;
+      }
+
+      /* Get WRMS norm of correction; add correction to acor and y */
+      del = N_VWrmsNorm(b, ark_mem->ark_ewt);
+      N_VLinearSum(ONE, ark_mem->ark_acor, ONE, b, ark_mem->ark_acor);
+      N_VLinearSum(ONE, ark_mem->ark_ycur, ONE, ark_mem->ark_acor, ark_mem->ark_y);
+
+      /* Compute the nonlinear error estimate.  If m > 0, an estimate of the convergence
+	 rate constant is stored in crate, and used in the subsequent estimates */
+      if (m > 0) 
+	ark_mem->ark_crate = SUNMAX(ark_mem->ark_crdown*ark_mem->ark_crate, del/delp);
+      dcon = SUNMIN(ark_mem->ark_crate, ONE) * del / ark_mem->ark_nlscoef;
+
+      /* compute the forcing term for linear solver tolerance */
+      ark_mem->ark_eRNrm = SUNMIN(ark_mem->ark_crate, ONE) * del
+	                 * RCONST(0.1) * ark_mem->ark_nlscoef;
+#ifdef FIXED_LIN_TOL
+      /* reset if a fixed linear solver tolerance is desired */
+      ark_mem->ark_eRNrm = RCONST(0.1) * ark_mem->ark_nlscoef;
+#endif
+
+#ifdef DEBUG_OUTPUT
+ printf("Newton iter %i,  del = %19.16g,  crate = %19.16g\n", m, del, ark_mem->ark_crate);
+ printf("   dcon = %19.16g\n", dcon);
+ printf("Newton correction:\n");
+ N_VPrint_Serial(ark_mem->ark_acor);
+#endif
+
+      /* Solver diagnostics reporting */
+      if (ark_mem->ark_report) 
+	fprintf(ark_mem->ark_diagfp, "    newt  %i  %19.16g  %19.16g\n", m, del, dcon);
+    
+      if (dcon <= ONE) {
+	ark_mem->ark_jcur = FALSE;
+	ier = ARK_SUCCESS;
+	break;
+      }
+
+      /* update Newton iteration counter */
+      ark_mem->ark_mnewt = ++m;
+    
+      /* Stop at maxcor iterations or if iteration seems to be diverging.
+	 If still not converged and Jacobian data is not current, signal 
+	 to try the solution again */
+      if ((m == ark_mem->ark_maxcor) || 
+	  ((m >= 2) && (del > ark_mem->ark_rdiv*delp))) {
+	if ((!ark_mem->ark_jcur) && (ark_mem->ark_setupNonNull)) 
+	  ier = TRY_AGAIN;
+	else
+	  ier = CONV_FAIL;
+	break;
+      }
+    
+      /* Save norm of correction, evaluate fi, and loop again */
+      delp = del;
+      if (!ark_mem->ark_explicit) {
+	retval = ark_mem->ark_fi(ark_mem->ark_tn, ark_mem->ark_y, 
+				 ark_mem->ark_ftemp, ark_mem->ark_user_data);
+	ark_mem->ark_nfi++;
+	if (retval < 0) {
+	  ier = ARK_RHSFUNC_FAIL;
+	  break;
+	}
+	if (retval > 0) {
+	  if ((!ark_mem->ark_jcur) && (ark_mem->ark_setupNonNull)) 
+	    ier = TRY_AGAIN;
+	  else
+	    ier = RHSFUNC_RECVR;
+	  break;
+	}
+      }
+    } 
+    /* end modified Newton iteration */
+    /*********************************/
+    
+    /* If there is a convergence failure and the Jacobian-related 
+       data appears not to be current, loop again with a call to lsetup
+       in which convfail=ARK_FAIL_BAD_J.  Otherwise return. */
+    if (ier != TRY_AGAIN) return(ier);
+    
+    callSetup = TRUE;
+    convfail = ARK_FAIL_BAD_J;
+  }
+}
+
+
+/*---------------------------------------------------------------
+ arkNlsAccelFP
+
+ This routine handles the Anderson-accelerated fixed-point 
+ iteration for implicit portions of the ARK and DIRK methods. It 
+ performs an accelerated fixed-point iteration (without need for 
+ a Jacobian or preconditioner. 
+
+ Upon entry, the predicted solution is held in ark_mem->ark_ycur.
+
+ Upon a successful solve, the solution is held in ark_mem->ark_y.
+
+ Possible return values:
+
+   ARK_SUCCESS       ---> continue with error test
+
+   ARK_RHSFUNC_FAIL  ---> halt the integration 
+
+   CONV_FAIL         -+
+   RHSFUNC_RECVR     -+-> predict again or stop if too many
+---------------------------------------------------------------*/
+static int arkNlsAccelFP(ARKodeMem ark_mem, int nflag)
+{
+  /* local variables */
+  int retval;
+  realtype del, delp, dcon;
+
+  /* local shortcut variables */
+  realtype tn     = ark_mem->ark_tn;
+  realtype *R     = ark_mem->ark_fp_R;
+  realtype *gamma = ark_mem->ark_fp_gamma;
+  long int maa    = ark_mem->ark_fp_m;
+  void *udata     = ark_mem->ark_user_data;
+  N_Vector ypred  = ark_mem->ark_acor;
+  N_Vector y      = ark_mem->ark_y;
+  N_Vector ycur   = ark_mem->ark_ycur;
+  N_Vector ftemp  = ark_mem->ark_ftemp;
+  N_Vector fval   = ark_mem->ark_fp_fval;
+  N_Vector tempv  = ark_mem->ark_tempv;
+
+  /* Initialize temporary variables for use in iteration */
+  del = delp = ZERO;
+  ark_mem->ark_crate = ONE;
+
+  /* Initialize iteration counter */
+  ark_mem->ark_mnewt = 0;
+
+  /* Load prediction into y vector, ypred */
+  N_VScale(ONE, ycur, y);
+  N_VScale(ONE, ycur, ypred);
+
+  /* Looping point for attempts at solution of the nonlinear system:
+       Evaluate f at predicted y, store result in ark_mem->ark_ftemp.
+       Performs the accelerated fixed-point iteration.
+       Repeat process if a recoverable failure occurred (convergence
+	  failure with stale Jacobian). */
+  for(;;) {
+
+    /* evaluate implicit ODE RHS function, store in ftemp */
+    if (!ark_mem->ark_explicit) {
+      retval = ark_mem->ark_fi(tn, y, ftemp, udata);
+      ark_mem->ark_nfi++;
+      if (retval < 0) return(ARK_RHSFUNC_FAIL);
+      if (retval > 0) return(RHSFUNC_RECVR);
+    }
+
+    /* store difference between current guess and prediction in tempv */
+    N_VLinearSum(ONE, y, -ONE, ypred, tempv);
+
+    /* evaluate nonlinear residual, store in fval */
+    retval = arkNlsResid(ark_mem, tempv, ftemp, fval);
+    if (retval != ARK_SUCCESS) return(ARK_RHSFUNC_FAIL);
+
+    /* convert nonlinear residual result to a fixed-point function result */
+    N_VLinearSum(ONE, y, ONE, fval, fval);
+
+    /* perform fixed point update */
+    if (maa == 0) {
+      /* plain fixed-point solver, copy residual into y */
+      N_VScale(ONE, fval, y);
+    } else {
+      /* Anderson-accelerated solver */
+      N_VScale(ONE, ycur, y);   /* update guess */
+      retval = arkAndersonAcc(ark_mem, fval, tempv, y,  /* accelerate guess */
+			      ycur, (int)(ark_mem->ark_mnewt), R, gamma);
+    }
+    ark_mem->ark_nni++;
+
+    /* compute the nonlinear error estimate.  If m > 0, an estimate of the convergence
+       rate constant is stored in crate, and used in the subsequent estimates */
+    N_VLinearSum(ONE, y, -ONE, ycur, tempv);
+    del = N_VWrmsNorm(tempv, ark_mem->ark_ewt);
+    if (ark_mem->ark_mnewt > 0)
+      ark_mem->ark_crate = SUNMAX(ark_mem->ark_crdown*ark_mem->ark_crate, del/delp);
+    dcon = SUNMIN(ark_mem->ark_crate, ONE) * del / ark_mem->ark_nlscoef;
+
+#ifdef DEBUG_OUTPUT
+ printf("FP iter %i,  del = %19.16g,  crate = %19.16g\n", ark_mem->ark_mnewt, del, ark_mem->ark_crate);
+ printf("   dcon = %19.16g\n", dcon);
+ printf("Fixed-point correction:\n");
+ N_VPrint_Serial(tempv);
+#endif
+
+    /* Solver diagnostics reporting */
+    if (ark_mem->ark_report)
+      fprintf(ark_mem->ark_diagfp, "    fp  %i  %19.16g  %19.16g\n", ark_mem->ark_mnewt, del, dcon);
+
+    /* update iteration counter */
+    ark_mem->ark_mnewt++;
+
+    if (dcon <= ONE)  return(ARK_SUCCESS);
+
+    /* Stop at maxcor iterations or if iteration seems to be diverging */
+    if ((ark_mem->ark_mnewt == ark_mem->ark_maxcor) ||
+	((ark_mem->ark_mnewt >= 2) && (del > ark_mem->ark_rdiv*delp))) 
+      return(CONV_FAIL);
+
+    /* Update current solution guess */
+    N_VScale(ONE, y, ycur);
+    
+    /* Save norm of correction and loop again */
+    delp = del;
+
+  }
+}
+
+
+/*---------------------------------------------------------------
+ arkAndersonAcc
+
+ This routine computes the Anderson-accelerated fixed point 
+ iterate itself, as used by the nonlinear solver arkNlsAccelFP().  
+
+ Upon entry, the predicted solution is held in xold;
+ this array is never changed throughout this routine.  
+
+ The result of the routine is held in x.  
+
+ Possible return values:
+   ARK_SUCCESS   ---> successful completion
+
+---------------------------------------------------------------*/
+static int arkAndersonAcc(ARKodeMem ark_mem, N_Vector gval, 
+			  N_Vector fv, N_Vector x, N_Vector xold, 
+			  int iter, realtype *R, realtype *gamma)
+{
+  /* local variables */
+  long int i_pt, i, j, lAA;
+  realtype alfa, a, b, temp, c, s;
+
+  /* local shortcut variables */
+  N_Vector vtemp2 = ark_mem->ark_y;       /* rename y as vtemp2 for readability */
+  long int *ipt_map = ark_mem->ark_fp_imap;
+  long int maa = ark_mem->ark_fp_m;
+  N_Vector gold = ark_mem->ark_fp_gold;
+  N_Vector fold = ark_mem->ark_fp_fold;
+  N_Vector *df = ark_mem->ark_fp_df;
+  N_Vector *dg = ark_mem->ark_fp_dg;
+  N_Vector *Q = ark_mem->ark_fp_q;
+  
+  for (i=0; i<maa; i++)  ipt_map[i]=0;
+  i_pt = iter-1 - ((iter-1)/maa)*maa;
+  N_VLinearSum(ONE, gval, -ONE, xold, fv);
+  if (iter > 0) {
+    /* compute dg_new = gval - gval_old*/
+    N_VLinearSum(ONE, gval, -ONE, gold, dg[i_pt]);
+    /* compute df_new = fval - fval_old */
+    N_VLinearSum(ONE, fv, -ONE, fold, df[i_pt]);
+  }
+    
+  N_VScale(ONE, gval, gold);
+  N_VScale(ONE, fv, fold);
+  
+  if (iter == 0) {
+    N_VScale(ONE, gval, x);
+  } else {
+    if (iter == 1) {
+      R[0] = SUNRsqrt(N_VDotProd(df[i_pt], df[i_pt])); 
+      alfa = ONE/R[0];
+      N_VScale(alfa, df[i_pt], Q[i_pt]);
+      ipt_map[0] = 0;
+    } else if (iter <= maa) {
+      N_VScale(ONE, df[i_pt], vtemp2);
+      for (j=0; j<(iter-1); j++) {
+	ipt_map[j] = j;
+	R[(iter-1)*maa+j] = N_VDotProd(Q[j], vtemp2);
+	N_VLinearSum(ONE, vtemp2, -R[(iter-1)*maa+j], Q[j], vtemp2);
+      }
+      R[(iter-1)*maa+iter-1] = SUNRsqrt(N_VDotProd(vtemp2, vtemp2)); 
+      if (R[(iter-1)*maa+iter-1] == ZERO) {
+	N_VScale(ZERO, vtemp2, Q[i_pt]);
+      } else {
+	N_VScale((ONE/R[(iter-1)*maa+iter-1]), vtemp2, Q[i_pt]);
+      }
+      ipt_map[iter-1] = iter-1;
+    } else {
+      /* Delete left-most column vector from QR factorization */
+      for (i=0; i < maa-1; i++) {
+        a = R[(i+1)*maa + i];
+        b = R[(i+1)*maa + i+1];
+        temp = SUNRsqrt(a*a + b*b);
+        c = a / temp;
+        s = b / temp;
+        R[(i+1)*maa + i] = temp;
+        R[(i+1)*maa + i+1] = 0.0;      
+	/* OK to re-use temp */
+        if (i < maa-1) {
+          for (j = i+2; j < maa; j++) {
+            a = R[j*maa + i];
+            b = R[j*maa + i+1];
+            temp = c * a + s * b;
+            R[j*maa + i+1] = -s*a + c*b;
+            R[j*maa + i] = temp;
+	  }
+	}
+        N_VLinearSum(c, Q[i], s, Q[i+1], vtemp2);
+        N_VLinearSum(-s, Q[i], c, Q[i+1], Q[i+1]);
+        N_VScale(ONE, vtemp2, Q[i]);
+      }
+
+      /* Shift R to the left by one. */
+      for (i = 1; i < maa; i++) {
+        for (j = 0; j < maa-1; j++) {
+          R[(i-1)*maa + j] = R[i*maa + j];
+        }
+      }
+
+      /* Add the new df vector */
+      N_VScale(ONE,df[i_pt],vtemp2);
+      for (j=0; j < (maa-1); j++) {
+        R[(maa-1)*maa+j] = N_VDotProd(Q[j],vtemp2);
+        N_VLinearSum(ONE,vtemp2,-R[(maa-1)*maa+j],Q[j],vtemp2);
+      }
+      R[(maa-1)*maa+maa-1] = SUNRsqrt(N_VDotProd(vtemp2,vtemp2));
+      N_VScale((1/R[(maa-1)*maa+maa-1]),vtemp2,Q[maa-1]);
+
+      /* Update the iteration map */
+      j = 0;
+      for (i=i_pt+1; i<maa; i++)
+	ipt_map[j++] = i;
+      for (i=0; i<(i_pt+1); i++)
+	ipt_map[j++] = i;
+    }
+
+    /* Solve least squares problem and update solution */
+    lAA = iter;
+    if (maa < iter)  lAA = maa;
+    N_VScale(ONE, gval, x);
+    for (i=0; i<lAA; i++)
+      gamma[i] = N_VDotProd(fv, Q[i]);
+    for (i=lAA-1; i>-1; i--) {
+      for (j=i+1; j<lAA; j++) 
+	gamma[i] = gamma[i] - R[j*maa+i]*gamma[j]; 
+      if (gamma[i] == ZERO) {
+	gamma[i] = ZERO;
+      } else {
+	gamma[i] = gamma[i]/R[i*maa+i];
+      }
+      N_VLinearSum(ONE, x, -gamma[i], dg[ipt_map[i]], x);
+    }
+  }
+
+  return 0;
+}
+
+/*---------------------------------------------------------------
+ arkLs
+
+ This routine attempts to solve the linear system associated
+ with a single implicit step of the ARK method.  This should 
+ only be called if the user has specified that the implicit 
+ problem is linear.  In this routine, we assume that the problem 
+ depends linearly on the solution.  Additionally, if the Jacobian
+ is not time dependent we only call lsetup on changes to gamma; 
+ otherwise we call lsetup at every call.  In all cases, we then 
+ call the user-specified linear solver (with a tight tolerance) 
+ to compute the time-evolved solution.  
+
+ Upon entry, the predicted solution is held in ark_mem->ark_ycur.
+
+ Upon a successful solve, the solution is held in ark_mem->ark_y.
+
+ Possible return values:
+
+   ARK_SUCCESS       ---> continue with error test
+
+   ARK_RHSFUNC_FAIL  -+  
+   ARK_LSETUP_FAIL    |-> halt the integration 
+   ARK_LSOLVE_FAIL   -+
+
+   RHSFUNC_RECVR     --> predict again or stop if too many
+---------------------------------------------------------------*/
+static int arkLs(ARKodeMem ark_mem, int nflag)
+{
+  N_Vector vtemp1, vtemp2, vtemp3, b;
+  int convfail, retval, ier;
+  booleantype callSetup;
+  realtype del;
+  
+  vtemp1 = ark_mem->ark_acor;  /* rename acor as vtemp1 for readability  */
+  vtemp2 = ark_mem->ark_y;     /* rename y as vtemp2 for readability     */
+  vtemp3 = ark_mem->ark_tempv; /* rename tempv as vtemp3 for readability */
+  b      = ark_mem->ark_tempv; /* also rename tempv as b for readability */
+
+  /* Set flag convfail, input to lsetup for its evaluation decision */
+  convfail = (nflag == FIRST_CALL) ? ARK_NO_FAILURES : ARK_FAIL_OTHER;
+
+  /* Decide whether or not to call setup routine (if one exists) */
+  if (ark_mem->ark_setupNonNull) {      
+    callSetup = (ark_mem->ark_firststage) || 
+      (ark_mem->ark_linear_timedep) || (ark_mem->ark_msbp < 0) ||
+      (SUNRabs(ark_mem->ark_gamrat-ONE) > ark_mem->ark_dgmax);
+  } else {  
+    callSetup = FALSE;
+  }
+  
+  /* update implicit RHS, store in ark_mem->ark_ftemp */
+  if (!ark_mem->ark_explicit) {
+    retval = ark_mem->ark_fi(ark_mem->ark_tn, ark_mem->ark_ycur, 
+			     ark_mem->ark_ftemp, ark_mem->ark_user_data);
+    ark_mem->ark_nfi++; 
+    if (retval < 0) return(ARK_RHSFUNC_FAIL);
+    if (retval > 0) return(RHSFUNC_RECVR);
+  }
+  
+  /* update system matrix if necessary */
+  if (callSetup) {
+
+    /* Solver diagnostics reporting */
+    if (ark_mem->ark_report)  fprintf(ark_mem->ark_diagfp, "  lsetup\n");
+
+    ier = ark_mem->ark_lsetup(ark_mem, convfail, ark_mem->ark_ycur, 
+			      ark_mem->ark_ftemp, &ark_mem->ark_jcur, 
+			      vtemp1, vtemp2, vtemp3);
+    ark_mem->ark_nsetups++;
+    callSetup = FALSE;
+    ark_mem->ark_firststage = FALSE;
+    ark_mem->ark_gamrat = ark_mem->ark_crate = ONE; 
+    ark_mem->ark_gammap = ark_mem->ark_gamma;
+    ark_mem->ark_nstlp  = ark_mem->ark_nst;
+
+    /* Return if lsetup failed */
+    if (ier < 0) return(ARK_LSETUP_FAIL);
+    if (ier > 0) return(CONV_FAIL);
+  }
+
+  /* Set acor to zero and load prediction into y vector */
+  N_VConst(ZERO, ark_mem->ark_acor);
+  N_VScale(ONE, ark_mem->ark_ycur, ark_mem->ark_y);
+  
+
+  /* Do a single Newton iteration */
+
+  /*   Initialize temporary variables for use in iteration */
+  ark_mem->ark_mnewt = 0;
+  del = ZERO;
+
+  /*   Set the stored residual norm to force an "accurate" initial linear solve */
+  ark_mem->ark_eRNrm = RCONST(0.1) * ark_mem->ark_nlscoef;
+
+  /*   Evaluate the nonlinear system residual, put result into b */
+  retval = arkNlsResid(ark_mem, ark_mem->ark_acor, ark_mem->ark_ftemp, b);
+  if (retval != ARK_SUCCESS)  return (ARK_RHSFUNC_FAIL);
+
+  /*   Call the lsolve function */
+  retval = ark_mem->ark_lsolve(ark_mem, b, ark_mem->ark_rwt, 
+			       ark_mem->ark_y, ark_mem->ark_ftemp); 
+  ark_mem->ark_nni++;
+  if (retval != 0)  return (ARK_LSOLVE_FAIL);
+    
+  /*   Get WRMS norm of correction; add correction to acor and y */
+  del = N_VWrmsNorm(b, ark_mem->ark_ewt);
+  N_VLinearSum(ONE, ark_mem->ark_acor, ONE, b, ark_mem->ark_acor);
+  N_VLinearSum(ONE, ark_mem->ark_ycur, ONE, ark_mem->ark_acor, ark_mem->ark_y);
+
+  /*   Solver diagnostics reporting */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "    newt  %i  %19.16g  %19.16g\n", 0, del, 0.0);
+
+  /* clean up and return */ 
+  ark_mem->ark_jcur = FALSE;
+  return (ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkHandleNFlag
+
+ This routine takes action on the return value nflag = *nflagPtr
+ returned by arkNls, as follows:
+
+ If arkNls succeeded in solving the nonlinear system, then
+ arkHandleNFlag returns the constant SOLVE_SUCCESS, which tells 
+ arkStep it is safe to continue with other stage solves, or to 
+ perform the error test.
+
+ If the nonlinear system was not solved successfully, then ncfn and
+ ncf = *ncfPtr are incremented.
+
+ If the solution of the nonlinear system failed due to an
+ unrecoverable failure by setup, we return the value ARK_LSETUP_FAIL.
+ 
+ If it failed due to an unrecoverable failure in solve, then we return
+ the value ARK_LSOLVE_FAIL.
+
+ If it failed due to an unrecoverable failure in rhs, then we return
+ the value ARK_RHSFUNC_FAIL.
+
+ Otherwise, a recoverable failure occurred when solving the 
+ nonlinear system (arkNls returned nflag == CONV_FAIL or RHSFUNC_RECVR). 
+ In this case, if using fixed time step sizes, or if ncf is now equal 
+ to maxncf, or if |h| = hmin, then we return the value ARK_CONV_FAILURE 
+ (if nflag=CONV_FAIL) or ARK_REPTD_RHSFUNC_ERR (if nflag=RHSFUNC_RECVR).
+ If not, we set *nflagPtr = PREV_CONV_FAIL and return the value
+ PREDICT_AGAIN, telling arkStep to reattempt the step.
+---------------------------------------------------------------*/
+static int arkHandleNFlag(ARKodeMem ark_mem, int *nflagPtr, 
+			  realtype saved_t, int *ncfPtr)
+{
+  int nflag;
+  
+  nflag = *nflagPtr;
+  
+  if (nflag == ARK_SUCCESS) return(SOLVE_SUCCESS);
+
+  /* The nonlinear soln. failed; increment ncfn */
+  ark_mem->ark_ncfn++;
+  
+  /* If fixed time stepping, then return with convergence failure */
+  if (ark_mem->ark_fixedstep)    return(ARK_CONV_FAILURE);
+
+  /* Restore the previous step time, tn */
+  ark_mem->ark_tn = saved_t;
+  
+  /* Return if lsetup, lsolve, or rhs failed unrecoverably */
+  if (nflag == ARK_LSETUP_FAIL)  return(ARK_LSETUP_FAIL);
+  if (nflag == ARK_LSOLVE_FAIL)  return(ARK_LSOLVE_FAIL);
+  if (nflag == ARK_RHSFUNC_FAIL) return(ARK_RHSFUNC_FAIL);
+  
+  /* At this point, nflag = CONV_FAIL or RHSFUNC_RECVR; increment ncf */
+  (*ncfPtr)++;
+  ark_mem->ark_etamax = ONE;
+
+  /* If we had maxncf failures or |h| = hmin, 
+     return ARK_CONV_FAILURE or ARK_REPTD_RHSFUNC_ERR. */
+  if ((SUNRabs(ark_mem->ark_h) <= ark_mem->ark_hmin*ONEPSM) ||
+      (*ncfPtr == ark_mem->ark_maxncf)) {
+    if (nflag == CONV_FAIL)     return(ARK_CONV_FAILURE);
+    if (nflag == RHSFUNC_RECVR) return(ARK_REPTD_RHSFUNC_ERR);    
+  }
+
+  /* Reduce step size; return to reattempt the step */
+  ark_mem->ark_eta = SUNMAX(ark_mem->ark_etacf,
+			 ark_mem->ark_hmin / SUNRabs(ark_mem->ark_h));
+  ark_mem->ark_h *= ark_mem->ark_eta;
+  ark_mem->ark_next_h = ark_mem->ark_h;
+  *nflagPtr = PREV_CONV_FAIL;
+
+
+  return(PREDICT_AGAIN);
+}
+
+
+/*---------------------------------------------------------------
+ arkHandleFailure
+
+ This routine prints error messages for all cases of failure by
+ arkHin and arkStep. It returns to ARKode the value that ARKode is 
+ to return to the user.
+---------------------------------------------------------------*/
+static int arkHandleFailure(ARKodeMem ark_mem, int flag)
+{
+
+  /* Depending on flag, print error message and return error flag */
+  switch (flag) {
+  case ARK_ERR_FAILURE: 
+    arkProcessError(ark_mem, ARK_ERR_FAILURE, "ARKODE", "ARKode", 
+		    MSGARK_ERR_FAILS, ark_mem->ark_tn, ark_mem->ark_h);
+    break;
+  case ARK_CONV_FAILURE:
+    arkProcessError(ark_mem, ARK_CONV_FAILURE, "ARKODE", "ARKode", 
+		    MSGARK_CONV_FAILS, ark_mem->ark_tn, ark_mem->ark_h);
+    break;
+  case ARK_LSETUP_FAIL:
+    arkProcessError(ark_mem, ARK_LSETUP_FAIL, "ARKODE", "ARKode", 
+		    MSGARK_SETUP_FAILED, ark_mem->ark_tn);
+    break;
+  case ARK_LSOLVE_FAIL:
+    arkProcessError(ark_mem, ARK_LSOLVE_FAIL, "ARKODE", "ARKode", 
+		    MSGARK_SOLVE_FAILED, ark_mem->ark_tn);
+    break;
+  case ARK_RHSFUNC_FAIL:
+    arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, "ARKODE", "ARKode", 
+		    MSGARK_RHSFUNC_FAILED, ark_mem->ark_tn);
+    break;
+  case ARK_UNREC_RHSFUNC_ERR:
+    arkProcessError(ark_mem, ARK_UNREC_RHSFUNC_ERR, "ARKODE", "ARKode", 
+		    MSGARK_RHSFUNC_UNREC, ark_mem->ark_tn);
+    break;
+  case ARK_REPTD_RHSFUNC_ERR:
+    arkProcessError(ark_mem, ARK_REPTD_RHSFUNC_ERR, "ARKODE", "ARKode", 
+		    MSGARK_RHSFUNC_REPTD, ark_mem->ark_tn);
+    break;
+  case ARK_RTFUNC_FAIL:    
+    arkProcessError(ark_mem, ARK_RTFUNC_FAIL, "ARKODE", "ARKode", 
+		    MSGARK_RTFUNC_FAILED, ark_mem->ark_tn);
+    break;
+  case ARK_TOO_CLOSE:
+    arkProcessError(ark_mem, ARK_TOO_CLOSE, "ARKODE", "ARKode", 
+		    MSGARK_TOO_CLOSE);
+    break;
+  case ARK_MASSSOLVE_FAIL:
+    arkProcessError(ark_mem, ARK_MASSSOLVE_FAIL, "ARKODE", "ARKode", 
+		    MSGARK_MASSSOLVE_FAIL);
+    break;
+  default:
+    return(ARK_SUCCESS);   
+  }
+
+  return(flag);
+}
+
+
+/*---------------------------------------------------------------
+ arkDenseEval
+
+ This routine evaluates the dense output formula for the method,
+ using a cubic Hermite interpolating formula with the data 
+ {yn,yp,fn,fp}, where yn,yp are the stored solution values and 
+ fn,fp are the sotred RHS function values at the endpoints of the
+ last successful time step [tn,tp].  If greater polynomial order 
+ than 3 is requested (and the method order allows it, then we 
+ can bootstrap up to a 5th-order accurate interpolant.  For lower 
+ order interpolants than cubic, we use {yn,yp,fp} for 
+ quadratic, {yn,yp} for linear, and {0.5*(yn+yp)} for constant.
+ 
+ Derivatives have reduced accuracy than the dense output function
+ itself, losing one order per derivative.  We will provide 
+ derivatives up to d = min(5,q).
+
+ The input 'tau' specifies the time at which to return derivative
+ information, the formula is 
+    t = tn + tau*h,
+ where h = tp-tn, i.e. values 0<tau<1 provide interpolation, 
+ other values result in extrapolation.
+---------------------------------------------------------------*/
+static int arkDenseEval(ARKodeMem ark_mem, realtype tau, 
+			int d, int order, N_Vector yout)
+{
+  /* local variables */
+  int q;
+  realtype h, a0, a1, a2, a3, tau2, tau3;
+  h = ark_mem->ark_hold;
+  tau2 = tau*tau;
+  tau3 = tau*tau2;
+
+  /* determine polynomial order q */
+  q = SUNMIN(order, ark_mem->ark_dense_q);   /* respect Set routine  */
+  q = SUNMIN(q, ark_mem->ark_q);             /* respect method order */
+  q = SUNMAX(q, 0);                          /* respect lower bound  */
+  q = SUNMIN(q, 3);                          /* respect max possible */
+
+  /* check that d is possible */
+  /* if ((d > SUNMIN(5,q)) || (d < 0)) { */
+  if ((d > SUNMIN(3,q)) || (d < 0)) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "arkDenseEval", "Requested illegal derivative.");
+    return (ARK_ILL_INPUT);
+  }
+
+  /* build polynomial based on order */
+  switch (q) {
+
+  case(0):    /* constant interpolant, yout = 0.5*(yn+yp) */
+    N_VLinearSum(HALF, ark_mem->ark_yold, HALF, ark_mem->ark_ynew, yout);
+    break;
+
+  case(1):    /* linear interpolant */
+    if (d == 0) {
+      a0 = -tau;
+      a1 = ONE+tau;
+    } else {  /* d=1 */
+      a0 = -ONE/h;
+      a1 =  ONE/h;
+    }
+    N_VLinearSum(a0, ark_mem->ark_yold, a1, ark_mem->ark_ynew, yout);
+    break;
+
+  case(2):    /* quadratic interpolant */
+    if (d == 0) {
+      a0 = tau2;
+      a1 = ONE -tau2;
+      a2 = h*(tau2 + tau);
+    } else if (d == 1) {
+      a0 = TWO*tau/h;
+      a1 = -TWO*tau/h;
+      a2 = (ONE + TWO*tau);
+    } else {  /* d == 2 */
+      a0 = TWO/h/h;
+      a1 = -TWO/h/h;
+      a2 = TWO/h;
+    }
+    N_VLinearSum(a0, ark_mem->ark_yold, a1, ark_mem->ark_ynew, yout);
+    N_VLinearSum(a2, ark_mem->ark_fnew, ONE, yout, yout);
+    break;
+
+  case(3):    /* cubic interpolant */
+    if (d == 0) {
+      a0 = THREE*tau2 + TWO*tau3;
+      a1 = ONE - THREE*tau2 - TWO*tau3;
+      a2 = h*(tau2 + tau3);
+      a3 = h*(tau + TWO*tau2 + tau3);
+    } else if (d == 1) {
+      a0 = (SIX*tau + SIX*tau2)/h;
+      a1 = -(SIX*tau + SIX*tau2)/h;
+      a2 = TWO*tau + THREE*tau2;
+      a3 = ONE + FOUR*tau + THREE*tau2;
+    } else if (d == 2) {
+      a0 = (SIX + TWELVE*tau)/h/h;
+      a1 = -(SIX + TWELVE*tau)/h/h;
+      a2 = (TWO + SIX*tau)/h;
+      a3 = (FOUR + SIX*tau)/h;
+    } else {  /* d == 3 */
+      a0 = TWELVE/h/h/h;
+      a1 = -TWELVE/h/h/h;
+      a2 = SIX/h/h;
+      a3 = SIX/h/h;
+    }
+    N_VLinearSum(a0, ark_mem->ark_yold, a1, ark_mem->ark_ynew, yout);
+    N_VLinearSum(a2, ark_mem->ark_fold, ONE, yout, yout);
+    N_VLinearSum(a3, ark_mem->ark_fnew, ONE, yout, yout);
+    break;
+
+  default:
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkDenseEval", 
+		    "Illegal polynomial order.");
+    return (ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkFullRHS
+
+ This routine computes the full ODE RHS [fe(t,y) + fi(t,y)].  If
+ a non-identity mass matrix is defined for the problem, it fills
+ the return array with M^{-1}*[fe(t,y) + fi(t,y)]
+
+ Inputs (unchanged): ark_mem, t, y
+ Output: f
+ Temporary: tmp
+---------------------------------------------------------------*/
+static int arkFullRHS(ARKodeMem ark_mem, realtype t, 
+		      N_Vector y, N_Vector tmp, N_Vector f)
+{
+  int retval;
+
+  /* if the problem involves a non-identity mass matrix and setup is
+     required, do so here (use f, tmp and ark_sdata as a temporaries) */
+  if (ark_mem->ark_mass_matrix && ark_mem->ark_MassSetupNonNull) {
+    retval = ark_mem->ark_msetup(ark_mem, f, tmp, ark_mem->ark_sdata);
+    if (retval != ARK_SUCCESS)  return(ARK_MASSSETUP_FAIL);
+  }
+
+
+  /* explicit problem -- only call fe */
+  if (ark_mem->ark_explicit) {
+
+    retval = ark_mem->ark_fe(t, y, f, ark_mem->ark_user_data);
+    ark_mem->ark_nfe++;
+    if (retval != 0) {
+      arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, "ARKODE", "arkFullRHS", 
+		      MSGARK_RHSFUNC_FAILED, ark_mem->ark_tn);
+      return(ARK_RHSFUNC_FAIL);
+    }
+
+
+  /* implicit problem -- only call fi */
+  } else if (ark_mem->ark_implicit) {
+
+    retval = ark_mem->ark_fi(t, y, f, ark_mem->ark_user_data);
+    ark_mem->ark_nfi++;
+    if (retval != 0) {
+      arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, "ARKODE", 
+		      "arkFullRHS", MSGARK_RHSFUNC_FAILED, ark_mem->ark_tn);
+      return(ARK_RHSFUNC_FAIL);
+    }
+
+
+  /* imex problem */
+  } else {
+    
+    /* explicit portion */
+    retval = ark_mem->ark_fe(t, y, f, ark_mem->ark_user_data);
+    ark_mem->ark_nfe++;
+    if (retval != 0) {
+      arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, "ARKODE", "arkFullRHS", 
+		      MSGARK_RHSFUNC_FAILED, ark_mem->ark_tn);
+      return(ARK_RHSFUNC_FAIL);
+    }
+
+    /* implicit portion */
+    retval = ark_mem->ark_fi(t, y, tmp, ark_mem->ark_user_data);
+    ark_mem->ark_nfi++;
+    if (retval != 0) {
+      arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, "ARKODE", 
+		      "arkFullRHS", MSGARK_RHSFUNC_FAILED, ark_mem->ark_tn);
+      return(ARK_RHSFUNC_FAIL);
+    }
+    N_VLinearSum(ONE, tmp, ONE, f, f);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkEwtSetSS
+
+ This routine sets ewt as decribed above in the case tol_type = ARK_SS.
+ It tests for non-positive components before inverting. arkEwtSetSS
+ returns 0 if ewt is successfully set to a positive vector
+ and -1 otherwise. In the latter case, ewt is considered undefined.
+---------------------------------------------------------------*/
+static int arkEwtSetSS(ARKodeMem ark_mem, N_Vector ycur, N_Vector weight)
+{
+  N_VAbs(ycur, ark_mem->ark_tempv);
+  N_VScale(ark_mem->ark_reltol, ark_mem->ark_tempv, ark_mem->ark_tempv);
+  N_VAddConst(ark_mem->ark_tempv, ark_mem->ark_Sabstol, ark_mem->ark_tempv);
+  if (N_VMin(ark_mem->ark_tempv) <= ZERO) return(-1);
+  N_VInv(ark_mem->ark_tempv, weight);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkEwtSetSV
+
+ This routine sets ewt as decribed above in the case tol_type = ARK_SV.
+ It tests for non-positive components before inverting. arkEwtSetSV
+ returns 0 if ewt is successfully set to a positive vector
+ and -1 otherwise. In the latter case, ewt is considered undefined.
+---------------------------------------------------------------*/
+static int arkEwtSetSV(ARKodeMem ark_mem, N_Vector ycur, N_Vector weight)
+{
+  N_VAbs(ycur, ark_mem->ark_tempv);
+  N_VLinearSum(ark_mem->ark_reltol, ark_mem->ark_tempv, ONE, 
+	       ark_mem->ark_Vabstol, ark_mem->ark_tempv);
+  if (N_VMin(ark_mem->ark_tempv) <= ZERO) return(-1);
+  N_VInv(ark_mem->ark_tempv, weight);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkRwtSetSS
+
+ This routine sets rwt as decribed above in the case tol_type = ARK_SS.
+ It tests for non-positive components before inverting. arkRwtSetSS
+ returns 0 if rwt is successfully set to a positive vector
+ and -1 otherwise. In the latter case, rwt is considered undefined.
+---------------------------------------------------------------*/
+static int arkRwtSetSS(ARKodeMem ark_mem, N_Vector My, N_Vector weight)
+{
+  N_VAbs(My, ark_mem->ark_tempv);
+  N_VScale(ark_mem->ark_reltol, ark_mem->ark_tempv, ark_mem->ark_tempv);
+  N_VAddConst(ark_mem->ark_tempv, ark_mem->ark_SRabstol, ark_mem->ark_tempv);
+  if (N_VMin(ark_mem->ark_tempv) <= ZERO) return(-1);
+  N_VInv(ark_mem->ark_tempv, weight);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkRwtSetSV
+
+ This routine sets rwt as decribed above in the case tol_type = ARK_SV.
+ It tests for non-positive components before inverting. arkRwtSetSV
+ returns 0 if rwt is successfully set to a positive vector
+ and -1 otherwise. In the latter case, rwt is considered undefined.
+---------------------------------------------------------------*/
+static int arkRwtSetSV(ARKodeMem ark_mem, N_Vector My, N_Vector weight)
+{
+  N_VAbs(My, ark_mem->ark_tempv);
+  N_VLinearSum(ark_mem->ark_reltol, ark_mem->ark_tempv, ONE, 
+	       ark_mem->ark_VRabstol, ark_mem->ark_tempv);
+  if (N_VMin(ark_mem->ark_tempv) <= ZERO) return(-1);
+  N_VInv(ark_mem->ark_tempv, weight);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkAdapt is the time step adaptivity wrapper function.  This 
+ should be called after arkCompleteStep, as it depends on the 
+ values updated by that routine.  It computes and sets the value 
+ of ark_eta inside ark_mem.
+---------------------------------------------------------------*/
+static int arkAdapt(ARKodeMem ark_mem)
+{
+  int ier;
+  realtype h_acc, h_cfl, safety, int_dir;
+  safety = ark_mem->ark_hadapt_safety;
+
+  /* Call algorithm-specific error adaptivity method */
+  switch (ark_mem->ark_hadapt_imethod) {
+  case(0):    /* PID controller */
+    ier = arkAdaptPID(ark_mem, &h_acc);
+    break;
+  case(1):    /* PI controller */
+    ier = arkAdaptPI(ark_mem, &h_acc);
+    break;
+  case(2):    /* I controller */
+    ier = arkAdaptI(ark_mem, &h_acc);
+    break;
+  case(3):    /* explicit Gustafsson controller */
+    ier = arkAdaptExpGus(ark_mem, &h_acc);
+    break;
+  case(4):    /* implicit Gustafsson controller */
+    ier = arkAdaptImpGus(ark_mem, &h_acc);
+    break;
+  case(5):    /* imex Gustafsson controller */
+    ier = arkAdaptImExGus(ark_mem, &h_acc);
+    break;
+  case(-1):   /* user-supplied controller */
+    ier = ark_mem->ark_hadapt(ark_mem->ark_ycur,
+			      ark_mem->ark_tn, 
+			      ark_mem->ark_hadapt_hhist[0], 
+			      ark_mem->ark_hadapt_hhist[1], 
+			      ark_mem->ark_hadapt_hhist[2], 
+			      ark_mem->ark_hadapt_ehist[0],
+			      ark_mem->ark_hadapt_ehist[1],
+			      ark_mem->ark_hadapt_ehist[2],
+			      ark_mem->ark_q, ark_mem->ark_p, 
+			      &h_acc, ark_mem->ark_hadapt_data);
+    break;
+  default:
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkAdapt", 
+		    "Illegal adapt_imethod.");
+    return (ARK_ILL_INPUT);
+  }
+  if (ier != ARK_SUCCESS) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkAdapt", 
+		    "Error in accuracy-based adaptivity function.");
+    return (ARK_ILL_INPUT);
+  }
+
+  /* determine direction of integration */
+  int_dir = ark_mem->ark_h / SUNRabs(ark_mem->ark_h);
+
+  /* Call explicit stability function */
+  ier = ark_mem->ark_expstab(ark_mem->ark_ycur, ark_mem->ark_tn,
+			     &h_cfl, ark_mem->ark_estab_data);
+  if (ier != ARK_SUCCESS) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", "arkAdapt", 
+		    "Error in explicit stability function.");
+    return (ARK_ILL_INPUT);
+  }
+  if (h_cfl <= 0.0)  h_cfl = RCONST(1.0e30) * SUNRabs(ark_mem->ark_h);
+
+  /* Solver diagnostics reporting */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "  adapt  %19.16g  %19.16g  %19.16g  %19.16g  %19.16g  %19.16g  %19.16g  %19.16g  ",
+	    ark_mem->ark_hadapt_ehist[0], ark_mem->ark_hadapt_ehist[1], 
+	    ark_mem->ark_hadapt_ehist[2], ark_mem->ark_hadapt_hhist[0], 
+	    ark_mem->ark_hadapt_hhist[1], ark_mem->ark_hadapt_hhist[2], h_acc, h_cfl);
+
+  /* enforce safety factors */
+  h_acc *= safety;
+  h_cfl *= ark_mem->ark_hadapt_cfl * int_dir;
+
+  /* enforce maximum bound on time step growth */
+  h_acc = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(ark_mem->ark_etamax*ark_mem->ark_h));
+
+  /* enforce minimum bound time step reduction */
+  h_acc = int_dir * SUNMAX(SUNRabs(h_acc), SUNRabs(ETAMIN*ark_mem->ark_h));
+
+  /* Solver diagnostics reporting */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "%19.16g  %19.16g  ", h_acc, h_cfl);
+
+  /* increment the relevant step counter, set desired step */
+  if (SUNRabs(h_acc) < SUNRabs(h_cfl))
+    ark_mem->ark_nst_acc++;
+  else
+    ark_mem->ark_nst_exp++;
+  h_acc = int_dir * SUNMIN(SUNRabs(h_acc), SUNRabs(h_cfl));
+
+  /* enforce adaptivity bounds to retain Jacobian/preconditioner accuracy */
+  if ( (SUNRabs(h_acc) > SUNRabs(ark_mem->ark_h*ark_mem->ark_hadapt_lbound*ONEMSM)) &&
+       (SUNRabs(h_acc) < SUNRabs(ark_mem->ark_h*ark_mem->ark_hadapt_ubound*ONEPSM)) )
+    h_acc = ark_mem->ark_h;
+
+  /* set basic value of ark_eta */
+  ark_mem->ark_eta = h_acc / ark_mem->ark_h;
+
+  /* enforce minimum time step size */
+  ark_mem->ark_eta = SUNMAX(ark_mem->ark_eta,
+			 ark_mem->ark_hmin / SUNRabs(ark_mem->ark_h));
+
+  /* enforce maximum time step size */
+  ark_mem->ark_eta /= SUNMAX(ONE, SUNRabs(ark_mem->ark_h) *
+			  ark_mem->ark_hmax_inv*ark_mem->ark_eta);
+
+  /* Solver diagnostics reporting */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "%19.16g\n", ark_mem->ark_eta);
+
+  return(ier);
+}
+
+
+/*---------------------------------------------------------------
+ arkAdaptPID implements a PID time step control algorithm.
+---------------------------------------------------------------*/
+static int arkAdaptPID(ARKodeMem ark_mem, realtype *hnew)
+{
+  realtype k, k1, k2, k3, e1, e2, e3, hcur, h_acc;
+
+  /* set usable time-step adaptivity parameters */
+  k = (ark_mem->ark_hadapt_pq) ? ark_mem->ark_q : ark_mem->ark_p;
+  k1 = -ark_mem->ark_hadapt_k1 / k;
+  k2 =  ark_mem->ark_hadapt_k2 / k;
+  k3 = -ark_mem->ark_hadapt_k3 / k;
+  e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+  e2 = SUNMAX(ark_mem->ark_hadapt_ehist[1], TINY);
+  e3 = SUNMAX(ark_mem->ark_hadapt_ehist[2], TINY);
+  hcur = ark_mem->ark_h;
+  
+  /* compute estimated optimal time step size, set into output */
+  h_acc = hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2) * SUNRpowerR(e3,k3);
+  *hnew = h_acc;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkAdaptPI implements a PI time step control algorithm.
+---------------------------------------------------------------*/
+static int arkAdaptPI(ARKodeMem ark_mem, realtype *hnew)
+{
+  realtype k, k1, k2, e1, e2, hcur, h_acc;
+
+  /* set usable time-step adaptivity parameters */
+  k = (ark_mem->ark_hadapt_pq) ? ark_mem->ark_q : ark_mem->ark_p;
+  k1 = -ark_mem->ark_hadapt_k1 / k;
+  k2 =  ark_mem->ark_hadapt_k2 / k;
+  e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+  e2 = SUNMAX(ark_mem->ark_hadapt_ehist[1], TINY);
+  hcur = ark_mem->ark_h;
+  
+  /* compute estimated optimal time step size, set into output */
+  h_acc = hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2);
+  *hnew = h_acc;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkAdaptI implements an I time step control algorithm.
+---------------------------------------------------------------*/
+static int arkAdaptI(ARKodeMem ark_mem, realtype *hnew)
+{
+  realtype k, k1, e1, hcur, h_acc;
+
+  /* set usable time-step adaptivity parameters */
+  k = (ark_mem->ark_hadapt_pq) ? ark_mem->ark_q : ark_mem->ark_p;
+  k1 = -ark_mem->ark_hadapt_k1 / k;
+  e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+  hcur = ark_mem->ark_h;
+  
+  /* compute estimated optimal time step size, set into output */
+  h_acc = hcur * SUNRpowerR(e1,k1);
+  *hnew = h_acc;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkAdaptExpGus implements the explicit Gustafsson time step
+ control algorithm.
+---------------------------------------------------------------*/
+static int arkAdaptExpGus(ARKodeMem ark_mem, realtype *hnew)
+{
+  realtype k, k1, k2, e1, e2, hcur, h_acc;
+  k = (ark_mem->ark_hadapt_pq) ? ark_mem->ark_q : ark_mem->ark_p;
+
+  /* modified method for first step */
+  if (ark_mem->ark_nst < 2) {
+
+    k1 = -ONE / k;
+    hcur = ark_mem->ark_h;
+    e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+    h_acc = hcur * SUNRpowerR(e1,k1);
+
+  /* general estimate */
+  } else {
+
+    k1 = -ark_mem->ark_hadapt_k1 / k;
+    k2 = -ark_mem->ark_hadapt_k2 / k;
+    e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+    e2 = e1 / SUNMAX(ark_mem->ark_hadapt_ehist[1], TINY);
+    hcur = ark_mem->ark_h;
+    h_acc = hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2);
+
+  }
+  *hnew = h_acc;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkAdaptImpGus implements the implicit Gustafsson time step 
+ control algorithm.
+---------------------------------------------------------------*/
+static int arkAdaptImpGus(ARKodeMem ark_mem, realtype *hnew)
+{
+  realtype k, k1, k2, e1, e2, hcur, hrat, h_acc;
+  k = (ark_mem->ark_hadapt_pq) ? ark_mem->ark_q : ark_mem->ark_p;
+
+  /* modified method for first step */
+  if (ark_mem->ark_nst < 2) {
+
+    k1 = -ONE / k;
+    hcur = ark_mem->ark_h;
+    e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+    h_acc = hcur * SUNRpowerR(e1,k1);
+
+  /* general estimate */
+  } else {
+
+    k1 = -ark_mem->ark_hadapt_k1 / k;
+    k2 = -ark_mem->ark_hadapt_k2 / k;
+    e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+    e2 = e1 / SUNMAX(ark_mem->ark_hadapt_ehist[1], TINY);
+    hcur = ark_mem->ark_hadapt_hhist[0];
+    hrat = hcur / ark_mem->ark_hadapt_hhist[1];
+    h_acc = hcur * hrat * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2);
+
+  }
+  *hnew = h_acc;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkAdaptImExGus implements a combination implicit/explicit 
+ Gustafsson time step control algorithm.
+---------------------------------------------------------------*/
+static int arkAdaptImExGus(ARKodeMem ark_mem, realtype *hnew)
+{
+  realtype k, k1, k2, k3, e1, e2, hcur, hrat, h_acc;
+  k = (ark_mem->ark_hadapt_pq) ? ark_mem->ark_q : ark_mem->ark_p;
+
+  /* modified method for first step */
+  if (ark_mem->ark_nst < 2) {
+
+    k1 = -ONE / k;
+    hcur = ark_mem->ark_h;
+    e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+    h_acc = hcur * SUNRpowerR(e1,k1);
+
+  /* general estimate */
+  } else {
+
+    k1 = -ark_mem->ark_hadapt_k1 / k;
+    k2 = -ark_mem->ark_hadapt_k2 / k;
+    k3 = -ark_mem->ark_hadapt_k3 / k;
+    e1 = SUNMAX(ark_mem->ark_hadapt_ehist[0], TINY);
+    e2 = e1 / SUNMAX(ark_mem->ark_hadapt_ehist[1], TINY);
+    hcur = ark_mem->ark_hadapt_hhist[0];
+    hrat = hcur / ark_mem->ark_hadapt_hhist[1];
+    /* implicit estimate */
+    h_acc = hcur * hrat * SUNRpowerR(e1,k3) * SUNRpowerR(e2,k3);
+    /* explicit estimate */
+    h_acc = SUNMIN(h_acc, hcur * SUNRpowerR(e1,k1) * SUNRpowerR(e2,k2));
+
+  }
+  *hnew = h_acc;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkExpStab is the default explicit stability estimation function
+---------------------------------------------------------------*/
+int arkExpStab(N_Vector y, realtype t, realtype *hstab, void *data)
+{
+  /* explicit stability not used by default, 
+     set to zero to disable */
+  *hstab = RCONST(0.0);
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkProcessError is a high level error handling function
+ - if ark_mem==NULL it prints the error message to stderr
+ - otherwise, it sets-up and calls the error handling function 
+   pointed to by ark_ehfun 
+---------------------------------------------------------------*/
+void arkProcessError(ARKodeMem ark_mem, int error_code, 
+		     const char *module, const char *fname, 
+		     const char *msgfmt, ...)
+{
+  va_list ap;
+  char msg[256];
+
+  /* Initialize the argument pointer variable 
+     (msgfmt is the last required argument to arkProcessError) */
+  va_start(ap, msgfmt);
+
+  /* Compose the message */
+  vsprintf(msg, msgfmt, ap);
+
+  if (ark_mem == NULL) {    /* We write to stderr */
+
+#ifndef NO_FPRINTF_OUTPUT
+    fprintf(stderr, "\n[%s ERROR]  %s\n  ", module, fname);
+    fprintf(stderr, "%s\n\n", msg);
+#endif
+
+  } else {                 /* We can call ehfun */
+    ark_mem->ark_ehfun(error_code, module, fname, msg, 
+		       ark_mem->ark_eh_data);
+  }
+
+  /* Finalize argument processing */
+  va_end(ap);
+
+  return;
+}
+
+
+/*---------------------------------------------------------------
+ arkRootCheck1
+
+ This routine completes the initialization of rootfinding memory
+ information, and checks whether g has a zero both at and very near
+ the initial point of the IVP.
+
+ This routine returns an int equal to:
+  ARK_RTFUNC_FAIL < 0  if the g function failed, or
+  ARK_SUCCESS     = 0  otherwise.
+---------------------------------------------------------------*/
+static int arkRootCheck1(ARKodeMem ark_mem)
+{
+  int i, retval;
+  realtype smallh, hratio, tplus;
+  booleantype zroot;
+
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) 
+    ark_mem->ark_iroots[i] = 0;
+  ark_mem->ark_tlo = ark_mem->ark_tn;
+  ark_mem->ark_ttol = (SUNRabs(ark_mem->ark_tn) +
+		       SUNRabs(ark_mem->ark_h))*ark_mem->ark_uround*HUND;
+
+  /* Evaluate g at initial t and check for zero values. */
+  retval = ark_mem->ark_gfun(ark_mem->ark_tlo, ark_mem->ark_ycur,
+			     ark_mem->ark_glo, ark_mem->ark_user_data);
+  ark_mem->ark_nge = 1;
+  if (retval != 0) return(ARK_RTFUNC_FAIL);
+
+  zroot = FALSE;
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) {
+    if (SUNRabs(ark_mem->ark_glo[i]) == ZERO) {
+      zroot = TRUE;
+      ark_mem->ark_gactive[i] = FALSE;
+    }
+  }
+  if (!zroot) return(ARK_SUCCESS);
+
+  /* Some g_i is zero at t0; look at g at t0+(small increment). */
+  hratio = SUNMAX(ark_mem->ark_ttol/SUNRabs(ark_mem->ark_h), TENTH);
+  smallh = hratio*ark_mem->ark_h;
+  tplus = ark_mem->ark_tlo + smallh;
+  N_VLinearSum(ONE, ark_mem->ark_ycur, smallh,
+	       ark_mem->ark_fold, ark_mem->ark_y);
+  retval = ark_mem->ark_gfun(tplus, ark_mem->ark_y, ark_mem->ark_ghi, 
+			     ark_mem->ark_user_data);
+  ark_mem->ark_nge++;
+  if (retval != 0) return(ARK_RTFUNC_FAIL);
+
+  /* We check now only the components of g which were exactly 0.0 at t0
+   * to see if we can 'activate' them. */
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) {
+    if (!ark_mem->ark_gactive[i] && SUNRabs(ark_mem->ark_ghi[i]) != ZERO) {
+      ark_mem->ark_gactive[i] = TRUE;
+      ark_mem->ark_glo[i] = ark_mem->ark_ghi[i];
+    }
+  }
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkRootCheck2
+
+ This routine checks for exact zeros of g at the last root found,
+ if the last return was a root.  It then checks for a close pair of
+ zeros (an error condition), and for a new root at a nearby point.
+ The array glo = g(tlo) at the left endpoint of the search interval
+ is adjusted if necessary to assure that all g_i are nonzero
+ there, before returning to do a root search in the interval.
+
+ On entry, tlo = tretlast is the last value of tret returned by
+ ARKode.  This may be the previous tn, the previous tout value, or
+ the last root location.
+
+ This routine returns an int equal to:
+      ARK_RTFUNC_FAIL < 0 if the g function failed, or
+      CLOSERT         = 3 if a close pair of zeros was found, or
+      RTFOUND         = 1 if a new zero of g was found near tlo, or
+      ARK_SUCCESS     = 0 otherwise.
+---------------------------------------------------------------*/
+static int arkRootCheck2(ARKodeMem ark_mem)
+{
+  int i, retval;
+  /* realtype smallh, hratio, tplus; */
+  realtype smallh, tplus;
+  booleantype zroot;
+
+  /* return if no roots in previous step */
+  if (ark_mem->ark_irfnd == 0) return(ARK_SUCCESS);
+
+  /* Set ark_y = y(tlo) */
+  (void) ARKodeGetDky(ark_mem, ark_mem->ark_tlo, 0, ark_mem->ark_y);
+
+  /* Evaluate root-finding function: glo = g(tlo, y(tlo)) */
+  retval = ark_mem->ark_gfun(ark_mem->ark_tlo, ark_mem->ark_y, 
+			     ark_mem->ark_glo, ark_mem->ark_user_data);
+  ark_mem->ark_nge++;
+  if (retval != 0) return(ARK_RTFUNC_FAIL);
+
+  /* reset root-finding flags (overall, and for specific eqns) */
+  zroot = FALSE;
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) 
+    ark_mem->ark_iroots[i] = 0;
+
+  /* for all active roots, check if glo_i == 0 to mark roots found */
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) {
+    if (!ark_mem->ark_gactive[i]) continue;
+    if (SUNRabs(ark_mem->ark_glo[i]) == ZERO) {
+      zroot = TRUE;
+      ark_mem->ark_iroots[i] = 1;
+    }
+  }
+  if (!zroot) return(ARK_SUCCESS);  /* return if no roots */
+
+  /* One or more g_i has a zero at tlo.  Check g at tlo+smallh. */
+  /*     set time tolerance */
+  ark_mem->ark_ttol = (SUNRabs(ark_mem->ark_tn) +
+		       SUNRabs(ark_mem->ark_h))*ark_mem->ark_uround*HUND;
+  /*     set tplus = tlo + smallh */
+  smallh = (ark_mem->ark_h > ZERO) ? ark_mem->ark_ttol : -ark_mem->ark_ttol;
+  tplus = ark_mem->ark_tlo + smallh;
+  /*     update ark_y with small explicit Euler step (if tplus is past tn) */
+  if ( (tplus - ark_mem->ark_tn)*ark_mem->ark_h >= ZERO ) {
+    /* hratio = smallh/ark_mem->ark_h; */
+    N_VLinearSum(ONE, ark_mem->ark_y, smallh, 
+		 ark_mem->ark_fold, ark_mem->ark_y);
+  } else {
+    /*   set ark_y = y(tplus) via interpolation */
+    (void) ARKodeGetDky(ark_mem, tplus, 0, ark_mem->ark_y);
+  }
+  /*     set ghi = g(tplus,y(tplus)) */
+  retval = ark_mem->ark_gfun(tplus, ark_mem->ark_y, ark_mem->ark_ghi, 
+			     ark_mem->ark_user_data);
+  ark_mem->ark_nge++;
+  if (retval != 0) return(ARK_RTFUNC_FAIL);
+
+  /* Check for close roots (error return), for a new zero at tlo+smallh,
+  and for a g_i that changed from zero to nonzero. */
+  zroot = FALSE;
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) {
+    if (!ark_mem->ark_gactive[i]) continue;
+    if (SUNRabs(ark_mem->ark_ghi[i]) == ZERO) {
+      if (ark_mem->ark_iroots[i] == 1) return(CLOSERT);
+      zroot = TRUE;
+      ark_mem->ark_iroots[i] = 1;
+    } else {
+      if (ark_mem->ark_iroots[i] == 1) 
+	ark_mem->ark_glo[i] = ark_mem->ark_ghi[i];
+    }
+  }
+  if (zroot) return(RTFOUND);
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkRootCheck3
+
+ This routine interfaces to arkRootfind to look for a root of g
+ between tlo and either tn or tout, whichever comes first.
+ Only roots beyond tlo in the direction of integration are sought.
+
+ This routine returns an int equal to:
+      ARK_RTFUNC_FAIL < 0 if the g function failed, or
+      RTFOUND         = 1 if a root of g was found, or
+      ARK_SUCCESS     = 0 otherwise.
+---------------------------------------------------------------*/
+static int arkRootCheck3(ARKodeMem ark_mem)
+{
+  int i, retval, ier;
+
+  /* Set thi = tn or tout, whichever comes first; set y = y(thi). */
+  if (ark_mem->ark_taskc == ARK_ONE_STEP) {
+    ark_mem->ark_thi = ark_mem->ark_tn;
+    N_VScale(ONE, ark_mem->ark_ycur, ark_mem->ark_y);
+  }
+  if (ark_mem->ark_taskc == ARK_NORMAL) {
+    if ( (ark_mem->ark_toutc - ark_mem->ark_tn)*ark_mem->ark_h >= ZERO) {
+      ark_mem->ark_thi = ark_mem->ark_tn; 
+      N_VScale(ONE, ark_mem->ark_ycur, ark_mem->ark_y);
+    } else {
+      ark_mem->ark_thi = ark_mem->ark_toutc;
+      (void) ARKodeGetDky(ark_mem, ark_mem->ark_thi, 0, ark_mem->ark_y);
+    }
+  }
+
+  /* Set ark_mem->ark_ghi = g(thi) and call arkRootfind to search (tlo,thi) for roots. */
+  retval = ark_mem->ark_gfun(ark_mem->ark_thi, ark_mem->ark_y, 
+			     ark_mem->ark_ghi, ark_mem->ark_user_data);
+  ark_mem->ark_nge++;
+  if (retval != 0) return(ARK_RTFUNC_FAIL);
+
+  ark_mem->ark_ttol = (SUNRabs(ark_mem->ark_tn) +
+		       SUNRabs(ark_mem->ark_h))*ark_mem->ark_uround*HUND;
+  ier = arkRootfind(ark_mem);
+  if (ier == ARK_RTFUNC_FAIL) return(ARK_RTFUNC_FAIL);
+  for(i=0; i<ark_mem->ark_nrtfn; i++) {
+    if (!ark_mem->ark_gactive[i] && ark_mem->ark_grout[i] != ZERO) 
+      ark_mem->ark_gactive[i] = TRUE;
+  }
+  ark_mem->ark_tlo = ark_mem->ark_trout;
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) 
+    ark_mem->ark_glo[i] = ark_mem->ark_grout[i];
+
+  /* If no root found, return ARK_SUCCESS. */  
+  if (ier == ARK_SUCCESS) return(ARK_SUCCESS);
+
+  /* If a root was found, interpolate to get y(trout) and return.  */
+  (void) ARKodeGetDky(ark_mem, ark_mem->ark_trout, 0, ark_mem->ark_y);
+  return(RTFOUND);
+
+}
+
+
+/*---------------------------------------------------------------
+ arkRootfind
+
+ This routine solves for a root of g(t) between tlo and thi, if
+ one exists.  Only roots of odd multiplicity (i.e. with a change
+ of sign in one of the g_i), or exact zeros, are found.
+ Here the sign of tlo - thi is arbitrary, but if multiple roots
+ are found, the one closest to tlo is returned.
+
+ The method used is the Illinois algorithm, a modified secant method.
+ Reference: Kathie L. Hiebert and Lawrence F. Shampine, Implicitly
+ Defined Output Points for Solutions of ODEs, Sandia National
+ Laboratory Report SAND80-0180, February 1980.
+
+ This routine uses the following parameters for communication:
+
+ nrtfn    = number of functions g_i, or number of components of
+            the vector-valued function g(t).  Input only.
+
+ gfun     = user-defined function for g(t).  Its form is
+            (void) gfun(t, y, gt, user_data)
+
+ rootdir  = in array specifying the direction of zero-crossings.
+            If rootdir[i] > 0, search for roots of g_i only if
+            g_i is increasing; if rootdir[i] < 0, search for
+            roots of g_i only if g_i is decreasing; otherwise
+            always search for roots of g_i.
+
+ gactive  = array specifying whether a component of g should
+            or should not be monitored. gactive[i] is initially
+            set to TRUE for all i=0,...,nrtfn-1, but it may be
+            reset to FALSE if at the first step g[i] is 0.0
+            both at the I.C. and at a small perturbation of them.
+            gactive[i] is then set back on TRUE only after the 
+            corresponding g function moves away from 0.0.
+
+ nge      = cumulative counter for gfun calls.
+
+ ttol     = a convergence tolerance for trout.  Input only.
+            When a root at trout is found, it is located only to
+            within a tolerance of ttol.  Typically, ttol should
+            be set to a value on the order of
+               100 * UROUND * max (SUNRabs(tlo), SUNRabs(thi))
+            where UROUND is the unit roundoff of the machine.
+
+ tlo, thi = endpoints of the interval in which roots are sought.
+            On input, and must be distinct, but tlo - thi may
+            be of either sign.  The direction of integration is
+            assumed to be from tlo to thi.  On return, tlo and thi
+            are the endpoints of the final relevant interval.
+
+ glo, ghi = arrays of length nrtfn containing the vectors g(tlo)
+            and g(thi) respectively.  Input and output.  On input,
+            none of the glo[i] should be zero.
+
+ trout    = root location, if a root was found, or thi if not.
+            Output only.  If a root was found other than an exact
+            zero of g, trout is the endpoint thi of the final
+            interval bracketing the root, with size at most ttol.
+
+ grout    = array of length nrtfn containing g(trout) on return.
+
+ iroots   = int array of length nrtfn with root information.
+            Output only.  If a root was found, iroots indicates
+            which components g_i have a root at trout.  For
+            i = 0, ..., nrtfn-1, iroots[i] = 1 if g_i has a root
+            and g_i is increasing, iroots[i] = -1 if g_i has a
+            root and g_i is decreasing, and iroots[i] = 0 if g_i
+            has no roots or g_i varies in the direction opposite
+            to that indicated by rootdir[i].
+
+ This routine returns an int equal to:
+      ARK_RTFUNC_FAIL < 0 if the g function failed, or
+      RTFOUND         = 1 if a root of g was found, or
+      ARK_SUCCESS     = 0 otherwise.
+---------------------------------------------------------------*/
+static int arkRootfind(ARKodeMem ark_mem)
+{
+  realtype alpha, tmid, gfrac, maxfrac, fracint, fracsub;
+  int i, retval, imax, side, sideprev;
+  booleantype zroot, sgnchg;
+
+  imax = 0;
+
+  /* First check for change in sign in ghi or for a zero in ghi. */
+  maxfrac = ZERO;
+  zroot = FALSE;
+  sgnchg = FALSE;
+  for (i = 0;  i < ark_mem->ark_nrtfn; i++) {
+    if (!ark_mem->ark_gactive[i]) continue;
+    if (SUNRabs(ark_mem->ark_ghi[i]) == ZERO) {
+      if (ark_mem->ark_rootdir[i]*ark_mem->ark_glo[i] <= ZERO) {
+        zroot = TRUE;
+      }
+    } else {
+      if ( (ark_mem->ark_glo[i]*ark_mem->ark_ghi[i] < ZERO) && 
+	   (ark_mem->ark_rootdir[i]*ark_mem->ark_glo[i] <= ZERO) ) {
+        gfrac = SUNRabs(ark_mem->ark_ghi[i]/(ark_mem->ark_ghi[i] - ark_mem->ark_glo[i]));
+        if (gfrac > maxfrac) {
+          sgnchg = TRUE;
+          maxfrac = gfrac;
+          imax = i;
+        }
+      }
+    }
+  }
+
+  /* If no sign change was found, reset trout and grout.  Then return
+     ARK_SUCCESS if no zero was found, or set iroots and return RTFOUND.  */ 
+  if (!sgnchg) {
+    ark_mem->ark_trout = ark_mem->ark_thi;
+    for (i = 0; i < ark_mem->ark_nrtfn; i++) 
+      ark_mem->ark_grout[i] = ark_mem->ark_ghi[i];
+    if (!zroot) return(ARK_SUCCESS);
+    for (i = 0; i < ark_mem->ark_nrtfn; i++) {
+      ark_mem->ark_iroots[i] = 0;
+      if (!ark_mem->ark_gactive[i]) continue;
+      if (SUNRabs(ark_mem->ark_ghi[i]) == ZERO)
+	ark_mem->ark_iroots[i] = ark_mem->ark_glo[i] > 0 ? -1:1;
+    }
+    return(RTFOUND);
+  }
+
+  /* Initialize alpha to avoid compiler warning */
+  alpha = ONE;
+
+  /* A sign change was found.  Loop to locate nearest root. */
+  side = 0;  sideprev = -1;
+  for(;;) {                                    /* Looping point */
+
+    /* If interval size is already less than tolerance ttol, break. */
+    if (SUNRabs(ark_mem->ark_thi - ark_mem->ark_tlo) <= ark_mem->ark_ttol) break;
+    
+    /* Set weight alpha.
+       On the first two passes, set alpha = 1.  Thereafter, reset alpha
+       according to the side (low vs high) of the subinterval in which
+       the sign change was found in the previous two passes.
+       If the sides were opposite, set alpha = 1.
+       If the sides were the same, then double alpha (if high side),
+       or halve alpha (if low side).
+       The next guess tmid is the secant method value if alpha = 1, but
+       is closer to tlo if alpha < 1, and closer to thi if alpha > 1.    */
+    if (sideprev == side) {
+      alpha = (side == 2) ? alpha*TWO : alpha*HALF;
+    } else {
+      alpha = ONE;
+    }
+
+    /* Set next root approximation tmid and get g(tmid).
+       If tmid is too close to tlo or thi, adjust it inward,
+       by a fractional distance that is between 0.1 and 0.5.  */
+    tmid = ark_mem->ark_thi - (ark_mem->ark_thi - ark_mem->ark_tlo) *
+      ark_mem->ark_ghi[imax]/(ark_mem->ark_ghi[imax] - alpha*ark_mem->ark_glo[imax]);
+    if (SUNRabs(tmid - ark_mem->ark_tlo) < HALF*ark_mem->ark_ttol) {
+      fracint = SUNRabs(ark_mem->ark_thi - ark_mem->ark_tlo)/ark_mem->ark_ttol;
+      fracsub = (fracint > FIVE) ? TENTH : HALF/fracint;
+      tmid = ark_mem->ark_tlo + fracsub*(ark_mem->ark_thi - ark_mem->ark_tlo);
+    }
+    if (SUNRabs(ark_mem->ark_thi - tmid) < HALF*ark_mem->ark_ttol) {
+      fracint = SUNRabs(ark_mem->ark_thi - ark_mem->ark_tlo)/ark_mem->ark_ttol;
+      fracsub = (fracint > FIVE) ? TENTH : HALF/fracint;
+      tmid = ark_mem->ark_thi - fracsub*(ark_mem->ark_thi - ark_mem->ark_tlo);
+    }
+
+    (void) ARKodeGetDky(ark_mem, tmid, 0, ark_mem->ark_y);
+    retval = ark_mem->ark_gfun(tmid, ark_mem->ark_y, ark_mem->ark_grout, 
+			       ark_mem->ark_user_data);
+    ark_mem->ark_nge++;
+    if (retval != 0) return(ARK_RTFUNC_FAIL);
+
+    /* Check to see in which subinterval g changes sign, and reset imax.
+       Set side = 1 if sign change is on low side, or 2 if on high side.  */  
+    maxfrac = ZERO;
+    zroot = FALSE;
+    sgnchg = FALSE;
+    sideprev = side;
+    for (i = 0;  i < ark_mem->ark_nrtfn; i++) {
+      if (!ark_mem->ark_gactive[i]) continue;
+      if (SUNRabs(ark_mem->ark_grout[i]) == ZERO) {
+        if (ark_mem->ark_rootdir[i]*ark_mem->ark_glo[i] <= ZERO) {
+          zroot = TRUE;
+        }
+      } else {
+        if ( (ark_mem->ark_glo[i]*ark_mem->ark_grout[i] < ZERO) && 
+	     (ark_mem->ark_rootdir[i]*ark_mem->ark_glo[i] <= ZERO) ) {
+          gfrac = SUNRabs(ark_mem->ark_grout[i]/(ark_mem->ark_grout[i] - ark_mem->ark_glo[i]));
+          if (gfrac > maxfrac) {
+            sgnchg = TRUE;
+            maxfrac = gfrac;
+            imax = i;
+          }
+        }
+      }
+    }
+    if (sgnchg) {
+      /* Sign change found in (tlo,tmid); replace thi with tmid. */
+      ark_mem->ark_thi = tmid;
+      for (i = 0; i < ark_mem->ark_nrtfn; i++) 
+	ark_mem->ark_ghi[i] = ark_mem->ark_grout[i];
+      side = 1;
+      /* Stop at root thi if converged; otherwise loop. */
+      if (SUNRabs(ark_mem->ark_thi - ark_mem->ark_tlo) <= ark_mem->ark_ttol) break;
+      continue;  /* Return to looping point. */
+    }
+
+    if (zroot) {
+      /* No sign change in (tlo,tmid), but g = 0 at tmid; return root tmid. */
+      ark_mem->ark_thi = tmid;
+      for (i = 0; i < ark_mem->ark_nrtfn; i++) 
+	ark_mem->ark_ghi[i] = ark_mem->ark_grout[i];
+      break;
+    }
+
+    /* No sign change in (tlo,tmid), and no zero at tmid.
+       Sign change must be in (tmid,thi).  Replace tlo with tmid. */
+    ark_mem->ark_tlo = tmid;
+    for (i = 0; i < ark_mem->ark_nrtfn; i++) 
+      ark_mem->ark_glo[i] = ark_mem->ark_grout[i];
+    side = 2;
+    /* Stop at root thi if converged; otherwise loop back. */
+    if (SUNRabs(ark_mem->ark_thi - ark_mem->ark_tlo) <= ark_mem->ark_ttol)
+      break;
+
+  } /* End of root-search loop */
+
+  /* Reset trout and grout, set iroots, and return RTFOUND. */
+  ark_mem->ark_trout = ark_mem->ark_thi;
+  for (i = 0; i < ark_mem->ark_nrtfn; i++) {
+    ark_mem->ark_grout[i] = ark_mem->ark_ghi[i];
+    ark_mem->ark_iroots[i] = 0;
+    if (!ark_mem->ark_gactive[i]) continue;
+    if ( (SUNRabs(ark_mem->ark_ghi[i]) == ZERO) &&
+	 (ark_mem->ark_rootdir[i]*ark_mem->ark_glo[i] <= ZERO) ) 
+      ark_mem->ark_iroots[i] = ark_mem->ark_glo[i] > 0 ? -1:1;
+    if ( (ark_mem->ark_glo[i]*ark_mem->ark_ghi[i] < ZERO) && 
+	 (ark_mem->ark_rootdir[i]*ark_mem->ark_glo[i] <= ZERO) ) 
+      ark_mem->ark_iroots[i] = ark_mem->ark_glo[i] > 0 ? -1:1;
+  }
+  return(RTFOUND);
+}
+
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/arkode_band.c b/src/arkode/arkode_band.c
new file mode 100644
index 0000000..603a66a
--- /dev/null
+++ b/src/arkode/arkode_band.c
@@ -0,0 +1,637 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the ARKBAND linear solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_band.h>
+#include "arkode_direct_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* ARKBAND linit, lsetup, lsolve, and lfree routines */
+static int arkBandInit(ARKodeMem ark_mem);
+static int arkBandSetup(ARKodeMem ark_mem, int convfail, N_Vector ypred,
+                       N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
+                       N_Vector vtemp2, N_Vector vtemp3);
+static int arkBandSolve(ARKodeMem ark_mem, N_Vector b, N_Vector weight,
+                       N_Vector ycur, N_Vector fcur);
+static int arkBandFree(ARKodeMem ark_mem);
+
+/* ARKBAND minit, msetup, msolve, mfree and mtimes routines */
+static int arkMassBandInit(ARKodeMem ark_mem);
+static int arkMassBandSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			    N_Vector vtemp2, N_Vector vtemp3);
+static int arkMassBandSolve(ARKodeMem ark_mem, N_Vector b, N_Vector weight);
+static int arkMassBandFree(ARKodeMem ark_mem);
+static int arkMassBandMultiply(N_Vector v, N_Vector Mv, 
+			       realtype t, void *user_data);
+
+
+/*---------------------------------------------------------------
+ ARKBand:
+
+ This routine initializes the memory record and sets various function
+ fields specific to the band linear solver module.  ARKBand first calls
+ the existing lfree routine if this is not NULL.  It then sets the
+ ark_linit, ark_lsetup, ark_lsolve, and ark_lfree fields in (*arkode_mem)
+ to be arkBandInit, arkBandSetup, arkBandSolve, and arkBandFree,
+ respectively.  It allocates memory for a structure of type
+ ARKDlsMemRec and sets the ark_lmem field in (*arkode_mem) to the
+ address of this structure.  It sets setupNonNull in (*arkode_mem) to be
+ TRUE, d_mu to be mupper, d_ml to be mlower, and the d_jac field to be 
+ arkDlsBandDQJac.  Finally, it allocates memory for M, savedJ, and pivot.  
+ The ARKBand return value is SUCCESS = 0, LMEM_FAIL = -1, or 
+ LIN_ILL_INPUT = -2.
+
+ NOTE: The band linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKBand will first 
+       test for compatible a compatible N_Vector internal
+       representation by checking that the function 
+       N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+int ARKBand(void *arkode_mem, long int N, long int mupper, long int mlower)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKBAND", "ARKBand", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the BAND solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKBAND", "ARKBand", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */  
+  ark_mem->ark_linit  = arkBandInit;
+  ark_mem->ark_lsetup = arkBandSetup;
+  ark_mem->ark_lsolve = arkBandSolve;
+  ark_mem->ark_lfree  = arkBandFree;
+  ark_mem->ark_lsolve_type = 2;
+  
+  /* Get memory for ARKDlsMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMem) malloc(sizeof(struct ARKDlsMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKBand", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_BAND;
+  
+  /* Initialize Jacobian-related data */
+  arkdls_mem->d_jacDQ = TRUE;
+  arkdls_mem->d_bjac = NULL;
+  arkdls_mem->d_J_data = NULL;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_setupNonNull = TRUE;
+
+  /* Initialize counters */
+  arkDlsInitializeCounters(arkdls_mem);
+  
+  /* Load problem dimension */
+  arkdls_mem->d_n = N;
+
+  /* Load half-bandwiths in arkdls_mem */
+  arkdls_mem->d_ml = mlower;
+  arkdls_mem->d_mu = mupper;
+
+  /* Test ml and mu for legality */
+  if ((arkdls_mem->d_ml < 0) || (arkdls_mem->d_mu < 0) || (arkdls_mem->d_ml >= N) || (arkdls_mem->d_mu >= N)) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKBAND", "ARKBand", MSGD_BAD_SIZES);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  /* Set extended upper half-bandwith for M (required for pivoting) */
+  arkdls_mem->d_smu = SUNMIN(N-1, arkdls_mem->d_mu + arkdls_mem->d_ml);
+
+  /* Allocate memory for M, savedJ, and pivot arrays */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_M = NewBandMat(N, arkdls_mem->d_mu, arkdls_mem->d_ml, arkdls_mem->d_smu);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKBand", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_savedJ = NULL;
+  arkdls_mem->d_savedJ = NewBandMat(N, arkdls_mem->d_mu, arkdls_mem->d_ml, arkdls_mem->d_mu);
+  if (arkdls_mem->d_savedJ == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKBand", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_lpivots = NULL;
+  arkdls_mem->d_lpivots = NewLintArray(N);
+  if (arkdls_mem->d_lpivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKBand", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    DestroyMat(arkdls_mem->d_savedJ);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkBandInit:
+
+ This routine does remaining initializations specific to the band
+ linear solver.
+---------------------------------------------------------------*/
+static int arkBandInit(ARKodeMem ark_mem)
+{
+  ARKDlsMem arkdls_mem;
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  arkDlsInitializeCounters(arkdls_mem);
+
+  /* Set Jacobian function and data, depending on jacDQ */
+  if (arkdls_mem->d_jacDQ) {
+    arkdls_mem->d_bjac = arkDlsBandDQJac;
+    arkdls_mem->d_J_data = ark_mem;
+  } else {
+    arkdls_mem->d_J_data = ark_mem->ark_user_data;
+  }
+
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkBandSetup:
+
+ This routine does the setup operations for the band linear 
+ solver. It makes a decision whether or not to call the Jacobian 
+ evaluation routine based on various state variables, and if not 
+ it uses the saved copy.  In any case, it constructs the Newton 
+ matrix  A = M - gamma*J, updates counters, and calls the band 
+ LU factorization routine.
+---------------------------------------------------------------*/
+static int arkBandSetup(ARKodeMem ark_mem, int convfail, 
+			N_Vector ypred, N_Vector fpred, 
+			booleantype *jcurPtr, N_Vector vtemp1,
+			N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma;
+  long int i, j, ier, ml, mu, N, M, is, ie;
+  DlsMat A, Mass;
+  ARKDlsMem arkdls_mem;
+  ARKDlsMassMem arkdls_mass_mem;
+  int retval;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkdls_mem->d_nstlj + ARKD_MSBJ) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKD_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  jok = !jbad;
+  
+  if (jok) {
+
+    /* If jok = TRUE, use saved copy of J */
+    *jcurPtr = FALSE;
+    BandCopy(arkdls_mem->d_savedJ, arkdls_mem->d_M, arkdls_mem->d_mu, arkdls_mem->d_ml);
+
+  } else {
+
+    /* If jok = FALSE, call jac routine for new J value */
+    arkdls_mem->d_nje++;
+    arkdls_mem->d_nstlj = ark_mem->ark_nst;
+    *jcurPtr = TRUE;
+    SetToZero(arkdls_mem->d_M); 
+
+    retval = arkdls_mem->d_bjac(arkdls_mem->d_n, arkdls_mem->d_mu, arkdls_mem->d_ml, 
+				ark_mem->ark_tn, ypred, fpred, arkdls_mem->d_M, 
+				arkdls_mem->d_J_data, vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_JACFUNC_UNRECVR, "ARKBAND", "arkBandSetup", MSGD_JACFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_RECVR;
+      return(1);
+    }
+
+    BandCopy(arkdls_mem->d_M, arkdls_mem->d_savedJ, arkdls_mem->d_mu, arkdls_mem->d_ml);
+
+  }
+
+  /* Scale J by -gamma */
+  BandScale(-ark_mem->ark_gamma, arkdls_mem->d_M);
+
+  /* Add mass matrix to get A = M-gamma*J*/
+  if (ark_mem->ark_mass_matrix) {
+
+    /* Compute mass matrix */
+    arkdls_mass_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+    SetToZero(arkdls_mass_mem->d_M);
+    retval = arkdls_mass_mem->d_bmass(arkdls_mass_mem->d_n, arkdls_mass_mem->d_mu, 
+				      arkdls_mass_mem->d_ml, ark_mem->ark_tn, 
+				      arkdls_mass_mem->d_M, arkdls_mass_mem->d_M_data, 
+				      vtemp1, vtemp2, vtemp3);
+    arkdls_mass_mem->d_nme++;
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKBAND", 
+		      "arkBandSetup",  MSGD_MASSFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+      return(1);
+    }
+
+    /* perform matrix sum */
+    ml = arkdls_mem->d_M->ml;
+    mu = arkdls_mem->d_M->mu;
+    N = arkdls_mem->d_M->N;
+    M = arkdls_mem->d_M->M;
+    A = arkdls_mem->d_M;
+    Mass = arkdls_mass_mem->d_M;
+    for (j=0; j<N; j++) {                /* loop over columns */
+      is = (0 > j-mu) ? 0 : j-mu;        /* colum nonzero bounds */
+      ie = (M-1 < j+ml) ? M-1 : j+ml;
+      for (i=is; i<=ie; i++) {           /* loop over rows */
+	BAND_ELEM(A,i,j) += BAND_ELEM(Mass,i,j);
+      }
+    }
+
+  } else {
+    AddIdentity(arkdls_mem->d_M);
+  }
+
+  /* Do LU factorization of M */
+  ier = BandGBTRF(arkdls_mem->d_M, arkdls_mem->d_lpivots);
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  if (ier > 0) {
+    arkdls_mem->d_last_flag = ier;
+    return(1);
+  }
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkBandSolve:
+
+ This routine handles the solve operation for the band linear solver
+ by calling the band backsolve routine.  The return value is 0.
+---------------------------------------------------------------*/
+static int arkBandSolve(ARKodeMem ark_mem, N_Vector b, N_Vector weight,
+                       N_Vector ycur, N_Vector fcur)
+{
+  ARKDlsMem arkdls_mem;
+  realtype *bd;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  bd = N_VGetArrayPointer(b);
+
+  BandGBTRS(arkdls_mem->d_M, arkdls_mem->d_lpivots, bd);
+
+  /* scale the correction to account for change in gamma */
+  if (ark_mem->ark_gamrat != ONE) 
+    N_VScale(TWO/(ONE + ark_mem->ark_gamrat), b, b);
+
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkBandFree:
+
+ This routine frees memory specific to the band linear solver.
+---------------------------------------------------------------*/
+static int arkBandFree(ARKodeMem ark_mem)
+{
+  ARKDlsMem arkdls_mem;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  DestroyMat(arkdls_mem->d_M);
+  DestroyMat(arkdls_mem->d_savedJ);
+  DestroyArray(arkdls_mem->d_lpivots);
+  free(arkdls_mem);
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+
+/*---------------------------------------------------------------
+ ARKMassBand:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the band mass matrix linear solver 
+ module.  ARKMassBand first calls the existing mfree routine if 
+ this is not NULL.  It then sets the ark_minit, ark_msetup, 
+ ark_msolve, and ark_mfree fields in (*arkode_mem) to be 
+ arkMassBandInit, arkMassBandSetup, arkMassBandSolve, and 
+ arkMassBandFree, respectively.  It allocates memory for a 
+ structure of type ARKDlsMassMemRec and sets the ark_mass_mem 
+ field in (*arkode_mem) to the address of this structure.  It 
+ sets MassSetupNonNull in (*arkode_mem) to be TRUE, d_mu to be 
+ mupper and d_ml to be mlower. Finally, it allocates memory for 
+ M and pivot.  The ARKMassBand return value is SUCCESS = 0, 
+ LMEM_FAIL = -1, or LIN_ILL_INPUT = -2.
+
+ NOTE: The band linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKMassBand will first 
+       test for compatible a compatible N_Vector internal
+       representation by checking that the function 
+       N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+int ARKMassBand(void *arkode_mem, long int N, long int mupper, 
+		long int mlower, ARKDlsBandMassFn bmass)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKBAND", "ARKMassBand", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the BAND solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKBAND", "ARKMassBand", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = arkMassBandInit;
+  ark_mem->ark_msetup = arkMassBandSetup;
+  ark_mem->ark_msolve = arkMassBandSolve;
+  ark_mem->ark_mfree  = arkMassBandFree;
+  ark_mem->ark_mtimes = arkMassBandMultiply;
+  ark_mem->ark_mtimes_data = (void *) ark_mem;
+  ark_mem->ark_msolve_type = 2;
+  
+  /* Get memory for ARKDlsMassMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMassMem) malloc(sizeof(struct ARKDlsMassMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKMassBand", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_BAND;
+  
+  /* Initialize mass-matrix-related data */
+  arkdls_mem->d_nme = 0;
+  arkdls_mem->d_bmass = bmass;
+  arkdls_mem->d_M_data = NULL;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = TRUE;
+
+  /* Load problem dimension */
+  arkdls_mem->d_n = N;
+
+  /* Load half-bandwiths in arkdls_mem */
+  arkdls_mem->d_ml = mlower;
+  arkdls_mem->d_mu = mupper;
+
+  /* Test ml and mu for legality */
+  if ((arkdls_mem->d_ml < 0) || (arkdls_mem->d_mu < 0) || (arkdls_mem->d_ml >= N) || (arkdls_mem->d_mu >= N)) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKBAND", "ARKMassBand", MSGD_BAD_SIZES);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  /* Set extended upper half-bandwith for M (required for pivoting) */
+  arkdls_mem->d_smu = SUNMIN(N-1, arkdls_mem->d_mu + arkdls_mem->d_ml);
+
+  /* Allocate memory for M, M_lu, and pivot arrays */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_M = NewBandMat(N, arkdls_mem->d_mu, arkdls_mem->d_ml, arkdls_mem->d_mu);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKMassBand", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_M_lu = NULL;
+  arkdls_mem->d_M_lu = NewBandMat(N, arkdls_mem->d_mu, arkdls_mem->d_ml, arkdls_mem->d_smu);
+  if (arkdls_mem->d_M_lu == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKMassBand", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_lpivots = NULL;
+  arkdls_mem->d_lpivots = NewLintArray(N);
+  if (arkdls_mem->d_lpivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKBAND", "ARKMassBand", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    DestroyMat(arkdls_mem->d_M_lu);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassBandInit:
+
+ This routine does remaining initializations specific to the band
+ mass matrix linear solver.
+---------------------------------------------------------------*/
+static int arkMassBandInit(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem arkdls_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  arkdls_mem->d_nme = 0;
+
+  /* Set mass matrix data */
+  arkdls_mem->d_M_data = ark_mem->ark_user_data;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassBandSetup:
+
+ This routine does the setup operations for the band mass matrix
+ solver. It constructs the mass matrix, M, updates counters, 
+ and calls the band LU factorization routine.
+---------------------------------------------------------------*/
+static int arkMassBandSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			    N_Vector vtemp2, N_Vector vtemp3)
+{
+  long int ier;
+  ARKDlsMassMem arkdls_mem;
+  int retval;
+
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  SetToZero(arkdls_mem->d_M); 
+  retval = arkdls_mem->d_bmass(arkdls_mem->d_n, arkdls_mem->d_mu, 
+			       arkdls_mem->d_ml, ark_mem->ark_tn, 
+			       arkdls_mem->d_M, arkdls_mem->d_M_data, 
+			       vtemp1, vtemp2, vtemp3);
+  arkdls_mem->d_nme++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKBAND", "arkMassBandSetup", 
+		    MSGD_MASSFUNC_FAILED);
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+    return(-1);
+  }
+  if (retval > 0) {
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+    return(1);
+  }
+
+  /* Copy M into M_lu for LU decomposition */
+  BandCopy(arkdls_mem->d_M, arkdls_mem->d_M_lu, arkdls_mem->d_mu, arkdls_mem->d_ml);
+
+  /* Do LU factorization of M */
+  ier = BandGBTRF(arkdls_mem->d_M_lu, arkdls_mem->d_lpivots);
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  if (ier > 0) {
+    arkdls_mem->d_last_flag = ier;
+    return(1);
+  }
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassBandSolve:
+
+ This routine handles the solve operation for the band mass 
+ matrix solver by calling the band backsolve routine.  The 
+ return value is 0.
+---------------------------------------------------------------*/
+static int arkMassBandSolve(ARKodeMem ark_mem, N_Vector b, 
+			    N_Vector weight)
+{
+  ARKDlsMassMem arkdls_mem;
+  realtype *bd;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  bd = N_VGetArrayPointer(b);
+  BandGBTRS(arkdls_mem->d_M_lu, arkdls_mem->d_lpivots, bd);
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassBandFree:
+
+ This routine frees memory specific to the band linear solver.
+---------------------------------------------------------------*/
+static int arkMassBandFree(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem arkdls_mem;
+
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  DestroyMat(arkdls_mem->d_M);
+  DestroyMat(arkdls_mem->d_M_lu);
+  DestroyArray(arkdls_mem->d_lpivots);
+  free(arkdls_mem);
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassBandMultiply performs a matrix-vector product, 
+ multiplying the current mass matrix by a given vector.
+---------------------------------------------------------------*/                  
+static int arkMassBandMultiply(N_Vector v, N_Vector Mv, 
+			       realtype t, void *arkode_mem)
+{
+  /* extract the DlsMassMem structure from the user_data pointer */
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+  realtype *vdata=NULL, *Mvdata=NULL;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKBAND", 
+		    "arkMassBandMultiply", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  /* access the vector arrays (since they must be serial vectors) */
+  vdata = N_VGetArrayPointer(v);
+  Mvdata = N_VGetArrayPointer(Mv);
+  if (vdata == NULL || Mvdata == NULL)
+    return(1);
+
+  /* perform matrix-vector product and return */
+  BandMatvec(arkdls_mem->d_M, vdata, Mvdata);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+    EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_bandpre.c b/src/arkode/arkode_bandpre.c
new file mode 100644
index 0000000..5757f17
--- /dev/null
+++ b/src/arkode/arkode_bandpre.c
@@ -0,0 +1,465 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This file contains implementations of the banded difference
+ * quotient Jacobian-based preconditioner and solver routines for
+ * use with the ARKSPILS linear solvers..
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode_impl.h"
+#include "arkode_bandpre_impl.h"
+#include "arkode_spils_impl.h"
+#include <sundials/sundials_math.h>
+
+#define MIN_INC_MULT RCONST(1000.0)
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+
+
+/* Prototypes of ARKBandPrecSetup and ARKBandPrecSolve */
+static int ARKBandPrecSetup(realtype t, N_Vector y, N_Vector fy, 
+			    booleantype jok, booleantype *jcurPtr, 
+			    realtype gamma, void *bp_data,
+			    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+static int ARKBandPrecSolve(realtype t, N_Vector y, N_Vector fy, 
+			    N_Vector r, N_Vector z, 
+			    realtype gamma, realtype delta,
+			    int lr, void *bp_data, N_Vector tmp);
+
+/* Prototype for ARKBandPrecFree */
+static int ARKBandPrecFree(ARKodeMem ark_mem);
+
+/* Prototype for difference quotient Jacobian calculation routine */
+static int ARKBandPDQJac(ARKBandPrecData pdata,
+			 realtype t, N_Vector y, N_Vector fy, 
+			 N_Vector ftemp, N_Vector ytemp);
+
+
+/*---------------------------------------------------------------
+ Initialization, Free, and Get Functions
+ NOTE: The band linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKBandPrecInit will
+       first test for a compatible N_Vector internal 
+       representation by checking that the function 
+       N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+int ARKBandPrecInit(void *arkode_mem, long int N, 
+		    long int mu, long int ml)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  ARKBandPrecData pdata;
+  long int mup, mlp, storagemu;
+  int flag;
+
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKBANDPRE", "ARKBandPrecInit", MSGBP_MEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if one of the SPILS linear solvers has been attached */
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKBANDPRE", "ARKBandPrecInit", MSGBP_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Test if the NVECTOR package is compatible with the BAND preconditioner */
+  if(ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKBANDPRE", "ARKBandPrecInit", MSGBP_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  pdata = NULL;
+  pdata = (ARKBandPrecData) malloc(sizeof *pdata);  /* Allocate data memory */
+  if (pdata == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBANDPRE", "ARKBandPrecInit", MSGBP_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Load pointers and bandwidths into pdata block. */
+  pdata->arkode_mem = arkode_mem;
+  pdata->N = N;
+  pdata->mu = mup = SUNMIN(N-1, SUNMAX(0,mu));
+  pdata->ml = mlp = SUNMIN(N-1, SUNMAX(0,ml));
+
+  /* Initialize nfeBP counter */
+  pdata->nfeBP = 0;
+
+  /* Allocate memory for saved banded Jacobian approximation. */
+  pdata->savedJ = NULL;
+  pdata->savedJ = NewBandMat(N, mup, mlp, mup);
+  if (pdata->savedJ == NULL) {
+    free(pdata); pdata = NULL;
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBANDPRE", "ARKBandPrecInit", MSGBP_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Allocate memory for banded preconditioner. */
+  storagemu = SUNMIN(N-1, mup+mlp);
+  pdata->savedP = NULL;
+  pdata->savedP = NewBandMat(N, mup, mlp, storagemu);
+  if (pdata->savedP == NULL) {
+    DestroyMat(pdata->savedJ);
+    free(pdata); pdata = NULL;
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBANDPRE", "ARKBandPrecInit", MSGBP_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Allocate memory for pivot array. */
+  pdata->lpivots = NULL;
+  pdata->lpivots = NewLintArray(N);
+  if (pdata->lpivots == NULL) {
+    DestroyMat(pdata->savedP);
+    DestroyMat(pdata->savedJ);
+    free(pdata); pdata = NULL;
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBANDPRE", "ARKBandPrecInit", MSGBP_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* make sure s_P_data is free from any previous allocations */
+  if (arkspils_mem->s_pfree != NULL) {
+    arkspils_mem->s_pfree(ark_mem);
+  }
+
+  /* Point to the new P_data field in the SPILS memory */
+  arkspils_mem->s_P_data = pdata;
+
+  /* Attach the pfree function */
+  arkspils_mem->s_pfree = ARKBandPrecFree;
+
+  /* Attach preconditioner solve and setup functions */
+  flag = ARKSpilsSetPreconditioner(arkode_mem, ARKBandPrecSetup, ARKBandPrecSolve);
+
+  return(flag);
+}
+
+
+int ARKBandPrecGetWorkSpace(void *arkode_mem, long int *lenrwBP, long int *leniwBP)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  ARKBandPrecData pdata;
+  long int N, ml, mu, smu;
+
+  
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKBANDPRE", "ARKBandPrecGetWorkSpace", MSGBP_MEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKBANDPRE", "ARKBandPrecGetWorkSpace", MSGBP_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  if (arkspils_mem->s_P_data == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_PMEM_NULL, "ARKBANDPRE", "ARKBandPrecGetWorkSpace", MSGBP_PMEM_NULL);
+    return(ARKSPILS_PMEM_NULL);
+  } 
+  pdata = (ARKBandPrecData) arkspils_mem->s_P_data;
+
+  N   = pdata->N;
+  mu  = pdata->mu;
+  ml  = pdata->ml;
+  smu = SUNMIN( N-1, mu + ml);
+
+  *leniwBP = pdata->N;
+  *lenrwBP = N * ( 2*ml + smu + mu + 2 );
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+int ARKBandPrecGetNumRhsEvals(void *arkode_mem, long int *nfevalsBP)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  ARKBandPrecData pdata;
+
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKBANDPRE", "ARKBandPrecGetNumRhsEvals", MSGBP_MEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKBANDPRE", "ARKBandPrecGetNumRhsEvals", MSGBP_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  if (arkspils_mem->s_P_data == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_PMEM_NULL, "ARKBANDPRE", "ARKBandPrecGetNumRhsEvals", MSGBP_PMEM_NULL);
+    return(ARKSPILS_PMEM_NULL);
+  } 
+  pdata = (ARKBandPrecData) arkspils_mem->s_P_data;
+
+  *nfevalsBP = pdata->nfeBP;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKBandPrecSetup:
+
+ Together ARKBandPrecSetup and ARKBandPrecSolve use a banded
+ difference quotient Jacobian to create a preconditioner.
+ ARKBandPrecSetup calculates a new J, if necessary, then
+ calculates P = I - gamma*J, and does an LU factorization of P.
+
+ The parameters of ARKBandPrecSetup are as follows:
+
+ t       is the current value of the independent variable.
+
+ y       is the current value of the dependent variable vector,
+         namely the predicted value of y(t).
+
+ fy      is the vector f(t,y).
+
+ jok     is an input flag indicating whether Jacobian-related
+         data needs to be recomputed, as follows:
+           jok == FALSE means recompute Jacobian-related data
+                  from scratch.
+           jok == TRUE means that Jacobian data from the
+                  previous PrecSetup call will be reused
+                  (with the current value of gamma).
+         A ARKBandPrecSetup call with jok == TRUE should only
+         occur after a call with jok == FALSE.
+
+ *jcurPtr is a pointer to an output integer flag which is
+          set by ARKBandPrecond as follows:
+            *jcurPtr = TRUE if Jacobian data was recomputed.
+            *jcurPtr = FALSE if Jacobian data was not recomputed,
+                       but saved data was reused.
+
+ gamma   is the scalar appearing in the Newton matrix.
+
+ bp_data is a pointer to preconditoner data (set by ARKBandPrecInit)
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated
+           for vectors of length N for work space. This
+           routine uses only tmp1 and tmp2.
+
+ The value to be returned by the ARKBandPrecSetup function is
+   0  if successful, or
+   1  if the band factorization failed.
+---------------------------------------------------------------*/
+static int ARKBandPrecSetup(realtype t, N_Vector y, N_Vector fy, 
+                           booleantype jok, booleantype *jcurPtr, 
+                           realtype gamma, void *bp_data,
+                           N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  ARKBandPrecData pdata;
+  ARKodeMem ark_mem;
+  int retval;
+  long int ier;
+
+  /* Assume matrix and lpivots have already been allocated. */
+  pdata = (ARKBandPrecData) bp_data;
+
+  ark_mem = (ARKodeMem) pdata->arkode_mem;
+
+  if (jok) {
+
+    /* If jok = TRUE, use saved copy of J. */
+    *jcurPtr = FALSE;
+    BandCopy(pdata->savedJ, pdata->savedP, pdata->mu, pdata->ml);
+
+  } else {
+
+    /* If jok = FALSE, call ARKBandPDQJac for new J value. */
+    *jcurPtr = TRUE;
+    SetToZero(pdata->savedJ);
+
+    retval = ARKBandPDQJac(pdata, t, y, fy, tmp1, tmp2);
+    if (retval < 0) {
+      arkProcessError(ark_mem, -1, "ARKBANDPRE", "ARKBandPrecSetup", MSGBP_RHSFUNC_FAILED);
+      return(-1);
+    }
+    if (retval > 0) {
+      return(1);
+    }
+
+    BandCopy(pdata->savedJ, pdata->savedP, pdata->mu, pdata->ml);
+
+  }
+  
+  /* Scale and add I to get savedP = I - gamma*J. */
+  BandScale(-gamma, pdata->savedP);
+  AddIdentity(pdata->savedP);
+ 
+  /* Do LU factorization of matrix. */
+  ier = BandGBTRF(pdata->savedP, pdata->lpivots);
+ 
+  /* Return 0 if the LU was complete; otherwise return 1. */
+  if (ier > 0) return(1);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKBandPrecSolve:
+
+ ARKBandPrecSolve solves a linear system P z = r, where P is the
+ matrix computed by ARKBandPrecond.
+
+ The parameters of ARKBandPrecSolve used here are as follows:
+
+ r is the right-hand side vector of the linear system.
+
+ bp_data is a pointer to preconditoner data (set by ARKBandPrecInit)
+
+ z is the output vector computed by ARKBandPrecSolve.
+
+ The value returned by the ARKBandPrecSolve function is always 0,
+ indicating success.
+---------------------------------------------------------------*/ 
+static int ARKBandPrecSolve(realtype t, N_Vector y, N_Vector fy, 
+                           N_Vector r, N_Vector z, 
+                           realtype gamma, realtype delta,
+                           int lr, void *bp_data, N_Vector tmp)
+{
+  ARKBandPrecData pdata;
+  realtype *zd;
+
+  /* Assume matrix and lpivots have already been allocated. */
+  pdata = (ARKBandPrecData) bp_data;
+
+  /* Copy r to z. */
+  N_VScale(ONE, r, z);
+
+  /* Do band backsolve on the vector z. */
+  zd = N_VGetArrayPointer(z);
+
+  BandGBTRS(pdata->savedP, pdata->lpivots, zd);
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKBandPrecFree:
+
+ Frees data associated with the ARKBand preconditioner.
+---------------------------------------------------------------*/ 
+static int ARKBandPrecFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  ARKBandPrecData pdata;
+
+  if (ark_mem->ark_lmem == NULL) return(0);
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  
+  if (arkspils_mem->s_P_data == NULL) return(0);
+  pdata = (ARKBandPrecData) arkspils_mem->s_P_data;
+
+  DestroyMat(pdata->savedJ);
+  DestroyMat(pdata->savedP);
+  DestroyArray(pdata->lpivots);
+
+  free(pdata);
+  pdata = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKBandPDQJac:
+
+ This routine generates a banded difference quotient approximation to
+ the Jacobian of f(t,y). It assumes that a band matrix of type
+ DlsMat is stored column-wise, and that elements within each column
+ are contiguous. This makes it possible to get the address of a column
+ of J via the macro BAND_COL and to write a simple for loop to set
+ each of the elements of a column in succession.
+---------------------------------------------------------------*/
+static int ARKBandPDQJac(ARKBandPrecData pdata, 
+			 realtype t, N_Vector y, N_Vector fy, 
+			 N_Vector ftemp, N_Vector ytemp)
+{
+  ARKodeMem ark_mem;
+  realtype fnorm, minInc, inc, inc_inv, srur;
+  long int group, i, j, width, ngroups, i1, i2;
+  realtype *col_j, *ewt_data, *fy_data, *ftemp_data, *y_data, *ytemp_data;
+  int retval;
+
+  ark_mem = (ARKodeMem) pdata->arkode_mem;
+
+  /* Obtain pointers to the data for ewt, fy, ftemp, y, ytemp. */
+  ewt_data   = N_VGetArrayPointer(ark_mem->ark_ewt);
+  fy_data    = N_VGetArrayPointer(fy);
+  ftemp_data = N_VGetArrayPointer(ftemp);
+  y_data     = N_VGetArrayPointer(y);
+  ytemp_data = N_VGetArrayPointer(ytemp);
+
+  /* Load ytemp with y = predicted y vector. */
+  N_VScale(ONE, y, ytemp);
+
+  /* Set minimum increment based on uround and norm of f. */
+  srur = SUNRsqrt(ark_mem->ark_uround);
+  /* fnorm = N_VWrmsNorm(fy, ark_mem->ark_ewt); */
+  fnorm = N_VWrmsNorm(fy, ark_mem->ark_rwt);
+  minInc = (fnorm != ZERO) ?
+    (MIN_INC_MULT * SUNRabs(ark_mem->ark_h) * ark_mem->ark_uround * pdata->N * fnorm) : ONE;
+
+  /* Set bandwidth and number of column groups for band differencing. */
+  width = pdata->ml + pdata->mu + 1;
+  ngroups = SUNMIN(width, pdata->N);
+  
+  for (group = 1; group <= ngroups; group++) {
+    
+    /* Increment all y_j in group. */
+    for(j = group-1; j < pdata->N; j += width) {
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
+      ytemp_data[j] += inc;
+    }
+
+    /* Evaluate f with incremented y. */
+    retval = ark_mem->ark_fi(t, ytemp, ftemp, ark_mem->ark_user_data);
+    pdata->nfeBP++;
+    if (retval != 0) return(retval);
+
+    /* Restore ytemp, then form and load difference quotients. */
+    for (j = group-1; j < pdata->N; j += width) {
+      ytemp_data[j] = y_data[j];
+      col_j = BAND_COL(pdata->savedJ,j);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
+      inc_inv = ONE/inc;
+      i1 = SUNMAX(0, j-pdata->mu);
+      i2 = SUNMIN(j+pdata->ml, pdata->N-1);
+      for (i=i1; i <= i2; i++)
+        BAND_COL_ELEM(col_j,i,j) =
+          inc_inv * (ftemp_data[i] - fy_data[i]);
+    }
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+   EOF
+---------------------------------------------------------------*/ 
diff --git a/src/arkode/arkode_bandpre_impl.h b/src/arkode/arkode_bandpre_impl.h
new file mode 100644
index 0000000..6c65b69
--- /dev/null
+++ b/src/arkode/arkode_bandpre_impl.h
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation header file for the ARKBANDPRE module.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKBANDPRE_IMPL_H
+#define _ARKBANDPRE_IMPL_H
+
+#include <arkode/arkode_bandpre.h>
+#include <sundials/sundials_band.h>
+#include <sundials/sundials_direct.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ Type: ARKBandPrecData
+---------------------------------------------------------------*/
+
+typedef struct ARKBandPrecDataRec {
+
+  /* Data set by user in ARKBandPrecInit */
+  long int N;
+  long int ml, mu;
+
+  /* Data set by ARKBandPrecSetup */
+  DlsMat savedJ;
+  DlsMat savedP;
+  long int *lpivots;
+
+  /* Rhs calls */
+  long int nfeBP;
+
+  /* Pointer to arkode_mem */
+  void *arkode_mem;
+
+} *ARKBandPrecData;
+
+
+/*---------------------------------------------------------------
+ ARKBANDPRE error messages
+---------------------------------------------------------------*/
+
+#define MSGBP_MEM_NULL       "Integrator memory is NULL."
+#define MSGBP_LMEM_NULL      "Linear solver memory is NULL. One of the SPILS linear solvers must be attached."
+#define MSGBP_MEM_FAIL       "A memory request failed."
+#define MSGBP_BAD_NVECTOR    "A required vector operation is not implemented."
+#define MSGBP_PMEM_NULL      "Band preconditioner memory is NULL. ARKBandPrecInit must be called."
+#define MSGBP_RHSFUNC_FAILED "The right-hand side routine failed in an unrecoverable manner."
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/arkode/arkode_bbdpre.c b/src/arkode/arkode_bbdpre.c
new file mode 100644
index 0000000..8bdb603
--- /dev/null
+++ b/src/arkode/arkode_bbdpre.c
@@ -0,0 +1,547 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This file contains implementations of routines for a
+ * band-block-diagonal preconditioner, i.e. a block-diagonal
+ * matrix with banded blocks, for use with ARKODE, a ARKSPILS 
+ * linear solver, and the parallel implementation of NVECTOR.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode_impl.h"
+#include "arkode_bbdpre_impl.h"
+#include "arkode_spils_impl.h"
+#include <sundials/sundials_math.h>
+
+
+#define MIN_INC_MULT RCONST(1000.0)
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+
+
+/* Prototypes of functions ARKBBDPrecSetup and ARKBBDPrecSolve */
+static int ARKBBDPrecSetup(realtype t, N_Vector y, N_Vector fy, 
+			   booleantype jok, booleantype *jcurPtr, 
+			   realtype gamma, void *bbd_data, 
+			   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+static int ARKBBDPrecSolve(realtype t, N_Vector y, N_Vector fy, 
+			   N_Vector r, N_Vector z, 
+			   realtype gamma, realtype delta,
+			   int lr, void *bbd_data, N_Vector tmp);
+
+/* Prototype for ARKBBDPrecFree */
+static int ARKBBDPrecFree(ARKodeMem ark_mem);
+
+/* Prototype for difference quotient Jacobian calculation routine */
+static int ARKBBDDQJac(ARKBBDPrecData pdata, realtype t, 
+		       N_Vector y, N_Vector gy, 
+		       N_Vector ytemp, N_Vector gtemp);
+
+
+/*---------------------------------------------------------------
+ User-Callable Functions: initialization, reinit and free
+---------------------------------------------------------------*/
+int ARKBBDPrecInit(void *arkode_mem, long int Nlocal, 
+                   long int mudq, long int mldq,
+                   long int mukeep, long int mlkeep, 
+                   realtype dqrely, 
+                   ARKLocalFn gloc, ARKCommFn cfn)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  ARKBBDPrecData pdata;
+  long int muk, mlk, storage_mu;
+  int flag;
+
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecInit", MSGBBD_MEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if one of the SPILS linear solvers has been attached */
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecInit", MSGBBD_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Test if the NVECTOR package is compatible with the BLOCK 
+     BAND preconditioner */
+  if(ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKBBDPRE", 
+		    "ARKBBDPrecInit", MSGBBD_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate data memory */
+  pdata = NULL;
+  pdata = (ARKBBDPrecData) malloc(sizeof *pdata);  
+  if (pdata == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBBDPRE", 
+		    "ARKBBDPrecInit", MSGBBD_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set pointers to gloc and cfn; load half-bandwidths */
+  pdata->arkode_mem = arkode_mem;
+  pdata->gloc = gloc;
+  pdata->cfn = cfn;
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0,mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0,mldq));
+  muk = SUNMIN(Nlocal-1, SUNMAX(0,mukeep));
+  mlk = SUNMIN(Nlocal-1, SUNMAX(0,mlkeep));
+  pdata->mukeep = muk;
+  pdata->mlkeep = mlk;
+
+  /* Allocate memory for saved Jacobian */
+  pdata->savedJ = NewBandMat(Nlocal, muk, mlk, muk);
+  if (pdata->savedJ == NULL) { 
+    free(pdata); pdata = NULL; 
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBBDPRE", 
+		    "ARKBBDPrecInit", MSGBBD_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL); 
+  }
+
+  /* Allocate memory for preconditioner matrix */
+  storage_mu = SUNMIN(Nlocal-1, muk + mlk);
+  pdata->savedP = NULL;
+  pdata->savedP = NewBandMat(Nlocal, muk, mlk, storage_mu);
+  if (pdata->savedP == NULL) {
+    DestroyMat(pdata->savedJ);
+    free(pdata); pdata = NULL;
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBBDPRE", 
+		    "ARKBBDPrecInit", MSGBBD_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+  /* Allocate memory for lpivots */
+  pdata->lpivots = NULL;
+  pdata->lpivots = NewLintArray(Nlocal);
+  if (pdata->lpivots == NULL) {
+    DestroyMat(pdata->savedP);
+    DestroyMat(pdata->savedJ);
+    free(pdata); pdata = NULL;
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKBBDPRE", 
+		    "ARKBBDPrecInit", MSGBBD_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set pdata->dqrely based on input dqrely (0 implies default). */
+  pdata->dqrely = (dqrely > ZERO) ? dqrely : SUNRsqrt(ark_mem->ark_uround);
+
+  /* Store Nlocal to be used in ARKBBDPrecSetup */
+  pdata->n_local = Nlocal;
+
+  /* Set work space sizes and initialize nge */
+  pdata->rpwsize = Nlocal*(muk + 2*mlk + storage_mu + 2);
+  pdata->ipwsize = Nlocal;
+  pdata->nge = 0;
+
+  /* make sure s_P_data is free from any previous allocations */
+  if (arkspils_mem->s_pfree != NULL) {
+    arkspils_mem->s_pfree(ark_mem);
+  }
+
+  /* Point to the new P_data field in the SPILS memory */
+  arkspils_mem->s_P_data = pdata;
+
+  /* Attach the pfree function */
+  arkspils_mem->s_pfree = ARKBBDPrecFree;
+
+  /* Attach preconditioner solve and setup functions */
+  flag = ARKSpilsSetPreconditioner(arkode_mem, ARKBBDPrecSetup, 
+				   ARKBBDPrecSolve);
+
+  return(flag);
+}
+
+
+/*-------------------------------------------------------------*/
+int ARKBBDPrecReInit(void *arkode_mem, long int mudq, 
+		     long int mldq, realtype dqrely)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  ARKBBDPrecData pdata;
+  long int Nlocal;
+
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecReInit", MSGBBD_MEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if one of the SPILS linear solvers has been attached */
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecReInit", MSGBBD_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Test if the preconditioner data is non-NULL */
+  if (arkspils_mem->s_P_data == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_PMEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecReInit", MSGBBD_PMEM_NULL);
+    return(ARKSPILS_PMEM_NULL);
+  } 
+  pdata = (ARKBBDPrecData) arkspils_mem->s_P_data;
+
+  /* Load half-bandwidths */
+  Nlocal = pdata->n_local;
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0,mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0,mldq));
+
+  /* Set pdata->dqrely based on input dqrely (0 implies default). */
+  pdata->dqrely = (dqrely > ZERO) ? dqrely : SUNRsqrt(ark_mem->ark_uround);
+
+  /* Re-initialize nge */
+  pdata->nge = 0;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*-------------------------------------------------------------*/
+int ARKBBDPrecGetWorkSpace(void *arkode_mem, long int *lenrwBBDP, 
+			   long int *leniwBBDP)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  ARKBBDPrecData pdata;
+
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecGetWorkSpace", MSGBBD_MEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecGetWorkSpace", MSGBBD_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  if (arkspils_mem->s_P_data == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_PMEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecGetWorkSpace", MSGBBD_PMEM_NULL);
+    return(ARKSPILS_PMEM_NULL);
+  } 
+  pdata = (ARKBBDPrecData) arkspils_mem->s_P_data;
+
+  *lenrwBBDP = pdata->rpwsize;
+  *leniwBBDP = pdata->ipwsize;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*-------------------------------------------------------------*/
+int ARKBBDPrecGetNumGfnEvals(void *arkode_mem, long int *ngevalsBBDP)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  ARKBBDPrecData pdata;
+
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecGetNumGfnEvals", MSGBBD_MEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecGetNumGfnEvals", MSGBBD_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  if (arkspils_mem->s_P_data == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_PMEM_NULL, "ARKBBDPRE", 
+		    "ARKBBDPrecGetNumGfnEvals", MSGBBD_PMEM_NULL);
+    return(ARKSPILS_PMEM_NULL);
+  } 
+  pdata = (ARKBBDPrecData) arkspils_mem->s_P_data;
+
+  *ngevalsBBDP = pdata->nge;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKBBDPrecSetup:
+
+ ARKBBDPrecSetup generates and factors a banded block of the
+ preconditioner matrix on each processor, via calls to the
+ user-supplied gloc and cfn functions. It uses difference
+ quotient approximations to the Jacobian elements.
+
+ ARKBBDPrecSetup calculates a new J,if necessary, then calculates
+ P = I - gamma*J, and does an LU factorization of P.
+
+ The parameters of ARKBBDPrecSetup used here are as follows:
+
+ t       is the current value of the independent variable.
+
+ y       is the current value of the dependent variable vector,
+         namely the predicted value of y(t).
+
+ fy      is the vector f(t,y).
+
+ jok     is an input flag indicating whether Jacobian-related
+         data needs to be recomputed, as follows:
+           jok == FALSE means recompute Jacobian-related data
+                  from scratch.
+           jok == TRUE  means that Jacobian data from the
+                  previous ARKBBDPrecon call can be reused
+                  (with the current value of gamma).
+         A ARKBBDPrecon call with jok == TRUE should only occur
+         after a call with jok == FALSE.
+
+ jcurPtr is a pointer to an output integer flag which is
+         set by ARKBBDPrecon as follows:
+           *jcurPtr = TRUE if Jacobian data was recomputed.
+           *jcurPtr = FALSE if Jacobian data was not recomputed,
+                      but saved data was reused.
+
+ gamma   is the scalar appearing in the Newton matrix.
+
+ bbd_data is a pointer to the preconditioner data set by
+          ARKBBDPrecInit
+
+ tmp1, tmp2, and tmp3 are pointers to memory allocated
+           for NVectors which are be used by ARKBBDPrecSetup
+           as temporary storage or work space.
+
+ Return value:
+ The value returned by this ARKBBDPrecSetup function is the int
+   0  if successful,
+   1  for a recoverable error (step will be retried).
+---------------------------------------------------------------*/
+static int ARKBBDPrecSetup(realtype t, N_Vector y, N_Vector fy, 
+			   booleantype jok, booleantype *jcurPtr, 
+			   realtype gamma, void *bbd_data, 
+			   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  long int ier;
+  ARKBBDPrecData pdata;
+  ARKodeMem ark_mem;
+  int retval;
+
+  pdata = (ARKBBDPrecData) bbd_data;
+
+  ark_mem = (ARKodeMem) pdata->arkode_mem;
+
+  /* If jok = TRUE, use saved copy of J */
+  if (jok) {
+    *jcurPtr = FALSE;
+    BandCopy(pdata->savedJ, pdata->savedP, pdata->mukeep, pdata->mlkeep);
+
+  /* Otherwise call ARKBBDDQJac for new J value */
+  } else {
+    *jcurPtr = TRUE;
+    SetToZero(pdata->savedJ);
+
+    retval = ARKBBDDQJac(pdata, t, y, tmp1, tmp2, tmp3);
+    if (retval < 0) {
+      arkProcessError(ark_mem, -1, "ARKBBDPRE", "ARKBBDPrecSetup", 
+		      MSGBBD_FUNC_FAILED);
+      return(-1);
+    }
+    if (retval > 0) {
+      return(1);
+    }
+    BandCopy(pdata->savedJ, pdata->savedP, pdata->mukeep, pdata->mlkeep);
+
+  }
+  
+  /* Scale and add I to get P = I - gamma*J */
+  BandScale(-gamma, pdata->savedP);
+  AddIdentity(pdata->savedP);
+ 
+  /* Do LU factorization of P in place */
+  ier = BandGBTRF(pdata->savedP, pdata->lpivots);
+ 
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  if (ier > 0) return(1);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKBBDPrecSolve:
+
+ ARKBBDPrecSolve solves a linear system P z = r, with the
+ band-block-diagonal preconditioner matrix P generated and
+ factored by ARKBBDPrecSetup.
+
+ The parameters of ARKBBDPrecSolve used here are as follows:
+
+ r is the right-hand side vector of the linear system.
+
+ bbd_data is a pointer to the preconditioner data set by
+   ARKBBDPrecInit.
+
+ z is the output vector computed by ARKBBDPrecSolve.
+
+ The value returned by the ARKBBDPrecSolve function is always 0,
+ indicating success.
+---------------------------------------------------------------*/
+static int ARKBBDPrecSolve(realtype t, N_Vector y, N_Vector fy, 
+			   N_Vector r, N_Vector z, 
+			   realtype gamma, realtype delta,
+			   int lr, void *bbd_data, N_Vector tmp)
+{
+  ARKBBDPrecData pdata;
+  realtype *zd;
+
+  pdata = (ARKBBDPrecData) bbd_data;
+
+  /* Copy r to z, then do backsolve and return */
+  N_VScale(ONE, r, z);
+  zd = N_VGetArrayPointer(z);
+  BandGBTRS(pdata->savedP, pdata->lpivots, zd);
+
+  return(0);
+}
+
+
+/*-------------------------------------------------------------*/
+static int ARKBBDPrecFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  ARKBBDPrecData pdata;
+  
+  if (ark_mem->ark_lmem == NULL) return(0);
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  
+  if (arkspils_mem->s_P_data == NULL) return(0);
+  pdata = (ARKBBDPrecData) arkspils_mem->s_P_data;
+
+  DestroyMat(pdata->savedJ);
+  DestroyMat(pdata->savedP);
+  DestroyArray(pdata->lpivots);
+
+  free(pdata);
+  pdata = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKBBDDQJac:
+
+ This routine generates a banded difference quotient approximation
+ to the local block of the Jacobian of g(t,y). It assumes that a
+ band matrix of type DlsMat is stored columnwise, and that elements
+ within each column are contiguous. All matrix elements are generated
+ as difference quotients, by way of calls to the user routine gloc.
+ By virtue of the band structure, the number of these calls is
+ bandwidth + 1, where bandwidth = mldq + mudq + 1.
+ But the band matrix kept has bandwidth = mlkeep + mukeep + 1.
+ This routine also assumes that the local elements of a vector are
+ stored contiguously.
+---------------------------------------------------------------*/
+static int ARKBBDDQJac(ARKBBDPrecData pdata, realtype t, 
+		       N_Vector y, N_Vector gy, 
+		       N_Vector ytemp, N_Vector gtemp)
+{
+  ARKodeMem ark_mem;
+  realtype gnorm, minInc, inc, inc_inv;
+  long int group, i, j, width, ngroups, i1, i2;
+  realtype *y_data, *ewt_data, *gy_data, *gtemp_data, *ytemp_data, *col_j;
+  int retval;
+
+  ark_mem = (ARKodeMem) pdata->arkode_mem;
+
+  /* Load ytemp with y = predicted solution vector */
+  N_VScale(ONE, y, ytemp);
+
+  /* Call cfn and gloc to get base value of g(t,y) */
+  if (pdata->cfn != NULL) {
+    retval = pdata->cfn(pdata->n_local, t, y, ark_mem->ark_user_data);
+    if (retval != 0) return(retval);
+  }
+
+  retval = pdata->gloc(pdata->n_local, t, ytemp, gy, ark_mem->ark_user_data);
+  pdata->nge++;
+  if (retval != 0) return(retval);
+
+  /* Obtain pointers to the data for various vectors */
+  y_data     =  N_VGetArrayPointer(y);
+  gy_data    =  N_VGetArrayPointer(gy);
+  ewt_data   =  N_VGetArrayPointer(ark_mem->ark_ewt);
+  ytemp_data =  N_VGetArrayPointer(ytemp);
+  gtemp_data =  N_VGetArrayPointer(gtemp);
+
+  /* Set minimum increment based on uround and norm of g */
+  /* gnorm = N_VWrmsNorm(gy, ark_mem->ark_ewt); */
+  gnorm = N_VWrmsNorm(gy, ark_mem->ark_rwt);
+  minInc = (gnorm != ZERO) ? (MIN_INC_MULT * SUNRabs(ark_mem->ark_h) *
+			      ark_mem->ark_uround * pdata->n_local * gnorm) : ONE;
+
+  /* Set bandwidth and number of column groups for band differencing */
+  width = pdata->mldq + pdata->mudq + 1;
+  ngroups = SUNMIN(width, pdata->n_local);
+
+  /* Loop over groups */  
+  for (group=1; group <= ngroups; group++) {
+    
+    /* Increment all y_j in group */
+    for(j=group-1; j < pdata->n_local; j+=width) {
+      inc = SUNMAX(pdata->dqrely*SUNRabs(y_data[j]), minInc/ewt_data[j]);
+      ytemp_data[j] += inc;
+    }
+
+    /* Evaluate g with incremented y */
+    retval = pdata->gloc(pdata->n_local, t, ytemp, gtemp, 
+			 ark_mem->ark_user_data);
+    pdata->nge++;
+    if (retval != 0) return(retval);
+
+    /* Restore ytemp, then form and load difference quotients */
+    for (j=group-1; j < pdata->n_local; j+=width) {
+      ytemp_data[j] = y_data[j];
+      col_j = BAND_COL(pdata->savedJ,j);
+      inc = SUNMAX(pdata->dqrely*SUNRabs(y_data[j]), minInc/ewt_data[j]);
+      inc_inv = ONE/inc;
+      i1 = SUNMAX(0, j-pdata->mukeep);
+      i2 = SUNMIN(j+pdata->mlkeep, pdata->n_local-1);
+      for (i=i1; i <= i2; i++)
+        BAND_COL_ELEM(col_j,i,j) =
+          inc_inv * (gtemp_data[i] - gy_data[i]);
+    }
+  }
+
+  return(0);
+}
+
+
+
+/*---------------------------------------------------------------
+    EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_bbdpre_impl.h b/src/arkode/arkode_bbdpre_impl.h
new file mode 100644
index 0000000..d546867
--- /dev/null
+++ b/src/arkode/arkode_bbdpre_impl.h
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation header file for the ARKBBDPRE module.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKBBDPRE_IMPL_H
+#define _ARKBBDPRE_IMPL_H
+
+#include <arkode/arkode_bbdpre.h>
+#include <sundials/sundials_band.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*---------------------------------------------------------------
+ Type: ARKBBDPrecData
+---------------------------------------------------------------*/
+typedef struct ARKBBDPrecDataRec {
+
+  /* passed by user to ARKBBDPrecAlloc and used by PrecSetup/PrecSolve */
+  long int mudq, mldq, mukeep, mlkeep;
+  realtype dqrely;
+  ARKLocalFn gloc;
+  ARKCommFn cfn;
+
+  /* set by ARKBBDPrecSetup and used by ARKBBDPrecSolve */
+  DlsMat savedJ;
+  DlsMat savedP;
+  long int *lpivots;
+
+  /* set by ARKBBDPrecAlloc and used by ARKBBDPrecSetup */
+  long int n_local;
+
+  /* available for optional output */
+  long int rpwsize;
+  long int ipwsize;
+  long int nge;
+
+  /* pointer to arkode_mem */
+  void *arkode_mem;
+
+} *ARKBBDPrecData;
+
+
+/*---------------------------------------------------------------
+ ARKBBDPRE error messages
+---------------------------------------------------------------*/
+
+#define MSGBBD_MEM_NULL    "Integrator memory is NULL."
+#define MSGBBD_LMEM_NULL   "Linear solver memory is NULL. One of the SPILS linear solvers must be attached."
+#define MSGBBD_MEM_FAIL    "A memory request failed."
+#define MSGBBD_BAD_NVECTOR "A required vector operation is not implemented."
+#define MSGBBD_PMEM_NULL   "BBD peconditioner memory is NULL. ARKBBDPrecInit must be called."
+#define MSGBBD_FUNC_FAILED "The gloc or cfn routine failed in an unrecoverable manner."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/arkode/arkode_butcher.c b/src/arkode/arkode_butcher.c
new file mode 100644
index 0000000..065dabf
--- /dev/null
+++ b/src/arkode/arkode_butcher.c
@@ -0,0 +1,1038 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the known Butcher tables 
+ * for the ARKODE solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode_impl.h"
+#include <sundials/sundials_math.h>
+#include <sundials/sundials_types.h>
+
+
+/*---------------------------------------------------------------
+ Returns butcher table for Runge Kutta methods.  
+ Input:
+     imeth -- integer key for the desired method (see below)
+ Outputs:
+     s -- int number of stages for the requested method [s <= ARK_S_MAX = 8]
+     q -- integer, theoretical order of accuracy for the method
+     p -- integer, theoretical order of accuracy for the embedding
+     A[s][s] -- realtype Butcher table coefficients
+     b[s] -- realtype root node coefficients
+     c[s] -- realtype canopy node coefficients
+     b2[s] -- realtype embedding coefficients
+
+ Allowed 'method' names and properties (those in an ARK pair are marked 
+ with a *).  All method names are of the form <name>_s_p_q:
+
+   imeth                       type  A-stable  L-stable
+  ------------------------------------------------------
+   HEUN_EULER_2_1_2             ERK     N         N 
+   BOGACKI_SHAMPINE_4_2_3       ERK     N         N 
+   ARK324L2SA_ERK_4_2_3*        ERK     N         N 
+   ZONNEVELD_5_3_4              ERK     N         N 
+   ARK436L2SA_ERK_6_3_4*        ERK     N         N 
+   SAYFY_ABURUB_6_3_4           ERK     N         N 
+   CASH_KARP_6_4_5              ERK     N         N 
+   FEHLBERG_6_4_5               ERK     N         N 
+   DORMAND_PRINCE_7_4_5         ERK     N         N 
+   ARK548L2SA_ERK_8_4_5*        ERK     N         N 
+   VERNER_8_5_6                 ERK     N         N 
+   FEHLBERG_13_7_8              ERK     N         N 
+   SDIRK_2_1_2                SDIRK     Y         N 
+   BILLINGTON_3_3_2           SDIRK     N         N
+   TRBDF2_3_3_2              ESDIRK     N         N
+   KVAERNO_4_2_3             ESDIRK     Y         Y
+   ARK324L2SA_DIRK_4_2_3*    ESDIRK     Y         Y 
+   CASH_5_2_4                 SDIRK     Y         Y 
+   CASH_5_3_4                 SDIRK     Y         Y  
+   SDIRK_5_3_4                SDIRK     Y         Y  
+   KVAERNO_5_3_4             ESDIRK     Y         N 
+   ARK436L2SA_DIRK_6_3_4*    ESDIRK     Y         Y  
+   KVAERNO_7_4_5             ESDIRK     Y         Y  
+   ARK548L2SA_DIRK_8_4_5*    ESDIRK     Y         Y  
+  ------------------------------------------------------
+
+---------------------------------------------------------------*/
+int ARKodeLoadButcherTable(int imethod, int *s, int *q, int *p, 
+			   realtype *A, realtype *b, 
+			   realtype *c, realtype *b2) 
+{
+
+  int i, j;
+  realtype one = RCONST(1.0);
+  realtype two = RCONST(2.0);
+  realtype three = RCONST(3.0);
+  realtype four = RCONST(4.0);
+  realtype six = RCONST(6.0);
+  realtype sqrt2 = SUNRsqrt(two);
+
+  /* initialize output tables to zero */
+  for (i=0; i<ARK_S_MAX; i++) {
+    b[i]  = ZERO;
+    c[i]  = ZERO;
+    b2[i] = ZERO;
+    for (j=0; j<ARK_S_MAX; j++)  ARK_A(A,i,j) = ZERO;
+  }
+
+  /* fill in coefficients based on method name */
+  switch(imethod) {
+
+  case(HEUN_EULER_2_1_2):    /* Heun-Euler-ERK */
+    *s = 2;
+    *q = 2;
+    *p = 1;
+      
+    ARK_A(A,1,0) = RCONST(1.0);
+
+    b[0] = RCONST(0.5);
+    b[1] = RCONST(0.5);
+
+    b2[0] = RCONST(1.0);
+
+    c[1] = RCONST(1.0);
+    break;
+
+  case(BOGACKI_SHAMPINE_4_2_3):    /* Bogacki-Shampine-ERK */
+    *s = 4;
+    *q = 3;
+    *p = 2;
+    ARK_A(A,1,0) = RCONST(1.0)/RCONST(2.0);
+    ARK_A(A,2,1) = RCONST(3.0)/RCONST(4.0);
+    ARK_A(A,3,0) = RCONST(2.0)/RCONST(9.0);
+    ARK_A(A,3,1) = RCONST(1.0)/RCONST(3.0);
+    ARK_A(A,3,2) = RCONST(4.0)/RCONST(9.0);
+
+    b[0] = RCONST(2.0)/RCONST(9.0);
+    b[1] = RCONST(1.0)/RCONST(3.0);
+    b[2] = RCONST(4.0)/RCONST(9.0);
+
+    b2[0] = RCONST(7.0)/RCONST(24.0);
+    b2[1] = RCONST(1.0)/RCONST(4.0);
+    b2[2] = RCONST(1.0)/RCONST(3.0);
+    b2[3] = RCONST(1.0)/RCONST(8.0);
+
+    c[1] = RCONST(1.0)/RCONST(2.0);
+    c[2] = RCONST(3.0)/RCONST(4.0);
+    c[3] = RCONST(1.0);
+    break;
+
+  case(ARK324L2SA_ERK_4_2_3):    /* ARK3(2)4L[2]SA-ERK */
+    *s = 4;
+    *q = 3;
+    *p = 2;
+    ARK_A(A,1,0) = RCONST(1767732205903.0)/RCONST(2027836641118.0);
+    ARK_A(A,2,0) = RCONST(5535828885825.0)/RCONST(10492691773637.0);
+    ARK_A(A,2,1) = RCONST(788022342437.0)/RCONST(10882634858940.0);
+    ARK_A(A,3,0) = RCONST(6485989280629.0)/RCONST(16251701735622.0);
+    ARK_A(A,3,1) = RCONST(-4246266847089.0)/RCONST(9704473918619.0);
+    ARK_A(A,3,2) = RCONST(10755448449292.0)/RCONST(10357097424841.0);
+
+    b[0] = RCONST(1471266399579.0)/RCONST(7840856788654.0);
+    b[1] = RCONST(-4482444167858.0)/RCONST(7529755066697.0);
+    b[2] = RCONST(11266239266428.0)/RCONST(11593286722821.0);
+    b[3] = RCONST(1767732205903.0)/RCONST(4055673282236.0);
+
+    b2[0] = RCONST(2756255671327.0)/RCONST(12835298489170.0);
+    b2[1] = RCONST(-10771552573575.0)/RCONST(22201958757719.0);
+    b2[2] = RCONST(9247589265047.0)/RCONST(10645013368117.0);
+    b2[3] = RCONST(2193209047091.0)/RCONST(5459859503100.0);
+
+    c[1] = RCONST(1767732205903.0)/RCONST(2027836641118.0);
+    c[2] = RCONST(3.0)/RCONST(5.0);
+    c[3] = RCONST(1.0);
+    break;
+
+  case(ZONNEVELD_5_3_4):    /* Zonneveld */
+    *s = 5;
+    *q = 4;
+    *p = 3;
+    ARK_A(A,1,0) = RCONST(0.5);
+    ARK_A(A,2,1) = RCONST(0.5);
+    ARK_A(A,3,2) = RCONST(1.0);
+    ARK_A(A,4,0) = RCONST(5.0)/RCONST(32.0);
+    ARK_A(A,4,1) = RCONST(7.0)/RCONST(32.0);
+    ARK_A(A,4,2) = RCONST(13.0)/RCONST(32.0);
+    ARK_A(A,4,3) = RCONST(-1.0)/RCONST(32.0);
+
+    b[0] = RCONST(1.0)/RCONST(6.0);
+    b[1] = RCONST(1.0)/RCONST(3.0);
+    b[2] = RCONST(1.0)/RCONST(3.0);
+    b[3] = RCONST(1.0)/RCONST(6.0);
+
+    b2[0] = RCONST(-1.0)/RCONST(2.0);
+    b2[1] = RCONST(7.0)/RCONST(3.0);
+    b2[2] = RCONST(7.0)/RCONST(3.0);
+    b2[3] = RCONST(13.0)/RCONST(6.0);
+    b2[4] = RCONST(-16.0)/RCONST(3.0);
+
+    c[1] = RCONST(0.5);
+    c[2] = RCONST(0.5);
+    c[3] = RCONST(1.0);
+    c[4] = RCONST(0.75);
+    break;
+
+  case(ARK436L2SA_ERK_6_3_4):    /* ARK4(3)6L[2]SA-ERK */
+    *s = 6;
+    *q = 4;
+    *p = 3;
+    ARK_A(A,1,0) = RCONST(0.5);
+    ARK_A(A,2,0) = RCONST(13861.0)/RCONST(62500.0);
+    ARK_A(A,2,1) = RCONST(6889.0)/RCONST(62500.0);
+    ARK_A(A,3,0) = RCONST(-116923316275.0)/RCONST(2393684061468.0);
+    ARK_A(A,3,1) = RCONST(-2731218467317.0)/RCONST(15368042101831.0);
+    ARK_A(A,3,2) = RCONST(9408046702089.0)/RCONST(11113171139209.0);
+    ARK_A(A,4,0) = RCONST(-451086348788.0)/RCONST(2902428689909.0);
+    ARK_A(A,4,1) = RCONST(-2682348792572.0)/RCONST(7519795681897.0);
+    ARK_A(A,4,2) = RCONST(12662868775082.0)/RCONST(11960479115383.0);
+    ARK_A(A,4,3) = RCONST(3355817975965.0)/RCONST(11060851509271.0);
+    ARK_A(A,5,0) = RCONST(647845179188.0)/RCONST(3216320057751.0);
+    ARK_A(A,5,1) = RCONST(73281519250.0)/RCONST(8382639484533.0);
+    ARK_A(A,5,2) = RCONST(552539513391.0)/RCONST(3454668386233.0);
+    ARK_A(A,5,3) = RCONST(3354512671639.0)/RCONST(8306763924573.0);
+    ARK_A(A,5,4) = RCONST(4040.0)/RCONST(17871.0);
+
+    b[0] = RCONST(82889.0)/RCONST(524892.0);
+    b[2] = RCONST(15625.0)/RCONST(83664.0);
+    b[3] = RCONST(69875.0)/RCONST(102672.0);
+    b[4] = RCONST(-2260.0)/RCONST(8211.0);
+    b[5] = RCONST(1.0)/RCONST(4.0);
+
+    b2[0] = RCONST(4586570599.0)/RCONST(29645900160.0);
+    b2[2] = RCONST(178811875.0)/RCONST(945068544.0);
+    b2[3] = RCONST(814220225.0)/RCONST(1159782912.0);
+    b2[4] = RCONST(-3700637.0)/RCONST(11593932.0);
+    b2[5] = RCONST(61727.0)/RCONST(225920.0);
+
+    c[1] = RCONST(1.0)/RCONST(2.0);
+    c[2] = RCONST(83.0)/RCONST(250.0);
+    c[3] = RCONST(31.0)/RCONST(50.0);
+    c[4] = RCONST(17.0)/RCONST(20.0);
+    c[5] = RCONST(1.0);
+    break;
+
+  case(SAYFY_ABURUB_6_3_4):    /* Sayfy-Aburub-4-3-ERK */
+    *s = 6;
+    *q = 4;
+    *p = 3;
+    ARK_A(A,1,0) = RCONST(1.0)/RCONST(2.0); 
+    ARK_A(A,2,0) = RCONST(-1.0); 
+    ARK_A(A,2,1) = RCONST(2.0); 
+    ARK_A(A,3,0) = RCONST(1.0)/RCONST(6.0);
+    ARK_A(A,3,1) = RCONST(2.0)/RCONST(3.0);
+    ARK_A(A,3,2) = RCONST(1.0)/RCONST(6.0);
+    ARK_A(A,4,0) = RCONST(0.137);
+    ARK_A(A,4,1) = RCONST(0.226);
+    ARK_A(A,4,2) = RCONST(0.137);
+    ARK_A(A,5,0) = RCONST(0.452);
+    ARK_A(A,5,1) = RCONST(-0.904);
+    ARK_A(A,5,2) = RCONST(-0.548);
+    ARK_A(A,5,4) = RCONST(2.0);
+
+    b[0] = RCONST(1.0)/RCONST(6.0);
+    b[1] = RCONST(1.0)/RCONST(3.0);
+    b[2] = RCONST(1.0)/RCONST(12.0);
+    b[3] = RCONST(0.0);
+    b[4] = RCONST(1.0)/RCONST(3.0);
+    b[5] = RCONST(1.0)/RCONST(12.0);
+
+    b2[0] = RCONST(1.0)/RCONST(6.0);
+    b2[1] = RCONST(2.0)/RCONST(3.0);
+    b2[2] = RCONST(1.0)/RCONST(6.0);
+
+    c[1] = RCONST(1.0)/RCONST(2.0);
+    c[2] = RCONST(1.0);
+    c[3] = RCONST(1.0);
+    c[4] = RCONST(1.0)/RCONST(2.0);
+    c[5] = RCONST(1.0);
+    break;
+
+  case(CASH_KARP_6_4_5):    /* Cash-Karp-ERK */
+    *s = 6;
+    *q = 5;
+    *p = 4;
+    ARK_A(A,1,0) = RCONST(1.0)/RCONST(5.0);
+    ARK_A(A,2,0) = RCONST(3.0)/RCONST(40.0);
+    ARK_A(A,2,1) = RCONST(9.0)/RCONST(40.0);
+    ARK_A(A,3,0) = RCONST(3.0)/RCONST(10.0);
+    ARK_A(A,3,1) = RCONST(-9.0)/RCONST(10.0);
+    ARK_A(A,3,2) = RCONST(6.0)/RCONST(5.0);
+    ARK_A(A,4,0) = RCONST(-11.0)/RCONST(54.0);
+    ARK_A(A,4,1) = RCONST(5.0)/RCONST(2.0);
+    ARK_A(A,4,2) = RCONST(-70.0)/RCONST(27.0);
+    ARK_A(A,4,3) = RCONST(35.0)/RCONST(27.0);
+    ARK_A(A,5,0) = RCONST(1631.0)/RCONST(55296.0);
+    ARK_A(A,5,1) = RCONST(175.0)/RCONST(512.0);
+    ARK_A(A,5,2) = RCONST(575.0)/RCONST(13824.0);
+    ARK_A(A,5,3) = RCONST(44275.0)/RCONST(110592.0);
+    ARK_A(A,5,4) = RCONST(253.0)/RCONST(4096.0);
+
+    b[0] = RCONST(37.0)/RCONST(378.0);
+    b[2] = RCONST(250.0)/RCONST(621.0);
+    b[3] = RCONST(125.0)/RCONST(594.0);
+    b[5] = RCONST(512.0)/RCONST(1771.0);
+
+    b2[0] = RCONST(2825.0)/RCONST(27648.0);
+    b2[2] = RCONST(18575.0)/RCONST(48384.0);
+    b2[3] = RCONST(13525.0)/RCONST(55296.0);
+    b2[4] = RCONST(277.0)/RCONST(14336.0);
+    b2[5] = RCONST(1.0)/RCONST(4.0);
+
+    c[1] = RCONST(1.0)/RCONST(5.0);
+    c[2] = RCONST(3.0)/RCONST(10.0);
+    c[3] = RCONST(3.0)/RCONST(5.0);
+    c[4] = RCONST(1.0);
+    c[5] = RCONST(7.0)/RCONST(8.0);
+    break;
+
+  case(FEHLBERG_6_4_5):    /* Fehlberg-ERK */
+    *s = 6;
+    *q = 5;
+    *p = 4;
+    ARK_A(A,1,0) = RCONST(1.0)/RCONST(4.0);
+    ARK_A(A,2,0) = RCONST(3.0)/RCONST(32.0);
+    ARK_A(A,2,1) = RCONST(9.0)/RCONST(32.0);
+    ARK_A(A,3,0) = RCONST(1932.0)/RCONST(2197.0);
+    ARK_A(A,3,1) = RCONST(-7200.0)/RCONST(2197.0);
+    ARK_A(A,3,2) = RCONST(7296.0)/RCONST(2197.0);
+    ARK_A(A,4,0) = RCONST(439.0)/RCONST(216.0);
+    ARK_A(A,4,1) = RCONST(-8.0);
+    ARK_A(A,4,2) = RCONST(3680.0)/RCONST(513.0);
+    ARK_A(A,4,3) = RCONST(-845.0)/RCONST(4104.0);
+    ARK_A(A,5,0) = RCONST(-8.0)/RCONST(27.0);
+    ARK_A(A,5,1) = RCONST(2.0);
+    ARK_A(A,5,2) = RCONST(-3544.0)/RCONST(2565.0);
+    ARK_A(A,5,3) = RCONST(1859.0)/RCONST(4104.0);
+    ARK_A(A,5,4) = RCONST(-11.0)/RCONST(40.0);
+
+    b[0] = RCONST(16.0)/RCONST(135.0);
+    b[2] = RCONST(6656.0)/RCONST(12825.0);
+    b[3] = RCONST(28561.0)/RCONST(56430.0);
+    b[4] = RCONST(-9.0)/RCONST(50.0);
+    b[5] = RCONST(2.0)/RCONST(55.0);
+
+    b2[0] = RCONST(25.0)/RCONST(216.0);
+    b2[2] = RCONST(1408.0)/RCONST(2565.0);
+    b2[3] = RCONST(2197.0)/RCONST(4104.0);
+    b2[4] = RCONST(-1.0)/RCONST(5.0);
+      
+    c[1] = RCONST(1.0)/RCONST(4.0);
+    c[2] = RCONST(3.0)/RCONST(8.0);
+    c[3] = RCONST(12.0)/RCONST(13.0);
+    c[4] = RCONST(1.0);
+    c[5] = RCONST(1.0)/RCONST(2.0);
+    break;
+
+  case(DORMAND_PRINCE_7_4_5):    /* Dormand-Prince-ERK */
+    *s = 7;
+    *q = 5;
+    *p = 4;
+    ARK_A(A,1,0) = RCONST(1.0)/RCONST(5.0);
+    ARK_A(A,2,0) = RCONST(3.0)/RCONST(40.0);
+    ARK_A(A,2,1) = RCONST(9.0)/RCONST(40.0);
+    ARK_A(A,3,0) = RCONST(44.0)/RCONST(45.0);
+    ARK_A(A,3,1) = RCONST(-56.0)/RCONST(15.0);
+    ARK_A(A,3,2) = RCONST(32.0)/RCONST(9.0);
+    ARK_A(A,4,0) = RCONST(19372.0)/RCONST(6561.0);
+    ARK_A(A,4,1) = RCONST(-25360.0)/RCONST(2187.0);
+    ARK_A(A,4,2) = RCONST(64448.0)/RCONST(6561.0);
+    ARK_A(A,4,3) = RCONST(-212.0)/RCONST(729.0);
+    ARK_A(A,5,0) = RCONST(9017.0)/RCONST(3168.0);
+    ARK_A(A,5,1) = RCONST(-355.0)/RCONST(33.0);
+    ARK_A(A,5,2) = RCONST(46732.0)/RCONST(5247.0);
+    ARK_A(A,5,3) = RCONST(49.0)/RCONST(176.0);
+    ARK_A(A,5,4) = RCONST(-5103.0)/RCONST(18656.0);
+    ARK_A(A,6,0) = RCONST(35.0)/RCONST(384.0);
+    ARK_A(A,6,2) = RCONST(500.0)/RCONST(1113.0);
+    ARK_A(A,6,3) = RCONST(125.0)/RCONST(192.0);
+    ARK_A(A,6,4) = RCONST(-2187.0)/RCONST(6784.0);
+    ARK_A(A,6,5) = RCONST(11.0)/RCONST(84.0);
+
+    b[0] = RCONST(35.0)/RCONST(384.0);
+    b[2] = RCONST(500.0)/RCONST(1113.0);
+    b[3] = RCONST(125.0)/RCONST(192.0);
+    b[4] = RCONST(-2187.0)/RCONST(6784.0);
+    b[5] = RCONST(11.0)/RCONST(84.0);
+
+    b2[0] = RCONST(5179.0)/RCONST(57600.0);
+    b2[2] = RCONST(7571.0)/RCONST(16695.0);
+    b2[3] = RCONST(393.0)/RCONST(640.0);
+    b2[4] = RCONST(-92097.0)/RCONST(339200.0);
+    b2[5] = RCONST(187.0)/RCONST(2100.0);
+    b2[6] = RCONST(1.0)/RCONST(40.0);
+
+    c[1] = RCONST(1.0)/RCONST(5.0);
+    c[2] = RCONST(3.0)/RCONST(10.0);
+    c[3] = RCONST(4.0)/RCONST(5.0);
+    c[4] = RCONST(8.0)/RCONST(9.0);
+    c[5] = RCONST(1.0);
+    c[6] = RCONST(1.0);
+    break;
+
+  case(ARK548L2SA_ERK_8_4_5):    /* ARK5(4)8L[2]SA-ERK */
+    *s = 8;
+    *q = 5;
+    *p = 4;
+    ARK_A(A,1,0) = RCONST(41.0)/RCONST(100.0);
+    ARK_A(A,2,0) = RCONST(367902744464.0)/RCONST(2072280473677.0);
+    ARK_A(A,2,1) = RCONST(677623207551.0)/RCONST(8224143866563.0);
+    ARK_A(A,3,0) = RCONST(1268023523408.0)/RCONST(10340822734521.0);
+    ARK_A(A,3,2) = RCONST(1029933939417.0)/RCONST(13636558850479.0);
+    ARK_A(A,4,0) = RCONST(14463281900351.0)/RCONST(6315353703477.0);
+    ARK_A(A,4,2) = RCONST(66114435211212.0)/RCONST(5879490589093.0);
+    ARK_A(A,4,3) = RCONST(-54053170152839.0)/RCONST(4284798021562.0);
+    ARK_A(A,5,0) = RCONST(14090043504691.0)/RCONST(34967701212078.0);
+    ARK_A(A,5,2) = RCONST(15191511035443.0)/RCONST(11219624916014.0);
+    ARK_A(A,5,3) = RCONST(-18461159152457.0)/RCONST(12425892160975.0);
+    ARK_A(A,5,4) = RCONST(-281667163811.0)/RCONST(9011619295870.0);
+    ARK_A(A,6,0) = RCONST(19230459214898.0)/RCONST(13134317526959.0);
+    ARK_A(A,6,2) = RCONST(21275331358303.0)/RCONST(2942455364971.0);
+    ARK_A(A,6,3) = RCONST(-38145345988419.0)/RCONST(4862620318723.0);
+    ARK_A(A,6,4) = RCONST(-1.0)/RCONST(8.0);
+    ARK_A(A,6,5) = RCONST(-1.0)/RCONST(8.0);
+    ARK_A(A,7,0) = RCONST(-19977161125411.0)/RCONST(11928030595625.0);
+    ARK_A(A,7,2) = RCONST(-40795976796054.0)/RCONST(6384907823539.0);
+    ARK_A(A,7,3) = RCONST(177454434618887.0)/RCONST(12078138498510.0);
+    ARK_A(A,7,4) = RCONST(782672205425.0)/RCONST(8267701900261.0);
+    ARK_A(A,7,5) = RCONST(-69563011059811.0)/RCONST(9646580694205.0);
+    ARK_A(A,7,6) = RCONST(7356628210526.0)/RCONST(4942186776405.0);
+
+    b[0] = RCONST(-872700587467.0)/RCONST(9133579230613.0);
+    b[3] = RCONST(22348218063261.0)/RCONST(9555858737531.0);
+    b[4] = RCONST(-1143369518992.0)/RCONST(8141816002931.0);
+    b[5] = RCONST(-39379526789629.0)/RCONST(19018526304540.0);
+    b[6] = RCONST(32727382324388.0)/RCONST(42900044865799.0);
+    b[7] = RCONST(41.0)/RCONST(200.0);
+
+    b2[0] = RCONST(-975461918565.0)/RCONST(9796059967033.0);
+    b2[3] = RCONST(78070527104295.0)/RCONST(32432590147079.0);
+    b2[4] = RCONST(-548382580838.0)/RCONST(3424219808633.0);
+    b2[5] = RCONST(-33438840321285.0)/RCONST(15594753105479.0);
+    b2[6] = RCONST(3629800801594.0)/RCONST(4656183773603.0);
+    b2[7] = RCONST(4035322873751.0)/RCONST(18575991585200.0);
+
+    c[1] = RCONST(41.0)/RCONST(100.0);
+    c[2] = RCONST(2935347310677.0)/RCONST(11292855782101.0);
+    c[3] = RCONST(1426016391358.0)/RCONST(7196633302097.0);
+    c[4] = RCONST(92.0)/RCONST(100.0);
+    c[5] = RCONST(24.0)/RCONST(100.0);
+    c[6] = RCONST(3.0)/RCONST(5.0);
+    c[7] = RCONST(1.0);
+    break;
+
+  case(VERNER_8_5_6):    /* Verner-6-5 */
+    *s = 8;
+    *q = 6;
+    *p = 5;
+    ARK_A(A,1,0) = RCONST(1.0)/RCONST(6.0);
+    ARK_A(A,2,0) = RCONST(4.0)/RCONST(75.0);
+    ARK_A(A,2,1) = RCONST(16.0)/RCONST(75.0);
+    ARK_A(A,3,0) = RCONST(5.0)/RCONST(6.0);
+    ARK_A(A,3,1) = RCONST(-8.0)/RCONST(3.0);
+    ARK_A(A,3,2) = RCONST(5.0)/RCONST(2.0);
+    ARK_A(A,4,0) = RCONST(-165.0)/RCONST(64.0);
+    ARK_A(A,4,1) = RCONST(55.0)/RCONST(6.0);
+    ARK_A(A,4,2) = RCONST(-425.0)/RCONST(64.0);
+    ARK_A(A,4,3) = RCONST(85.0)/RCONST(96.0);
+    ARK_A(A,5,0) = RCONST(12.0)/RCONST(5.0);
+    ARK_A(A,5,1) = RCONST(-8.0);
+    ARK_A(A,5,2) = RCONST(4015.0)/RCONST(612.0);
+    ARK_A(A,5,3) = RCONST(-11.0)/RCONST(36.0);
+    ARK_A(A,5,4) = RCONST(88.0)/RCONST(255.0);
+    ARK_A(A,6,0) = RCONST(-8263.0)/RCONST(15000.0);
+    ARK_A(A,6,1) = RCONST(124.0)/RCONST(75.0);
+    ARK_A(A,6,2) = RCONST(-643.0)/RCONST(680.0);
+    ARK_A(A,6,3) = RCONST(-81.0)/RCONST(250.0);
+    ARK_A(A,6,4) = RCONST(2484.0)/RCONST(10625.0);
+    ARK_A(A,7,0) = RCONST(3501.0)/RCONST(1720.0);
+    ARK_A(A,7,1) = RCONST(-300.0)/RCONST(43.0);
+    ARK_A(A,7,2) = RCONST(297275.0)/RCONST(52632.0);
+    ARK_A(A,7,3) = RCONST(-319.0)/RCONST(2322.0);
+    ARK_A(A,7,4) = RCONST(24068.0)/RCONST(84065.0);
+    ARK_A(A,7,6) = RCONST(3850.0)/RCONST(26703.0);
+
+    b[0] = RCONST(3.0)/RCONST(40.0);
+    b[2] = RCONST(875.0)/RCONST(2244.0);
+    b[3] = RCONST(23.0)/RCONST(72.0);
+    b[4] = RCONST(264.0)/RCONST(1955.0);
+    b[6] = RCONST(125.0)/RCONST(11592.0);
+    b[7] = RCONST(43.0)/RCONST(616.0);
+
+    b2[0] = RCONST(13.0)/RCONST(160.0);
+    b2[2] = RCONST(2375.0)/RCONST(5984.0);
+    b2[3] = RCONST(5.0)/RCONST(16.0);
+    b2[4] = RCONST(12.0)/RCONST(85.0);
+    b2[5] = RCONST(3.0)/RCONST(44.0);
+
+    c[0] = RCONST(0.0);
+    c[1] = RCONST(1.0)/RCONST(6.0);
+    c[2] = RCONST(4.0)/RCONST(15.0);
+    c[3] = RCONST(2.0)/RCONST(3.0);
+    c[4] = RCONST(5.0)/RCONST(6.0);
+    c[5] = RCONST(1.0);
+    c[6] = RCONST(1.0)/RCONST(15.0);
+    c[7] = RCONST(1.0);
+    break;
+
+  case(FEHLBERG_13_7_8):    /* Fehlberg-8-7 */
+    *s = 13;
+    *q = 8;
+    *p = 7;
+    ARK_A(A,1,0) = RCONST(2.0)/RCONST(27.0);
+    ARK_A(A,2,0) = RCONST(1.0)/RCONST(36.0);
+    ARK_A(A,2,1) = RCONST(1.0)/RCONST(12.0);
+    ARK_A(A,3,0) = RCONST(1.0)/RCONST(24.0);
+    ARK_A(A,3,2) = RCONST(1.0)/RCONST(8.0);
+    ARK_A(A,4,0) = RCONST(5.0)/RCONST(12.0);
+    ARK_A(A,4,2) = RCONST(-25.0)/RCONST(16.0);
+    ARK_A(A,4,3) = RCONST(25.0)/RCONST(16.0);
+    ARK_A(A,5,0) = RCONST(1.0)/RCONST(20.0);
+    ARK_A(A,5,3) = RCONST(1.0)/RCONST(4.0);
+    ARK_A(A,5,4) = RCONST(1.0)/RCONST(5.0);
+    ARK_A(A,6,0) = RCONST(-25.0)/RCONST(108.0);
+    ARK_A(A,6,3) = RCONST(125.0)/RCONST(108.0);
+    ARK_A(A,6,4) = RCONST(-65.0)/RCONST(27.0);
+    ARK_A(A,6,5) = RCONST(125.0)/RCONST(54.0);
+    ARK_A(A,7,0) = RCONST(31.0)/RCONST(300.0);
+    ARK_A(A,7,4) = RCONST(61.0)/RCONST(225.0);
+    ARK_A(A,7,5) = RCONST(-2.0)/RCONST(9.0);
+    ARK_A(A,7,6) = RCONST(13.0)/RCONST(900.0);
+    ARK_A(A,8,0) = RCONST(2.0);
+    ARK_A(A,8,3) = RCONST(-53.0)/RCONST(6.0);
+    ARK_A(A,8,4) = RCONST(704.0)/RCONST(45.0);
+    ARK_A(A,8,5) = RCONST(-107.0)/RCONST(9.0);
+    ARK_A(A,8,6) = RCONST(67.0)/RCONST(90.0);
+    ARK_A(A,8,7) = RCONST(3.0);
+    ARK_A(A,9,0) = RCONST(-91.0)/RCONST(108.0);
+    ARK_A(A,9,3) = RCONST(23.0)/RCONST(108.0);
+    ARK_A(A,9,4) = RCONST(-976.0)/RCONST(135.0);
+    ARK_A(A,9,5) = RCONST(311.0)/RCONST(54.0);
+    ARK_A(A,9,6) = RCONST(-19.0)/RCONST(60.0);
+    ARK_A(A,9,7) = RCONST(17.0)/RCONST(6.0);
+    ARK_A(A,9,8) = RCONST(-1.0)/RCONST(12.0);
+    ARK_A(A,10,0) = RCONST(2383.0)/RCONST(4100.0);
+    ARK_A(A,10,3) = RCONST(-341.0)/RCONST(164.0);
+    ARK_A(A,10,4) = RCONST(4496.0)/RCONST(1025.0);
+    ARK_A(A,10,5) = RCONST(-301.0)/RCONST(82.0);
+    ARK_A(A,10,6) = RCONST(2133.0)/RCONST(4100.0);
+    ARK_A(A,10,7) = RCONST(45.0)/RCONST(82.0);
+    ARK_A(A,10,8) = RCONST(45.0)/RCONST(164.0);
+    ARK_A(A,10,9) = RCONST(18.0)/RCONST(41.0);
+    ARK_A(A,11,0) = RCONST(3.0)/RCONST(205.0);
+    ARK_A(A,11,5) = RCONST(-6.0)/RCONST(41.0);
+    ARK_A(A,11,6) = RCONST(-3.0)/RCONST(205.0);
+    ARK_A(A,11,7) = RCONST(-3.0)/RCONST(41.0);
+    ARK_A(A,11,8) = RCONST(3.0)/RCONST(41.0);
+    ARK_A(A,11,9) = RCONST(6.0)/RCONST(41.0);
+    ARK_A(A,12,0) = RCONST(-1777.0)/RCONST(4100.0);
+    ARK_A(A,12,3) = RCONST(-341.0)/RCONST(164.0);
+    ARK_A(A,12,4) = RCONST(4496.0)/RCONST(1025.0);
+    ARK_A(A,12,5) = RCONST(-289.0)/RCONST(82.0);
+    ARK_A(A,12,6) = RCONST(2193.0)/RCONST(4100.0);
+    ARK_A(A,12,7) = RCONST(51.0)/RCONST(82.0);
+    ARK_A(A,12,8) = RCONST(33.0)/RCONST(164.0);
+    ARK_A(A,12,9) = RCONST(12.0)/RCONST(41.0);
+    ARK_A(A,12,11) = RCONST(1.0);
+
+    b[5]  = RCONST(34.0)/RCONST(105.0);
+    b[6]  = RCONST(9.0)/RCONST(35.0);
+    b[7]  = RCONST(9.0)/RCONST(35.0);
+    b[8]  = RCONST(9.0)/RCONST(280.0);
+    b[9]  = RCONST(9.0)/RCONST(280.0);
+    b[11] = RCONST(41.0)/RCONST(840.0);
+    b[12] = RCONST(41.0)/RCONST(840.0);
+
+    b2[0]  = RCONST(41.0)/RCONST(840.0);
+    b2[5]  = RCONST(34.0)/RCONST(105.0);
+    b2[6]  = RCONST(9.0)/RCONST(35.0);
+    b2[7]  = RCONST(9.0)/RCONST(35.0);
+    b2[8]  = RCONST(9.0)/RCONST(280.0);
+    b2[9]  = RCONST(9.0)/RCONST(280.0);
+    b2[10] = RCONST(41.0)/RCONST(840.0);
+
+    c[1]  = RCONST(2.0)/RCONST(27.0);
+    c[2]  = RCONST(1.0)/RCONST(9.0);
+    c[3]  = RCONST(1.0)/RCONST(6.0);
+    c[4]  = RCONST(5.0)/RCONST(12.0);
+    c[5]  = RCONST(1.0)/RCONST(2.0);
+    c[6]  = RCONST(5.0)/RCONST(6.0);
+    c[7]  = RCONST(1.0)/RCONST(6.0);
+    c[8]  = RCONST(2.0)/RCONST(3.0);
+    c[9]  = RCONST(1.0)/RCONST(3.0);
+    c[10] = RCONST(1.0);
+    c[12] = RCONST(1.0);
+    break;
+
+  case(SDIRK_2_1_2):   /* SDIRK-2-1 (A,B stable) */
+    *s = 2;
+    *q = 2;
+    *p = 1;
+      
+    ARK_A(A,0,0) = RCONST(1.0);
+    ARK_A(A,1,0) = RCONST(-1.0);
+    ARK_A(A,1,1) = RCONST(1.0);
+
+    b[0] = RCONST(0.5);
+    b[1] = RCONST(0.5);
+
+    b2[0] = RCONST(1.0);
+
+    c[0] = RCONST(1.0);
+    c[1] = RCONST(0.0);
+    break;
+
+  case(BILLINGTON_3_3_2):    /* Billington-SDIRK */
+    *s = 3;
+    /* *q = 3; */
+    /* *p = 2; */
+    *q = 2;
+    *p = 3;
+
+    ARK_A(A,0,0) = RCONST(0.292893218813);
+    ARK_A(A,1,0) = RCONST(0.798989873223);
+    ARK_A(A,1,1) = RCONST(0.292893218813);
+    ARK_A(A,2,0) = RCONST(0.740789228841);
+    ARK_A(A,2,1) = RCONST(0.259210771159);
+    ARK_A(A,2,2) = RCONST(0.292893218813);
+
+    /* b[0] = RCONST(0.691665115992); */
+    /* b[1] = RCONST(0.503597029883); */
+    /* b[2] = RCONST(-0.195262145876); */
+
+    /* b2[0] = RCONST(0.740789228840); */
+    /* b2[1] = RCONST(0.259210771159); */
+
+    b2[0] = RCONST(0.691665115992);
+    b2[1] = RCONST(0.503597029883);
+    b2[2] = RCONST(-0.195262145876);
+
+    b[0] = RCONST(0.740789228840);
+    b[1] = RCONST(0.259210771159);
+
+    c[0] = RCONST(0.292893218813);
+    c[1] = RCONST(1.091883092037);
+    c[2] = RCONST(1.292893218813);
+    break;
+
+  case(TRBDF2_3_3_2):    /* TRBDF2-ESDIRK */
+    *s = 3;
+    /* *q = 3; */
+    /* *p = 2; */
+    *q = 2;
+    *p = 3;
+
+    ARK_A(A,1,0) = (two-sqrt2)/two;
+    ARK_A(A,1,1) = (two-sqrt2)/two;
+    ARK_A(A,2,0) = sqrt2/four;
+    ARK_A(A,2,1) = sqrt2/four;
+    ARK_A(A,2,2) = (two-sqrt2)/two;
+
+    /* b[0] = (one-sqrt2/four)/three; */
+    /* b[1] = (three*sqrt2/four+one)/three; */
+    /* b[2] = (two-sqrt2)/six; */
+
+    /* b2[0] = sqrt2/four; */
+    /* b2[1] = sqrt2/four; */
+    /* b2[2] = (two-sqrt2)/two; */
+
+    b2[0] = (one-sqrt2/four)/three;
+    b2[1] = (three*sqrt2/four+one)/three;
+    b2[2] = (two-sqrt2)/six;
+
+    b[0] = sqrt2/four;
+    b[1] = sqrt2/four;
+    b[2] = (two-sqrt2)/two;
+
+    c[1] = two-sqrt2;
+    c[2] = one;
+    break;
+
+  case(KVAERNO_4_2_3):    /* Kvaerno(4,2,3)-ESDIRK */
+    *s = 4;
+    *q = 3;
+    *p = 2;
+    ARK_A(A,1,0) = RCONST(0.4358665215);
+    ARK_A(A,1,1) = RCONST(0.4358665215);
+    ARK_A(A,2,0) = RCONST(0.490563388419108);
+    ARK_A(A,2,1) = RCONST(0.073570090080892);
+    ARK_A(A,2,2) = RCONST(0.4358665215);
+    ARK_A(A,3,0) = RCONST(0.308809969973036);
+    ARK_A(A,3,1) = RCONST(1.490563388254106);
+    ARK_A(A,3,2) = RCONST(-1.235239879727145);
+    ARK_A(A,3,3) = RCONST(0.4358665215);
+
+    b[0] = RCONST(0.308809969973036);
+    b[1] = RCONST(1.490563388254106);
+    b[2] = RCONST(-1.235239879727145);
+    b[3] = RCONST(0.4358665215);
+
+    b2[0] = RCONST(0.490563388419108);
+    b2[1] = RCONST(0.073570090080892);
+    b2[2] = RCONST(0.4358665215);
+
+    c[1] = RCONST(0.871733043);
+    c[2] = RCONST(1.0);
+    c[3] = RCONST(1.0);
+    break;
+
+  case(ARK324L2SA_DIRK_4_2_3):    /* ARK3(2)4L[2]SA-ESDIRK */
+    *s = 4;
+    *q = 3;
+    *p = 2;
+    ARK_A(A,1,0) = RCONST(1767732205903.0)/RCONST(4055673282236.0);
+    ARK_A(A,1,1) = RCONST(1767732205903.0)/RCONST(4055673282236.0);
+    ARK_A(A,2,0) = RCONST(2746238789719.0)/RCONST(10658868560708.0);
+    ARK_A(A,2,1) = RCONST(-640167445237.0)/RCONST(6845629431997.0);
+    ARK_A(A,2,2) = RCONST(1767732205903.0)/RCONST(4055673282236.0);
+    ARK_A(A,3,0) = RCONST(1471266399579.0)/RCONST(7840856788654.0);
+    ARK_A(A,3,1) = RCONST(-4482444167858.0)/RCONST(7529755066697.0);
+    ARK_A(A,3,2) = RCONST(11266239266428.0)/RCONST(11593286722821.0);
+    ARK_A(A,3,3) = RCONST(1767732205903.0)/RCONST(4055673282236.0);
+
+    b[0] = RCONST(1471266399579.0)/RCONST(7840856788654.0);
+    b[1] = RCONST(-4482444167858.0)/RCONST(7529755066697.0);
+    b[2] = RCONST(11266239266428.0)/RCONST(11593286722821.0);
+    b[3] = RCONST(1767732205903.0)/RCONST(4055673282236.0);
+
+    b2[0] = RCONST(2756255671327.0)/RCONST(12835298489170.0);
+    b2[1] = RCONST(-10771552573575.0)/RCONST(22201958757719.0);
+    b2[2] = RCONST(9247589265047.0)/RCONST(10645013368117.0);
+    b2[3] = RCONST(2193209047091.0)/RCONST(5459859503100.0);
+
+    c[1] = RCONST(1767732205903.0)/RCONST(2027836641118.0);
+    c[2] = RCONST(3.0)/RCONST(5.0);
+    c[3] = RCONST(1.0);
+    break;
+
+  case(CASH_5_2_4):    /* Cash(5,2,4)-SDIRK */
+    *s = 5;
+    *q = 4;
+    *p = 2;
+    ARK_A(A,0,0) = RCONST(0.435866521508);
+    ARK_A(A,1,0) = RCONST(-1.13586652150);
+    ARK_A(A,1,1) = RCONST(0.435866521508);
+    ARK_A(A,2,0) = RCONST(1.08543330679);
+    ARK_A(A,2,1) = RCONST(-0.721299828287);
+    ARK_A(A,2,2) = RCONST(0.435866521508);
+    ARK_A(A,3,0) = RCONST(0.416349501547);
+    ARK_A(A,3,1) = RCONST(0.190984004184);
+    ARK_A(A,3,2) = RCONST(-0.118643265417);
+    ARK_A(A,3,3) = RCONST(0.435866521508);
+    ARK_A(A,4,0) = RCONST(0.896869652944);
+    ARK_A(A,4,1) = RCONST(0.0182725272734);
+    ARK_A(A,4,2) = RCONST(-0.0845900310706);
+    ARK_A(A,4,3) = RCONST(-0.266418670647);
+    ARK_A(A,4,4) = RCONST(0.435866521508);
+
+    b[0] = RCONST(0.896869652944);
+    b[1] = RCONST(0.0182725272734);
+    b[2] = RCONST(-0.0845900310706);
+    b[3] = RCONST(-0.266418670647);
+    b[4] = RCONST(0.435866521508);
+
+    b2[0] = RCONST((-0.7-0.5))/RCONST((-0.7-0.435866521508));
+    b2[1] = RCONST((0.5-0.435866521508))/RCONST((-0.7-0.435866521508));
+
+    c[0] = RCONST(0.435866521508);
+    c[1] = RCONST(-0.7);
+    c[2] = RCONST(0.8);
+    c[3] = RCONST(0.924556761814);
+    c[4] = RCONST(1.0);
+    break;
+
+  case(CASH_5_3_4):    /* Cash(5,3,4)-SDIRK */
+    *s = 5;
+    *q = 4;
+    *p = 3;
+    ARK_A(A,0,0) = RCONST(0.435866521508);
+    ARK_A(A,1,0) = RCONST(-1.13586652150);
+    ARK_A(A,1,1) = RCONST(0.435866521508);
+    ARK_A(A,2,0) = RCONST(1.08543330679);
+    ARK_A(A,2,1) = RCONST(-0.721299828287);
+    ARK_A(A,2,2) = RCONST(0.435866521508);
+    ARK_A(A,3,0) = RCONST(0.416349501547);
+    ARK_A(A,3,1) = RCONST(0.190984004184);
+    ARK_A(A,3,2) = RCONST(-0.118643265417);
+    ARK_A(A,3,3) = RCONST(0.435866521508);
+    ARK_A(A,4,0) = RCONST(0.896869652944);
+    ARK_A(A,4,1) = RCONST(0.0182725272734);
+    ARK_A(A,4,2) = RCONST(-0.0845900310706);
+    ARK_A(A,4,3) = RCONST(-0.266418670647);
+    ARK_A(A,4,4) = RCONST(0.435866521508);
+
+    b[0] = RCONST(0.896869652944);
+    b[1] = RCONST(0.0182725272734);
+    b[2] = RCONST(-0.0845900310706);
+    b[3] = RCONST(-0.266418670647);
+    b[4] = RCONST(0.435866521508);
+
+    b2[0] = RCONST(0.776691932910);
+    b2[1] = RCONST(0.0297472791484);
+    b2[2] = RCONST(-0.0267440239074);
+    b2[3] = RCONST(0.220304811849);
+
+    c[0] = RCONST(0.435866521508);
+    c[1] = RCONST(-0.7);
+    c[2] = RCONST(0.8);
+    c[3] = RCONST(0.924556761814);
+    c[4] = RCONST(1.0);
+    break;
+
+  case(SDIRK_5_3_4):    /* SDIRK-5-4 */
+    *s = 5;
+    *q = 4;
+    *p = 3;
+    ARK_A(A,0,0) = RCONST(0.25);
+    ARK_A(A,1,0) = RCONST(0.5);
+    ARK_A(A,1,1) = RCONST(0.25);
+    ARK_A(A,2,0) = RCONST(17.0)/RCONST(50.0);
+    ARK_A(A,2,1) = RCONST(-1.0)/RCONST(25.0);
+    ARK_A(A,2,2) = RCONST(0.25);
+    ARK_A(A,3,0) = RCONST(371.0)/RCONST(1360.0);
+    ARK_A(A,3,1) = RCONST(-137.0)/RCONST(2720.0);
+    ARK_A(A,3,2) = RCONST(15.0)/RCONST(544.0);
+    ARK_A(A,3,3) = RCONST(0.25);
+    ARK_A(A,4,0) = RCONST(25.0)/RCONST(24.0);
+    ARK_A(A,4,1) = RCONST(-49.0)/RCONST(48.0);
+    ARK_A(A,4,2) = RCONST(125.0)/RCONST(16.0);
+    ARK_A(A,4,3) = RCONST(-85.0)/RCONST(12.0);
+    ARK_A(A,4,4) = RCONST(0.25);
+
+    b[0] = RCONST(25.0)/RCONST(24.0);
+    b[1] = RCONST(-49.0)/RCONST(48.0);
+    b[2] = RCONST(125.0)/RCONST(16.0);
+    b[3] = RCONST(-85.0)/RCONST(12.0);
+    b[4] = RCONST(0.25);
+
+    b2[0] = RCONST(59.0)/RCONST(48.0);
+    b2[1] = RCONST(-17.0)/RCONST(96.0);
+    b2[2] = RCONST(225.0)/RCONST(32.0);
+    b2[3] = RCONST(-85.0)/RCONST(12.0);
+
+    c[0] = RCONST(0.25);
+    c[1] = RCONST(0.75);
+    c[2] = RCONST(11.0)/RCONST(20.0);
+    c[3] = RCONST(0.5);
+    c[4] = RCONST(1.0);
+    break;
+
+  case(KVAERNO_5_3_4):    /* Kvaerno(5,3,4)-ESDIRK */
+    *s = 5;
+    *q = 4;
+    *p = 3;
+    ARK_A(A,1,0) = RCONST(0.4358665215); 
+    ARK_A(A,1,1) = RCONST(0.4358665215); 
+    ARK_A(A,2,0) = RCONST(0.140737774731968);
+    ARK_A(A,2,1) = RCONST(-0.108365551378832);
+    ARK_A(A,2,2) = RCONST(0.4358665215);
+    ARK_A(A,3,0) = RCONST(0.102399400616089);
+    ARK_A(A,3,1) = RCONST(-0.376878452267324);
+    ARK_A(A,3,2) = RCONST(0.838612530151233);
+    ARK_A(A,3,3) = RCONST(0.4358665215);
+    ARK_A(A,4,0) = RCONST(0.157024897860995);
+    ARK_A(A,4,1) = RCONST(0.117330441357768);
+    ARK_A(A,4,2) = RCONST(0.61667803039168);
+    ARK_A(A,4,3) = RCONST(-0.326899891110444);
+    ARK_A(A,4,4) = RCONST(0.4358665215);
+
+    b[0] = RCONST(0.157024897860995);
+    b[1] = RCONST(0.117330441357768);
+    b[2] = RCONST(0.61667803039168);
+    b[3] = RCONST(-0.326899891110444);
+    b[4] = RCONST(0.4358665215);
+
+    b2[0] = RCONST(0.102399400616089);
+    b2[1] = RCONST(-0.376878452267324);
+    b2[2] = RCONST(0.838612530151233);
+    b2[3] = RCONST(0.4358665215);
+
+    c[1] = RCONST(0.871733043);
+    c[2] = RCONST(0.468238744853136);
+    c[3] = RCONST(1.0);
+    c[4] = RCONST(1.0);
+    break;
+
+  case(ARK436L2SA_DIRK_6_3_4):    /* ARK4(3)6L[2]SA-ESDIRK */
+    *s = 6;
+    *q = 4;
+    *p = 3;
+    ARK_A(A,1,0) = RCONST(1.0)/RCONST(4.0);
+    ARK_A(A,1,1) = RCONST(1.0)/RCONST(4.0);
+    ARK_A(A,2,0) = RCONST(8611.0)/RCONST(62500.0);
+    ARK_A(A,2,1) = RCONST(-1743.0)/RCONST(31250.0);
+    ARK_A(A,2,2) = RCONST(1.0)/RCONST(4.0);
+    ARK_A(A,3,0) = RCONST(5012029.0)/RCONST(34652500.0);
+    ARK_A(A,3,1) = RCONST(-654441.0)/RCONST(2922500.0);
+    ARK_A(A,3,2) = RCONST(174375.0)/RCONST(388108.0);
+    ARK_A(A,3,3) = RCONST(1.0)/RCONST(4.0);
+    ARK_A(A,4,0) = RCONST(15267082809.0)/RCONST(155376265600.0);
+    ARK_A(A,4,1) = RCONST(-71443401.0)/RCONST(120774400.0);
+    ARK_A(A,4,2) = RCONST(730878875.0)/RCONST(902184768.0);
+    ARK_A(A,4,3) = RCONST(2285395.0)/RCONST(8070912.0);
+    ARK_A(A,4,4) = RCONST(1.0)/RCONST(4.0);
+    ARK_A(A,5,0) = RCONST(82889.0)/RCONST(524892.0);
+    ARK_A(A,5,2) = RCONST(15625.0)/RCONST(83664.0);
+    ARK_A(A,5,3) = RCONST(69875.0)/RCONST(102672.0);
+    ARK_A(A,5,4) = RCONST(-2260.0)/RCONST(8211.0);
+    ARK_A(A,5,5) = RCONST(1.0)/RCONST(4.0);
+
+    b[0] = RCONST(82889.0)/RCONST(524892.0);
+    b[2] = RCONST(15625.0)/RCONST(83664.0);
+    b[3] = RCONST(69875.0)/RCONST(102672.0);
+    b[4] = RCONST(-2260.0)/RCONST(8211.0);
+    b[5] = RCONST(1.0)/RCONST(4.0);
+
+    c[1] = RCONST(1.0)/RCONST(2.0);
+    c[2] = RCONST(83.0)/RCONST(250.0);
+    c[3] = RCONST(31.0)/RCONST(50.0);
+    c[4] = RCONST(17.0)/RCONST(20.0);
+    c[5] = RCONST(1.0);
+
+    b2[0] = RCONST(4586570599.0)/RCONST(29645900160.0);
+    b2[2] = RCONST(178811875.0)/RCONST(945068544.0);
+    b2[3] = RCONST(814220225.0)/RCONST(1159782912.0);
+    b2[4] = RCONST(-3700637.0)/RCONST(11593932.0);
+    b2[5] = RCONST(61727.0)/RCONST(225920.0);
+    break;
+
+  case(KVAERNO_7_4_5):    /* Kvaerno(7,4,5)-ESDIRK */
+    *s = 7;
+    *q = 5;
+    *p = 4;
+    ARK_A(A,1,0) = RCONST(0.26);
+    ARK_A(A,1,1) = RCONST(0.26);
+    ARK_A(A,2,0) = RCONST(0.13);
+    ARK_A(A,2,1) = RCONST(0.84033320996790809);
+    ARK_A(A,2,2) = RCONST(0.26);
+    ARK_A(A,3,0) = RCONST(0.22371961478320505);
+    ARK_A(A,3,1) = RCONST(0.47675532319799699);
+    ARK_A(A,3,2) = RCONST(-0.06470895363112615);
+    ARK_A(A,3,3) = RCONST(0.26);
+    ARK_A(A,4,0) = RCONST(0.16648564323248321);
+    ARK_A(A,4,1) = RCONST(0.10450018841591720);
+    ARK_A(A,4,2) = RCONST(0.03631482272098715);
+    ARK_A(A,4,3) = RCONST(-0.13090704451073998);
+    ARK_A(A,4,4) = RCONST(0.26);
+    ARK_A(A,5,0) = RCONST(0.13855640231268224);
+    ARK_A(A,5,2) = RCONST(-0.04245337201752043);
+    ARK_A(A,5,3) = RCONST(0.02446657898003141);
+    ARK_A(A,5,4) = RCONST(0.61943039072480676);
+    ARK_A(A,5,5) = RCONST(0.26);
+    ARK_A(A,6,0) = RCONST(0.13659751177640291);
+    ARK_A(A,6,2) = RCONST(-0.05496908796538376);
+    ARK_A(A,6,3) = RCONST(-0.04118626728321046);
+    ARK_A(A,6,4) = RCONST(0.62993304899016403);
+    ARK_A(A,6,5) = RCONST(0.06962479448202728);
+    ARK_A(A,6,6) = RCONST(0.26);
+
+    b[0] = RCONST(0.13659751177640291);
+    b[2] = RCONST(-0.05496908796538376);
+    b[3] = RCONST(-0.04118626728321046);
+    b[4] = RCONST(0.62993304899016403);
+    b[5] = RCONST(0.06962479448202728);
+    b[6] = RCONST(0.26);
+
+    b2[0] = RCONST(0.13855640231268224);
+    b2[2] = RCONST(-0.04245337201752043);
+    b2[3] = RCONST(0.02446657898003141);
+    b2[4] = RCONST(0.61943039072480676);
+    b2[5] = RCONST(0.26);
+
+    c[1] = RCONST(0.52);
+    c[2] = RCONST(1.230333209967908);
+    c[3] = RCONST(0.895765984350076);
+    c[4] = RCONST(0.436393609858648);
+    c[5] = RCONST(1.0);
+    c[6] = RCONST(1.0);
+    break;
+
+  case(ARK548L2SA_DIRK_8_4_5):    /* ARK5(4)8L[2]SA-ESDIRK */
+    *s = 8;
+    *q = 5;
+    *p = 4;
+    ARK_A(A,1,0) = RCONST(41.0)/RCONST(200.0);
+    ARK_A(A,1,1) = RCONST(41.0)/RCONST(200.0);
+    ARK_A(A,2,0) = RCONST(41.0)/RCONST(400.0);
+    ARK_A(A,2,1) = RCONST(-567603406766.0)/RCONST(11931857230679.0);
+    ARK_A(A,2,2) = RCONST(41.0)/RCONST(200.0);
+    ARK_A(A,3,0) = RCONST(683785636431.0)/RCONST(9252920307686.0);
+    ARK_A(A,3,2) = RCONST(-110385047103.0)/RCONST(1367015193373.0);
+    ARK_A(A,3,3) = RCONST(41.0)/RCONST(200.0);
+    ARK_A(A,4,0) = RCONST(3016520224154.0)/RCONST(10081342136671.0);
+    ARK_A(A,4,2) = RCONST(30586259806659.0)/RCONST(12414158314087.0);
+    ARK_A(A,4,3) = RCONST(-22760509404356.0)/RCONST(11113319521817.0);
+    ARK_A(A,4,4) = RCONST(41.0)/RCONST(200.0);
+    ARK_A(A,5,0) = RCONST(218866479029.0)/RCONST(1489978393911.0);
+    ARK_A(A,5,2) = RCONST(638256894668.0)/RCONST(5436446318841.0);
+    ARK_A(A,5,3) = RCONST(-1179710474555.0)/RCONST(5321154724896.0);
+    ARK_A(A,5,4) = RCONST(-60928119172.0)/RCONST(8023461067671.0);
+    ARK_A(A,5,5) = RCONST(41.0)/RCONST(200.0);
+    ARK_A(A,6,0) = RCONST(1020004230633.0)/RCONST(5715676835656.0);
+    ARK_A(A,6,2) = RCONST(25762820946817.0)/RCONST(25263940353407.0);
+    ARK_A(A,6,3) = RCONST(-2161375909145.0)/RCONST(9755907335909.0);
+    ARK_A(A,6,4) = RCONST(-211217309593.0)/RCONST(5846859502534.0);
+    ARK_A(A,6,5) = RCONST(-4269925059573.0)/RCONST(7827059040749.0);
+    ARK_A(A,6,6) = RCONST(41.0)/RCONST(200.0);
+    ARK_A(A,7,0) = RCONST(-872700587467.0)/RCONST(9133579230613.0);
+    ARK_A(A,7,3) = RCONST(22348218063261.0)/RCONST(9555858737531.0);
+    ARK_A(A,7,4) = RCONST(-1143369518992.0)/RCONST(8141816002931.0);
+    ARK_A(A,7,5) = RCONST(-39379526789629.0)/RCONST(19018526304540.0);
+    ARK_A(A,7,6) = RCONST(32727382324388.0)/RCONST(42900044865799.0);
+    ARK_A(A,7,7) = RCONST(41.0)/RCONST(200.0);
+
+    b[0] = RCONST(-872700587467.0)/RCONST(9133579230613.0);
+    b[3] = RCONST(22348218063261.0)/RCONST(9555858737531.0);
+    b[4] = RCONST(-1143369518992.0)/RCONST(8141816002931.0);
+    b[5] = RCONST(-39379526789629.0)/RCONST(19018526304540.0);
+    b[6] = RCONST(32727382324388.0)/RCONST(42900044865799.0);
+    b[7] = RCONST(41.0)/RCONST(200.0);
+
+    b2[0] = RCONST(-975461918565.0)/RCONST(9796059967033.0);
+    b2[3] = RCONST(78070527104295.0)/RCONST(32432590147079.0);
+    b2[4] = RCONST(-548382580838.0)/RCONST(3424219808633.0);
+    b2[5] = RCONST(-33438840321285.0)/RCONST(15594753105479.0);
+    b2[6] = RCONST(3629800801594.0)/RCONST(4656183773603.0);
+    b2[7] = RCONST(4035322873751.0)/RCONST(18575991585200.0);
+
+    c[1] = RCONST(41.0)/RCONST(100.0);
+    c[2] = RCONST(2935347310677.0)/RCONST(11292855782101.0);
+    c[3] = RCONST(1426016391358.0)/RCONST(7196633302097.0);
+    c[4] = RCONST(92.0)/RCONST(100.0);
+    c[5] = RCONST(24.0)/RCONST(100.0);
+    c[6] = RCONST(3.0)/RCONST(5.0);
+    c[7] = RCONST(1.0);
+    break;
+
+  default:
+
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeGetButcherTable", "Unknown Butcher table");
+    return(ARK_ILL_INPUT);
+
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+  EOF
+  ---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_dense.c b/src/arkode/arkode_dense.c
new file mode 100644
index 0000000..b472218
--- /dev/null
+++ b/src/arkode/arkode_dense.c
@@ -0,0 +1,613 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the impleentation file for the ARKDENSE linear solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_dense.h>
+#include "arkode_direct_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* ARKDENSE linit, lsetup, lsolve, and lfree routines */
+static int arkDenseInit(ARKodeMem ark_mem);
+static int arkDenseSetup(ARKodeMem ark_mem, int convfail, N_Vector ypred,
+			 N_Vector fpred, booleantype *jcurPtr, 
+			 N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+static int arkDenseSolve(ARKodeMem ark_mem, N_Vector b, N_Vector weight,
+			 N_Vector ycur, N_Vector fcur);
+static int arkDenseFree(ARKodeMem ark_mem);
+
+/* ARKDENSE minit, msetup, msolve, mfree and mtimes routines */
+static int arkMassDenseInit(ARKodeMem ark_mem);
+static int arkMassDenseSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			     N_Vector vtemp2, N_Vector vtemp3);
+static int arkMassDenseSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight);
+static int arkMassDenseFree(ARKodeMem ark_mem);
+static int arkMassDenseMultiply(N_Vector v, N_Vector Mv, 
+				realtype t, void *arkode_mem);
+                
+                
+/*---------------------------------------------------------------
+ ARKDense:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the dense linear solver module.  
+ ARKDense first calls the existing lfree routine if this is not 
+ NULL.  Then it sets the ark_linit, ark_lsetup, ark_lsolve and
+ ark_lfree fields in (*arkode_mem) to be arkDenseInit, 
+ arkDenseSetup, arkDenseSolve, and arkDenseFree, respectively.  
+ It allocates memory for a structure of type ARKDlsMemRec and 
+ sets the ark_lmem field in (*arkode_mem) to the address of this 
+ structure.  It sets setupNonNull in (*arkode_mem) to TRUE, and 
+ the d_jac field to the default arkDlsDenseDQJac.  Finally, it
+ allocates memory for M, savedJ, and lpivots. The return value 
+ is SUCCESS = 0, or LMEM_FAIL = -1.
+
+ NOTE: The dense linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKDense will first 
+       test for compatible a compatible N_Vector internal
+       representation by checking that N_VGetArrayPointer and
+       N_VSetArrayPointer exist.
+---------------------------------------------------------------*/
+int ARKDense(void *arkode_mem, long int N)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDENSE", 
+                    "ARKDense", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the DENSE solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL ||
+      ark_mem->ark_tempv->ops->nvsetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKDENSE", 
+                    "ARKDense", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree !=NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */
+  ark_mem->ark_linit  = arkDenseInit;
+  ark_mem->ark_lsetup = arkDenseSetup;
+  ark_mem->ark_lsolve = arkDenseSolve;
+  ark_mem->ark_lfree  = arkDenseFree;
+  ark_mem->ark_lsolve_type = 1;
+
+  /* Get memory for ARKDlsMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMem) malloc(sizeof(struct ARKDlsMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+                    "ARKDense", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_DENSE;
+
+  /* Initialize Jacobian-related data */
+  arkdls_mem->d_jacDQ  = TRUE;
+  arkdls_mem->d_djac   = NULL;
+  arkdls_mem->d_J_data = NULL;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_setupNonNull = TRUE;
+
+  /* Initialize counters */
+  arkDlsInitializeCounters(arkdls_mem);
+
+  /* Set problem dimension */
+  arkdls_mem->d_n = N;
+
+  /* Allocate memory for M, savedJ, and pivot array */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_M = NewDenseMat(N, N);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+                    "ARKDense", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_savedJ = NULL;
+  arkdls_mem->d_savedJ = NewDenseMat(N, N);
+  if (arkdls_mem->d_savedJ == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+                    "ARKDense", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_lpivots = NULL;
+  arkdls_mem->d_lpivots = NewLintArray(N);
+  if (arkdls_mem->d_lpivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+                    "ARKDense", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    DestroyMat(arkdls_mem->d_savedJ);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkDenseInit:
+
+ This routine does remaining initializations specific to the 
+ dense linear solver.
+---------------------------------------------------------------*/
+static int arkDenseInit(ARKodeMem ark_mem)
+{
+  ARKDlsMem arkdls_mem;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  
+  arkDlsInitializeCounters(arkdls_mem);
+
+  /* Set Jacobian function and data, depending on jacDQ */
+  if (arkdls_mem->d_jacDQ) {
+    arkdls_mem->d_djac   = arkDlsDenseDQJac;
+    arkdls_mem->d_J_data = ark_mem;
+  } else {
+    arkdls_mem->d_J_data = ark_mem->ark_user_data;
+  }
+
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkDenseSetup:
+
+ This routine does the setup operations for the dense linear solver.
+ It makes a decision whether or not to call the Jacobian evaluation
+ routine based on various state variables, and if not it uses the 
+ saved copy.  In any case, it constructs the Newton matrix 
+ A = M - gamma*J, updates counters, and calls the dense LU 
+ factorization routine.
+---------------------------------------------------------------*/
+static int arkDenseSetup(ARKodeMem ark_mem, int convfail, 
+			 N_Vector ypred, N_Vector fpred, 
+			 booleantype *jcurPtr, N_Vector vtemp1, 
+			 N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma, *Acol_j, *Mcol_j;
+  long int i, j, ier;
+  ARKDlsMem arkdls_mem;
+  ARKDlsMassMem arkdls_mass_mem;
+  int retval;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+ 
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkdls_mem->d_nstlj + ARKD_MSBJ) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKD_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  jok = !jbad;
+ 
+  /* If jok = TRUE, use saved copy of J */
+  if (jok) {
+    *jcurPtr = FALSE;
+    DenseCopy(arkdls_mem->d_savedJ, arkdls_mem->d_M);
+
+  /* If jok = FALSE, call jac routine for new J value */
+  } else {
+    arkdls_mem->d_nje++;
+    arkdls_mem->d_nstlj = ark_mem->ark_nst;
+    *jcurPtr = TRUE;
+    SetToZero(arkdls_mem->d_M);
+
+    retval = arkdls_mem->d_djac(arkdls_mem->d_n, ark_mem->ark_tn, 
+				ypred, fpred, arkdls_mem->d_M, 
+				arkdls_mem->d_J_data, 
+				vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_JACFUNC_UNRECVR, "ARKDENSE", 
+		      "arkDenseSetup",  MSGD_JACFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_RECVR;
+      return(1);
+    }
+
+    DenseCopy(arkdls_mem->d_M, arkdls_mem->d_savedJ);
+
+  }
+  
+  /* Scale J by -gamma */
+  DenseScale(-ark_mem->ark_gamma, arkdls_mem->d_M);
+  
+  /* Add mass matrix to get A = M-gamma*J*/
+  if (ark_mem->ark_mass_matrix) {
+
+    /* Compute mass matrix */
+    arkdls_mass_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+    SetToZero(arkdls_mass_mem->d_M);
+    retval = arkdls_mass_mem->d_dmass(arkdls_mass_mem->d_n, 
+				      ark_mem->ark_tn, 
+				      arkdls_mass_mem->d_M, 
+				      arkdls_mass_mem->d_M_data, 
+				      vtemp1, vtemp2, vtemp3);
+    arkdls_mass_mem->d_nme++;
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKDENSE", 
+		      "arkDenseSetup",  MSGD_MASSFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+      return(1);
+    }
+
+    /* Add to A */
+    for (j=0; j<arkdls_mem->d_M->N; j++) {
+      Acol_j = arkdls_mem->d_M->cols[j];
+      Mcol_j = arkdls_mass_mem->d_M->cols[j];
+      for (i=0; i<arkdls_mem->d_M->M; i++) 
+	Acol_j[i] += Mcol_j[i];
+    }
+  } else {
+    AddIdentity(arkdls_mem->d_M);
+  }
+
+  /* Do LU factorization of A */
+  ier = DenseGETRF(arkdls_mem->d_M, arkdls_mem->d_lpivots); 
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  arkdls_mem->d_last_flag = ier;
+  if (ier > 0) return(1);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkDenseSolve:
+
+ This routine handles the solve operation for the dense linear 
+ solver by calling the dense backsolve routine.  The returned 
+ value is 0.
+---------------------------------------------------------------*/
+static int arkDenseSolve(ARKodeMem ark_mem, N_Vector b, 
+			 N_Vector weight, N_Vector ycur, 
+			 N_Vector fcur)
+{
+  ARKDlsMem arkdls_mem;
+  realtype *bd;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  
+  bd = N_VGetArrayPointer(b);
+
+  DenseGETRS(arkdls_mem->d_M, arkdls_mem->d_lpivots, bd);
+
+  /* scale the correction to account for change in gamma */
+  if (ark_mem->ark_gamrat != ONE) 
+    N_VScale(TWO/(ONE + ark_mem->ark_gamrat), b, b);
+  
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkDenseFree:
+
+ This routine frees memory specific to the dense linear solver.
+---------------------------------------------------------------*/
+static int arkDenseFree(ARKodeMem ark_mem)
+{
+  ARKDlsMem  arkdls_mem;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  
+  DestroyMat(arkdls_mem->d_M);
+  DestroyMat(arkdls_mem->d_savedJ);
+  DestroyArray(arkdls_mem->d_lpivots);
+  free(arkdls_mem);
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+
+/*---------------------------------------------------------------
+ ARKMassDense:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the dense mass matrix linear solver
+ module.  ARKMassDense first calls the existing mfree routine if 
+ this is not NULL.  Then it sets the ark_minit, ark_msetup, 
+ ark_msolve, ark_mfree fields in (*arkode_mem) to be 
+ arkMassDenseInit, arkMassDenseSetup, arkMassDenseSolve, and 
+ arkMassDenseFree, respectively.  It allocates memory for a 
+ structure of type ARKDlsMassMemRec and sets the ark_mass_mem
+ field in (*arkode_mem) to the address of this structure.  It 
+ sets MassSetupNonNull in (*arkode_mem) to TRUE.  Finally, it 
+ allocates memory for M and lpivots. The return value is 
+ SUCCESS = 0, or LMEM_FAIL = -1.
+
+ NOTE: The dense linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKMassDense will first 
+       test for compatible a compatible N_Vector internal
+       representation by checking that N_VGetArrayPointer and
+       N_VSetArrayPointer exist.
+---------------------------------------------------------------*/
+int ARKMassDense(void *arkode_mem, long int N, ARKDlsDenseMassFn dmass)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDENSE", 
+		    "ARKMassDense", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the DENSE solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL ||
+      ark_mem->ark_tempv->ops->nvsetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKDENSE", 
+		    "ARKMassDense", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree !=NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = arkMassDenseInit;
+  ark_mem->ark_msetup = arkMassDenseSetup;
+  ark_mem->ark_msolve = arkMassDenseSolve;
+  ark_mem->ark_mfree  = arkMassDenseFree;
+  ark_mem->ark_mtimes = arkMassDenseMultiply;
+  ark_mem->ark_mtimes_data = (void *) ark_mem;
+  ark_mem->ark_msolve_type = 1;
+
+  /* Get memory for ARKDlsMassMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMassMem) malloc(sizeof(struct ARKDlsMassMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+		    "ARKMassDense", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_DENSE;
+
+  /* Initialize mass-matrix-related data */
+  arkdls_mem->d_nme = 0;
+  arkdls_mem->d_dmass = dmass;
+  arkdls_mem->d_M_data = NULL;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = TRUE;
+
+  /* Set problem dimension */
+  arkdls_mem->d_n = N;
+
+  /* Allocate memory for M, M_lu, and pivot array */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_M = NewDenseMat(N, N);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+		    "ARKMassDense", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_M_lu = NULL;
+  arkdls_mem->d_M_lu = NewDenseMat(N, N);
+  if (arkdls_mem->d_M_lu == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+		    "ARKMassDense", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_lpivots = NULL;
+  arkdls_mem->d_lpivots = NewLintArray(N);
+  if (arkdls_mem->d_lpivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKDENSE", 
+		    "ARKMassDense", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    DestroyMat(arkdls_mem->d_M_lu);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassDenseInit:
+
+ This routine does remaining initializations specific to the 
+ dense linear solver.
+---------------------------------------------------------------*/
+static int arkMassDenseInit(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem arkdls_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  arkdls_mem->d_nme = 0;
+
+  /* Set mass matrix function data */
+  arkdls_mem->d_M_data = ark_mem->ark_user_data;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassDenseSetup:
+
+ This routine does the setup operations for the dense mass matrix 
+ solver.  It calls the mass matrix evaluation, updates counters, 
+ and calls the dense LU factorization routine.
+---------------------------------------------------------------*/
+static int arkMassDenseSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			     N_Vector vtemp2, N_Vector vtemp3)
+{
+  long int ier;
+  ARKDlsMassMem arkdls_mem;
+  int retval;
+
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+ 
+  /* call Mass routine for new M matrix */
+  SetToZero(arkdls_mem->d_M);
+  retval = arkdls_mem->d_dmass(arkdls_mem->d_n, ark_mem->ark_tn, 
+			       arkdls_mem->d_M, 
+			       arkdls_mem->d_M_data, vtemp1, 
+			       vtemp2, vtemp3);
+  arkdls_mem->d_nme++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKDENSE", 
+		    "arkMassDenseSetup",  MSGD_MASSFUNC_FAILED);
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+    return(-1);
+  }
+  if (retval > 0) {
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+    return(1);
+  }
+
+  /* Copy M into M_lu for LU decomposition */
+  DenseCopy(arkdls_mem->d_M, arkdls_mem->d_M_lu);
+
+  /* Do LU factorization of M_lu */
+  ier = DenseGETRF(arkdls_mem->d_M_lu, arkdls_mem->d_lpivots); 
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  arkdls_mem->d_last_flag = ier;
+  if (ier > 0) return(1);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassDenseSolve:
+
+ This routine handles the solve operation for the dense mass 
+ matrix solver by calling the dense backsolve routine.  The 
+ returned value is 0.
+---------------------------------------------------------------*/
+static int arkMassDenseSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight)
+{
+  ARKDlsMassMem arkdls_mem;
+  realtype *bd;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  bd = N_VGetArrayPointer(b);
+  DenseGETRS(arkdls_mem->d_M_lu, arkdls_mem->d_lpivots, bd);
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassDenseFree:
+
+ This routine frees memory specific to the dense mass matrix
+ solver.
+---------------------------------------------------------------*/
+static int arkMassDenseFree(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem  arkdls_mem;
+
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  
+  DestroyMat(arkdls_mem->d_M);
+  DestroyMat(arkdls_mem->d_M_lu);
+  DestroyArray(arkdls_mem->d_lpivots);
+  free(arkdls_mem);
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassDenseMultiply performs a matrix-vector product, 
+ multiplying the current mass matrix by a given vector.
+---------------------------------------------------------------*/                  
+static int arkMassDenseMultiply(N_Vector v, N_Vector Mv, 
+				realtype t, void *arkode_mem)
+{
+  /* extract the DlsMassMem structure from the user_data pointer */
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+  realtype *vdata=NULL, *Mvdata=NULL;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDENSE", 
+		    "arkMassDenseMultiply", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  /* access the vector arrays (since they must be serial vectors) */
+  vdata = N_VGetArrayPointer(v);
+  Mvdata = N_VGetArrayPointer(Mv);
+  if (vdata == NULL || Mvdata == NULL)
+    return(1);
+
+  /* perform matrix-vector product and return */
+  DenseMatvec(arkdls_mem->d_M, vdata, Mvdata);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+   EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_direct.c b/src/arkode/arkode_direct.c
new file mode 100644
index 0000000..ad03b14
--- /dev/null
+++ b/src/arkode/arkode_direct.c
@@ -0,0 +1,617 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the ARKDLS linear solvers
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode_impl.h"
+#include "arkode_direct_impl.h"
+#include <sundials/sundials_math.h>
+
+/*===============================================================
+ FUNCTION SPECIFIC CONSTANTS
+===============================================================*/
+
+/* Constant for DQ Jacobian approximation */
+#define MIN_INC_MULT RCONST(1000.0)
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+
+
+/*===============================================================
+ EXPORTED FUNCTIONS
+===============================================================*/
+              
+/*---------------------------------------------------------------
+ ARKDlsSetDenseJacFn specifies the dense Jacobian function.
+---------------------------------------------------------------*/
+int ARKDlsSetDenseJacFn(void *arkode_mem, ARKDlsDenseJacFn jac)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsSetDenseJacFn", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_LMEM_NULL, "ARKDLS", 
+		    "ARKDlsSetDenseJacFn", MSGD_LMEM_NULL);
+    return(ARKDLS_LMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  if (jac != NULL) {
+    arkdls_mem->d_jacDQ = FALSE;
+    arkdls_mem->d_djac  = jac;
+  } else {
+    arkdls_mem->d_jacDQ = TRUE;
+  }
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsSetBandJacFn specifies the band Jacobian function.
+---------------------------------------------------------------*/
+int ARKDlsSetBandJacFn(void *arkode_mem, ARKDlsBandJacFn jac)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsSetBandJacFn", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_LMEM_NULL, "ARKDLS", 
+		    "ARKDlsSetBandJacFn", MSGD_LMEM_NULL);
+    return(ARKDLS_LMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  if (jac != NULL) {
+    arkdls_mem->d_jacDQ = FALSE;
+    arkdls_mem->d_bjac  = jac;
+  } else {
+    arkdls_mem->d_jacDQ = TRUE;
+  }
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsSetDenseMassFn specifies the dense mass matrix function.
+---------------------------------------------------------------*/
+int ARKDlsSetDenseMassFn(void *arkode_mem, ARKDlsDenseMassFn mass)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsSetDenseMassFn", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MASSMEM_NULL, "ARKDLS", 
+		    "ARKDlsSetDenseMassFn", MSGD_MASSMEM_NULL);
+    return(ARKDLS_MASSMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  if (mass != NULL) {
+    arkdls_mem->d_dmass = mass;
+  } else {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKDLS", 
+		    "ARKDlsSetDenseMassFn", "DenseMassFn must be non-NULL");
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsSetBandMassFn specifies the band mass matrix function.
+---------------------------------------------------------------*/
+int ARKDlsSetBandMassFn(void *arkode_mem, ARKDlsBandMassFn mass)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsSetBandMassFn", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MASSMEM_NULL, "ARKDLS", 
+		    "ARKDlsSetBandMassFn", MSGD_MASSMEM_NULL);
+    return(ARKDLS_MASSMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  if (mass != NULL) {
+    arkdls_mem->d_bmass = mass;
+  } else {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKDLS", 
+		    "ARKDlsSetBandMassFn", "BandMassFn must be non-NULL");
+    return(ARKDLS_MASSMEM_NULL);
+  }
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetWorkSpace returns the length of workspace allocated for 
+ the ARKDLS linear solver.
+---------------------------------------------------------------*/
+int ARKDlsGetWorkSpace(void *arkode_mem, long int *lenrwLS, long int *leniwLS)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsGetWorkSpace", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_LMEM_NULL, "ARKDLS", 
+		    "ARKDlsGetWorkSpace", MSGD_LMEM_NULL);
+    return(ARKDLS_LMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  if (arkdls_mem->d_type == SUNDIALS_DENSE) {
+    *lenrwLS = 2*arkdls_mem->d_n*arkdls_mem->d_n;
+    *leniwLS = arkdls_mem->d_n;
+  } else if (arkdls_mem->d_type == SUNDIALS_BAND) {
+    *lenrwLS = arkdls_mem->d_n*(arkdls_mem->d_smu + arkdls_mem->d_mu + 2*arkdls_mem->d_ml + 2);
+    *leniwLS = arkdls_mem->d_n;
+  }
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetMassWorkSpace returns the length of workspace allocated 
+ for the ARKDLS mass matrix linear solver.
+---------------------------------------------------------------*/
+int ARKDlsGetMassWorkSpace(void *arkode_mem, long int *lenrwMLS, 
+			   long int *leniwMLS)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsGetMassWorkSpace", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MASSMEM_NULL, "ARKDLS", 
+		    "ARKDlsGetMassWorkSpace", MSGD_MASSMEM_NULL);
+    return(ARKDLS_MASSMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  if (arkdls_mem->d_type == SUNDIALS_DENSE) {
+    *lenrwMLS = 2*arkdls_mem->d_n*arkdls_mem->d_n;
+    *leniwMLS = arkdls_mem->d_n;
+  } else if (arkdls_mem->d_type == SUNDIALS_BAND) {
+    *lenrwMLS = arkdls_mem->d_n*(arkdls_mem->d_smu + arkdls_mem->d_mu + 2*arkdls_mem->d_ml + 2);
+    *leniwMLS = arkdls_mem->d_n;
+  }
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetNumJacEvals returns the number of Jacobian evaluations.
+---------------------------------------------------------------*/
+int ARKDlsGetNumJacEvals(void *arkode_mem, long int *njevals)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsGetNumJacEvals", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_LMEM_NULL, "ARKDLS", 
+		    "ARKDlsGetNumJacEvals", MSGD_LMEM_NULL);
+    return(ARKDLS_LMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  *njevals = arkdls_mem->d_nje;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetNumMassEvals returns the number of mass matrix evaluations.
+---------------------------------------------------------------*/
+int ARKDlsGetNumMassEvals(void *arkode_mem, long int *nmevals)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsGetNumMassEvals", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MASSMEM_NULL, "ARKDLS", 
+		    "ARKDlsGetNumMassEvals", MSGD_MASSMEM_NULL);
+    return(ARKDLS_MASSMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  *nmevals = arkdls_mem->d_nme;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetNumRhsEvals returns the number of calls to the ODE function
+ needed for the DQ Jacobian approximation.
+---------------------------------------------------------------*/
+int ARKDlsGetNumRhsEvals(void *arkode_mem, long int *nfevalsLS)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsGetNumRhsEvals", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_LMEM_NULL, "ARKDLS", 
+		    "ARKDlsGetNumRhsEvals", MSGD_LMEM_NULL);
+    return(ARKDLS_LMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  *nfevalsLS = arkdls_mem->d_nfeDQ;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetReturnFlagName returns the name associated with a ARKDLS
+ return value.
+---------------------------------------------------------------*/
+char *ARKDlsGetReturnFlagName(long int flag)
+{
+  char *name;
+
+  name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case ARKDLS_SUCCESS:
+    sprintf(name,"ARKDLS_SUCCESS");
+    break;   
+  case ARKDLS_MEM_NULL:
+    sprintf(name,"ARKDLS_MEM_NULL");
+    break;
+  case ARKDLS_LMEM_NULL:
+    sprintf(name,"ARKDLS_LMEM_NULL");
+    break;
+  case ARKDLS_MASSMEM_NULL:
+    sprintf(name,"ARKDLS_MASSMEM_NULL");
+    break;
+  case ARKDLS_ILL_INPUT:
+    sprintf(name,"ARKDLS_ILL_INPUT");
+    break;
+  case ARKDLS_MEM_FAIL:
+    sprintf(name,"ARKDLS_MEM_FAIL");
+    break;
+  case ARKDLS_JACFUNC_UNRECVR:
+    sprintf(name,"ARKDLS_JACFUNC_UNRECVR");
+    break;
+  case ARKDLS_JACFUNC_RECVR:
+    sprintf(name,"ARKDLS_JACFUNC_RECVR");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetLastFlag returns the last flag set in a ARKDLS function.
+---------------------------------------------------------------*/
+int ARKDlsGetLastFlag(void *arkode_mem, long int *flag)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsGetLastFlag", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_LMEM_NULL, "ARKDLS", 
+		    "ARKDlsGetLastFlag", MSGD_LMEM_NULL);
+    return(ARKDLS_LMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  *flag = arkdls_mem->d_last_flag;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKDlsGetLastMassFlag returns the last flag set in a ARKDLS mass
+  matrix function.
+---------------------------------------------------------------*/
+int ARKDlsGetLastMassFlag(void *arkode_mem, long int *flag)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKDLS", 
+		    "ARKDlsGetLastMassFlag", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MASSMEM_NULL, "ARKDLS", 
+		    "ARKDlsGetLastMassFlag", MSGD_MASSMEM_NULL);
+    return(ARKDLS_MASSMEM_NULL);
+  }
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  *flag = arkdls_mem->d_last_flag;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*===============================================================
+ DQ JACOBIAN APPROXIMATIONS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkDlsDenseDQJac:
+
+ This routine generates a dense difference quotient approximation 
+ to the Jacobian of f(t,y). It assumes that a dense matrix of 
+ type DlsMat is stored column-wise, and that elements within each 
+ column are contiguous. The address of the jth column of J is 
+ obtained via the macro DENSE_COL and this pointer is associated 
+ with an N_Vector using the N_VGetArrayPointer/N_VSetArrayPointer 
+ functions.  Finally, the actual computation of the jth column of
+ the Jacobian is done with a call to N_VLinearSum.
+---------------------------------------------------------------*/
+int arkDlsDenseDQJac(long int N, realtype t, N_Vector y, 
+		     N_Vector fy, DlsMat Jac, void *data,
+		     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  realtype fnorm, minInc, inc, inc_inv, yjsaved, srur;
+  realtype *tmp2_data, *y_data, *ewt_data;
+  N_Vector ftemp, jthCol;
+  long int j;
+  int retval = 0;
+
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* data points to arkode_mem */
+  ark_mem = (ARKodeMem) data;
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  /* Save pointer to the array in tmp2 */
+  tmp2_data = N_VGetArrayPointer(tmp2);
+
+  /* Rename work vectors for readibility */
+  ftemp = tmp1; 
+  jthCol = tmp2;
+
+  /* Obtain pointers to the data for ewt, y */
+  ewt_data = N_VGetArrayPointer(ark_mem->ark_ewt);
+  y_data   = N_VGetArrayPointer(y);
+
+  /* Set minimum increment based on uround and norm of f */
+  srur = SUNRsqrt(ark_mem->ark_uround);
+  /* fnorm = N_VWrmsNorm(fy, ark_mem->ark_ewt); */
+  fnorm = N_VWrmsNorm(fy, ark_mem->ark_rwt);
+  minInc = (fnorm != ZERO) ?
+           (MIN_INC_MULT * SUNRabs(ark_mem->ark_h) * ark_mem->ark_uround * N * fnorm) : ONE;
+
+  for (j = 0; j < N; j++) {
+
+    /* Generate the jth col of J(tn,y) */
+    N_VSetArrayPointer(DENSE_COL(Jac,j), jthCol);
+
+    yjsaved = y_data[j];
+    inc = SUNMAX(srur*SUNRabs(yjsaved), minInc/ewt_data[j]);
+    y_data[j] += inc;
+
+    retval = ark_mem->ark_fi(t, y, ftemp, ark_mem->ark_user_data);
+    arkdls_mem->d_nfeDQ++;
+    if (retval != 0) break;
+    
+    y_data[j] = yjsaved;
+
+    inc_inv = ONE/inc;
+    N_VLinearSum(inc_inv, ftemp, -inc_inv, fy, jthCol);
+
+    DENSE_COL(Jac,j) = N_VGetArrayPointer(jthCol);
+  }
+
+  /* Restore original array pointer in tmp2 */
+  N_VSetArrayPointer(tmp2_data, tmp2);
+
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ arkDlsBandDQJac:
+
+ This routine generates a banded difference quotient approximation 
+ to the Jacobian of f(t,y).  It assumes that a band matrix of type
+ DlsMat is stored column-wise, and that elements within each 
+ column are contiguous. This makes it possible to get the address 
+ of a column of J via the macro BAND_COL and to write a simple for 
+ loop to set each of the elements of a column in succession.
+---------------------------------------------------------------*/
+int arkDlsBandDQJac(long int N, long int mupper, long int mlower,
+                   realtype t, N_Vector y, N_Vector fy, 
+                   DlsMat Jac, void *data,
+                   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
+{
+  N_Vector ftemp, ytemp;
+  realtype fnorm, minInc, inc, inc_inv, srur;
+  realtype *col_j, *ewt_data, *fy_data, *ftemp_data, *y_data, *ytemp_data;
+  long int group, i, j, width, ngroups, i1, i2;
+  int retval = 0;
+
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* data points to arkode_mem */
+  ark_mem = (ARKodeMem) data;
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  /* Rename work vectors for use as temporary values of y and f */
+  ftemp = tmp1;
+  ytemp = tmp2;
+
+  /* Obtain pointers to the data for ewt, fy, ftemp, y, ytemp */
+  ewt_data   = N_VGetArrayPointer(ark_mem->ark_ewt);
+  fy_data    = N_VGetArrayPointer(fy);
+  ftemp_data = N_VGetArrayPointer(ftemp);
+  y_data     = N_VGetArrayPointer(y);
+  ytemp_data = N_VGetArrayPointer(ytemp);
+
+  /* Load ytemp with y = predicted y vector */
+  N_VScale(ONE, y, ytemp);
+
+  /* Set minimum increment based on uround and norm of f */
+  srur = SUNRsqrt(ark_mem->ark_uround);
+  /* fnorm = N_VWrmsNorm(fy, ark_mem->ark_ewt); */
+  fnorm = N_VWrmsNorm(fy, ark_mem->ark_rwt);
+  minInc = (fnorm != ZERO) ?
+           (MIN_INC_MULT * SUNRabs(ark_mem->ark_h) * ark_mem->ark_uround * N * fnorm) : ONE;
+
+  /* Set bandwidth and number of column groups for band differencing */
+  width = mlower + mupper + 1;
+  ngroups = SUNMIN(width, N);
+
+  /* Loop over column groups. */
+  for (group=1; group <= ngroups; group++) {
+    
+    /* Increment all y_j in group */
+    for(j=group-1; j < N; j+=width) {
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
+      ytemp_data[j] += inc;
+    }
+
+    /* Evaluate f with incremented y */
+    retval = ark_mem->ark_fi(ark_mem->ark_tn, ytemp, ftemp, 
+                             ark_mem->ark_user_data);
+    arkdls_mem->d_nfeDQ++;
+    if (retval != 0) break;
+
+    /* Restore ytemp, then form and load difference quotients */
+    for (j=group-1; j < N; j+=width) {
+      ytemp_data[j] = y_data[j];
+      col_j = BAND_COL(Jac,j);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
+      inc_inv = ONE/inc;
+      i1 = SUNMAX(0, j-mupper);
+      i2 = SUNMIN(j+mlower, N-1);
+      for (i=i1; i <= i2; i++)
+        BAND_COL_ELEM(col_j,i,j) = inc_inv * (ftemp_data[i] - fy_data[i]);
+    }
+  }
+  
+  return(retval);
+}
+
+
+int arkDlsInitializeCounters(ARKDlsMem arkdls_mem)
+{
+  arkdls_mem->d_nje    = 0;
+  arkdls_mem->d_nfeDQ  = 0;
+  arkdls_mem->d_nstlj  = 0;
+  return(0);
+}
+
+/*---------------------------------------------------------------
+    EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_direct_impl.h b/src/arkode/arkode_direct_impl.h
new file mode 100644
index 0000000..29b1906
--- /dev/null
+++ b/src/arkode/arkode_direct_impl.h
@@ -0,0 +1,141 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Common implementation header file for the ARKDLS linear solvers.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKDLS_IMPL_H
+#define _ARKDLS_IMPL_H
+
+#include <arkode/arkode_direct.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ ARKDLS solver constants:
+
+ ARKD_MSBJ   maximum number of steps between Jacobian evaluations
+ ARKD_DGMAX  maximum change in gamma between Jacobian evaluations
+---------------------------------------------------------------*/
+#define ARKD_MSBJ  50
+#define ARKD_DGMAX RCONST(0.2)
+
+
+/*---------------------------------------------------------------
+ Types: ARKDlsMemRec, ARKDlsMem                             
+
+ ARKDlsMem is pointer to a ARKDlsMemRec structure.
+---------------------------------------------------------------*/
+typedef struct ARKDlsMemRec {
+
+  int d_type;             /* SUNDIALS_DENSE or SUNDIALS_BAND              */
+
+  long int d_n;           /* problem dimension                            */
+
+  long int d_ml;          /* lower bandwidth of Jacobian                  */
+  long int d_mu;          /* upper bandwidth of Jacobian                  */ 
+  long int d_smu;         /* upper bandwith of M = MIN(N-1,d_mu+d_ml)     */
+
+  booleantype d_jacDQ;    /* TRUE if using internal DQ Jacobian approx.   */
+  ARKDlsDenseJacFn d_djac; /* dense Jacobian routine to be called          */
+  ARKDlsBandJacFn d_bjac;  /* band Jacobian routine to be called           */
+  void *d_J_data;         /* user data is passed to djac or bjac          */
+
+  DlsMat d_M;             /* M = I - gamma * df/dy                        */
+  DlsMat d_savedJ;        /* savedJ = old Jacobian                        */
+
+  int *d_pivots;          /* pivots = int pivot array for PM = LU         */
+  long int *d_lpivots;    /* lpivots = long int pivot array for PM = LU   */
+
+  long int  d_nstlj;      /* nstlj = nst at last Jacobian eval.           */
+
+  long int d_nje;         /* nje = no. of calls to jac                    */
+
+  long int d_nfeDQ;       /* no. of calls to f due to DQ Jacobian approx. */
+
+  long int d_last_flag;   /* last error return flag                       */
+  
+} *ARKDlsMem;
+
+
+/*---------------------------------------------------------------
+ Types: ARKDlsMassMemRec, ARKDlsMassMem
+
+ ARKDlsMassMem is pointer to a ARKDlsMassMemRec structure.
+---------------------------------------------------------------*/
+typedef struct ARKDlsMassMemRec {
+
+  int d_type;                /* SUNDIALS_DENSE or SUNDIALS_BAND            */
+
+  long int d_n;              /* problem dimension                          */
+
+  long int d_ml;             /* lower bandwidth of mass matrix             */
+  long int d_mu;             /* upper bandwidth of mass matrix             */ 
+  long int d_smu;            /* upper bandwith of M = MIN(N-1,d_mu+d_ml)   */
+
+  ARKDlsDenseMassFn d_dmass; /* dense mass matrix routine to be called     */
+  ARKDlsBandMassFn d_bmass;  /* band mass matrix routine to be called      */
+  void *d_M_data;            /* user data is passed to djac or bjac        */
+
+  DlsMat d_M;                /* mass matrix structure                      */
+  DlsMat d_M_lu;             /* mass matrix structure for LU decomposition */
+
+  int *d_pivots;             /* pivots = int pivot array for PM = LU       */
+  long int *d_lpivots;       /* lpivots = long int pivot array for PM = LU */
+
+  long int d_nme;            /* nje = no. of calls to mass matrix routine  */
+
+  long int d_last_flag;      /* last error return flag                     */
+  
+} *ARKDlsMassMem;
+
+
+/*---------------------------------------------------------------
+ Prototypes of internal functions
+---------------------------------------------------------------*/
+int arkDlsDenseDQJac(long int N, realtype t, N_Vector y, 
+                     N_Vector fy, DlsMat Jac, void *data,
+                     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+int arkDlsBandDQJac(long int N, long int mupper, long int mlower,
+                    realtype t, N_Vector y, N_Vector fy, 
+                    DlsMat Jac, void *data, N_Vector tmp1, 
+                    N_Vector tmp2, N_Vector tmp3);
+
+/* Auxilliary functions */
+
+int arkDlsInitializeCounters(ARKDlsMem arkdls_mem);
+
+
+/*---------------------------------------------------------------
+ Error Messages
+---------------------------------------------------------------*/
+#define MSGD_ARKMEM_NULL    "Integrator memory is NULL."
+#define MSGD_BAD_NVECTOR    "A required vector operation is not implemented."
+#define MSGD_BAD_SIZES      "Illegal bandwidth parameter(s). Must have 0 <=  ml, mu <= N-1."
+#define MSGD_MEM_FAIL       "A memory request failed."
+#define MSGD_LMEM_NULL      "Linear solver memory is NULL."
+#define MSGD_MASSMEM_NULL   "Mass matrix solver memory is NULL."
+#define MSGD_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
+#define MSGD_MASSFUNC_FAILED "The mass matrix routine failed in an unrecoverable manner."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h
new file mode 100644
index 0000000..b8bfcf2
--- /dev/null
+++ b/src/arkode/arkode_impl.h
@@ -0,0 +1,805 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation header file for the main ARKODE integrator.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKODE_IMPL_H
+#define _ARKODE_IMPL_H
+
+#include <stdarg.h>
+#include <arkode/arkode.h>
+#include <arkode/arkode_spils.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/*===============================================================
+             ARKODE Private Constants                             
+===============================================================*/
+
+/* Basic ARKODE constants */
+#define Q_DEFAULT        4       /* default RK order */
+#define QDENSE_DEF       3       /* default dense output order */
+#define MXSTEP_DEFAULT   500     /* mxstep default value */
+#define MAXNEF           7       /* maxnef default value */
+#define MAXNCF           10      /* maxncf default value */
+#define MXHNIL           10      /* mxhnil default value */
+#define MAXCOR           3       /* maxcor default value */
+#define FP_ACCEL_M       3       /* fp_m default value */
+
+/* Numeric constants */
+#define ZERO   RCONST(0.0)      /* real 0.0     */
+#define TINY   RCONST(1.0e-10)  /* small number */
+#define TENTH  RCONST(0.1)      /* real 0.1     */
+#define POINT2 RCONST(0.2)      /* real 0.2     */
+#define FOURTH RCONST(0.25)     /* real 0.25    */
+#define HALF   RCONST(0.5)      /* real 0.5     */
+#define ONE    RCONST(1.0)      /* real 1.0     */
+#define TWO    RCONST(2.0)      /* real 2.0     */
+#define THREE  RCONST(3.0)      /* real 3.0     */
+#define FOUR   RCONST(4.0)      /* real 4.0     */
+#define FIVE   RCONST(5.0)      /* real 5.0     */
+#define SIX    RCONST(6.0)      /* real 6.0     */
+#define SEVEN  RCONST(7.0)      /* real 7.0     */
+#define TWELVE RCONST(12.0)     /* real 12.0    */
+#define HUND   RCONST(100.0)    /* real 100.0   */
+
+/* Time step controller default values */
+#define CFLFAC    RCONST(0.5)
+#define SAFETY    RCONST(0.96)  /* CVODE uses 1.0  */
+#define BIAS      RCONST(1.5)   /* CVODE uses 6.0  */
+#define GROWTH    RCONST(20.0)  /* CVODE uses 10.0 */
+#define HFIXED_LB RCONST(1.0)   /* CVODE uses 1.0  */
+#define HFIXED_UB RCONST(1.5)   /* CVODE uses 1.5  */
+#define AD0_K1    RCONST(0.58)  /* PID controller constants */
+#define AD0_K2    RCONST(0.21)
+#define AD0_K3    RCONST(0.1)
+#define AD1_K1    RCONST(0.8)   /* PI controller constants */
+#define AD1_K2    RCONST(0.31)
+#define AD2_K1    RCONST(1.0)   /* I controller constants */
+#define AD3_K1    RCONST(0.367) /* explicit Gustafsson controller */
+#define AD3_K2    RCONST(0.268)
+#define AD4_K1    RCONST(0.98)  /* implicit Gustafsson controller */
+#define AD4_K2    RCONST(0.95)
+#define AD5_K1    RCONST(0.367) /* imex Gustafsson controller */
+#define AD5_K2    RCONST(0.268)
+#define AD5_K3    RCONST(0.95)
+
+/* Default solver tolerance factor */
+/* #define NLSCOEF   RCONST(0.003)   /\* Hairer & Wanner constant *\/ */
+/* #define NLSCOEF   RCONST(0.2)     /\* CVODE constant *\/ */
+#define NLSCOEF   RCONST(0.1)
+
+/* Control constants for tolerances */
+#define ARK_SS  0
+#define ARK_SV  1
+#define ARK_WF  2
+
+
+/*===============================================================
+             ARKODE Routine-Specific Constants                   
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Control constants for lower-level functions used by arkStep:
+-----------------------------------------------------------------
+ arkHin return values:  ARK_SUCCESS, ARK_RHSFUNC_FAIL, or 
+    ARK_TOO_CLOSE
+
+ arkStep control constants:  SOLVE_SUCCESS or PREDICT_AGAIN
+
+ arkStep return values:  ARK_SUCCESS, ARK_LSETUP_FAIL, 
+    ARK_LSOLVE_FAIL, ARK_RHSFUNC_FAIL, ARK_RTFUNC_FAIL,
+    ARK_CONV_FAILURE, ARK_ERR_FAILURE or ARK_FIRST_RHSFUNC_ERR
+
+ arkNls input nflag values:  FIRST_CALL, PREV_CONV_FAIL or 
+    PREV_ERR_FAIL
+    
+ arkNls return values:  ARK_SUCCESS, ARK_LSETUP_FAIL,
+    ARK_LSOLVE_FAIL, ARK_RHSFUNC_FAIL, CONV_FAIL or
+    RHSFUNC_RECVR
+ 
+ arkNewtonIteration return values:  ARK_SUCCESS, ARK_LSOLVE_FAIL,
+    ARK_RHSFUNC_FAIL, CONV_FAIL, RHSFUNC_RECVR or TRY_AGAIN
+---------------------------------------------------------------*/
+#define SOLVE_SUCCESS    +2
+#define PREDICT_AGAIN    +3
+
+#define CONV_FAIL        +4 
+#define TRY_AGAIN        +5
+
+#define FIRST_CALL       +6
+#define PREV_CONV_FAIL   +7
+#define PREV_ERR_FAIL    +8
+
+#define RHSFUNC_RECVR    +9
+
+
+/*---------------------------------------------------------------
+ Return values for lower-level rootfinding functions
+-----------------------------------------------------------------
+ arkRootCheck1:  ARK_SUCCESS or ARK_RTFUNC_FAIL
+
+ arkRootCheck2:  ARK_SUCCESS, ARK_RTFUNC_FAIL, CLOSERT or RTFOUND
+
+ arkRootCheck3:  ARK_SUCCESS, ARK_RTFUNC_FAIL or RTFOUND
+
+ arkRootfind:  ARK_SUCCESS, ARK_RTFUNC_FAIL or RTFOUND
+---------------------------------------------------------------*/
+#define RTFOUND          +1
+#define CLOSERT          +3
+
+
+/*---------------------------------------------------------------
+ Algorithmic constants
+-----------------------------------------------------------------
+ ARKodeGetDky and arkStep:  FUZZ_FACTOR
+
+ arkHin:  H0_LBFACTOR, H0_UBFACTOR, H0_BIAS and H0_ITERS
+
+ arkStep:  
+    ETAMX1      maximum step size change on first step
+    ETAMXF      step size reduction factor on multiple error 
+                test failures (multiple implies >= SMALL_NEF)
+    ETAMIN      smallest allowable step size reduction factor 
+                on an error test failure
+    ETACF       step size reduction factor on nonlinear 
+                convergence failure
+    ONEPSM      safety factor for floating point comparisons
+    ONEMSM      safety factor for floating point comparisons
+    SMALL_NEF   if an error failure occurs and SMALL_NEF <= nef,
+                then reset  eta = MIN(eta, ETAMXF)
+
+ arkNls:
+    CRDOWN      constant used in the estimation of the 
+                convergence rate (crate) of the iterates for 
+                the nonlinear equation
+    DGMAX       if |gamma/gammap-1| > DGMAX then call lsetup
+    RDIV        declare divergence if ratio del/delp > RDIV
+    MSBP        max no. of steps between lsetup calls
+---------------------------------------------------------------*/
+#define FUZZ_FACTOR RCONST(100.0)
+
+#define H0_LBFACTOR RCONST(100.0)
+#define H0_UBFACTOR RCONST(0.1)
+#define H0_BIAS     HALF
+#define H0_ITERS    4
+
+#define ETAMX1      RCONST(10000.0)     /* default */
+#define ETAMXF      RCONST(0.3)         /* default */
+#define ETAMIN      RCONST(0.1)         /* default */
+#define ETACF       RCONST(0.25)        /* default */
+#define ONEPSM      RCONST(1.000001)
+#define ONEMSM      RCONST(0.999999)
+#define SMALL_NEF   2                   /* default */
+
+#define CRDOWN      RCONST(0.3)         /* default */
+#define DGMAX       RCONST(0.2)         /* default */
+#define RDIV        RCONST(2.3)         /* default */
+#define MSBP        20                  /* default */
+
+
+/*===============================================================
+  MAIN INTEGRATOR MEMORY BLOCK
+===============================================================*/
+
+/*---------------------------------------------------------------
+ Types : struct ARKodeMemRec, ARKodeMem
+-----------------------------------------------------------------
+ The type ARKodeMem is type pointer to struct ARKodeMemRec.
+ This structure contains fields to keep track of problem state.
+---------------------------------------------------------------*/
+typedef struct ARKodeMemRec {
+
+  realtype ark_uround;         /* machine unit roundoff */
+
+  /*-------------------------- 
+    Problem Specification Data 
+    --------------------------*/
+  ARKRhsFn     ark_fe;         /* y' = fe(t,y(t)) + fi(t,y(t))          */
+  ARKRhsFn     ark_fi;
+  void        *ark_user_data;  /* user pointer passed to fe, fi         */
+  ARKExpStabFn ark_expstab;    /* time step stability function for fe   */
+  void        *ark_estab_data; /* user pointer passed to expstab        */
+  int          ark_itol;       /* itol = ARK_SS (scalar, default), 
+                                         ARK_SV (vector),
+                                         ARK_WF (user weight function)  */
+  int          ark_ritol;      /* itol = ARK_SS (scalar, default), 
+                                         ARK_SV (vector),
+                                         ARK_WF (user weight function)  */
+  realtype     ark_reltol;     /* relative tolerance                    */
+  realtype     ark_Sabstol;    /* scalar absolute solution tolerance    */
+  N_Vector     ark_Vabstol;    /* vector absolute solution tolerance    */
+  realtype     ark_SRabstol;   /* scalar absolute residual tolerance    */
+  N_Vector     ark_VRabstol;   /* vector absolute residual tolerance    */
+  booleantype  ark_user_efun;  /* TRUE if user sets efun                */
+  ARKEwtFn     ark_efun;       /* function to set ewt                   */
+  void        *ark_e_data;     /* user pointer passed to efun           */
+  booleantype  ark_user_rfun;  /* TRUE if user sets rfun                */
+  ARKRwtFn     ark_rfun;       /* function to set rwt                   */
+  void        *ark_r_data;     /* user pointer passed to rfun           */
+  booleantype  ark_linear;     /* TRUE if fi is linear                  */
+  booleantype  ark_linear_timedep;  /* TRUE if dfi/dy depends on t      */
+  booleantype  ark_explicit;   /* TRUE if fi is disabled                */
+  booleantype  ark_implicit;   /* TRUE if fe is disabled                */
+
+  /*-----------------
+    Stored RHS arrays
+    -----------------*/
+  N_Vector ark_Fe[ARK_S_MAX];  /* explicit RHS at each stage */
+  N_Vector ark_Fi[ARK_S_MAX];  /* implicit RHS at each stage */
+
+  /*--------------------------
+    other vectors of length N 
+    -------------------------*/
+  N_Vector ark_ewt;     /* error weight vector                               */
+  N_Vector ark_rwt;     /* residual weight vector                            */
+  booleantype ark_rwt_is_ewt;     /* TRUE if rwt is a pointer to ewt         */
+  N_Vector ark_y;       /* y is used as temporary storage by the solver
+			   The memory is provided by the user to ARKode
+			   where the vector is named yout.                   */
+  N_Vector ark_ycur;    /* ycur always holds the solver's current version of 
+                           the solution */
+  N_Vector ark_sdata;   /* Storage for old stage data in computing residual. */
+  N_Vector ark_tempv;   /* temporary storage vector                          */
+  N_Vector ark_acor;    /* temporary storage vector; Between steps this  
+			   holds the estimaged local error                   */
+  N_Vector ark_ftemp;   /* temporary storage vector                          */
+  N_Vector ark_fold;    /* f(t,y) at beginning of last successful step       */
+  N_Vector ark_fnew;    /* f(t,y) at end of last successful step             */
+  N_Vector ark_yold;    /* y at beginning of last successful step            */
+  N_Vector ark_ynew;    /* y at end of last successful step                  */
+  /* N_Vector ark_fa;      /\* f at h/3 through step (high order dense output)   *\/ */
+  /* N_Vector ark_fb;      /\* f at h*2/3 through step (high order dense output) *\/ */
+
+  /*-----------------
+    Tstop information
+    -----------------*/
+  booleantype ark_tstopset;
+  realtype    ark_tstop;
+
+  /*-----------
+    Method Data 
+    -----------*/  
+  int ark_q;                              /* method order                   */
+  int ark_p;                              /* embedding order                */
+  int ark_istage;                         /* current stage                  */
+  int ark_stages;                         /* number of stages               */
+  int ark_dense_q;                        /* dense output polynomial order  */
+  realtype ark_Ae[ARK_S_MAX*ARK_S_MAX];   /* ERK Butcher table              */
+  realtype ark_Ai[ARK_S_MAX*ARK_S_MAX];   /* IRK Butcher table              */
+  realtype ark_ce[ARK_S_MAX];             /* ERK method canopy nodes        */
+  realtype ark_ci[ARK_S_MAX];             /* IRK method canopy nodes        */
+  realtype ark_be[ARK_S_MAX];             /* ERK method solution coeffs     */
+  realtype ark_bi[ARK_S_MAX];             /* IRK method solution coeffs     */
+  realtype ark_b2e[ARK_S_MAX];            /* ERK method embedding coeffs    */
+  realtype ark_b2i[ARK_S_MAX];            /* IRK method embedding coeffs    */
+
+  /*---------
+    Step Data 
+    ---------*/  
+  realtype ark_hin;             /* initial step size                        */
+  realtype ark_h;               /* current step size                        */
+  realtype ark_hprime;          /* step size to be used on the next step    */ 
+  realtype ark_next_h;          /* step size to be used on the next step    */ 
+  realtype ark_eta;             /* eta = hprime / h                         */
+  realtype ark_tn;              /* current internal value of t              */
+  realtype ark_tretlast;        /* value of tret last returned by ARKode    */
+  realtype ark_gamma;           /* gamma = h * rl1                          */
+  realtype ark_gammap;          /* gamma at the last setup call             */
+  realtype ark_gamrat;          /* gamma / gammap                           */
+  realtype ark_crate;           /* estimated corrector convergence rate     */
+  realtype ark_eRNrm;           /* estimated residual norm, used in nonlinear 
+				   and linear solver convergence tests      */
+  realtype ark_nlscoef;         /* coefficient in nonlin. convergence test  */
+  int      ark_mnewt;           /* Newton iteration counter                 */
+
+
+  /*-------------------------
+    Time Step Adaptivity Data 
+    -------------------------*/
+  booleantype ark_fixedstep;       /* flag to disable temporal adaptivity    */
+  ARKAdaptFn ark_hadapt;           /* function to set the new time step size */
+  void      *ark_hadapt_data;      /* user pointer passed to hadapt          */
+  realtype   ark_hadapt_ehist[3];  /* error history for time adaptivity      */
+  realtype   ark_hadapt_hhist[3];  /* step history for time adaptivity       */
+  int        ark_hadapt_imethod;   /* time step adaptivity method to use:
+				      -1 -> User-specified function above
+				       0 -> PID controller
+				       1 -> PI controller
+				       2 -> I controller
+				       3 -> explicit Gustafsson controller
+				       4 -> implicit Gustafsson controller
+				       5 -> imex Gustafsson controller       */
+  realtype   ark_hadapt_cfl;       /* cfl safety factor                      */
+  realtype   ark_hadapt_safety;    /* accuracy safety factor on h            */
+  realtype   ark_hadapt_bias;      /* accuracy safety factor on LTE          */
+  realtype   ark_hadapt_growth;    /* maximum step growth safety factor      */
+  realtype   ark_hadapt_lbound;    /* eta lower bound to leave h unchanged   */
+  realtype   ark_hadapt_ubound;    /* eta upper bound to leave h unchanged   */
+  booleantype ark_hadapt_pq;       /* choice of using p (0) vs q (1)         */
+  realtype   ark_hadapt_k1;
+  realtype   ark_hadapt_k2;        /* method-specific adaptivity parameters  */
+  realtype   ark_hadapt_k3;
+
+  /*------------------------------------
+    Limits and various solver parameters
+    ------------------------------------*/
+  long int ark_mxstep;   /* max number of internal steps for one user call */
+  int      ark_maxcor;   /* max number of corrector iterations for the
+			    solution of the nonlinear equation             */
+  int      ark_mxhnil;   /* max number of warning messages issued to the
+			    user that t+h == t for the next internal step  */
+  int      ark_maxnef;   /* max number of error test failures in one step  */
+  int      ark_maxncf;   /* max number of nonlin. conv. fails in one step  */
+  realtype ark_hmin;     /* |h| >= hmin                                    */
+  realtype ark_hmax_inv; /* |h| <= 1/hmax_inv                              */
+  realtype ark_etamax;   /* eta <= etamax                                  */
+
+  realtype ark_etamx1;   /* max step size change on first step             */
+  realtype ark_etamxf;   /* h reduction factor on multiple error fails     */
+  int ark_small_nef;     /* bound to determine 'multiple' above            */
+  realtype ark_etacf;    /* h reduction factor on nonlinear conv fail      */
+
+  realtype ark_crdown;   /* nonlinear convergence rate estimation constant */
+  realtype ark_rdiv;     /* declare divergence if ratio del/delp > RDIV    */
+
+  realtype ark_dgmax;    /* if |gamma/gammap-1| > DGMAX then call lsetup   */
+  int ark_msbp;          /* positive => max # steps between lsetup calls
+			    negative => recompute at every Newton iter.    */
+  int ark_predictor;     /* choice of prediction method */
+
+  /*--------
+    Counters 
+    --------*/
+  long int ark_nst;          /* number of internal steps taken             */
+  long int ark_nst_acc;      /* number of accuracy-limited internal steps  */
+  long int ark_nst_exp;      /* number of stability-limited internal steps */
+  long int ark_nst_attempts; /* number of attempted steps                  */
+  long int ark_nfe;          /* number of fe calls                         */
+  long int ark_nfi;          /* number of fi calls                         */
+  long int ark_ncfn;         /* number of corrector convergence failures   */
+  long int ark_nmassfails;   /* number of mass matrix solver failures      */
+  long int ark_netf;         /* number of error test failures              */
+  long int ark_nni;          /* number of Newton iterations performed      */
+  long int ark_nsetups;      /* number of setup calls                      */
+  int      ark_nhnil;        /* number of messages issued to the user that 
+			        t+h == t for the next iternal step         */
+
+  /*-----------------
+    Diagnostic output
+    -----------------*/
+  booleantype ark_report;   /* flag to enable/disable diagnostic output    */
+  FILE       *ark_diagfp;   /* diagnostic outputs are sent to ark_diagfp   */
+
+  /*-----------------------------
+    Space requirements for ARKODE 
+    -----------------------------*/
+  long int ark_lrw1;        /* no. of realtype words in 1 N_Vector          */ 
+  long int ark_liw1;        /* no. of integer words in 1 N_Vector           */ 
+  long int ark_lrw;         /* no. of realtype words in ARKODE work vectors */
+  long int ark_liw;         /* no. of integer words in ARKODE work vectors  */
+
+
+  /*-----------------------
+    Fixed-point Solver Data 
+    -----------------------*/
+  booleantype ark_use_fp;     /* flag to enable fixed-point solver vs Newton */
+  long int    ark_fp_m;       /* number of vectors to use in acceleration    */
+  long int    *ark_fp_imap;   /* array of length m          */
+  realtype    *ark_fp_R;      /* array of length m*m        */
+  realtype    *ark_fp_gamma;  /* array of length m          */
+  N_Vector    *ark_fp_df;     /* vector array of length m   */
+  N_Vector    *ark_fp_dg;     /* vector array of length m   */
+  N_Vector    *ark_fp_q;      /* vector array of length m   */
+  N_Vector     ark_fp_fval;   /* temporary N_Vectors        */
+  N_Vector     ark_fp_fold;
+  N_Vector     ark_fp_gold;
+
+  /*------------------
+    Linear Solver Data 
+    ------------------*/
+  int (*ark_linit)(struct ARKodeMemRec *ark_mem);
+  int (*ark_lsetup)(struct ARKodeMemRec *ark_mem, int convfail, N_Vector ypred,
+		    N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
+		    N_Vector vtemp2, N_Vector vtemp3); 
+  int (*ark_lsolve)(struct ARKodeMemRec *ark_mem, N_Vector b, N_Vector weight,
+		    N_Vector ycur, N_Vector fcur);
+  int (*ark_lfree)(struct ARKodeMemRec *ark_mem);
+  void *ark_lmem;
+  int ark_lsolve_type;   /* linear solver type: 0=iterative; 1=dense; 
+                                                2=band; 3=sparse; 4=custom */
+
+  /*-----------------------
+    Mass Matrix Solver Data 
+    -----------------------*/
+  booleantype ark_mass_matrix;   /* flag denoting use of a non-identity M  */
+  long int ark_mass_solves;      /* number of mass matrix solve calls      */
+  long int ark_mass_mult;        /* number of mass matrix product calls    */
+  ARKSpilsMassTimesVecFn ark_mtimes;   /* mass-matrix-vector product routine */
+  void *ark_mtimes_data;         /* user pointer passed to mtimes          */
+  int (*ark_minit)(struct ARKodeMemRec *ark_mem);
+  int (*ark_msetup)(struct ARKodeMemRec *ark_mem, N_Vector vtemp1, 
+		    N_Vector vtemp2, N_Vector vtemp3); 
+  int (*ark_msolve)(struct ARKodeMemRec *ark_mem, N_Vector b, N_Vector weight);
+  int (*ark_mfree)(struct ARKodeMemRec *ark_mem);
+  void *ark_mass_mem;
+  int ark_msolve_type;   /* mass matrix type: 0=iterative; 1=dense; 
+			                      2=band; 3=sparse; 4=custom */
+
+  /*------------
+    Saved Values
+    ------------*/
+  long int    ark_nstlp;        /* step number of last setup call             */
+  realtype    ark_h0u;          /* actual initial stepsize                    */
+  realtype    ark_tnew;         /* time of last successful step               */
+  realtype    ark_hold;         /* last successful h value used               */
+  booleantype ark_jcur;         /* is Jacobian info. for lin. solver current? */
+  realtype    ark_tolsf;        /* tolerance scale factor                     */
+  booleantype ark_setupNonNull; /* does ark_lsetup do anything?               */
+  booleantype ark_MassSetupNonNull; /* does ark_msetup do anything?           */
+  booleantype ark_VabstolMallocDone;
+  booleantype ark_VRabstolMallocDone;
+  booleantype ark_MallocDone;  
+  booleantype ark_resized;      /* denotes first step after ARKodeResize      */
+  booleantype ark_firststage;   /* denotes first stage in simulation          */
+
+  /*-------------------------------------------
+    Error handler function and error ouput file 
+    -------------------------------------------*/
+  ARKErrHandlerFn ark_ehfun;    /* error messages are handled by ehfun        */
+  void           *ark_eh_data;  /* data pointer passed to ehfun               */
+  FILE           *ark_errfp;    /* ARKODE error messages are sent to errfp    */
+
+  /*----------------
+    Rootfinding Data
+    ----------------*/
+  ARKRootFn    ark_gfun;        /* function g for roots sought                  */
+  int          ark_nrtfn;       /* number of components of g                    */
+  int         *ark_iroots;      /* array for root information                   */
+  int         *ark_rootdir;     /* array specifying direction of zero-crossing  */
+  realtype     ark_tlo;         /* nearest endpoint of interval in root search  */
+  realtype     ark_thi;         /* farthest endpoint of interval in root search */
+  realtype     ark_trout;       /* t value returned by rootfinding routine      */
+  realtype    *ark_glo;         /* saved array of g values at t = tlo           */
+  realtype    *ark_ghi;         /* saved array of g values at t = thi           */
+  realtype    *ark_grout;       /* array of g values at t = trout               */
+  realtype     ark_toutc;       /* copy of tout (if NORMAL mode)                */
+  realtype     ark_ttol;        /* tolerance on root location                   */
+  int          ark_taskc;       /* copy of parameter itask                      */
+  int          ark_irfnd;       /* flag showing whether last step had a root    */
+  long int     ark_nge;         /* counter for g evaluations                    */
+  booleantype *ark_gactive;     /* array with active/inactive event functions   */
+  int          ark_mxgnull;     /* num. warning messages about possible g==0    */
+
+  /*----------------------------------------------------
+    User-supplied step solution post-processing function
+    ----------------------------------------------------*/
+  ARKPostProcessStepFn ark_ProcessStep;
+
+} *ARKodeMem;
+
+
+
+/*===============================================================
+     I N T E R F A C E   T O    L I N E A R   S O L V E R S
+===============================================================*/
+  
+/*---------------------------------------------------------------
+ Communication between ARKODE and a ARKODE Linear Solver
+-----------------------------------------------------------------
+ convfail (input to ark_lsetup)
+
+ ARK_NO_FAILURES : Either this is the first ark_setup call for 
+                   this step, or the local error test failed on 
+		   the previous attempt at this step (but the 
+		   Newton iteration converged).
+
+ ARK_FAIL_BAD_J  : This value is passed to ark_lsetup if
+
+                  (a) The previous Newton corrector iteration
+                      did not converge and the linear solver's
+                      setup routine indicated that its Jacobian-
+                      related data is not current
+                                   or
+                  (b) During the previous Newton corrector
+                      iteration, the linear solver's solve 
+		      routine failed in a recoverable manner 
+		      and the linear solver's setup routine 
+		      indicated that its Jacobian-related data 
+		      is not current.
+
+ ARK_FAIL_OTHER  : During the current internal step try, the
+                   previous Newton iteration failed to converge
+		   even though the linear solver was using 
+		   current Jacobian-related data.
+---------------------------------------------------------------*/
+  
+/* Constants for convfail (input to ark_lsetup) */
+#define ARK_NO_FAILURES 0
+#define ARK_FAIL_BAD_J  1
+#define ARK_FAIL_OTHER  2
+
+/*---------------------------------------------------------------
+ int (*ark_linit)(ARKodeMem ark_mem);
+-----------------------------------------------------------------
+ The purpose of ark_linit is to complete initializations for a
+ specific linear solver, such as counters and statistics.
+ An LInitFn should return 0 if it has successfully initialized 
+ the ARKODE linear solver and a negative value otherwise.
+ If an error does occur, an appropriate message should be sent 
+ to the error handler function.
+---------------------------------------------------------------*/
+  
+/*---------------------------------------------------------------
+ int (*ark_lsetup)(ARKodeMem ark_mem, int convfail, 
+                   N_Vector ypred, N_Vector fpred, 
+		   booleantype *jcurPtr, N_Vector vtemp1, 
+		   N_Vector vtemp2, N_Vector vtemp3);
+ -----------------------------------------------------------------
+ The job of ark_lsetup is to prepare the linear solver for
+ subsequent calls to ark_lsolve. It may recompute Jacobian-
+ related data is it deems necessary. Its parameters are as
+ follows:
+
+ ark_mem - problem memory pointer of type ARKodeMem. See the
+          typedef earlier in this file.
+
+ convfail - a flag to indicate any problem that occurred during
+            the solution of the nonlinear equation on the
+            current time step for which the linear solver is
+            being used. This flag can be used to help decide
+            whether the Jacobian data kept by a ARKODE linear
+            solver needs to be updated or not.
+            Its possible values have been documented above.
+
+ ypred - the predicted y vector for the current ARKODE internal
+         step.
+
+ fpred - f(tn, ypred).
+
+ jcurPtr - a pointer to a boolean to be filled in by ark_lsetup.
+           The function should set *jcurPtr=TRUE if its Jacobian
+           data is current after the call and should set
+           *jcurPtr=FALSE if its Jacobian data is not current.
+           Note: If ark_lsetup calls for re-evaluation of
+           Jacobian data (based on convfail and ARKODE state
+           data), it should return *jcurPtr=TRUE always;
+           otherwise an infinite loop can result.
+
+ vtemp1 - temporary N_Vector provided for use by ark_lsetup.
+
+ vtemp3 - temporary N_Vector provided for use by ark_lsetup.
+
+ vtemp3 - temporary N_Vector provided for use by ark_lsetup.
+
+ The ark_lsetup routine should return 0 if successful, a positive
+ value for a recoverable error, and a negative value for an
+ unrecoverable error.
+---------------------------------------------------------------*/
+
+/*---------------------------------------------------------------
+ int (*ark_lsolve)(ARKodeMem ark_mem, N_Vector b, N_Vector weight,
+                   N_Vector ycur, N_Vector fcur);
+-----------------------------------------------------------------
+ ark_lsolve must solve the linear equation P x = b, where
+ P is some approximation to (M - gamma J), M is the system mass
+ matrix, J = (df/dy)(tn,ycur), and the RHS vector b is input. The 
+ N-vector ycur contains the solver's current approximation to 
+ y(tn) and the vector fcur contains the N_Vector f(tn,ycur). The 
+ solution is to be returned in the vector b. ark_lsolve returns 
+ a positive value for a recoverable error and a negative value 
+ for an unrecoverable error. Success is indicated by a 0 return 
+ value.
+---------------------------------------------------------------*/
+
+/*---------------------------------------------------------------
+ int (*ark_lfree)(ARKodeMem ark_mem);
+-----------------------------------------------------------------
+ ark_lfree should free up any memory allocated by the linear
+ solver. This routine is called once a problem has been
+ completed and the linear solver is no longer needed.  It should 
+ return 0 upon success, or a nonzero on failure.
+---------------------------------------------------------------*/
+
+
+
+/*---------------------------------------------------------------
+ int (*ark_minit)(ARKodeMem ark_mem);
+-----------------------------------------------------------------
+ The purpose of ark_minit is to complete initializations for a
+ specific mass matrix linear solver, such as counters and 
+ statistics. An function of this type should return 0 if it has 
+ successfully initialized the mass matrix linear solver and a 
+ negative value otherwise.  If an error does occur, an 
+ appropriate message should be sent to the error handler function.
+---------------------------------------------------------------*/
+  
+/*---------------------------------------------------------------
+ int (*ark_msetup)(ARKodeMem ark_mem, N_Vector vtemp1, 
+                   N_Vector vtemp2, N_Vector vtemp3);
+ -----------------------------------------------------------------
+ The job of ark_msetup is to prepare the mass matrix solver for
+ subsequent calls to ark_msolve. It may recompute mass matrix
+ related data is it deems necessary. Its parameters are as
+ follows:
+
+ ark_mem - problem memory pointer of type ARKodeMem. See the
+          typedef earlier in this file.
+
+ vtemp1 - temporary N_Vector provided for use by ark_lsetup.
+
+ vtemp3 - temporary N_Vector provided for use by ark_lsetup.
+
+ vtemp3 - temporary N_Vector provided for use by ark_lsetup.
+
+ The ark_msetup routine should return 0 if successful, and a 
+ negative value for an unrecoverable error.
+---------------------------------------------------------------*/
+
+/*---------------------------------------------------------------
+ int (*ark_msolve)(ARKodeMem ark_mem, N_Vector b, N_Vector weight);
+-----------------------------------------------------------------
+ ark_msolve must solve the linear equation M x = b, where
+ M is the system mass matrix, and the RHS vector b is input. The
+ solution is to be returned in the vector b.  The ark_msolve
+ routine returns a positive value for a recoverable error and 
+ a negative value for an unrecoverable error. Success is 
+ indicated by a 0 return value.
+---------------------------------------------------------------*/
+
+/*---------------------------------------------------------------
+ int (*ark_mfree)(ARKodeMem ark_mem);
+-----------------------------------------------------------------
+ ark_mfree should free up any memory allocated by the mass matrix
+ solver. This routine is called once a problem has been
+ completed and the solver is no longer needed.  It should return
+ 0 upon success, or a nonzero on failure.
+---------------------------------------------------------------*/
+
+  
+/*===============================================================
+   ARKODE PROTOTYPE FUNCTIONS (MAY BE REPLACED BY USER)
+===============================================================*/
+
+/* Prototype of internal ewtSet function */
+int arkEwtSet(N_Vector ycur, N_Vector weight, void *data);
+
+/* Prototype of internal rwtSet function */
+int arkRwtSet(N_Vector ycur, N_Vector weight, void *data);
+
+/* Prototype of internal errHandler function */
+void arkErrHandler(int error_code, const char *module, 
+		   const char *function, char *msg, void *data);
+
+/* Prototype of internal explicit stability estimation function */
+int arkExpStab(N_Vector y, realtype t, realtype *hstab, void *user_data);
+
+/*===============================================================
+   HIGH LEVEL ERROR HANDLER, USED THROUGHOUT ARKODE
+===============================================================*/
+
+void arkProcessError(ARKodeMem ark_mem, int error_code, 
+		     const char *module, const char *fname, 
+		     const char *msgfmt, ...);
+
+/*===============================================================
+   ARKODE ERROR MESSAGES
+===============================================================*/
+
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+
+#define MSG_TIME        "t = %Lg"
+#define MSG_TIME_H      "t = %Lg and h = %Lg"
+#define MSG_TIME_INT    "t = %Lg is not between tcur - hold = %Lg and tcur = %Lg."
+#define MSG_TIME_TOUT   "tout = %Lg"
+#define MSG_TIME_TSTOP  "tstop = %Lg"
+
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+
+#define MSG_TIME        "t = %lg"
+#define MSG_TIME_H      "t = %lg and h = %lg"
+#define MSG_TIME_INT    "t = %lg is not between tcur - hold = %lg and tcur = %lg."
+#define MSG_TIME_TOUT   "tout = %lg"
+#define MSG_TIME_TSTOP  "tstop = %lg"
+
+#else
+
+#define MSG_TIME        "t = %g"
+#define MSG_TIME_H      "t = %g and h = %g"
+#define MSG_TIME_INT    "t = %g is not between tcur - hold = %g and tcur = %g."
+#define MSG_TIME_TOUT   "tout = %g"
+#define MSG_TIME_TSTOP  "tstop = %g"
+
+#endif
+
+/* Initialization and I/O error messages */
+#define MSGARK_NO_MEM        "arkode_mem = NULL illegal."
+#define MSGARK_ARKMEM_FAIL   "Allocation of arkode_mem failed."
+#define MSGARK_MEM_FAIL      "A memory request failed."
+#define MSGARK_NO_MALLOC     "Attempt to call before ARKodeInit."
+#define MSGARK_NEG_MAXORD    "maxord <= 0 illegal."
+#define MSGARK_BAD_MAXORD    "Illegal attempt to increase maximum method order."
+#define MSGARK_NEG_HMIN      "hmin < 0 illegal."
+#define MSGARK_NEG_HMAX      "hmax < 0 illegal."
+#define MSGARK_BAD_HMIN_HMAX "Inconsistent step size limits: hmin > hmax."
+#define MSGARK_BAD_RELTOL    "reltol < 0 illegal."
+#define MSGARK_BAD_ABSTOL    "abstol has negative component(s) (illegal)."
+#define MSGARK_NULL_ABSTOL   "abstol = NULL illegal."
+#define MSGARK_BAD_RABSTOL   "rabstol has negative component(s) (illegal)."
+#define MSGARK_NULL_RABSTOL  "rabstol = NULL illegal."
+#define MSGARK_NULL_Y0       "y0 = NULL illegal."
+#define MSGARK_NULL_F        "Must specify at least one of fe, fi (both NULL)."
+#define MSGARK_NULL_G        "g = NULL illegal."
+#define MSGARK_BAD_NVECTOR   "A required vector operation is not implemented."
+#define MSGARK_BAD_K         "Illegal value for k."
+#define MSGARK_NULL_DKY      "dky = NULL illegal."
+#define MSGARK_BAD_T         "Illegal value for t." MSG_TIME_INT
+#define MSGARK_NO_ROOT       "Rootfinding was not initialized."
+
+/* ARKode Error Messages */
+#define MSGARK_LSOLVE_NULL    "The linear solver's solve routine is NULL."
+#define MSGARK_YOUT_NULL      "yout = NULL illegal."
+#define MSGARK_TRET_NULL      "tret = NULL illegal."
+#define MSGARK_BAD_EWT        "Initial ewt has component(s) equal to zero (illegal)."
+#define MSGARK_EWT_NOW_BAD    "At " MSG_TIME ", a component of ewt has become <= 0."
+#define MSGARK_BAD_RWT        "Initial rwt has component(s) equal to zero (illegal)."
+#define MSGARK_RWT_NOW_BAD    "At " MSG_TIME ", a component of rwt has become <= 0."
+#define MSGARK_BAD_ITASK      "Illegal value for itask."
+#define MSGARK_BAD_H0         "h0 and tout - t0 inconsistent."
+#define MSGARK_BAD_TOUT       "Trouble interpolating at " MSG_TIME_TOUT ". tout too far back in direction of integration"
+#define MSGARK_EWT_FAIL       "The user-provide EwtSet function failed."
+#define MSGARK_EWT_NOW_FAIL   "At " MSG_TIME ", the user-provide EwtSet function failed."
+#define MSGARK_RWT_FAIL       "The user-provide RwtSet function failed."
+#define MSGARK_RWT_NOW_FAIL   "At " MSG_TIME ", the user-provide RwtSet function failed."
+#define MSGARK_LINIT_FAIL     "The linear solver's init routine failed."
+#define MSGARK_LFREE_FAIL     "The linear solver's free routine failed."
+#define MSGARK_HNIL_DONE      "The above warning has been issued mxhnil times and will not be issued again for this problem."
+#define MSGARK_TOO_CLOSE      "tout too close to t0 to start integration."
+#define MSGARK_MAX_STEPS      "At " MSG_TIME ", mxstep steps taken before reaching tout."
+#define MSGARK_TOO_MUCH_ACC   "At " MSG_TIME ", too much accuracy requested."
+#define MSGARK_HNIL           "Internal " MSG_TIME_H " are such that t + h = t on the next step. The solver will continue anyway."
+#define MSGARK_ERR_FAILS      "At " MSG_TIME_H ", the error test failed repeatedly or with |h| = hmin."
+#define MSGARK_CONV_FAILS     "At " MSG_TIME_H ", the solver convergence test failed repeatedly or with |h| = hmin."
+#define MSGARK_SETUP_FAILED   "At " MSG_TIME ", the setup routine failed in an unrecoverable manner."
+#define MSGARK_SOLVE_FAILED   "At " MSG_TIME ", the solve routine failed in an unrecoverable manner."
+#define MSGARK_RHSFUNC_FAILED "At " MSG_TIME ", the right-hand side routine failed in an unrecoverable manner."
+#define MSGARK_RHSFUNC_UNREC  "At " MSG_TIME ", the right-hand side failed in a recoverable manner, but no recovery is possible."
+#define MSGARK_RHSFUNC_REPTD  "At " MSG_TIME " repeated recoverable right-hand side function errors."
+#define MSGARK_RHSFUNC_FIRST  "The right-hand side routine failed at the first call."
+#define MSGARK_RTFUNC_FAILED  "At " MSG_TIME ", the rootfinding routine failed in an unrecoverable manner."
+#define MSGARK_CLOSE_ROOTS    "Root found at and very near " MSG_TIME "."
+#define MSGARK_BAD_TSTOP      "The value " MSG_TIME_TSTOP " is behind current " MSG_TIME " in the direction of integration."
+#define MSGARK_INACTIVE_ROOTS "At the end of the first step, there are still some root functions identically 0. This warning will not be issued again."
+#define MSGARK_MISSING_FE     "Cannot specify that method is explicit without providing a function pointer to fe(t,y)."
+#define MSGARK_MISSING_FI     "Cannot specify that method is explicit without providing a function pointer to fe(t,y)."
+#define MSGARK_MISSING_F      "Cannot specify that method is ImEx without providing function pointers to fi(t,y) and fe(t,y)."
+#define MSGARK_RESIZE_FAIL    "Error in user-supplied resize() function."
+#define MSGARK_MASSINIT_FAIL  "The mass matrix solver's init routine failed."
+#define MSGARK_MASSSETUP_FAIL "The mass matrix solver's setup routine failed."
+#define MSGARK_MASSSOLVE_NULL "The mass matrix solver's solve routine is NULL."
+#define MSGARK_MASSSOLVE_FAIL "The mass matrix solver failed."
+#define MSGARK_MASSFREE_FAIL  "The mass matrixsolver's free routine failed."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c
new file mode 100644
index 0000000..7be7adf
--- /dev/null
+++ b/src/arkode/arkode_io.c
@@ -0,0 +1,2944 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the optional input and 
+ * output functions for the ARKODE solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode_impl.h"
+#include <sundials/sundials_math.h>
+#include <sundials/sundials_types.h>
+
+
+/*===============================================================
+ ARKODE optional input functions
+===============================================================*/
+
+/*---------------------------------------------------------------
+ ARKodeSetDefaults:
+
+ Resets all optional inputs to ARKode default values.  Does not 
+ change problem-defining function pointers fe and fi or 
+ user_data pointer.  Also leaves alone any data 
+ structures/options related to root-finding (those can be reset 
+ using ARKodeRootInit).
+---------------------------------------------------------------*/
+int ARKodeSetDefaults(void *arkode_mem)
+{
+  int i, j;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetDefaults", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Set default values for integrator optional inputs */
+  ark_mem->ark_q                = Q_DEFAULT;      /* method order */
+  ark_mem->ark_p                = 0;              /* embedding order */
+  ark_mem->ark_dense_q          = QDENSE_DEF;     /* dense output order */
+  ark_mem->ark_expstab          = arkExpStab;     /* explicit stability fn */
+  ark_mem->ark_estab_data       = ark_mem;        /* explicit stability data */
+  ark_mem->ark_fixedstep        = FALSE;          /* default to use adaptive steps */
+  ark_mem->ark_hadapt           = NULL;           /* step adaptivity fn */
+  ark_mem->ark_hadapt_data      = NULL;           /* step adaptivity data */
+  ark_mem->ark_hadapt_cfl       = CFLFAC;         /* explicit stability factor */
+  ark_mem->ark_hadapt_safety    = SAFETY;         /* step adaptivity safety factor  */
+  ark_mem->ark_hadapt_bias      = BIAS;           /* step adaptivity error bias */
+  ark_mem->ark_hadapt_growth    = GROWTH;         /* step adaptivity growth factor */
+  ark_mem->ark_hadapt_lbound    = HFIXED_LB;      /* step adaptivity no-change lower bound */
+  ark_mem->ark_hadapt_ubound    = HFIXED_UB;      /* step adaptivity no-change upper bound */
+  ark_mem->ark_hadapt_pq        = FALSE;          /* use embedding order */
+  ark_mem->ark_hadapt_imethod   = 0;              /* PID controller */
+  ark_mem->ark_hadapt_k1        = AD0_K1;         /* step adaptivity parameter */
+  ark_mem->ark_hadapt_k2        = AD0_K2;         /* step adaptivity parameter */
+  ark_mem->ark_hadapt_k3        = AD0_K3;         /* step adaptivity parameter */
+  ark_mem->ark_predictor        = 0;              /* trivial predictor */
+  ark_mem->ark_reltol           = 1.e-4;          /* relative tolerance */
+  ark_mem->ark_itol             = ARK_SS;         /* scalar-scalar solution tolerances */
+  ark_mem->ark_ritol            = ARK_SS;         /* scalar-scalar residual tolerances */
+  ark_mem->ark_Sabstol          = 1.e-9;          /* solution absolute tolerance */
+  ark_mem->ark_SRabstol         = 1.e-9;          /* residual absolute tolerance */
+  ark_mem->ark_user_efun        = FALSE;          /* no user-supplied ewt function */
+  ark_mem->ark_efun             = arkEwtSet;      /* built-in ewt function */
+  ark_mem->ark_e_data           = NULL;           /* ewt function data */
+  ark_mem->ark_user_rfun        = FALSE;          /* no user-supplied rwt function */
+  ark_mem->ark_rfun             = arkRwtSet;      /* built-in rwt function */
+  ark_mem->ark_e_data           = NULL;           /* rwt function data */
+  ark_mem->ark_linear           = FALSE;          /* nonlinear problem */
+  ark_mem->ark_linear_timedep   = TRUE;           /* dfi/dy depends on t */
+  ark_mem->ark_explicit         = FALSE;          /* fi(t,y) will be used */
+  ark_mem->ark_implicit         = FALSE;          /* fe(t,y) will be used */
+  ark_mem->ark_ehfun            = arkErrHandler;  /* default error handler fn */
+  ark_mem->ark_eh_data          = ark_mem;        /* error handler data */
+  ark_mem->ark_errfp            = stderr;         /* output stream for errors */
+  ark_mem->ark_mxstep           = MXSTEP_DEFAULT; /* max number of steps */
+  ark_mem->ark_mxhnil           = MXHNIL;         /* max warns of t+h==t */
+  ark_mem->ark_hin              = ZERO;           /* determine initial step on-the-fly */
+  ark_mem->ark_hmin             = ZERO;           /* no minimum step size */
+  ark_mem->ark_hmax_inv         = ZERO;           /* no maximum step size */
+  ark_mem->ark_tstopset         = FALSE;          /* no stop time set */
+  ark_mem->ark_tstop            = ZERO;           /* no fixed stop time */
+  ark_mem->ark_maxcor           = MAXCOR;         /* max nonlinear iters/stage */
+  ark_mem->ark_maxnef           = MAXNEF;         /* max error test fails */
+  ark_mem->ark_maxncf           = MAXNCF;         /* max convergence fails */
+  ark_mem->ark_nlscoef          = NLSCOEF;        /* nonlinear tolerance coefficient */
+  ark_mem->ark_etamx1           = ETAMX1;         /* max change on first step */
+  ark_mem->ark_etamxf           = ETAMXF;         /* max change on error-failed step */
+  ark_mem->ark_small_nef        = SMALL_NEF;      /* num error fails before ETAMXF enforced */
+  ark_mem->ark_etacf            = ETACF;          /* max change on convergence failure */
+  ark_mem->ark_crdown           = CRDOWN;         /* nonlinear convergence estimate coeff. */
+  ark_mem->ark_rdiv             = RDIV;           /* nonlinear divergence tolerance */
+  ark_mem->ark_dgmax            = DGMAX;          /* max step change before recomputing J or P */
+  ark_mem->ark_msbp             = MSBP;           /* max steps between updates to J or P */
+  ark_mem->ark_use_fp           = FALSE;          /* use Newton solver */
+  ark_mem->ark_fp_m             = FP_ACCEL_M;     /* num Anderson acceleration vectors */
+  ark_mem->ark_diagfp           = NULL;           /* no solver diagnostics file */
+  ark_mem->ark_report           = FALSE;          /* don't report solver diagnostics */
+  ark_mem->ark_stages           = 0;              /* no stages */
+  ark_mem->ark_istage           = 0;              /* current stage */
+  for (i=0; i<ARK_S_MAX; i++) {                   /* no Butcher table */
+    for (j=0; j<ARK_S_MAX; j++) {
+      ARK_A(ark_mem->ark_Ae,i,j) = ZERO;
+      ARK_A(ark_mem->ark_Ai,i,j) = ZERO;
+    }
+    ark_mem->ark_ce[i]  = ZERO;
+    ark_mem->ark_ci[i]  = ZERO;
+    ark_mem->ark_be[i]  = ZERO;
+    ark_mem->ark_bi[i]  = ZERO;
+    ark_mem->ark_b2e[i] = ZERO;
+    ark_mem->ark_b2i[i] = ZERO;
+  }
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetOptimalParams:
+
+ Sets all adaptivity and solver parameters to our 'best guess' 
+ values, for a given integration method (ERK, DIRK, ARK), a 
+ given method order, and a given nonlinear solver type.  Should
+ only be called after the method order, solver, and integration
+ method have been set.
+---------------------------------------------------------------*/
+int ARKodeSetOptimalParams(void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetOptimalParams", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Choose values based on method, order */
+
+  /*    explicit */
+  if (ark_mem->ark_explicit) {
+    ark_mem->ark_hadapt_imethod = 1;
+    ark_mem->ark_hadapt_safety  = RCONST(0.99);
+    ark_mem->ark_hadapt_bias    = RCONST(1.2);
+    ark_mem->ark_hadapt_growth  = RCONST(25.0);
+    ark_mem->ark_hadapt_k1      = RCONST(0.8);
+    ark_mem->ark_hadapt_k2      = RCONST(0.31);
+    ark_mem->ark_etamxf         = RCONST(0.3);
+
+  /*    implicit */
+  } else if (ark_mem->ark_implicit) {
+    switch (ark_mem->ark_q) {
+    case 2:   /* just use standard defaults since better ones unknown */
+      ark_mem->ark_hadapt_imethod   = 0;
+      ark_mem->ark_hadapt_safety    = SAFETY;
+      ark_mem->ark_hadapt_bias      = BIAS;
+      ark_mem->ark_hadapt_growth    = GROWTH;
+      ark_mem->ark_etamxf           = ETAMXF;
+      ark_mem->ark_nlscoef          = RCONST(0.001);
+      ark_mem->ark_maxcor           = 5;
+      ark_mem->ark_crdown           = CRDOWN;
+      ark_mem->ark_rdiv             = RDIV;
+      ark_mem->ark_dgmax            = DGMAX;
+      ark_mem->ark_msbp             = MSBP;
+      ark_mem->ark_small_nef        = SMALL_NEF;
+      ark_mem->ark_etacf            = ETACF;
+      break;
+    case 3:
+      ark_mem->ark_hadapt_imethod   = 2;
+      ark_mem->ark_hadapt_safety    = RCONST(0.957);
+      ark_mem->ark_hadapt_bias      = RCONST(1.9);
+      ark_mem->ark_hadapt_growth    = RCONST(17.6);
+      ark_mem->ark_etamxf           = RCONST(0.45);
+      ark_mem->ark_nlscoef          = RCONST(0.22);
+      ark_mem->ark_crdown           = RCONST(0.17);
+      ark_mem->ark_rdiv             = RCONST(2.3);
+      ark_mem->ark_dgmax            = RCONST(0.19);
+      ark_mem->ark_msbp             = 60;
+      ark_mem->ark_small_nef        = SMALL_NEF;
+      ark_mem->ark_etacf            = ETACF;
+      break;
+    case 4:
+      ark_mem->ark_hadapt_imethod   = 0;
+      ark_mem->ark_hadapt_safety    = RCONST(0.988);
+      ark_mem->ark_hadapt_bias      = RCONST(1.2);
+      ark_mem->ark_hadapt_growth    = RCONST(31.5);
+      ark_mem->ark_hadapt_k1        = RCONST(0.535);
+      ark_mem->ark_hadapt_k2        = RCONST(0.209);
+      ark_mem->ark_hadapt_k3        = RCONST(0.148);
+      ark_mem->ark_etamxf           = RCONST(0.33);
+      ark_mem->ark_nlscoef          = RCONST(0.24);
+      ark_mem->ark_crdown           = RCONST(0.26);
+      ark_mem->ark_rdiv             = RCONST(2.3);
+      ark_mem->ark_dgmax            = RCONST(0.16);
+      ark_mem->ark_msbp             = 31;
+      ark_mem->ark_small_nef        = SMALL_NEF;
+      ark_mem->ark_etacf            = ETACF;
+      break;
+    case 5:
+      ark_mem->ark_hadapt_imethod   = 0;
+      ark_mem->ark_hadapt_safety    = RCONST(0.937);
+      ark_mem->ark_hadapt_bias      = RCONST(3.3);
+      ark_mem->ark_hadapt_growth    = RCONST(22.0);
+      ark_mem->ark_hadapt_k1        = RCONST(0.56);
+      ark_mem->ark_hadapt_k2        = RCONST(0.338);
+      ark_mem->ark_hadapt_k3        = RCONST(0.14);
+      ark_mem->ark_etamxf           = RCONST(0.44);
+      ark_mem->ark_nlscoef          = RCONST(0.25);
+      ark_mem->ark_crdown           = RCONST(0.4);
+      ark_mem->ark_rdiv             = RCONST(2.3);
+      ark_mem->ark_dgmax            = RCONST(0.32);
+      ark_mem->ark_msbp             = 31;
+      ark_mem->ark_small_nef        = SMALL_NEF;
+      ark_mem->ark_etacf            = ETACF;
+      break;
+    }
+
+    /* newton vs fixed-point */
+    if (ark_mem->ark_use_fp)  ark_mem->ark_maxcor = 10;
+
+  /*    imex */
+  } else {
+    switch (ark_mem->ark_q) {
+    case 3:
+      ark_mem->ark_hadapt_imethod   = 0;
+      ark_mem->ark_hadapt_safety    = RCONST(0.965);
+      ark_mem->ark_hadapt_bias      = RCONST(1.42);
+      ark_mem->ark_hadapt_growth    = RCONST(28.7);
+      ark_mem->ark_hadapt_k1        = RCONST(0.54);
+      ark_mem->ark_hadapt_k2        = RCONST(0.36);
+      ark_mem->ark_hadapt_k3        = RCONST(0.14);
+      ark_mem->ark_etamxf           = RCONST(0.46);
+      ark_mem->ark_nlscoef          = RCONST(0.22);
+      ark_mem->ark_crdown           = RCONST(0.17);
+      ark_mem->ark_rdiv             = RCONST(2.3);
+      ark_mem->ark_dgmax            = RCONST(0.19);
+      ark_mem->ark_msbp             = 60;
+      ark_mem->ark_small_nef        = SMALL_NEF;
+      ark_mem->ark_etacf            = ETACF;
+      break;
+    case 4:
+      ark_mem->ark_hadapt_imethod   = 0;
+      ark_mem->ark_hadapt_safety    = RCONST(0.97);
+      ark_mem->ark_hadapt_bias      = RCONST(1.35);
+      ark_mem->ark_hadapt_growth    = RCONST(25.0);
+      ark_mem->ark_hadapt_k1        = RCONST(0.543);
+      ark_mem->ark_hadapt_k2        = RCONST(0.297);
+      ark_mem->ark_hadapt_k3        = RCONST(0.14);
+      ark_mem->ark_etamxf           = RCONST(0.47);
+      ark_mem->ark_nlscoef          = RCONST(0.24);
+      ark_mem->ark_crdown           = RCONST(0.26);
+      ark_mem->ark_rdiv             = RCONST(2.3);
+      ark_mem->ark_dgmax            = RCONST(0.16);
+      ark_mem->ark_msbp             = 31;
+      ark_mem->ark_small_nef        = SMALL_NEF;
+      ark_mem->ark_etacf            = ETACF;
+      break;
+    case 5:
+      ark_mem->ark_hadapt_imethod   = 1;
+      ark_mem->ark_hadapt_safety    = RCONST(0.993);
+      ark_mem->ark_hadapt_bias      = RCONST(1.15);
+      ark_mem->ark_hadapt_growth    = RCONST(28.5);
+      ark_mem->ark_hadapt_k1        = RCONST(0.8);
+      ark_mem->ark_hadapt_k2        = RCONST(0.35);
+      ark_mem->ark_etamxf           = RCONST(0.3);
+      ark_mem->ark_nlscoef          = RCONST(0.25);
+      ark_mem->ark_crdown           = RCONST(0.4);
+      ark_mem->ark_rdiv             = RCONST(2.3);
+      ark_mem->ark_dgmax            = RCONST(0.32);
+      ark_mem->ark_msbp             = 31;
+      ark_mem->ark_small_nef        = SMALL_NEF;
+      ark_mem->ark_etacf            = ETACF;
+      break;
+    }
+
+    /* newton vs fixed-point */
+    if (ark_mem->ark_use_fp)  ark_mem->ark_maxcor = 10;
+
+  }
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetErrHandlerFn:
+
+ Specifies the error handler function
+---------------------------------------------------------------*/
+int ARKodeSetErrHandlerFn(void *arkode_mem, ARKErrHandlerFn ehfun, 
+			  void *eh_data)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetErrHandlerFn", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* set user-provided values, or defaults, depending on argument */
+  if (ehfun == NULL) {
+    ark_mem->ark_ehfun   = arkErrHandler;
+    ark_mem->ark_eh_data = ark_mem;
+  } else {
+    ark_mem->ark_ehfun   = ehfun;
+    ark_mem->ark_eh_data = eh_data;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetErrFile:
+
+ Specifies the FILE pointer for output (NULL means no messages)
+---------------------------------------------------------------*/
+int ARKodeSetErrFile(void *arkode_mem, FILE *errfp)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetErrFile", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  ark_mem->ark_errfp = errfp;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetUserData:
+
+ Specifies the user data pointer for f
+---------------------------------------------------------------*/
+int ARKodeSetUserData(void *arkode_mem, void *user_data)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetUserData", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  ark_mem->ark_user_data = user_data;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetDiagnostics:
+
+ Specifies to enable solver diagnostics, and specifies the FILE
+ pointer for output (diagfp==NULL disables output)
+---------------------------------------------------------------*/
+int ARKodeSetDiagnostics(void *arkode_mem, FILE *diagfp)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetDiagnostics", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  ark_mem->ark_diagfp = diagfp;
+  if (diagfp != NULL) {
+    ark_mem->ark_report = TRUE;
+  } else {
+    ark_mem->ark_report = FALSE;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetOrder:
+
+ Specifies the method order
+
+ ** Note in documentation that this should not be called along 
+    with ARKodeSetERKTable, ARKodeSetIRKTable, ARKodeSetARKTable, 
+    ARKodeSetERKTableNum, ARKodeSetIRKTableNum or 
+    ARKodeSetARKTableNum.  This routine is used to specify a 
+    desired method order using default Butcher tables, whereas 
+    any user-supplied table will have their own order associated 
+    with them.
+---------------------------------------------------------------*/
+int ARKodeSetOrder(void *arkode_mem, int ord)
+{
+  int i, j;
+
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetOrder", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* set user-provided value, or default, depending on argument */
+  if (ord <= 0) {
+    ark_mem->ark_q = Q_DEFAULT;
+  } else {
+    ark_mem->ark_q = ord;
+  }
+
+  /* clear Butcher tables, since user is requesting a change in method
+     or a reset to defaults.  Tables will be set in ARKInitialSetup. */
+  ark_mem->ark_stages = 0;
+  ark_mem->ark_istage = 0;
+  ark_mem->ark_p = 0;
+  for (i=0; i<ARK_S_MAX; i++) {
+    for (j=0; j<ARK_S_MAX; j++) {
+      ARK_A(ark_mem->ark_Ae,i,j) = ZERO;
+      ARK_A(ark_mem->ark_Ai,i,j) = ZERO;
+    }
+    ark_mem->ark_ce[i]  = ZERO;
+    ark_mem->ark_ci[i]  = ZERO;
+    ark_mem->ark_be[i]  = ZERO;
+    ark_mem->ark_bi[i]  = ZERO;
+    ark_mem->ark_b2e[i] = ZERO;
+    ark_mem->ark_b2i[i] = ZERO;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetDenseOrder:
+
+ Specifies the polynomial order for dense output.  Allowed values
+ range from 0 to min(q,5), where q is the order of the time 
+ integration method.  Illegal values imply to use the default.
+---------------------------------------------------------------*/
+int ARKodeSetDenseOrder(void *arkode_mem, int dord)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetDenseOrder", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check input */
+  if (dord > 5) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetDenseOrder", "Dense output order must be <= 5");
+    return(ARK_ILL_INPUT);
+  }
+  /* NOTE: we check that dord < q internally, to allow for subsequent 
+     changes via ARKodeSetOrder */
+
+  /* set user-provided value, or default, depending on argument */
+  /* if ((dord < 0) || (dord > 5)) { */
+  if ((dord < 0) || (dord > 3)) {
+    ark_mem->ark_dense_q = QDENSE_DEF;
+  } else {
+    ark_mem->ark_dense_q = dord;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetLinear:
+
+ Specifies that the implicit portion of the problem is linear, 
+ and to tighten the linear solver tolerances while taking only 
+ one Newton iteration.  Not useful when used in combination with
+ the fixed-point solver.  Automatically tightens DeltaGammaMax 
+ to ensure that step size changes cause Jacobian recomputation.
+
+ The argument should be 1 or 0, where 1 indicates that the 
+ Jacobian of fi with respect to y depends on time, and
+ 0 indicates that it is not time dependent.  Alternately, when 
+ using an iterative linear solver this flag denotes time 
+ dependence of the preconditioner. 
+---------------------------------------------------------------*/
+int ARKodeSetLinear(void *arkode_mem, int timedepend)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetLinear", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  ark_mem = (ARKodeMem) arkode_mem;
+  ark_mem->ark_linear = TRUE;
+  ark_mem->ark_linear_timedep = (timedepend == 1);
+  ark_mem->ark_dgmax = RCONST(100.0)*UNIT_ROUNDOFF;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetNonlinear:
+
+ Specifies that the implicit portion of the problem is nonlinear.
+ Used to undo a previous call to ARKodeSetLinear.  Automatically
+ loosens DeltaGammaMax back to default value.
+---------------------------------------------------------------*/
+int ARKodeSetNonlinear(void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetNonlinear", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  ark_mem = (ARKodeMem) arkode_mem;
+  ark_mem->ark_linear = FALSE;
+  ark_mem->ark_linear_timedep = TRUE;
+  ark_mem->ark_dgmax = DGMAX;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetFixedPoint:
+
+ Specifies that the implicit portion of the problem should be 
+ solved using the accelerated fixed-point solver instead of the 
+ Newton iteration.  Allowed values for the dimension of the 
+ acceleration space, fp_m, must be non-negative.  Illegal 
+ values imply to use the default.
+---------------------------------------------------------------*/
+int ARKodeSetFixedPoint(void *arkode_mem, long int fp_m)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetFixedPoint", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  ark_mem = (ARKodeMem) arkode_mem;
+  ark_mem->ark_use_fp = TRUE;
+  if (fp_m < 0) {
+    ark_mem->ark_fp_m = FP_ACCEL_M;
+  } else {
+    ark_mem->ark_fp_m = fp_m;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetNewton:
+
+ Specifies that the implicit portion of the problem should be 
+ solved using the modified Newton solver.  Used to undo a 
+ previous call to ARKodeSetFixedPoint.
+---------------------------------------------------------------*/
+int ARKodeSetNewton(void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetNewton", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  ark_mem = (ARKodeMem) arkode_mem;
+  ark_mem->ark_use_fp = FALSE;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetExplicit:
+
+ Specifies that the implicit portion of the problem is disabled, 
+ and to use an explicit RK method.
+---------------------------------------------------------------*/
+int ARKodeSetExplicit(void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetExplicit", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* ensure that fe is defined */
+  if (ark_mem->ark_fe == NULL) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetExplicit", MSGARK_MISSING_FE);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set the relevant parameters */
+  ark_mem->ark_explicit = TRUE;
+  ark_mem->ark_implicit = FALSE;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetImplicit:
+
+ Specifies that the explicit portion of the problem is disabled, 
+ and to use an implicit RK method.
+---------------------------------------------------------------*/
+int ARKodeSetImplicit(void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetImplicit", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* ensure that fi is defined */
+  if (ark_mem->ark_fi == NULL) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetImplicit", MSGARK_MISSING_FI);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set the relevant parameters */
+  ark_mem->ark_implicit = TRUE;
+  ark_mem->ark_explicit = FALSE;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetImEx:
+
+ Specifies that the specifies that problem has both implicit and
+ explicit parts, and to use an ARK method (this is the default).
+---------------------------------------------------------------*/
+int ARKodeSetImEx(void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetImEx", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* ensure that fe and fi are defined */
+  if (ark_mem->ark_fe == NULL) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetImEx", MSGARK_MISSING_FE);
+    return(ARK_ILL_INPUT);
+  }
+  if (ark_mem->ark_fi == NULL) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetImEx", MSGARK_MISSING_FI);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set the relevant parameters */
+  ark_mem->ark_explicit = FALSE;
+  ark_mem->ark_implicit = FALSE;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetERKTable:
+
+ Specifies to use a customized Butcher table for the explicit 
+ portion of the system (automatically calls ARKodeSetExplicit).
+ 
+ If bembed==NULL, then the method is automatically flagged as a 
+ fixed-step method; a user MUST also call either 
+ ARKodeSetFixedStep or ARKodeSetInitStep to set the desired time 
+ step size.
+---------------------------------------------------------------*/
+int ARKodeSetERKTable(void *arkode_mem, int s, int q, int p,
+		      realtype *c, realtype *A, realtype *b, 
+		      realtype *bembed)
+{
+  int i, j;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetERKTable", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check for legal inputs */
+  if (s > ARK_S_MAX) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetERKTable", "s exceeds ARK_S_MAX");
+    return(ARK_ILL_INPUT);
+  }
+  if ((c == NULL) || (A == NULL) || (b == NULL)) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetERKTable", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  /* clear any existing parameters */
+  ark_mem->ark_stages = 0;
+  ark_mem->ark_q = 0;
+  ark_mem->ark_p = 0;
+  for (i=0; i<ARK_S_MAX; i++) {
+    ark_mem->ark_ce[i]  = 0.0;
+    ark_mem->ark_be[i]  = 0.0;
+    ark_mem->ark_b2e[i] = 0.0;
+    for (j=0; j<ARK_S_MAX; j++) 
+      ARK_A(ark_mem->ark_Ae,i,j) = 0.0;
+  }
+
+  /* set the relevant parameters */
+  ark_mem->ark_stages = s;
+  ark_mem->ark_q = q;
+  ark_mem->ark_p = p;
+  for (i=0; i<s; i++) {
+    ark_mem->ark_ce[i]  = c[i];
+    ark_mem->ark_be[i]  = b[i];
+    for (j=0; j<s; j++) {
+      ARK_A(ark_mem->ark_Ae,i,j) = A[i*s + j];
+    }
+  }
+
+  /* set embedding (if applicable), otherwise set as fixed-step method */
+  if (bembed == NULL) {
+    ark_mem->ark_fixedstep = TRUE;
+  } else {
+    for (i=0; i<s; i++) 
+      ark_mem->ark_b2e[i] = bembed[i];
+  }
+  
+  /* set method as purely explicit */
+  if (ARKodeSetExplicit(arkode_mem) != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetERKTable", MSGARK_MISSING_FE);
+    return(ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetIRKTable:
+
+ Specifies to use a customized Butcher table for the implicit 
+ portion of the system (automatically calls ARKodeSetImplicit).
+
+ If bembed==NULL, then the method is automatically flagged as a 
+ fixed-step method; a user MUST also call either 
+ ARKodeSetFixedStep or ARKodeSetInitStep to set the desired time 
+ step size.
+---------------------------------------------------------------*/
+int ARKodeSetIRKTable(void *arkode_mem, int s, int q, int p,
+		      realtype *c, realtype *A, realtype *b, 
+		      realtype *bembed)
+{
+  int i, j;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetIRKTable", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check for legal inputs */
+  if (s > ARK_S_MAX) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetIRKTable", "s exceeds ARK_S_MAX");
+    return(ARK_ILL_INPUT);
+  }
+  if ((c == NULL) || (A == NULL) || (b == NULL)) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetIRKTable", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  /* clear any existing parameters */
+  ark_mem->ark_stages = 0;
+  ark_mem->ark_q = 0;
+  ark_mem->ark_p = 0;
+  for (i=0; i<ARK_S_MAX; i++) {
+    ark_mem->ark_ci[i]  = 0.0;
+    ark_mem->ark_bi[i]  = 0.0;
+    ark_mem->ark_b2i[i] = 0.0;
+    for (j=0; j<ARK_S_MAX; j++) 
+      ARK_A(ark_mem->ark_Ai,i,j) = 0.0;
+  }
+
+  /* set the relevant parameters */
+  ark_mem->ark_stages = s;
+  ark_mem->ark_q = q;
+  ark_mem->ark_p = p;
+  for (i=0; i<s; i++) {
+    ark_mem->ark_ci[i]  = c[i];
+    ark_mem->ark_bi[i]  = b[i];
+    for (j=0; j<s; j++) {
+      ARK_A(ark_mem->ark_Ai,i,j) = A[i*s + j];
+    }
+  }
+
+  /* set embedding (if applicable), otherwise set as fixed-step method */
+  if (bembed == NULL) {
+    ark_mem->ark_fixedstep = TRUE;
+  } else {
+    for (i=0; i<s; i++) 
+      ark_mem->ark_b2i[i] = bembed[i];
+  }
+  
+  /* set method as purely implicit */
+  if (ARKodeSetImplicit(arkode_mem) != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetIRKTable", MSGARK_MISSING_FI);
+    return(ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetARKTables:
+
+ Specifies to use customized Butcher tables for the ImEx system
+ (automatically calls ARKodeSetImEx).
+
+ If either b2e==NULL or b2i==NULL, then the method is 
+ automatically flagged as a fixed-step method; a user MUST also 
+ call either ARKodeSetFixedStep or ARKodeSetInitStep to set the 
+ desired time step size.
+---------------------------------------------------------------*/
+int ARKodeSetARKTables(void *arkode_mem, int s, int q, int p,
+		       realtype *ci, realtype *ce, 
+		       realtype *Ai, realtype *Ae, 
+		       realtype *bi, realtype *be, 
+		       realtype *b2i, realtype *b2e)
+{
+  int i, j;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetARKTables", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check for legal inputs */
+  if (s > ARK_S_MAX) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetARKTables", "s exceeds ARK_S_MAX");
+    return(ARK_ILL_INPUT);
+  }
+  if ((ci == NULL) || (ce == NULL) || 
+      (Ai == NULL) || (Ae == NULL) || 
+      (bi == NULL) || (be == NULL)) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetARKTables", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  /* clear any existing parameters */
+  ark_mem->ark_stages = 0;
+  ark_mem->ark_q = 0;
+  ark_mem->ark_p = 0;
+  for (i=0; i<ARK_S_MAX; i++) {
+    ark_mem->ark_ce[i]  = 0.0;
+    ark_mem->ark_ci[i]  = 0.0;
+    ark_mem->ark_be[i]  = 0.0;
+    ark_mem->ark_bi[i]  = 0.0;
+    ark_mem->ark_b2e[i] = 0.0;
+    ark_mem->ark_b2i[i] = 0.0;
+    for (j=0; j<ARK_S_MAX; j++) {
+      ARK_A(ark_mem->ark_Ai,i,j) = 0.0;
+      ARK_A(ark_mem->ark_Ae,i,j) = 0.0;
+    }
+  }
+
+  /* set the relevant parameters */
+  ark_mem->ark_stages = s;
+  ark_mem->ark_q = q;
+  ark_mem->ark_p = p;
+  for (i=0; i<s; i++) {
+    ark_mem->ark_ce[i]  = ce[i];
+    ark_mem->ark_ci[i]  = ci[i];
+    ark_mem->ark_be[i]  = be[i];
+    ark_mem->ark_bi[i]  = bi[i];
+    for (j=0; j<s; j++) {
+      ARK_A(ark_mem->ark_Ai,i,j) = Ai[i*s + j];
+      ARK_A(ark_mem->ark_Ae,i,j) = Ae[i*s + j];
+    }
+  }
+
+  /* set embeddings (if applicable), otherwise set as fixed-step method */
+  if ((b2e == NULL) || (b2i == NULL)) {
+    ark_mem->ark_fixedstep = TRUE;
+  } else {
+    for (i=0; i<s; i++) {
+      ark_mem->ark_b2e[i] = b2e[i];
+      ark_mem->ark_b2i[i] = b2i[i];
+    }
+  }
+
+  /* set method as ImEx */
+  if (ARKodeSetImEx(arkode_mem) != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetARKTables", MSGARK_MISSING_F);
+    return(ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetERKTableNum:
+
+ Specifies to use a pre-existing Butcher table for the explicit 
+ portion of the problem, based on the integer flag held in 
+ ARKodeLoadButcherTable() within the file arkode_butcher.c 
+ (automatically calls ARKodeSetExplicit).
+---------------------------------------------------------------*/
+int ARKodeSetERKTableNum(void *arkode_mem, int itable)
+{
+  int iflag;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetERKTableNum", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check that argument specifies an explicit table */
+  if (itable<MIN_ERK_NUM || itable>MAX_ERK_NUM) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetERKTableNum", 
+		    "Illegal ERK table number");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* fill in table based on argument */
+  iflag = ARKodeLoadButcherTable(itable, 
+				 &ark_mem->ark_stages, 
+				 &ark_mem->ark_q, 
+				 &ark_mem->ark_p, 
+				 ark_mem->ark_Ae, 
+				 ark_mem->ark_be, 
+				 ark_mem->ark_ce, 
+				 ark_mem->ark_b2e);
+  if (iflag != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetERKTableNum", 
+		    "Error setting table with that index");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set method as purely explicit */
+  if (ARKodeSetExplicit(arkode_mem) != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetERKTableNum", MSGARK_MISSING_FE);
+    return(ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetIRKTableNum:
+
+ Specifies to use a pre-existing Butcher table for the implicit 
+ portion of the problem, based on the integer flag held in 
+ ARKodeLoadButcherTable() within the file arkode_butcher.c
+ (automatically calls ARKodeSetImplicit).
+---------------------------------------------------------------*/
+int ARKodeSetIRKTableNum(void *arkode_mem, int itable)
+{
+  int iflag;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetIRKTableNum", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check that argument specifies an implicit table */
+  if (itable<MIN_DIRK_NUM || itable>MAX_DIRK_NUM) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetIRKTableNum", 
+		    "Illegal IRK table number");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* fill in table based on argument */
+  iflag = ARKodeLoadButcherTable(itable, 
+				 &ark_mem->ark_stages, 
+				 &ark_mem->ark_q, 
+				 &ark_mem->ark_p, 
+				 ark_mem->ark_Ai, 
+				 ark_mem->ark_bi, 
+				 ark_mem->ark_ci, 
+				 ark_mem->ark_b2i);
+  if (iflag != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetIRKTableNum", 
+		    "Error setting table with that index");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set method as purely implicit */
+  if (ARKodeSetImplicit(arkode_mem) != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetIRKTableNum", MSGARK_MISSING_FI);
+    return(ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetARKTableNum:
+
+ Specifies to use pre-existing Butcher tables for the ImEx system,
+ based on the integer flags held in ARKodeLoadButcherTable() 
+ within the file arkode_butcher.c (automatically calls ARKodeSetImEx).
+---------------------------------------------------------------*/
+int ARKodeSetARKTableNum(void *arkode_mem, int itable, int etable)
+{
+  int iflag, eflag;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetARKTableNum", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* ensure that tables match */
+  iflag = 1;
+  if ( ((etable == ARK324L2SA_ERK_4_2_3) && (itable == ARK324L2SA_DIRK_4_2_3)) ||
+       ((etable == ARK436L2SA_ERK_6_3_4) && (itable == ARK436L2SA_DIRK_6_3_4)) ||
+       ((etable == ARK548L2SA_ERK_8_4_5) && (itable == ARK548L2SA_DIRK_8_4_5)) )
+    iflag = 0;
+  if (iflag) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetARKTableNum", 
+		    "Incompatible Butcher tables for ARK method");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* fill in tables based on arguments */
+  iflag = ARKodeLoadButcherTable(itable, 
+				 &ark_mem->ark_stages, 
+				 &ark_mem->ark_q, 
+				 &ark_mem->ark_p, 
+				 ark_mem->ark_Ai, 
+				 ark_mem->ark_bi, 
+				 ark_mem->ark_ci, 
+				 ark_mem->ark_b2i);
+  eflag = ARKodeLoadButcherTable(etable, 
+				 &ark_mem->ark_stages, 
+				 &ark_mem->ark_q, 
+				 &ark_mem->ark_p, 
+				 ark_mem->ark_Ae, 
+				 ark_mem->ark_be, 
+				 ark_mem->ark_ce, 
+				 ark_mem->ark_b2e);
+
+  /* check that requested tables are legal */
+  if (iflag != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetARKTableNum", 
+		    "Illegal IRK table number");
+    return(ARK_ILL_INPUT);
+  }
+  if (eflag != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetARKTableNum", 
+		    "Illegal ERK table number");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set method as ImEx */
+  if (ARKodeSetImEx(arkode_mem) != ARK_SUCCESS) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetARKTableNum", MSGARK_MISSING_F);
+    return(ARK_ILL_INPUT);
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxNumSteps:
+
+ Specifies the maximum number of integration steps
+---------------------------------------------------------------*/
+int ARKodeSetMaxNumSteps(void *arkode_mem, long int mxsteps)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxNumSteps", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Passing mxsteps=0 sets the default. Passing mxsteps<0 disables the test. */
+  if (mxsteps == 0)
+    ark_mem->ark_mxstep = MXSTEP_DEFAULT;
+  else
+    ark_mem->ark_mxstep = mxsteps;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxHnilWarns:
+
+ Specifies the maximum number of warnings for small h
+---------------------------------------------------------------*/
+int ARKodeSetMaxHnilWarns(void *arkode_mem, int mxhnil)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxHnilWarns", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Passing mxhnil=0 sets the default, otherwise use input. */
+  if (mxhnil == 0) {
+    ark_mem->ark_mxhnil = 10;
+  } else {
+    ark_mem->ark_mxhnil = mxhnil;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetInitStep:
+
+ Specifies the initial step size
+---------------------------------------------------------------*/
+int ARKodeSetInitStep(void *arkode_mem, realtype hin)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetInitStep", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Passing hin=0 sets the default, otherwise use input. */
+  if (hin == ZERO) {
+    ark_mem->ark_hin = ZERO;
+  } else {
+    ark_mem->ark_hin = hin;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMinStep:
+
+ Specifies the minimum step size
+---------------------------------------------------------------*/
+int ARKodeSetMinStep(void *arkode_mem, realtype hmin)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMinStep", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Passing a value <= 0 sets hmax = infinity */
+  if (hmin <= ZERO) {
+    ark_mem->ark_hmin = ZERO;
+    return(ARK_SUCCESS);
+  }
+
+  /* check that hmin and hmax are agreeable */
+  if (hmin * ark_mem->ark_hmax_inv > ONE) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetMinStep", MSGARK_BAD_HMIN_HMAX);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set the value */
+  ark_mem->ark_hmin = hmin;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxStep:
+
+ Specifies the maximum step size
+---------------------------------------------------------------*/
+int ARKodeSetMaxStep(void *arkode_mem, realtype hmax)
+{
+  realtype hmax_inv;
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxStep", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Passing a value <= 0 sets hmax = infinity */
+  if (hmax <= ZERO) {
+    ark_mem->ark_hmax_inv = ZERO;
+    return(ARK_SUCCESS);
+  }
+
+  /* check that hmax and hmin are agreeable */
+  hmax_inv = ONE/hmax;
+  if (hmax_inv * ark_mem->ark_hmin > ONE) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetMaxStep", MSGARK_BAD_HMIN_HMAX);
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set the value */
+  ark_mem->ark_hmax_inv = hmax_inv;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetStopTime:
+
+ Specifies the time beyond which the integration is not to proceed.
+---------------------------------------------------------------*/
+int ARKodeSetStopTime(void *arkode_mem, realtype tstop)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetStopTime", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* If ARKode was called at least once, test if tstop is legal
+     (i.e. if it was not already passed).
+     If ARKodeSetStopTime is called before the first call to ARKode,
+     tstop will be checked in ARKode. */
+  if (ark_mem->ark_nst > 0) {
+    if ( (tstop - ark_mem->ark_tn) * ark_mem->ark_h < ZERO ) {
+      arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		      "ARKodeSetStopTime", MSGARK_BAD_TSTOP, 
+		      tstop, ark_mem->ark_tn);
+      return(ARK_ILL_INPUT);
+    }
+  }
+
+  ark_mem->ark_tstop    = tstop;
+  ark_mem->ark_tstopset = TRUE;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetFixedStep:
+
+ Specifies to use a fixed time step size instead of performing 
+ any form of temporal adaptivity.  ARKode will use this step size 
+ for all steps (unless tstop is set, in which case it may need to 
+ modify that last step approaching tstop.  If any (non)linear
+ solver failure occurs, ARKode will immediately return with an 
+ error message since the time step size cannot be modified.  
+
+ Any nonzero argument will result in the use of that fixed step 
+ size; an argument of 0 will re-enable temporal adaptivity.
+---------------------------------------------------------------*/
+int ARKodeSetFixedStep(void *arkode_mem, realtype hfixed)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetFixedStep", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* set ark_mem entry */
+  if (hfixed != ZERO) {
+    ark_mem->ark_fixedstep = TRUE;
+    ark_mem->ark_hin = hfixed;
+  } else {
+    ark_mem->ark_fixedstep = FALSE;
+  }
+    
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetCFLFraction:
+
+ Specifies the safety factor to use on the maximum explicitly-
+ stable step size.  Allowable values must be within the open 
+ interval (0,1).  A non-positive input implies a reset to
+ the default value.
+---------------------------------------------------------------*/
+int ARKodeSetCFLFraction(void *arkode_mem, realtype cfl_frac)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetCFLFraction", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check for allowable parameters */
+  if (cfl_frac >= 1.0) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetCFLFraction", "Illegal CFL fraction");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set positive-valued parameters into ark_mem, 
+     otherwise set default */
+  if (cfl_frac <= ZERO) {
+    ark_mem->ark_hadapt_cfl = CFLFAC;
+  } else {
+    ark_mem->ark_hadapt_cfl = cfl_frac;
+  }
+    
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetSafetyFactor:
+
+ Specifies the safety factor to use on the error-based predicted 
+ time step size.  Allowable values must be within the open 
+ interval (0,1).  A non-positive input implies a reset to the 
+ default value.
+---------------------------------------------------------------*/
+int ARKodeSetSafetyFactor(void *arkode_mem, realtype safety)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetSafetyFactoy", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check for allowable parameters */
+  if (safety >= 1.0) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetSafetyFactor", "Illegal safety factor");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set positive-valued parameters into ark_mem, 
+     otherwise set default */
+  if (safety <= ZERO) {
+    ark_mem->ark_hadapt_safety = SAFETY;
+  } else {
+    ark_mem->ark_hadapt_safety = safety;
+  }
+    
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetErrorBias:
+
+ Specifies the error bias to use when performing adaptive-step
+ error control.  Allowable values must be >= 1.0.  Any illegal
+ value implies a reset to the default value.
+---------------------------------------------------------------*/
+int ARKodeSetErrorBias(void *arkode_mem, realtype bias)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetErrorBias", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* set allowed value into ark_mem, otherwise set default */
+  if (bias < 1.0) {
+    ark_mem->ark_hadapt_bias = BIAS;
+  } else {
+    ark_mem->ark_hadapt_bias = bias;
+  }
+    
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxGrowth:
+
+ Specifies the maximum step size growth factor to be allowed
+ between successive integration steps.  Note: the first step uses 
+ a separate maximum growth factor.  Allowable values must be 
+ > 1.0.  Any illegal value implies a reset to the default.
+---------------------------------------------------------------*/
+int ARKodeSetMaxGrowth(void *arkode_mem, realtype mx_growth)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxGrowth", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* set allowed value into ark_mem, otherwise set default */
+  if (mx_growth == ZERO) {
+    ark_mem->ark_hadapt_growth = GROWTH;
+  } else {
+    ark_mem->ark_hadapt_growth = mx_growth;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetFixedStepBounds:
+
+ Specifies the step size growth interval within which the step 
+ size will remain unchanged.  Allowable values must enclose the 
+ value 1.0.  Any illegal interval implies a reset to the default.
+---------------------------------------------------------------*/
+int ARKodeSetFixedStepBounds(void *arkode_mem, realtype lb, realtype ub)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetFixedStepBounds", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* set allowable interval into ark_mem, otherwise set defaults */
+  if ((lb <= 1.0) && (ub >= 1.0)) {
+    ark_mem->ark_hadapt_lbound = lb;
+    ark_mem->ark_hadapt_ubound = ub;
+  } else {
+    ark_mem->ark_hadapt_lbound = HFIXED_LB;
+    ark_mem->ark_hadapt_ubound = HFIXED_UB;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetAdaptivityMethod:
+
+ Specifies the built-in time step adaptivity algorithm (and 
+ optionally, its associated parameters) to use.  All parameters 
+ will be checked for validity when used by the solver.
+---------------------------------------------------------------*/
+int ARKodeSetAdaptivityMethod(void *arkode_mem, int imethod, 
+			      int idefault, int pq, 
+			      realtype *adapt_params)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetAdaptivityMethod", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* check for allowable parameters */
+  if ((imethod > 5) || (imethod < 0)) {
+    arkProcessError(ark_mem, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetAdaptivityMethod", "Illegal imethod");
+    return(ARK_ILL_INPUT);
+  }
+
+  /* set adaptivity method */
+  ark_mem->ark_hadapt_imethod = imethod;
+
+  /* set flag whether to use p or q */
+  ark_mem->ark_hadapt_pq = (pq != 0);
+
+  /* set method parameters */
+  if (idefault == 1) {
+    switch (ark_mem->ark_hadapt_imethod) {
+    case (0):
+      ark_mem->ark_hadapt_k1 = AD0_K1; 
+      ark_mem->ark_hadapt_k2 = AD0_K2;
+      ark_mem->ark_hadapt_k3 = AD0_K3; break;
+    case (1):
+      ark_mem->ark_hadapt_k1 = AD1_K1;
+      ark_mem->ark_hadapt_k2 = AD1_K2; break;
+    case (2):
+      ark_mem->ark_hadapt_k1 = AD2_K1; break;
+    case (3):
+      ark_mem->ark_hadapt_k1 = AD3_K1;
+      ark_mem->ark_hadapt_k2 = AD3_K2; break;
+    case (4):
+      ark_mem->ark_hadapt_k1 = AD4_K1;
+      ark_mem->ark_hadapt_k2 = AD4_K2; break;
+    case (5):
+      ark_mem->ark_hadapt_k1 = AD5_K1;
+      ark_mem->ark_hadapt_k2 = AD5_K2; 
+      ark_mem->ark_hadapt_k3 = AD5_K3; break;
+    }
+  } else {
+    ark_mem->ark_hadapt_k1 = adapt_params[0];
+    ark_mem->ark_hadapt_k2 = adapt_params[1];
+    ark_mem->ark_hadapt_k3 = adapt_params[2];
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetAdaptivityFn:
+
+ Specifies the user-provided time step adaptivity function to use.
+---------------------------------------------------------------*/
+int ARKodeSetAdaptivityFn(void *arkode_mem, ARKAdaptFn hfun,
+			  void *h_data)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetAdaptivityFn", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* NULL argument sets default, otherwise set inputs */
+  if (hfun == NULL) {
+    ark_mem->ark_hadapt         = NULL;
+    ark_mem->ark_hadapt_data    = NULL;
+    ark_mem->ark_hadapt_imethod = 0;
+  } else {
+    ark_mem->ark_hadapt         = hfun;
+    ark_mem->ark_hadapt_data    = h_data;
+    ark_mem->ark_hadapt_imethod = -1;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxFirstGrowth:
+
+ Specifies the user-provided time step adaptivity constant 
+ etamx1.  Legal values are greater than 1.0.  Illegal values 
+ imply a reset to the default value. 
+---------------------------------------------------------------*/
+int ARKodeSetMaxFirstGrowth(void *arkode_mem, realtype etamx1)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxFirstGrowth", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if (etamx1 <= ONE) {
+    ark_mem->ark_etamx1 = ETAMX1;
+  } else {
+    ark_mem->ark_etamx1 = etamx1;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxEFailGrowth:
+
+ Specifies the user-provided time step adaptivity constant 
+ etamxf. Legal values are in the interval (0,1].  Illegal values 
+ imply a reset to the default value. 
+---------------------------------------------------------------*/
+int ARKodeSetMaxEFailGrowth(void *arkode_mem, realtype etamxf)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxEFailGrowth", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if ((etamxf <= ZERO) || (etamxf > ONE)) {
+    ark_mem->ark_etamxf = ETAMXF;
+  } else {
+    ark_mem->ark_etamxf = etamxf;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetSmallNumEFails:
+
+ Specifies the user-provided time step adaptivity constant
+ small_nef.  Legal values are > 0.  Illegal values 
+ imply a reset to the default value. 
+---------------------------------------------------------------*/
+int ARKodeSetSmallNumEFails(void *arkode_mem, int small_nef)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetSmallNumEFails", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if (small_nef <= 0) {
+    ark_mem->ark_small_nef = SMALL_NEF;
+  } else {
+    ark_mem->ark_small_nef = small_nef;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxCFailGrowth:
+
+ Specifies the user-provided time step adaptivity constant
+ etacf. Legal values are in the interval (0,1].  Illegal values 
+ imply a reset to the default value. 
+---------------------------------------------------------------*/
+int ARKodeSetMaxCFailGrowth(void *arkode_mem, realtype etacf)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxCFailGrowth", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if ((etacf <= ZERO) || (etacf > ONE)) {
+    ark_mem->ark_etacf = ETACF;
+  } else {
+    ark_mem->ark_etacf = etacf;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetNonlinCRDown:
+
+ Specifies the user-provided nonlinear convergence constant
+ crdown.  Legal values are strictly positive; illegal values 
+ imply a reset to the default.
+---------------------------------------------------------------*/
+int ARKodeSetNonlinCRDown(void *arkode_mem, realtype crdown)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetNonlinCRDown", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if (crdown <= ZERO) {
+    ark_mem->ark_crdown = CRDOWN;
+  } else {
+    ark_mem->ark_crdown = crdown;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetNonlinRDiv:
+
+ Specifies the user-provided nonlinear convergence constant
+ rdiv.  Legal values are strictly positive; illegal values 
+ imply a reset to the default.
+---------------------------------------------------------------*/
+int ARKodeSetNonlinRDiv(void *arkode_mem, realtype rdiv)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetNonlinRDiv", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if (rdiv <= ZERO) {
+    ark_mem->ark_rdiv = RDIV;
+  } else {
+    ark_mem->ark_rdiv = rdiv;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetDeltaGammaMax:
+
+ Specifies the user-provided linear setup decision constant
+ dgmax.  Legal values are strictly positive; illegal values imply 
+ a reset to the default. 
+---------------------------------------------------------------*/
+int ARKodeSetDeltaGammaMax(void *arkode_mem, realtype dgmax)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetDeltaGammaMax", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if (dgmax <= ZERO) {
+    ark_mem->ark_dgmax = DGMAX;
+  } else {
+    ark_mem->ark_dgmax = dgmax;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxStepsBetweenLSet:
+
+ Specifies the user-provided linear setup decision constant
+ msbp.  Positive values give the number of time steps to wait 
+ before calling lsetup; negative values imply recomputation of 
+ lsetup at each Newton iteration; a zero value implies a reset 
+ to the default. 
+---------------------------------------------------------------*/
+int ARKodeSetMaxStepsBetweenLSet(void *arkode_mem, int msbp)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxStepsBetweenLSet", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* if argument legal set it, otherwise set default */
+  if (msbp == 0) {
+    ark_mem->ark_msbp = MSBP;
+  } else {
+    ark_mem->ark_msbp = msbp;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetPredictorMethod:
+
+ Specifies the method to use for predicting implicit solutions.  
+ Non-default choices are {1,2,3,4}, all others will use default 
+ (trivial) predictor.
+---------------------------------------------------------------*/
+int ARKodeSetPredictorMethod(void *arkode_mem, int pred_method)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetPredictorMethod", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+  ark_mem->ark_predictor = pred_method;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetStabilityFn:
+
+ Specifies the user-provided explicit time step stability 
+ function to use.  A NULL input function implies a reset to
+ the default function (empty).
+---------------------------------------------------------------*/
+int ARKodeSetStabilityFn(void *arkode_mem, ARKExpStabFn EStab,
+			 void *estab_data)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetStabilityFn", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* NULL argument sets default, otherwise set inputs */
+  if (EStab == NULL) {
+    ark_mem->ark_expstab    = arkExpStab;
+    ark_mem->ark_estab_data = ark_mem;
+  } else {
+    ark_mem->ark_expstab    = EStab;
+    ark_mem->ark_estab_data = estab_data;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxErrTestFails:
+
+ Specifies the maximum number of error test failures during one
+ step try.  A non-positive input implies a reset to
+ the default value.
+---------------------------------------------------------------*/
+int ARKodeSetMaxErrTestFails(void *arkode_mem, int maxnef)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxErrTestFails", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* argument <= 0 sets default, otherwise set input */
+  if (maxnef <= 0) {
+    ark_mem->ark_maxnef = MAXNEF;
+  } else {
+    ark_mem->ark_maxnef = maxnef;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxConvFails:
+
+ Specifies the maximum number of nonlinear convergence failures 
+ during one step try.  A non-positive input implies a reset to
+ the default value.
+---------------------------------------------------------------*/
+int ARKodeSetMaxConvFails(void *arkode_mem, int maxncf)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxConvFails", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* argument <= 0 sets default, otherwise set input */
+  if (maxncf <= 0) {
+    ark_mem->ark_maxncf = MAXNCF;
+  } else {
+    ark_mem->ark_maxncf = maxncf;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetMaxNonlinIters:
+
+ Specifies the maximum number of nonlinear iterations during
+ one solve.  A non-positive input implies a reset to the 
+ default value.
+---------------------------------------------------------------*/
+int ARKodeSetMaxNonlinIters(void *arkode_mem, int maxcor)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetMaxNonlinIters", MSGARK_NO_MEM);
+    return (ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* argument <= 0 sets default, otherwise set input */
+  if (maxcor <= 0) {
+    ark_mem->ark_maxcor = MAXCOR;
+  } else {
+    ark_mem->ark_maxcor = maxcor;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetNonlinConvCoef:
+
+ Specifies the coefficient in the nonlinear solver convergence
+ test.  A non-positive input implies a reset to the default value.
+---------------------------------------------------------------*/
+int ARKodeSetNonlinConvCoef(void *arkode_mem, realtype nlscoef)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetNonlinConvCoef", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* argument <= 0 sets default, otherwise set input */
+  if (nlscoef <= ZERO) {
+    ark_mem->ark_nlscoef = NLSCOEF;
+  } else {
+    ark_mem->ark_nlscoef = nlscoef;
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetRootDirection:
+
+ Specifies the direction of zero-crossings to be monitored.
+ The default is to monitor both crossings.
+---------------------------------------------------------------*/
+int ARKodeSetRootDirection(void *arkode_mem, int *rootdir)
+{
+  ARKodeMem ark_mem;
+  int i, nrt;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetRootDirection", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  nrt = ark_mem->ark_nrtfn;
+  if (nrt==0) {
+    arkProcessError(NULL, ARK_ILL_INPUT, "ARKODE", 
+		    "ARKodeSetRootDirection", MSGARK_NO_ROOT);
+    return(ARK_ILL_INPUT);    
+  }
+
+  for(i=0; i<nrt; i++) ark_mem->ark_rootdir[i] = rootdir[i];
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetNoInactiveRootWarn:
+
+ Disables issuing a warning if some root function appears
+ to be identically zero at the beginning of the integration
+---------------------------------------------------------------*/
+int ARKodeSetNoInactiveRootWarn(void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetNoInactiveRootWarn", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  ark_mem->ark_mxgnull = 0;
+  
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeSetPostprocessStepFn:
+
+ Specifies a user-provided step postprocessing function having 
+ type ARKPostProcessStepFn.  A NULL input function disables step
+ postprocessing.
+
+ IF THE SUPPLIED FUNCTION MODIFIES ANY OF THE ACTIVE STATE DATA, 
+ THEN ALL THEORETICAL GUARANTEES OF SOLUTION ACCURACY AND 
+ STABILITY ARE LOST.
+---------------------------------------------------------------*/
+int ARKodeSetPostprocessStepFn(void *arkode_mem, 
+			       ARKPostProcessStepFn ProcessStep)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeSetStabilityFn", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* NULL argument sets default, otherwise set inputs */
+  ark_mem->ark_ProcessStep = ProcessStep;
+  return(ARK_SUCCESS);
+}
+
+
+/*===============================================================
+ ARKODE optional output functions
+===============================================================*/
+
+/*---------------------------------------------------------------
+ ARKodeGetNumSteps:
+
+ Returns the current number of integration steps
+---------------------------------------------------------------*/
+int ARKodeGetNumSteps(void *arkode_mem, long int *nsteps)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumSteps", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nsteps = ark_mem->ark_nst;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumExpSteps:
+
+ Returns the current number of stability-limited steps
+---------------------------------------------------------------*/
+int ARKodeGetNumExpSteps(void *arkode_mem, long int *nsteps)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumExpSteps", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nsteps = ark_mem->ark_nst_exp;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumAccSteps:
+
+ Returns the current number of accuracy-limited steps
+---------------------------------------------------------------*/
+int ARKodeGetNumAccSteps(void *arkode_mem, long int *nsteps)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumAccSteps", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nsteps = ark_mem->ark_nst_acc;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumStepAttempts:
+
+ Returns the current number of steps attempted by the solver
+---------------------------------------------------------------*/
+int ARKodeGetNumStepAttempts(void *arkode_mem, long int *nsteps)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumStepAttempts", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nsteps = ark_mem->ark_nst_attempts;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumRhsEvals:
+
+ Returns the current number of calls to fe and fi
+---------------------------------------------------------------*/
+int ARKodeGetNumRhsEvals(void *arkode_mem, long int *fe_evals,
+			 long int *fi_evals)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumRhsEvals", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *fe_evals = ark_mem->ark_nfe;
+  *fi_evals = ark_mem->ark_nfi;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumLinSolvSetups:
+
+ Returns the current number of calls to the lsetup routine
+---------------------------------------------------------------*/
+int ARKodeGetNumLinSolvSetups(void *arkode_mem, long int *nlinsetups)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumLinSolvSetups", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nlinsetups = ark_mem->ark_nsetups;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumMassSolves:
+
+ Returns the current number of calls to the mass matrix solver.
+---------------------------------------------------------------*/
+int ARKodeGetNumMassSolves(void *arkode_mem, long int *nMassSolves)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumMassSolves", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nMassSolves = ark_mem->ark_mass_solves;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumMassMultiplies:
+
+ Returns the current number of calls to the mass matrix product.
+---------------------------------------------------------------*/
+int ARKodeGetNumMassMultiplies(void *arkode_mem, long int *nMassMult)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumMassMult", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nMassMult = ark_mem->ark_mass_mult;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumErrTestFails:
+
+ Returns the current number of error test failures
+---------------------------------------------------------------*/
+int ARKodeGetNumErrTestFails(void *arkode_mem, long int *netfails)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumErrTestFails", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *netfails = ark_mem->ark_netf;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetActualInitStep:
+
+ Returns the step size used on the first step
+---------------------------------------------------------------*/
+int ARKodeGetActualInitStep(void *arkode_mem, realtype *hinused)
+{
+  ARKodeMem ark_mem;
+
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetActualInitStep", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *hinused = ark_mem->ark_h0u;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetLastStep:
+
+ Returns the step size used on the last successful step
+---------------------------------------------------------------*/
+int ARKodeGetLastStep(void *arkode_mem, realtype *hlast)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetLastStep", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *hlast = ark_mem->ark_hold;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetCurrentStep:
+
+ Returns the step size to be attempted on the next step
+---------------------------------------------------------------*/
+int ARKodeGetCurrentStep(void *arkode_mem, realtype *hcur)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetCurrentStep", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+  
+  *hcur = ark_mem->ark_next_h;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetCurrentTime:
+
+ Returns the current value of the independent variable
+---------------------------------------------------------------*/
+int ARKodeGetCurrentTime(void *arkode_mem, realtype *tcur)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetCurrentTime", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *tcur = ark_mem->ark_tn;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetCurrentButcherTables:
+
+ Returns the explicit and implicit Butcher tables currently in 
+ use.  The tables should be declared statically as 
+ Ae[ARK_S_MAX*ARK_S_MAX] and Ai[ARK_S_MAX*ARK_S_MAX], and the 
+ arrays c, b and b2 should all have length ARK_S_MAX.
+---------------------------------------------------------------*/
+int ARKodeGetCurrentButcherTables(void *arkode_mem, 
+				  int *s, int *q, int *p,
+				  realtype *Ai, realtype *Ae, 
+				  realtype *ci, realtype *ce, 
+				  realtype *bi, realtype *be,
+				  realtype *b2i, realtype *b2e)
+{
+  int i,j;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetCurrentButcherTables", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *s = ark_mem->ark_stages;
+  *q = ark_mem->ark_q;
+  *p = ark_mem->ark_p;
+  for (i=0; i<ARK_S_MAX; i++) {
+    for (j=0; j<ARK_S_MAX; j++) {
+      ARK_A(Ae,i,j) = ARK_A(ark_mem->ark_Ae,i,j);
+      ARK_A(Ai,i,j) = ARK_A(ark_mem->ark_Ai,i,j);
+    }
+    ce[i]  = ark_mem->ark_ce[i];
+    ci[i]  = ark_mem->ark_ci[i];
+    be[i]  = ark_mem->ark_be[i];
+    bi[i]  = ark_mem->ark_bi[i];
+    b2e[i] = ark_mem->ark_b2e[i];
+    b2i[i] = ark_mem->ark_b2i[i];
+  }
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetTolScaleFactor:
+
+ Returns a suggested factor for scaling tolerances
+---------------------------------------------------------------*/
+int ARKodeGetTolScaleFactor(void *arkode_mem, realtype *tolsfact)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetTolScaleFactor", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *tolsfact = ark_mem->ark_tolsf;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetErrWeights:
+
+ This routine returns the current weight vector.
+---------------------------------------------------------------*/
+int ARKodeGetErrWeights(void *arkode_mem, N_Vector eweight)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetErrWeights", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  N_VScale(ONE, ark_mem->ark_ewt, eweight);
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetEstLocalErrors: (updated to the correct vector, but 
+   need to verify that it is unchanged between filling the 
+   estimated error and the end of the time step)
+
+ Returns an estimate of the local error
+---------------------------------------------------------------*/
+int ARKodeGetEstLocalErrors(void *arkode_mem, N_Vector ele)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetEstLocalErrors", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  N_VScale(ONE, ark_mem->ark_tempv, ele);
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetWorkSpace:
+
+ Returns integrator work space requirements
+---------------------------------------------------------------*/
+int ARKodeGetWorkSpace(void *arkode_mem, long int *lenrw, long int *leniw)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetWorkSpace", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *leniw = ark_mem->ark_liw;
+  *lenrw = ark_mem->ark_lrw;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetIntegratorStats:
+
+ Returns integrator statistics
+---------------------------------------------------------------*/
+int ARKodeGetIntegratorStats(void *arkode_mem, long int *nsteps, 
+			     long int *expsteps, long int *accsteps, 
+			     long int *step_attempts, long int *fe_evals, 
+			     long int *fi_evals, long int *nlinsetups, 
+			     long int *netfails, realtype *hinused, 
+			     realtype *hlast, realtype *hcur, 
+			     realtype *tcur)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetIntegratorStats", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nsteps        = ark_mem->ark_nst;
+  *expsteps      = ark_mem->ark_nst_exp;
+  *accsteps      = ark_mem->ark_nst_acc;
+  *step_attempts = ark_mem->ark_nst_attempts;
+  *fe_evals      = ark_mem->ark_nfe;
+  *fi_evals      = ark_mem->ark_nfi;
+  *nlinsetups    = ark_mem->ark_nsetups;
+  *netfails      = ark_mem->ark_netf;
+  *hinused       = ark_mem->ark_h0u;
+  *hlast         = ark_mem->ark_hold;
+  *hcur          = ark_mem->ark_next_h;
+  *tcur          = ark_mem->ark_tn;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumGEvals:
+
+ Returns the current number of calls to g (for rootfinding)
+---------------------------------------------------------------*/
+int ARKodeGetNumGEvals(void *arkode_mem, long int *ngevals)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumGEvals", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *ngevals = ark_mem->ark_nge;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetRootInfo:
+
+ Returns pointer to array rootsfound showing roots found
+---------------------------------------------------------------*/
+int ARKodeGetRootInfo(void *arkode_mem, int *rootsfound)
+{
+  int i, nrt;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetRootInfo", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  nrt = ark_mem->ark_nrtfn;
+
+  for (i=0; i<nrt; i++) rootsfound[i] = ark_mem->ark_iroots[i];
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumNonlinSolvIters:
+
+ Returns the current number of nonlinear solver iterations 
+---------------------------------------------------------------*/
+int ARKodeGetNumNonlinSolvIters(void *arkode_mem, long int *nniters)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumNonlinSolvIters", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nniters = ark_mem->ark_nni;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNumNonlinSolvConvFails:
+
+ Returns the current number of nonlinear solver convergence fails
+---------------------------------------------------------------*/
+int ARKodeGetNumNonlinSolvConvFails(void *arkode_mem, long int *nncfails)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNumNonlinSolvConvFails", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nncfails = ark_mem->ark_ncfn;
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeGetNonlinSolvStats:
+
+ Returns nonlinear solver statistics
+---------------------------------------------------------------*/
+int ARKodeGetNonlinSolvStats(void *arkode_mem, long int *nniters, 
+			     long int *nncfails)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeGetNonlinSolvStats", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  *nniters = ark_mem->ark_nni;
+  *nncfails = ark_mem->ark_ncfn;
+
+  return(ARK_SUCCESS);
+}
+
+/*-----------------------------------------------------------------*/
+
+char *ARKodeGetReturnFlagName(long int flag)
+{
+  char *name;
+  name = (char *)malloc(24*sizeof(char));
+
+  switch(flag) {
+  case ARK_SUCCESS:
+    sprintf(name,"ARK_SUCCESS");
+    break;
+  case ARK_TSTOP_RETURN:
+    sprintf(name,"ARK_TSTOP_RETURN");
+    break;
+  case ARK_ROOT_RETURN:
+    sprintf(name,"ARK_ROOT_RETURN");
+    break;
+  case ARK_TOO_MUCH_WORK:
+    sprintf(name,"ARK_TOO_MUCH_WORK");
+    break;
+  case ARK_TOO_MUCH_ACC:
+    sprintf(name,"ARK_TOO_MUCH_ACC");
+    break;
+  case ARK_ERR_FAILURE:
+    sprintf(name,"ARK_ERR_FAILURE");
+    break;
+  case ARK_CONV_FAILURE:
+    sprintf(name,"ARK_CONV_FAILURE");
+    break;
+  case ARK_LINIT_FAIL:
+    sprintf(name,"ARK_LINIT_FAIL");
+    break;
+  case ARK_LSETUP_FAIL:
+    sprintf(name,"ARK_LSETUP_FAIL");
+    break;
+  case ARK_LSOLVE_FAIL:
+    sprintf(name,"ARK_LSOLVE_FAIL");
+    break;
+  case ARK_RHSFUNC_FAIL:
+    sprintf(name,"ARK_RHSFUNC_FAIL");
+    break;
+  case ARK_FIRST_RHSFUNC_ERR:
+    sprintf(name,"ARK_FIRST_RHSFUNC_ERR");
+    break;
+  case ARK_REPTD_RHSFUNC_ERR:
+    sprintf(name,"ARK_REPTD_RHSFUNC_ERR");
+    break;
+  case ARK_UNREC_RHSFUNC_ERR:
+    sprintf(name,"ARK_UNREC_RHSFUNC_ERR");
+    break;
+  case ARK_RTFUNC_FAIL:
+    sprintf(name,"ARK_RTFUNC_FAIL");
+    break;
+  case ARK_LFREE_FAIL:
+    sprintf(name,"ARK_LFREE_FAIL");
+    break;
+  case ARK_MASSINIT_FAIL:
+    sprintf(name,"ARK_MASSINIT_FAIL");
+    break;
+  case ARK_MASSSETUP_FAIL:
+    sprintf(name,"ARK_MASSSETUP_FAIL");
+    break;
+  case ARK_MASSSOLVE_FAIL:
+    sprintf(name,"ARK_MASSSOLVE_FAIL");
+    break;
+  case ARK_MASSFREE_FAIL:
+    sprintf(name,"ARK_MASSFREE_FAIL");
+    break;
+  case ARK_MASSMULT_FAIL:
+    sprintf(name,"ARK_MASSMULT_FAIL");
+    break;
+  case ARK_MEM_FAIL:
+    sprintf(name,"ARK_MEM_FAIL");
+    break;
+  case ARK_MEM_NULL:
+    sprintf(name,"ARK_MEM_NULL");
+    break;
+  case ARK_ILL_INPUT:
+    sprintf(name,"ARK_ILL_INPUT");
+    break;
+  case ARK_NO_MALLOC:
+    sprintf(name,"ARK_NO_MALLOC");
+    break;
+  case ARK_BAD_K:
+    sprintf(name,"ARK_BAD_K");
+    break;
+  case ARK_BAD_T:
+    sprintf(name,"ARK_BAD_T");
+    break;
+  case ARK_BAD_DKY:
+    sprintf(name,"ARK_BAD_DKY");
+    break;
+  case ARK_TOO_CLOSE:
+    sprintf(name,"ARK_TOO_CLOSE");
+    break;    
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+
+
+/*===============================================================
+  ARKODE parameter output
+===============================================================*/
+
+/*---------------------------------------------------------------
+ ARKodeWriteParameters:
+
+ Outputs all solver parameters to the provided file pointer.
+---------------------------------------------------------------*/
+int ARKodeWriteParameters(void *arkode_mem, FILE *fp)
+{
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeWriteParameters", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* print integrator parameters to file */
+  fprintf(fp, "ARKode solver parameters:\n");
+  fprintf(fp, "  Method order %i\n",ark_mem->ark_q);
+  fprintf(fp, "  Dense output order %i\n",ark_mem->ark_dense_q);
+  if (ark_mem->ark_linear) {
+    fprintf(fp, "  Linear implicit problem");
+    if (ark_mem->ark_linear_timedep) {
+      fprintf(fp, " (time-dependent Jacobian)\n");
+    } else {
+      fprintf(fp, " (time-independent Jacobian)\n");
+    }
+  }
+  if (ark_mem->ark_explicit) {
+    fprintf(fp, "  Explicit integrator\n");
+  } else if (ark_mem->ark_implicit) {
+    fprintf(fp, "  Implicit integrator\n");
+  } else {
+    fprintf(fp, "  ImEx integrator\n");
+  }
+  if (ark_mem->ark_fixedstep) {
+    fprintf(fp, "  Fixed time-stepping enabled\n");
+  } else {
+    if (ark_mem->ark_hadapt == NULL) {
+      fprintf(fp, "  Time step adaptivity method %i\n", ark_mem->ark_hadapt_imethod);
+      fprintf(fp, "     Safety factor = %g\n", ark_mem->ark_hadapt_safety);
+      fprintf(fp, "     Bias factor = %g\n", ark_mem->ark_hadapt_bias);
+      fprintf(fp, "     Growth factor = %g\n", ark_mem->ark_hadapt_growth);
+      fprintf(fp, "     Step growth lower bound = %g\n", ark_mem->ark_hadapt_lbound);
+      fprintf(fp, "     Step growth upper bound = %g\n", ark_mem->ark_hadapt_ubound);
+      fprintf(fp, "     k1 = %g\n", ark_mem->ark_hadapt_k1);
+      fprintf(fp, "     k2 = %g\n", ark_mem->ark_hadapt_k2);
+      fprintf(fp, "     k3 = %g\n", ark_mem->ark_hadapt_k3);
+    } else {
+      fprintf(fp, "  User provided time step adaptivity function\n");
+    }
+  }
+  if (ark_mem->ark_itol == ARK_WF) {
+    fprintf(fp, "  User provided error weight function\n");
+  } else {
+    fprintf(fp, "  Solver relative tolerance = %g\n", ark_mem->ark_reltol);
+    if (ark_mem->ark_itol == ARK_SS) {
+      fprintf(fp, "  Solver absolute tolerance = %g\n", ark_mem->ark_Sabstol);
+    } else {
+      fprintf(fp, "  Vector-valued solver absolute tolerance\n");
+    }
+  }
+  if (!ark_mem->ark_rwt_is_ewt) {
+    if (ark_mem->ark_ritol == ARK_WF) {
+      fprintf(fp, "  User provided residual weight function\n");
+    } else {
+      if (ark_mem->ark_ritol == ARK_SS) {
+	fprintf(fp, "  Absolute residual tolerance = %g\n", ark_mem->ark_SRabstol);
+      } else {
+	fprintf(fp, "  Vector-valued residual absolute tolerance\n");
+      }
+    }
+  }
+  if (ark_mem->ark_hin != ZERO)  
+    fprintf(fp, "  Initial step size = %g\n",ark_mem->ark_hin);
+  if (ark_mem->ark_hmin != ZERO)  
+    fprintf(fp, "  Minimum step size = %g\n",ark_mem->ark_hmin);
+  if (ark_mem->ark_hmax_inv != ZERO)  
+    fprintf(fp, "  Maximum step size = %g\n",ONE/ark_mem->ark_hmax_inv);
+  fprintf(fp, "  Maximum number of error test failures = %i\n",ark_mem->ark_maxnef);
+  fprintf(fp, "  Maximum number of convergence test failures = %i\n",ark_mem->ark_maxncf);
+  fprintf(fp, "  Maximum step increase (first step) = %g\n",ark_mem->ark_etamx1);
+  fprintf(fp, "  Step reduction factor on multiple error fails = %g\n",ark_mem->ark_etamxf);
+  fprintf(fp, "  Minimum error fails before above factor is used = %i\n",ark_mem->ark_small_nef);
+  fprintf(fp, "  Step reduction factor on nonlinear convergence failure = %g\n",ark_mem->ark_etacf);
+
+  if (!ark_mem->ark_implicit) {
+    if (ark_mem->ark_expstab == arkExpStab) {
+      fprintf(fp, "  Default explicit stability function\n");
+    } else {
+      fprintf(fp, "  User provided explicit stability function\n");
+    }
+    fprintf(fp, "  Explicit safety factor = %g\n",ark_mem->ark_hadapt_cfl);
+  }
+  if (!ark_mem->ark_explicit) {
+    fprintf(fp, "  Implicit predictor method = %i\n",ark_mem->ark_predictor);
+    fprintf(fp, "  Implicit solver tolerance coefficient = %g\n",ark_mem->ark_nlscoef);
+    fprintf(fp, "  Maximum number of nonlinear corrections = %i\n",ark_mem->ark_maxcor);
+    fprintf(fp, "  Nonlinear convergence rate constant = %g\n",ark_mem->ark_crdown);
+    fprintf(fp, "  Nonlinear divergence tolerance = %g\n",ark_mem->ark_rdiv);
+    fprintf(fp, "  Gamma factor LSetup tolerance = %g\n",ark_mem->ark_dgmax);
+    fprintf(fp, "  Number of steps between LSetup calls = %i\n",ark_mem->ark_msbp);
+  }
+  fprintf(fp, "\n");
+
+  return(ARK_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKodeWriteButcher:
+
+ Outputs Butcher tables to the provided file pointer.
+---------------------------------------------------------------*/
+int ARKodeWriteButcher(void *arkode_mem, FILE *fp)
+{
+  int i, j;
+  ARKodeMem ark_mem;
+  if (arkode_mem==NULL) {
+    arkProcessError(NULL, ARK_MEM_NULL, "ARKODE", 
+		    "ARKodeWriteButcher", MSGARK_NO_MEM);
+    return(ARK_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* print Butcher tables to file */
+  fprintf(fp, "\nARKode Butcher tables (stages = %i):\n", ark_mem->ark_stages);
+  if (!ark_mem->ark_implicit) {
+    fprintf(fp, "  Explicit Butcher table:\n");
+    for (i=0; i<ark_mem->ark_stages; i++) {
+      fprintf(fp, "     %.5f",ark_mem->ark_ce[i]);
+      for (j=0; j<ark_mem->ark_stages; j++) 
+	fprintf(fp, " %.5f",ARK_A(ark_mem->ark_Ae,i,j));
+      fprintf(fp,"\n");
+    }
+    fprintf(fp, "            ");
+    for (j=0; j<ark_mem->ark_stages; j++) 
+      fprintf(fp, " %.5f",ark_mem->ark_be[j]);
+    fprintf(fp,"\n");
+    fprintf(fp, "            ");
+    for (j=0; j<ark_mem->ark_stages; j++) 
+      fprintf(fp, " %.5f",ark_mem->ark_b2e[j]);
+    fprintf(fp,"\n");
+  }
+  if (!ark_mem->ark_explicit) {
+    fprintf(fp, "  Implicit Butcher table:\n");
+    for (i=0; i<ark_mem->ark_stages; i++) {
+      fprintf(fp, "     %.5f",ark_mem->ark_ci[i]);
+      for (j=0; j<ark_mem->ark_stages; j++) 
+	fprintf(fp, " %.5f",ARK_A(ark_mem->ark_Ai,i,j));
+      fprintf(fp,"\n");
+    }
+    fprintf(fp, "            ");
+    for (j=0; j<ark_mem->ark_stages; j++) 
+      fprintf(fp, " %.5f",ark_mem->ark_bi[j]);
+    fprintf(fp,"\n");
+    fprintf(fp, "            ");
+    for (j=0; j<ark_mem->ark_stages; j++) 
+      fprintf(fp, " %.5f",ark_mem->ark_b2i[j]);
+    fprintf(fp,"\n");
+  }
+  fprintf(fp, "\n");
+
+  return(ARK_SUCCESS);
+}
+
+
+
+
+/*---------------------------------------------------------------
+      EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_klu.c b/src/arkode/arkode_klu.c
new file mode 100644
index 0000000..5102ac6
--- /dev/null
+++ b/src/arkode/arkode_klu.c
@@ -0,0 +1,1275 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation file for the ARKKLU linear solver module.
+ *---------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode/arkode_klu.h"
+#include "arkode/arkode_sparse.h"
+#include "arkode_sparse_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_klu_impl.h>
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ONE RCONST(1.0)
+#define TWO RCONST(2.0)
+#define TWOTHIRDS    RCONST(0.6666666666666667)
+
+/* ARKKLU linit, lsetup, lsolve, and lfree routines */
+static int arkKLUInit(ARKodeMem ark_mem);
+static int arkKLUSetup(ARKodeMem ark_mem, int convfail, 
+		       N_Vector ypred, N_Vector fpred, 
+		       booleantype *jcurPtr, N_Vector tmp1, 
+		       N_Vector tmp2, N_Vector tmp3);
+static int arkKLUSolve(ARKodeMem ark_mem, N_Vector b, 
+		       N_Vector weight, N_Vector ycur, 
+		       N_Vector fcur);
+static int arkKLUFree(ARKodeMem ark_mem);
+
+/* ARKKLU minit, msetup, msolve, mfree and mtimes routines */
+static int arkMassKLUInit(ARKodeMem ark_mem);
+static int arkMassKLUSetup(ARKodeMem ark_mem, N_Vector tmp1, 
+			   N_Vector tmp2, N_Vector tmp3);
+static int arkMassKLUSolve(ARKodeMem ark_mem, N_Vector b, 
+			   N_Vector weight);
+static int arkMassKLUFree(ARKodeMem ark_mem);
+static int arkMassKLUMultiply(N_Vector v, N_Vector Mv, 
+			      realtype t, void *arkode_mem);
+
+
+/*---------------------------------------------------------------
+ ARKKLU
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the ARKode / KLU linear solver 
+ module.  ARKKLU first calls the existing lfree routine if this 
+ is not NULL.  Then it sets the ark_linit, ark_lsetup, ark_lsolve
+ and ark_lfree fields in (*arkode_mem) to be arkKLUInit, 
+ arkKLUSetup, arkKLUSolve and arkKLUFree, respectively.   It 
+ allocates memory for a structure of type ARKSlsMemRec and sets 
+ the ark_lmem field in (*arkode_mem) to the address of this 
+ structure.  It sets setupNonNull in (*arkode_mem) to TRUE.  
+ Finally, it allocates memory for KLU.  The return value is 
+ ARKSLS_SUCCESS = 0, ARKSLS_LMEM_FAIL = -1, or 
+ ARKSLS_ILL_INPUT = -2.
+
+ NOTE: The KLU linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKKLU will first 
+       test for a compatible N_Vector internal representation
+       by checking that the function N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+int ARKKLU(void *arkode_mem, int n, int nnz, int sparsetype)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+  KLUData klu_data;
+  int flag;
+
+  /* Return immediately if ark_mem is NULL. */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+                    "ARKKLU", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKSLS_ILL_INPUT, "ARKSLS", 
+                    "ARKKLU", MSGSP_BAD_NVECTOR);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem. */
+  ark_mem->ark_linit  = arkKLUInit;
+  ark_mem->ark_lsetup = arkKLUSetup;
+  ark_mem->ark_lsolve = arkKLUSolve;
+  ark_mem->ark_lfree  = arkKLUFree;
+  ark_mem->ark_lsolve_type = 3;
+
+  /* Get memory for ARKSlsMemRec. */
+  arksls_mem = (ARKSlsMem) malloc(sizeof(struct ARKSlsMemRec));
+  if (arksls_mem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKKLU", MSGSP_MEM_FAIL);
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Get memory for KLUData. */
+  klu_data = (KLUData) malloc(sizeof(struct KLUDataRec));
+  if (klu_data == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKKLU", MSGSP_MEM_FAIL);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Initialize Jacobian-related data */
+  arksls_mem->s_Jeval = NULL;
+  arksls_mem->s_Jdata = NULL;
+  ark_mem->ark_setupNonNull = TRUE;
+  arksls_mem->sparsetype = sparsetype;
+
+  /* Initialize counters */
+  arksls_mem->s_nje = 0;
+  arksls_mem->s_first_factorize = 1;
+  arksls_mem->s_nstlj = 0;
+
+  /* Allocate memory for the sparse Jacobian */
+  arksls_mem->s_A = NULL;
+  arksls_mem->s_A = SparseNewMat(n, n, nnz, sparsetype);
+  if (arksls_mem->s_A == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKKLU", MSGSP_MEM_FAIL);
+    free(klu_data); klu_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Allocate memory for saved sparse Jacobian */
+  arksls_mem->s_savedJ = NULL;
+  arksls_mem->s_savedJ = SparseNewMat(n, n, nnz, sparsetype);
+  if (arksls_mem->s_savedJ == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKKLU", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_A);
+    free(klu_data); klu_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Initialize KLU structures */
+  switch (sparsetype) {
+    case CSC_MAT:
+      klu_data->sun_klu_solve = &klu_solve;
+      break;
+    case CSR_MAT:
+      klu_data->sun_klu_solve = &klu_tsolve;
+      break;
+    default:
+      SparseDestroyMat(arksls_mem->s_A);
+      SparseDestroyMat(arksls_mem->s_savedJ);
+      free(klu_data); klu_data = NULL;
+      free(arksls_mem); arksls_mem = NULL;
+      return(ARKSLS_ILL_INPUT);
+  }
+  klu_data->s_Symbolic = NULL;
+  klu_data->s_Numeric = NULL;
+
+  /* Set default parameters for KLU */
+  flag = klu_defaults(&klu_data->s_Common);
+  if (flag == 0) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKKLU", MSGSP_MEM_FAIL);
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    free(klu_data->s_Numeric);  klu_data->s_Numeric = NULL;
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    free(klu_data->s_Symbolic);  klu_data->s_Symbolic = NULL;
+    SparseDestroyMat(arksls_mem->s_A);
+    SparseDestroyMat(arksls_mem->s_savedJ);
+    free(klu_data); klu_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Set ordering to COLAMD as the arkode default use.
+     Users can set a different value with ARKKLUSetOrdering,
+     and the user-set value is loaded before any call to klu_analyze in
+     ARKKLUSetup.  */
+  klu_data->s_ordering = 1;
+  klu_data->s_Common.ordering = klu_data->s_ordering;
+
+  /* Attach linear solver memory to the integrator memory */
+  arksls_mem->s_solver_data = (void *) klu_data;
+  ark_mem->ark_lmem = arksls_mem;
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+  ARKKLUReInit
+
+  This routine reinitializes memory and flags for a new 
+  factorization (symbolic and numeric) to be conducted at the 
+  next solver setup call.  This routine is useful in the cases 
+  where the number of nonzeroes has changed or if the structure 
+  of the linear system has changed which would require a new 
+  symbolic (and numeric) factorization.
+ 
+  The reinit_type argument governs the level of reinitialization:
+ 
+  reinit_type = 1: The Jacobian matrix will be destroyed and 
+                   a new one will be allocated based on the nnz
+                   value passed to this call. New symbolic and
+                   numeric factorizations will be completed at the 
+                   next solver setup.
+ 
+  reinit_type = 2: Only symbolic and numeric factorizations will be 
+                   completed.  It is assumed that the Jacobian size
+                   has not exceeded the size of nnz given in the 
+                   prior call to ARKMassKLU.
+ 
+  This routine assumes no other changes to solver use are necessary.
+ 
+  The return value is ARKSLS_SUCCESS = 0, ARKSLS_MEM_NULL = -1, 
+  ARKSLS_MASSMEM_NULL = -8, ARKSLS_ILL_INPUT = -3, or 
+  ARKSLS_MEM_FAIL = -4.
+---------------------------------------------------------------*/
+int ARKKLUReInit(void *arkode_mem, int n, int nnz, int reinit_type)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if arkode_mem is NULL. */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", "ARKKLUReInit", 
+		    MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Return immediately if ark_lmem is NULL. */
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(NULL, ARKSLS_LMEM_NULL, "ARKSLS", "ARKKLUReInit", 
+		    MSGSP_LMEM_NULL);
+    return(ARKSLS_LMEM_NULL);
+  }
+
+  arksls_mem = (ARKSlsMem) (ark_mem->ark_lmem);
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  /* Return if reinit_type is not valid */
+  if ((reinit_type != 1) && (reinit_type != 2)) {
+    arkProcessError(NULL, ARKSLS_ILL_INPUT, "ARKSLS", "ARKKLUReInit", 
+		    MSGSP_ILL_INPUT);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  if (reinit_type == 1) {
+
+    /* Destroy previous Jacobian information */
+    if (arksls_mem->s_A) {
+      SparseDestroyMat(arksls_mem->s_A);
+    }
+
+    /* Allocate memory for the sparse Jacobian */
+    arksls_mem->s_A = SparseNewMat(n, n, nnz, arksls_mem->sparsetype);
+    if (arksls_mem->s_A == NULL) {
+      arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", "ARKKLU", 
+		    MSGSP_MEM_FAIL);
+      return(ARKSLS_MEM_FAIL);
+    }
+  }
+
+  /* Free the prior factorazation and reset for first factorization */
+  if( klu_data->s_Symbolic != NULL)
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  if( klu_data->s_Numeric != NULL)
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  arksls_mem->s_first_factorize = 1;
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+
+  return(0);
+}
+
+/*---------------------------------------------------------------
+ arkKLUInit:
+
+ This routine does remaining initializations specific to the 
+ ARKKLU linear solver module.  It returns 0 if successful.
+---------------------------------------------------------------*/
+static int arkKLUInit(ARKodeMem ark_mem)
+{
+  ARKSlsMem arksls_mem;
+
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+
+  arksls_mem->s_Jdata = ark_mem->ark_user_data;
+
+  arksls_mem->s_nje = 0;
+  /* Force factorization every call to ARKODE */
+  arksls_mem->s_first_factorize = 1;
+  arksls_mem->s_nstlj = 0;
+
+  arksls_mem->s_last_flag = 0;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkKLUSetup:
+
+  This routine does the setup operations for the ARKKLU linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     ARKSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+---------------------------------------------------------------*/
+static int arkKLUSetup(ARKodeMem ark_mem, int convfail, 
+		       N_Vector ypred, N_Vector fpred, 
+		       booleantype *jcurPtr, N_Vector vtemp1, 
+		       N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma;
+  ARKSlsMem arksls_mem;
+  ARKSlsMassMem arksls_mass_mem;
+  KLUData klu_data;
+  int retval;
+
+  realtype uround_twothirds;
+  
+  uround_twothirds = SUNRpowerR(ark_mem->ark_uround,TWOTHIRDS);
+
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+  
+  /* Check that Jacobian eval routine is set */
+  if (arksls_mem->s_Jeval == NULL) {
+    arkProcessError(ark_mem, ARKSLS_JAC_NOSET, "ARKSLS", 
+		    "arkKLUSetup", MSGSP_JAC_NOSET);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_JAC_NOSET);
+  }
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arksls_mem->s_nstlj + ARKS_MSBJ) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKS_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  jok = !jbad;
+  
+  /* If jok = TRUE, use saved copy of J */
+  if (jok) {
+    *jcurPtr = FALSE;
+    SparseCopyMat(arksls_mem->s_savedJ, arksls_mem->s_A);
+
+  /* If jok = FALSE, call jac routine for new J value */
+  } else {
+    arksls_mem->s_nje++;
+    arksls_mem->s_nstlj = ark_mem->ark_nst;
+    *jcurPtr = TRUE;
+    SparseSetMatToZero(arksls_mem->s_A);
+
+    retval = arksls_mem->s_Jeval(ark_mem->ark_tn, ypred, fpred, 
+				 arksls_mem->s_A, arksls_mem->s_Jdata, 
+				 vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKSLS_JACFUNC_UNRECVR, "ARKSLS", 
+		      "arkKLUSetup", MSGSP_JACFUNC_FAILED);
+      arksls_mem->s_last_flag = ARKSLS_JACFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arksls_mem->s_last_flag = ARKSLS_JACFUNC_RECVR;
+      return(1);
+    }
+
+    SparseCopyMat(arksls_mem->s_A, arksls_mem->s_savedJ);
+  }
+
+  /* Scale J by -gamma */
+  SparseScaleMat(-ark_mem->ark_gamma, arksls_mem->s_A);
+
+  /* Add mass matrix to get A = M-gamma*J */
+  if (ark_mem->ark_mass_matrix) {
+
+    /* Compute mass matrix */
+    arksls_mass_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+    SparseSetMatToZero(arksls_mass_mem->s_M);
+    retval = arksls_mass_mem->s_Meval(ark_mem->ark_tn, 
+				      arksls_mass_mem->s_M, 
+				      arksls_mass_mem->s_Mdata, 
+				      vtemp1, vtemp2, vtemp3);
+    arksls_mass_mem->s_nme++;
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKSLS_MASSFUNC_UNRECVR, "ARKSLS", 
+		      "arkKLUSetup",  MSGSP_MASSFUNC_FAILED);
+      arksls_mem->s_last_flag = ARKSLS_MASSFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arksls_mem->s_last_flag = ARKSLS_MASSFUNC_RECVR;
+      return(1);
+    }
+    
+    /* add to A */
+    retval = SparseAddMat(arksls_mem->s_A, arksls_mass_mem->s_M);
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "arkKLUSetup",  "Error in adding mass matrix to Jacobian");
+      arksls_mem->s_last_flag = ARKSLS_PACKAGE_FAIL;
+      return(retval);
+    }
+    if (retval > 0)  return(retval);
+    
+  } else {
+    SparseAddIdentityMat(arksls_mem->s_A);
+  }
+
+
+  /* On first decomposition, get the symbolic factorization */ 
+  if (arksls_mem->s_first_factorize) {
+
+    /* Update the ordering option with user-updated values */
+    klu_data->s_Common.ordering = klu_data->s_ordering;
+
+    /* Perform symbolic analysis of sparsity structure */
+    if (klu_data->s_Symbolic != NULL) {
+       klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    }
+    klu_data->s_Symbolic = klu_analyze(arksls_mem->s_A->NP, 
+				       arksls_mem->s_A->indexptrs, 
+				       arksls_mem->s_A->indexvals, 
+				       &(klu_data->s_Common));
+    if (klu_data->s_Symbolic == NULL) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+
+    /* ------------------------------------------------------------
+       Compute the LU factorization of  the Jacobian.
+       ------------------------------------------------------------*/
+    if( klu_data->s_Numeric != NULL) {
+       klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    }
+    klu_data->s_Numeric = klu_factor(arksls_mem->s_A->indexptrs, 
+				     arksls_mem->s_A->indexvals, 
+				     arksls_mem->s_A->data, 
+				     klu_data->s_Symbolic, 
+				     &(klu_data->s_Common));
+    if (klu_data->s_Numeric == NULL) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+
+    arksls_mem->s_first_factorize = 0;
+  }
+  else {
+
+    retval = klu_refactor(arksls_mem->s_A->indexptrs, 
+			  arksls_mem->s_A->indexvals, 
+			  arksls_mem->s_A->data, 
+			  klu_data->s_Symbolic, klu_data->s_Numeric,
+			  &(klu_data->s_Common));
+    if (retval == 0) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+    
+    /*-----------------------------------------------------------
+      Check if a cheap estimate of the reciprocal of the condition 
+      number is getting too small.  If so, delete
+      the prior numeric factorization and recompute it.
+      -----------------------------------------------------------*/
+    
+    retval = klu_rcond(klu_data->s_Symbolic, klu_data->s_Numeric,
+		       &(klu_data->s_Common));
+    if (retval == 0) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+
+    if ( (klu_data->s_Common.rcond)  < uround_twothirds ) {
+      
+      /* Condition number may be getting large.  
+	 Compute more accurate estimate */
+      retval = klu_condest(arksls_mem->s_A->indexptrs, 
+			   arksls_mem->s_A->data, 
+			   klu_data->s_Symbolic, klu_data->s_Numeric,
+			   &(klu_data->s_Common));
+      if (retval == 0) {
+	arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+			"ARKKLUSetup", MSGSP_PACKAGE_FAIL);
+	return(ARKSLS_PACKAGE_FAIL);
+      }
+      
+      if ( (klu_data->s_Common.condest) > 
+	   (1.0/uround_twothirds) ) {
+
+	/* More accurate estimate also says condition number is 
+	   large, so recompute the numeric factorization */
+
+	klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+	
+	klu_data->s_Numeric = klu_factor(arksls_mem->s_A->indexptrs, 
+					 arksls_mem->s_A->indexvals, 
+					 arksls_mem->s_A->data,
+					 klu_data->s_Symbolic, 
+					 &(klu_data->s_Common));
+
+	if (klu_data->s_Numeric == NULL) {
+	  arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+			  "ARKKLUSetup", MSGSP_PACKAGE_FAIL);
+	  return(ARKSLS_PACKAGE_FAIL);
+	}
+      }
+    }
+  }
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkKLUSolve:
+
+ This routine handles the solve operation for the ARKKLU linear
+ solver module.  It calls the KLU solve routine, then returns 
+ ARKSLS_SUCCESS = 0.
+---------------------------------------------------------------*/
+static int arkKLUSolve(ARKodeMem ark_mem, N_Vector b, 
+		       N_Vector weight, N_Vector ycur, 
+		       N_Vector fcur)
+{
+  int flag;
+  ARKSlsMem arksls_mem;
+  KLUData klu_data;
+  realtype *bd;
+  
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  bd = N_VGetArrayPointer(b);
+
+  /* Call KLU to solve the linear system */
+  flag = klu_data->sun_klu_solve(klu_data->s_Symbolic, klu_data->s_Numeric, 
+                                 arksls_mem->s_A->NP, 1, bd, 
+                                 &(klu_data->s_Common));
+  if (flag == 0) {
+    arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		    "ARKKLUSolve", MSGSP_PACKAGE_FAIL);
+    return(ARKSLS_PACKAGE_FAIL);
+  }
+
+  /* Scale the correction to account for change in gamma. */
+  if (ark_mem->ark_gamrat != ONE)
+    N_VScale(TWO/(ONE + ark_mem->ark_gamrat), b, b);
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkKLUFree:
+
+ This routine frees memory specific to the ARKKLU linear solver.
+---------------------------------------------------------------*/
+static int arkKLUFree(ARKodeMem ark_mem)
+{
+  ARKSlsMem arksls_mem;
+  KLUData klu_data;
+  
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  if( klu_data->s_Numeric != NULL)
+  {
+     klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  }
+  if( klu_data->s_Symbolic != NULL)
+  {
+     klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  }
+
+  if (arksls_mem->s_A) {
+    SparseDestroyMat(arksls_mem->s_A);
+    arksls_mem->s_A = NULL;
+  }
+
+  if (arksls_mem->s_savedJ) {
+    SparseDestroyMat(arksls_mem->s_savedJ);
+    arksls_mem->s_savedJ = NULL;
+  }
+
+  free(klu_data); 
+  free(arksls_mem); 
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+/*---------------------------------------------------------------
+ ARKMassKLU
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the ARKode / KLU mass matrix linear 
+ solver module.  ARKMassKLU first calls the existing mfree 
+ routine if this is not NULL.  Then it sets the ark_minit, 
+ ark_msetup, ark_msolve and ark_mfree fields in (*arkode_mem) 
+ to be arkMassKLUInit, arkMassKLUSetup, arkMassKLUSolve and 
+ arkMassKLUFree, respectively.   It allocates memory for a 
+ structure of type ARKSlsMassMemRec and sets the ark_mass_mem 
+ field in (*arkode_mem) to the address of this structure.  It 
+ sets MassSetupNonNull in (*arkode_mem) to TRUE.  Finally, it 
+ allocates memory for KLU.  The return value is 
+ ARKSLS_SUCCESS = 0, ARKSLS_LMEM_FAIL = -1, or 
+ ARKSLS_ILL_INPUT = -2.
+
+ NOTE: The KLU linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKMassKLU will first 
+       test for a compatible N_Vector internal representation
+       by checking that the function N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+int ARKMassKLU(void *arkode_mem, int n, int nnz, int sparsetype, 
+               ARKSlsSparseMassFn smass)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+  KLUData klu_data;
+  int flag;
+
+  /* Return immediately if arkode_mem is NULL. */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+                    "ARKMassKLU", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKSLS_ILL_INPUT, "ARKSLS", 
+                    "ARKMassKLU", MSGSP_BAD_NVECTOR);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set five main function fields in ark_mem, enable mass matrix. */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = arkMassKLUInit;
+  ark_mem->ark_msetup = arkMassKLUSetup;
+  ark_mem->ark_msolve = arkMassKLUSolve;
+  ark_mem->ark_mfree  = arkMassKLUFree;
+  ark_mem->ark_mtimes = arkMassKLUMultiply;
+  ark_mem->ark_mtimes_data = (void *) ark_mem;
+  ark_mem->ark_msolve_type = 3;
+
+  /* Get memory for ARKSlsMassMemRec. */
+  arksls_mem = (ARKSlsMassMem) malloc(sizeof(struct ARKSlsMassMemRec));
+  if (arksls_mem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKMassKLU", MSGSP_MEM_FAIL);
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Get memory for KLUData. */
+  klu_data = (KLUData) malloc(sizeof(struct KLUDataRec));
+  if (klu_data == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKMassKLU", MSGSP_MEM_FAIL);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Initialize mass-matrix-related data */
+  arksls_mem->s_nme = 0;
+  arksls_mem->s_first_factorize = 1;
+  arksls_mem->s_Meval = smass;
+  arksls_mem->s_Mdata = ark_mem->ark_user_data;
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = TRUE;
+  arksls_mem->sparsetype = sparsetype;
+
+  /* Allocate memory for M and M_lu */
+  arksls_mem->s_M = NULL;
+  arksls_mem->s_M = SparseNewMat(n, n, nnz, sparsetype);
+  if (arksls_mem->s_M == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKMassKLU", MSGSP_MEM_FAIL);
+    free(klu_data); klu_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+  arksls_mem->s_M_lu = NULL;
+  arksls_mem->s_M_lu = SparseNewMat(n, n, nnz, sparsetype);
+  if (arksls_mem->s_M_lu == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKMassKLU", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_M);
+    free(klu_data); klu_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Initialize KLU structures */
+  switch (sparsetype) {
+    case CSC_MAT:
+      klu_data->sun_klu_solve = &klu_solve;
+      break;
+    case CSR_MAT:
+      klu_data->sun_klu_solve = &klu_tsolve;
+      break;
+    default:
+      SparseDestroyMat(arksls_mem->s_M);
+      SparseDestroyMat(arksls_mem->s_M_lu);
+      free(klu_data); klu_data = NULL;
+      free(arksls_mem); arksls_mem = NULL;
+      return(ARKSLS_ILL_INPUT);
+  }
+  klu_data->s_Symbolic = NULL;
+  klu_data->s_Numeric = NULL;
+
+  /* Set default parameters for KLU */
+  flag = klu_defaults(&klu_data->s_Common);
+  if (flag == 0) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+                    "ARKMassKLU", MSGSP_MEM_FAIL);
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    free(klu_data->s_Numeric);  klu_data->s_Numeric = NULL;
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    free(klu_data->s_Symbolic);  klu_data->s_Symbolic = NULL;
+    SparseDestroyMat(arksls_mem->s_M);
+    SparseDestroyMat(arksls_mem->s_M_lu);
+    free(klu_data); klu_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Set ordering to COLAMD as the arkode default use.
+     Users can set a different value with ARKMassKLUSetOrdering,
+     and the user-set value is loaded before any call to klu_analyze in
+     ARKMassKLUSetup.  */
+  klu_data->s_ordering = 1;
+  klu_data->s_Common.ordering = klu_data->s_ordering;
+
+  /* Attach linear solver memory to the integrator memory */
+  arksls_mem->s_solver_data = (void *) klu_data;
+  ark_mem->ark_mass_mem = arksls_mem;
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+  ARKMassKLUReInit
+
+  This routine reinitializes memory and flags for a new 
+  factorization (symbolic and numeric) to be conducted at the 
+  next solver setup call.  This routine is useful in the cases 
+  where the number of nonzeroes has changed or if the structure 
+  of the linear system has changed which would require a new 
+  symbolic (and numeric) factorization.
+ 
+  The reinit_type argument governs the level of reinitialization:
+ 
+  reinit_type = 1: The mass matrix will be destroyed and 
+                   a new one will be allocated based on the nnz
+                   value passed to this call. New symbolic and
+                   numeric factorizations will be completed at the 
+                   next solver setup.
+ 
+  reinit_type = 2: Only symbolic and numeric factorizations will be 
+                   completed.  It is assumed that the mass matrix
+                   size has not exceeded the size of nnz given in 
+                   the prior call to ARKMassKLU.
+ 
+  This routine assumes no other changes to solver use are necessary.
+ 
+  The return value is ARKSLS_SUCCESS = 0, ARKSLS_MEM_NULL = -1, 
+  ARKSLS_MASSMEM_NULL = -8, ARKSLS_ILL_INPUT = -3, or 
+  ARKSLS_MEM_FAIL = -4.
+---------------------------------------------------------------*/
+int ARKMassKLUReInit(void *arkode_mem, int n, int nnz, int reinit_type)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if arkode_mem is NULL. */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", "ARKMassKLUReInit", 
+		    MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Return immediately if ark_lmem is NULL. */
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MASSMEM_NULL, "ARKSLS", "ARKMassKLUReInit", 
+		    MSGSP_MASSMEM_NULL);
+    return(ARKSLS_MASSMEM_NULL);
+  }
+
+  arksls_mem = (ARKSlsMassMem) (ark_mem->ark_mass_mem);
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  /* Return if reinit_type is not valid */
+  if ((reinit_type != 1) && (reinit_type != 2)) {
+    arkProcessError(NULL, ARKSLS_ILL_INPUT, "ARKSLS", "ARKMassKLUReInit", 
+		    MSGSP_ILL_INPUT);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  if (reinit_type == 1) {
+
+    /* Destroy previous Jacobian information */
+    if (arksls_mem->s_M) {
+      SparseDestroyMat(arksls_mem->s_M);
+    }
+
+    /* Allocate memory for the sparse Jacobian */
+    arksls_mem->s_M = SparseNewMat(n, n, nnz, arksls_mem->sparsetype);
+    if (arksls_mem->s_M == NULL) {
+      arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", "ARKMassKLU", 
+		    MSGSP_MEM_FAIL);
+      return(ARKSLS_MEM_FAIL);
+    }
+  }
+
+  /* Free the prior factorazation and reset for first factorization */
+  if( klu_data->s_Symbolic != NULL)
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  if( klu_data->s_Numeric != NULL)
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  arksls_mem->s_first_factorize = 1;
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+
+  return(0);
+}
+
+/*---------------------------------------------------------------
+ arkMassKLUInit:
+
+ This routine does remaining initializations specific to the 
+ ARKKLU mass matrix linear solver module.  It returns 0 if 
+ successful.
+---------------------------------------------------------------*/
+static int arkMassKLUInit(ARKodeMem ark_mem)
+{
+  ARKSlsMassMem arksls_mem;
+
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  arksls_mem->s_nme = 0;
+  arksls_mem->s_first_factorize = 1;
+
+  arksls_mem->s_Mdata = ark_mem->ark_user_data;
+
+  /* Set mass matrix function data */
+  arksls_mem->s_Mdata = ark_mem->ark_user_data;
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassKLUSetup:
+
+  This routine does the setup operations for the ARKMassKLU 
+  linear solver module.  It calls the mass matrix evaluation 
+  routine, updates counters, and calls the LU factorization 
+  routine.  The return value is either
+     ARkSLS_SUCCESS = 0  if successful,
+     +1  if the Meval routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the Meval routine failed unrecoverably.
+---------------------------------------------------------------*/
+static int arkMassKLUSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			   N_Vector vtemp2, N_Vector vtemp3)
+{
+  ARKSlsMassMem arksls_mem;
+  KLUData klu_data;
+  int retval;
+  
+  realtype uround_twothirds;
+  
+  uround_twothirds = SUNRpowerR(ark_mem->ark_uround,TWOTHIRDS);
+
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+  
+  /* Check that mass matrix eval routine is set */
+  if (arksls_mem->s_Meval == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MASS_NOSET, "ARKSLS", 
+		    "arkMassKLUSetup", MSGSP_MASS_NOSET);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MASS_NOSET);
+  }
+
+  /* call Meval routine for new M matrix */
+  SparseSetMatToZero(arksls_mem->s_M);
+  retval = arksls_mem->s_Meval(ark_mem->ark_tn, arksls_mem->s_M, 
+			       arksls_mem->s_Mdata, vtemp1, 
+			       vtemp2, vtemp3);
+  arksls_mem->s_nme++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, ARKSLS_MASSFUNC_UNRECVR, "ARKSLS", 
+		    "arkMassKLUSetup", MSGSP_MASSFUNC_FAILED);
+    arksls_mem->s_last_flag = ARKSLS_MASSFUNC_UNRECVR;
+    return(-1);
+  }
+  if (retval > 0) {
+    arksls_mem->s_last_flag = ARKSLS_MASSFUNC_RECVR;
+    return(1);
+  }
+
+  /* Copy M into M_lu for LU decomposition */
+  SparseCopyMat(arksls_mem->s_M, arksls_mem->s_M_lu);
+
+  /* On first decomposition, get the symbolic factorization */ 
+  if (arksls_mem->s_first_factorize) {
+
+    /* Update the ordering option with user-updated values */
+    klu_data->s_Common.ordering = klu_data->s_ordering;
+
+    /* Perform symbolic analysis of sparsity structure */
+    if (klu_data->s_Symbolic != NULL) {
+       klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    }
+    klu_data->s_Symbolic = klu_analyze(arksls_mem->s_M_lu->N, 
+                                       arksls_mem->s_M_lu->indexptrs, 
+				       arksls_mem->s_M_lu->indexvals, 
+				       &(klu_data->s_Common));
+    if (klu_data->s_Symbolic == NULL) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKMassKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+
+    /* ------------------------------------------------------------
+       Compute the LU factorization of  the Jacobian.
+       ------------------------------------------------------------*/
+    if( klu_data->s_Numeric != NULL) {
+       klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    }
+    klu_data->s_Numeric = klu_factor(arksls_mem->s_M_lu->indexptrs, 
+				     arksls_mem->s_M_lu->indexvals, 
+				     arksls_mem->s_M_lu->data, 
+				     klu_data->s_Symbolic, 
+				     &(klu_data->s_Common));
+    if (klu_data->s_Numeric == NULL) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKMassKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+    
+    arksls_mem->s_first_factorize = 0;
+  }
+  else {
+
+    retval = klu_refactor(arksls_mem->s_M_lu->indexptrs, 
+			  arksls_mem->s_M_lu->indexvals, 
+			  arksls_mem->s_M_lu->data,
+			  klu_data->s_Symbolic, klu_data->s_Numeric,
+			  &(klu_data->s_Common));
+    if (retval == 0) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKMassKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+    
+    /*-----------------------------------------------------------
+      Check if a cheap estimate of the reciprocal of the condition 
+      number is getting too small.  If so, delete
+      the prior numeric factorization and recompute it.
+      -----------------------------------------------------------*/
+    
+    retval = klu_rcond(klu_data->s_Symbolic, klu_data->s_Numeric,
+		       &(klu_data->s_Common));
+    if (retval == 0) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "ARKMassKLUSetup", MSGSP_PACKAGE_FAIL);
+      return(ARKSLS_PACKAGE_FAIL);
+    }
+
+    if ( (klu_data->s_Common.rcond)  < uround_twothirds ) {
+      
+      /* Condition number may be getting large.  
+	 Compute more accurate estimate */
+      retval = klu_condest(arksls_mem->s_M_lu->indexptrs, 
+			   arksls_mem->s_M_lu->data,
+			   klu_data->s_Symbolic, klu_data->s_Numeric,
+			   &(klu_data->s_Common));
+      if (retval == 0) {
+	arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+			"ARKMassKLUSetup", MSGSP_PACKAGE_FAIL);
+	return(ARKSLS_PACKAGE_FAIL);
+      }
+      
+      if ( (klu_data->s_Common.condest) > 
+	   (1.0/uround_twothirds) ) {
+
+	/* More accurate estimate also says condition number is 
+	   large, so recompute the numeric factorization */
+
+	klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+	
+	klu_data->s_Numeric = klu_factor(arksls_mem->s_M_lu->indexptrs, 
+					 arksls_mem->s_M_lu->indexvals, 
+					 arksls_mem->s_M_lu->data, 
+					 klu_data->s_Symbolic, 
+					 &(klu_data->s_Common));
+
+	if (klu_data->s_Numeric == NULL) {
+	  arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+			  "ARKMassKLUSetup", MSGSP_PACKAGE_FAIL);
+	  return(ARKSLS_PACKAGE_FAIL);
+	}
+      }
+    }
+  }
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassKLUSolve:
+
+  This routine handles the solve operation for the ARKKLU mass 
+  matrix linear solver module.  It calls the KLU solve routine, 
+  then returns ARKSLS_SUCCESS = 0.
+---------------------------------------------------------------*/
+static int arkMassKLUSolve(ARKodeMem ark_mem, N_Vector b, 
+			   N_Vector weight)
+{
+  int flag;
+  ARKSlsMassMem arksls_mem;
+  KLUData klu_data;
+  realtype *bd;
+  
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  bd = N_VGetArrayPointer(b);
+
+  /* Call KLU to solve the linear system */
+  flag = klu_data->sun_klu_solve(klu_data->s_Symbolic, klu_data->s_Numeric, 
+                                 arksls_mem->s_M_lu->NP, 1, bd, 
+                                 &(klu_data->s_Common));
+  if (flag == 0) {
+    arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		    "ARKMassKLUSolve", MSGSP_PACKAGE_FAIL);
+    return(ARKSLS_PACKAGE_FAIL);
+  }
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassKLUFree:
+
+ This routine frees memory specific to the ARKMassKLU mass 
+ matrix linear solver.
+---------------------------------------------------------------*/
+static int arkMassKLUFree(ARKodeMem ark_mem)
+{
+  ARKSlsMassMem arksls_mem;
+  KLUData klu_data;
+  
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  if( klu_data->s_Numeric != NULL)
+  {
+     klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  }
+  if( klu_data->s_Symbolic != NULL)
+  {
+     klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  }
+
+  if (arksls_mem->s_M) {
+    SparseDestroyMat(arksls_mem->s_M);
+    arksls_mem->s_M = NULL;
+  }
+
+  if (arksls_mem->s_M_lu) {
+    SparseDestroyMat(arksls_mem->s_M_lu);
+    arksls_mem->s_M_lu = NULL;
+  }
+
+  free(klu_data); 
+  free(arksls_mem); 
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+/*===============================================================
+ Utility Functions
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkMassKLUMultiply:
+
+ Multiplies the mass matrix by the vector v to fill in the 
+ vector Mv.
+---------------------------------------------------------------*/
+static int arkMassKLUMultiply(N_Vector v, N_Vector Mv, 
+			      realtype t, void *arkode_mem)
+{
+
+  /* extract the SlsMassMem structure from the arkode_mem pointer */
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+  realtype *vdata=NULL, *Mvdata=NULL;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "arkMassKLUMultiply", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+
+  /* zero out the result */
+  N_VConst(0.0, Mv);
+
+  /* access the vector arrays (since they must be serial vectors) */
+  vdata = N_VGetArrayPointer(v);
+  Mvdata = N_VGetArrayPointer(Mv);
+  if (vdata == NULL || Mvdata == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "arkMassKLLUMultiply", 
+		    "Vector data un-allocated.");
+    return(ARKSLS_MEM_NULL);
+  }
+
+  /* perform matrix-vector product with arksls_mem->s_M and return */
+  if (SparseMatvec(arksls_mem->s_M, vdata, Mvdata) != 0) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "arkMassKLUMultiply", 
+		    "Mass matrix data un-allocated.");
+    return(ARKSLS_MEM_NULL);
+  }
+
+  return(0);
+
+}
+
+
+/*===============================================================
+ Optional Input Specification Functions
+===============================================================*/
+
+
+/*---------------------------------------------------------------
+ ARKKLUSetOrdering:
+
+ Sets the ordering used by KLU for reducing fill.  Options are: 
+     0 for AMD, 
+     1 for COLAMD, and 
+     2 for the natural ordering.  
+ The default used is 1 (COLAMD).
+---------------------------------------------------------------*/
+int ARKKLUSetOrdering(void *arkode_mem, int ordering_choice)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if ark_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKKLUSetOrdering", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) ) {
+    arkProcessError(NULL, ARKSLS_ILL_INPUT, "ARKSLS", 
+		    "ARKKLUSetOrdering", MSGSP_ILL_INPUT);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  klu_data->s_ordering = ordering_choice;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassKLUSetOrdering:
+
+ Sets the ordering used by KLU for reducing fill.  Options are: 
+     0 for AMD, 
+     1 for COLAMD, and 
+     2 for the natural ordering.  
+ The default used is 1 (COLAMD).
+---------------------------------------------------------------*/
+int ARKMassKLUSetOrdering(void *arkode_mem, int ordering_choice)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if ark_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKKLUSetOrdering", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) ) {
+    arkProcessError(NULL, ARKSLS_ILL_INPUT, "ARKSLS", 
+		    "ARKKLUSetOrdering", MSGSP_ILL_INPUT);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  klu_data = (KLUData) arksls_mem->s_solver_data;
+
+  klu_data->s_ordering = ordering_choice;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+   EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_lapack.c b/src/arkode/arkode_lapack.c
new file mode 100644
index 0000000..ae7ce31
--- /dev/null
+++ b/src/arkode/arkode_lapack.c
@@ -0,0 +1,1270 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for a ARKODE dense linear solver
+ * using BLAS and LAPACK functions.
+ *--------------------------------------------------------------*/
+
+/* NOTE: the only operation that does not use Blas/Lapack functions
+   is matrix plus mass matrix (in calculating M-gamma*J in lsetup) */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_lapack.h>
+#include "arkode_direct_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+
+/*===============================================================
+ PROTOTYPES FOR PRIVATE FUNCTIONS
+===============================================================*/
+
+/* ARKLAPACK DENSE linit, lsetup, lsolve, and lfree routines */ 
+static int arkLapackDenseInit(ARKodeMem ark_mem);
+static int arkLapackDenseSetup(ARKodeMem ark_mem, int convfail, 
+			       N_Vector yP, N_Vector fctP, 
+			       booleantype *jcurPtr, N_Vector tmp1, 
+			       N_Vector tmp2, N_Vector tmp3);
+static int arkLapackDenseSolve(ARKodeMem ark_mem, N_Vector b, 
+			       N_Vector weight, N_Vector yC, 
+			       N_Vector fctC);
+static int arkLapackDenseFree(ARKodeMem ark_mem);
+
+/* ARKLAPACK DENSE minit, msetup, msolve, mfree and mtimes routines */ 
+static int arkMassLapackDenseInit(ARKodeMem ark_mem);
+static int arkMassLapackDenseSetup(ARKodeMem ark_mem, N_Vector tmp1, 
+				   N_Vector tmp2, N_Vector tmp3);
+static int arkMassLapackDenseSolve(ARKodeMem ark_mem, N_Vector b, 
+				   N_Vector weight);
+static int arkMassLapackDenseFree(ARKodeMem ark_mem);
+static int arkMassLapackDenseMultiply(N_Vector v, N_Vector Mv, 
+				      realtype t, void *user_data);
+
+/* ARKLAPACK BAND linit, lsetup, lsolve, and lfree routines */ 
+static int arkLapackBandInit(ARKodeMem ark_mem);
+static int arkLapackBandSetup(ARKodeMem ark_mem, int convfail, 
+			      N_Vector yP, N_Vector fctP, 
+			      booleantype *jcurPtr, N_Vector tmp1, 
+			      N_Vector tmp2, N_Vector tmp3);
+static int arkLapackBandSolve(ARKodeMem ark_mem, N_Vector b, 
+			      N_Vector weight, N_Vector yC, 
+			      N_Vector fctC);
+static int arkLapackBandFree(ARKodeMem ark_mem);
+
+/* ARKLAPACK BAND minit, msetup, msolve, mfree and mtimes routines */ 
+static int arkMassLapackBandInit(ARKodeMem ark_mem);
+static int arkMassLapackBandSetup(ARKodeMem ark_mem, N_Vector tmp1, 
+				  N_Vector tmp2, N_Vector tmp3);
+static int arkMassLapackBandSolve(ARKodeMem ark_mem, N_Vector b, 
+				  N_Vector weight);
+static int arkMassLapackBandFree(ARKodeMem ark_mem);
+static int arkMassLapackBandMultiply(N_Vector v, N_Vector Mv, 
+				     realtype t, void *user_data);
+
+/*===============================================================
+ EXPORTED FUNCTIONS FOR IMPLICIT INTEGRATION
+===============================================================*/
+              
+/*---------------------------------------------------------------
+ ARKLapackDense:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the linear solver module.  
+ ARKLapackDense first calls the existing lfree routine if this is 
+ not NULL.  Then it sets the ark_linit, ark_lsetup, ark_lsolve, 
+ ark_lfree fields in (*arkode_mem) to be arkLapackDenseInit, 
+ arkLapackDenseSetup, arkLapackDenseSolve, and arkLapackDenseFree, 
+ respectively.  It allocates memory for a structure of type 
+ ARKDlsMemRec and sets the ark_lmem field in (*arkode_mem) to the
+ address of this structure.  It sets setupNonNull in (*arkode_mem) 
+ to TRUE, and the d_jac field to the default arkDlsDenseDQJac. 
+ Finally, it allocates memory for M, pivots, and savedJ.
+ The return value is SUCCESS = 0, or LMEM_FAIL = -1.
+
+ NOTE: The dense linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKLapackDense will 
+       first test for a compatible N_Vector internal 
+       representation by checking that N_VGetArrayPointer and 
+       N_VSetArrayPointer exist.  Of course, other vector 
+       implementations may also have these functions set, so 
+       this test is not sufficient to guarantee use of the 
+       serial NVECTOR package.
+---------------------------------------------------------------*/
+int ARKLapackDense(void *arkode_mem, int N)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKLAPACK", 
+		    "ARKLapackDense", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the LAPACK solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL ||
+      ark_mem->ark_tempv->ops->nvsetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKLAPACK", 
+		    "ARKLapackDense", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree !=NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */
+  ark_mem->ark_linit  = arkLapackDenseInit;
+  ark_mem->ark_lsetup = arkLapackDenseSetup;
+  ark_mem->ark_lsolve = arkLapackDenseSolve;
+  ark_mem->ark_lfree  = arkLapackDenseFree;
+  ark_mem->ark_lsolve_type = 1;
+
+  /* Get memory for ARKDlsMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMem) malloc(sizeof(struct ARKDlsMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackDense", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_DENSE;
+
+  /* Initialize Jacobian-related data */
+  arkdls_mem->d_jacDQ  = TRUE;
+  arkdls_mem->d_djac   = NULL;
+  arkdls_mem->d_J_data = NULL;
+
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_setupNonNull = TRUE;
+
+  /* Initialize counters */
+  arkDlsInitializeCounters(arkdls_mem);
+  
+  /* Set problem dimension */
+  arkdls_mem->d_n = (long int) N;
+
+  /* Allocate memory for M, pivot array, and savedJ */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_pivots = NULL;
+  arkdls_mem->d_savedJ = NULL;
+
+  arkdls_mem->d_M = NewDenseMat(arkdls_mem->d_n, arkdls_mem->d_n);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackDense", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_pivots = NewIntArray(N);
+  if (arkdls_mem->d_pivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackDense", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_savedJ = NewDenseMat(arkdls_mem->d_n, arkdls_mem->d_n);
+  if (arkdls_mem->d_savedJ == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackDense", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    DestroyArray(arkdls_mem->d_pivots);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKLapackBand:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the band linear solver module. It 
+ first calls the existing lfree routine if this is not NULL.  It 
+ then sets the ark_linit, ark_lsetup, ark_lsolve, and ark_lfree 
+ fields in (*arkode_mem) to be arkLapackBandInit, 
+ arkLapackBandSetup, arkLapackBandSolve, and arkLapackBandFree, 
+ respectively.  It allocates memory for a structure of type 
+ ARKLapackBandMemRec and sets the ark_lmem field in (*arkode_mem) 
+ to the address of this structure.  It sets setupNonNull in 
+ (*arkode_mem) to be TRUE, mu to be mupper, and ml to be mlower.  
+ Finally, it allocates memory for M, pivots, and savedJ.  The 
+ ARKLapackBand return value is ARKDLS_SUCCESS=0, 
+ ARKDLS_MEM_FAIL=-1, or ARKDLS_ILL_INPUT=-2.
+
+ NOTE: The ARKLAPACK linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKLapackBand will first 
+       test for compatible a compatible N_Vector internal
+       representation by checking that the function 
+       N_VGetArrayPointer exists.  Again, this test is insufficient
+       to guarantee the serial NVECTOR package, but it's a start.
+---------------------------------------------------------------*/                  
+int ARKLapackBand(void *arkode_mem, int N, int mupper, int mlower)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKLAPACK", 
+		    "ARKLapackBand", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the BAND solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKLAPACK", 
+		    "ARKLapackBand", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */  
+  ark_mem->ark_linit  = arkLapackBandInit;
+  ark_mem->ark_lsetup = arkLapackBandSetup;
+  ark_mem->ark_lsolve = arkLapackBandSolve;
+  ark_mem->ark_lfree  = arkLapackBandFree;
+  ark_mem->ark_lsolve_type = 2;
+  
+  /* Get memory for ARKDlsMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMem) malloc(sizeof(struct ARKDlsMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackBand", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_BAND;
+
+  /* Initialize Jacobian-related data */
+  arkdls_mem->d_jacDQ  = TRUE;
+  arkdls_mem->d_bjac   = NULL;
+  arkdls_mem->d_J_data = NULL;
+
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_setupNonNull = TRUE;
+  
+  /* Initialize counters */
+  arkDlsInitializeCounters(arkdls_mem);
+  
+  /* Load problem dimension */
+  arkdls_mem->d_n = (long int) N;
+
+  /* Load half-bandwiths in arkdls_mem */
+  arkdls_mem->d_ml = (long int) mlower;
+  arkdls_mem->d_mu = (long int) mupper;
+
+  /* Test ml and mu for legality */
+  if ((arkdls_mem->d_ml < 0) || (arkdls_mem->d_mu < 0) || 
+      (arkdls_mem->d_ml >= arkdls_mem->d_n) || 
+      (arkdls_mem->d_mu >= arkdls_mem->d_n)) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKLAPACK", 
+		    "ARKLapackBand", MSGD_BAD_SIZES);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  /* Set extended upper half-bandwith for M (required for pivoting) */
+  arkdls_mem->d_smu = SUNMIN(arkdls_mem->d_n-1,
+			  arkdls_mem->d_mu + arkdls_mem->d_ml);
+
+  /* Allocate memory for M, pivot array, and savedJ */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_pivots = NULL;
+  arkdls_mem->d_savedJ = NULL;
+
+  arkdls_mem->d_M = NewBandMat(arkdls_mem->d_n, arkdls_mem->d_mu, 
+			       arkdls_mem->d_ml, arkdls_mem->d_smu);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackBand", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }  
+  arkdls_mem->d_pivots = NewIntArray(N);
+  if (arkdls_mem->d_pivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackBand", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_savedJ = NewBandMat(arkdls_mem->d_n, arkdls_mem->d_mu, 
+				    arkdls_mem->d_ml, arkdls_mem->d_smu);
+  if (arkdls_mem->d_savedJ == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKLapackBand", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    DestroyArray(arkdls_mem->d_pivots);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassLapackDense:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the mass matrix solver module.  
+ ARKMassLapackDense first calls the existing mfree routine if 
+ this is not NULL.  Then it sets the ark_minit, ark_msetup, 
+ ark_msolve, ark_mfree fields in (*arkode_mem) to be 
+ arkMassLapackDenseInit, arkMassLapackDenseSetup, 
+ arkMassLapackDenseSolve, and arkMassLapackDenseFree, 
+ respectively.  It allocates memory for a structure of type 
+ ARKDlsMassMemRec and sets the ark_mass_mem field in 
+ (*arkode_mem) to the address of this structure.  It sets 
+ MassSetupNonNull in (*arkode_mem) to TRUE.  Finally, it 
+ allocates memory for M and pivots. The return value is 
+ SUCCESS = 0, or LMEM_FAIL = -1.
+
+ NOTE: The dense linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKMassLapackDense will 
+       first test for a compatible N_Vector internal 
+       representation by checking that N_VGetArrayPointer and 
+       N_VSetArrayPointer exist.  Of course, other vector 
+       implementations may also have these functions set, so 
+       this test is not sufficient to guarantee use of the 
+       serial NVECTOR package.
+---------------------------------------------------------------*/
+int ARKMassLapackDense(void *arkode_mem, int N, 
+		       ARKDlsDenseMassFn dmass)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKLAPACK", 
+		    "ARKMassLapackDense", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the LAPACK solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL ||
+      ark_mem->ark_tempv->ops->nvsetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKLAPACK", 
+		    "ARKMassLapackDense", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree !=NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set related function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = arkMassLapackDenseInit;
+  ark_mem->ark_msetup = arkMassLapackDenseSetup;
+  ark_mem->ark_msolve = arkMassLapackDenseSolve;
+  ark_mem->ark_mfree  = arkMassLapackDenseFree;
+  ark_mem->ark_mtimes = arkMassLapackDenseMultiply;
+  ark_mem->ark_mtimes_data = (void *) ark_mem;
+  ark_mem->ark_msolve_type = 1;
+
+  /* Get memory for ARKDlsMassMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMassMem) malloc(sizeof(struct ARKDlsMassMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKMassLapackDense", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_DENSE;
+
+  /* Initialize mass-matrix-related data */
+  arkdls_mem->d_dmass = dmass;
+  arkdls_mem->d_M_data = NULL;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = TRUE;
+
+  /* Set problem dimension */
+  arkdls_mem->d_n = (long int) N;
+
+  /* Allocate memory for M and pivot array */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_pivots = NULL;
+
+  arkdls_mem->d_M = NewDenseMat(arkdls_mem->d_n, arkdls_mem->d_n);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKMassLapackDense", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+  arkdls_mem->d_pivots = NewIntArray(N);
+  if (arkdls_mem->d_pivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKMassLapackDense", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassLapackBand:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the band mass matrix solver module. 
+ It first calls the existing mfree routine if this is not NULL.  
+ It then sets the ark_minit, ark_msetup, ark_msolve, and ark_mfree 
+ fields in (*arkode_mem) to be arkMassLapackBandInit, 
+ arkMassLapackBandSetup, arkMassLapackBandSolve, and 
+ arkMassLapackBandFree, respectively.  It allocates memory for a
+ structure of type ARKMassLapackBandMemRec and sets the 
+ ark_mass_mem field in (*arkode_mem) to the address of this 
+ structure.  It sets MassSetupNonNull in (*arkode_mem) to be TRUE, 
+ mu to be mupper, and ml to be mlower.  Finally, it allocates 
+ memory for M and pivots.  The ARKMassLapackBand return value is 
+ ARKDLS_SUCCESS=0, ARKDLS_MEM_FAIL=-1, or ARKDLS_ILL_INPUT=-2.
+
+ NOTE: The ARKLAPACK linear solver assumes a serial implementation
+       of the NVECTOR package. Therefore, ARKMassLapackBand will first 
+       test for compatible a compatible N_Vector internal
+       representation by checking that the function 
+       N_VGetArrayPointer exists.  Again, this test is insufficient
+       to guarantee the serial NVECTOR package, but it's a start.
+---------------------------------------------------------------*/                  
+int ARKMassLapackBand(void *arkode_mem, int N, int mupper, 
+		      int mlower, ARKDlsBandMassFn bmass)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKLAPACK", 
+		    "ARKMassLapackBand", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the BAND solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKLAPACK", 
+		    "ARKMassLapackBand", MSGD_BAD_NVECTOR);
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = arkMassLapackBandInit;
+  ark_mem->ark_msetup = arkMassLapackBandSetup;
+  ark_mem->ark_msolve = arkMassLapackBandSolve;
+  ark_mem->ark_mfree  = arkMassLapackBandFree;
+  ark_mem->ark_mtimes = arkMassLapackBandMultiply;
+  ark_mem->ark_mtimes_data = (void *) ark_mem;
+  ark_mem->ark_msolve_type = 2;
+  
+  /* Get memory for ARKDlsMassMemRec */
+  arkdls_mem = NULL;
+  arkdls_mem = (ARKDlsMassMem) malloc(sizeof(struct ARKDlsMassMemRec));
+  if (arkdls_mem == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKMassLapackBand", MSGD_MEM_FAIL);
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Set matrix type */
+  arkdls_mem->d_type = SUNDIALS_BAND;
+
+  /* Initialize mass-matrix-related data */
+  arkdls_mem->d_bmass = bmass;
+  arkdls_mem->d_M_data = NULL;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = TRUE;
+  
+  /* Load problem dimension */
+  arkdls_mem->d_n = (long int) N;
+
+  /* Load half-bandwiths in arkdls_mem */
+  arkdls_mem->d_ml = (long int) mlower;
+  arkdls_mem->d_mu = (long int) mupper;
+
+  /* Test ml and mu for legality */
+  if ((arkdls_mem->d_ml < 0) || (arkdls_mem->d_mu < 0) || 
+      (arkdls_mem->d_ml >= arkdls_mem->d_n) || 
+      (arkdls_mem->d_mu >= arkdls_mem->d_n)) {
+    arkProcessError(ark_mem, ARKDLS_ILL_INPUT, "ARKLAPACK", 
+		    "ARKMassLapackBand", MSGD_BAD_SIZES);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_ILL_INPUT);
+  }
+
+  /* Set extended upper half-bandwith for M (required for pivoting) */
+  arkdls_mem->d_smu = SUNMIN(arkdls_mem->d_n-1,
+			  arkdls_mem->d_mu + arkdls_mem->d_ml);
+
+  /* Allocate memory for M and pivot array */
+  arkdls_mem->d_M = NULL;
+  arkdls_mem->d_pivots = NULL;
+
+  arkdls_mem->d_M = NewBandMat(arkdls_mem->d_n, arkdls_mem->d_mu, 
+			       arkdls_mem->d_ml, arkdls_mem->d_smu);
+  if (arkdls_mem->d_M == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKMassLapackBand", MSGD_MEM_FAIL);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }  
+  arkdls_mem->d_pivots = NewIntArray(N);
+  if (arkdls_mem->d_pivots == NULL) {
+    arkProcessError(ark_mem, ARKDLS_MEM_FAIL, "ARKLAPACK", 
+		    "ARKMassLapackBand", MSGD_MEM_FAIL);
+    DestroyMat(arkdls_mem->d_M);
+    free(arkdls_mem); arkdls_mem = NULL;
+    return(ARKDLS_MEM_FAIL);
+  }
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkdls_mem;
+
+  return(ARKDLS_SUCCESS);
+}
+
+
+/*===============================================================
+  PRIVATE FUNCTIONS FOR IMPLICIT INTEGRATION WITH DENSE JACOBIANS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkLapackDenseInit does remaining initializations specific to 
+ the dense linear solver.
+---------------------------------------------------------------*/                  
+static int arkLapackDenseInit(ARKodeMem ark_mem)
+{
+  ARKDlsMem arkdls_mem;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  
+  arkDlsInitializeCounters(arkdls_mem);
+
+  /* Set Jacobian function and data, depending on jacDQ */
+  if (arkdls_mem->d_jacDQ) {
+    arkdls_mem->d_djac = arkDlsDenseDQJac;
+    arkdls_mem->d_J_data = ark_mem;
+  } else {
+    arkdls_mem->d_J_data = ark_mem->ark_user_data;
+  }
+
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkLapackDenseSetup does the setup operations for the dense 
+ linear solver. It makes a decision whether or not to call the 
+ Jacobian evaluation routine based on various state variables, 
+ and if not it uses the saved copy. In any case, it constructs 
+ the Newton matrix A = M - gamma*J updates counters, and calls 
+ the dense LU factorization routine.
+---------------------------------------------------------------*/                  
+static int arkLapackDenseSetup(ARKodeMem ark_mem, int convfail,
+			       N_Vector yP, N_Vector fctP,
+			       booleantype *jcurPtr, N_Vector tmp1, 
+			       N_Vector tmp2, N_Vector tmp3)
+{
+  ARKDlsMem arkdls_mem;
+  ARKDlsMassMem arkdls_mass_mem;
+  realtype dgamma, fact, *Acol_j, *Mcol_j;
+  booleantype jbad, jok;
+  int ier, retval, one = 1;
+  int intn, lenmat, i, j;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  intn = (int) arkdls_mem->d_n;
+  lenmat = arkdls_mem->d_M->ldata ;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkdls_mem->d_nstlj + ARKD_MSBJ) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKD_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  jok = !jbad;
+  
+  /* If jok = TRUE, use saved copy of J */
+  if (jok) {
+    *jcurPtr = FALSE;
+    dcopy_f77(&lenmat, arkdls_mem->d_savedJ->data, &one, 
+	      arkdls_mem->d_M->data, &one);
+    
+  /* If jok = FALSE, call jac routine for new J value */
+  } else {
+    arkdls_mem->d_nje++;
+    arkdls_mem->d_nstlj = ark_mem->ark_nst;
+    *jcurPtr = TRUE;
+    SetToZero(arkdls_mem->d_M);
+
+    retval = arkdls_mem->d_djac(arkdls_mem->d_n, ark_mem->ark_tn, 
+				yP, fctP, arkdls_mem->d_M, 
+				arkdls_mem->d_J_data, tmp1, tmp2, tmp3);
+
+    if (retval == 0) {
+      dcopy_f77(&lenmat, arkdls_mem->d_M->data, &one, 
+		arkdls_mem->d_savedJ->data, &one);
+    } else if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_JACFUNC_UNRECVR, "ARKLAPACK", 
+		      "arkLapackDenseSetup", MSGD_JACFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_UNRECVR;
+      return(-1);
+    } else if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_RECVR;
+      return(1);
+    }
+  }
+
+  /* Scale J by -gamma */
+  fact = -ark_mem->ark_gamma;
+  dscal_f77(&lenmat, &fact, arkdls_mem->d_M->data, &one);
+  
+  /* Add mass matrix to get A = M-gamma*J*/
+  if (ark_mem->ark_mass_matrix) {
+
+    /* Compute mass matrix */
+    arkdls_mass_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+    SetToZero(arkdls_mass_mem->d_M);
+    retval = arkdls_mass_mem->d_dmass(arkdls_mass_mem->d_n, 
+				      ark_mem->ark_tn, 
+				      arkdls_mass_mem->d_M, 
+				      arkdls_mass_mem->d_M_data, 
+				      tmp1, tmp2, tmp3);
+    arkdls_mass_mem->d_nme++;
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKDENSE", 
+		      "arkLapackDenseSetup",  MSGD_MASSFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+      return(1);
+    }
+
+    /* Add to A */
+    for (j=0; j<arkdls_mem->d_M->N; j++) {
+      Acol_j = arkdls_mem->d_M->cols[j];
+      Mcol_j = arkdls_mass_mem->d_M->cols[j];
+      for (i=0; i<arkdls_mem->d_M->M; i++) 
+	Acol_j[i] += Mcol_j[i];
+    }
+  } else {
+    AddIdentity(arkdls_mem->d_M);
+  }
+
+  /* Do LU factorization of M */
+  dgetrf_f77(&intn, &intn, arkdls_mem->d_M->data, 
+	     &intn, arkdls_mem->d_pivots, &ier);
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  arkdls_mem->d_last_flag = (long int) ier;
+  if (ier > 0) return(1);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkLapackDenseSolve handles the solve operation for the dense 
+ linear solver by calling the dense backsolve routine.
+---------------------------------------------------------------*/                  
+static int arkLapackDenseSolve(ARKodeMem ark_mem, N_Vector b, 
+			       N_Vector weight, N_Vector yC, 
+			       N_Vector fctC)
+{
+  ARKDlsMem arkdls_mem;
+  realtype *bd, fact;
+  int ier, one = 1;
+  int intn;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  intn = (int) arkdls_mem->d_n;
+
+  bd = N_VGetArrayPointer(b);
+
+  dgetrs_f77("N", &intn, &one, arkdls_mem->d_M->data, &intn, 
+	     arkdls_mem->d_pivots, bd, &intn, &ier, 1); 
+
+  if (ier > 0) return(1);
+
+  /* scale the correction to account for change in gamma */
+  if (ark_mem->ark_gamrat != ONE) {
+    fact = TWO/(ONE + ark_mem->ark_gamrat);
+    dscal_f77(&intn, &fact, bd, &one); 
+  }
+  
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkLapackDenseFree frees memory specific to the dense linear 
+ solver.
+---------------------------------------------------------------*/                  
+static int arkLapackDenseFree(ARKodeMem ark_mem)
+{
+  ARKDlsMem  arkdls_mem;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  
+  DestroyMat(arkdls_mem->d_M);
+  DestroyArray(arkdls_mem->d_pivots);
+  DestroyMat(arkdls_mem->d_savedJ);
+  free(arkdls_mem); 
+  arkdls_mem = NULL;
+
+  return(0);
+}
+
+
+/*===============================================================
+  PRIVATE FUNCTIONS FOR IMPLICIT INTEGRATION WITH DENSE MASS MATRIX
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkMassLapackDenseInit does remaining initializations specific to 
+ the dense linear solver.
+---------------------------------------------------------------*/                  
+static int arkMassLapackDenseInit(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem arkdls_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  arkdls_mem->d_nme = 0;
+  arkdls_mem->d_M_data = ark_mem->ark_user_data;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackDenseSetup does the setup operations for the dense 
+ mass matrix solver. It calls the mass matrix evaluation routine,
+ updates counters, and calls the dense LU factorization routine.
+---------------------------------------------------------------*/                  
+static int arkMassLapackDenseSetup(ARKodeMem ark_mem, N_Vector tmp1, 
+				   N_Vector tmp2, N_Vector tmp3)
+{
+  ARKDlsMassMem arkdls_mem;
+  int ier, retval;
+  int intn;
+
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  intn = (int) arkdls_mem->d_n;
+
+  SetToZero(arkdls_mem->d_M);
+  retval = arkdls_mem->d_dmass(arkdls_mem->d_n, ark_mem->ark_tn, 
+			       arkdls_mem->d_M, arkdls_mem->d_M_data, 
+			       tmp1, tmp2, tmp3);
+  arkdls_mem->d_nme++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKLAPACK", 
+		    "arkMassLapackDenseSetup", MSGD_MASSFUNC_FAILED);
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+    return(-1);
+  } else if (retval > 0) {
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+    return(1);
+  }
+
+  /* Do LU factorization of M */
+  dgetrf_f77(&intn, &intn, arkdls_mem->d_M->data, 
+	     &intn, arkdls_mem->d_pivots, &ier);
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  arkdls_mem->d_last_flag = (long int) ier;
+  if (ier > 0) return(1);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackDenseSolve handles the solve operation for the
+ dense mass matrix solver by calling the dense backsolve routine.
+---------------------------------------------------------------*/                  
+static int arkMassLapackDenseSolve(ARKodeMem ark_mem, N_Vector b, 
+				   N_Vector weight)
+{
+  ARKDlsMassMem arkdls_mem;
+  realtype *bd;
+  int ier, one = 1;
+  int intn;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  intn = (int) arkdls_mem->d_n;
+  bd = N_VGetArrayPointer(b);
+  dgetrs_f77("N", &intn, &one, arkdls_mem->d_M->data, &intn, 
+	     arkdls_mem->d_pivots, bd, &intn, &ier, 1); 
+  if (ier > 0) return(1);
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackDenseFree frees memory specific to the dense mass
+ matrix solver.
+---------------------------------------------------------------*/                  
+static int arkMassLapackDenseFree(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem arkdls_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  DestroyMat(arkdls_mem->d_M);
+  DestroyArray(arkdls_mem->d_pivots);
+  free(arkdls_mem); 
+  arkdls_mem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackDenseMultiply performs a matrix-vector product, 
+ multiplying the current mass matrix by a given vector.
+---------------------------------------------------------------*/                  
+static int arkMassLapackDenseMultiply(N_Vector v, N_Vector Mv, 
+				      realtype t, void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+  realtype *vdata=NULL, *Mvdata=NULL;
+  realtype *Mcol_j;
+  int i, j;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKLAPACK", 
+		    "arkMassLapackDenseMultiply", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+
+  /* extract the DlsMassMem structure from the user_data pointer */
+  ark_mem = (ARKodeMem) arkode_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  /* zero out the result */
+  N_VConst(0.0, Mv);
+
+  /* access the vector arrays (since they must be serial vectors) */
+  vdata = N_VGetArrayPointer(v);
+  Mvdata = N_VGetArrayPointer(Mv);
+  if (vdata == NULL || Mvdata == NULL)
+    return(1);
+
+  /* perform matrix-vector product and return */
+  for (j=0; j<arkdls_mem->d_M->N; j++) {
+    Mcol_j = arkdls_mem->d_M->cols[j];
+    for (i=0; i<arkdls_mem->d_M->M; i++) 
+      Mvdata[i] += Mcol_j[i]*vdata[j];
+  }
+  return(0);
+}
+
+
+/*===============================================================
+  PRIVATE FUNCTIONS FOR IMPLICIT INTEGRATION WITH BAND JACOBIANS
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkLapackBandInit does remaining initializations specific to 
+ the band linear solver.
+---------------------------------------------------------------*/                  
+static int arkLapackBandInit(ARKodeMem ark_mem)
+{
+  ARKDlsMem arkdls_mem;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+
+  arkDlsInitializeCounters(arkdls_mem);
+
+  /* Set Jacobian function and data, depending on jacDQ */
+  if (arkdls_mem->d_jacDQ) {
+    arkdls_mem->d_bjac = arkDlsBandDQJac;
+    arkdls_mem->d_J_data = ark_mem;
+  } else {
+    arkdls_mem->d_J_data = ark_mem->ark_user_data;
+  }
+  
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkLapackBandSetup does the setup operations for the band linear 
+ solver. It makes a decision whether or not to call the Jacobian 
+ evaluation routine based on various state variables, and if not 
+ it uses the saved copy. In any case, it constructs the Newton 
+ matrix A = M - gamma*J, updates counters, and calls the band LU
+ factorization routine.
+---------------------------------------------------------------*/                  
+static int arkLapackBandSetup(ARKodeMem ark_mem, int convfail, 
+			      N_Vector yP, N_Vector fctP, 
+			      booleantype *jcurPtr, N_Vector tmp1, 
+			      N_Vector tmp2, N_Vector tmp3)
+{
+  ARKDlsMem arkdls_mem;
+  ARKDlsMassMem arkdls_mass_mem;
+  realtype dgamma, fact, *Acol_j, *Mcol_j;
+  booleantype jbad, jok;
+  int ier, retval, one = 1;
+  int intn, iml, imu, lenmat, ldmat, i, j, colSize;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  intn = (int) arkdls_mem->d_n;
+  iml = (int) arkdls_mem->d_ml;
+  imu = (int) arkdls_mem->d_mu;
+  lenmat = arkdls_mem->d_M->ldata;
+  ldmat = arkdls_mem->d_M->ldim;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkdls_mem->d_nstlj + ARKD_MSBJ) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKD_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  jok = !jbad;
+  
+  /* If jok = TRUE, use saved copy of J */
+  if (jok) {
+    *jcurPtr = FALSE;
+    dcopy_f77(&lenmat, arkdls_mem->d_savedJ->data, 
+	      &one, arkdls_mem->d_M->data, &one);
+    
+  /* If jok = FALSE, call jac routine for new J value */
+  } else {
+    arkdls_mem->d_nje++;
+    arkdls_mem->d_nstlj = ark_mem->ark_nst;
+    *jcurPtr = TRUE;
+    SetToZero(arkdls_mem->d_M);
+
+    retval = arkdls_mem->d_bjac(arkdls_mem->d_n, arkdls_mem->d_mu, 
+				arkdls_mem->d_ml, ark_mem->ark_tn, 
+				yP, fctP, arkdls_mem->d_M, 
+				arkdls_mem->d_J_data, tmp1, tmp2, tmp3);
+    if (retval == 0) {
+      dcopy_f77(&lenmat, arkdls_mem->d_M->data, &one, 
+		arkdls_mem->d_savedJ->data, &one);
+    } else if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_JACFUNC_UNRECVR, "ARKLAPACK", 
+		      "arkLapackBandSetup", MSGD_JACFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_UNRECVR;
+      return(-1);
+    } else if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_JACFUNC_RECVR;
+      return(1);
+    }
+  }
+  
+  /* Scale J by -gamma */
+  fact = -ark_mem->ark_gamma;
+  dscal_f77(&lenmat, &fact, arkdls_mem->d_M->data, &one);
+  
+  /* Add mass matrix to get A = M-gamma*J*/
+  if (ark_mem->ark_mass_matrix) {
+
+    /* Compute mass matrix */
+    arkdls_mass_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+    SetToZero(arkdls_mass_mem->d_M);
+    retval = arkdls_mass_mem->d_bmass(arkdls_mass_mem->d_n, arkdls_mass_mem->d_mu, 
+				      arkdls_mass_mem->d_ml, ark_mem->ark_tn, 
+				      arkdls_mass_mem->d_M, arkdls_mass_mem->d_M_data, 
+				      tmp1, tmp2, tmp3);
+    arkdls_mass_mem->d_nme++;
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKLAPACK", 
+		      "arkLapackBandSetup",  MSGD_MASSFUNC_FAILED);
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+      return(1);
+    }
+
+    /* Add to A -- CURRENTLY ASSUMES THAT BOTH MATRICES HAVE 
+                   THE SAME BAND STRUCTURE AND COLUMN SIZE */
+    colSize = arkdls_mem->d_M->mu + arkdls_mem->d_M->ml + 1;
+    for (j=0; j<arkdls_mem->d_M->M; j++) {
+      Acol_j = arkdls_mem->d_M->cols[j] + arkdls_mem->d_M->s_mu - arkdls_mem->d_M->mu;
+      Mcol_j = arkdls_mass_mem->d_M->cols[j] + arkdls_mass_mem->d_M->s_mu 
+	     - arkdls_mass_mem->d_M->mu;
+      for (i=0; i<colSize; i++) 
+	Acol_j[i] += Mcol_j[i];
+    }
+  } else {
+    AddIdentity(arkdls_mem->d_M);
+  }
+  
+  /* Do LU factorization of M */
+  dgbtrf_f77(&intn, &intn, &iml, &imu, arkdls_mem->d_M->data, 
+	     &ldmat, arkdls_mem->d_pivots, &ier);
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  arkdls_mem->d_last_flag = (long int) ier;
+  if (ier > 0) return(1);
+  return(0);
+
+}
+
+
+/*---------------------------------------------------------------
+ arkLapackBandSolve handles the solve operation for the band 
+ linear solver by calling the band backsolve routine.
+---------------------------------------------------------------*/                  
+static int arkLapackBandSolve(ARKodeMem ark_mem, N_Vector b, 
+			      N_Vector weight, N_Vector yC, 
+			      N_Vector fctC)
+{
+  ARKDlsMem arkdls_mem;
+  realtype *bd, fact;
+  int ier, one = 1;
+  int intn, iml, imu, ldmat;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  intn = (int) arkdls_mem->d_n;
+  iml = (int) arkdls_mem->d_ml;
+  imu = (int) arkdls_mem->d_mu;
+  ldmat = arkdls_mem->d_M->ldim;
+
+  bd = N_VGetArrayPointer(b);
+
+  dgbtrs_f77("N", &intn, &iml, &imu, &one, arkdls_mem->d_M->data, 
+	     &ldmat, arkdls_mem->d_pivots, bd, &intn, &ier, 1);
+  if (ier > 0) return(1);
+
+  /* scale the correction to account for change in gamma */
+  if (ark_mem->ark_gamrat != ONE) {
+    fact = TWO/(ONE + ark_mem->ark_gamrat);
+    dscal_f77(&intn, &fact, bd, &one); 
+  }
+
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkLapackBandFree frees memory specific to the band linear 
+ solver.
+---------------------------------------------------------------*/                  
+static int arkLapackBandFree(ARKodeMem ark_mem)
+{
+  ARKDlsMem  arkdls_mem;
+
+  arkdls_mem = (ARKDlsMem) ark_mem->ark_lmem;
+  
+  DestroyMat(arkdls_mem->d_M);
+  DestroyArray(arkdls_mem->d_pivots);
+  DestroyMat(arkdls_mem->d_savedJ);
+  free(arkdls_mem); 
+  arkdls_mem = NULL;
+
+  return(0);
+}
+
+
+/*===============================================================
+  PRIVATE FUNCTIONS FOR IMPLICIT INTEGRATION WITH BAND MASS MATRIX
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkMassLapackBandInit does remaining initializations specific to 
+ the band linear solver.
+---------------------------------------------------------------*/                  
+static int arkMassLapackBandInit(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem arkdls_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  arkdls_mem->d_nme = 0;
+  arkdls_mem->d_M_data = ark_mem->ark_user_data;
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackBandSetup does the setup operations for the band 
+ mass matrix solver. It constructs the mass matrix M, updates 
+ counters, and calls the band LU factorization routine.
+---------------------------------------------------------------*/                  
+static int arkMassLapackBandSetup(ARKodeMem ark_mem, N_Vector tmp1, 
+				  N_Vector tmp2, N_Vector tmp3)
+{
+  ARKDlsMassMem arkdls_mem;
+  int ier, retval;
+  int intn, iml, imu, ldmat;
+
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  intn = (int) arkdls_mem->d_n;
+  iml = (int) arkdls_mem->d_ml;
+  imu = (int) arkdls_mem->d_mu;
+  ldmat = arkdls_mem->d_M->ldim;
+
+  SetToZero(arkdls_mem->d_M);
+  retval = arkdls_mem->d_bmass(arkdls_mem->d_n, arkdls_mem->d_mu, 
+			       arkdls_mem->d_ml, ark_mem->ark_tn, 
+			       arkdls_mem->d_M, arkdls_mem->d_M_data, 
+			       tmp1, tmp2, tmp3);
+  arkdls_mem->d_nme++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, ARKDLS_MASSFUNC_UNRECVR, "ARKLAPACK", 
+		    "arkMassLapackBandSetup", MSGD_MASSFUNC_FAILED);
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_UNRECVR;
+    return(-1);
+  } else if (retval > 0) {
+    arkdls_mem->d_last_flag = ARKDLS_MASSFUNC_RECVR;
+    return(1);
+  }
+  
+  /* Do LU factorization of M */
+  dgbtrf_f77(&intn, &intn, &iml, &imu, arkdls_mem->d_M->data, 
+	     &ldmat, arkdls_mem->d_pivots, &ier);
+
+  /* Return 0 if the LU was complete; otherwise return 1 */
+  arkdls_mem->d_last_flag = (long int) ier;
+  if (ier > 0) return(1);
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackBandSolve handles the solve operation for the band 
+ mass matrix solver by calling the band backsolve routine.
+---------------------------------------------------------------*/                  
+static int arkMassLapackBandSolve(ARKodeMem ark_mem, N_Vector b, 
+				  N_Vector weight)
+{
+  ARKDlsMassMem arkdls_mem;
+  realtype *bd;
+  int ier, one = 1;
+  int intn, iml, imu, ldmat;
+
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  intn = (int) arkdls_mem->d_n;
+  iml = (int) arkdls_mem->d_ml;
+  imu = (int) arkdls_mem->d_mu;
+  ldmat = arkdls_mem->d_M->ldim;
+  bd = N_VGetArrayPointer(b);
+  dgbtrs_f77("N", &intn, &iml, &imu, &one, arkdls_mem->d_M->data, 
+	     &ldmat, arkdls_mem->d_pivots, bd, &intn, &ier, 1);
+  if (ier > 0) return(1);
+  arkdls_mem->d_last_flag = ARKDLS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackBandFree frees memory specific to the band mass
+ matrix solver.
+---------------------------------------------------------------*/                  
+static int arkMassLapackBandFree(ARKodeMem ark_mem)
+{
+  ARKDlsMassMem arkdls_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+  DestroyMat(arkdls_mem->d_M);
+  DestroyArray(arkdls_mem->d_pivots);
+  free(arkdls_mem); 
+  arkdls_mem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassLapackBandMultiply performs a matrix-vector product, 
+ multiplying the current mass matrix by a given vector.
+---------------------------------------------------------------*/                  
+static int arkMassLapackBandMultiply(N_Vector v, N_Vector Mv, 
+				     realtype t, void *arkode_mem)
+{
+  ARKodeMem ark_mem;
+  ARKDlsMassMem arkdls_mem;
+  realtype *vdata=NULL, *Mvdata=NULL;
+  realtype *Mcol_j;
+  int colSize, s_mu, i, j;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKDLS_MEM_NULL, "ARKLAPACK", 
+		    "arkMassLapackBandMultiply", MSGD_ARKMEM_NULL);
+    return(ARKDLS_MEM_NULL);
+  }
+
+  /* extract the DlsMassMem structure from the user_data pointer */
+  ark_mem = (ARKodeMem) arkode_mem;
+  arkdls_mem = (ARKDlsMassMem) ark_mem->ark_mass_mem;
+
+  /* zero out the result */
+  N_VConst(0.0, Mv);
+
+  /* access the vector arrays (since they must be serial vectors) */
+  vdata = N_VGetArrayPointer(v);
+  Mvdata = N_VGetArrayPointer(Mv);
+  if (vdata == NULL || Mvdata == NULL)
+    return(1);
+
+  /* perform matrix-vector product and return */
+  colSize = arkdls_mem->d_M->mu + arkdls_mem->d_M->ml + 1;
+  s_mu = arkdls_mem->d_M->s_mu;
+  for (j=0; j<arkdls_mem->d_M->M; j++) {
+    Mcol_j = arkdls_mem->d_M->cols[j] + arkdls_mem->d_M->s_mu - arkdls_mem->d_M->mu;
+    for (i=0; i<colSize; i++) 
+      Mvdata[i+j-s_mu] += Mcol_j[i]*vdata[j];
+  }
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+     EOF
+---------------------------------------------------------------*/                  
diff --git a/src/arkode/arkode_pcg.c b/src/arkode/arkode_pcg.c
new file mode 100644
index 0000000..21bf1f3
--- /dev/null
+++ b/src/arkode/arkode_pcg.c
@@ -0,0 +1,772 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *--------------------------------------------------------------
+ * This is the implementation file for the ARKPCG linear solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_pcg.h>
+#include "arkode_spils_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_pcg.h>
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* ARKPCG linit, lsetup, lsolve, and lfree routines */
+static int ARKPcgInit(ARKodeMem ark_mem);
+static int ARKPcgSetup(ARKodeMem ark_mem, int convfail, 
+		       N_Vector ypred, N_Vector fpred, 
+		       booleantype *jcurPtr, N_Vector vtemp1,
+		       N_Vector vtemp2, N_Vector vtemp3);
+static int ARKPcgSolve(ARKodeMem ark_mem, N_Vector b, 
+		       N_Vector weight, N_Vector ynow, 
+		       N_Vector fnow);
+static int ARKPcgFree(ARKodeMem ark_mem);
+
+/* ARKPCG minit, msetup, msolve, and mfree routines */
+static int ARKMassPcgInit(ARKodeMem ark_mem);
+static int ARKMassPcgSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			   N_Vector vtemp2, N_Vector vtemp3);
+static int ARKMassPcgSolve(ARKodeMem ark_mem, N_Vector b, 
+			   N_Vector weight);
+static int ARKMassPcgFree(ARKodeMem ark_mem);
+
+
+/*---------------------------------------------------------------
+ ARKPcg:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Pcg linear solver module. 
+ ARKPcg first calls the existing lfree routine if this is not 
+ NULL. It then sets the ark_linit, ark_lsetup, ark_lsolve, 
+ ark_lfree fields in (*arkode_mem) to be ARKPcgInit, 
+ ARKPcgSetup, ARKPcgSolve, and ARKPcgFree, respectively. 
+ It allocates memory for a structure of type ARKSpilsMemRec and 
+ sets the ark_lmem field in (*arkode_mem) to the address of 
+ this structure. It sets setupNonNull in (*arkode_mem),
+ and sets various fields in the ARKSpilsMemRec structure.
+ Finally, ARKPcg allocates memory for ytemp and x, and calls
+ PcgMalloc to allocate memory for the Pcg solver.
+---------------------------------------------------------------*/
+int ARKPcg(void *arkode_mem, int pretype, int maxl)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  PcgMem pcg_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKPCG", 
+		    "ARKPcg", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd and N_VWrmsNorm is present */
+  if ((ark_mem->ark_tempv->ops->nvdotprod == NULL) ||
+      (ark_mem->ark_tempv->ops->nvwrmsnorm == NULL)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKPCG", 
+		    "ARKPcg", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */
+  ark_mem->ark_linit  = ARKPcgInit;
+  ark_mem->ark_lsetup = ARKPcgSetup;
+  ark_mem->ark_lsolve = ARKPcgSolve;
+  ark_mem->ark_lfree  = ARKPcgFree;
+  ark_mem->ark_lsolve_type = 0;
+
+  /* Get memory for ARKSpilsMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMem) malloc(sizeof(struct ARKSpilsMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKPcg", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_PCG;
+
+  /* Set Pcg parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for Jacobian-related fields */
+  arkspils_mem->s_jtimesDQ = TRUE;
+  arkspils_mem->s_jtimes   = NULL;
+  arkspils_mem->s_j_data   = NULL;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+  arkspils_mem->s_nstlpre = arkspils_mem->s_njtimes = 0;
+  arkspils_mem->s_nfes = 0;
+
+  /* Set default values for the rest of the Pcg parameters */
+  arkspils_mem->s_eplifac   = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  ark_mem->ark_setupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKPCG", 
+		    "ARKPcg", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKPcg", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKPcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt(N_VDotProd(arkspils_mem->s_ytemp, 
+					   arkspils_mem->s_ytemp));
+
+  /* Call PcgMalloc to allocate workspace for Pcg */
+  pcg_mem = NULL;
+  pcg_mem = PcgMalloc(mxl, ark_mem->ark_tempv);
+  if (pcg_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKPcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach PCG memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) pcg_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKPcgInit:
+
+ This routine does remaining initializations specific to the 
+ Pcg linear solver.
+---------------------------------------------------------------*/
+static int ARKPcgInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  PcgMem pcg_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  pcg_mem = (PcgMem) arkspils_mem->s_spils_mem;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+  arkspils_mem->s_nstlpre = arkspils_mem->s_njtimes = 0;
+  arkspils_mem->s_nfes = 0;
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) && 
+      (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKPCG", 
+		    "ARKPcgInit", MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set setupNonNull = TRUE iff there is preconditioning
+     (pretype != PREC_NONE)  and there is a preconditioning
+     setup phase (pset != NULL) */
+  ark_mem->ark_setupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  /* Set Jacobian-related fields, based on jtimesDQ */
+  if (arkspils_mem->s_jtimesDQ) {
+    arkspils_mem->s_jtimes = ARKSpilsDQJtimes;
+    arkspils_mem->s_j_data = ark_mem;
+  } else {
+    arkspils_mem->s_j_data = ark_mem->ark_user_data;
+  }
+
+  /*  Set maxl in the PCG memory in case it was changed by the user */
+  pcg_mem->l_max = arkspils_mem->s_maxl;
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKPcgSetup:
+
+ This routine does the setup operations for the Pcg linear 
+ solver. It makes a decision as to whether or not to signal for 
+ reevaluation of Jacobian data in the pset routine, based on 
+ various state variables, then it calls pset. If we signal for 
+ reevaluation, then we reset jcur = *jcurPtr to TRUE, regardless 
+ of the pset output. In any case, if jcur == TRUE, we increment 
+ npe and save nst in nstlpre.
+---------------------------------------------------------------*/
+static int ARKPcgSetup(ARKodeMem ark_mem, int convfail, 
+		       N_Vector ypred, N_Vector fpred, 
+		       booleantype *jcurPtr, N_Vector vtemp1,
+		       N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma;
+  int  retval;
+  ARKSpilsMem arkspils_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkspils_mem->s_nstlpre + ARKSPILS_MSBPRE) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKSPILS_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  *jcurPtr = jbad;
+  jok = !jbad;
+
+  /* Call pset routine and possibly reset jcur */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, ypred, fpred, jok, 
+				jcurPtr, ark_mem->ark_gamma, 
+				arkspils_mem->s_P_data, vtemp1, 
+				vtemp2, vtemp3);
+  if (retval < 0) {
+    arkProcessError(ark_mem, PCG_PSET_FAIL_UNREC, "ARKPCG", 
+		    "ARKPcgSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = PCG_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = PCG_PSET_FAIL_REC;
+  }
+
+  if (jbad) *jcurPtr = TRUE;
+
+  /* If jcur = TRUE, increment npe and save nst value */
+  if (*jcurPtr) {
+    arkspils_mem->s_npe++;
+    arkspils_mem->s_nstlpre = ark_mem->ark_nst;
+  }
+
+  arkspils_mem->s_last_flag = PCG_SUCCESS;
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKPcgSolve:
+
+ This routine handles the call to the generic solver PcgSolve
+ for the solution of the linear system Ax = b with the PCG 
+ method. The solution x is returned in the vector b.
+
+ If the WRMS norm of b is small, we return x = b (if this is the 
+ first Newton iteration) or x = 0 (if a later Newton iteration).
+
+ Otherwise, we set the tolerance parameter and initial guess 
+ (x = 0), call PcgSolve, and copy the solution x into b. The 
+ x-scaling and b-scaling arrays are both equal to weight.
+
+ The counters nli, nps, and ncfl are incremented, and the return 
+ value is set according to the success of PcgSolve. The 
+ success flag is returned if PcgSolve converged, or if this is 
+ the first Newton iteration and the residual norm was reduced 
+ below its initial value.
+---------------------------------------------------------------*/
+static int ARKPcgSolve(ARKodeMem ark_mem, N_Vector b, 
+		       N_Vector weight, N_Vector ynow, 
+		       N_Vector fnow)
+{
+  realtype bnorm, res_norm;
+  ARKSpilsMem arkspils_mem;
+  PcgMem pcg_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  pcg_mem = (PcgMem) arkspils_mem->s_spils_mem;
+
+  /* Test norm(b); if small, return x = 0 or x = b */
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_eRNrm; 
+  bnorm = N_VWrmsNorm(b, weight);
+  if (bnorm <= arkspils_mem->s_deltar) {
+    if (ark_mem->ark_mnewt > 0) N_VConst(ZERO, b); 
+    return(0);
+  }
+
+  /* Set vectors ycur and fcur for use by the Atimes and Psolve routines */
+  arkspils_mem->s_ycur = ynow;
+  arkspils_mem->s_fcur = fnow;
+
+  /* Set inputs delta and initial guess x = 0 to PcgSolve */
+  arkspils_mem->s_delta = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  /* N_VConst(ark_mem->ark_uround, arkspils_mem->s_x); */
+
+  /* Call PcgSolve and copy x to b */
+  retval = PcgSolve(pcg_mem, ark_mem, arkspils_mem->s_x, b, 
+		    arkspils_mem->s_pretype, arkspils_mem->s_delta,
+		    ark_mem, weight, ARKSpilsAtimes, 
+		    ARKSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != PCG_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      kry  %19.16g  %19.16g  %i  %i\n", 
+	    bnorm, res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SpbcgSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case PCG_SUCCESS:
+    return 0;
+    break;
+  case PCG_RES_REDUCED:
+    /* allow reduction but not solution on first Newton iteration, 
+       otherwise return with a recoverable failure */
+    if (ark_mem->ark_mnewt == 0) return(0);
+    else                         return(1);
+    break;
+  case PCG_CONV_FAIL:
+    return 1;
+    break;
+  case PCG_PSOLVE_FAIL_REC:
+    return 1;
+    break;
+  case PCG_ATIMES_FAIL_REC:
+    return 1;
+    break;
+  case PCG_MEM_NULL:
+    return -1;
+    break;
+  case PCG_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, PCG_ATIMES_FAIL_UNREC, "ARKPCG", 
+		    "ARKPcgSolve", MSGS_JTIMES_FAILED);    
+    return -1;
+    break;
+  case PCG_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, PCG_PSOLVE_FAIL_UNREC, "ARKPCG", 
+		    "ARKPcgSolve", MSGS_PSOLVE_FAILED);
+    return -1;
+    break;
+  }
+
+  return 0;
+}
+
+
+/*---------------------------------------------------------------
+ ARKPcgFree:
+
+ This routine frees memory specific to the Pcg linear solver.
+---------------------------------------------------------------*/
+static int ARKPcgFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  PcgMem pcg_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  pcg_mem = (PcgMem) arkspils_mem->s_spils_mem;
+  PcgFree(pcg_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassPcg:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Pcg mass matrix solver module. 
+ ARKMassPcg first calls the existing mfree routine if this is not 
+ NULL. It then sets the ark_minit, ark_msetup, ark_msolve, 
+ ark_mfree fields in (*arkode_mem) to be ARKMassPcgInit, 
+ ARKMassPcgSetup, ARKMassPcgSolve, and ARKMassPcgFree, 
+ respectively. It sets MassSetupNonNull in (*arkode_mem), 
+ allocates memory for a structure of type ARKSpilsMassMemRec and 
+ sets the ark_mass_mem field in (*arkode_mem) to the address of 
+ this structure.  Finally, ARKMassPcg allocates memory for ytemp 
+ and x, and calls PcgMalloc to allocate memory for the Pcg solver.
+---------------------------------------------------------------*/
+int ARKMassPcg(void *arkode_mem, int pretype, int maxl, 
+	       ARKSpilsMassTimesVecFn mtimes, void *mtimes_data)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  PcgMem pcg_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKPCG", 
+		    "ARKMassPcg", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd and N_VWrmsNorm is present */
+  if ((ark_mem->ark_tempv->ops->nvdotprod == NULL) ||
+      (ark_mem->ark_tempv->ops->nvwrmsnorm == NULL)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKPCG", 
+		    "ARKMassPcg", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = ARKMassPcgInit;
+  ark_mem->ark_msetup = ARKMassPcgSetup;
+  ark_mem->ark_msolve = ARKMassPcgSolve;
+  ark_mem->ark_mfree  = ARKMassPcgFree;
+  ark_mem->ark_msolve_type = 0;
+
+  /* Get memory for ARKSpilsMassMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMassMem) malloc(sizeof(struct ARKSpilsMassMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKMassPcg", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set mass-matrix-vector product routine */
+  ark_mem->ark_mtimes      = mtimes;
+  ark_mem->ark_mtimes_data = mtimes_data;
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_PCG;
+
+  /* Set Pcg parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype    = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Set default values for the rest of the Pcg parameters */
+  arkspils_mem->s_eplifac       = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag     = ARKSPILS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKPCG", 
+		    "ARKMassPcg", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKMassPcg", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKMassPcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt(N_VDotProd(arkspils_mem->s_ytemp, 
+					   arkspils_mem->s_ytemp));
+
+  /* Call PcgMalloc to allocate workspace for Pcg */
+  pcg_mem = NULL;
+  pcg_mem = PcgMalloc(mxl, ark_mem->ark_tempv);
+  if (pcg_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKPCG", 
+		    "ARKMassPcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach PCG memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) pcg_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassPcgInit:
+
+ This routine does remaining initializations specific to the 
+ Pcg linear solver.
+---------------------------------------------------------------*/
+static int ARKMassPcgInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  PcgMem pcg_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  pcg_mem = (PcgMem) arkspils_mem->s_spils_mem;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) && 
+      (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKPCG", 
+		    "ARKMassPcgInit", MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set MassSetupNonNull = TRUE iff there is preconditioning
+     (pretype != PREC_NONE)  and there is a preconditioning
+     setup phase (pset != NULL) */
+  ark_mem->ark_MassSetupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  /* Set maxl in the PCG memory in case it was changed by the user */
+  pcg_mem->l_max = arkspils_mem->s_maxl;
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassPcgSetup:
+
+ This routine does the setup operations for the Pcg linear 
+ solver. It makes a decision as to whether or not to signal for 
+ reevaluation of Jacobian data in the pset routine, based on 
+ various state variables, then it calls pset.
+---------------------------------------------------------------*/
+static int ARKMassPcgSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			   N_Vector vtemp2, N_Vector vtemp3)
+{
+  int  retval;
+  ARKSpilsMassMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Call pset routine */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, 
+				arkspils_mem->s_P_data, 
+				vtemp1, vtemp2, vtemp3);
+  arkspils_mem->s_npe++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, PCG_PSET_FAIL_UNREC, "ARKPCG", 
+		    "ARKMassPcgSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = PCG_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = PCG_PSET_FAIL_REC;
+  }
+  if (retval == 0) {
+    arkspils_mem->s_last_flag = PCG_SUCCESS;
+  }
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassPcgSolve:
+
+ This routine handles the call to the generic solver PcgSolve
+ for the solution of the mass matrix system Mx = b with the PCG 
+ method. The solution x is returned in the vector b.
+
+ We set the tolerance parameter and initial guess 
+ (x = 0), call PcgSolve, and copy the solution x into b. The 
+ x-scaling and b-scaling arrays are both equal to weight.
+
+ The counters nli, nps, and ncfl are incremented, and the return 
+ value is set according to the success of PcgSolve. The 
+ success flag is returned if PcgSolve converged.
+---------------------------------------------------------------*/
+static int ARKMassPcgSolve(ARKodeMem ark_mem, N_Vector b, 
+			   N_Vector weight)
+{
+  realtype res_norm;
+  ARKSpilsMassMem arkspils_mem;
+  PcgMem pcg_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  pcg_mem = (PcgMem) arkspils_mem->s_spils_mem;
+
+  /* Set inputs delta and initial guess x = 0 to PcgSolve */
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_nlscoef; 
+  arkspils_mem->s_delta  = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+
+  /* Call PcgSolve and copy x to b */
+  retval = PcgSolve(pcg_mem, ark_mem, arkspils_mem->s_x, b, 
+		    arkspils_mem->s_pretype, arkspils_mem->s_delta,
+		    ark_mem, weight, ARKSpilsMtimes, 
+		    ARKSpilsMPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != PCG_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      mass  %19.16g  %i  %i\n", 
+	    res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from PcgSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case PCG_SUCCESS:
+    return 0;
+    break;
+  case PCG_RES_REDUCED:
+    return 1;
+    break;
+  case PCG_CONV_FAIL:
+    return 1;
+    break;
+  case PCG_PSOLVE_FAIL_REC:
+    return 1;
+    break;
+  case PCG_ATIMES_FAIL_REC:
+    return 1;
+    break;
+  case PCG_MEM_NULL:
+    return -1;
+    break;
+  case PCG_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, PCG_ATIMES_FAIL_UNREC, "ARKPCG", 
+		    "ARKMassPcgSolve", MSGS_MTIMES_FAILED);
+    return -1;
+    break;
+  case PCG_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, PCG_PSOLVE_FAIL_UNREC, "ARKPCG", 
+		    "ARKMassPcgSolve", MSGS_PSOLVE_FAILED);
+    return -1;
+    break;
+  }
+
+  return 0;
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassPcgFree:
+
+ This routine frees memory specific to the Pcg linear solver.
+---------------------------------------------------------------*/
+static int ARKMassPcgFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  PcgMem pcg_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  pcg_mem = (PcgMem) arkspils_mem->s_spils_mem;
+  PcgFree(pcg_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+     EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_sparse.c b/src/arkode/arkode_sparse.c
new file mode 100644
index 0000000..c00a0d0
--- /dev/null
+++ b/src/arkode/arkode_sparse.c
@@ -0,0 +1,268 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation file for the generic ARKSLS linear solver module.
+ *---------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode_impl.h"
+#include "arkode_sparse_impl.h"
+#include <sundials/sundials_math.h>
+
+/*===============================================================
+ FUNCTION SPECIFIC CONSTANTS (none)
+===============================================================*/
+
+/*===============================================================
+ EXPORTED FUNCTIONS
+===============================================================*/
+              
+/*---------------------------------------------------------------
+ ARKSlsSetSparseJacFn specifies the sparse Jacobian function.
+---------------------------------------------------------------*/
+int ARKSlsSetSparseJacFn(void *arkode_mem, ARKSlsSparseJacFn jac)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		   "ARKSlsSetSparseJacFn", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_LMEM_NULL, "ARKSLS", 
+		    "ARKSlsSetSparseJacFn", MSGSP_LMEM_NULL);
+    return(ARKSLS_LMEM_NULL);
+  }
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+
+  arksls_mem->s_Jeval = jac;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSlsSetSparseMassFn specifies the sparse mass matrix function.
+---------------------------------------------------------------*/
+int ARKSlsSetSparseMassFn(void *arkode_mem, ARKSlsSparseMassFn mass)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		   "ARKSlsSetSparseMassFn", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MASSMEM_NULL, "ARKSLS", 
+		    "ARKSlsSetSparseMassFn", MSGSP_MASSMEM_NULL);
+    return(ARKSLS_MASSMEM_NULL);
+  }
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+
+  arksls_mem->s_Meval = mass;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSlsGetNumJacEvals returns the number of Jacobian evaluations.
+---------------------------------------------------------------*/
+int ARKSlsGetNumJacEvals(void *arkode_mem, long int *njevals)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		   "ARKSlsGetNumJacEvals", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_LMEM_NULL, "ARKSLS", 
+		    "ARKSlsGetNumJacEvals", MSGSP_LMEM_NULL);
+    return(ARKSLS_LMEM_NULL);
+  }
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+
+  *njevals = arksls_mem->s_nje;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+
+/*---------------------------------------------------------------
+ ARKSlsGetNumMassEvals returns the number of mass matrix evaluations.
+---------------------------------------------------------------*/
+int ARKSlsGetNumMassEvals(void *arkode_mem, long int *nmevals)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		   "ARKSlsGetNumMassEvals", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MASSMEM_NULL, "ARKSLS", 
+		    "ARKSlsGetNumMassEvals", MSGSP_MASSMEM_NULL);
+    return(ARKSLS_MASSMEM_NULL);
+  }
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+
+  *nmevals = arksls_mem->s_nme;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSlsGetReturnFlagName returns the name associated with a 
+ ARKSLS return value.
+---------------------------------------------------------------*/
+char *ARKSlsGetReturnFlagName(long int flag)
+{
+  char *name;
+
+  name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case ARKSLS_SUCCESS:
+    sprintf(name,"ARKSLS_SUCCESS");
+    break;   
+  case ARKSLS_MEM_NULL:
+    sprintf(name,"ARKSLS_MEM_NULL");
+    break;
+  case ARKSLS_LMEM_NULL:
+    sprintf(name,"ARKSLS_LMEM_NULL");
+    break;
+  case ARKSLS_ILL_INPUT:
+    sprintf(name,"ARKSLS_ILL_INPUT");
+    break;
+  case ARKSLS_MEM_FAIL:
+    sprintf(name,"ARKSLS_MEM_FAIL");
+    break;
+  case ARKSLS_JAC_NOSET:
+    sprintf(name,"ARKSLS_JAC_NOSET");
+    break;
+  case ARKSLS_PACKAGE_FAIL:
+    sprintf(name,"ARKSLS_PACKAGE_FAIL");
+    break;
+  case ARKSLS_MASSMEM_NULL:
+    sprintf(name,"ARKSLS_MASSMEM_NULL");
+    break;
+  case ARKSLS_JACFUNC_UNRECVR:
+    sprintf(name,"ARKSLS_JACFUNC_UNRECVR");
+    break;
+  case ARKSLS_JACFUNC_RECVR:
+    sprintf(name,"ARKSLS_JACFUNC_RECVR");
+    break;
+  case ARKSLS_MASSFUNC_UNRECVR:
+    sprintf(name,"ARKSLS_MASSFUNC_UNRECVR");
+    break;
+  case ARKSLS_MASSFUNC_RECVR:
+    sprintf(name,"ARKSLS_MASSFUNC_RECVR");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSlsGetLastFlag returns the last flag set in a ARKSLS function.
+---------------------------------------------------------------*/
+int ARKSlsGetLastFlag(void *arkode_mem, long int *flag)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKSlsGetLastFlag", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_LMEM_NULL, "ARKSLS", 
+		    "ARKSlsGetLastFlag", MSGSP_LMEM_NULL);
+    return(ARKSLS_LMEM_NULL);
+  }
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+
+  *flag = arksls_mem->s_last_flag;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSlsGetLastMassFlag returns the last flag set in a ARKSLS mass
+ matrix function.
+---------------------------------------------------------------*/
+int ARKSlsGetLastMassFlag(void *arkode_mem, long int *flag)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKSlsGetLastMassFlag", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MASSMEM_NULL, "ARKSLS", 
+		    "ARKSlsGetLastMassFlag", MSGSP_MASSMEM_NULL);
+    return(ARKSLS_MASSMEM_NULL);
+  }
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+
+  *flag = arksls_mem->s_last_flag;
+
+  return(ARKSLS_SUCCESS);
+}
+
+/*---------------------------------------------------------------
+    EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_sparse_impl.h b/src/arkode/arkode_sparse_impl.h
new file mode 100644
index 0000000..331bd78
--- /dev/null
+++ b/src/arkode/arkode_sparse_impl.h
@@ -0,0 +1,127 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation header file for the generic ARKSLS linear solver 
+ * module.
+ *---------------------------------------------------------------*/
+
+#ifndef _ARKSPARSE_IMPL_H
+#define _ARKSPARSE_IMPL_H
+
+#include "arkode/arkode_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*---------------------------------------------------------------
+ ARKSLS solver constants:
+
+ ARKS_MSBJ   maximum number of steps between Jacobian evaluations
+ ARKS_DGMAX  maximum change in gamma between Jacobian evaluations
+---------------------------------------------------------------*/
+#define ARKS_MSBJ  50
+#define ARKS_DGMAX RCONST(0.2)
+
+ 
+/*---------------------------------------------------------------
+ Types: ARKSlsMemRec, ARKSlsMem
+
+ ARKSlsMem is pointer to a ARKSlsMemRec structure.
+---------------------------------------------------------------*/
+
+typedef struct ARKSlsMemRec {
+
+  ARKSlsSparseJacFn s_Jeval; /* user Jacobian evaluation routine 
+                                to be called                   */
+  void *s_Jdata;             /* user data passed to s_Jeval    */
+
+  long int s_nje;            /* nje = no. of calls to s_Jeval  */
+
+  long int s_last_flag;      /* last error return flag         */
+
+  int s_first_factorize;     /* flag telling whether the first 
+			        factorization needs to happen  */
+
+  int s_nstlj;               /* time step of last J evaluation */
+
+  SlsMat s_A;                /* A = M - gamma * df/dy          */
+
+  SlsMat s_savedJ;           /* saved copy of Jacobian         */
+
+  int sparsetype;            /* matrix type: compressed sparse column or row */
+
+  void *s_solver_data;       /* struct for solver data         */
+
+} *ARKSlsMem;
+
+
+/*---------------------------------------------------------------
+ Types: ARKSlsMassMemRec, ARKSlsMassMem
+
+ ARKSlsMassMem is pointer to a ARKSlsMassMemRec structure.
+---------------------------------------------------------------*/
+
+typedef struct ARKSlsMassMemRec {
+
+  ARKSlsSparseMassFn s_Meval; /* user mass matrix evaluation 
+                                    routine to be called       */
+  void *s_Mdata;              /* user data passed to s_Meval   */
+
+  long int s_nme;             /* nme = no. of calls to s_Meval */
+
+  long int s_last_flag;       /* last error return flag        */
+
+  int s_first_factorize;      /* flag telling whether the first 
+			         factorization needs to happen */
+
+  SlsMat s_M;                 /* mass matrix structure         */
+
+  SlsMat s_M_lu;              /* mass matrix for LU decomp     */
+
+  int sparsetype;             /* matrix type: compressed sparse column or row */
+
+  void *s_solver_data;        /* struct for solver data        */
+
+} *ARKSlsMassMem;
+
+
+/*---------------------------------------------------------------
+ Prototypes of internal functions (none)
+---------------------------------------------------------------*/
+  
+
+/*---------------------------------------------------------------
+ Error Messages
+---------------------------------------------------------------*/
+#define MSGSP_ARKMEM_NULL     "Integrator memory is NULL."
+#define MSGSP_BAD_NVECTOR     "A required vector operation is not implemented."
+#define MSGSP_MEM_FAIL        "A memory request failed."
+#define MSGSP_LMEM_NULL       "Linear solver memory is NULL."
+#define MSGSP_MASSMEM_NULL    "Mass matrix solver memory is NULL."
+#define MSGSP_ILL_INPUT       "Invalid input detected."
+#define MSGSP_JAC_NOSET       "Jacobian evaluation function has not been set."
+#define MSGSP_MASS_NOSET      "Mass matrix evaluation function has not been set."
+#define MSGSP_JACFUNC_FAILED  "The Jacobian routine failed in an unrecoverable manner."
+#define MSGSP_MASSFUNC_FAILED "The mass matrix routine failed in an unrecoverable manner."
+#define MSGSP_PACKAGE_FAIL    "A call to an external package failed."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/arkode/arkode_spbcgs.c b/src/arkode/arkode_spbcgs.c
new file mode 100644
index 0000000..6bbed59
--- /dev/null
+++ b/src/arkode/arkode_spbcgs.c
@@ -0,0 +1,766 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the ARKSPBCG linear solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_spbcgs.h>
+#include "arkode_spils_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_spbcgs.h>
+#include <sundials/sundials_math.h>
+
+
+/* Constants */
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* ARKSPBCG linit, lsetup, lsolve, and lfree routines */
+static int ARKSpbcgInit(ARKodeMem ark_mem);
+static int ARKSpbcgSetup(ARKodeMem ark_mem, int convfail, 
+			 N_Vector ypred, N_Vector fpred, 
+			 booleantype *jcurPtr, N_Vector vtemp1,
+			 N_Vector vtemp2, N_Vector vtemp3);
+static int ARKSpbcgSolve(ARKodeMem ark_mem, N_Vector b, 
+			 N_Vector weight, N_Vector ynow, 
+			 N_Vector fnow);
+static int ARKSpbcgFree(ARKodeMem ark_mem);
+
+/* ARKSPBCG minit, msetup, msolve, and mfree routines */
+static int ARKMassSpbcgInit(ARKodeMem ark_mem);
+static int ARKMassSpbcgSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			     N_Vector vtemp2, N_Vector vtemp3);
+static int ARKMassSpbcgSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight);
+static int ARKMassSpbcgFree(ARKodeMem ark_mem);
+
+
+/*---------------------------------------------------------------
+ ARKSpbcg:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Spbcg linear solver module. 
+ ARKSpbcg first calls the existing lfree routine if this is not 
+ NULL. It then sets the ark_linit, ark_lsetup, ark_lsolve, 
+ ark_lfree fields in (*arkode_mem) to be ARKSpbcgInit, 
+ ARKSpbcgSetup, ARKSpbcgSolve, and ARKSpbcgFree, respectively. 
+ It allocates memory for a structure of type ARKSpilsMemRec and 
+ sets the ark_lmem field in (*arkode_mem) to the address of 
+ this structure. It sets setupNonNull in (*arkode_mem),
+ and sets various fields in the ARKSpilsMemRec structure.
+ Finally, ARKSpbcg allocates memory for ytemp and x, and calls
+ SpbcgMalloc to allocate memory for the Spbcg solver.
+---------------------------------------------------------------*/
+int ARKSpbcg(void *arkode_mem, int pretype, int maxl)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPBCG", 
+		    "ARKSpbcg", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd and N_VProd are present */
+  if ((ark_mem->ark_tempv->ops->nvdotprod == NULL) ||
+      (ark_mem->ark_tempv->ops->nvprod == NULL)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPBCG", 
+		    "ARKSpbcg", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */
+  ark_mem->ark_linit  = ARKSpbcgInit;
+  ark_mem->ark_lsetup = ARKSpbcgSetup;
+  ark_mem->ark_lsolve = ARKSpbcgSolve;
+  ark_mem->ark_lfree  = ARKSpbcgFree;
+  ark_mem->ark_lsolve_type = 0;
+
+  /* Get memory for ARKSpilsMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMem) malloc(sizeof(struct ARKSpilsMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKSpbcg", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPBCG;
+
+  /* Set Spbcg parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for Jacobian-related fields */
+  arkspils_mem->s_jtimesDQ = TRUE;
+  arkspils_mem->s_jtimes   = NULL;
+  arkspils_mem->s_j_data   = NULL;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Set default values for the rest of the Spbcg parameters */
+  arkspils_mem->s_eplifac = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  ark_mem->ark_setupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPBCG", 
+		    "ARKSpbcg", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKSpbcg", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKSpbcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt(N_VDotProd(arkspils_mem->s_ytemp, 
+					   arkspils_mem->s_ytemp));
+
+  /* Call SpbcgMalloc to allocate workspace for Spbcg */
+  spbcg_mem = NULL;
+  spbcg_mem = SpbcgMalloc(mxl, ark_mem->ark_tempv);
+  if (spbcg_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKSpbcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPBCG memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) spbcg_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpbcgInit:
+
+ This routine does remaining initializations specific to the 
+ Spbcg linear solver.
+---------------------------------------------------------------*/
+static int ARKSpbcgInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  spbcg_mem = (SpbcgMem) arkspils_mem->s_spils_mem;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) && 
+      (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPBCG", 
+                    "ARKSpbcgInit", MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set setupNonNull = TRUE iff there is preconditioning
+     (pretype != PREC_NONE)  and there is a preconditioning
+     setup phase (pset != NULL) */
+  ark_mem->ark_setupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  /* Set Jacobian-related fields, based on jtimesDQ */
+  if (arkspils_mem->s_jtimesDQ) {
+    arkspils_mem->s_jtimes = ARKSpilsDQJtimes;
+    arkspils_mem->s_j_data = ark_mem;
+  } else {
+    arkspils_mem->s_j_data = ark_mem->ark_user_data;
+  }
+
+  /*  Set maxl in the SPBCG memory in case it was changed by the user */
+  spbcg_mem->l_max  = arkspils_mem->s_maxl;
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpbcgSetup:
+
+ This routine does the setup operations for the Spbcg linear 
+ solver. It makes a decision as to whether or not to signal for 
+ reevaluation of Jacobian data in the pset routine, based on 
+ various state variables, then it calls pset. If we signal for 
+ reevaluation, then we reset jcur = *jcurPtr to TRUE, regardless 
+ of the pset output. In any case, if jcur == TRUE, we increment 
+ npe and save nst in nstlpre.
+---------------------------------------------------------------*/
+static int ARKSpbcgSetup(ARKodeMem ark_mem, int convfail, 
+			 N_Vector ypred, N_Vector fpred, 
+			 booleantype *jcurPtr, N_Vector vtemp1,
+			 N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma;
+  int  retval;
+  ARKSpilsMem arkspils_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkspils_mem->s_nstlpre + ARKSPILS_MSBPRE) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKSPILS_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  *jcurPtr = jbad;
+  jok = !jbad;
+
+  /* Call pset routine and possibly reset jcur */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, ypred, fpred, jok, 
+				jcurPtr, ark_mem->ark_gamma, 
+				arkspils_mem->s_P_data, vtemp1, 
+				vtemp2, vtemp3);
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPBCG_PSET_FAIL_UNREC, "ARKSPBCG", 
+		    "ARKSpbcgSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPBCG_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = SPBCG_PSET_FAIL_REC;
+  }
+
+  if (jbad) *jcurPtr = TRUE;
+
+  /* If jcur = TRUE, increment npe and save nst value */
+  if (*jcurPtr) {
+    arkspils_mem->s_npe++;
+    arkspils_mem->s_nstlpre = ark_mem->ark_nst;
+  }
+
+  arkspils_mem->s_last_flag = SPBCG_SUCCESS;
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpbcgSolve:
+
+ This routine handles the call to the generic solver SpbcgSolve
+ for the solution of the linear system Ax = b with the SPBCG 
+ method. The solution x is returned in the vector b.
+
+ If the WRMS norm of b is small, we return x = b (if this is the 
+ first Newton iteration) or x = 0 (if a later Newton iteration).
+
+ Otherwise, we set the tolerance parameter and initial guess 
+ (x = 0), call SpbcgSolve, and copy the solution x into b. The 
+ x-scaling and b-scaling arrays are both equal to weight.
+
+ The counters nli, nps, and ncfl are incremented, and the return 
+ value is set according to the success of SpbcgSolve. The 
+ success flag is returned if SpbcgSolve converged, or if this is 
+ the first Newton iteration and the residual norm was reduced 
+ below its initial value.
+---------------------------------------------------------------*/
+static int ARKSpbcgSolve(ARKodeMem ark_mem, N_Vector b, 
+			 N_Vector weight, N_Vector ynow, 
+			 N_Vector fnow)
+{
+  realtype bnorm, res_norm;
+  ARKSpilsMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  spbcg_mem = (SpbcgMem) arkspils_mem->s_spils_mem;
+
+  /* Test norm(b); if small, return x = 0 or x = b */
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_eRNrm; 
+  bnorm = N_VWrmsNorm(b, weight);
+  if (bnorm <= arkspils_mem->s_deltar) {
+    if (ark_mem->ark_mnewt > 0) N_VConst(ZERO, b); 
+    return(0);
+  }
+
+  /* Set vectors ycur and fcur for use by the Atimes and Psolve routines */
+  arkspils_mem->s_ycur = ynow;
+  arkspils_mem->s_fcur = fnow;
+
+  /* Set inputs delta and initial guess x = 0 to SpbcgSolve */  
+  arkspils_mem->s_delta = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SpbcgSolve and copy x to b */
+  retval = SpbcgSolve(spbcg_mem, ark_mem, arkspils_mem->s_x, b, 
+		      arkspils_mem->s_pretype, arkspils_mem->s_delta,
+		      ark_mem, weight, weight, ARKSpilsAtimes, 
+		      ARKSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPBCG_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      kry  %19.16g  %19.16g  %i  %i\n", 
+	    bnorm, res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SpbcgSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPBCG_SUCCESS:
+    return(0);
+    break;
+  case SPBCG_RES_REDUCED:
+    /* allow reduction but not solution on first Newton iteration, 
+       otherwise return with a recoverable failure */
+    if (ark_mem->ark_mnewt == 0) return(0);
+    else                         return(1);
+    break;
+  case SPBCG_CONV_FAIL:
+    return(1);
+    break;
+  case SPBCG_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPBCG_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPBCG_MEM_NULL:
+    return(-1);
+    break;
+  case SPBCG_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPBCG_ATIMES_FAIL_UNREC, "ARKSPBCG", 
+		    "ARKSpbcgSolve", MSGS_JTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPBCG_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPBCG_PSOLVE_FAIL_UNREC, "ARKSPBCG", 
+		    "ARKSpbcgSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpbcgFree:
+
+ This routine frees memory specific to the Spbcg linear solver.
+---------------------------------------------------------------*/
+static int ARKSpbcgFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  spbcg_mem = (SpbcgMem) arkspils_mem->s_spils_mem;
+  SpbcgFree(spbcg_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+
+/*---------------------------------------------------------------
+ ARKMassSpbcg:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Spbcg mass matrix solver module. 
+ ARKMassSpbcg first calls the existing mfree routine if this is 
+ not NULL. It then sets the ark_minit, ark_msetup, ark_msolve, 
+ ark_mfree fields in (*arkode_mem) to be ARKMassSpbcgInit, 
+ ARKMassSpbcgSetup, ARKMassSpbcgSolve, and ARKMassSpbcgFree, 
+ respectively. It allocates memory for a structure of type 
+ ARKSpilsMassMemRec and sets the ark_mass_mem field in
+ (*arkode_mem) to the address of this structure. It sets 
+ MassSetupNonNull in (*arkode_mem), and sets various fields in
+ the ARKSpilsMassMemRec structure, allocates memory for ytemp 
+ and x, and calls SpbcgMalloc to allocate memory for the Spbcg 
+ solver.
+---------------------------------------------------------------*/
+int ARKMassSpbcg(void *arkode_mem, int pretype, int maxl, 
+		 ARKSpilsMassTimesVecFn mtimes, void *mtimes_data)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPBCG", 
+		    "ARKMassSpbcg", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd is present */
+  if (ark_mem->ark_tempv->ops->nvdotprod == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPBCG", 
+		    "ARKMassSpbcg", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = ARKMassSpbcgInit;
+  ark_mem->ark_msetup = ARKMassSpbcgSetup;
+  ark_mem->ark_msolve = ARKMassSpbcgSolve;
+  ark_mem->ark_mfree  = ARKMassSpbcgFree;
+  ark_mem->ark_msolve_type = 0;
+
+  /* Get memory for ARKSpilsMassMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMassMem) malloc(sizeof(struct ARKSpilsMassMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKMassSpbcg", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set mass-matrix-vector product routine */
+  ark_mem->ark_mtimes      = mtimes;
+  ark_mem->ark_mtimes_data = mtimes_data;
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPBCG;
+
+  /* Set Spbcg parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype    = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Set default values for the rest of the Spbcg parameters */
+  arkspils_mem->s_eplifac       = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag     = ARKSPILS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPBCG", 
+		    "ARKMassSpbcg", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKMassSpbcg", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKMassSpbcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt(N_VDotProd(arkspils_mem->s_ytemp, 
+					   arkspils_mem->s_ytemp));
+
+  /* Call SpbcgMalloc to allocate workspace for Spbcg */
+  spbcg_mem = NULL;
+  spbcg_mem = SpbcgMalloc(mxl, ark_mem->ark_tempv);
+  if (spbcg_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPBCG", 
+		    "ARKMassSpbcg", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPBCG memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) spbcg_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpbcgInit:
+
+ This routine does remaining initializations specific to the 
+ Spbcg linear solver.
+---------------------------------------------------------------*/
+static int ARKMassSpbcgInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  spbcg_mem = (SpbcgMem) arkspils_mem->s_spils_mem;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) && 
+      (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPBCG", 
+		    "ARKMassSpbcgInit", MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set MassSetupNonNull = TRUE iff there is preconditioning
+     (pretype != PREC_NONE)  and there is a preconditioning
+     setup phase (pset != NULL) */
+  ark_mem->ark_MassSetupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  /*  Set maxl in the SPBCG memory in case it was changed by the user */
+  spbcg_mem->l_max = arkspils_mem->s_maxl;
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpbcgSetup:
+
+ This routine does the setup operations for the Spbcg mass matrix 
+ solver. It calls pset and increments npe.
+---------------------------------------------------------------*/
+static int ARKMassSpbcgSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			     N_Vector vtemp2, N_Vector vtemp3)
+{
+  int  retval;
+  ARKSpilsMassMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Call pset routine */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, 
+				arkspils_mem->s_P_data, 
+				vtemp1, vtemp2, vtemp3);
+  arkspils_mem->s_npe++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPBCG_PSET_FAIL_UNREC, "ARKSPBCG", 
+		    "ARKMassSpbcgSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPBCG_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = SPBCG_PSET_FAIL_REC;
+  }
+  if (retval == 0) {
+    arkspils_mem->s_last_flag = SPBCG_SUCCESS;
+  }
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpbcgSolve:
+
+ This routine handles the call to the generic solver SpbcgSolve
+ for the solution of the mass matrix system Mx = b with the SPBCG 
+ method. The solution x is returned in the vector b.
+
+ We set the tolerance parameter and initial guess (x = 0), call
+ SpbcgSolve, and copy the solution x into b. The 
+ x-scaling and b-scaling arrays are both equal to weight.
+
+ The counters nli, nps, and ncfl are incremented, and the return 
+ value is set according to the success of SpbcgSolve.
+---------------------------------------------------------------*/
+static int ARKMassSpbcgSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight)
+{
+  realtype res_norm;
+  ARKSpilsMassMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  spbcg_mem = (SpbcgMem) arkspils_mem->s_spils_mem;
+
+  /* Set inputs delta and initial guess x = 0 to SpbcgSolve */  
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_nlscoef; 
+  arkspils_mem->s_delta  = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SpbcgSolve and copy x to b */
+  retval = SpbcgSolve(spbcg_mem, ark_mem, arkspils_mem->s_x, b, 
+		      arkspils_mem->s_pretype, arkspils_mem->s_delta,
+		      ark_mem, weight, weight, ARKSpilsMtimes, 
+		      ARKSpilsMPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPBCG_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      mass  %19.16g  %i  %i\n", 
+	    res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SpbcgSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPBCG_SUCCESS:
+    return(0);
+    break;
+  case SPBCG_RES_REDUCED:
+    return(1);
+    break;
+  case SPBCG_CONV_FAIL:
+    return(1);
+    break;
+  case SPBCG_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPBCG_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPBCG_MEM_NULL:
+    return(-1);
+    break;
+  case SPBCG_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPBCG_ATIMES_FAIL_UNREC, "ARKSPBCG", 
+		    "ARKMassSpbcgSolve", MSGS_MTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPBCG_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPBCG_PSOLVE_FAIL_UNREC, "ARKSPBCG", 
+		    "ARKMassSpbcgSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpbcgFree:
+
+ This routine frees memory specific to the Spbcg mass matrix solver.
+---------------------------------------------------------------*/
+static int ARKMassSpbcgFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  SpbcgMem spbcg_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  spbcg_mem = (SpbcgMem) arkspils_mem->s_spils_mem;
+  SpbcgFree(spbcg_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_mass_mem = NULL;
+  
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+     EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_spfgmr.c b/src/arkode/arkode_spfgmr.c
new file mode 100644
index 0000000..4b7932d
--- /dev/null
+++ b/src/arkode/arkode_spfgmr.c
@@ -0,0 +1,777 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the ARKSPFGMR linear solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_spfgmr.h>
+#include "arkode_spils_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_spfgmr.h>
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* ARKSPFGMR linit, lsetup, lsolve, and lfree routines */
+static int ARKSpfgmrInit(ARKodeMem ark_mem);
+static int ARKSpfgmrSetup(ARKodeMem ark_mem, int convfail, 
+			  N_Vector ypred, N_Vector fpred, 
+			  booleantype *jcurPtr, N_Vector vtemp1,
+			  N_Vector vtemp2, N_Vector vtemp3);
+static int ARKSpfgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			  N_Vector weight, N_Vector ynow, 
+			  N_Vector fnow);
+static int ARKSpfgmrFree(ARKodeMem ark_mem);
+
+/* ARKSPFGMR minit, msetup, msolve, and mfree routines */
+static int ARKMassSpfgmrInit(ARKodeMem ark_mem);
+static int ARKMassSpfgmrSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			      N_Vector vtemp2, N_Vector vtemp3);
+static int ARKMassSpfgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			      N_Vector weight);
+static int ARKMassSpfgmrFree(ARKodeMem ark_mem);
+
+
+/*---------------------------------------------------------------
+ ARKSpfgmr:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Spfgmr linear solver module. 
+ ARKSpfgmr first calls the existing lfree routine if this is not 
+ NULL.  It then sets the ark_linit, ark_lsetup, ark_lsolve, 
+ ark_lfree fields in (*arkode_mem) to be ARKSpfgmrInit, 
+ ARKSpfgmrSetup, ARKSpfgmrSolve, and ARKSpfgmrFree, respectively.  
+ It allocates memory for a structure of type ARKSpilsMemRec and
+ sets the ark_lmem field in (*arkode_mem) to the address of this
+ structure.  It sets setupNonNull in (*arkode_mem), and sets 
+ various fields in the ARKSpilsMemRec structure. Finally, 
+ ARKSpfgmr allocates memory for ytemp and x, and calls
+ SpfgmrMalloc to allocate memory for the Spfgmr solver.
+---------------------------------------------------------------*/
+int ARKSpfgmr(void *arkode_mem, int pretype, int maxl)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  SpfgmrMem spfgmr_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPFGMR", 
+		    "ARKSpfgmr", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd and N_VProd are present */
+  if ((ark_mem->ark_tempv->ops->nvdotprod == NULL) ||
+      (ark_mem->ark_tempv->ops->nvprod == NULL)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPFGMR", 
+		    "ARKSpfgmr", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */
+  ark_mem->ark_linit  = ARKSpfgmrInit;
+  ark_mem->ark_lsetup = ARKSpfgmrSetup;
+  ark_mem->ark_lsolve = ARKSpfgmrSolve;
+  ark_mem->ark_lfree  = ARKSpfgmrFree;
+  ark_mem->ark_lsolve_type = 0;
+
+  /* Get memory for ARKSpilsMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMem) malloc(sizeof(struct ARKSpilsMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKSpfgmr", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPFGMR;
+
+  /* Set Spfgmr parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype    = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for Jacobian-related fields */
+  arkspils_mem->s_jtimesDQ = TRUE;
+  arkspils_mem->s_jtimes   = NULL;
+  arkspils_mem->s_j_data   = NULL;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Set default values for the rest of the Spfgmr parameters */
+  arkspils_mem->s_gstype    = MODIFIED_GS;
+  arkspils_mem->s_eplifac   = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  ark_mem->ark_setupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPFGMR", 
+		    "ARKSpfgmr", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKSpfgmr", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKSpfgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt( N_VDotProd(arkspils_mem->s_ytemp, 
+					    arkspils_mem->s_ytemp) );
+
+  /* Call SpfgmrMalloc to allocate workspace for Spfgmr */
+  spfgmr_mem = NULL;
+  spfgmr_mem = SpfgmrMalloc(mxl, ark_mem->ark_tempv);
+  if (spfgmr_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKSpfgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPFGMR memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) spfgmr_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpfgmrInit:
+
+ This routine does remaining initializations specific to the 
+ Spfgmr linear solver.
+---------------------------------------------------------------*/
+static int ARKSpfgmrInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) 
+      && (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPFGMR", "ARKSpfgmrInit", 
+                    MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set setupNonNull=TRUE iff there is preconditioning (pretype != PREC_NONE)
+     and there is a preconditioning setup phase (pset != NULL)             */
+  ark_mem->ark_setupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  /* Set Jacobian-related fields, based on jtimesDQ */
+  if (arkspils_mem->s_jtimesDQ) {
+    arkspils_mem->s_jtimes = ARKSpilsDQJtimes;
+    arkspils_mem->s_j_data = ark_mem;
+  } else {
+    arkspils_mem->s_j_data = ark_mem->ark_user_data;
+  }
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpfgmrSetup:
+
+ This routine does the setup operations for the Spfgmr linear 
+ solver. It makes a decision as to whether or not to signal for 
+ re-evaluation of Jacobian data in the pset routine, based on 
+ various state variables, then it calls pset.  If we signal for 
+ re-evaluation, then we reset jcur = *jcurPtr to TRUE, regardless 
+ of the pset output. In any case, if jcur == TRUE, we increment 
+ npe and save nst in nstlpre.
+---------------------------------------------------------------*/
+static int ARKSpfgmrSetup(ARKodeMem ark_mem, int convfail, 
+			 N_Vector ypred, N_Vector fpred, 
+			 booleantype *jcurPtr, N_Vector vtemp1,
+			 N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma;
+  int  retval;
+  ARKSpilsMem arkspils_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkspils_mem->s_nstlpre + ARKSPILS_MSBPRE) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKSPILS_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  *jcurPtr = jbad;
+  jok = !jbad;
+
+  /* Call pset routine and possibly reset jcur */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, ypred, fpred, jok, 
+				jcurPtr, ark_mem->ark_gamma, 
+				arkspils_mem->s_P_data, vtemp1, 
+				vtemp2, vtemp3);
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPFGMR_PSET_FAIL_UNREC, "ARKSPFGMR", 
+		    "ARKSpfgmrSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPFGMR_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) 
+    arkspils_mem->s_last_flag = SPFGMR_PSET_FAIL_REC;
+
+  if (jbad) *jcurPtr = TRUE;
+
+  /* If jcur = TRUE, increment npe and save nst value */
+  if (*jcurPtr) {
+    arkspils_mem->s_npe++;
+    arkspils_mem->s_nstlpre = ark_mem->ark_nst;
+  }
+
+  arkspils_mem->s_last_flag = SPFGMR_SUCCESS;
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpfgmrSolve:
+
+ This routine handles the call to the generic solver SpfgmrSolve
+ for the solution of the linear system Ax = b with the SPFGMR 
+ method, without restarts.  The solution x is returned in the 
+ vector b.
+
+ If the WRMS norm of b is small, we return x = b (if this is the 
+ first Newton iteration) or x = 0 (if a later Newton iteration).
+
+ Otherwise, we set the tolerance parameter and initial guess 
+ (x = 0), call SpfgmrSolve, and copy the solution x into b.  The 
+ x-scaling and b-scaling arrays are both equal to weight, and no 
+ restarts are allowed.
+
+ The counters nli, nps, and ncfl are incremented, and the return
+ value is set according to the success of SpfgmrSolve.  The 
+ success flag is returned if SpfgmrSolve converged, or if this is 
+ the first Newton iteration and the residual norm was reduced 
+ below its initial value.
+---------------------------------------------------------------*/
+static int ARKSpfgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			  N_Vector weight, N_Vector ynow, 
+			  N_Vector fnow)
+{
+  realtype bnorm, res_norm;
+  ARKSpilsMem arkspils_mem;
+  SpfgmrMem spfgmr_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  spfgmr_mem = (SpfgmrMem) arkspils_mem->s_spils_mem;
+
+  /* Test norm(b); if small, return x = 0 or x = b */
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_eRNrm; 
+  bnorm = N_VWrmsNorm(b, weight);
+  if (bnorm <= arkspils_mem->s_deltar) {
+    if (ark_mem->ark_mnewt > 0) N_VConst(ZERO, b); 
+    return(0);
+  }
+
+  /* Set vectors ycur and fcur for use by the Atimes and Psolve routines */
+  arkspils_mem->s_ycur = ynow;
+  arkspils_mem->s_fcur = fnow;
+
+  /* Set inputs delta and initial guess x = 0 to SpfgmrSolve */  
+  arkspils_mem->s_delta = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SpfgmrSolve and copy x to b */
+  retval = SpfgmrSolve(spfgmr_mem, ark_mem, arkspils_mem->s_x, b, 
+		       arkspils_mem->s_pretype, arkspils_mem->s_gstype, 
+		       arkspils_mem->s_delta, 0, arkspils_mem->s_maxl, 
+		       ark_mem, weight, weight, ARKSpilsAtimes, 
+		       ARKSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPFGMR_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      kry  %19.16g  %19.16g  %i  %i\n", 
+	    bnorm, res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SpfgmrSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPFGMR_SUCCESS:
+    return(0);
+    break;
+  case SPFGMR_RES_REDUCED:
+    /* allow reduction but not solution on first Newton iteration, 
+       otherwise return with a recoverable failure */
+    if (ark_mem->ark_mnewt == 0) return(0);
+    else                         return(1);
+    break;
+  case SPFGMR_CONV_FAIL:
+    return(1);
+    break;
+  case SPFGMR_QRFACT_FAIL:
+    return(1);
+    break;
+  case SPFGMR_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPFGMR_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPFGMR_MEM_NULL:
+    return(-1);
+    break;
+  case SPFGMR_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPFGMR_ATIMES_FAIL_UNREC, "ARKSPFGMR", 
+		    "ARKSpfgmrSolve", MSGS_JTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPFGMR_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPFGMR_PSOLVE_FAIL_UNREC, "ARKSPFGMR", 
+		    "ARKSpfgmrSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  case SPFGMR_GS_FAIL:
+    return(-1);
+    break;
+  case SPFGMR_QRSOL_FAIL:
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpfgmrFree:
+
+ This routine frees memory specific to the Spfgmr linear solver.
+---------------------------------------------------------------*/
+static int ARKSpfgmrFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  SpfgmrMem spfgmr_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  spfgmr_mem = (SpfgmrMem) arkspils_mem->s_spils_mem;
+  SpfgmrFree(spfgmr_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+
+
+/*---------------------------------------------------------------
+ ARKMassSpfgmr:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Spfgmr mass matrix solver 
+ module. ARKMassSpfgmr first calls the existing mfree routine if 
+ this is not NULL.  It then sets the ark_minit, ark_msetup, 
+ ark_msolve, ark_mfree fields in (*arkode_mem) to be 
+ ARKMassSpfgmrInit, ARKMassSpfgmrSetup, ARKMassSpfgmrSolve, and 
+ ARKMassSpfgmrFree, respectively.  It allocates memory for a 
+ structure of type ARKSpilsMassMemRec and sets the ark_mass_mem
+ field in (*arkode_mem) to the address of this structure.  It 
+ sets MassSetupNonNull in (*arkode_mem), and sets various fields
+ in the ARKSpilsMassMemRec structure, allocates memory for ytemp 
+ and x, and calls SpfgmrMalloc to allocate memory for the Spfgmr 
+ solver.
+---------------------------------------------------------------*/
+int ARKMassSpfgmr(void *arkode_mem, int pretype, int maxl, 
+		  ARKSpilsMassTimesVecFn mtimes, void *mtimes_data)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  SpfgmrMem spfgmr_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPFGMR", 
+		    "ARKMassSpfgmr", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd is present */
+  if(ark_mem->ark_tempv->ops->nvdotprod == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPFGMR", 
+		    "ARKMassSpfgmr", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = ARKMassSpfgmrInit;
+  ark_mem->ark_msetup = ARKMassSpfgmrSetup;
+  ark_mem->ark_msolve = ARKMassSpfgmrSolve;
+  ark_mem->ark_mfree  = ARKMassSpfgmrFree;
+  ark_mem->ark_msolve_type = 0;
+
+  /* Get memory for ARKSpilsMassMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMassMem) malloc(sizeof(struct ARKSpilsMassMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKMassSpfgmr", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set mass-matrix-vector product routine */
+  ark_mem->ark_mtimes      = mtimes;
+  ark_mem->ark_mtimes_data = mtimes_data;
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPFGMR;
+
+  /* Set Spfgmr parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype    = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Set default values for the rest of the Spfgmr parameters */
+  arkspils_mem->s_gstype        = MODIFIED_GS;
+  arkspils_mem->s_eplifac       = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag     = ARKSPILS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPFGMR", 
+		    "ARKMassSpfgmr", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKMassSpfgmr", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKMassSpfgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt( N_VDotProd(arkspils_mem->s_ytemp, 
+					    arkspils_mem->s_ytemp) );
+
+  /* Call SpfgmrMalloc to allocate workspace for Spfgmr */
+  spfgmr_mem = NULL;
+  spfgmr_mem = SpfgmrMalloc(mxl, ark_mem->ark_tempv);
+  if (spfgmr_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPFGMR", 
+		    "ARKMassSpfgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPFGMR memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) spfgmr_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpfgmrInit:
+
+ This routine does remaining initializations specific to the 
+ Spfgmr linear solver.
+---------------------------------------------------------------*/
+static int ARKMassSpfgmrInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) 
+      && (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPFGMR", "ARKMassSpfgmrInit", 
+		    MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set MassSetupNonNull=TRUE iff there is preconditioning 
+     (pretype != PREC_NONE) and there is a preconditioning 
+     setup phase (pset != NULL)             */
+  ark_mem->ark_MassSetupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpfgmrSetup:
+
+ This routine does the setup operations for the Spfgmr mass
+ matrix solver. It calls pset, and increments npe.
+---------------------------------------------------------------*/
+static int ARKMassSpfgmrSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			      N_Vector vtemp2, N_Vector vtemp3)
+{
+  int  retval;
+  ARKSpilsMassMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Call pset routine */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, 
+				arkspils_mem->s_P_data, 
+				vtemp1, vtemp2, vtemp3);
+  arkspils_mem->s_npe++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPFGMR_PSET_FAIL_UNREC, "ARKSPFGMR", 
+		    "ARKMassSpfgmrSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPFGMR_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) 
+    arkspils_mem->s_last_flag = SPFGMR_PSET_FAIL_REC;
+  if (retval == 0)
+    arkspils_mem->s_last_flag = SPFGMR_SUCCESS;
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpfgmrSolve:
+
+ This routine handles the call to the generic solver SpfgmrSolve
+ for the solution of the mass matrix system Mx = b with the 
+ SPFGMR method, without restarts.  The solution x is returned in 
+ the vector b.
+
+ We set the tolerance parameter and initial guess (x = 0), call 
+ SpfgmrSolve, and copy the solution x into b.  The x-scaling and 
+ b-scaling arrays are both equal to weight, and no restarts are
+ allowed.
+
+ The counters nli, nps, and ncfl are incremented, and the return
+ value is set according to the success of SpfgmrSolve.
+---------------------------------------------------------------*/
+static int ARKMassSpfgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			      N_Vector weight)
+{
+  realtype res_norm;
+  ARKSpilsMassMem arkspils_mem;
+  SpfgmrMem spfgmr_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  spfgmr_mem = (SpfgmrMem) arkspils_mem->s_spils_mem;
+
+  /* Set inputs delta and initial guess x = 0 to SpfgmrSolve */  
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_nlscoef; 
+  arkspils_mem->s_delta  = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SpfgmrSolve and copy x to b */
+  retval = SpfgmrSolve(spfgmr_mem, ark_mem, arkspils_mem->s_x, b, 
+		       arkspils_mem->s_pretype, arkspils_mem->s_gstype, 
+		       arkspils_mem->s_delta, 0, arkspils_mem->s_maxl, 
+		       ark_mem, weight, weight, ARKSpilsMtimes, 
+		       ARKSpilsMPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPFGMR_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      mass  %19.16g  %i  %i\n", 
+	    res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SpfgmrSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPFGMR_SUCCESS:
+    return(0);
+    break;
+  case SPFGMR_RES_REDUCED:
+    return(1);
+    break;
+  case SPFGMR_CONV_FAIL:
+    return(1);
+    break;
+  case SPFGMR_QRFACT_FAIL:
+    return(1);
+    break;
+  case SPFGMR_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPFGMR_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPFGMR_MEM_NULL:
+    return(-1);
+    break;
+  case SPFGMR_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPFGMR_ATIMES_FAIL_UNREC, "ARKSPFGMR", 
+		    "ARKMassSpfgmrSolve", MSGS_MTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPFGMR_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPFGMR_PSOLVE_FAIL_UNREC, "ARKSPFGMR", 
+		    "ARKMassSpfgmrSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  case SPFGMR_GS_FAIL:
+    return(-1);
+    break;
+  case SPFGMR_QRSOL_FAIL:
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpfgmrFree:
+
+ This routine frees memory specific to the Spfgmr linear solver.
+---------------------------------------------------------------*/
+static int ARKMassSpfgmrFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  SpfgmrMem spfgmr_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  spfgmr_mem = (SpfgmrMem) arkspils_mem->s_spils_mem;
+  SpfgmrFree(spfgmr_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+    EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_spgmr.c b/src/arkode/arkode_spgmr.c
new file mode 100644
index 0000000..4e4d360
--- /dev/null
+++ b/src/arkode/arkode_spgmr.c
@@ -0,0 +1,779 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the ARKSPGMR linear solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_spgmr.h>
+#include "arkode_spils_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_spgmr.h>
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* ARKSPGMR linit, lsetup, lsolve, and lfree routines */
+static int ARKSpgmrInit(ARKodeMem ark_mem);
+static int ARKSpgmrSetup(ARKodeMem ark_mem, int convfail, 
+			 N_Vector ypred, N_Vector fpred, 
+			 booleantype *jcurPtr, N_Vector vtemp1,
+			 N_Vector vtemp2, N_Vector vtemp3);
+static int ARKSpgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			 N_Vector weight, N_Vector ynow, 
+			 N_Vector fnow);
+static int ARKSpgmrFree(ARKodeMem ark_mem);
+
+/* ARKSPGMR minit, msetup, msolve, and mfree routines */
+static int ARKMassSpgmrInit(ARKodeMem ark_mem);
+static int ARKMassSpgmrSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			     N_Vector vtemp2, N_Vector vtemp3);
+static int ARKMassSpgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight);
+static int ARKMassSpgmrFree(ARKodeMem ark_mem);
+
+
+/*---------------------------------------------------------------
+ ARKSpgmr:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Spgmr linear solver module. 
+ ARKSpgmr first calls the existing lfree routine if this is not 
+ NULL.  It then sets the ark_linit, ark_lsetup, ark_lsolve, 
+ ark_lfree fields in (*arkode_mem) to be ARKSpgmrInit, 
+ ARKSpgmrSetup, ARKSpgmrSolve, and ARKSpgmrFree, respectively.  
+ It allocates memory for a structure of type ARKSpilsMemRec and
+ sets the ark_lmem field in (*arkode_mem) to the address of this
+ structure.  It sets setupNonNull in (*arkode_mem), and sets 
+ various fields in the ARKSpilsMemRec structure. Finally, 
+ ARKSpgmr allocates memory for ytemp and x, and calls
+ SpgmrMalloc to allocate memory for the Spgmr solver.
+---------------------------------------------------------------*/
+int ARKSpgmr(void *arkode_mem, int pretype, int maxl)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  SpgmrMem spgmr_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPGMR", 
+		    "ARKSpgmr", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd and N_VProd are present */
+  if ((ark_mem->ark_tempv->ops->nvdotprod == NULL) ||
+      (ark_mem->ark_tempv->ops->nvprod == NULL)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPGMR", 
+		    "ARKSpgmr", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */
+  ark_mem->ark_linit  = ARKSpgmrInit;
+  ark_mem->ark_lsetup = ARKSpgmrSetup;
+  ark_mem->ark_lsolve = ARKSpgmrSolve;
+  ark_mem->ark_lfree  = ARKSpgmrFree;
+  ark_mem->ark_lsolve_type = 0;
+
+  /* Get memory for ARKSpilsMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMem) malloc(sizeof(struct ARKSpilsMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKSpgmr", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPGMR;
+
+  /* Set Spgmr parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype    = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for Jacobian-related fields */
+  arkspils_mem->s_jtimesDQ = TRUE;
+  arkspils_mem->s_jtimes   = NULL;
+  arkspils_mem->s_j_data   = NULL;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Set default values for the rest of the Spgmr parameters */
+  arkspils_mem->s_gstype = MODIFIED_GS;
+  arkspils_mem->s_eplifac = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag  = ARKSPILS_SUCCESS;
+  ark_mem->ark_setupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPGMR", 
+		    "ARKSpgmr", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKSpgmr", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKSpgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt( N_VDotProd(arkspils_mem->s_ytemp, 
+					    arkspils_mem->s_ytemp) );
+
+  /* Call SpgmrMalloc to allocate workspace for Spgmr */
+  spgmr_mem = NULL;
+  spgmr_mem = SpgmrMalloc(mxl, ark_mem->ark_tempv);
+  if (spgmr_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKSpgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPGMR memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) spgmr_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpgmrInit:
+
+ This routine does remaining initializations specific to the Spgmr 
+ linear solver.
+---------------------------------------------------------------*/
+static int ARKSpgmrInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) 
+      && (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPGMR", "ARKSpgmrInit", 
+		    MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set setupNonNull = TRUE iff there is preconditioning (pretype != PREC_NONE)
+     and there is a preconditioning setup phase (pset != NULL)             */
+  ark_mem->ark_setupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  /* Set Jacobian-related fields, based on jtimesDQ */
+  if (arkspils_mem->s_jtimesDQ) {
+    arkspils_mem->s_jtimes = ARKSpilsDQJtimes;
+    arkspils_mem->s_j_data = ark_mem;
+  } else {
+    arkspils_mem->s_j_data = ark_mem->ark_user_data;
+  }
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpgmrSetup:
+
+ This routine does the setup operations for the Spgmr linear 
+ solver. It makes a decision as to whether or not to signal for 
+ re-evaluation of Jacobian data in the pset routine, based on 
+ various state variables, then it calls pset.  If we signal for 
+ re-evaluation, then we reset jcur = *jcurPtr to TRUE, regardless 
+ of the pset output. In any case, if jcur == TRUE, we increment 
+ npe and save nst in nstlpre.
+---------------------------------------------------------------*/
+static int ARKSpgmrSetup(ARKodeMem ark_mem, int convfail, 
+			 N_Vector ypred, N_Vector fpred, 
+			 booleantype *jcurPtr, N_Vector vtemp1,
+			 N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma;
+  int  retval;
+  ARKSpilsMem arkspils_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkspils_mem->s_nstlpre + ARKSPILS_MSBPRE) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKSPILS_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  *jcurPtr = jbad;
+  jok = !jbad;
+
+  /* Call pset routine and possibly reset jcur */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, ypred, fpred, jok, 
+				jcurPtr, ark_mem->ark_gamma, 
+				arkspils_mem->s_P_data, vtemp1, 
+				vtemp2, vtemp3);
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPGMR_PSET_FAIL_UNREC, "ARKSPGMR", 
+		    "ARKSpgmrSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPGMR_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = SPGMR_PSET_FAIL_REC;
+  }
+
+  if (jbad) *jcurPtr = TRUE;
+
+  /* If jcur = TRUE, increment npe and save nst value */
+  if (*jcurPtr) {
+    arkspils_mem->s_npe++;
+    arkspils_mem->s_nstlpre = ark_mem->ark_nst;
+  }
+
+  arkspils_mem->s_last_flag = SPGMR_SUCCESS;
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpgmrSolve:
+
+ This routine handles the call to the generic solver SpgmrSolve
+ for the solution of the linear system Ax = b with the SPGMR 
+ method, without restarts.  The solution x is returned in the 
+ vector b.
+
+ If the WRMS norm of b is small, we return x = b (if this is the 
+ first Newton iteration) or x = 0 (if a later Newton iteration).
+
+ Otherwise, we set the tolerance parameter and initial guess 
+ (x = 0), call SpgmrSolve, and copy the solution x into b.  The 
+ x-scaling and b-scaling arrays are both equal to weight, and no 
+ restarts are allowed.
+
+ The counters nli, nps, and ncfl are incremented, and the return
+ value is set according to the success of SpgmrSolve.  The 
+ success flag is returned if SpgmrSolve converged, or if this is 
+ the first Newton iteration and the residual norm was reduced 
+ below its initial value.
+---------------------------------------------------------------*/
+static int ARKSpgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			 N_Vector weight, N_Vector ynow, 
+			 N_Vector fnow)
+{
+  realtype bnorm, res_norm;
+  ARKSpilsMem arkspils_mem;
+  SpgmrMem spgmr_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  spgmr_mem = (SpgmrMem) arkspils_mem->s_spils_mem;
+
+  /* Test norm(b); if small, return x = 0 or x = b */
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_eRNrm; 
+  bnorm = N_VWrmsNorm(b, weight);
+  if (bnorm <= arkspils_mem->s_deltar) {
+    if (ark_mem->ark_mnewt > 0) N_VConst(ZERO, b); 
+    return(0);
+  }
+
+  /* Set vectors ycur and fcur for use by the Atimes and Psolve routines */
+  arkspils_mem->s_ycur = ynow;
+  arkspils_mem->s_fcur = fnow;
+
+  /* Set inputs delta and initial guess x = 0 to SpgmrSolve */  
+  arkspils_mem->s_delta = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SpgmrSolve and copy x to b */
+  retval = SpgmrSolve(spgmr_mem, ark_mem, arkspils_mem->s_x, b, 
+		      arkspils_mem->s_pretype, arkspils_mem->s_gstype, 
+		      arkspils_mem->s_delta, 0, ark_mem, weight, weight, 
+		      ARKSpilsAtimes, ARKSpilsPSolve, &res_norm, 
+		      &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPGMR_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      kry  %19.16g  %19.16g  %i  %i\n", 
+	    bnorm, res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SpgmrSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPGMR_SUCCESS:
+    return(0);
+    break;
+  case SPGMR_RES_REDUCED:
+    /* allow reduction but not solution on first Newton iteration, 
+       otherwise return with a recoverable failure */
+    if (ark_mem->ark_mnewt == 0) return(0);
+    else                         return(1);
+    break;
+  case SPGMR_CONV_FAIL:
+    return(1);
+    break;
+  case SPGMR_QRFACT_FAIL:
+    return(1);
+    break;
+  case SPGMR_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPGMR_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPGMR_MEM_NULL:
+    return(-1);
+    break;
+  case SPGMR_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPGMR_ATIMES_FAIL_UNREC, "ARKSPGMR", 
+		    "ARKSpgmrSolve", MSGS_JTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPGMR_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPGMR_PSOLVE_FAIL_UNREC, "ARKSPGMR", 
+		    "ARKSpgmrSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  case SPGMR_GS_FAIL:
+    return(-1);
+    break;
+  case SPGMR_QRSOL_FAIL:
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpgmrFree:
+
+ This routine frees memory specific to the Spgmr linear solver.
+---------------------------------------------------------------*/
+static int ARKSpgmrFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  SpgmrMem spgmr_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  spgmr_mem = (SpgmrMem) arkspils_mem->s_spils_mem;
+  SpgmrFree(spgmr_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+
+/*---------------------------------------------------------------
+ ARKMassSpgmr:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Spgmr mass matrix solver module. 
+ ARKMassSpgmr first calls the existing mfree routine if this is 
+ not NULL.  It then sets the ark_minit, ark_msetup, ark_msolve, 
+ ark_mfree fields in (*arkode_mem) to be ARKMassSpgmrInit, 
+ ARKMassSpgmrSetup, ARKMassSpgmrSolve, and ARKMassSpgmrFree, 
+ respectively.  It allocates memory for a structure of type 
+ ARKSpilsMassMemRec and sets the ark_mass_mem field in 
+ (*arkode_mem) to the address of this structure.  It sets 
+ MassSetupNonNull in (*arkode_mem), and sets various fields in
+ the ARKSpilsMassMemRec structure, allocates memory for ytemp
+ and x, and calls SpgmrMalloc to allocate memory for the Spgmr 
+ solver.
+---------------------------------------------------------------*/
+int ARKMassSpgmr(void *arkode_mem, int pretype, int maxl, 
+		 ARKSpilsMassTimesVecFn mtimes, void *mtimes_data)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  SpgmrMem spgmr_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPGMR", 
+		    "ARKMassSpgmr", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd is present */
+  if(ark_mem->ark_tempv->ops->nvdotprod == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPGMR", 
+		    "ARKMassSpgmr", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = ARKMassSpgmrInit;
+  ark_mem->ark_msetup = ARKMassSpgmrSetup;
+  ark_mem->ark_msolve = ARKMassSpgmrSolve;
+  ark_mem->ark_mfree  = ARKMassSpgmrFree;
+  ark_mem->ark_msolve_type = 0;
+
+  /* Get memory for ARKSpilsMassMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMassMem) malloc(sizeof(struct ARKSpilsMassMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKMassSpgmr", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set mass-matrix-vector product routine */
+  ark_mem->ark_mtimes      = mtimes;
+  ark_mem->ark_mtimes_data = mtimes_data;
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPGMR;
+
+  /* Set Spgmr parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype    = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Set default values for the rest of the Spgmr parameters */
+  arkspils_mem->s_gstype        = MODIFIED_GS;
+  arkspils_mem->s_eplifac       = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag     = ARKSPILS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPGMR", 
+		    "ARKMassSpgmr", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKMassSpgmr", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKMassSpgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt( N_VDotProd(arkspils_mem->s_ytemp, 
+					    arkspils_mem->s_ytemp) );
+
+  /* Call SpgmrMalloc to allocate workspace for Spgmr */
+  spgmr_mem = NULL;
+  spgmr_mem = SpgmrMalloc(mxl, ark_mem->ark_tempv);
+  if (spgmr_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPGMR", 
+		    "ARKMassSpgmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPGMR memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) spgmr_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpgmrInit:
+
+ This routine does remaining initializations specific to the Spgmr 
+ linear solver.
+---------------------------------------------------------------*/
+static int ARKMassSpgmrInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) 
+      && (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPGMR", 
+		    "ARKMassSpgmrInit", MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set MassSetupNonNull = TRUE iff there is preconditioning
+     (pretype != PREC_NONE) and there is a preconditioning setup 
+     phase (pset != NULL)             */
+  ark_mem->ark_MassSetupNonNull = (arkspils_mem->s_pretype != PREC_NONE) 
+    && (arkspils_mem->s_pset != NULL);
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpgmrSetup:
+
+ This routine does the setup operations for the Spgmr mass matrix
+ solver. It calls pset and increments npe.
+---------------------------------------------------------------*/
+static int ARKMassSpgmrSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			     N_Vector vtemp2, N_Vector vtemp3)
+{
+  int  retval;
+  ARKSpilsMassMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Call pset routine */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, 
+				arkspils_mem->s_P_data, 
+				vtemp1, vtemp2, vtemp3);
+  arkspils_mem->s_npe++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPGMR_PSET_FAIL_UNREC, "ARKSPGMR", 
+		    "ARKMassSpgmrSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPGMR_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = SPGMR_PSET_FAIL_REC;
+  }
+  if (retval == 0) {
+    arkspils_mem->s_last_flag = SPGMR_SUCCESS;
+  }
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpgmrSolve:
+
+ This routine handles the call to the generic solver SpgmrSolve
+ for the solution of the mass matrix system Mx = b with the SPGMR 
+ method, without restarts.  The solution x is returned in the 
+ vector b.
+
+ We set the tolerance parameter and initial guess (x = 0), call 
+ SpgmrSolve, and copy the solution x into b.  The x-scaling and 
+ b-scaling arrays are both equal to weight, and no restarts are
+ allowed.
+
+ The counters nli, nps, and ncfl are incremented, and the return
+ value is set according to the success of SpgmrSolve.
+---------------------------------------------------------------*/
+static int ARKMassSpgmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight)
+{
+  realtype res_norm;
+  ARKSpilsMassMem arkspils_mem;
+  SpgmrMem spgmr_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  spgmr_mem = (SpgmrMem) arkspils_mem->s_spils_mem;
+
+  /* Set inputs delta and initial guess x = 0 to SpgmrSolve */  
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_nlscoef; 
+  arkspils_mem->s_delta  = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SpgmrSolve and copy x to b */
+  retval = SpgmrSolve(spgmr_mem, ark_mem, arkspils_mem->s_x, b, 
+		      arkspils_mem->s_pretype, arkspils_mem->s_gstype, 
+		      arkspils_mem->s_delta, 0, ark_mem, weight, weight, 
+		      ARKSpilsMtimes, ARKSpilsMPSolve, &res_norm, 
+		      &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPGMR_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      mass  %19.16g  %i  %i\n", 
+	    res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SpgmrSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPGMR_SUCCESS:
+    return(0);
+    break;
+  case SPGMR_RES_REDUCED:
+    return(1);
+    break;
+  case SPGMR_CONV_FAIL:
+    return(1);
+    break;
+  case SPGMR_QRFACT_FAIL:
+    return(1);
+    break;
+  case SPGMR_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPGMR_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPGMR_MEM_NULL:
+    return(-1);
+    break;
+  case SPGMR_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPGMR_ATIMES_FAIL_UNREC, "ARKSPGMR", 
+		    "ARKMassSpgmrSolve", MSGS_MTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPGMR_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPGMR_PSOLVE_FAIL_UNREC, "ARKSPGMR", 
+		    "ARKMassSpgmrSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  case SPGMR_GS_FAIL:
+    return(-1);
+    break;
+  case SPGMR_QRSOL_FAIL:
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSpgmrFree:
+
+ This routine frees memory specific to the Spgmr linear solver.
+---------------------------------------------------------------*/
+static int ARKMassSpgmrFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  SpgmrMem spgmr_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  spgmr_mem = (SpgmrMem) arkspils_mem->s_spils_mem;
+  SpgmrFree(spgmr_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+    EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_spils.c b/src/arkode/arkode_spils.c
new file mode 100644
index 0000000..050cb49
--- /dev/null
+++ b/src/arkode/arkode_spils.c
@@ -0,0 +1,1191 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the ARKSPILS linear solvers.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode_impl.h"
+#include "arkode_spils_impl.h"
+
+/* constants */
+#define MAX_DQITERS  3  /* max. # of attempts to recover in DQ J*v */
+#define ZERO   RCONST(0.0)
+#define PT25   RCONST(0.25)
+#define ONE    RCONST(1.0)
+
+
+/*===============================================================
+   OPTIONAL INPUT and OUTPUT
+===============================================================*/
+
+/*---------------------------------------------------------------
+ ARKSpilsSetPrecType
+---------------------------------------------------------------*/
+int ARKSpilsSetPrecType(void *arkode_mem, int pretype)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetPrecType", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetPrecType", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE)  && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetPrecType", MSGS_BAD_PRETYPE);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  arkspils_mem->s_pretype = pretype;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetMassPrecType
+---------------------------------------------------------------*/
+int ARKSpilsSetMassPrecType(void *arkode_mem, int pretype)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassPrecType", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassPrecType", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE)  && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetMassPrecType", MSGS_BAD_PRETYPE);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  arkspils_mem->s_pretype = pretype;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetGSType
+---------------------------------------------------------------*/
+int ARKSpilsSetGSType(void *arkode_mem, int gstype)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetGSType", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetGSType", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  if ((arkspils_mem->s_type != SPILS_SPGMR) &&
+      (arkspils_mem->s_type != SPILS_SPFGMR)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetGSType", MSGS_BAD_LSTYPE);
+    fprintf(stderr,"solver type = %i\n",arkspils_mem->s_type);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Check for legal gstype */
+  if ((gstype != MODIFIED_GS) && (gstype != CLASSICAL_GS)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetGSType", MSGS_BAD_GSTYPE);
+    return(ARKSPILS_ILL_INPUT);
+  }
+  arkspils_mem->s_gstype = gstype;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetMassGSType
+---------------------------------------------------------------*/
+int ARKSpilsSetMassGSType(void *arkode_mem, int gstype)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassGSType", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassGSType", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  if ((arkspils_mem->s_type != SPILS_SPGMR) &&
+      (arkspils_mem->s_type != SPILS_SPFGMR)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetMassGSType", MSGS_BAD_LSTYPE);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Check for legal gstype */
+  if ((gstype != MODIFIED_GS) && (gstype != CLASSICAL_GS)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetMassGSType", MSGS_BAD_GSTYPE);
+    return(ARKSPILS_ILL_INPUT);
+  }
+  arkspils_mem->s_gstype = gstype;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ Function : ARKSpilsSetMaxl
+---------------------------------------------------------------*/
+int ARKSpilsSetMaxl(void *arkode_mem, int maxl)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMaxl", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(NULL, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMaxl", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  if ((arkspils_mem->s_type == SPILS_SPGMR) &&
+      (arkspils_mem->s_type == SPILS_SPFGMR)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetMaxl", MSGS_BAD_LSTYPE);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  mxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+  arkspils_mem->s_maxl = mxl;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ Function : ARKSpilsSetMassMaxl
+---------------------------------------------------------------*/
+int ARKSpilsSetMassMaxl(void *arkode_mem, int maxl)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassMaxl", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassMaxl", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  if ((arkspils_mem->s_type == SPILS_SPGMR) &&
+      (arkspils_mem->s_type == SPILS_SPFGMR)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetMassMaxl", MSGS_BAD_LSTYPE);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  mxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+  arkspils_mem->s_maxl = mxl;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetEpsLin
+---------------------------------------------------------------*/
+int ARKSpilsSetEpsLin(void *arkode_mem, realtype eplifac)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetEpsLin", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetEpsLin", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Check for legal eplifac */
+  if(eplifac < ZERO) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetEpsLin", MSGS_BAD_EPLIN);
+    return(ARKSPILS_ILL_INPUT);
+  }
+  arkspils_mem->s_eplifac = (eplifac == ZERO) ? ARKSPILS_EPLIN : eplifac;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetMassEpsLin
+---------------------------------------------------------------*/
+int ARKSpilsSetMassEpsLin(void *arkode_mem, realtype eplifac)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassEpsLin", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassEpsLin", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Check for legal eplifac */
+  if(eplifac < ZERO) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetMassEpsLin", MSGS_BAD_EPLIN);
+    return(ARKSPILS_ILL_INPUT);
+  }
+  arkspils_mem->s_eplifac = (eplifac == ZERO) ? ARKSPILS_EPLIN : eplifac;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetPreconditioner
+---------------------------------------------------------------*/
+int ARKSpilsSetPreconditioner(void *arkode_mem, 
+			      ARKSpilsPrecSetupFn pset, 
+			      ARKSpilsPrecSolveFn psolve)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetPreconditioner", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetPreconditioner", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  arkspils_mem->s_pset   = pset;
+  arkspils_mem->s_psolve = psolve;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetMassPreconditioner
+---------------------------------------------------------------*/
+int ARKSpilsSetMassPreconditioner(void *arkode_mem, 
+				  ARKSpilsMassPrecSetupFn pset, 
+				  ARKSpilsMassPrecSolveFn psolve)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassPreconditioner", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetMassPreconditioner", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  arkspils_mem->s_pset   = pset;
+  arkspils_mem->s_psolve = psolve;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetJacTimesVecFn
+---------------------------------------------------------------*/
+int ARKSpilsSetJacTimesVecFn(void *arkode_mem, 
+			     ARKSpilsJacTimesVecFn jtv)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetJacTimesVecFn", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetJacTimesVecFn", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  if (jtv != NULL) {
+    arkspils_mem->s_jtimesDQ = FALSE;
+    arkspils_mem->s_jtimes   = jtv;
+  } else {
+    arkspils_mem->s_jtimesDQ = TRUE;
+  }
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsSetMassTimesVecFn
+---------------------------------------------------------------*/
+int ARKSpilsSetMassTimesVecFn(void *arkode_mem, 
+			      ARKSpilsMassTimesVecFn mtv,
+			      void *mtimes_data)
+{
+  ARKodeMem ark_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsSetJacTimesVecFn", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (mtv == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPILS", 
+		    "ARKSpilsSetMassTimesVecFn", "non-NULL function must be supplied");
+    return(ARKSPILS_LMEM_NULL);
+  }
+
+  /* set arguments into ark_mem data structure */
+  ark_mem->ark_mtimes = mtv;
+  ark_mem->ark_mtimes_data = mtimes_data;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetWorkSpace
+---------------------------------------------------------------*/
+int ARKSpilsGetWorkSpace(void *arkode_mem, long int *lenrwLS, 
+			 long int *leniwLS)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  int maxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetWorkSpace", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetWorkSpace", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  switch(arkspils_mem->s_type) {
+  case SPILS_SPGMR:
+    maxl = arkspils_mem->s_maxl;
+    *lenrwLS = ark_mem->ark_lrw1*(maxl + 5) + maxl*(maxl + 4) + 1;
+    *leniwLS = ark_mem->ark_liw1*(maxl + 5);
+    break;
+  case SPILS_SPBCG:
+    *lenrwLS = ark_mem->ark_lrw1 * 9;
+    *leniwLS = ark_mem->ark_liw1 * 9;
+    break;
+  case SPILS_SPTFQMR:
+    *lenrwLS = ark_mem->ark_lrw1*11;
+    *leniwLS = ark_mem->ark_liw1*11;
+    break;
+  case SPILS_PCG:
+    *lenrwLS = ark_mem->ark_lrw1 * 4;
+    *leniwLS = ark_mem->ark_liw1 * 4 + 1;
+    break;
+  case SPILS_SPFGMR:
+    maxl = arkspils_mem->s_maxl;
+    *lenrwLS = ark_mem->ark_lrw1*(2*maxl + 4) + maxl*(maxl + 4) + 1;
+    *leniwLS = ark_mem->ark_liw1*(2*maxl + 4);
+    break;
+  }
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetMassWorkSpace
+---------------------------------------------------------------*/
+int ARKSpilsGetMassWorkSpace(void *arkode_mem, long int *lenrwMLS, 
+			     long int *leniwMLS)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  int maxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetMassWorkSpace", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetMassWorkSpace", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  switch(arkspils_mem->s_type) {
+  case SPILS_SPGMR:
+    maxl = arkspils_mem->s_maxl;
+    *lenrwMLS = ark_mem->ark_lrw1*(maxl + 5) + maxl*(maxl + 4) + 1;
+    *leniwMLS = ark_mem->ark_liw1*(maxl + 5);
+    break;
+  case SPILS_SPBCG:
+    *lenrwMLS = ark_mem->ark_lrw1 * 9;
+    *leniwMLS = ark_mem->ark_liw1 * 9;
+    break;
+  case SPILS_SPTFQMR:
+    *lenrwMLS = ark_mem->ark_lrw1*11;
+    *leniwMLS = ark_mem->ark_liw1*11;
+    break;
+  case SPILS_PCG:
+    *lenrwMLS = ark_mem->ark_lrw1 * 4;
+    *leniwMLS = ark_mem->ark_liw1 * 4 + 1;
+    break;
+  case SPILS_SPFGMR:
+    maxl = arkspils_mem->s_maxl;
+    *lenrwMLS = ark_mem->ark_lrw1*(2*maxl + 4) + maxl*(maxl + 4) + 1;
+    *leniwMLS = ark_mem->ark_liw1*(2*maxl + 4);
+    break;
+  }
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumPrecEvals
+---------------------------------------------------------------*/
+int ARKSpilsGetNumPrecEvals(void *arkode_mem, long int *npevals)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumPrecEvals", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumPrecEvals", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  *npevals = arkspils_mem->s_npe;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumMassPrecEvals
+---------------------------------------------------------------*/
+int ARKSpilsGetNumMassPrecEvals(void *arkode_mem, long int *npevals)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassPrecEvals", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassPrecEvals", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  *npevals = arkspils_mem->s_npe;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumPrecSolves
+---------------------------------------------------------------*/
+int ARKSpilsGetNumPrecSolves(void *arkode_mem, long int *npsolves)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumPrecSolves", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumPrecSolves", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  *npsolves = arkspils_mem->s_nps;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumMassPrecSolves
+---------------------------------------------------------------*/
+int ARKSpilsGetNumMassPrecSolves(void *arkode_mem, long int *npsolves)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassPrecSolves", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassPrecSolves", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  *npsolves = arkspils_mem->s_nps;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumLinIters
+---------------------------------------------------------------*/
+int ARKSpilsGetNumLinIters(void *arkode_mem, long int *nliters)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumLinIters", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumLinIters", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  *nliters = arkspils_mem->s_nli;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumMassIters
+---------------------------------------------------------------*/
+int ARKSpilsGetNumMassIters(void *arkode_mem, long int *nmiters)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassLinIters", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassLinIters", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  *nmiters = arkspils_mem->s_nli;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumConvFails
+---------------------------------------------------------------*/
+int ARKSpilsGetNumConvFails(void *arkode_mem, long int *nlcfails)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumConvFails", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumConvFails", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  *nlcfails = arkspils_mem->s_ncfl;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumMassConvFails
+---------------------------------------------------------------*/
+int ARKSpilsGetNumMassConvFails(void *arkode_mem, long int *nmcfails)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassConvFails", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMassConvFails", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  *nmcfails = arkspils_mem->s_ncfl;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumJtimesEvals
+---------------------------------------------------------------*/
+int ARKSpilsGetNumJtimesEvals(void *arkode_mem, long int *njvevals)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumJtimesEvals", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumJtimesEvals", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  *njvevals = arkspils_mem->s_njtimes;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumMtimesEvals
+---------------------------------------------------------------*/
+int ARKSpilsGetNumMtimesEvals(void *arkode_mem, long int *nmvevals)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMtimesEvals", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumMtimesEvals", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_mass_mem;
+
+  *nmvevals = arkspils_mem->s_njtimes;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetNumRhsEvals
+---------------------------------------------------------------*/
+int ARKSpilsGetNumRhsEvals(void *arkode_mem, long int *nfevalsLS)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumRhsEvals", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetNumRhsEvals", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  *nfevalsLS = arkspils_mem->s_nfes;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetLastFlag
+---------------------------------------------------------------*/
+int ARKSpilsGetLastFlag(void *arkode_mem, long int *flag)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetLastFlag", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_lmem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_LMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetLastFlag", MSGS_LMEM_NULL);
+    return(ARKSPILS_LMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  *flag = arkspils_mem->s_last_flag;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetLastMassFlag
+---------------------------------------------------------------*/
+int ARKSpilsGetLastMassFlag(void *arkode_mem, long int *flag)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetLastMassFlag", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  if (ark_mem->ark_mass_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MASSMEM_NULL, "ARKSPILS", 
+		    "ARKSpilsGetLastMassFlag", MSGS_MASSMEM_NULL);
+    return(ARKSPILS_MASSMEM_NULL);
+  }
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  *flag = arkspils_mem->s_last_flag;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsGetReturnFlagName
+---------------------------------------------------------------*/
+char *ARKSpilsGetReturnFlagName(long int flag)
+{
+  char *name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case ARKSPILS_SUCCESS:
+    sprintf(name,"ARKSPILS_SUCCESS");
+    break; 
+  case ARKSPILS_MEM_NULL:
+    sprintf(name,"ARKSPILS_MEM_NULL");
+    break;
+  case ARKSPILS_LMEM_NULL:
+    sprintf(name,"ARKSPILS_LMEM_NULL");
+    break;
+  case ARKSPILS_MASSMEM_NULL:
+    sprintf(name,"ARKSPILS_MASSMEM_NULL");
+    break;
+  case ARKSPILS_ILL_INPUT:
+    sprintf(name,"ARKSPILS_ILL_INPUT");
+    break;
+  case ARKSPILS_MEM_FAIL:
+    sprintf(name,"ARKSPILS_MEM_FAIL");
+    break;
+  case ARKSPILS_PMEM_NULL:
+    sprintf(name,"ARKSPILS_PMEM_NULL");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+
+/*===============================================================
+   ARKSPILS private functions
+===============================================================*/
+
+/*---------------------------------------------------------------
+ ARKSpilsAtimes:
+
+ This routine generates the matrix-vector product z = Av, where
+ A = M - gamma*J. The product M*v is obtained either by calling 
+ the mtimes routine or by just using v (if M=I).  The product 
+ J*v is obtained by calling the jtimes routine. It is then scaled 
+ by -gamma and added to M*v to obtain A*v. The return value is 
+ the same as the values returned by jtimes and mtimes -- 
+ 0 if successful, nonzero otherwise.
+---------------------------------------------------------------*/
+int ARKSpilsAtimes(void *arkode_mem, N_Vector v, N_Vector z)
+{
+  ARKodeMem   ark_mem;
+  ARKSpilsMem arkspils_mem;
+  int jtflag, mtflag;
+
+  ark_mem = (ARKodeMem) arkode_mem;
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  jtflag = arkspils_mem->s_jtimes(v, z, ark_mem->ark_tn, 
+				  arkspils_mem->s_ycur, 
+				  arkspils_mem->s_fcur, 
+				  arkspils_mem->s_j_data, 
+				  arkspils_mem->s_ytemp);
+  arkspils_mem->s_njtimes++;
+  if (jtflag != 0) return(jtflag);
+
+  /* Compute mass matrix vector product and add to result */
+  if (ark_mem->ark_mass_matrix) {
+    mtflag = ARKSpilsMtimes(arkode_mem, v, arkspils_mem->s_ytemp);
+    if (mtflag != 0) return(mtflag);
+    N_VLinearSum(ONE, arkspils_mem->s_ytemp, -ark_mem->ark_gamma, z, z);
+  } else {
+    N_VLinearSum(ONE, v, -ark_mem->ark_gamma, z, z);
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsPSolve:
+
+ This routine interfaces between the generic Sp***Solve routine
+ (within the SPGMR, SPBCG, SPTFQMR, SPFGMR or PCG solver) and the 
+ user's psolve routine.  It passes to psolve all required state 
+ information from arkode_mem.  Its return value is the same as 
+ that returned by psolve. Note that the generic SP*** solver 
+ guarantees that ARKSpilsPSolve will not be called in the case 
+ in which preconditioning is not done. This is the only case in 
+ which the user's psolve routine is allowed to be NULL.
+---------------------------------------------------------------*/
+int ARKSpilsPSolve(void *arkode_mem, N_Vector r, N_Vector z, int lr)
+{
+  ARKodeMem   ark_mem;
+  ARKSpilsMem arkspils_mem;
+  int retval;
+
+  ark_mem = (ARKodeMem) arkode_mem;
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* This call is counted in nps within the ARKSp***Solve routine */
+  retval = arkspils_mem->s_psolve(ark_mem->ark_tn, 
+				  arkspils_mem->s_ycur, 
+				  arkspils_mem->s_fcur, r, z, 
+				  ark_mem->ark_gamma, 
+				  arkspils_mem->s_delta, lr, 
+				  arkspils_mem->s_P_data, 
+				  arkspils_mem->s_ytemp);
+
+  return(retval);     
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsMtimes:
+
+ This routine generates the matrix-vector product z = Mv, where
+ M is the system mass matrix, by calling the user-supplied mtimes
+ routine.. The return value is the same as the value returned 
+ by mtimes -- 0 if successful, nonzero otherwise.
+---------------------------------------------------------------*/
+int ARKSpilsMtimes(void *arkode_mem, N_Vector v, N_Vector z)
+{
+  ARKodeMem ark_mem;
+  int retval;
+  ark_mem = (ARKodeMem) arkode_mem;
+  retval = ark_mem->ark_mtimes(v, z, ark_mem->ark_tn, 
+			       ark_mem->ark_mtimes_data);
+  ark_mem->ark_mass_mult++;
+
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsMPSolve:
+
+ This routine interfaces between the generic Sp***Solve routine
+ (within the SPGMR, SPBCG, SPTFQMR, SPFGMR or PCG solver) and the 
+ user's mass matrix psolve routine.  It passes to psolve all 
+ required state information from arkode_mem.  Its return value is
+ the same as that returned by psolve. Note that the generic SP*** 
+ solver guarantees that ARKSpilsMPSolve will not be called in the 
+ case in which preconditioning is not done. This is the only case 
+ in which the user's psolve routine is allowed to be NULL.
+---------------------------------------------------------------*/
+int ARKSpilsMPSolve(void *arkode_mem, N_Vector r, N_Vector z, int lr)
+{
+  ARKodeMem       ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  int retval;
+
+  ark_mem = (ARKodeMem) arkode_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* This call is counted in nps within the ARKSp***Solve routine */
+  retval = arkspils_mem->s_psolve(ark_mem->ark_tn, r, z, 
+				  arkspils_mem->s_delta, lr, 
+				  arkspils_mem->s_P_data, 
+				  arkspils_mem->s_ytemp);
+  return(retval);     
+}
+
+
+/*---------------------------------------------------------------
+ ARKSpilsDQJtimes:
+
+ This routine generates a difference quotient approximation to
+ the Jacobian times vector f_y(t,y) * v. The approximation is 
+ Jv = vnrm[f(y + v/vnrm) - f(y)], where vnrm = (WRMS norm of v) 
+ is input, i.e. the WRMS norm of v/vnrm is 1.
+---------------------------------------------------------------*/
+int ARKSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t, 
+		     N_Vector y, N_Vector fy,
+		     void *data, N_Vector work)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  realtype sig, siginv;
+  int iter, retval;
+
+  /* data is arkode_mem */
+  ark_mem = (ARKodeMem) data;
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Initialize perturbation to 1/||v|| */
+  sig = ONE/N_VWrmsNorm(v, ark_mem->ark_ewt);
+
+  for (iter=0; iter<MAX_DQITERS; iter++) {
+
+    /* Set work = y + sig*v */
+    N_VLinearSum(sig, v, ONE, y, work);
+
+    /* Set Jv = f(tn, y+sig*v) */
+    retval = ark_mem->ark_fi(t, work, Jv, ark_mem->ark_user_data); 
+    arkspils_mem->s_nfes++;
+    if (retval == 0) break;
+    if (retval < 0)  return(-1);
+
+    /* If fi failed recoverably, shrink sig and retry */
+    sig *= PT25;
+
+  }
+
+  /* If retval still isn't 0, return with a recoverable failure */
+  if (retval > 0) return(+1);
+
+  /* Replace Jv by (Jv - fy)/sig */
+  siginv = ONE/sig;
+  N_VLinearSum(siginv, Jv, -siginv, fy, Jv);
+
+  return(0);
+}
+
+
+int arkSpilsInitializeCounters(ARKSpilsMem arkspils_mem)
+{
+  arkspils_mem->s_npe     = 0;
+  arkspils_mem->s_nli     = 0;
+  arkspils_mem->s_nps     = 0;
+  arkspils_mem->s_ncfl    = 0;
+  arkspils_mem->s_nstlpre = 0;
+  arkspils_mem->s_njtimes = 0;
+  arkspils_mem->s_nfes    = 0;
+  return(0); 
+}
+
+
+/*---------------------------------------------------------------
+    EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_spils_impl.h b/src/arkode/arkode_spils_impl.h
new file mode 100644
index 0000000..7703e46
--- /dev/null
+++ b/src/arkode/arkode_spils_impl.h
@@ -0,0 +1,192 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Common implementation header file for the scaled, preconditioned
+ * linear solver modules.
+ *--------------------------------------------------------------*/
+
+#ifndef _ARKSPILS_IMPL_H
+#define _ARKSPILS_IMPL_H
+
+#include <arkode/arkode_spils.h>
+#include "arkode_impl.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+
+/* Types of iterative linear solvers */
+#define SPILS_SPGMR   1
+#define SPILS_SPBCG   2
+#define SPILS_SPTFQMR 3
+#define SPILS_PCG     4
+#define SPILS_SPFGMR  5
+
+
+/*---------------------------------------------------------------
+ Types: ARKSpilsMemRec, ARKSpilsMem
+
+ The type ARKSpilsMem is pointer to a ARKSpilsMemRec.
+---------------------------------------------------------------*/
+typedef struct ARKSpilsMemRec {
+
+  int s_type;           /* type of scaled preconditioned iterative LS   */
+
+  int  s_pretype;       /* type of preconditioning                      */
+  int  s_gstype;        /* type of Gram-Schmidt orthogonalization       */
+  realtype s_sqrtN;     /* sqrt(N)                                      */
+  realtype s_eplifac;   /* eplifac = user specified or EPLIN_DEFAULT    */
+  realtype s_deltar;    /* deltar = delt * LTE                          */
+  realtype s_delta;     /* delta = deltar * sqrtN                       */
+  int  s_maxl;          /* maxl = maximum dimension of the Krylov space */
+
+  long int s_nstlpre;   /* value of nst at the last pset call           */
+  long int s_npe;       /* npe = total number of pset calls             */
+  long int s_nli;       /* nli = total number of linear iterations      */
+  long int s_nps;       /* nps = total number of psolve calls           */
+  long int s_ncfl;      /* ncfl = total number of convergence failures  */
+  long int s_njtimes;   /* njtimes = total number of calls to jtimes    */
+  long int s_nfes;      /* nfeSG = total number of calls to f for     
+                           difference quotient Jacobian-vector products */
+
+  N_Vector s_ytemp;     /* temp vector passed to jtimes and psolve      */
+  N_Vector s_x;         /* temp vector used by ARKSpilsSolve            */
+  N_Vector s_ycur;      /* ARKODE current y vector in Newton Iteration  */
+  N_Vector s_fcur;      /* fcur = f(tn, ycur)                           */
+
+  void* s_spils_mem;    /* memory used by the generic solver            */
+
+  /* Preconditioner computation
+    (a) user-provided:
+        - P_data == user_data
+        - pfree == NULL (the user dealocates memory for user_data)
+    (b) internal preconditioner module
+        - P_data == arkode_mem
+        - pfree == set by the prec. module and called in ARKodeFree  */
+  ARKSpilsPrecSetupFn s_pset;
+  ARKSpilsPrecSolveFn s_psolve;
+  int (*s_pfree)(ARKodeMem ark_mem);
+  void *s_P_data;
+
+  /* Jacobian times vector compuation
+    (a) jtimes function provided by the user:
+        - j_data == user_data
+        - jtimesDQ == FALSE
+    (b) internal jtimes
+        - j_data == arkode_mem
+        - jtimesDQ == TRUE   */
+  booleantype s_jtimesDQ;
+  ARKSpilsJacTimesVecFn s_jtimes;
+  void *s_j_data;
+
+  long int s_last_flag; /* last error flag returned by any function     */
+
+} *ARKSpilsMem;
+
+
+/*---------------------------------------------------------------
+ Types: ARKSpilsMassMemRec, ARKSpilsMassMem
+
+ The type ARKSpilsMassMem is pointer to a ARKSpilsMassMemRec.
+---------------------------------------------------------------*/
+typedef struct ARKSpilsMassMemRec {
+
+  int s_type;           /* type of scaled preconditioned iterative LS   */
+
+  int  s_pretype;       /* type of preconditioning                      */
+  int  s_gstype;        /* type of Gram-Schmidt orthogonalization       */
+  realtype s_sqrtN;     /* sqrt(N)                                      */
+  realtype s_eplifac;   /* eplifac = user specified or EPLIN_DEFAULT    */
+  realtype s_deltar;    /* deltar = delt * LTE                          */
+  realtype s_delta;     /* delta = deltar * sqrtN                       */
+  int  s_maxl;          /* maxl = maximum dimension of the Krylov space */
+
+  long int s_npe;       /* npe = total number of pset calls             */
+  long int s_nli;       /* nli = total number of linear iterations      */
+  long int s_nps;       /* nps = total number of psolve calls           */
+  long int s_ncfl;      /* ncfl = total number of convergence failures  */
+
+  N_Vector s_ytemp;     /* temp vector passed to mtimes and psolve      */
+  N_Vector s_x;         /* temp vector used by ARKSpilsSolve            */
+  N_Vector s_ycur;      /* ARKODE current y vector                      */
+
+  void* s_spils_mem;    /* memory used by the generic solver            */
+
+  /* Preconditioner computation
+    (a) user-provided:
+        - P_data == user_data
+        - pfree == NULL (the user dealocates memory for user_data)
+    (b) internal preconditioner module
+        - P_data == arkode_mem
+        - pfree == set by the prec. module and called in ARKodeFree */
+  ARKSpilsMassPrecSetupFn s_pset;
+  ARKSpilsMassPrecSolveFn s_psolve;
+  int (*s_pfree)(ARKodeMem ark_mem);
+  void *s_P_data;
+
+  long int s_last_flag; /* last error flag returned by any function     */
+
+} *ARKSpilsMassMem;
+
+
+/*---------------------------------------------------------------
+ Prototypes of internal functions
+---------------------------------------------------------------*/
+
+/* Atimes and PSolve routines called by generic solver */
+int ARKSpilsAtimes(void *ark_mem, N_Vector v, N_Vector z);
+int ARKSpilsPSolve(void *ark_mem, N_Vector r, N_Vector z, int lr);
+
+/* Mtimes and MPSolve routines called by mass matrix solver */
+int ARKSpilsMtimes(void *ark_mem, N_Vector v, N_Vector z);
+int ARKSpilsMPSolve(void *ark_mem, N_Vector r, N_Vector z, int lr);
+
+/* Difference quotient approximation for Jac times vector */
+int ARKSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t,
+                     N_Vector y, N_Vector fy, void *data,
+                     N_Vector work);
+
+/* Auxilliary functions */
+int arkSpilsInitializeCounters(ARKSpilsMem arkspils_mem);
+
+
+/*---------------------------------------------------------------
+ Error Messages
+---------------------------------------------------------------*/
+#define MSGS_ARKMEM_NULL   "Integrator memory is NULL."
+#define MSGS_MEM_FAIL      "A memory request failed."
+#define MSGS_BAD_NVECTOR   "A required vector operation is not implemented."
+#define MSGS_BAD_LSTYPE    "Incompatible linear solver type."
+#define MSGS_BAD_PRETYPE   "Illegal value for pretype. Legal values are PREC_NONE, PREC_LEFT, PREC_RIGHT, and PREC_BOTH."
+#define MSGS_PSOLVE_REQ    "pretype != PREC_NONE, but PSOLVE = NULL is illegal."
+#define MSGS_LMEM_NULL     "Linear solver memory is NULL."
+#define MSGS_MASSMEM_NULL  "Mass matrix solver memory is NULL."
+#define MSGS_BAD_GSTYPE    "Illegal value for gstype. Legal values are MODIFIED_GS and CLASSICAL_GS."
+#define MSGS_BAD_EPLIN     "eplifac < 0 illegal."
+
+#define MSGS_PSET_FAILED   "The preconditioner setup routine failed in an unrecoverable manner."
+#define MSGS_PSOLVE_FAILED "The preconditioner solve routine failed in an unrecoverable manner."
+#define MSGS_JTIMES_FAILED "The Jacobian x vector routine failed in an unrecoverable manner."
+#define MSGS_MTIMES_FAILED "The mass matrix * vector routine failed in an unrecoverable manner."
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/arkode/arkode_sptfqmr.c b/src/arkode/arkode_sptfqmr.c
new file mode 100644
index 0000000..605093a
--- /dev/null
+++ b/src/arkode/arkode_sptfqmr.c
@@ -0,0 +1,767 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation file for the ARKSPTFQMR linear solver.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arkode/arkode_sptfqmr.h>
+#include "arkode_spils_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_sptfqmr.h>
+#include <sundials/sundials_math.h>
+
+/* Other Constants */
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/* ARKSPTFQMR linit, lsetup, lsolve, and lfree routines */
+static int ARKSptfqmrInit(ARKodeMem ark_mem);
+static int ARKSptfqmrSetup(ARKodeMem ark_mem, int convfail, N_Vector ypred,
+			   N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
+			   N_Vector vtemp2, N_Vector vtemp3);
+static int ARKSptfqmrSolve(ARKodeMem ark_mem, N_Vector b, N_Vector weight,
+			   N_Vector ynow, N_Vector fnow);
+static int ARKSptfqmrFree(ARKodeMem ark_mem);
+
+/* ARKSPTFQMR minit, msetup, msolve, and mfree routines */
+static int ARKMassSptfqmrInit(ARKodeMem ark_mem);
+static int ARKMassSptfqmrSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			       N_Vector vtemp2, N_Vector vtemp3);
+static int ARKMassSptfqmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			       N_Vector weight);
+static int ARKMassSptfqmrFree(ARKodeMem ark_mem);
+
+
+/*---------------------------------------------------------------
+ ARKSptfqmr:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Sptfqmr linear solver module. 
+ ARKSptfqmr first calls the existing lfree routine if this is not 
+ NULL. It then sets the ark_linit, ark_lsetup, ark_lsolve, 
+ ark_lfree fields in (*arkode_mem) to be ARKSptfqmrInit, 
+ ARKSptfqmrSetup, ARKSptfqmrSolve, and ARKSptfqmrFree,
+ respectively. It allocates memory for a structure of type
+ ARKSpilsMemRec and sets the ark_lmem field in (*arkode_mem) to 
+ the address of this structure. It sets setupNonNull in 
+ (*arkode_mem), and sets various fields in the ARKSpilsMemRec 
+ structure. Finally, ARKSptfqmr allocates memory for ytemp and 
+ x, and calls SptfqmrMalloc to allocate memory for the Sptfqmr 
+ solver.
+---------------------------------------------------------------*/
+int ARKSptfqmr(void *arkode_mem, int pretype, int maxl)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPTFQMR", 
+		    "ARKSptfqmr", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd and N_VProd are present */
+  if ((ark_mem->ark_tempv->ops->nvdotprod == NULL) ||
+      (ark_mem->ark_tempv->ops->nvprod == NULL)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPTFQMR", 
+		    "ARKSptfqmr", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem */
+  ark_mem->ark_linit  = ARKSptfqmrInit;
+  ark_mem->ark_lsetup = ARKSptfqmrSetup;
+  ark_mem->ark_lsolve = ARKSptfqmrSolve;
+  ark_mem->ark_lfree  = ARKSptfqmrFree;
+  ark_mem->ark_lsolve_type = 0;
+
+  /* Get memory for ARKSpilsMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMem) malloc(sizeof(struct ARKSpilsMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+                    "ARKSptfqmr", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPTFQMR;
+
+  /* Set Sptfqmr parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for Jacobian-related fields */
+  arkspils_mem->s_jtimesDQ = TRUE;
+  arkspils_mem->s_jtimes   = NULL;
+  arkspils_mem->s_j_data   = NULL;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Set default values for the rest of the Sptfqmr parameters */
+  arkspils_mem->s_eplifac = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  ark_mem->ark_setupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPTFQMR", 
+                    "ARKSptfqmr", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+		    "ARKSptfqmr", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+		    "ARKSptfqmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt(N_VDotProd(arkspils_mem->s_ytemp, 
+					   arkspils_mem->s_ytemp));
+
+  /* Call SptfqmrMalloc to allocate workspace for Sptfqmr */
+  sptfqmr_mem = NULL;
+  sptfqmr_mem = SptfqmrMalloc(mxl, ark_mem->ark_tempv);
+  if (sptfqmr_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+		    "ARKSptfqmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPTFQMR memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) sptfqmr_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_lmem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSptfqmrInit:
+
+ This routine does remaining initializations specific to the 
+ Sptfqmr linear solver.
+---------------------------------------------------------------*/
+static int ARKSptfqmrInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  sptfqmr_mem = (SptfqmrMem) arkspils_mem->s_spils_mem;
+
+  /* Initialize counters */
+  arkSpilsInitializeCounters(arkspils_mem);
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) && 
+      (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPTFQMR", "ARKSptfqmrInit", 
+                    MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set setupNonNull = TRUE iff there is preconditioning
+     (pretype != PREC_NONE)  and there is a preconditioning
+     setup phase (pset != NULL) */
+  ark_mem->ark_setupNonNull = (arkspils_mem->s_pretype != PREC_NONE) && 
+    (arkspils_mem->s_pset != NULL);
+
+  /* Set Jacobian-related fields, based on jtimesDQ */
+  if (arkspils_mem->s_jtimesDQ) {
+    arkspils_mem->s_jtimes = ARKSpilsDQJtimes;
+    arkspils_mem->s_j_data = ark_mem;
+  } else {
+    arkspils_mem->s_j_data = ark_mem->ark_user_data;
+  }
+
+  /* Set maxl in the SPTFQMR memory in case it was changed by the user */
+  sptfqmr_mem->l_max = arkspils_mem->s_maxl;
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+/*---------------------------------------------------------------
+ ARKSptfqmrSetup:
+
+ This routine does the setup operations for the Sptfqmr linear 
+ solver. It makes a decision as to whether or not to signal for 
+ reevaluation of Jacobian data in the pset routine, based on 
+ various state variables, then it calls pset. If we signal for 
+ reevaluation, then we reset jcur = *jcurPtr to TRUE, regardless 
+ of the pset output. In any case, if jcur == TRUE, we increment 
+ npe and save nst in nstlpre.
+---------------------------------------------------------------*/
+static int ARKSptfqmrSetup(ARKodeMem ark_mem, int convfail, 
+			   N_Vector ypred, N_Vector fpred, 
+			   booleantype *jcurPtr, N_Vector vtemp1,
+			   N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  realtype dgamma;
+  int  retval;
+  ARKSpilsMem arkspils_mem;
+
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arkspils_mem->s_nstlpre + ARKSPILS_MSBPRE) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKSPILS_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  *jcurPtr = jbad;
+  jok = !jbad;
+
+  /* Call pset routine and possibly reset jcur */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, ypred, fpred, jok, 
+				jcurPtr, ark_mem->ark_gamma, 
+				arkspils_mem->s_P_data, 
+				vtemp1, vtemp2, vtemp3);
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPTFQMR_PSET_FAIL_UNREC, "ARKSPTFQMR", 
+		    "ARKSptfqmrSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPTFQMR_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = SPTFQMR_PSET_FAIL_REC;
+  }
+
+  if (jbad) *jcurPtr = TRUE;
+
+  /* If jcur = TRUE, increment npe and save nst value */
+  if (*jcurPtr) {
+    arkspils_mem->s_npe++;
+    arkspils_mem->s_nstlpre = ark_mem->ark_nst;
+  }
+
+  arkspils_mem->s_last_flag = SPTFQMR_SUCCESS;
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSptfqmrSolve:
+
+ This routine handles the call to the generic solver SptfqmrSolve
+ for the solution of the linear system Ax = b with the SPTFQMR 
+ method. The solution x is returned in the vector b.
+
+ If the WRMS norm of b is small, we return x = b (if this is the 
+ first Newton iteration) or x = 0 (if a later Newton iteration).
+
+ Otherwise, we set the tolerance parameter and initial guess 
+ (x = 0), call SptfqmrSolve, and copy the solution x into b. The 
+ x-scaling and b-scaling arrays are both equal to weight.
+
+ The counters nli, nps, and ncfl are incremented, and the return 
+ value is set according to the success of SptfqmrSolve. The 
+ success flag is returned if SptfqmrSolve converged, or if this 
+ is the first Newton iteration and the residual norm was reduced 
+ below its initial value.
+---------------------------------------------------------------*/
+static int ARKSptfqmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			   N_Vector weight, N_Vector ynow, 
+			   N_Vector fnow)
+{
+  realtype bnorm, res_norm;
+  ARKSpilsMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+  int nli_inc, nps_inc, retval;
+  
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+  sptfqmr_mem = (SptfqmrMem) arkspils_mem->s_spils_mem;
+
+  /* Test norm(b); if small, return x = 0 */
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_eRNrm; 
+  bnorm = N_VWrmsNorm(b, weight);
+  if (bnorm <= arkspils_mem->s_deltar) {
+    if (ark_mem->ark_mnewt > 0) N_VConst(ZERO, b); 
+    return(0);
+  }
+
+  /* Set vectors ycur and fcur for use by the Atimes and Psolve routines */
+  arkspils_mem->s_ycur = ynow;
+  arkspils_mem->s_fcur = fnow;
+
+  /* Set inputs delta and initial guess x = 0 to SptfqmrSolve */  
+  arkspils_mem->s_delta = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SptfqmrSolve and copy x to b */
+  retval = SptfqmrSolve(sptfqmr_mem, ark_mem, arkspils_mem->s_x, b, 
+			arkspils_mem->s_pretype, arkspils_mem->s_delta,
+                        ark_mem, weight, weight, ARKSpilsAtimes, 
+			ARKSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPTFQMR_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      kry  %19.16g  %19.16g  %i  %i\n", 
+	    bnorm, res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SptfqmrSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPTFQMR_SUCCESS:
+    return(0);
+    break;
+  case SPTFQMR_RES_REDUCED:
+    /* allow reduction but not solution on first Newton iteration, 
+       otherwise return with a recoverable failure */
+    if (ark_mem->ark_mnewt == 0) return(0);
+    else                         return(1);
+    break;
+  case SPTFQMR_CONV_FAIL:
+    return(1);
+    break;
+  case SPTFQMR_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPTFQMR_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPTFQMR_MEM_NULL:
+    return(-1);
+    break;
+  case SPTFQMR_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPTFQMR_ATIMES_FAIL_UNREC, "ARKSPTFQMR", 
+		    "ARKSptfqmrSolve", MSGS_JTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPTFQMR_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPTFQMR_PSOLVE_FAIL_UNREC, "ARKSPTFQMR", 
+		    "ARKSptfqmrSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKSptfqmrFree:
+
+ This routine frees memory specific to the Sptfqmr linear solver.
+---------------------------------------------------------------*/
+static int ARKSptfqmrFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+    
+  arkspils_mem = (ARKSpilsMem) ark_mem->ark_lmem;
+
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  sptfqmr_mem = (SptfqmrMem) arkspils_mem->s_spils_mem;
+  SptfqmrFree(sptfqmr_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+/*---------------------------------------------------------------
+ ARKMassSptfqmr:
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the Sptfqmr mass matrix solver 
+ module. ARKMassSptfqmr first calls the existing mfree routine 
+ if this is not NULL. It then sets the ark_minit, ark_msetup, 
+ ark_msolve, ark_mfree fields in (*arkode_mem) to be 
+ ARKMassSptfqmrInit, ARKMassSptfqmrSetup, ARKMassSptfqmrSolve, 
+ and ARKMassSptfqmrFree, respectively. It allocates memory for a
+ structure of type ARKMassSpilsMemRec and sets the ark_mass_mem
+ field in (*arkode_mem) to the address of this structure. It sets 
+ MassSetupNonNull in (*arkode_mem), and sets various fields in 
+ the ARKSpilsMassMemRec structure, allocates memory for ytemp 
+ and x, and calls SptfqmrMalloc to allocate memory for the 
+ Sptfqmr solver.
+---------------------------------------------------------------*/
+int ARKMassSptfqmr(void *arkode_mem, int pretype, int maxl, 
+		   ARKSpilsMassTimesVecFn mtimes, void *mtimes_data)
+{
+  ARKodeMem ark_mem;
+  ARKSpilsMassMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+  int mxl;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSPILS_MEM_NULL, "ARKSPTFQMR", 
+		    "ARKMassSptfqmr", MSGS_ARKMEM_NULL);
+    return(ARKSPILS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Check if N_VDotProd is present */
+  if (ark_mem->ark_tempv->ops->nvdotprod == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPTFQMR", 
+		    "ARKMassSptfqmr", MSGS_BAD_NVECTOR);
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set four main function fields in ark_mem, enable mass matrix */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = ARKMassSptfqmrInit;
+  ark_mem->ark_msetup = ARKMassSptfqmrSetup;
+  ark_mem->ark_msolve = ARKMassSptfqmrSolve;
+  ark_mem->ark_mfree  = ARKMassSptfqmrFree;
+  ark_mem->ark_msolve_type = 0;
+
+  /* Get memory for ARKSpilsMassMemRec */
+  arkspils_mem = NULL;
+  arkspils_mem = (ARKSpilsMassMem) malloc(sizeof(struct ARKSpilsMassMemRec));
+  if (arkspils_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+		    "ARKMassSptfqmr", MSGS_MEM_FAIL);
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Set mass-matrix-vector product routine */
+  ark_mem->ark_mtimes      = mtimes;
+  ark_mem->ark_mtimes_data = mtimes_data;
+
+  /* Set ILS type */
+  arkspils_mem->s_type = SPILS_SPTFQMR;
+
+  /* Set Sptfqmr parameters that have been passed in call sequence */
+  arkspils_mem->s_pretype = pretype;
+  mxl = arkspils_mem->s_maxl = (maxl <= 0) ? ARKSPILS_MAXL : maxl;
+
+  /* Set defaults for preconditioner-related fields */
+  arkspils_mem->s_pset   = NULL;
+  arkspils_mem->s_psolve = NULL;
+  arkspils_mem->s_pfree  = NULL;
+  arkspils_mem->s_P_data = ark_mem->ark_user_data;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Set default values for the rest of the Sptfqmr parameters */
+  arkspils_mem->s_eplifac   = ARKSPILS_EPLIN;
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+
+  /* Disable call to msetup in ARKode solver (for now) */
+  ark_mem->ark_MassSetupNonNull = FALSE;
+
+  /* Check for legal pretype */ 
+  if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
+      (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
+    arkProcessError(ark_mem, ARKSPILS_ILL_INPUT, "ARKSPTFQMR", 
+		    "ARKMassSptfqmr", MSGS_BAD_PRETYPE);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_ILL_INPUT);
+  }
+
+  /* Allocate memory for ytemp and x */
+  arkspils_mem->s_ytemp = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_ytemp == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+		    "ARKMassSptfqmr", MSGS_MEM_FAIL);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  arkspils_mem->s_x = N_VClone(ark_mem->ark_tempv);
+  if (arkspils_mem->s_x == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+		    "ARKMassSptfqmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+
+  /* Compute sqrtN from a dot product */
+  N_VConst(ONE, arkspils_mem->s_ytemp);
+  arkspils_mem->s_sqrtN = SUNRsqrt(N_VDotProd(arkspils_mem->s_ytemp, 
+					   arkspils_mem->s_ytemp));
+
+  /* Call SptfqmrMalloc to allocate workspace for Sptfqmr */
+  sptfqmr_mem = NULL;
+  sptfqmr_mem = SptfqmrMalloc(mxl, ark_mem->ark_tempv);
+  if (sptfqmr_mem == NULL) {
+    arkProcessError(ark_mem, ARKSPILS_MEM_FAIL, "ARKSPTFQMR", 
+		    "ARKMassSptfqmr", MSGS_MEM_FAIL);
+    N_VDestroy(arkspils_mem->s_ytemp);
+    N_VDestroy(arkspils_mem->s_x);
+    free(arkspils_mem); arkspils_mem = NULL;
+    return(ARKSPILS_MEM_FAIL);
+  }
+  
+  /* Attach SPTFQMR memory to spils memory structure */
+  arkspils_mem->s_spils_mem = (void *) sptfqmr_mem;
+
+  /* Attach linear solver memory to integrator memory */
+  ark_mem->ark_mass_mem = arkspils_mem;
+
+  return(ARKSPILS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSptfqmrInit:
+
+ This routine does remaining initializations specific to the 
+ Sptfqmr linear solver.
+---------------------------------------------------------------*/
+static int ARKMassSptfqmrInit(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  sptfqmr_mem = (SptfqmrMem) arkspils_mem->s_spils_mem;
+
+  /* Initialize counters */
+  arkspils_mem->s_npe = arkspils_mem->s_nli  = 0;
+  arkspils_mem->s_nps = arkspils_mem->s_ncfl = 0;
+
+  /* Check for legal combination pretype - psolve */
+  if ((arkspils_mem->s_pretype != PREC_NONE) && 
+      (arkspils_mem->s_psolve == NULL)) {
+    arkProcessError(ark_mem, -1, "ARKSPTFQMR", "ARKMassSptfqmrInit", 
+		    MSGS_PSOLVE_REQ);
+    arkspils_mem->s_last_flag = ARKSPILS_ILL_INPUT;
+    return(-1);
+  }
+
+  /* Set MassSetupNonNull = TRUE iff there is preconditioning
+     (pretype != PREC_NONE)  and there is a preconditioning
+     setup phase (pset != NULL) */
+  ark_mem->ark_MassSetupNonNull = (arkspils_mem->s_pretype != PREC_NONE) && 
+    (arkspils_mem->s_pset != NULL);
+
+  /* Set maxl in the SPTFQMR memory in case it was changed by the user */
+  sptfqmr_mem->l_max = arkspils_mem->s_maxl;
+
+  arkspils_mem->s_last_flag = ARKSPILS_SUCCESS;
+  return(0);
+}
+
+/*---------------------------------------------------------------
+ ARKMassSptfqmrSetup:
+
+ This routine does the setup operations for the Sptfqmr mass 
+ matrix solver. It calls the setup routine and increments npe.
+---------------------------------------------------------------*/
+static int ARKMassSptfqmrSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+			       N_Vector vtemp2, N_Vector vtemp3)
+{
+  int  retval;
+  ARKSpilsMassMem arkspils_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  /* Call pset routine */
+  retval = arkspils_mem->s_pset(ark_mem->ark_tn, 
+				arkspils_mem->s_P_data, 
+				vtemp1, vtemp2, vtemp3);
+  arkspils_mem->s_npe++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, SPTFQMR_PSET_FAIL_UNREC, "ARKSPTFQMR", 
+		    "ARKMassSptfqmrSetup", MSGS_PSET_FAILED);
+    arkspils_mem->s_last_flag = SPTFQMR_PSET_FAIL_UNREC;
+  }
+  if (retval > 0) {
+    arkspils_mem->s_last_flag = SPTFQMR_PSET_FAIL_REC;
+  }
+  if (retval == 0) {
+    arkspils_mem->s_last_flag = SPTFQMR_SUCCESS;
+  }
+
+  /* Return the same value that pset returned */
+  return(retval);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSptfqmrSolve:
+
+ This routine handles the call to the generic solver SptfqmrSolve
+ for the solution of the mass matrix system Mx = b with the 
+ SPTFQMR method. The solution x is returned in the vector b.
+
+ We set the tolerance parameter and initial guess (x = 0), call 
+ SptfqmrSolve, and copy the solution x into b. The x-scaling and 
+ b-scaling arrays are both equal to weight.
+
+ The counters nli, nps, and ncfl are incremented, and the return 
+ value is set according to the success of SptfqmrSolve. The 
+ success flag is returned if SptfqmrSolve converged.
+---------------------------------------------------------------*/
+static int ARKMassSptfqmrSolve(ARKodeMem ark_mem, N_Vector b, 
+			       N_Vector weight)
+{
+  realtype res_norm;
+  ARKSpilsMassMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+  int nli_inc, nps_inc, retval;
+
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+  sptfqmr_mem = (SptfqmrMem) arkspils_mem->s_spils_mem;
+
+  /* Set inputs delta and initial guess x = 0 to SptfqmrSolve */  
+  arkspils_mem->s_deltar = arkspils_mem->s_eplifac * ark_mem->ark_nlscoef; 
+  arkspils_mem->s_delta  = arkspils_mem->s_deltar * arkspils_mem->s_sqrtN;
+  N_VConst(ZERO, arkspils_mem->s_x);
+  
+  /* Call SptfqmrSolve and copy x to b */
+  retval = SptfqmrSolve(sptfqmr_mem, ark_mem, arkspils_mem->s_x, b, 
+			arkspils_mem->s_pretype, arkspils_mem->s_delta,
+                        ark_mem, weight, weight, ARKSpilsMtimes, 
+			ARKSpilsMPSolve, &res_norm, &nli_inc, &nps_inc);
+  N_VScale(ONE, arkspils_mem->s_x, b);
+  
+  /* Increment counters nli, nps, and ncfl */
+  arkspils_mem->s_nli += nli_inc;
+  arkspils_mem->s_nps += nps_inc;
+  if (retval != SPTFQMR_SUCCESS) arkspils_mem->s_ncfl++;
+
+  /* Log solver statistics to diagnostics file (if requested) */
+  if (ark_mem->ark_report) 
+    fprintf(ark_mem->ark_diagfp, "      mass  %19.16g  %i  %i\n", 
+	    res_norm, nli_inc, nps_inc);
+  
+  /* Interpret return value from SptfqmrSolve */
+  arkspils_mem->s_last_flag = retval;
+
+  switch(retval) {
+
+  case SPTFQMR_SUCCESS:
+    return(0);
+    break;
+  case SPTFQMR_RES_REDUCED:
+    return(1);
+    break;
+  case SPTFQMR_CONV_FAIL:
+    return(1);
+    break;
+  case SPTFQMR_PSOLVE_FAIL_REC:
+    return(1);
+    break;
+  case SPTFQMR_ATIMES_FAIL_REC:
+    return(1);
+    break;
+  case SPTFQMR_MEM_NULL:
+    return(-1);
+    break;
+  case SPTFQMR_ATIMES_FAIL_UNREC:
+    arkProcessError(ark_mem, SPTFQMR_ATIMES_FAIL_UNREC, "ARKSPTFQMR", 
+		    "ARKMassSptfqmrSolve", MSGS_MTIMES_FAILED);    
+    return(-1);
+    break;
+  case SPTFQMR_PSOLVE_FAIL_UNREC:
+    arkProcessError(ark_mem, SPTFQMR_PSOLVE_FAIL_UNREC, "ARKSPTFQMR", 
+		    "ARKMassSptfqmrSolve", MSGS_PSOLVE_FAILED);
+    return(-1);
+    break;
+  }
+
+  return(0);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSptfqmrFree:
+
+ This routine frees memory specific to the Sptfqmr linear solver.
+---------------------------------------------------------------*/
+static int ARKMassSptfqmrFree(ARKodeMem ark_mem)
+{
+  ARKSpilsMassMem arkspils_mem;
+  SptfqmrMem sptfqmr_mem;
+  arkspils_mem = (ARKSpilsMassMem) ark_mem->ark_mass_mem;
+
+  N_VDestroy(arkspils_mem->s_ytemp);
+  N_VDestroy(arkspils_mem->s_x);
+
+  sptfqmr_mem = (SptfqmrMem) arkspils_mem->s_spils_mem;
+  SptfqmrFree(sptfqmr_mem);
+
+  if (arkspils_mem->s_pfree != NULL) (arkspils_mem->s_pfree)(ark_mem);
+
+  free(arkspils_mem);
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+
+/*---------------------------------------------------------------
+     EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/arkode_superlumt.c b/src/arkode/arkode_superlumt.c
new file mode 100644
index 0000000..d0e3cf6
--- /dev/null
+++ b/src/arkode/arkode_superlumt.c
@@ -0,0 +1,1097 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Implementation file for the ARKSUPERLUMT linear solver module.
+ *---------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arkode/arkode_superlumt.h"
+#include "arkode/arkode_sparse.h"
+#include "arkode_sparse_impl.h"
+#include "arkode_impl.h"
+
+#include <sundials/sundials_superlumt_impl.h>
+#include <sundials/sundials_math.h>
+
+/* Constants */
+#define ONE RCONST(1.0)
+#define TWO RCONST(2.0)
+
+/* ARKSUPERLUMT linit, lsetup, lsolve, and lfree routines */
+static int arkSuperLUMTInit(ARKodeMem ark_mem);
+static int arkSuperLUMTSetup(ARKodeMem ark_mem, int convfail, 
+			     N_Vector ypred, N_Vector fpred, 
+			     booleantype *jcurPtr, N_Vector tmp1, 
+			     N_Vector tmp2, N_Vector tmp3);
+static int arkSuperLUMTSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight, N_Vector ycur, 
+			     N_Vector fcur);
+static int arkSuperLUMTFree(ARKodeMem ark_mem);
+
+/* ARKSUPERLUMT minit, msetup, msolve, mfree and mtimes routines */
+static int arkMassSuperLUMTInit(ARKodeMem ark_mem);
+static int arkMassSuperLUMTSetup(ARKodeMem ark_mem, N_Vector tmp1,
+			     N_Vector tmp2, N_Vector tmp3);
+static int arkMassSuperLUMTSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight);
+static int arkMassSuperLUMTFree(ARKodeMem ark_mem);
+static int arkMassSuperLUMTMultiply(N_Vector v, N_Vector Mv, 
+				    realtype t, void *arkode_mem);
+
+
+/*---------------------------------------------------------------
+ ARKSuperLUMT
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the ARKODE / SuperLUMT linear solver
+ module.  ARKSuperLUMT first calls the existing lfree routine if
+ this is not NULL.  Then it sets the ark_linit, ark_lsetup, 
+ ark_lsolve and ark_lfree fields in (*ark_mem) to be 
+ arkSuperLUMTInit, arkSuperLUMTSetup, arkSuperLUMTSolve, and 
+ arkSuperLUMTFree, respectively.  It allocates memory for a 
+ structure of type ARKSlsMemRec and sets the ark_lmem field in 
+ (*arkode_mem) to the address of this structure.  It sets 
+ setupNonNull in (*arkode_mem) to TRUE.  Finally, it allocates 
+ memory for SuperLUMT.  The return value is ARKSLS_SUCCESS = 0, 
+ ARKSLS_LMEM_FAIL = -1, or ARKSLS_ILL_INPUT = -2.
+
+ NOTE: The SuperLUMT linear solver assumes a serial 
+       implementation of the NVECTOR package. Therefore, 
+       ARKSuperLUMT will first test for a compatible N_Vector 
+       internal representation by checking that the function 
+       N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+int ARKSuperLUMT(void *arkode_mem, int num_threads, int n, int nnz)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+  SLUMTData slumt_data;
+  int *perm_c, *perm_r;
+  int nrhs, panel_size, relax;
+  double *bd;
+  SuperMatrix *B;
+
+  /* Return immediately if ark_mem is NULL. */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKSLS_ILL_INPUT, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_BAD_NVECTOR);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_lfree != NULL) ark_mem->ark_lfree(ark_mem);
+
+  /* Set four main function fields in ark_mem. */
+  ark_mem->ark_linit  = arkSuperLUMTInit;
+  ark_mem->ark_lsetup = arkSuperLUMTSetup;
+  ark_mem->ark_lsolve = arkSuperLUMTSolve;
+  ark_mem->ark_lfree  = arkSuperLUMTFree;
+  ark_mem->ark_lsolve_type = 3;
+
+  /* Get memory for ARKSlsMemRec. */
+  arksls_mem = (ARKSlsMem) malloc(sizeof(struct ARKSlsMemRec));
+  if (arksls_mem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_MEM_FAIL);
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Get memory for SLUMTData. */
+  slumt_data = (SLUMTData) malloc(sizeof(struct SLUMTDataRec));
+  if (slumt_data == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_MEM_FAIL);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Initialize Jacobian-related data */
+  arksls_mem->s_Jeval = NULL;
+  arksls_mem->s_Jdata = ark_mem->ark_user_data;
+  ark_mem->ark_setupNonNull = TRUE;
+  arksls_mem->sparsetype = CSC_MAT;
+
+  /* Initialize counters */
+  arksls_mem->s_nje = 0;
+  arksls_mem->s_first_factorize = 1;
+  arksls_mem->s_nstlj = 0;
+
+  /* Allocate memory for the sparse Jacobian */
+  arksls_mem->s_A = NULL;
+  arksls_mem->s_A = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (arksls_mem->s_A == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_MEM_FAIL);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Allocate memory for saved sparse Jacobian */
+  arksls_mem->s_savedJ = NULL;
+  arksls_mem->s_savedJ = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (arksls_mem->s_savedJ == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_A);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Set up memory for the permutations */
+  perm_r = NULL;
+  perm_r = (int *) malloc(n*sizeof(int));
+  if (perm_r == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_A);
+    SparseDestroyMat(arksls_mem->s_savedJ);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+  perm_c = NULL;
+  perm_c = (int *) malloc(n*sizeof(int));
+  if (perm_c == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKSuperLUMT", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_A);
+    SparseDestroyMat(arksls_mem->s_savedJ);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    free(perm_r); perm_r = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+  slumt_data->perm_r = perm_r;
+  slumt_data->perm_c = perm_c;
+
+  /* Set default parameters for SuperLU */
+  slumt_data->num_threads = num_threads;
+  slumt_data->diag_pivot_thresh = 1.0;
+
+  /* Allocate structures for SuperLU */
+  slumt_data->Gstat = (Gstat_t *) malloc(sizeof(Gstat_t));
+  slumt_data->s_A   = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_AC  = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_L   = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_U   = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_A->Store  = NULL;
+  slumt_data->s_AC->Store = NULL;
+  slumt_data->s_L->Store  = NULL;
+  slumt_data->s_U->Store  = NULL;
+  slumt_data->superlumt_options = 
+    (superlumt_options_t *) malloc(sizeof(superlumt_options_t));
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  StatAlloc(arksls_mem->s_A->N, num_threads, panel_size, 
+	    relax, slumt_data->Gstat);
+  
+  /* Create RHS matrix */
+  nrhs = 1;
+  bd = NULL;
+  B = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  B->Store = NULL;
+  dCreate_Dense_Matrix(B, n, nrhs, bd, n, 
+		       SLU_DN, SLU_D, SLU_GE);
+  slumt_data->s_B = B;
+
+  /* Set ordering to COLAMD as the arkode default use.
+     Users can set a different value with ARKSuperLUMTSetOrdering,
+     and the user-set value is loaded before any call to 
+     factorize the matrix in arkSuperLUMTSetup.  */
+  slumt_data->s_ordering = 3;
+
+  /* Attach linear solver memory to the integrator memory */
+  arksls_mem->s_solver_data = (void *) slumt_data;
+  ark_mem->ark_lmem = arksls_mem;
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkSuperLUMTInit:
+
+ This routine does remaining initializations specific to the 
+ ARKSuperLUMT linear solver module.  It returns 0 if successful.
+---------------------------------------------------------------*/
+static int arkSuperLUMTInit(ARKodeMem ark_mem)
+{
+  ARKSlsMem arksls_mem;
+  SLUMTData slumt_data;
+
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  arksls_mem->s_nje = 0;
+  arksls_mem->s_first_factorize = 1;
+  arksls_mem->s_nstlj = 0;
+
+  /* Allocate storage and initialize statistics variables. */
+  StatInit(arksls_mem->s_A->N, slumt_data->num_threads, 
+	   slumt_data->Gstat);
+
+  arksls_mem->s_Jdata = ark_mem->ark_user_data;
+  arksls_mem->s_last_flag = 0;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkSuperLUMTSetup:
+
+  This routine does the setup operations for the ARKSuperLUMT 
+  linear solver module.  It calls the Jacobian evaluation 
+  routine, updates counters, and calls the LU factorization 
+  routine.  The return value is either
+     ARKSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+---------------------------------------------------------------*/
+static int arkSuperLUMTSetup(ARKodeMem ark_mem, int convfail, 
+			     N_Vector ypred, N_Vector fpred, 
+			     booleantype *jcurPtr, N_Vector vtemp1, 
+			     N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  int retval;
+  int panel_size, relax, lwork;
+  realtype dgamma;
+  double drop_tol;
+  fact_t fact;
+  trans_t trans;
+  yes_no_t refact, usepr;
+  ARKSlsMem arksls_mem;
+  ARKSlsMassMem arksls_mass_mem;
+  SLUMTData slumt_data;
+  void *work;
+  
+  arksls_mem = (ARKSlsMem) (ark_mem->ark_lmem);
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  /* Set option values for SuperLU_MT */
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  fact = EQUILIBRATE;
+  trans = NOTRANS;
+  usepr = NO;
+  drop_tol = 0.0;
+  lwork = 0;
+  work = NULL;
+
+  /* Check that Jacobian eval routine is set */
+  if (arksls_mem->s_Jeval == NULL) {
+    arkProcessError(ark_mem, ARKSLS_JAC_NOSET, "ARKSLS", 
+		    "arkSuperLUMTSetup", MSGSP_JAC_NOSET);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_JAC_NOSET);
+  }
+
+  /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
+  dgamma = SUNRabs((ark_mem->ark_gamma/ark_mem->ark_gammap) - ONE);
+  jbad = (ark_mem->ark_nst == 0) || 
+    (ark_mem->ark_nst > arksls_mem->s_nstlj + ARKS_MSBJ) ||
+    ((convfail == ARK_FAIL_BAD_J) && (dgamma < ARKS_DGMAX)) ||
+    (convfail == ARK_FAIL_OTHER);
+  jok = !jbad;
+  
+  /* If jok = TRUE, use saved copy of J */
+  if (jok) {
+    *jcurPtr = FALSE;
+    SparseCopyMat(arksls_mem->s_savedJ, arksls_mem->s_A);
+
+  /* If jok = FALSE, call jac routine for new J value */
+  } else {
+    arksls_mem->s_nje++;
+    arksls_mem->s_nstlj = ark_mem->ark_nst;
+    *jcurPtr = TRUE;
+    SparseSetMatToZero(arksls_mem->s_A);
+
+    retval = arksls_mem->s_Jeval(ark_mem->ark_tn, ypred, fpred, 
+				 arksls_mem->s_A, arksls_mem->s_Jdata, 
+				 vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKSLS_JACFUNC_UNRECVR, "ARKSLS", 
+		      "arkSuperLUMTSetup", MSGSP_JACFUNC_FAILED);
+      arksls_mem->s_last_flag = ARKSLS_JACFUNC_UNRECVR;
+      return(ARKSLS_JACFUNC_UNRECVR);
+    }
+    if (retval > 0) {
+      arksls_mem->s_last_flag = ARKSLS_JACFUNC_RECVR;
+      return(ARKSLS_JACFUNC_RECVR);
+    }
+
+    SparseCopyMat(arksls_mem->s_A, arksls_mem->s_savedJ);
+  }
+
+  /* Scale J by -gamma */
+  SparseScaleMat(-ark_mem->ark_gamma, arksls_mem->s_A);
+
+  /* Add mass matrix to get A = M-gamma*J */
+  if (ark_mem->ark_mass_matrix) {
+
+    /* Compute mass matrix */
+    arksls_mass_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+    SparseSetMatToZero(arksls_mass_mem->s_M);
+    retval = arksls_mass_mem->s_Meval(ark_mem->ark_tn, 
+				      arksls_mass_mem->s_M, 
+				      arksls_mass_mem->s_Mdata, 
+				      vtemp1, vtemp2, vtemp3);
+    arksls_mass_mem->s_nme++;
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKSLS_MASSFUNC_UNRECVR, "ARKSLS", 
+		      "arkSuperLUMTSetup",  MSGSP_MASSFUNC_FAILED);
+      arksls_mem->s_last_flag = ARKSLS_MASSFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      arksls_mem->s_last_flag = ARKSLS_MASSFUNC_RECVR;
+      return(1);
+    }
+    
+    /* add to A */
+    retval = SparseAddMat(arksls_mem->s_A, arksls_mass_mem->s_M);
+    if (retval < 0) {
+      arkProcessError(ark_mem, ARKSLS_PACKAGE_FAIL, "ARKSLS", 
+		      "arkSuperLUMTSetup",  
+		      "Error in adding mass matrix to Jacobian");
+      arksls_mem->s_last_flag = ARKSLS_PACKAGE_FAIL;
+      return(retval);
+    }
+    if (retval > 0)  return(retval);
+    
+  } else {
+    SparseAddIdentityMat(arksls_mem->s_A);
+  }
+
+  /* free and reallocate sparse matrix */
+  if (slumt_data->s_A->Store) {
+    SUPERLU_FREE(slumt_data->s_A->Store);
+  }
+  dCreate_CompCol_Matrix(slumt_data->s_A, arksls_mem->s_A->M, 
+			 arksls_mem->s_A->N, arksls_mem->s_A->NNZ, 
+			 arksls_mem->s_A->data, 
+			 arksls_mem->s_A->indexvals, 
+			 arksls_mem->s_A->indexptrs, 
+			 SLU_NC, SLU_D, SLU_GE);
+
+  /* On first decomposition, set up reusable pieces */ 
+  if (arksls_mem->s_first_factorize) {
+
+    /* Get column permutation vector perm_c[], according to s_ordering */
+    get_perm_c(slumt_data->s_ordering, slumt_data->s_A, 
+	       slumt_data->perm_c);
+    refact= NO;
+    arksls_mem->s_first_factorize = 0;
+
+  } else {
+    /* Re-initialize statistics variables */
+    StatInit(arksls_mem->s_A->N, slumt_data->num_threads, 
+	     slumt_data->Gstat);
+    Destroy_CompCol_Permuted(slumt_data->s_AC);
+    refact= YES;
+  }
+
+  /* Initialize the option structure superlumt_options using the
+     user-input parameters. Subsequent calls will re-initialize
+     options.  Apply perm_c to columns of original A to form AC */
+  pdgstrf_init(slumt_data->num_threads, fact, trans, refact, 
+	       panel_size, relax, slumt_data->diag_pivot_thresh, 
+	       usepr, drop_tol, slumt_data->perm_c, 
+	       slumt_data->perm_r, work, lwork, slumt_data->s_A, 
+	       slumt_data->s_AC, slumt_data->superlumt_options, 
+	       slumt_data->Gstat);
+
+  /* Compute the LU factorization of A.
+     The following routine will create num_threads threads. */
+  pdgstrf(slumt_data->superlumt_options, slumt_data->s_AC, 
+	  slumt_data->perm_r, slumt_data->s_L, slumt_data->s_U, 
+	  slumt_data->Gstat, &retval);
+  if (retval != 0) {
+    arksls_mem->s_last_flag = retval;
+    return(ARKSLS_PACKAGE_FAIL);
+  }
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkSuperLUMTSolve:
+
+ This routine handles the solve operation for the ARKSuperLUMT 
+ linear solver module.  It calls the SuperLU_MT solve routine,
+ then returns ARKSLS_SUCCESS = 0.
+---------------------------------------------------------------*/
+static int arkSuperLUMTSolve(ARKodeMem ark_mem, N_Vector b, 
+			     N_Vector weight, N_Vector ycur, 
+			     N_Vector fcur)
+{
+  int info;
+  ARKSlsMem arksls_mem;
+  DNformat *Bstore;
+  SLUMTData slumt_data;
+  realtype *bd;
+  trans_t trans;
+  
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  bd = N_VGetArrayPointer(b);
+  Bstore = (DNformat *) (slumt_data->s_B->Store);
+  Bstore->nzval = bd;
+
+  /* Call SuperLUMT to solve the linear system using L and U */
+  trans = NOTRANS;
+  dgstrs(trans, slumt_data->s_L, slumt_data->s_U, 
+	 slumt_data->perm_r, slumt_data->perm_c, 
+	 slumt_data->s_B, slumt_data->Gstat, &info);
+
+  /* Scale the correction to account for change in gamma. */
+  if (ark_mem->ark_gamrat != ONE) 
+    N_VScale(TWO/(ONE + ark_mem->ark_gamrat), b, b);
+  Bstore->nzval = NULL;
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkSuperLUMTFree:
+
+ This routine frees memory specific to the ARKSuperLUMT linear 
+ solver.
+---------------------------------------------------------------*/
+static int arkSuperLUMTFree(ARKodeMem ark_mem)
+{
+  ARKSlsMem arksls_mem;
+  SLUMTData slumt_data;
+  
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  pxgstrf_finalize(slumt_data->superlumt_options, 
+		   slumt_data->s_AC);
+  free(slumt_data->perm_r);
+  free(slumt_data->perm_c);
+  free(slumt_data->superlumt_options);
+  Destroy_SuperNode_SCP( (slumt_data->s_L) );
+  Destroy_CompCol_NCP( (slumt_data->s_U) );
+  StatFree(slumt_data->Gstat);
+  free(slumt_data->Gstat);
+  
+  Destroy_SuperMatrix_Store(slumt_data->s_B);
+  SUPERLU_FREE(slumt_data->s_A->Store);
+  if (arksls_mem->s_A) {
+    SparseDestroyMat(arksls_mem->s_A);
+    arksls_mem->s_A = NULL;
+  }
+
+  if (arksls_mem->s_savedJ) {
+    SparseDestroyMat(arksls_mem->s_savedJ);
+    arksls_mem->s_savedJ = NULL;
+  }
+
+  free(slumt_data->s_B);
+  free(slumt_data->s_A);
+  free(slumt_data->s_AC);
+  free(slumt_data->s_L);
+  free(slumt_data->s_U);
+
+  free(slumt_data); 
+  slumt_data = NULL;
+  free(arksls_mem); 
+  ark_mem->ark_lmem = NULL;
+
+  return(0);
+}
+
+
+
+/*---------------------------------------------------------------
+ ARKMassSuperLUMT
+
+ This routine initializes the memory record and sets various 
+ function fields specific to the ARKODE / SuperLUMT mass matrix 
+ linear solver module.  ARKMassSuperLUMT first calls the 
+ existing mfree routine if this is not NULL.  Then it sets the 
+ ark_minit, ark_msetup, ark_msolve and ark_mfree fields in 
+ (*arkode_mem) to be arkMassSuperLUMTInit, arkMassSuperLUMTSetup, 
+ arkMassSuperLUMTSolve, and arkMassSuperLUMTFree, respectively.  
+ It allocates memory for a structure of type ARKSlsMassMemRec and
+ sets the ark_mass_mem field in (*arkode_mem) to the address of 
+ this structure.  It sets MassSetupNonNull in (*arkode_mem) to 
+ TRUE.  Finally, it allocates memory for SuperLUMT.  The return
+ value is ARKSLS_SUCCESS = 0, ARKSLS_LMEM_FAIL = -1, or 
+ ARKSLS_ILL_INPUT = -2.
+
+ NOTE: The SuperLUMT linear solver assumes a serial 
+       implementation of the NVECTOR package. Therefore, 
+       ARKMassSuperLUMT will first test for a compatible 
+       N_Vector internal representation by checking that the 
+       function N_VGetArrayPointer exists.
+---------------------------------------------------------------*/
+int ARKMassSuperLUMT(void *arkode_mem, int num_threads, 
+		     int n, int nnz, ARKSlsSparseMassFn smass)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+  SLUMTData slumt_data;
+  int *perm_c, *perm_r;
+  int nrhs, panel_size, relax;
+  double *bd;
+  SuperMatrix *B;
+
+  /* Return immediately if arkode_mem is NULL. */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Test if the NVECTOR package is compatible with the solver */
+  if (ark_mem->ark_tempv->ops->nvgetarraypointer == NULL) {
+    arkProcessError(ark_mem, ARKSLS_ILL_INPUT, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_BAD_NVECTOR);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  if (ark_mem->ark_mfree != NULL) ark_mem->ark_mfree(ark_mem);
+
+  /* Set main function fields in ark_mem, enable mass matrix. */
+  ark_mem->ark_mass_matrix = TRUE;
+  ark_mem->ark_minit  = arkMassSuperLUMTInit;
+  ark_mem->ark_msetup = arkMassSuperLUMTSetup;
+  ark_mem->ark_msolve = arkMassSuperLUMTSolve;
+  ark_mem->ark_mfree  = arkMassSuperLUMTFree;
+  ark_mem->ark_mtimes = arkMassSuperLUMTMultiply;
+  ark_mem->ark_mtimes_data = (void *) ark_mem;
+  ark_mem->ark_msolve_type = 3;
+
+  /* Get memory for ARKSlsMassMemRec. */
+  arksls_mem = (ARKSlsMassMem) malloc(sizeof(struct ARKSlsMassMemRec));
+  if (arksls_mem == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_MEM_FAIL);
+    return(ARKSLS_MEM_FAIL);
+  }
+  
+  /* Get memory for SLUMTData. */
+  slumt_data = (SLUMTData) malloc(sizeof(struct SLUMTDataRec));
+  if (slumt_data == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_MEM_FAIL);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Initialize mass-matrix-related data */
+  arksls_mem->s_nme = 0;
+  arksls_mem->s_first_factorize = 1;
+  arksls_mem->s_Meval = smass;
+  arksls_mem->s_Mdata = ark_mem->ark_user_data;
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  ark_mem->ark_MassSetupNonNull = TRUE;
+  arksls_mem->sparsetype = CSC_MAT;
+
+  /* Allocate memory for M and M_lu */
+  arksls_mem->s_M = NULL;
+  arksls_mem->s_M = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (arksls_mem->s_M == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_MEM_FAIL);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+  arksls_mem->s_M_lu = NULL;
+  arksls_mem->s_M_lu = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (arksls_mem->s_M_lu == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_M);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+
+  /* Set up memory for the permutations */
+  perm_r = NULL;
+  perm_r = (int *) malloc(n*sizeof(int));
+  if (perm_r == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_M);
+    SparseDestroyMat(arksls_mem->s_M_lu);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+  perm_c = NULL;
+  perm_c = (int *) malloc(n*sizeof(int));
+  if (perm_c == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MEM_FAIL, "ARKSLS", 
+		    "ARKMassSuperLUMT", MSGSP_MEM_FAIL);
+    SparseDestroyMat(arksls_mem->s_M);
+    SparseDestroyMat(arksls_mem->s_M_lu);
+    free(slumt_data); slumt_data = NULL;
+    free(arksls_mem); arksls_mem = NULL;
+    free(perm_r); perm_r = NULL;
+    return(ARKSLS_MEM_FAIL);
+  }
+  slumt_data->perm_r = perm_r;
+  slumt_data->perm_c = perm_c;
+
+  /* Set default parameters for SuperLU */
+  slumt_data->num_threads = num_threads;
+  slumt_data->diag_pivot_thresh = 1.0;
+
+  /* Allocate structures for SuperLU */
+  slumt_data->Gstat = (Gstat_t *) malloc(sizeof(Gstat_t));
+  slumt_data->s_A   = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_AC  = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_L   = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_U   = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  slumt_data->s_A->Store  = NULL;
+  slumt_data->s_AC->Store = NULL;
+  slumt_data->s_L->Store  = NULL;
+  slumt_data->s_U->Store  = NULL;
+  slumt_data->superlumt_options = 
+    (superlumt_options_t *) malloc(sizeof(superlumt_options_t));
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  StatAlloc(arksls_mem->s_M->N, num_threads, panel_size, 
+	    relax, slumt_data->Gstat);
+  
+  /* Create RHS matrix */
+  nrhs = 1;
+  bd = NULL;
+  B = (SuperMatrix *) malloc(sizeof(SuperMatrix));
+  B->Store = NULL;
+  dCreate_Dense_Matrix(B, n, nrhs, bd, n, 
+		       SLU_DN, SLU_D, SLU_GE);
+  slumt_data->s_B = B;
+
+  /* Set ordering to COLAMD as the arkode default use.
+     Users can set a different value with ARKMassSuperLUMTSetOrdering,
+     and the user-set value is loaded before any call to 
+     factorize the matrix in arkMassSuperLUMTSetup.  */
+  slumt_data->s_ordering = 3;
+
+  /* Attach linear solver memory to the integrator memory */
+  arksls_mem->s_solver_data = (void *) slumt_data;
+  ark_mem->ark_mass_mem = arksls_mem;
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassSuperLUMTInit:
+
+ This routine does remaining initializations specific to the 
+ ARKSuperLUMT mass matrix linear solver module.  It returns 0 if
+ successful.
+---------------------------------------------------------------*/
+static int arkMassSuperLUMTInit(ARKodeMem ark_mem)
+{
+  ARKSlsMassMem arksls_mem;
+  SLUMTData slumt_data;
+
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  arksls_mem->s_nme = 0;
+  arksls_mem->s_first_factorize = 1;
+
+  /* Allocate storage and initialize statistics variables. */
+  StatInit(arksls_mem->s_M->N, slumt_data->num_threads, 
+	   slumt_data->Gstat);
+  arksls_mem->s_Mdata = ark_mem->ark_user_data;
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassSuperLUMTSetup:
+
+  This routine does the setup operations for the ARKMassSuperLUMT 
+  linear solver module.  It calls the mass matrix evaluation 
+  routine, updates counters, and calls the LU factorization 
+  routine.  The return value is either
+     ARKSLS_SUCCESS = 0  if successful,
+     +1  if the Meval routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the Meval routine failed unrecoverably.
+---------------------------------------------------------------*/
+static int arkMassSuperLUMTSetup(ARKodeMem ark_mem, N_Vector vtemp1, 
+				 N_Vector vtemp2, N_Vector vtemp3)
+{
+  int retval;
+  int panel_size, relax, lwork;
+  double drop_tol;
+  fact_t fact;
+  trans_t trans;
+  yes_no_t refact, usepr;
+  ARKSlsMassMem arksls_mem;
+  SLUMTData slumt_data;
+  void *work;
+  
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  /* Set option values for SuperLU_MT */
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  fact = EQUILIBRATE;
+  trans = NOTRANS;
+  usepr = NO;
+  drop_tol = 0.0;
+  lwork = 0;
+  work = NULL;
+
+  /* Check that mass matrix eval routine is set */
+  if (arksls_mem->s_Meval == NULL) {
+    arkProcessError(ark_mem, ARKSLS_MASS_NOSET, "ARKSLS", 
+		    "arkMassSuperLUMTSetup", MSGSP_MASS_NOSET);
+    free(arksls_mem); arksls_mem = NULL;
+    return(ARKSLS_MASS_NOSET);
+  }
+
+  /* call Meval routine for new M matrix */
+  SparseSetMatToZero(arksls_mem->s_M);
+  retval = arksls_mem->s_Meval(ark_mem->ark_tn, arksls_mem->s_M, 
+			       arksls_mem->s_Mdata, vtemp1, 
+			       vtemp2, vtemp3);
+  arksls_mem->s_nme++;
+  if (retval < 0) {
+    arkProcessError(ark_mem, ARKSLS_MASSFUNC_UNRECVR, "ARKSLS", 
+		    "arkMassSuperLUMTSetup", MSGSP_MASSFUNC_FAILED);
+    arksls_mem->s_last_flag = ARKSLS_MASSFUNC_UNRECVR;
+    return(ARKSLS_MASSFUNC_UNRECVR);
+  }
+  if (retval > 0) {
+    arksls_mem->s_last_flag = ARKSLS_MASSFUNC_RECVR;
+    return(ARKSLS_MASSFUNC_RECVR);
+  }
+
+  /* Copy M into M_lu for LU decomposition */
+  SparseCopyMat(arksls_mem->s_M, arksls_mem->s_M_lu);
+
+
+  /* free and reallocate sparse matrix */
+  if (slumt_data->s_A->Store) {
+    SUPERLU_FREE(slumt_data->s_A->Store);
+  }
+  dCreate_CompCol_Matrix(slumt_data->s_A, arksls_mem->s_M->M, 
+			 arksls_mem->s_M->N, arksls_mem->s_M->NNZ, 
+			 arksls_mem->s_M->data, 
+			 arksls_mem->s_M->indexvals, 
+			 arksls_mem->s_M->indexptrs, 
+			 SLU_NC, SLU_D, SLU_GE);
+
+  /* On first decomposition, set up reusable pieces */ 
+  if (arksls_mem->s_first_factorize) {
+
+    /* Get column permutation vector perm_c[], according to s_ordering */
+    get_perm_c(slumt_data->s_ordering, slumt_data->s_A, 
+	       slumt_data->perm_c);
+    refact= NO;
+    arksls_mem->s_first_factorize = 0;
+
+  } else {
+    /* Re-initialize statistics variables */
+    StatInit(arksls_mem->s_M->N, slumt_data->num_threads, 
+	     slumt_data->Gstat);
+    Destroy_CompCol_Permuted(slumt_data->s_AC);
+    refact= YES;
+  }
+
+  /* Initialize the option structure superlumt_options using the
+     user-input parameters. Subsequent calls will re-initialize
+     options.  Apply perm_c to columns of original A to form AC */
+  pdgstrf_init(slumt_data->num_threads, fact, trans, refact, 
+	       panel_size, relax, slumt_data->diag_pivot_thresh, 
+	       usepr, drop_tol, slumt_data->perm_c, 
+	       slumt_data->perm_r, work, lwork, slumt_data->s_A, 
+	       slumt_data->s_AC, slumt_data->superlumt_options, 
+	       slumt_data->Gstat);
+
+  /* Compute the LU factorization of A.
+     The following routine will create num_threads threads. */
+  pdgstrf(slumt_data->superlumt_options, slumt_data->s_AC, 
+	  slumt_data->perm_r, slumt_data->s_L, slumt_data->s_U, 
+	  slumt_data->Gstat, &retval);
+  if (retval != 0) {
+    arksls_mem->s_last_flag = retval;
+    return(ARKSLS_PACKAGE_FAIL);
+  }
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassSuperLUMTSolve:
+
+ This routine handles the solve operation for the ARKSuperLUMT 
+ mass matrix linear solver module.  It calls the SuperLU_MT 
+ solve routine, then returns ARKSLS_SUCCESS = 0.
+---------------------------------------------------------------*/
+static int arkMassSuperLUMTSolve(ARKodeMem ark_mem, N_Vector b, 
+				 N_Vector weight)
+{
+  int info;
+  ARKSlsMassMem arksls_mem;
+  DNformat *Bstore;
+  SLUMTData slumt_data;
+  realtype *bd;
+  trans_t trans;
+  
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  bd = N_VGetArrayPointer(b);
+  Bstore = (DNformat *) (slumt_data->s_B->Store);
+  Bstore->nzval = bd;
+
+  /* Call SuperLUMT to solve the linear system using L and U */
+  trans = NOTRANS;
+  dgstrs(trans, slumt_data->s_L, slumt_data->s_U, 
+	 slumt_data->perm_r, slumt_data->perm_c, 
+	 slumt_data->s_B, slumt_data->Gstat, &info);
+
+  arksls_mem->s_last_flag = ARKSLS_SUCCESS;
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ arkMassSuperLUMTFree:
+
+ This routine frees memory specific to the ARKSuperLUMT mass 
+ matrix linear solver.
+---------------------------------------------------------------*/
+static int arkMassSuperLUMTFree(ARKodeMem ark_mem)
+{
+  ARKSlsMassMem arksls_mem;
+  SLUMTData slumt_data;
+  
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  pxgstrf_finalize(slumt_data->superlumt_options, 
+		   slumt_data->s_AC);
+  free(slumt_data->perm_r);
+  free(slumt_data->perm_c);
+  free(slumt_data->superlumt_options);
+  Destroy_SuperNode_SCP( (slumt_data->s_L) );
+  Destroy_CompCol_NCP( (slumt_data->s_U) );
+  StatFree(slumt_data->Gstat);
+  free(slumt_data->Gstat);
+  
+  Destroy_SuperMatrix_Store(slumt_data->s_B);
+  SUPERLU_FREE(slumt_data->s_A->Store);
+  if (arksls_mem->s_M) {
+    SparseDestroyMat(arksls_mem->s_M);
+    arksls_mem->s_M = NULL;
+  }
+
+  if (arksls_mem->s_M_lu) {
+    SparseDestroyMat(arksls_mem->s_M_lu);
+    arksls_mem->s_M_lu = NULL;
+  }
+
+  free(slumt_data->s_B);
+  free(slumt_data->s_A);
+  free(slumt_data->s_AC);
+  free(slumt_data->s_L);
+  free(slumt_data->s_U);
+
+  free(slumt_data); 
+  slumt_data = NULL;
+  free(arksls_mem); 
+  ark_mem->ark_mass_mem = NULL;
+
+  return(0);
+}
+
+
+/*===============================================================
+ Utility Functions
+===============================================================*/
+
+/*---------------------------------------------------------------
+ arkMassSuperLUMTMultiply:
+
+ Multiplies the mass matrix by the vector v to fill in the 
+ vector Mv.
+---------------------------------------------------------------*/
+static int arkMassSuperLUMTMultiply(N_Vector v, N_Vector Mv, 
+				    realtype t, void *arkode_mem)
+{
+
+  /* extract the SlsMassMem structure from the arkode_mem pointer */
+  ARKodeMem ark_mem;
+  ARKSlsMassMem arksls_mem;
+  realtype *vdata=NULL, *Mvdata=NULL;
+
+  /* Return immediately if arkode_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "arkMassSuperLUMTMultiply", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+
+  /* zero out the result */
+  N_VConst(0.0, Mv);
+
+  /* access the vector arrays (since they must be serial vectors) */
+  vdata = N_VGetArrayPointer(v);
+  Mvdata = N_VGetArrayPointer(Mv);
+  if (vdata == NULL || Mvdata == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "arkMassSuperLUMTMultiply", 
+		    "Vector data un-allocated.");
+    return(ARKSLS_MEM_NULL);
+  }
+
+  /* perform matrix-vector product with arksls_mem->s_M and return */
+  if (SparseMatvec(arksls_mem->s_M, vdata, Mvdata) != 0) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "arkMassSuperLUMTMultiply", 
+		    "Mass matrix data un-allocated.");
+    return(ARKSLS_MEM_NULL);
+  }
+
+  return(0);
+
+}
+
+
+/*===============================================================
+ Optional Input Specification Functions
+===============================================================*/
+
+
+/*---------------------------------------------------------------
+ ARKSuperLUMTSetOrdering:
+
+ Sets the ordering used by SuperLUMT for reducing fill.
+ Options are: 
+     0 for natural ordering
+     1 for minimal degree ordering on A'*A
+     2 for minimal degree ordering on A'+A
+     3 for AMD ordering for unsymmetric matrices
+ The default used in SUNDIALS is 3 for COLAMD.
+---------------------------------------------------------------*/
+int ARKSuperLUMTSetOrdering(void *arkode_mem, int ordering_choice)
+{
+  ARKodeMem ark_mem;
+  ARKSlsMem arksls_mem;
+  SLUMTData slumt_data;
+
+  /* Return immediately if ark_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKSuperLUMTSetOrdering", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice < 0) || (ordering_choice > 3) ) {
+    arkProcessError(NULL, ARKSLS_ILL_INPUT, "ARKSLS", 
+		    "ARKSuperLUMTSetOrdering", MSGSP_ILL_INPUT);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  arksls_mem = (ARKSlsMem) ark_mem->ark_lmem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  slumt_data->s_ordering = ordering_choice;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+ ARKMassSuperLUMTSetOrdering:
+
+ Sets the ordering used by SuperLUMT for reducing fill. Options 
+ are: 
+     0 for natural ordering
+     1 for minimal degree ordering on A'*A
+     2 for minimal degree ordering on A'+A
+     3 for AMD ordering for unsymmetric matrices
+ The default used in SUNDIALS is 3 for COLAMD.
+---------------------------------------------------------------*/
+int ARKMassSuperLUMTSetOrdering(void *arkode_mem, int ordering_choice)
+{
+  ARKodeMem     ark_mem;
+  ARKSlsMassMem arksls_mem;
+  SLUMTData     slumt_data;
+
+  /* Return immediately if ark_mem is NULL */
+  if (arkode_mem == NULL) {
+    arkProcessError(NULL, ARKSLS_MEM_NULL, "ARKSLS", 
+		    "ARKMassSuperLUMTSetOrdering", MSGSP_ARKMEM_NULL);
+    return(ARKSLS_MEM_NULL);
+  }
+  ark_mem = (ARKodeMem) arkode_mem;
+
+  /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice < 0) || (ordering_choice > 3) ) {
+    arkProcessError(NULL, ARKSLS_ILL_INPUT, "ARKSLS", 
+		    "ARKMassSuperLUMTSetOrdering", MSGSP_ILL_INPUT);
+    return(ARKSLS_ILL_INPUT);
+  }
+
+  arksls_mem = (ARKSlsMassMem) ark_mem->ark_mass_mem;
+  slumt_data = (SLUMTData) arksls_mem->s_solver_data;
+
+  slumt_data->s_ordering = ordering_choice;
+
+  return(ARKSLS_SUCCESS);
+}
+
+
+/*---------------------------------------------------------------
+   EOF
+---------------------------------------------------------------*/
diff --git a/src/arkode/fcmix/CMakeLists.txt b/src/arkode/fcmix/CMakeLists.txt
new file mode 100644
index 0000000..cff9228
--- /dev/null
+++ b/src/arkode/fcmix/CMakeLists.txt
@@ -0,0 +1,76 @@
+# ---------------------------------------------------------------
+# Programmer:  Daniel R. Reynolds @ SMU
+# ---------------------------------------------------------------
+# Copyright (c) 2013, Southern Methodist University.
+# All rights reserved.
+# For details, see the LICENSE file.
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the FARKODE library
+
+# Add variable farkode_SOURCES with the sources for the FARKODE library
+SET(farkode_SOURCES
+  farkadapt.c
+  farkband.c
+  farkbandmass.c
+  farkbbd.c
+  farkbp.c
+  farkdense.c
+  farkdensemass.c
+  farkewt.c
+  farkexpstab.c
+  farkjtimes.c
+  farkmtimes.c
+  farkode.c
+  farkpreco.c
+  farkmasspreco.c
+  farkroot.c
+  )
+
+IF(LAPACK_FOUND)
+  SET(farkode_BL_SOURCES farklapack.c farklapdense.c farklapdensemass.c farklapband.c farklapbandmass.c)
+ELSE(LAPACK_FOUND)
+  SET(farkode_BL_SOURCES "")
+ENDIF(LAPACK_FOUND)
+
+IF(KLU_FOUND OR SUPERLUMT_FOUND)
+  SET(farkode_SPARSE_SOURCES farksparse.c farksparsemass.c)
+ELSE(SPARSE_FOUND)
+  SET(farkode_SPARSE_SOURCES "")
+ENDIF(KLU_FOUND OR SUPERLUMT_FOUND)
+
+IF(KLU_FOUND)
+  SET(farkode_KLU_SOURCES farkklu.c)
+ELSE(KLU_FOUND)
+  SET(farkode_KLU_SOURCES "")
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  SET(farkode_SUPERLUMT_SOURCES farksuperlumt.c)
+ELSE(SUPERLUMT_FOUND)
+  SET(farkode_SUPERLUMT_SOURCES "")
+ENDIF(SUPERLUMT_FOUND)
+
+# Add source directories to include directories for access to
+# implementation only header files (both for farkode and arkode)
+INCLUDE_DIRECTORIES(.)
+INCLUDE_DIRECTORIES(..)
+
+# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY 
+ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+
+# Only build STATIC libraries (we cannot build shared libraries 
+# for the FCMIX interfaces due to unresolved symbol errors 
+# coming from inexistent user-provided functions)
+
+# Add the build target for the FARKODE library
+ADD_LIBRARY(sundials_farkode_static STATIC ${farkode_SOURCES} ${farkode_BL_SOURCES} ${farkode_SPARSE_SOURCES} ${farkode_KLU_SOURCES} ${farkode_SUPERLUMT_SOURCES})
+
+# Set the library name and make sure it is not deleted
+SET_TARGET_PROPERTIES(sundials_farkode_static
+  PROPERTIES OUTPUT_NAME sundials_farkode CLEAN_DIRECT_OUTPUT 1)
+
+# Install the FARKODE library
+INSTALL(TARGETS sundials_farkode_static DESTINATION lib)
+
+#
+MESSAGE(STATUS "Added ARKODE FCMIX module")
diff --git a/src/arkode/fcmix/farkadapt.c b/src/arkode/fcmix/farkadapt.c
new file mode 100644
index 0000000..013fe40
--- /dev/null
+++ b/src/arkode/fcmix/farkadapt.c
@@ -0,0 +1,82 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE, for the case of a 
+ * user-supplied step adaptivity routine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_ADAPT(realtype *Y, realtype *T, realtype *H1, 
+			 realtype *H2, realtype *H3, realtype *E1, 
+			 realtype *E2, realtype *E3, int *Q, int *P, 
+			 realtype *HNEW, long int *IPAR, 
+			 realtype *RPAR, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetAdaptivityFn; see 
+   farkode.h for further information */
+void FARK_ADAPTSET(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKodeSetAdaptivityFn(ARK_arkodemem, NULL, NULL);
+  } else {
+    *ier = ARKodeSetAdaptivityFn(ARK_arkodemem, FARKAdapt, 
+				 ARK_arkodemem);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied fortran routine FARKADAPT; see 
+   farkode.h for further information */
+int FARKAdapt(N_Vector y, realtype t, realtype h1, realtype h2, 
+	      realtype h3, realtype e1, realtype e2, realtype e3, 
+	      int q, int p, realtype *hnew, void *user_data)
+{
+  int ier = 0;
+  realtype *ydata;
+  FARKUserData ARK_userdata;
+
+  ydata  = N_VGetArrayPointer(y);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_ADAPT(ydata, &t, &h1, &h2, &h3, &e1, &e2, &e3, &q, &p, 
+	     hnew, ARK_userdata->ipar, ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkband.c b/src/arkode/fcmix/farkband.c
new file mode 100644
index 0000000..2177ea0
--- /dev/null
+++ b/src/arkode/fcmix/farkband.c
@@ -0,0 +1,97 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKBAND, for the case 
+ * of a user-supplied Jacobian approximation routine.                
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_band.h>
+
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_BJAC(long int *N, long int *MU, long int *ML,
+  			long int *EBAND, realtype *T,
+  			realtype *Y, realtype *FY,
+  			realtype *BJAC, realtype *H,
+  			long int *IPAR, realtype *RPAR,
+  			realtype *V1, realtype *V2,
+  			realtype *V3, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface routine to ARKDlsSetBandJacFn; see farkode.h 
+   for further details */
+void FARK_BANDSETJAC(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKDlsSetBandJacFn(ARK_arkodemem, NULL);
+  } else {
+    *ier = ARKDlsSetBandJacFn(ARK_arkodemem, FARKBandJac);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran subroutine FARKBJAC; see 
+   farkode.h for further details */
+int FARKBandJac(long int N, long int mupper, 
+		long int mlower, realtype t, N_Vector y, 
+		N_Vector fy, DlsMat J, void *user_data, 
+		N_Vector vtemp1, N_Vector vtemp2, 
+		N_Vector vtemp3)
+{
+  int ier;
+  realtype *ydata, *fydata, *jacdata, *v1data, *v2data, *v3data;
+  realtype h;
+  long int eband;
+  FARKUserData ARK_userdata;
+
+  ARKodeGetLastStep(ARK_arkodemem, &h);
+  ydata   = N_VGetArrayPointer(y);
+  fydata  = N_VGetArrayPointer(fy);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  eband   = (J->s_mu) + mlower + 1;
+  jacdata = BAND_COL(J,0) - mupper;
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_BJAC(&N, &mupper, &mlower, &eband, &t, ydata, fydata, 
+	    jacdata, &h, ARK_userdata->ipar, ARK_userdata->rpar, 
+	    v1data, v2data, v3data, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkbandmass.c b/src/arkode/fcmix/farkbandmass.c
new file mode 100644
index 0000000..8d69bb5
--- /dev/null
+++ b/src/arkode/fcmix/farkbandmass.c
@@ -0,0 +1,84 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKBAND, for the case 
+ * of a user-supplied Jacobian approximation routine.                
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_band.h>
+
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_BMASS(long int *N, long int *MU, long int *ML,
+  			 long int *EBAND, realtype *T,
+  			 realtype *BMASS, long int *IPAR,
+  			 realtype *RPAR, realtype *V1,
+  			 realtype *V2, realtype *V3, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface routine to ARKDlsSetBandMassFn; see farkode.h 
+   for further details */
+void FARK_BANDSETMASS(int *ier)
+{
+  *ier = ARKDlsSetBandMassFn(ARK_arkodemem, FARKBandMass);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran subroutine FARKBMASS; see 
+   farkode.h for further details */
+int FARKBandMass(long int N, long int mupper, long int mlower, 
+		 realtype t, DlsMat M, void *user_data, 
+		 N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *massdata, *v1data, *v2data, *v3data;
+  long int eband;
+  FARKUserData ARK_userdata;
+
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  eband   = (M->s_mu) + mlower + 1;
+  massdata = BAND_COL(M,0) - mupper;
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_BMASS(&N, &mupper, &mlower, &eband, &t, massdata, 
+	     ARK_userdata->ipar, ARK_userdata->rpar, v1data, 
+	     v2data, v3data, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkbbd.c b/src/arkode/fcmix/farkbbd.c
new file mode 100644
index 0000000..15db62f
--- /dev/null
+++ b/src/arkode/fcmix/farkbbd.c
@@ -0,0 +1,129 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This module contains the routines necessary to interface with 
+ * the ARKBBDPRE module and user-supplied Fortran routines.
+ * The routines here call the generically named routines and 
+ * providea standard interface to the C code of the ARKBBDPRE 
+ * package.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "farkbbd.h"
+#include <arkode/arkode_bbdpre.h>
+
+/*=============================================================*/
+
+/* Prototypes of the Fortran routines */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_GLOCFN(long int *NLOC, realtype *T, 
+			  realtype *YLOC, realtype *GLOC,
+			  long int *IPAR, realtype *RPAR,
+			  int *ier);
+  extern void FARK_COMMFN(long int *NLOC, realtype *T, 
+			  realtype *Y, long int *IPAR, 
+			  realtype *RPAR, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKBBDPrecInit; see farkbbd.h 
+   for further details. */
+void FARK_BBDINIT(long int *Nloc, long int *mudq, long int *mldq, 
+		  long int *mu, long int *ml, realtype* dqrely, 
+		  int *ier)
+{
+  /* Notes: FARKgloc is a pointer to the ARKLocalFn function, 
+     and FARKcfn is a pointer to the ARKCommFn function */
+  *ier = ARKBBDPrecInit(ARK_arkodemem, *Nloc, *mudq, *mldq, 
+			*mu, *ml, *dqrely, FARKgloc, FARKcfn);
+  return; 
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKBBDPrecReInit; see farkbbd.h 
+   for further details. */
+void FARK_BBDREINIT(long int *Nloc, long int *mudq, 
+		    long int *mldq, realtype* dqrely, int *ier)
+{
+  *ier = ARKBBDPrecReInit(ARK_arkodemem, *mudq, *mldq, *dqrely);
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKGLOCFN; see 
+   farkbbd.h for further details. */
+int FARKgloc(long int Nloc, realtype t, N_Vector yloc, 
+	     N_Vector gloc, void *user_data)
+{
+  int ier;
+  realtype *yloc_data, *gloc_data;
+  FARKUserData ARK_userdata;
+
+  yloc_data = N_VGetArrayPointer(yloc);
+  gloc_data = N_VGetArrayPointer(gloc);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_GLOCFN(&Nloc, &t, yloc_data, gloc_data, 
+             ARK_userdata->ipar, ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKCOMMFN; see 
+   farkbbd.h for further details. */
+int FARKcfn(long int Nloc, realtype t, 
+	    N_Vector y, void *user_data)
+{
+  int ier;
+  realtype *yloc;
+  FARKUserData ARK_userdata;
+
+  yloc = N_VGetArrayPointer(y);
+  ARK_userdata = (FARKUserData) user_data;
+  FARK_COMMFN(&Nloc, &t, yloc, ARK_userdata->ipar, 
+	      ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routines ARKBBDPrecGetWorkSpace and 
+   ARKBBDPrecGetNumGfnEvals; see farkbbd.h for further details */
+void FARK_BBDOPT(long int *lenrwbbd, long int *leniwbbd, 
+		 long int *ngebbd)
+{
+  ARKBBDPrecGetWorkSpace(ARK_arkodemem, lenrwbbd, leniwbbd);
+  ARKBBDPrecGetNumGfnEvals(ARK_arkodemem, ngebbd);
+  return;
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkbbd.h b/src/arkode/fcmix/farkbbd.h
new file mode 100644
index 0000000..2a82efe
--- /dev/null
+++ b/src/arkode/fcmix/farkbbd.h
@@ -0,0 +1,645 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the Fortran interface include file for the BBD
+ * preconditioner (ARKBBDPRE)
+ *--------------------------------------------------------------*/
+
+/*===============================================================
+                   FARKBBD Interface Package
+ 
+ The FARKBBD Interface Package is a package of C functions which,
+ together with the FARKODE Interface Package, support the use of
+ the ARKODE solver and parallel N_Vector module, along with the 
+ ARKBBDPRE preconditioner module, for the solution of ODE systems
+ in a mixed Fortran/C setting.  The combination of ARKODE and 
+ ARKBBDPRE solves the linear systems arising from the solution 
+ of the implicit portions of the ODE system
+       dy/dt = fe(t,y) + fi(t,y)  
+ using a Krylov iterative linear solver (SPGMR, SPTFQMR, SPBCG, 
+ SPFGMR or PCG), and with a preconditioner that is block-diagonal 
+ with banded blocks.  While ARKODE and ARKBBDPRE are written in C, 
+ it is assumed here that the user's calling program and user-
+ supplied problem-defining routines are written in Fortran.
+ 
+ The user-callable functions in this package, with the 
+ corresponding ARKODE and ARKBBDPRE functions, are as follows: 
+
+   Fortran               ARKODE
+   --------------        ---------------------------
+   FARKBBDININT          ARKBBDPrecInit
+   FARKBBDREINIT         ARKBBDPrecReInit
+   FARKBBDOPT            (accesses optional outputs)
+   --------------        ---------------------------
+ 
+ In addition to the Fortran implicit right-hand side function 
+ FARKIFUN, the user-supplied functions used by this package are
+ listed below, each with the corresponding interface function 
+ which calls it (and its type within ARKBBDPRE or ARKODE):
+
+   Fortran          ARKODE           Type
+   -------------    ----------       ----------------
+   FARKGLOCFN       FARKgloc         ARKLocalFn
+   FARKCOMMFN       FARKcfn          ARKCommFn
+   FARKJTIMES(*)    FARKJtimes       ARKSpilsJtimesFn
+   -------------    ----------       ----------------
+   (*) = optional
+
+ Important notes on portability:
+
+ The names of all user-supplied routines here are fixed, in 
+ order to maximize portability for the resulting mixed-language 
+ program.
+
+ Additionally, the names of the interface functions, and the 
+ names of the Fortran user routines called by them, appear as 
+ dummy names which are mapped to actual values by a series of 
+ definitions in the header file farkbbd.h.
+ 
+ ================================================================
+ 
+            Usage of the FARKODE/FARKBBD Interface Packages
+ 
+ The usage of the combined interface packages FARKODE and 
+ FARKBBD requires calls to seven to twelve interface functions, 
+ and three or four user-supplied routines which define the 
+ problem to be solved and indirectly define the preconditioner.  
+ These function calls and user routines are summarized separately
+ below.
+ 
+ Some details are omitted, and the user is referred to the ARKODE
+ user document for more complete information.
+ 
+ (1) User-supplied implicit right-hand side routine: FARKIFUN
+     If any portion of the ODE system should be treated 
+     implicitly (and hence would require a linear solver at all),
+     the user must supply the following Fortran routine:
+
+       SUBROUTINE FARKIFUN(T, Y, YDOT, IPAR, RPAR, IER)
+
+     Sets the YDOT array to fi(T,Y), the implicit portion of the 
+     right-hand side of the ODE system, as function of time T and
+     the state variable array Y.
+
+     The arguments are:
+       Y    -- array containing state variables [realtype, input]
+       YDOT -- array containing state derivatives [realtype, 
+               output]
+       IPAR -- array containing integer user data that was passed
+               to FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                 >0 if a recoverable error occurred,
+                 <0 if an unrecoverable error ocurred.
+ 
+ (2) User-supplied routines to define preconditoner: FARKGLOCFN
+     and FARKCOMMFN
+ 
+     The routines in the ARKBBDPRE module provide a 
+     preconditioner matrix for ARKODE that is block-diagonal 
+     with banded blocks.  The blocking corresponds to the 
+     distribution of the dependent variable vector y among the 
+     processors.  Each preconditioner block is generated from the
+     Jacobian of the local part (on the current processor) of a 
+     given function g(t,y) approximating fi(t,y).  The blocks are
+     generated by a difference quotient scheme on each processor
+     independently, utilizing an assumed banded structure with
+     given half-bandwidths.  A separate pair of half-bandwidths
+     defines the band matrix retained.
+ 
+ (2.1) Local approximate function FARKGLOCFN.
+
+     The user must supply a subroutine of the form
+
+       SUBROUTINE FARKGLOCFN(NLOC, T, YLOC, GLOC, IPAR, 
+      &                      RPAR, IER)
+       DIMENSION YLOC(*), GLOC(*), IPAR(*), RPAR(*)
+
+     Sets the GLOC array to the function g(T,YLOC) which 
+     approximates the right-hand side function fi(T,YLOC).  This 
+     function is to be computed locally, i.e. without 
+     inter-processor communication (the case where g is 
+     mathematically identical to fi is allowed).  
+
+     The arguments are:
+       NLOC -- local problem size [long int, input]
+       T    -- current time [realtype, input]
+       YLOC -- array containing local state variables 
+               [realtype, input]
+       GLOC -- array containing local state derivatives 
+               [realtype, output]
+       IPAR -- array containing integer user data that was passed
+               to FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                 >0 if a recoverable error occurred,
+                 <0 if an unrecoverable error ocurred.
+ 
+ (2.2) Communication function FARKCOMMFN.
+
+     The user must also supply a subroutine of the form:
+
+       SUBROUTINE FARKCOMMFN(NLOC, T, YLOC, IPAR, RPAR, IER)
+       DIMENSION YLOC(*), IPAR(*), RPAR(*)
+
+     This performs all inter-processor communication necessary to
+     evaluate g described above.  It is expected to save 
+     communicated data in work space defined by the user, and 
+     made available to ARKLOCFN.  Each call to the FARKCOMMFN is
+     preceded by a call to FARKIFUN with the same (T,YLOC) 
+     arguments.  Thus FARKCOMMFN can omit any communications done
+     by FARKIFUN if relevant to the evaluation of g.
+
+     The arguments are:
+       NLOC -- local problem size [long int, input]
+       T    -- current time [realtype, input]
+       YLOC -- array containing local state variables 
+               [realtype, input]
+       IPAR -- array containing integer user data that was passed
+               to FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                 >0 if a recoverable error occurred,
+                 <0 if an unrecoverable error ocurred.
+ 
+ (3) Optional user-supplied Jacobian-vector product: FARKJTIMES
+
+     As an option, the user may supply a routine that computes 
+     the product of the system Jacobian  J = dfi(t,y)/dy and a 
+     given vector v.  If supplied, it must have the following 
+     form:
+
+       SUBROUTINE FARKJTIMES(V, FJV, T, Y, FY, H, IPAR, RPAR, 
+      &                      WORK, IER)
+
+     Typically this routine will use only NEQ, T, Y, V, and FJV. 
+     It must compute the product vector J*v where the vector V, 
+     and store the product in FJV.  
+
+     The arguments are:
+       V    -- vector to multiply [realtype, input]
+       FJV  -- product vector [realtype, output]
+       T    -- current time [realtype, input]
+       Y    -- state variables [realtype, input]
+       FY   -- state derivatives [realtype, input]
+       H    -- current step size [realtype, input]
+       IPAR -- array containing integer user data that was passed
+               to FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       WORK -- array containing temporary workspace of same size
+               as Y [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                  nonzero if an error.
+
+ (4) Initialization:  FNVINITP, FARKMALLOC, linear solver
+     initialization, and FARKBBDINIT.
+ 
+ (4.1) To initialize the parallel vector specification, the user
+     must make the following call:
+
+        CALL FNVINITP(4, NLOCAL, NGLOBAL, IER)
+
+     where the first argument is an int containing the ARKODE 
+     solver ID (4). The other arguments are:
+        NLOCAL = local vector size on this processor 
+	   [long int, input]
+        NGLOBAL = system size, and the global size of vectors 
+	   (the sum of all values of NLOCAL) [long int, input]
+        IER = return completion flag [int, ouptut]. 
+                  0 = success, 
+                 -1 = failure.
+
+     Note: If MPI was initialized by the user, the communicator 
+     must be set to MPI_COMM_WORLD.  If not, this routine 
+     initializes MPI and sets the communicator equal to 
+     MPI_COMM_WORLD.
+ 
+ (4.2) To set various problem and solution parameters and 
+     allocate internal memory, make the following call:
+
+       CALL FARKMALLOC(T0, Y0, IMEX, IATOL, RTOL, ATOL, IOUT,
+      &                ROUT, IPAR, RPAR, IER)
+
+     The arguments are:
+        T0 = initial value of t [realtype, input]
+	Y0 = array of initial conditions [realtype, input]
+	IMEX = flag denoting integration method [int, input]: 
+                  0 = implicit, 
+                  1 = explicit, 
+                  2 = imex
+        IATOL = type for absolute tolerance ATOL [int, input]: 
+                  1 = scalar, 
+                  2 = array,
+                  3 = user-supplied function; the user must 
+                      supply a routine FARKEWT to compute the 
+		      error weight vector.
+        RTOL = scalar relative tolerance [realtype, input]
+	ATOL = scalar/array absolute tolerance [realtype, input]
+	IOUT = array of length 22 for integer optional outputs
+	   [long int, output]
+	ROUT = array of length 6 for real optional outputs 
+	   [realtype, output]
+	IPAR = array of user integer data [long int, in/out]
+	RPAR = array with user real data [realtype, in/out]
+	IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+                 -1 = failure (see printed message for details).
+
+     The user data arrays IPAR and RPAR are passed unmodified to 
+     all subsequent calls to user-provided routines. Changes to
+     either array inside a user-provided routine will be 
+     propagated. Using these two arrays, the user can dispense 
+     with COMMON blocks to pass data betwen user-provided 
+     routines. 
+
+ (4.3) Attach one of the SPILS linear solvers.
+    
+ (4.3A) To specify the SPGMR (Scaled Preconditioned GMRES) 
+     linear solver make the following call:
+
+       CALL FARKSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPGMR linear solver, then following the call to 
+     FARKREINIT, a call to the FARKSPGMRREINIT routine is needed
+     if any of IPRETYPE, IGSTYPE, DELT is being changed.  In that
+     case, call FARKSPGMRREINIT as follows:
+
+       CALL FARKSPGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPGMR.  If 
+     MAXL is being changed, then the user should call FARKSPGMR 
+     instead.
+ 
+ (4.3B) To specify the SPBCG (Scaled Preconditioned Bi-CGSTAB) 
+     linear solver make the following call:
+
+       CALL FARKSPBCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 
+              0 = default.
+       DELT = convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPBCG linear solver, then following the call to 
+     FARKREINIT, a call to the FARKSPBCGREINIT routine is needed
+     if any of its arguments is being changed.  The call is:
+
+       CALL FARKSPBCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKSPBCG.
+
+ (4.3C) To specify the SPTFQMR (Scaled Preconditioned TFQMR) 
+     linear solver make the following call:
+
+       CALL FARKSPTFQMR(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 
+              0 = default.
+       DELT = convergence tolerance factor [realtype, input]
+	      0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPTFQMR linear solver, then following the call to
+     FARKREINIT, a call to the FARKSPTFQMRREINIT routine is 
+     needed if any of its arguments is being changed.  The call 
+     is:
+
+       CALL FARKSPTFQMRREINIT(IPRETYPE, MAXL, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPTFQMR.
+
+ (4.3D) To specify the SPFGMR (Scaled Preconditioned Flexible GMRES) 
+     linear solver make the following call:
+
+       CALL FARKSPFGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPFGMR linear solver, then following the call to 
+     FARKREINIT, a call to the FARKSPFGMRREINIT routine is needed
+     if any of IPRETYPE, IGSTYPE, DELT is being changed.  In that
+     case, call FARKSPFGMRREINIT as follows:
+
+       CALL FARKSPFGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPFGMR.  If 
+     MAXL is being changed, then the user should call FARKSPFGMR 
+     instead.
+ 
+ (4.3E) To specify the PCG (Preconditioned Conjugate Gradient) 
+     linear solver make the following call:
+
+       CALL FARKPCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = use preconditioning
+       MAXL = maximum Krylov subspace dimension [int, input]; 
+              0 = default.
+       DELT = convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the PCG linear solver, then following the call to 
+     FARKREINIT, a call to the FARKPCGREINIT routine is needed
+     if any of its arguments is being changed.  The call is:
+
+       CALL FARKPCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKPCG.
+
+ (4.4) To allocate memory and initialize data associated with the
+     ARKBBDPRE preconditioner, make the following call:
+
+       CALL FARKBBDINIT(NLOCAL, MUDQ, MLDQ, MU, ML, DQRELY, IER)
+ 
+      The arguments are:
+        NLOCAL = local vector size on this process 
+	     [long int, input]
+        MUDQ = upper half-bandwidth to be used in the computation
+             of the local Jacobian blocks by difference 
+	     quotients.  These may be smaller than the true 
+	     half-bandwidths of the Jacobian of the local block 
+	     of g, when smaller values may provide greater 
+	     efficiency [long int, input]
+        MLDQ = lower half-bandwidth to be used in the computation
+             of the local Jacobian blocks by difference 
+	     quotients [long int, input]
+	MU = upper half-bandwidth of the band matrix that is
+	     retained as an approximation of the local Jacobian
+	     block (may be smaller than MUDQ) [long int, input]
+	ML = lower half-bandwidth of the band matrix that is
+	     retained as an approximation of the local Jacobian
+	     block (may be smaller than MLDQ) [long int, input]
+	DQRELY = relative increment factor in y for difference 
+	     quotients [realtype, input]
+                    0.0 = default (sqrt(unit roundoff))
+        IER = return completion flag [int, output]:
+                    0 = success
+                   <0 = an error occurred
+
+ (4.5) To specify whether the Krylov linear solver should use the
+     supplied FARKJTIMES or the internal finite difference 
+     approximation, make the call
+
+        CALL FARKSPILSSETJAC(FLAG, IER)
+
+     with the int FLAG=1 to specify that FARKJTIMES is provided 
+     (FLAG=0 specifies to use and internal finite difference 
+     approximation to this product).  The int return flag IER=0
+     if successful, and nonzero otherwise.
+ 
+ (5) Re-initialization: FARKREINIT, FARKBBDREINIT
+
+     If a sequence of problems of the same size is being solved
+     using the Krylov linear solver in combination with the 
+     ARKBBDPRE preconditioner, then the ARKODE package can be 
+     reinitialized for the second and subsequent problems so as
+     to avoid further memory allocation.  First, in place of the
+     call to FARKMALLOC, make the following call:
+
+       CALL FARKREINIT(T0, Y0, IMEX, IATOL, RTOL, ATOL, IER)
+
+     The arguments have the same names and meanings as those of 
+     FARKMALLOC.  FARKREINIT performs the same initializations 
+     as FARKMALLOC, but does no memory allocation, using instead
+     the existing internal memory created by the previous 
+     FARKMALLOC call.  The subsequent call to specify the linear 
+     system solution method may or may not be needed.
+
+     If there is a change in any of the linear solver arguments,
+     then a call to FARKSPGMR, FARKSPBCG, FARKSPTFQMR, FARKSPFGMR
+     or FARKPCG must also be made; in this case the linear solver 
+     memory is reallocated. 
+
+     Following the call to FARKREINIT, a call to FARKBBDINIT may
+     or may not be needed.  If the input arguments are the same,
+     no FARKBBDINIT call is needed. If there is a change in input
+     arguments, then make the call
+
+       CALL FARKBBDREINIT(NLOCAL, MUDQ, MLDQ, DQRELY, IER)
+ 
+     This reinitializes the BBD preconditioner, but without 
+     reallocating its memory.  The arguments of the have the same
+     names and meanings as FARKBBDINIT.  If the value of MU or ML
+     is being changed, then a call to FARKBBDINIT must be made.
+ 
+ (6) The integrator: FARKODE
+
+     Carrying out the integration is accomplished by making calls
+     as follows:
+
+       CALL FARKODE(TOUT, T, Y, ITASK, IER)
+
+     The arguments are:
+       TOUT = next value of t at which a solution is desired 
+           [realtype, input]
+       T = value of t reached by the solver [realtype, output]
+       Y = state variable array on output [realtype, output]
+       ITASK = task indicator [int, input]:
+                 1 = normal mode (overshoot TOUT and interpolate)
+		 2 = one-step mode (return after each internal 
+		     step taken)
+		 3 = normal tstop mode (like 1, but integration 
+		     never proceeds past TSTOP, which must be 
+		     specified through a call to FARKSETRIN using
+		     the key 'STOP_TIME')
+		 4 = one step tstop (like 2, but integration 
+		     never goes past TSTOP)
+       IER = completion flag [int, output]: 
+                  0 = success, 
+		  1 = tstop return, 
+		  2 = root return, 
+                  values -1 ... -10 are failure modes (see 
+		     ARKODE manual).
+     The current values of the optional outputs are immediately 
+     available in the IOUT and ROUT arrays.
+ 
+ (7) Optional outputs: FARKBBDOPT
+
+     Optional outputs specific to the SP* linear solvers are:
+        LENRWLS = IOUT(14) from ARKSp*GetWorkSpace (real space)
+        LENIWLS = IOUT(15) from ARKSp*GetWorkSpace (int space)
+        LSTF    = IOUT(16) from ARKSp*GetLastFlag
+        NFELS   = IOUT(17) from ARKSp*GetRhsEvals
+        NJTV    = IOUT(18) from ARKSp*GetJtimesEvals
+        NPE     = IOUT(19) from ARKSp*GetPrecEvals
+        NPS     = IOUT(20) from ARKSp*GetPrecSolves
+        NLI     = IOUT(21) from ARKSp*GetLinIters
+        NCFL    = IOUT(22) from ARKSp*GetConvFails
+     See the ARKODE manual for descriptions.
+
+     To obtain the optional outputs associated with the ARKBBDPRE
+     module, make the following call:
+
+       CALL FARKBBDOPT(LENRWBBD, LENIWBBD, NGEBBD)
+
+     The arguments returned are:
+       LENRWBP = length of real preconditioner work space, in 
+           realtype words (this size is local to the current 
+	   processor if run in parallel) [long int, output]
+       LENIWBP = length of integer preconditioner work space, in
+           integer words (processor-local) [long int, output]
+       NGEBBD = number of g(t,y) evaluations (calls to ARKLOCFN)
+           so far [long int, output]
+ 
+ (8) Computing solution derivatives: FARKDKY
+
+     To obtain a derivative of the solution, of order up to the 
+     method order, make the following call:
+
+       CALL FARKDKY(T, K, DKY, IER)
+
+     The arguments are:
+       T = time at which solution derivative is desired, within 
+           the interval [TCUR-HU,TCUR], [realtype, input].
+       K = derivative order (0 .le. K .le. QU) [int, input]
+       DKY = array containing computed K-th derivative of y 
+           [realtype, output]
+       IER = return flag [int, output]: 
+                    0 = success
+		   <0 = illegal argument.
+ 
+ (9) Memory freeing: FARKFREE
+
+     To free the internal memory created by the calls to 
+     FARKMALLOC, FNVINITS or FNVINITP, and FARKBPINIT, make the
+     call:
+
+       CALL FARKFREE()
+
+===============================================================*/
+
+#ifndef _FARKBBD_H
+#define _FARKBBD_H
+
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_types.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* header files  */
+/* Definitions of interface function names */
+#if defined(SUNDIALS_F77_FUNC)
+
+#define FARK_BBDINIT    SUNDIALS_F77_FUNC(farkbbdinit,   FARKBBDINIT)
+#define FARK_BBDREINIT  SUNDIALS_F77_FUNC(farkbbdreinit, FARKBBDREINIT)
+#define FARK_BBDOPT     SUNDIALS_F77_FUNC(farkbbdopt,    FARKBBDOPT)
+#define FARK_GLOCFN     SUNDIALS_F77_FUNC(farkglocfn,    FARKGLOCFN)
+#define FARK_COMMFN     SUNDIALS_F77_FUNC(farkcommfn,    FARKCOMMFN)
+
+#else
+
+#define FARK_BBDINIT    farkbbdinit_
+#define FARK_BBDREINIT  farkbbdreinit_
+#define FARK_BBDOPT     farkbbdopt_
+#define FARK_GLOCFN     farkglocfn_
+#define FARK_COMMFN     farkcommfn_
+
+#endif
+
+/* Prototypes of exported functions */
+void FARK_BBDINIT(long int *Nloc, long int *mudq, 
+		  long int *mldq, long int *mu, 
+		  long int *ml, realtype* dqrely, int *ier);
+void FARK_BBDREINIT(long int *Nloc, long int *mudq, 
+		    long int *mldq, realtype* dqrely, int *ier);
+void FARK_BBDOPT(long int *lenrwbbd, long int *leniwbbd, 
+		 long int *ngebbd);
+
+/* Prototypes: Functions Called by the ARKBBDPRE Module */
+int FARKgloc(long int Nloc, realtype t, N_Vector yloc, 
+	     N_Vector gloc, void *user_data);
+int FARKcfn(long int Nloc, realtype t, N_Vector y, 
+	    void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkbp.c b/src/arkode/fcmix/farkbp.c
new file mode 100644
index 0000000..e8b8909
--- /dev/null
+++ b/src/arkode/fcmix/farkbp.c
@@ -0,0 +1,55 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This module contains the routines necessary to interface with 
+ * the ARKBANDPRE module and user-supplied Fortran routines. The 
+ * routines here call the generically named routines and provide 
+ * a standard interface to the C code of the ARKBANDPRE package.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "farkbp.h"
+#include <arkode/arkode_bandpre.h>
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKBandPrecInit; see farkbp.h 
+   for additional information */
+void FARK_BPINIT(long int *N, long int *mu, 
+		 long int *ml, int *ier)
+{
+  *ier = ARKBandPrecInit(ARK_arkodemem, *N, *mu, *ml);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routines ARKBandPrecGetWorkSpace and 
+   ARKBandPrecGetNumRhsEvals; see farkbp.h for additional 
+   information */
+void FARK_BPOPT(long int *lenrwbp, long int *leniwbp, long int *nfebp)
+{
+  ARKBandPrecGetWorkSpace(ARK_arkodemem, lenrwbp, leniwbp);
+  ARKBandPrecGetNumRhsEvals(ARK_arkodemem, nfebp);
+  return;
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkbp.h b/src/arkode/fcmix/farkbp.h
new file mode 100644
index 0000000..682ffc2
--- /dev/null
+++ b/src/arkode/fcmix/farkbp.h
@@ -0,0 +1,491 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the Fortran interface include file for the BAND
+ * preconditioner (ARKBANDPRE).
+ *--------------------------------------------------------------*/
+
+/*===============================================================
+                  FARKBP Interface Package
+
+ The FARKBP Interface Package is a package of C functions which,
+ together with the FARKODE Interface Package, support the use of 
+ the ARKODE solver and N_VSerial vector module with the ARKBANDPRE
+ preconditioner module, for the solution of ODE systems in a mixed
+ Fortran/C setting.  The combination of ARKODE and ARKBANDPRE 
+ solves the linear systems arising from the solution of the 
+ implicit portions of the ODE system
+       dy/dt = fe(t,y) + fi(t,y)  
+ using a Krylov iterative linear solver (SPGMR, SPTFQMR, SPBCG, 
+ SPFGMR or PCG), and with a banded preconditioner.  This 
+ preconditioner can be constructed using either a user-supplied 
+ routine, or automatically via finite differencing.
+ 
+ The user-callable functions in this package, with the 
+ corresponding ARKODE and ARKBBDPRE functions, are as follows: 
+
+   Fortran              ARKODE
+   -------------        ---------------------------
+   FARKBPINIT           ARKBandPrecInit
+   FARKBPOPT            (accesses optional outputs)
+   -------------        ---------------------------
+ 
+ In addition to the Fortran implicit right-hand side function 
+ FARKIFUN, the user may (optionally) supply a routine FARKJTIMES 
+ that is called by the C interface function FARKJtimes of type 
+ ARKSpilsJtimesFn.  
+
+ 
+ Important notes on portability:
+
+ The names of all user-supplied routines here are fixed, in 
+ order to maximize portability for the resulting mixed-language 
+ program.
+
+ Additionally, the names of the interface functions, and the 
+ names of the Fortran user routines called by them, appear as 
+ dummy names which are mapped to actual values by a series of 
+ definitions in the header file farkbp.h.
+ 
+ ================================================================
+ 
+           Usage of the FARKODE/FARKBP Interface Packages
+ 
+ The usage of the combined interface packages FARKODE and FARKBP 
+ requires calls to seven to ten interface functions, and one or 
+ two user-supplied routines which define the problem to be solved
+ and indirectly define the preconditioner.  These function calls 
+ and user routines are summarized separately below.
+ 
+ Some details are omitted, and the user is referred to the ARKODE
+ user document for more complete information.
+ 
+ (1) User-supplied implicit right-hand side routine: FARKIFUN
+     If any portion of the ODE system should be treated 
+     implicitly (and hence would require a linear solver at all),
+     the user must supply the following Fortran routine:
+
+       SUBROUTINE FARKIFUN(T, Y, YDOT, IPAR, RPAR, IER)
+
+     Sets the YDOT array to fi(T,Y), the implicit portion of the 
+     right-hand side of the ODE system, as function of time T and
+     the state variable array Y.
+
+     The arguments are:
+       Y    -- array containing state variables [realtype, input]
+       YDOT -- array containing state derivatives [realtype, 
+               output]
+       IPAR -- array containing integer user data that was passed
+               to FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                 >0 if a recoverable error occurred,
+                 <0 if an unrecoverable error ocurred.
+ 
+ (2) Optional user-supplied Jacobian-vector product: FARKJTIMES
+
+     As an option, the user may supply a routine that computes 
+     the product of the system Jacobian  J = dfi(t,y)/dy and a 
+     given vector v.  If supplied, it must have the following 
+     form:
+
+       SUBROUTINE FARKJTIMES(V, FJV, T, Y, FY, H, IPAR, RPAR, 
+      &                      WORK, IER)
+
+     Typically this routine will use only NEQ, T, Y, V, and FJV. 
+     It must compute the product vector J*v where the vector V, 
+     and store the product in FJV.  
+
+     The arguments are:
+       V    -- vector to multiply [realtype, input]
+       FJV  -- product vector [realtype, output]
+       T    -- current time [realtype, input]
+       Y    -- state variables [realtype, input]
+       FY   -- state derivatives [realtype, input]
+       H    -- current step size [realtype, input]
+       IPAR -- array containing integer user data that was passed
+               to FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       WORK -- array containing temporary workspace of same size
+               as Y [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                  nonzero if an error.
+
+ (3) Initialization:  FNVINITS, FARKMALLOC, linear solver 
+     initialization, and FARKBPINIT.
+ 
+ (3.1) To initialize the serial vector specification, the user 
+      must make the following call:
+
+        CALL FNVINITS(4, NEQ, IER)
+
+     where the first argument is an int containing the ARKODE 
+     solver ID (4). The other arguments are:
+        NEQ = size of vectors [long int, input]
+	IER = return completion flag [int, output]:
+	          0 = success, 
+		 -1 = failure.
+ 
+ (3.2) To set various problem and solution parameters and 
+     allocate internal memory, make the following call:
+
+       CALL FARKMALLOC(T0, Y0, IMEX, IATOL, RTOL, ATOL, IOUT,
+      &                ROUT, IPAR, RPAR, IER)
+
+     The arguments are:
+        T0 = initial value of t [realtype, input]
+	Y0 = array of initial conditions [realtype, input]
+	IMEX = flag denoting integration method [int, input]: 
+                  0 = implicit, 
+                  1 = explicit, 
+                  2 = imex
+        IATOL = type for absolute tolerance ATOL [int, input]: 
+                  1 = scalar, 
+                  2 = array,
+                  3 = user-supplied function; the user must 
+                      supply a routine FARKEWT to compute the 
+		      error weight vector.
+        RTOL = scalar relative tolerance [realtype, input]
+	ATOL = scalar/array absolute tolerance [realtype, input]
+	IOUT = array of length 22 for integer optional outputs
+	   [long int, output]
+	ROUT = array of length 6 for real optional outputs 
+	   [realtype, output]
+	IPAR = array of user integer data [long int, in/out]
+	RPAR = array with user real data [realtype, in/out]
+	IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+                 -1 = failure (see printed message for details).
+
+     The user data arrays IPAR and RPAR are passed unmodified to 
+     all subsequent calls to user-provided routines. Changes to
+     either array inside a user-provided routine will be 
+     propagated. Using these two arrays, the user can dispense 
+     with COMMON blocks to pass data betwen user-provided 
+     routines. 
+
+ (3.3) Attach one of the 3 SPILS linear solvers.
+    
+ (3.3A) To specify the SPGMR (Scaled Preconditioned GMRES) 
+     linear solver make the following call:
+
+       CALL FARKSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPGMR linear solver, then following the call to 
+     FARKREINIT, a call to the FARKSPGMRREINIT routine is needed
+     if any of IPRETYPE, IGSTYPE, DELT is being changed.  In that
+     case, call FARKSPGMRREINIT as follows:
+
+       CALL FARKSPGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPGMR.  If 
+     MAXL is being changed, then the user should call FARKSPGMR 
+     instead.
+ 
+ (3.3B) To specify the SPBCG (Scaled Preconditioned Bi-CGSTAB) 
+     linear solver make the following call:
+
+       CALL FARKSPBCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 
+              0 = default.
+       DELT = convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPBCG linear solver, then following the call to 
+     FARKREINIT, a call to the FARKSPBCGREINIT routine is needed
+     if any of its arguments is being changed.  The call is:
+
+       CALL FARKSPBCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKSPBCG.
+
+ (3.3C) To specify the SPTFQMR (Scaled Preconditioned TFQMR) 
+     linear solver make the following call:
+
+       CALL FARKSPTFQMR(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 
+              0 = default.
+       DELT = convergence tolerance factor [realtype, input]
+	      0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPTFQMR linear solver, then following the call to
+     FARKREINIT, a call to the FARKSPTFQMRREINIT routine is 
+     needed if any of its arguments is being changed.  The call 
+     is:
+
+       CALL FARKSPTFQMRREINIT(IPRETYPE, MAXL, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPTFQMR.
+
+ (3.3D) To specify the SPFGMR (Scaled Preconditioned Flexible GMRES) 
+     linear solver make the following call:
+
+       CALL FARKSPFGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the SPFGMR linear solver, then following the call to 
+     FARKREINIT, a call to the FARKSPFGMRREINIT routine is needed
+     if any of IPRETYPE, IGSTYPE, DELT is being changed.  In that
+     case, call FARKSPFGMRREINIT as follows:
+
+       CALL FARKSPFGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPFGMR.  If 
+     MAXL is being changed, then the user should call FARKSPFGMR 
+     instead.
+ 
+ (3.3E) To specify the PCG (Preconditioned Conjugate Gradient) 
+     linear solver make the following call:
+
+       CALL FARKPCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = use preconditioning
+       MAXL = maximum Krylov subspace dimension [int, input]; 
+              0 = default.
+       DELT = convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     If a sequence of problems of the same size is being solved 
+     using the PCG linear solver, then following the call to 
+     FARKREINIT, a call to the FARKPCGREINIT routine is needed
+     if any of its arguments is being changed.  The call is:
+
+       CALL FARKPCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKPCG.
+
+ (3.4) To allocate memory and initialize data associated with the
+      ARKBANDPRE preconditioner, make the following call:
+
+        CALL FARKBPINIT(NEQ, MU, ML, IER)
+
+      The arguments are:
+        NEQ = problem size [long int, input]
+        MU = upper half-bandwidth of the band matrix that is 
+	     retained as an approximation of the Jacobian 
+	     [long int, input]
+        ML = lower half-bandwidth of the band matrix approximant
+	     to the Jacobian [long int, input]
+        IER = return completion flag [int, output]:
+                    0 = success
+                   <0 = an error occurred
+
+ (3.5) To specify whether the Krylov linear solver should use the
+     supplied FARKJTIMES or the internal finite difference 
+     approximation, make the call
+
+        CALL FARKSPILSSETJAC(FLAG, IER)
+
+     with the int FLAG=1 to specify that FARKJTIMES is provided 
+     (FLAG=0 specifies to use and internal finite difference 
+     approximation to this product).  The int return flag IER=0
+     if successful, and nonzero otherwise.
+ 
+ (4) The integrator: FARKODE
+
+     Carrying out the integration is accomplished by making calls
+     as follows:
+
+       CALL FARKODE(TOUT, T, Y, ITASK, IER)
+
+     The arguments are:
+       TOUT = next value of t at which a solution is desired 
+           [realtype, input]
+       T = value of t reached by the solver [realtype, output]
+       Y = state variable array on output [realtype, output]
+       ITASK = task indicator [int, input]:
+                 1 = normal mode (overshoot TOUT and interpolate)
+		 2 = one-step mode (return after each internal 
+		     step taken)
+		 3 = normal tstop mode (like 1, but integration 
+		     never proceeds past TSTOP, which must be 
+		     specified through a call to FARKSETRIN using
+		     the key 'STOP_TIME')
+		 4 = one step tstop (like 2, but integration 
+		     never goes past TSTOP)
+       IER = completion flag [int, output]: 
+                  0 = success, 
+		  1 = tstop return, 
+		  2 = root return, 
+                  values -1 ... -10 are failure modes (see 
+		     ARKODE manual).
+     The current values of the optional outputs are immediately 
+     available in the IOUT and ROUT arrays.
+ 
+ (5) Optional outputs: FARKBPOPT
+
+     Optional outputs specific to the SP* linear solvers are:
+        LENRWLS = IOUT(14) from ARKSp*GetWorkSpace (real space)
+        LENIWLS = IOUT(15) from ARKSp*GetWorkSpace (int space)
+        LSTF    = IOUT(16) from ARKSp*GetLastFlag
+        NFELS   = IOUT(17) from ARKSp*GetRhsEvals
+        NJTV    = IOUT(18) from ARKSp*GetJtimesEvals
+        NPE     = IOUT(19) from ARKSp*GetPrecEvals
+        NPS     = IOUT(20) from ARKSp*GetPrecSolves
+        NLI     = IOUT(21) from ARKSp*GetLinIters
+        NCFL    = IOUT(22) from ARKSp*GetConvFails
+     See the ARKODE manual for descriptions.
+
+     To obtain the optional outputs associated with the 
+     ARKBANDPRE module, make the following call:
+
+       CALL FARKBPOPT(LENRWBP, LENIWBP, NFEBP)
+
+     The arguments returned are:
+       LENRWBP = length of real preconditioner work space, in 
+           realtype words (this size is local to the current 
+	   processor if run in parallel) [long int, output]
+       LENIWBP = length of integer preconditioner work space, in
+           integer words (processor-local) [long int, output]
+       NFEBP = number of fi(t,y) evaluations [long int, output]
+ 
+ (6) Computing solution derivatives: FARKDKY
+
+     To obtain a derivative of the solution, of order up to the 
+     method order, make the following call:
+
+       CALL FARKDKY(T, K, DKY, IER)
+
+     The arguments are:
+       T = time at which solution derivative is desired, within 
+           the interval [TCUR-HU,TCUR], [realtype, input].
+       K = derivative order (0 .le. K .le. QU) [int, input]
+       DKY = array containing computed K-th derivative of y 
+           [realtype, output]
+       IER = return flag [int, output]: 
+                    0 = success
+		   <0 = illegal argument.
+ 
+ (7) Memory freeing: FARKFREE
+
+     To free the internal memory created by the calls to 
+     FARKMALLOC, FNVINITS or FNVINITP, and FARKBPINIT, make the
+     call:
+
+       CALL FARKFREE()
+ 
+===============================================================*/
+
+#ifndef _FARKBP_H
+#define _FARKBP_H
+
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_types.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* header files  */
+/* Definitions of interface function names */
+#if defined(SUNDIALS_F77_FUNC)
+
+#define FARK_BPINIT    SUNDIALS_F77_FUNC(farkbpinit, FARKBPINIT)
+#define FARK_BPOPT     SUNDIALS_F77_FUNC(farkbpopt, FARKBPOPT)
+
+#else
+
+#define FARK_BPINIT    farkbpinit_
+#define FARK_BPOPT     farkbpopt_
+
+#endif
+
+/* Prototypes of exported function */
+void FARK_BPINIT(long int *N, 
+		 long int *mu, 
+		 long int *ml, 
+		 int *ier);
+void FARK_BPOPT(long int *lenrwbp, 
+		long int *leniwbp, 
+		long int *nfebp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkdense.c b/src/arkode/fcmix/farkdense.c
new file mode 100644
index 0000000..fcb1a9b
--- /dev/null
+++ b/src/arkode/fcmix/farkdense.c
@@ -0,0 +1,90 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKDENSE, for the case
+ * of a user-supplied Jacobian approximation routine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_dense.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_DJAC(long int *N, realtype *T, realtype *Y, 
+			realtype *FY, realtype *DJAC, 
+			realtype *H, long int *IPAR, 
+			realtype *RPAR, realtype *V1, 
+			realtype *V2, realtype *V3, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKDlsSetDenseJacFn; see 
+   farkode.h for additional information */
+void FARK_DENSESETJAC(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKDlsSetDenseJacFn(ARK_arkodemem, NULL);
+  } else {
+    *ier = ARKDlsSetDenseJacFn(ARK_arkodemem, FARKDenseJac);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKDJAC; see 
+   farkode.h for additional information  */
+int FARKDenseJac(long int N, realtype t, N_Vector y, N_Vector fy, 
+                 DlsMat J, void *user_data, N_Vector vtemp1, 
+                 N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *ydata, *fydata, *jacdata, *v1data, *v2data, *v3data;
+  realtype h;
+  FARKUserData ARK_userdata;
+
+  ARKodeGetLastStep(ARK_arkodemem, &h);
+  ydata   = N_VGetArrayPointer(y);
+  fydata  = N_VGetArrayPointer(fy);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  jacdata = DENSE_COL(J,0);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_DJAC(&N, &t, ydata, fydata, jacdata, &h, 
+            ARK_userdata->ipar, ARK_userdata->rpar, v1data, 
+            v2data, v3data, &ier); 
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkdensemass.c b/src/arkode/fcmix/farkdensemass.c
new file mode 100644
index 0000000..3a0253d
--- /dev/null
+++ b/src/arkode/fcmix/farkdensemass.c
@@ -0,0 +1,78 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKDENSE, for the case
+ * of a user-supplied Jacobian approximation routine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_dense.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_DMASS(long int *N, realtype *T, 
+			 realtype *DMASS, long int *IPAR, 
+			 realtype *RPAR, realtype *V1, 
+			 realtype *V2, realtype *V3, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface routine to ARKDlsSetDenseMassFn; see 
+   farkode.h for further details */
+void FARK_DENSESETMASS(int *ier)
+{
+  *ier = ARKDlsSetDenseMassFn(ARK_arkodemem, FARKDenseMass);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKDMASS; see 
+   farkode.h for additional information  */
+int FARKDenseMass(long int N, realtype t, DlsMat M, void *user_data, 
+		  N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *massdata, *v1data, *v2data, *v3data;
+  FARKUserData ARK_userdata;
+
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  massdata = DENSE_COL(M,0);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_DMASS(&N, &t, massdata, ARK_userdata->ipar, ARK_userdata->rpar, 
+	     v1data, v2data, v3data, &ier); 
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkewt.c b/src/arkode/fcmix/farkewt.c
new file mode 100644
index 0000000..931365a
--- /dev/null
+++ b/src/arkode/fcmix/farkewt.c
@@ -0,0 +1,76 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE, for the case of a 
+ * user-supplied error weight calculation routine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_EWT(realtype *Y, realtype *EWT, 
+		       long int *IPAR, realtype *RPAR, 
+		       int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeWFtolerances; see 
+   farkode.h for further information */
+void FARK_EWTSET(int *flag, int *ier)
+{
+  if (*flag != 0) {
+    *ier = ARKodeWFtolerances(ARK_arkodemem, FARKEwt);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied fortran routine FARKEWT; see 
+   farkode.h for further information */
+int FARKEwt(N_Vector y, N_Vector ewt, void *user_data)
+{
+  int ier = 0;
+  realtype *ydata, *ewtdata;
+  FARKUserData ARK_userdata;
+
+  ydata  = N_VGetArrayPointer(y);
+  ewtdata = N_VGetArrayPointer(ewt);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_EWT(ydata, ewtdata, ARK_userdata->ipar, 
+	   ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkexpstab.c b/src/arkode/fcmix/farkexpstab.c
new file mode 100644
index 0000000..29587a7
--- /dev/null
+++ b/src/arkode/fcmix/farkexpstab.c
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE, for the case of a 
+ * user-supplied explicit stability routine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_EXPSTAB(realtype *Y, realtype *T, realtype *HSTAB, 
+			   long int *IPAR, realtype *RPAR, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetStabilityFn; see 
+   farkode.h for further information */
+void FARK_EXPSTABSET(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKodeSetStabilityFn(ARK_arkodemem, NULL, NULL);
+  } else {
+    *ier = ARKodeSetStabilityFn(ARK_arkodemem, FARKExpStab, 
+				ARK_arkodemem);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied fortran routine FARKEXPSTAB; see 
+   farkode.h for further information */
+int FARKExpStab(N_Vector y, realtype t, realtype *hstab, void *udata)
+{
+  int ier = 0;
+  realtype *ydata;
+  FARKUserData ARK_userdata;
+
+  ydata = N_VGetArrayPointer(y);
+  ARK_userdata = (FARKUserData) udata;
+
+  FARK_EXPSTAB(ydata, &t, hstab, ARK_userdata->ipar, 
+	       ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkjtimes.c b/src/arkode/fcmix/farkjtimes.c
new file mode 100644
index 0000000..f9ebdcf
--- /dev/null
+++ b/src/arkode/fcmix/farkjtimes.c
@@ -0,0 +1,90 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * The C function FARKJtimes is to interface between the ARKSP* 
+ * modules and the user-supplied Jacobian-vector product routine
+ * FARKJTIMES. Note the use of the generic name FARK_JTIMES in
+ * the code below.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_spils.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_JTIMES(realtype *V, realtype *JV, realtype *T, 
+			  realtype *Y, realtype *FY, realtype *H,
+			  long int *IPAR, realtype *RPAR,
+			  realtype *WRK, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSpilsSetJacTimesVecFn; see 
+   farkode.h for further information */
+void FARK_SPILSSETJAC(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKSpilsSetJacTimesVecFn(ARK_arkodemem, NULL);
+  } else {
+    *ier = ARKSpilsSetJacTimesVecFn(ARK_arkodemem, FARKJtimes);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKJTIMES; see
+   farkode.h for further information */
+int FARKJtimes(N_Vector v, N_Vector Jv, realtype t, N_Vector y, 
+	       N_Vector fy, void *user_data, N_Vector work)
+{
+  realtype *vdata, *Jvdata, *ydata, *fydata, *wkdata;
+  realtype h;
+  FARKUserData ARK_userdata;
+  int ier = 0;
+  
+  ARKodeGetLastStep(ARK_arkodemem, &h);
+
+  vdata  = N_VGetArrayPointer(v);
+  Jvdata = N_VGetArrayPointer(Jv);
+  ydata  = N_VGetArrayPointer(y);
+  fydata = N_VGetArrayPointer(fy);
+  wkdata = N_VGetArrayPointer(work);
+
+  ARK_userdata = (FARKUserData) user_data;
+ 
+  FARK_JTIMES(vdata, Jvdata, &t, ydata, fydata, &h, ARK_userdata->ipar, 
+	      ARK_userdata->rpar, wkdata, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkklu.c b/src/arkode/fcmix/farkklu.c
new file mode 100644
index 0000000..29df44d
--- /dev/null
+++ b/src/arkode/fcmix/farkklu.c
@@ -0,0 +1,66 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKKLU
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_klu.h>
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKKLU; see farkode.h for 
+   further details */
+void FARK_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier)
+{
+  *ier = ARKKLU(ARK_arkodemem, *neq, *nnz, *sparsetype);
+  ARKKLUSetOrdering(ARK_arkodemem, *ordering);
+  ARK_ls = ARK_LS_KLU;
+  return;
+}
+
+/* Fortran interface to C routine ARKKLUReinit; see farkode.h for 
+   further details */
+void FARK_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier)
+{
+  *ier = ARKKLUReInit(ARK_arkodemem, *neq, *nnz, *reinit_type);
+}
+
+/* Fortran interface to C routine ARKMassKLU; see farkode.h for 
+   further details */
+void FARK_MASSKLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier)
+{
+  *ier = ARKMassKLU(ARK_arkodemem, *neq, *nnz, *sparsetype, NULL);
+  ARKMassKLUSetOrdering(ARK_arkodemem, *ordering);
+  ARK_mass_ls = ARK_LS_KLU;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassKLUReinit; see farkode.h for 
+   further details */
+void FARK_MASSKLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier)
+{
+  *ier = ARKMassKLUReInit(ARK_arkodemem, *neq, *nnz, *reinit_type);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
+
diff --git a/src/arkode/fcmix/farklapack.c b/src/arkode/fcmix/farklapack.c
new file mode 100644
index 0000000..100e8cf
--- /dev/null
+++ b/src/arkode/fcmix/farklapack.c
@@ -0,0 +1,71 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKLAPACK
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_lapack.h>
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKLapackDense; see farkode.h 
+   for further information */
+void FARK_LAPACKDENSE(int *neq, int *ier)
+{
+  *ier = ARKLapackDense(ARK_arkodemem, *neq);
+  ARK_ls = ARK_LS_LAPACKDENSE;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassLapackDense; see farkode.h 
+   for further information */
+void FARK_MASSLAPACKDENSE(int *neq, int *ier)
+{
+  *ier = ARKMassLapackDense(ARK_arkodemem, *neq, NULL);
+  ARK_mass_ls = ARK_LS_LAPACKDENSE;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKLapackBand; see farkode.h 
+   for further information */
+void FARK_LAPACKBAND(int *neq, int *mupper, int *mlower, int *ier)
+{
+  *ier = ARKLapackBand(ARK_arkodemem, *neq, *mupper, *mlower);
+  ARK_ls = ARK_LS_LAPACKBAND;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassLapackBand; see farkode.h 
+   for further information */
+void FARK_MASSLAPACKBAND(int *neq, int *mupper, int *mlower, int *ier)
+{
+  *ier = ARKMassLapackBand(ARK_arkodemem, *neq, *mupper, 
+			   *mlower, NULL);
+  ARK_mass_ls = ARK_LS_LAPACKBAND;
+  return;
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
+
diff --git a/src/arkode/fcmix/farklapband.c b/src/arkode/fcmix/farklapband.c
new file mode 100644
index 0000000..5d5f44c
--- /dev/null
+++ b/src/arkode/fcmix/farklapband.c
@@ -0,0 +1,103 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKLAPACKBAND, for the 
+ * case of a user-supplied Jacobian approximation routine.                
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_lapack.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_BJAC(long int *N, long int *MU, long int *ML, 
+			long int *EBAND, realtype *T, 
+			realtype *Y, realtype *FY,
+			realtype *LBJAC, realtype *H,
+			long int *IPAR, realtype *RPAR,
+			realtype *V1, realtype *V2, 
+			realtype *V3, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface routine to ARKDlsSetBandJacFn; see farkode.h 
+   for further details */
+void FARK_LAPACKBANDSETJAC(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKDlsSetBandJacFn(ARK_arkodemem, NULL);
+  } else {
+    *ier = ARKDlsSetBandJacFn(ARK_arkodemem, FARKLapackBandJac);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* The C function FARKLapackBandJac interfaces between ARKODE 
+   and a Fortran subroutine FARKBJAC for the solution of a 
+   linear system using Lapack with band Jacobian approximation.
+   Addresses of arguments are passed to FARKBJAC, using the 
+   macro BAND_COL and the routine N_VGetArrayPointer from 
+   NVECTOR. The address passed for J is that of the element in 
+   column 0 with row index -mupper.  An extended bandwith equal
+   to (J->smu) + mlower + 1 is passed as the column dimension 
+   of the corresponding array */
+int FARKLapackBandJac(long int N, long int mupper, 
+		      long int mlower, realtype t, N_Vector y, 
+		      N_Vector fy, DlsMat J, void *user_data,
+		      N_Vector vtemp1, N_Vector vtemp2, 
+		      N_Vector vtemp3)
+{
+  int ier;
+  realtype *ydata, *fydata, *jacdata, *v1data, *v2data, *v3data;
+  realtype h;
+  long int eband;
+  FARKUserData ARK_userdata;
+
+  ARKodeGetLastStep(ARK_arkodemem, &h);
+  ydata   = N_VGetArrayPointer(y);
+  fydata  = N_VGetArrayPointer(fy);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  eband = (J->s_mu) + mlower + 1;
+  jacdata = BAND_COL(J,0) - mupper;
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_BJAC(&N, &mupper, &mlower, &eband, &t, ydata, fydata, 
+	    jacdata, &h, ARK_userdata->ipar, ARK_userdata->rpar, 
+	    v1data, v2data, v3data, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farklapbandmass.c b/src/arkode/fcmix/farklapbandmass.c
new file mode 100644
index 0000000..ea26675
--- /dev/null
+++ b/src/arkode/fcmix/farklapbandmass.c
@@ -0,0 +1,84 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKLAPACKBAND, for the 
+ * case of a user-supplied Jacobian approximation routine.                
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_lapack.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_BMASS(long int *N, long int *MU, long int *ML,
+			 long int *EBAND, realtype *T, 
+			 realtype *BMASS, long int *IPAR, 
+			 realtype *RPAR, realtype *V1, 
+			 realtype *V2, realtype *V3, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface routine to ARKDlsSetBandMassFn; see farkode.h 
+   for further details */
+void FARK_LAPACKBANDSETMASS(int *ier)
+{
+  *ier = ARKDlsSetBandMassFn(ARK_arkodemem, FARKLapackBandMass);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran subroutine FARKBMASS; see 
+   farkode.h for further details */
+int FARKLapackBandMass(long int N, long int mupper, 
+		       long int mlower, realtype t, DlsMat M, 
+		       void *user_data, N_Vector vtemp1, 
+		       N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *massdata, *v1data, *v2data, *v3data;
+  long int eband;
+  FARKUserData ARK_userdata;
+
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  eband   = (M->s_mu) + mlower + 1;
+  massdata = BAND_COL(M,0) - mupper;
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_BMASS(&N, &mupper, &mlower, &eband, &t, massdata, 
+	     ARK_userdata->ipar, ARK_userdata->rpar, v1data, 
+	     v2data, v3data, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farklapdense.c b/src/arkode/fcmix/farklapdense.c
new file mode 100644
index 0000000..48c635c
--- /dev/null
+++ b/src/arkode/fcmix/farklapdense.c
@@ -0,0 +1,93 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKLAPACKDENSE, for the
+ * case of a user-supplied Jacobian approximation routine.a
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_lapack.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routines */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+  extern void FARK_DJAC(long int *N, realtype *T, realtype *Y, 
+			realtype *FY, realtype *LDJAC,
+			realtype *H, long int *IPAR, 
+			realtype *RPAR, realtype *V1, 
+			realtype *V2, realtype *V3, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKDlsSetDenseJacFn; see 
+   farkode.h for additional information */
+void FARK_LAPACKDENSESETJAC(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKDlsSetDenseJacFn(ARK_arkodemem, NULL);
+  } else {
+    *ier = ARKDlsSetDenseJacFn(ARK_arkodemem, FARKLapackDenseJac);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* The C function FARKLapackDenseJac interfaces between ARKODE 
+   and a Fortran subroutine FARKDJAC for solution of a linear 
+   system using Lapack with dense Jacobian approximation.
+   Addresses of arguments are passed to FARKDJAC, using the macro 
+   DENSE_COL and the routine N_VGetArrayPointer from NVECTOR  */
+int FARKLapackDenseJac(long int N, realtype t, N_Vector y, 
+		       N_Vector fy, DlsMat J, void *user_data,
+		       N_Vector vtemp1, N_Vector vtemp2, 
+		       N_Vector vtemp3)
+{
+  int ier;
+  realtype *ydata, *fydata, *jacdata, *v1data, *v2data, *v3data;
+  realtype h;
+  FARKUserData ARK_userdata;
+
+  ARKodeGetLastStep(ARK_arkodemem, &h);
+  ydata   = N_VGetArrayPointer(y);
+  fydata  = N_VGetArrayPointer(fy);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  jacdata = DENSE_COL(J,0);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_DJAC(&N, &t, ydata, fydata, jacdata, &h, ARK_userdata->ipar, 
+	    ARK_userdata->rpar, v1data, v2data, v3data, &ier); 
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
+
diff --git a/src/arkode/fcmix/farklapdensemass.c b/src/arkode/fcmix/farklapdensemass.c
new file mode 100644
index 0000000..481df4e
--- /dev/null
+++ b/src/arkode/fcmix/farklapdensemass.c
@@ -0,0 +1,80 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKLAPACKDENSE, for the
+ * case of a user-supplied Jacobian approximation routine.a
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_lapack.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routines */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_DMASS(long int *N, realtype *T, 
+			 realtype *DMASS, long int *IPAR, 
+			 realtype *RPAR, realtype *V1, 
+			 realtype *V2, realtype *V3, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface routine to ARKDlsSetDenseMassFn; see 
+   farkode.h for further details */
+void FARK_LAPACKDENSESETMASS(int *ier)
+{
+  *ier = ARKDlsSetDenseMassFn(ARK_arkodemem, FARKLapackDenseMass);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKDMASS; see 
+   farkode.h for additional information  */
+int FARKLapackDenseMass(long int N, realtype t, DlsMat M, 
+			void *user_data, N_Vector vtemp1, 
+			N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *massdata, *v1data, *v2data, *v3data;
+  FARKUserData ARK_userdata;
+
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  massdata = DENSE_COL(M,0);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_DMASS(&N, &t, massdata, ARK_userdata->ipar, ARK_userdata->rpar, 
+	     v1data, v2data, v3data, &ier); 
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
+
diff --git a/src/arkode/fcmix/farkmasspreco.c b/src/arkode/fcmix/farkmasspreco.c
new file mode 100644
index 0000000..41eeae6
--- /dev/null
+++ b/src/arkode/fcmix/farkmasspreco.c
@@ -0,0 +1,110 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * The C function FARKPSet is to interface between the ARKSP*
+ * modules and the user-supplied preconditioner setup routine 
+ * FARKPSET. Note the use of the generic name FARK_PSET in the 
+ * code below.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_spils.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routines */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_MASSPSET(realtype *T, long int *IPAR, 
+			    realtype *RPAR, realtype *W1, 
+			    realtype *W2, realtype *W3, int *IER);
+  extern void FARK_MASSPSOL(realtype *T, realtype *R, realtype *Z, 
+			    realtype *DELTA, int *LR, long int *IPAR, 
+			    realtype *RPAR, realtype *WRK, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSpilsSetMassPreconditioner; see 
+   farkode.h for further details */
+void FARK_SPILSSETMASSPREC(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKSpilsSetMassPreconditioner(ARK_arkodemem, NULL, NULL);
+  } else {
+    *ier = ARKSpilsSetMassPreconditioner(ARK_arkodemem, 
+					 FARKMassPSet, FARKMassPSol);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKMASSPSET; see 
+   farkode.h for further details */
+int FARKMassPSet(realtype t, void *user_data, N_Vector vtemp1, 
+		 N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier = 0;
+  realtype *v1data, *v2data, *v3data;
+  FARKUserData ARK_userdata;
+
+  v1data = N_VGetArrayPointer(vtemp1);
+  v2data = N_VGetArrayPointer(vtemp2);
+  v3data = N_VGetArrayPointer(vtemp3);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_MASSPSET(&t, ARK_userdata->ipar, ARK_userdata->rpar,
+		v1data, v2data, v3data, &ier);
+  return(ier);
+}
+
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKMASSPSOL; see 
+   farkode.h for further details */
+int FARKMassPSol(realtype t, N_Vector r, N_Vector z, realtype delta,
+		 int lr, void *user_data, N_Vector vtemp)
+{
+  int ier = 0;
+  realtype *vtdata, *rdata, *zdata;
+  FARKUserData ARK_userdata;
+
+  vtdata = N_VGetArrayPointer(vtemp);
+  rdata  = N_VGetArrayPointer(r);
+  zdata  = N_VGetArrayPointer(z);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_MASSPSOL(&t, rdata, zdata, &delta, &lr, ARK_userdata->ipar, 
+		ARK_userdata->rpar, vtdata, &ier);
+  return(ier);
+}
+
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkmtimes.c b/src/arkode/fcmix/farkmtimes.c
new file mode 100644
index 0000000..d16050a
--- /dev/null
+++ b/src/arkode/fcmix/farkmtimes.c
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * The C function FARKJtimes is to interface between the ARKSP* 
+ * modules and the user-supplied Jacobian-vector product routine
+ * FARKJTIMES. Note the use of the generic name FARK_JTIMES in
+ * the code below.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_spils.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_MTIMES(realtype *V, realtype *MV, realtype *T, 
+			  long int *IPAR, realtype *RPAR, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSpilsSetMassTimesVecFn; see 
+   farkode.h for further information */
+void FARK_SPILSSETMASS(int *ier)
+{
+  ARKodeMem ark_mem;
+  ark_mem = (ARKodeMem) ARK_arkodemem;
+  *ier = ARKSpilsSetMassTimesVecFn(ARK_arkodemem, FARKMtimes, 
+				   ark_mem->ark_user_data);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKMTIMES; see
+   farkode.h for further information */
+int FARKMtimes(N_Vector v, N_Vector Mv, realtype t, void *user_data)
+{
+  realtype *vdata, *Mvdata;
+  FARKUserData ARK_userdata;
+  int ier = 0;
+  
+  vdata  = N_VGetArrayPointer(v);
+  Mvdata = N_VGetArrayPointer(Mv);
+  ARK_userdata = (FARKUserData) user_data;
+  FARK_MTIMES(vdata, Mvdata, &t, ARK_userdata->ipar, 
+	      ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkode.c b/src/arkode/fcmix/farkode.c
new file mode 100644
index 0000000..899a798
--- /dev/null
+++ b/src/arkode/fcmix/farkode.c
@@ -0,0 +1,1189 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the implementation file for the Fortran interface to
+ * the ARKODE package.  See farkode.h for usage.
+ * NOTE: some routines are necessarily stored elsewhere to avoid
+ * linking problems.  Therefore, see also farkpreco.c, farkpsol.c,
+ * farkjtimes.c, farkadapt.c and farkexpstab.c for all the 
+ * available options.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_band.h>
+#include <arkode/arkode_dense.h>
+#include <arkode/arkode_klu.h>
+#include <arkode/arkode_superlumt.h>
+#include <arkode/arkode_spgmr.h>
+#include <arkode/arkode_spbcgs.h>
+#include <arkode/arkode_sptfqmr.h>
+#include <arkode/arkode_spfgmr.h>
+#include <arkode/arkode_pcg.h>
+
+/*=============================================================*/
+
+/* Definitions for global variables shared between Fortran/C 
+   interface routines */
+void     *ARK_arkodemem;
+long int *ARK_iout;
+realtype *ARK_rout;
+int       ARK_nrtfn;
+int       ARK_ls;
+int       ARK_mass_ls;
+
+/*=============================================================*/
+
+/* Prototypes of the Fortran routines */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_IMP_FUN(realtype *T, realtype *Y, realtype *YDOT,
+			   long int *IPAR, realtype *RPAR, int *IER);
+  extern void FARK_EXP_FUN(realtype *T, realtype *Y, realtype *YDOT,
+			   long int *IPAR, realtype *RPAR, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface routine to initialize ARKode memory 
+   structure; functions as an all-in-one interface to the C 
+   routines ARKodeCreate, ARKodeSetUserData, ARKodeInit, and 
+   ARKodeSStolerances (or ARKodeSVtolerances); see farkode.h 
+   for further details */
+void FARK_MALLOC(realtype *t0, realtype *y0, int *imex, 
+		 int *iatol, realtype *rtol, realtype *atol, 
+		 long int *iout, realtype *rout, 
+		 long int *ipar, realtype *rpar, int *ier) {
+
+  N_Vector Vatol;
+  FARKUserData ARK_userdata;
+  realtype reltol, abstol;
+
+  *ier = 0;
+
+  /* Check for required vector operations */
+  if(F2C_ARKODE_vec->ops->nvgetarraypointer == NULL) {
+    *ier = -1;
+    printf("Error: getarraypointer vector operation is not implemented.\n\n");
+    return;
+  }
+  if(F2C_ARKODE_vec->ops->nvsetarraypointer == NULL) {
+    *ier = -1;
+    printf("Error: setarraypointer vector operation is not implemented.\n\n");
+    return;
+  }
+  if(F2C_ARKODE_vec->ops->nvcloneempty == NULL) {
+    *ier = -1;
+    printf("Error: cloneempty vector operation is not implemented.\n\n");
+    return;
+  }
+
+  /* Initialize all pointers to NULL */
+  ARK_arkodemem = NULL;
+  Vatol = NULL;
+
+  /* initialize global constants to zero */
+  ARK_nrtfn = 0;
+  ARK_ls = 0;
+  ARK_mass_ls = 0;
+
+  /* Create ARKODE object */
+  ARK_arkodemem = ARKodeCreate();
+  if (ARK_arkodemem == NULL) {
+    *ier = -1;
+    return;
+  }
+
+  /* Set and attach user data */
+  ARK_userdata = NULL;
+  ARK_userdata = (FARKUserData) malloc(sizeof *ARK_userdata);
+  if (ARK_userdata == NULL) {
+    *ier = -1;
+    return;
+  }
+  ARK_userdata->rpar = rpar;
+  ARK_userdata->ipar = ipar;
+  *ier = ARKodeSetUserData(ARK_arkodemem, ARK_userdata);
+  if(*ier != ARK_SUCCESS) {
+    free(ARK_userdata); ARK_userdata = NULL;
+    *ier = -1;
+    return;
+  }
+
+  /* Set data in F2C_ARKODE_vec to y0 */
+  N_VSetArrayPointer(y0, F2C_ARKODE_vec);
+
+  /* Call ARKodeInit based on imex argument */
+  switch (*imex) {
+  case 0:  /* purely implicit */
+    *ier = ARKodeInit(ARK_arkodemem, NULL, FARKfi, 
+		      *t0, F2C_ARKODE_vec);
+    break;
+  case 1:  /* purely explicit */
+    *ier = ARKodeInit(ARK_arkodemem, FARKfe, NULL, 
+		      *t0, F2C_ARKODE_vec);
+    break;
+  case 2:  /* imex */
+    *ier = ARKodeInit(ARK_arkodemem, FARKfe, FARKfi, 
+		      *t0, F2C_ARKODE_vec);
+    break;
+  }
+    
+  /* Reset data pointers */
+  N_VSetArrayPointer(NULL, F2C_ARKODE_vec);
+
+  /* On failure, exit */
+  if(*ier != ARK_SUCCESS) {
+    free(ARK_userdata);
+    ARK_userdata = NULL;
+    *ier = -1;
+    return;
+  }
+
+  /* Set tolerances -- if <= 0, keep as defaults */
+  reltol=1.e-4;
+  abstol=1.e-9;
+  if (*rtol > 0.0)  reltol = *rtol;
+  switch (*iatol) {
+  case 1:
+    if (*atol > 0.0)  abstol = *atol;
+    *ier = ARKodeSStolerances(ARK_arkodemem, reltol, abstol); 
+    break;
+  case 2:
+    Vatol = N_VCloneEmpty(F2C_ARKODE_vec);
+    if (Vatol == NULL) {
+      free(ARK_userdata);
+      ARK_userdata = NULL;
+      *ier = -1;
+      return;
+    }
+    N_VSetArrayPointer(atol, Vatol);
+    if (N_VMin(Vatol) <= 0.0)  N_VConst(abstol, Vatol);
+    *ier = ARKodeSVtolerances(ARK_arkodemem, reltol, Vatol);
+    N_VDestroy(Vatol);
+    break;
+  }
+
+  /* On failure, exit */
+  if(*ier != ARK_SUCCESS) {
+    free(ARK_userdata); 
+    ARK_userdata = NULL;
+    *ier = -1;
+    return;
+  }
+
+  /* store pointers to optional output arrays in global vars */
+  ARK_iout = iout;
+  ARK_rout = rout;
+
+  /* Store the unit roundoff in rout for user access */
+  ARK_rout[5] = UNIT_ROUNDOFF;
+
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface routine to re-initialize ARKode memory 
+   structure; functions as an all-in-one interface to the C 
+   routines ARKodeReInit and ARKodeSStolerances (or 
+   ARKodeSVtolerances); see farkode.h for further details */
+void FARK_REINIT(realtype *t0, realtype *y0, int *imex, int *iatol, 
+		 realtype *rtol, realtype *atol, int *ier) {
+
+  N_Vector Vatol;
+  realtype reltol, abstol;
+  *ier = 0;
+
+  /* Initialize all pointers to NULL */
+  Vatol = NULL;
+
+  /* Set data in F2C_ARKODE_vec to y0 */
+  N_VSetArrayPointer(y0, F2C_ARKODE_vec);
+
+  /* Call ARKodeReInit based on imex argument */
+  switch (*imex) {
+  case 0:  /* purely implicit */
+    *ier = ARKodeReInit(ARK_arkodemem, NULL, FARKfi, 
+			*t0, F2C_ARKODE_vec);
+    break;
+  case 1:  /* purely explicit */
+    *ier = ARKodeReInit(ARK_arkodemem, FARKfe, NULL, 
+			*t0, F2C_ARKODE_vec);
+    break;
+  case 2:  /* imex */
+    *ier = ARKodeReInit(ARK_arkodemem, FARKfe, FARKfi, 
+			*t0, F2C_ARKODE_vec);
+    break;
+  }
+
+  /* Reset data pointers */
+  N_VSetArrayPointer(NULL, F2C_ARKODE_vec);
+
+  /* On failure, exit */
+  if (*ier != ARK_SUCCESS) {
+    *ier = -1;
+    return;
+  }
+
+  /* Set tolerances */
+  reltol=1.e-4;
+  abstol=1.e-9;
+  if (*rtol > 0.0)  reltol = *rtol;
+  switch (*iatol) {
+  case 1:
+    if (*atol > 0.0)  abstol = *atol;
+    *ier = ARKodeSStolerances(ARK_arkodemem, reltol, abstol); 
+    break;
+  case 2:
+    Vatol = N_VCloneEmpty(F2C_ARKODE_vec);
+    if (Vatol == NULL) {
+      *ier = -1;
+      return;
+    }
+    N_VSetArrayPointer(atol, Vatol);
+    if (N_VMin(Vatol) <= 0.0)  N_VConst(abstol, Vatol);
+    *ier = ARKodeSVtolerances(ARK_arkodemem, reltol, Vatol);
+    N_VDestroy(Vatol);
+    break;
+  }
+
+  /* On failure, exit */
+  if (*ier != ARK_SUCCESS) {
+    *ier = -1;
+    return;
+  }
+
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface routine to re-initialize ARKode memory 
+   structure for a problem with a new size but similar time 
+   scale; functions as an all-in-one interface to the C 
+   routines ARKodeResize (and potentially ARKodeSVtolerances); 
+   see farkode.h for further details */
+void FARK_RESIZE(realtype *t0, realtype *y0, realtype *hscale,
+		 int *itol, realtype *rtol, realtype *atol, int *ier) {
+
+  *ier = 0;
+
+  /* Set data in F2C_ARKODE_vec to y0 */
+  N_VSetArrayPointer(y0, F2C_ARKODE_vec);
+  
+  /* Call ARKodeResize (currently does not allow Fortran 
+     user-supplied vector resize function) */
+  *ier = ARKodeResize(ARK_arkodemem, F2C_ARKODE_vec, *hscale,
+		      *t0, NULL, NULL);
+
+  /* Reset data pointer */
+  N_VSetArrayPointer(NULL, F2C_ARKODE_vec);
+
+  /* On failure, exit */
+  if (*ier != ARK_SUCCESS) {
+    *ier = -1;
+    return;
+  }
+
+  /* Set tolerances, based on itol argument */
+  if (*itol) {
+    N_Vector Vatol = NULL;
+    Vatol = N_VCloneEmpty(F2C_ARKODE_vec);
+    if (Vatol == NULL) {
+      *ier = -1;
+      return;
+    }
+    N_VSetArrayPointer(atol, Vatol);
+    *ier = ARKodeSVtolerances(ARK_arkodemem, *rtol, Vatol);
+    N_VDestroy(Vatol);
+  }
+
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetDefaults; see 
+   farkode.h for further details */
+void FARK_SETDEFAULTS(int *ier) {
+  *ier = ARKodeSetDefaults(ARK_arkodemem);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C "set" routines having integer 
+   arguments; see farkode.h for further details */
+void FARK_SETIIN(char key_name[], long int *ival, int *ier) {
+  if (!strncmp(key_name, "ORDER", 5)) 
+    *ier = ARKodeSetOrder(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "DENSE_ORDER", 11)) 
+    *ier = ARKodeSetDenseOrder(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "LINEAR", 6)) 
+    *ier = ARKodeSetLinear(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "NONLINEAR", 9)) 
+    *ier = ARKodeSetNonlinear(ARK_arkodemem);
+  else if (!strncmp(key_name, "FIXEDPOINT", 10)) 
+    *ier = ARKodeSetFixedPoint(ARK_arkodemem, (long int) *ival);
+  else if (!strncmp(key_name, "NEWTON", 6)) 
+    *ier = ARKodeSetNewton(ARK_arkodemem);
+  else if (!strncmp(key_name, "EXPLICIT", 8)) 
+    *ier = ARKodeSetExplicit(ARK_arkodemem);
+  else if (!strncmp(key_name, "IMPLICIT", 8)) 
+    *ier = ARKodeSetImplicit(ARK_arkodemem);
+  else if (!strncmp(key_name, "IMEX", 4)) 
+    *ier = ARKodeSetImEx(ARK_arkodemem);
+  else if (!strncmp(key_name, "IRK_TABLE_NUM", 13)) 
+    *ier = ARKodeSetIRKTableNum(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "ERK_TABLE_NUM", 13)) 
+    *ier = ARKodeSetERKTableNum(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "ARK_TABLE_NUM", 13)) 
+    *ier = ARKodeSetARKTableNum(ARK_arkodemem, (int) ival[0], (int) ival[1]);
+  else if (!strncmp(key_name, "MAX_NSTEPS", 10)) 
+    *ier = ARKodeSetMaxNumSteps(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "HNIL_WARNS", 10)) 
+    *ier = ARKodeSetMaxHnilWarns(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "PREDICT_METHOD", 14)) 
+    *ier = ARKodeSetPredictorMethod(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "MAX_ERRFAIL", 11)) 
+    *ier = ARKodeSetMaxErrTestFails(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "MAX_CONVFAIL", 12)) 
+    *ier = ARKodeSetMaxConvFails(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "MAX_NITERS", 10)) 
+    *ier = ARKodeSetMaxNonlinIters(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "ADAPT_SMALL_NEF", 15))
+    *ier = ARKodeSetSmallNumEFails(ARK_arkodemem, (int) *ival);
+  else if (!strncmp(key_name, "LSETUP_MSBP", 11))
+    *ier = ARKodeSetMaxStepsBetweenLSet(ARK_arkodemem, (int) *ival);
+  else {
+    *ier = -99;
+    printf("FARKSETIIN: Unrecognized key.\n\n");
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C "set" routines having real
+   arguments; see farkode.h for further details */
+void FARK_SETRIN(char key_name[], realtype *rval, int *ier) {
+  if (!strncmp(key_name, "INIT_STEP", 9)) 
+    *ier = ARKodeSetInitStep(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "MAX_STEP", 8)) 
+    *ier = ARKodeSetMaxStep(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "MIN_STEP", 8)) 
+    *ier = ARKodeSetMinStep(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "STOP_TIME", 9)) 
+    *ier = ARKodeSetStopTime(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "NLCONV_COEF", 11)) 
+    *ier = ARKodeSetNonlinConvCoef(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "ADAPT_CFL", 9))
+    *ier = ARKodeSetCFLFraction(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "ADAPT_SAFETY", 12)) 
+    *ier = ARKodeSetSafetyFactor(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "ADAPT_BIAS", 10))
+    *ier = ARKodeSetErrorBias(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "ADAPT_GROWTH", 12)) 
+    *ier = ARKodeSetMaxGrowth(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "ADAPT_BOUNDS", 12))
+    *ier = ARKodeSetFixedStepBounds(ARK_arkodemem, rval[0], rval[1]);
+  else if (!strncmp(key_name, "ADAPT_ETAMX1", 12))
+    *ier = ARKodeSetMaxFirstGrowth(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "ADAPT_ETAMXF", 12))
+    *ier = ARKodeSetMaxEFailGrowth(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "ADAPT_ETACF", 11))
+    *ier = ARKodeSetMaxCFailGrowth(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "NONLIN_CRDOWN", 11))
+    *ier = ARKodeSetNonlinCRDown(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "NONLIN_RDIV", 9))
+    *ier = ARKodeSetNonlinRDiv(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "LSETUP_DGMAX", 12))
+    *ier = ARKodeSetDeltaGammaMax(ARK_arkodemem, *rval);
+  else if (!strncmp(key_name, "FIXED_STEP", 10))
+    *ier = ARKodeSetFixedStep(ARK_arkodemem, *rval);
+  else {
+    *ier = -99;
+    printf("FARKSETRIN: Unrecognized key: %s\n\n",key_name);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetAdaptivityMethod; 
+   see farkode.h for further details */
+void FARK_SETADAPTMETHOD(int *imethod, int *idefault, int *ipq, 
+			 realtype *params, int *ier) {
+
+  *ier = ARKodeSetAdaptivityMethod(ARK_arkodemem, *imethod, 
+				   *idefault, *ipq, params);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetERKTable; see 
+   farkode.h for further details */
+void FARK_SETERKTABLE(int *s, int *q, int *p, realtype *c, realtype *A, 
+		      realtype *b, realtype *b2, int *ier) {
+  *ier = ARKodeSetERKTable(ARK_arkodemem, *s, *q, *p, c, A, b, b2);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetIRKTable; see 
+   farkode.h for further details */
+void FARK_SETIRKTABLE(int *s, int *q, int *p, realtype *c, realtype *A, 
+		      realtype *b, realtype *b2, int *ier) {
+  *ier = ARKodeSetIRKTable(ARK_arkodemem, *s, *q, *p, c, A, b, b2);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetARKTables; see 
+   farkode.h for further details */
+void FARK_SETARKTABLES(int *s, int *q, int *p, realtype *ci, 
+		       realtype *ce, realtype *Ai, realtype *Ae, 
+		       realtype *bi, realtype *be, realtype *b2i, 
+		       realtype *b2e, int *ier) {
+  *ier = ARKodeSetARKTables(ARK_arkodemem, *s, *q, *p, ci, 
+			    ce, Ai, Ae, bi, be, b2i, b2e);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface routine to set residual tolerance 
+   scalar/array; functions as an all-in-one interface to the C 
+   routines ARKodeResStolerance and ARKodeResVtolerance; 
+   see farkode.h for further details */
+void FARK_SETRESTOLERANCE(int *itol, realtype *atol, int *ier) {
+
+  N_Vector Vatol;
+  realtype abstol;
+
+  *ier = 0;
+
+  /* Set tolerance, based on itol argument */
+  abstol=1.e-9;
+  switch (*itol) {
+  case 1:
+    if (*atol > 0.0)  abstol = *atol;
+    *ier = ARKodeResStolerance(ARK_arkodemem, abstol); 
+    break;
+  case 2:
+    Vatol = NULL;
+    Vatol = N_VCloneEmpty(F2C_ARKODE_vec);
+    if (Vatol == NULL) {
+      *ier = -1;
+      return;
+    }
+    N_VSetArrayPointer(atol, Vatol);
+    if (N_VMin(Vatol) <= 0.0)  N_VConst(abstol, Vatol);
+    *ier = ARKodeResVtolerance(ARK_arkodemem, Vatol);
+    N_VDestroy(Vatol);
+    break;
+  }
+
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeSetDiagnostics; see 
+   farkode.h for further details */
+void FARK_SETDIAGNOSTICS(char fname[], int *flen, int *ier) {
+  char *filename=NULL;
+  FILE *DFID=NULL;
+  int i;
+
+  /* copy fname into array of specified length */
+  filename = (char *) malloc((*flen)*sizeof(char));
+  for (i=0; i<*flen; i++)  filename[i] = fname[i];
+
+  /* open diagnostics output file */
+  DFID = fopen(filename,"w");
+  if (DFID == NULL) {
+    *ier = 1;
+    return;
+  }
+  *ier = ARKodeSetDiagnostics(ARK_arkodemem, DFID);
+  free(filename);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran routine to close diagnostics output file; see farkode.h 
+   for further details */
+void FARK_STOPDIAGNOSTICS(int *ier) {
+  ARKodeMem ark_mem;
+  if (ARK_arkodemem == NULL) {
+    *ier = 1;
+    return;
+  }
+  ark_mem = (ARKodeMem) ARK_arkodemem;
+
+  if (ark_mem->ark_diagfp == NULL) {
+    *ier = 1;
+    return;
+  }
+  *ier = fclose(ark_mem->ark_diagfp);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKDense; see farkode.h for 
+   further details */
+void FARK_DENSE(long int *neq, int *ier) {
+  *ier = ARKDense(ARK_arkodemem, *neq);
+  ARK_ls = ARK_LS_DENSE;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassDense; see farkode.h 
+   for further details */
+void FARK_MASSDENSE(long int *neq, int *ier) {
+  *ier = ARKMassDense(ARK_arkodemem, *neq, NULL);
+  ARK_mass_ls = ARK_LS_DENSE;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKBand; see farkode.h for 
+   further details */
+void FARK_BAND(long int *neq, long int *mupper, 
+	       long int *mlower, int *ier) {
+  *ier = ARKBand(ARK_arkodemem, *neq, *mupper, *mlower);
+  ARK_ls = ARK_LS_BAND;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassBand; see farkode.h 
+   for further details */
+void FARK_MASSBAND(long int *neq, long int *mupper, 
+		   long int *mlower, int *ier) {
+  *ier = ARKMassBand(ARK_arkodemem, *neq, *mupper, 
+		     *mlower, NULL);
+  ARK_mass_ls = ARK_LS_BAND;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSpgmr and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_SPGMR(int *pretype, int *gstype, int *maxl, 
+		realtype *delt, int *ier) {
+
+  *ier = ARKSpgmr(ARK_arkodemem, *pretype, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPGMR;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassSpgmr and it's 
+   associated "set" routines; see farkode.h for further details */
+void FARK_MASSSPGMR(int *pretype, int *gstype, int *maxl, 
+		    realtype *delt, int *ier) {
+
+  *ier = ARKMassSpgmr(ARK_arkodemem, *pretype, *maxl, NULL, NULL);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPGMR;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSpbcg and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_SPBCG(int *pretype, int *maxl, realtype *delt, int *ier) {
+
+  *ier = ARKSpbcg(ARK_arkodemem, *pretype, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPBCG;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassSpbcg and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_MASSSPBCG(int *pretype, int *maxl, 
+		    realtype *delt, int *ier) {
+
+  *ier = ARKMassSpbcg(ARK_arkodemem, *pretype, *maxl, NULL, NULL);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPBCG;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSptfqmr and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_SPTFQMR(int *pretype, int *maxl, realtype *delt, int *ier) {
+
+  *ier = ARKSptfqmr(ARK_arkodemem, *pretype, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPTFQMR;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassSptfqmr and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_MASSSPTFQMR(int *pretype, int *maxl, 
+		      realtype *delt, int *ier) {
+
+  *ier = ARKMassSptfqmr(ARK_arkodemem, *pretype, *maxl, NULL, NULL);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPTFQMR;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSpfgmr and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_SPFGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier) {
+
+  *ier = ARKSpfgmr(ARK_arkodemem, *pretype, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPFGMR;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassSpfgmr and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_MASSSPFGMR(int *pretype, int *gstype, int *maxl, 
+		     realtype *delt, int *ier) {
+
+  *ier = ARKMassSpfgmr(ARK_arkodemem, *pretype, *maxl, NULL, NULL);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPFGMR;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKPcg and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_PCG(int *pretype, int *maxl, realtype *delt, int *ier) {
+
+  *ier = ARKPcg(ARK_arkodemem, *pretype, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_PCG;
+  return;
+}
+
+/* Fortran interface to C routine ARKMassPcg and it's associated 
+   "set" routines; see farkode.h for further details */
+void FARK_MASSPCG(int *pretype, int *maxl, 
+		  realtype *delt, int *ier) {
+
+  *ier = ARKMassPcg(ARK_arkodemem, *pretype, *maxl, NULL, NULL);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_PCG;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C "set" routines for the ARKSpgmr solver; 
+   see farkode.h for further details */
+void FARK_SPGMRREINIT(int *pretype, int *gstype, 
+		      realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPGMR;
+  return;
+}
+
+/* Fortran interface to C "set" routines for the ARKMassSpgmr solver; 
+   see farkode.h for further details */
+void FARK_MASSSPGMRREINIT(int *pretype, int *gstype, 
+			  realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetMassPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPGMR;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C "set" routines for the ARKSpbcg solver; 
+   see farkode.h for further details */
+void FARK_SPBCGREINIT(int *pretype, int *maxl, 
+		      realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMaxl(ARK_arkodemem, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPBCG;
+  return;
+}
+
+/* Fortran interface to C "set" routines for the ARKMassSpbcg solver; 
+   see farkode.h for further details */
+void FARK_MASSSPBCGREINIT(int *pretype, int *maxl, 
+			  realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetMassPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassMaxl(ARK_arkodemem, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPBCG;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C "set" routines for the ARKSptfqmr
+   solver; see farkode.h for further details */
+void FARK_SPTFQMRREINIT(int *pretype, int *maxl, 
+			realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMaxl(ARK_arkodemem, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPTFQMR;
+  return;
+}
+
+/* Fortran interface to C "set" routines for the ARKMassSptfqmr
+   solver; see farkode.h for further details */
+void FARK_MASSSPTFQMRREINIT(int *pretype, int *maxl, 
+			    realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetMassPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassMaxl(ARK_arkodemem, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPTFQMR;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C "set" routines for the ARKSpfgmr solver; 
+   see farkode.h for further details */
+void FARK_SPFGMRREINIT(int *pretype, int *gstype, 
+		       realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_SPFGMR;
+  return;
+}
+
+/* Fortran interface to C "set" routines for the ARKMassSpfgmr solver; 
+   see farkode.h for further details */
+void FARK_MASSSPFGMRREINIT(int *pretype, int *gstype, 
+			   realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetMassPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassGSType(ARK_arkodemem, *gstype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_SPFGMR;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C "set" routines for the ARKPcg solver; 
+   see farkode.h for further details */
+void FARK_PCGREINIT(int *pretype, int *maxl, 
+		    realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMaxl(ARK_arkodemem, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_ls = ARK_LS_PCG;
+  return;
+}
+
+/* Fortran interface to C "set" routines for the ARKMassPcg solver; 
+   see farkode.h for further details */
+void FARK_MASSPCGREINIT(int *pretype, int *maxl, 
+			realtype *delt, int *ier) {
+
+  *ier = ARKSpilsSetMassPrecType(ARK_arkodemem, *pretype);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassMaxl(ARK_arkodemem, *maxl);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  *ier = ARKSpilsSetMassEpsLin(ARK_arkodemem, *delt);
+  if (*ier != ARKSPILS_SUCCESS) return;
+
+  ARK_mass_ls = ARK_LS_PCG;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKode (the main integrator); 
+   see farkode.h for further details */
+void FARK_ARKODE(realtype *tout, realtype *t, realtype *y, 
+		 int *itask, int *ier) {
+
+  /* attach user solution array to solver memory */
+  N_VSetArrayPointer(y, F2C_ARKODE_vec);
+
+  /* call ARKode solver */
+  *ier = ARKode(ARK_arkodemem, *tout, F2C_ARKODE_vec, t, *itask);
+
+  /* detach user solution array from solver memory */
+  N_VSetArrayPointer(NULL, F2C_ARKODE_vec);
+
+  /* Load optional outputs in iout & rout */
+  ARKodeGetWorkSpace(ARK_arkodemem,
+		     &ARK_iout[0],          /* LENRW   */
+		     &ARK_iout[1]);         /* LENIW   */
+  ARKodeGetIntegratorStats(ARK_arkodemem, 
+			   &ARK_iout[2],    /* NST     */
+			   &ARK_iout[3],    /* NST_STB */
+			   &ARK_iout[4],    /* NST_ACC */ 
+			   &ARK_iout[5],    /* NST_ATT */ 
+			   &ARK_iout[6],    /* NFE     */ 
+			   &ARK_iout[7],    /* NFI     */ 
+			   &ARK_iout[8],    /* NSETUPS */ 
+			   &ARK_iout[9],    /* NETF    */ 
+			   &ARK_rout[0],    /* H0U     */
+			   &ARK_rout[1],    /* HU      */ 
+			   &ARK_rout[2],    /* HCUR    */ 
+			   &ARK_rout[3]);   /* TCUR    */ 
+  ARKodeGetTolScaleFactor(ARK_arkodemem, 
+			  &ARK_rout[4]);    /* TOLSFAC */
+  ARKodeGetNonlinSolvStats(ARK_arkodemem,
+                          &ARK_iout[10],    /* NNI     */
+                          &ARK_iout[11]);   /* NCFN    */
+  
+  /* If root finding is on, load those outputs as well */
+  if (ARK_nrtfn != 0)
+    ARKodeGetNumGEvals(ARK_arkodemem, &ARK_iout[12]);  /* NGE */
+
+  /* Attach linear solver outputs */
+  switch(ARK_ls) {
+  case ARK_LS_DENSE:
+  case ARK_LS_BAND:
+  case ARK_LS_LAPACKDENSE:
+  case ARK_LS_LAPACKBAND:
+    ARKDlsGetWorkSpace(ARK_arkodemem, &ARK_iout[13], &ARK_iout[14]);  /* LENRWLS, LENIWLS */
+    ARKDlsGetLastFlag(ARK_arkodemem, &ARK_iout[15]);                  /* LSTF  */
+    ARKDlsGetNumRhsEvals(ARK_arkodemem, &ARK_iout[16]);               /* NFELS */
+    ARKDlsGetNumJacEvals(ARK_arkodemem, &ARK_iout[17]);               /* NJE   */
+    break;
+  case ARK_LS_KLU:
+  case ARK_LS_SUPERLUMT:
+    ARKSlsGetLastFlag(ARK_arkodemem, &ARK_iout[15]);                  /* LSTF  */
+    ARKSlsGetNumJacEvals(ARK_arkodemem, &ARK_iout[17]);               /* NJE   */
+    break;
+  case ARK_LS_SPGMR:
+  case ARK_LS_SPBCG:
+  case ARK_LS_SPTFQMR:
+  case ARK_LS_SPFGMR:
+  case ARK_LS_PCG:
+    ARKSpilsGetWorkSpace(ARK_arkodemem, &ARK_iout[13], &ARK_iout[14]); /* LENRWLS, LENIWLS */
+    ARKSpilsGetLastFlag(ARK_arkodemem, &ARK_iout[15]);                 /* LSTF  */
+    ARKSpilsGetNumRhsEvals(ARK_arkodemem, &ARK_iout[16]);              /* NFELS */
+    ARKSpilsGetNumJtimesEvals(ARK_arkodemem, &ARK_iout[17]);           /* NJTV  */
+    ARKSpilsGetNumPrecEvals(ARK_arkodemem, &ARK_iout[18]);             /* NPE   */
+    ARKSpilsGetNumPrecSolves(ARK_arkodemem, &ARK_iout[19]);            /* NPS   */
+    ARKSpilsGetNumLinIters(ARK_arkodemem, &ARK_iout[20]);              /* NLI   */
+    ARKSpilsGetNumConvFails(ARK_arkodemem, &ARK_iout[21]);             /* NCFL  */
+  }
+
+  /* Attach mass matrix linear solver outputs */
+  switch(ARK_mass_ls) {
+  case ARK_LS_DENSE:
+  case ARK_LS_BAND:
+  case ARK_LS_LAPACKDENSE:
+  case ARK_LS_LAPACKBAND:
+    ARKDlsGetMassWorkSpace(ARK_arkodemem, &ARK_iout[22], &ARK_iout[23]);  /* LENRWMS, LENIWMS */
+    ARKDlsGetLastMassFlag(ARK_arkodemem, &ARK_iout[24]);                  /* LSTMF */
+    ARKDlsGetNumMassEvals(ARK_arkodemem, &ARK_iout[25]);                  /* NME   */
+    break;
+  case ARK_LS_KLU:
+  case ARK_LS_SUPERLUMT:
+    ARKSlsGetLastMassFlag(ARK_arkodemem, &ARK_iout[24]);                  /* LSTMF */
+    ARKSlsGetNumMassEvals(ARK_arkodemem, &ARK_iout[25]);                  /* NME   */
+    break;
+  case ARK_LS_SPGMR:
+  case ARK_LS_SPBCG:
+  case ARK_LS_SPTFQMR:
+  case ARK_LS_SPFGMR:
+  case ARK_LS_PCG:
+    ARKSpilsGetMassWorkSpace(ARK_arkodemem, &ARK_iout[22], &ARK_iout[23]); /* LENRWMS, LENIWMS */
+    ARKSpilsGetLastMassFlag(ARK_arkodemem, &ARK_iout[24]);                 /* LSTMF */
+    ARKSpilsGetNumMassPrecEvals(ARK_arkodemem, &ARK_iout[25]);             /* NMPE  */
+    ARKSpilsGetNumMassPrecSolves(ARK_arkodemem, &ARK_iout[26]);            /* NMPS  */
+    ARKSpilsGetNumMassIters(ARK_arkodemem, &ARK_iout[27]);                 /* NMLI  */
+    ARKSpilsGetNumMassConvFails(ARK_arkodemem, &ARK_iout[28]);             /* NMCFL */
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeGetDky; see farkode.h 
+   for further details */
+void FARK_DKY(realtype *t, int *k, realtype *dky, int *ier) {
+
+  /* store pointer existing F2C_ARKODE_vec data array */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_ARKODE_vec);
+
+  /* attach output data array to F2C_ARKODE_vec */
+  N_VSetArrayPointer(dky, F2C_ARKODE_vec);
+
+  /* call ARKodeGetDky */
+  *ier = 0;
+  *ier = ARKodeGetDky(ARK_arkodemem, *t, *k, F2C_ARKODE_vec);
+
+  /* reattach F2C_ARKODE_vec to previous data array */
+  N_VSetArrayPointer(f2c_data, F2C_ARKODE_vec);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeGetErrWeights; see 
+   farkode.h for further details */
+void FARK_GETERRWEIGHTS(realtype *eweight, int *ier) {
+
+  /* store pointer existing F2C_ARKODE_vec data array */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_ARKODE_vec);
+
+  /* attach output data array to F2C_ARKODE_vec */
+  N_VSetArrayPointer(eweight, F2C_ARKODE_vec);
+
+  /* call ARKodeGetErrWeights */
+  *ier = 0;
+  *ier = ARKodeGetErrWeights(ARK_arkodemem, F2C_ARKODE_vec);
+
+  /* reattach F2C_ARKODE_vec to previous data array */
+  N_VSetArrayPointer(f2c_data, F2C_ARKODE_vec);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeGetEstLocalErrors; see 
+   farkode.h for further details */
+void FARK_GETESTLOCALERR(realtype *ele, int *ier) {
+
+  /* store pointer existing F2C_ARKODE_vec data array */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_ARKODE_vec);
+
+  /* attach output data array to F2C_ARKODE_vec */
+  N_VSetArrayPointer(ele, F2C_ARKODE_vec);
+
+  /* call ARKodeGetEstLocalErrors */
+  *ier = 0;
+  *ier = ARKodeGetEstLocalErrors(ARK_arkodemem, F2C_ARKODE_vec);
+
+  /* reattach F2C_ARKODE_vec to previous data array */
+  N_VSetArrayPointer(f2c_data, F2C_ARKODE_vec);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeFree; see farkode.h for 
+   further details */
+void FARK_FREE() {
+
+  ARKodeMem ark_mem;
+  ark_mem = (ARKodeMem) ARK_arkodemem;
+  free(ark_mem->ark_user_data); ark_mem->ark_user_data = NULL;
+
+  ARKodeFree(&ARK_arkodemem);
+
+  N_VSetArrayPointer(NULL, F2C_ARKODE_vec);
+  N_VDestroy(F2C_ARKODE_vec);
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeWriteParameters; see 
+   farkode.h for further details */
+void FARK_WRITEPARAMETERS(int *ier) {
+  *ier = ARKodeWriteParameters(ARK_arkodemem, stdout);
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied FORTRAN function FARKEFUN; see 
+   farkode.h for further details */
+int FARKfe(realtype t, N_Vector y, N_Vector ydot, void *user_data) {
+
+  int ier;
+  realtype *ydata, *dydata;
+  FARKUserData ARK_userdata;
+  ydata  = N_VGetArrayPointer(y);
+  dydata = N_VGetArrayPointer(ydot);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_EXP_FUN(&t, ydata, dydata, ARK_userdata->ipar, 
+	       ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied FORTRAN function FARKIFUN; see 
+   farkode.h for further details */
+int FARKfi(realtype t, N_Vector y, N_Vector ydot, void *user_data) {
+
+  int ier;
+  realtype *ydata, *dydata;
+  FARKUserData ARK_userdata;
+  ydata  = N_VGetArrayPointer(y);
+  dydata = N_VGetArrayPointer(ydot);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_IMP_FUN(&t, ydata, dydata, ARK_userdata->ipar, 
+	       ARK_userdata->rpar, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkode.h b/src/arkode/fcmix/farkode.h
new file mode 100644
index 0000000..c98665b
--- /dev/null
+++ b/src/arkode/fcmix/farkode.h
@@ -0,0 +1,2308 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the header file for FARKODE, the Fortran interface to
+ * the ARKODE package.                                            
+ *--------------------------------------------------------------*/
+
+/*===============================================================
+                FARKODE Interface Package
+
+ The FARKODE Interface Package is a package of C functions which 
+ support the use of the ARKODE solver, for the solution of ODE 
+ systems 
+         M(t) dy/dt = fe(t,y) + fi(t,y), 
+ in a mixed Fortran/C setting.  While ARKODE is written in C, it
+ is assumed here that the user's calling program and user-supplied
+ problem-defining routines are written in Fortran.  This package 
+ provides the necessary interface to ARKODE any acceptable NVECTOR
+ implementation.
+ 
+ A summary of the user-callable functions, with the corresponding 
+ ARKODE functions, are as follows:
+ 
+   Fortran                    ARKODE
+   ---------------------      --------------------------------
+   FNVINITS                   N_VNew_Serial
+   FNVINITP                   N_VNew_Parallel
+   FNVINITOMP                 N_VNew_OpenMP
+   FNVINITPTS                 N_VNew_Pthreads
+
+   FARKMALLOC                 ARKodeCreate, ARKodeSetUserData, 
+                                 and ARKodeInit
+   FARKREINIT                 ARKReInit
+   FARKRESIZE                 ARKResize
+   FARKSETIIN                 ARKodeSet* (integer arguments)
+   FARKSETRIN                 ARKodeSet* (real arguments)
+   FARKSETADAPTIVITYMETHOD    ARKodeSetAdaptivityMethod
+   FARKSETDEFAULTS            ARKodeSetDefaults
+   FARKSETERKTABLE            ARKodeSetERKTable
+   FARKSETIRKTABLE            ARKodeSetIRKTable
+   FARKSETARKTABLES           ARKodeSetARKTables
+   FARKSETRESTOLERANCE        ARKodeResStolerance, ARKodeResVtolerance
+   FARKEWTSET                 ARKodeWFtolerances
+   FARKADAPTSET               ARKodeSetAdaptivityFn
+   FARKEXPSTABSET             ARKodeSetStabilityFn
+   FARKSETDIAGNOSTICS         ARKodeSetDiagnostics
+   FARKSTOPDIAGNOSTICS        (none)
+
+   FARKDENSE                  ARKDense
+   FARKDENSESETJAC            ARKDlsSetDenseJacFn
+   FARKMASSDENSE              ARKMassDense
+   FARKDENSESETMASS           ARKDlsSetDenseMassFn
+
+   FARKBAND                   ARKBand
+   FARKBANDSETJAC             ARKDlsSetBandJacFn
+   FARKMASSBAND               ARKMassBand
+   FARKBANDSETMASS            ARKDlsSetBandMassFn
+
+   FARKLAPACKDENSE            ARKLapackDense
+   FARKLAPACKDENSESETJAC      ARKDlsSetDenseJacFn
+   FARKMASSLAPACKDENSE        ARKMassLapackDense
+   FARKLAPACKDENSESETMASS     ARKDlsSetDenseMassFn
+
+   FARKLAPACKBAND             ARKLapackBand
+   FARKLAPACKBANDSETJAC       ARKDlsSetBandJacFn
+   FARKMASSLAPACKBAND         ARKMassLapackBand
+   FARKLAPACKBANDSETMASS      ARKDlsSetBandMassFn
+
+   FARKKLU                    ARKKLU
+   FARKKLUREINIT              ARKKLUReinit
+   FARKSUPERLUMT              ARKSuperLUMT
+   FARKSPARSESETJAC           ARKSlsSetSparseJacFn
+   FARKMASSKLU                ARKMassKLU
+   FARKMASSKLUREINIT          ARKMassKLUReinit
+   FARKMASSSUPERLUMT          ARKMassSuperLUMT
+   FARKSPARSESETMASS          ARKSlsSetSparseMassFn
+
+   FARKSPGMR                  ARKSpgmr and ARKSpilsSet*
+   FARKSPGMRREINIT            ARKSpilsSet*
+   FARKMASSSPGMR              ARKMassSpgmr and ARKSpilsSetMass*
+   FARKMASSSPGMRREINIT        ARKSpilsSetMass*
+
+   FARKSPBCG                  ARKSpbcg and ARKSpilsSet*
+   FARKSPBCGREINIT            ARKSpilsSet*
+   FARKMASSSPBCG              ARKMassSpbcg and ARKSpilsSetMass*
+   FARKMASSSPBCGREINIT        ARKSpilsSetMass*
+
+   FARKSPTFQMR                ARKSptfqmr and ARKSpilsSet*
+   FARKSPTFQMRREINIT          ARKSpilsSet*
+   FARKMASSSPTFQMR            ARKMassSptfqmr and ARKSpilsSetMass*
+   FARKMASSSPTFQMRREINIT      ARKSpilsSetMass*
+
+   FARKSPFGMR                 ARKSpfgmr and ARKSpilsSet*
+   FARKSPFGMRREINIT           ARKSpilsSet*
+   FARKMASSSPFGMR             ARKwMASSMassSpfgmr and ARKSpilsSetMASS*
+   FARKMASSSPFGMRREINIT       ARKSpilsSetMASS*
+
+   FARKPCG                    ARKPcg and ARKSpilsSet*
+   FARKPCGREINIT              ARKSpilsSet*
+   FARKMASSPCG                ARKMASSPcg and ARKSpilsSetMASS*
+   FARKMASSPCGREINIT          ARKSpilsSetMASS*
+
+   FARKSPILSSETJAC            ARKSpilsSetJacTimesVecFn
+   FARKSPILSSETPREC           ARKSpilsSetPreconditioner
+   FARKSPILSSETMASS           ARKSpilsSetMassTimesVecFn
+   FARKSPILSSETMASSPREC       ARKSpilsSetMassPreconditioner
+ 
+   FARKODE                    ARKode, ARKodeGet*, and ARK*Get*
+   FARKDKY                    ARKodeGetDky
+
+   FARKGETERRWEIGHTS          ARKodeGetErrWeights
+   FARKGETESTLOCALERR         ARKodeGetEstLocalErrors
+
+   FARKFREE                   ARKodeFree
+   ---------------------      --------------------------------
+
+ 
+ The user-supplied functions, each listed with the corresponding interface
+ function which calls it (and its type within ARKODE), are as follows:
+
+   Fortran:           Interface Fcn:           ARKODE Type:
+   -------------      ------------------       -----------------------
+   FARKIFUN           FARKfi                   ARKRhsFn
+   FARKEFUN           FARKfe                   ARKRhsFn
+   FARKDJAC           FARKDenseJac             ARKDlsDenseJacFn
+   FARKDMASS          FARKDenseMass            ARKDlsDenseMassFn
+   FARKBJAC           FARKBandJac              ARKDlsBandJacFn
+   FARKBMASS          FARKBandMass             ARKDlsBandMassFn
+   FARKSPJAC          FARKSparseJac            ARKSlsSparseJacFn
+   FARKSPMASS         FARKSparseMass           ARKSlsSparseMassFn
+   FARKPSOL           FARKPSol                 ARKSpilsPrecSolveFn
+   FARKPSET           FARKPSet                 ARKSpilsPrecSetupFn
+   FARKMASSPSOL       FARKMassPSol             ARKSpilsMassPrecSolveFn
+   FARKMASSPSET       FARKMassPSet             ARKSpilsMassPrecSetupFn
+   FARKJTIMES         FARKJtimes               ARKSpilsJacTimesVecFn
+   FARKMTIMES         FARKMtimes               ARKSpilsMassTimesVecFn
+   FARKEWT            FARKEwt                  ARKEwtFn
+   FARKADAPT          FARKAdapt                ARKAdaptFn
+   FARKEXPSTAB        FARKExpStab              ARKExpStabFn
+   -------------      ------------------       -----------------------
+
+ In contrast to the case of direct use of ARKODE, and of most Fortran ODE
+ solvers, the names of all user-supplied routines here are fixed, in
+ order to maximize portability for the resulting mixed-language program.
+ 
+ Important note on portability:  In this package, the names of the interface 
+ functions, and the names of the Fortran user routines called by them, appear 
+ as dummy names which are mapped to actual values by a series of definitions, 
+ in this and other header files.
+ 
+ =============================================================================
+ 
+                  Usage of the FARKODE Interface Package
+ 
+ The usage of FARKODE requires calls to five or more interface
+ functions, depending on the method options selected, and one or more
+ user-supplied routines which define the problem to be solved.  These
+ function calls and user routines are summarized separately below.
+ 
+ Some details are omitted, and the user is referred to the ARKODE user 
+ documentation for more complete information.  Information on the arguments 
+ of any given user-callable interface routine, or of a given user-supplied 
+ function called by an interface function, can be found in the documentation 
+ on the corresponding function in the ARKODE package.
+ 
+ The number labels on the instructions below end with s for instructions
+ that are specific to use with the N_VSerial package; similarly those that 
+ end with p are specific to use with the N_VParallel package.
+
+ -----------------------------------------------------------------------------
+
+                               Data Types
+
+ Throughout this documentation, we will refer to data types according to their
+ usage in SUNDIALS.  The equivalent types to these may vary, depending on your
+ computer architecture and on how SUNDIALS was compiled.  A Fortran user 
+ should take care that all arguments passed through this Fortran/C interface 
+ are declared of the appropriate type.
+ 
+ Integers: SUNDIALS uses both 'int' and 'long int' types:
+   int      -- equivalent to an INTEGER or INTEGER*4 in Fortran
+   long int -- this will depend on the computer architecture:
+                 32-bit -- equivalent to an INTEGER or INTEGER*4 in Fortran
+                 64-bit -- equivalent to an INTEGER*8 in Fortran
+	      
+ Real numbers:  At compilation, SUNDIALS allows the configuration option 
+ '--with-precision', that accepts values of 'single', 'double' or 'extended' 
+ (the default is 'double').  This choice dictates the size of a SUNDIALS 
+ 'realtype' variable.  The corresponding Fortran types for these 'realtype' 
+ sizes are:
+   single   -- equivalent to a REAL or REAL*4 in Fortran
+   double   -- equivalent to a DOUBLE PRECISION or REAL*8 in Fortran
+   extended -- equivalent to a REAL*16 in Fortran
+
+ -----------------------------------------------------------------------------
+
+ (1) User-supplied right-hand side routines: FARKIFUN and FARKEFUN
+     The user must in all cases supply at least one of the following Fortran 
+     routines:
+
+       SUBROUTINE FARKIFUN(T, Y, YDOT, IPAR, RPAR, IER)
+
+     Sets the YDOT array to fi(T,Y), the implicit portion of the right-hand 
+     side of the ODE system, as function of time T and the state variable 
+     array Y.
+
+       SUBROUTINE FARKEFUN(T, Y, YDOT, IPAR, RPAR, IER)
+
+     Sets the YDOT array to fe(t,y), the explicit portion of the right-hand 
+     side of the ODE system, as function of time T and the state variable 
+     array Y.  
+
+     The arguments are:
+       Y    -- array containing state variables [realtype, input]
+       YDOT -- array containing state derivatives [realtype, output]
+       IPAR -- array containing integer user data that was passed to
+               FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                 >0 if a recoverable error occurred,
+                 <0 if an unrecoverable error ocurred.
+ 
+ (2s) Optional user-supplied dense Jacobian approximation routine: FARKDJAC
+
+     As an option when using the DENSE linear solver, the user may supply a
+     routine that computes a dense approximation of the system Jacobian 
+     J = dfi(t,y)/dy.  If supplied, it must have the following form:
+
+       SUBROUTINE FARKDJAC(NEQ, T, Y, FY, DJAC, H, IPAR, RPAR, WK1, WK2, 
+      &                    WK3, IER)
+
+     Typically this routine will use only NEQ, T, Y, and DJAC. It must compute
+     the Jacobian and store it column-wise in DJAC.
+
+     The arguments are:
+       NEQ  -- number of rows in the matrix [long int, input]
+       T    -- current time [realtype, input]
+       Y    -- array containing state variables [realtype, input]
+       FY   -- array containing state derivatives [realtype, input]
+       DJAC -- 2D array containing the jacobian entries [realtype of size
+               (NEQ,NEQ), output]
+       H    -- current step size [realtype, input]
+       IPAR -- array containing integer user data that was passed to
+               FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       WK*  -- array containing temporary workspace of same size as Y 
+               [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                 >0 if a recoverable error occurred,
+                 <0 if an unrecoverable error ocurred.
+ 
+ (2s) Optional user-supplied dense mass matrix routine: FARKDMASS
+
+     Required when using the DENSE or LAPACKDENSE mass matrix linear solvers,
+     the user must supply a routine that computes the system mass matrix M.  
+     This routine must have the following form: 
+
+       SUBROUTINE FARKDMASS(NEQ, T, DMASS, IPAR, RPAR, WK1, WK2, WK3, IER)
+
+     Typically this routine will use only NEQ, T, and DMASS. It must compute
+     the mass matrix and store it column-wise in DMASS.
+
+     The arguments are:
+       NEQ   -- number of rows in the matrix [long int, input]
+       T     -- current time [realtype, input]
+       DMASS -- 2D array containing the mass matrix entries [realtype 
+                of size (NEQ,NEQ), output]
+       IPAR  -- array containing integer user data that was passed to
+                FARKMALLOC [long int, input]
+       RPAR  -- array containing real user data that was passed to
+                FARKMALLOC [realtype, input]
+       WK*   -- array containing temporary workspace of same size as Y 
+                [realtype, input]
+       IER   -- return flag [int, output]:
+                   0 if successful, 
+                  >0 if a recoverable error occurred,
+                  <0 if an unrecoverable error ocurred.
+ 
+ (3s) Optional user-supplied band Jacobian approximation routine: FARKBJAC
+
+     As an option when using the BAND linear solver, the user may supply a
+     routine that computes a band approximation of the system Jacobian 
+     J = dfi(t,y)/dy. If supplied, it must have the following form:
+
+       SUBROUTINE FARKBJAC(NEQ, MU, ML, MDIM, T, Y, FY, BJAC, H,
+      &                    IPAR, RPAR, WK1, WK2, WK3, IER)
+
+     Typically this routine will use only NEQ, MU, ML, T, Y, and BJAC. It 
+     must load the MDIM by N array BJAC with the Jacobian matrix at the
+     current (t,y) in band form.  Store in BJAC(k,j) the Jacobian element 
+     J(i,j)  with k = i - j + MU + 1 (k = 1 ... ML+MU+1) and j = 1 ... N.
+
+     The arguments are:
+       NEQ  -- number of rows in the matrix [long int, input]
+       MU   -- upper half-bandwidth of the matrix [long int, input]
+       ML   -- lower half-bandwidth of the matrix [long int, input]
+       MDIM -- leading dimension of BJAC array [long int, input]
+       T    -- current time [realtype, input]
+       Y    -- array containing state variables [realtype, input]
+       FY   -- array containing state derivatives [realtype, input]
+       BJAC -- 2D array containing the jacobian entries [realtype of size
+               (MDIM,NEQ), output]
+       H    -- current step size [realtype, input]
+       IPAR -- array containing integer user data that was passed to
+               FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       WK*  -- array containing temporary workspace of same size as Y 
+               [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                 >0 if a recoverable error occurred,
+                 <0 if an unrecoverable error ocurred.
+ 
+ (4s) Optional user-supplied band Mass matrix routine: FARKBMASS
+
+     Required when using the BAND or LAPACKBAND mass matrix linear solvers, 
+     the user must supply a routine that computes the system mass matrix M.  
+     This routine must have the following form: 
+
+       SUBROUTINE FARKBMASS(NEQ, MU, ML, MDIM, T, BMASS, IPAR, 
+      &                     RPAR, WK1, WK2, WK3, IER)
+
+     Typically this routine will use only NEQ, MU, ML, T, and BMASS. It 
+     must load the MDIM by N array BMASS with the system mass matrix at 
+     the current (t) in band form.  Store in BMASS(k,j) the mass matrix 
+     element M(i,j)  with k = i - j + MU + 1 (k = 1 ... ML+MU+1) and 
+     j = 1 ... N.
+
+     The arguments are:
+       NEQ   -- number of rows in the matrix [long int, input]
+       MU    -- upper half-bandwidth of the matrix [long int, input]
+       ML    -- lower half-bandwidth of the matrix [long int, input]
+       MDIM  -- leading dimension of BMASS array [long int, input]
+       T     -- current time [realtype, input]
+       BMASS -- 2D array containing the mass matrix entries [realtype 
+                of size (MDIM,NEQ), output]
+       IPAR  -- array containing integer user data that was passed to
+                FARKMALLOC [long int, input]
+       RPAR  -- array containing real user data that was passed to
+                FARKMALLOC [realtype, input]
+       WK*   -- array containing temporary workspace of same size as Y 
+                [realtype, input]
+       IER   -- return flag [int, output]:
+                   0 if successful, 
+                  >0 if a recoverable error occurred,
+                  <0 if an unrecoverable error ocurred.
+ 
+ (5s) User-supplied sparse Jacobian approximation routine: FARKSPJAC
+
+     Required when using the ARKKLU or ARKSuperLUMT linear solvers, the 
+     user must supply a routine that computes a compressed-sparse-column 
+     [or compressed-sparse-row] approximation of the system Jacobian 
+     J = dfi(t,y)/dy.  This routine must have the following form:
+
+       SUBROUTINE FARKSPJAC(T, Y, FY, N, NNZ, JDATA, JRVALS, 
+      &                     JCPTRS, H, IPAR, RPAR, WK1, WK2, WK3, IER)
+
+     Typically this routine will use only M, N, NNZ, JDATA, JRVALS and 
+     JCPTRS. It must load the N by N compressed sparse column [or 
+     compressed sparse row] matrix with storage for NNZ nonzeros, stored 
+     in the arrays JDATA (nonzero values), JRVALS (row [or column] indices 
+     for each nonzero), JCOLPTRS (indices for start of each column [or row]), 
+     with the Jacobian matrix at the current (t,y) in CSC [or CSR] format 
+     (see sundials_sparse.h for more information).
+
+     The arguments are:
+         T    -- current time [realtype, input]
+         Y    -- array containing state variables [realtype, input]
+         FY   -- array containing state derivatives [realtype, input]
+         N    -- number of matrix rows/columns in Jacobian [int, input]
+         NNZ  -- allocated length of nonzero storage [int, input]
+        JDATA -- nonzero values in Jacobian
+                 [realtype of length NNZ, output]
+       JRVALS -- row [or column] indices for each nonzero in Jacobian
+                  [int of length NNZ, output]
+       JCPTRS -- pointers to each Jacobian column [or row] in preceding arrays
+                 [int of length N+1, output]
+         H    -- current step size [realtype, input]
+         IPAR -- array containing integer user data that was passed to
+                 FARKMALLOC [long int, input]
+         RPAR -- array containing real user data that was passed to
+                 FARKMALLOC [realtype, input]
+         WK*  -- array containing temporary workspace of same size as Y 
+                 [realtype, input]
+         IER  -- return flag [int, output]:
+                    0 if successful, 
+                   >0 if a recoverable error occurred,
+                   <0 if an unrecoverable error ocurred.
+ 
+ (6s) User-supplied sparse Mass matrix routine: FARKSPMASS
+
+     Required when using the ARKMassKLU or ARKMassSuperLUMT mass matrix 
+     linear solvers, the user must supply a routine that computes a 
+     compressed-sparse-column [or compressed-sparse-row] version of the 
+     (possibly time-dependent) system mass matrix M(t).  If supplied, 
+     it must have the following form:
+
+       SUBROUTINE FARKSPMASS(T, N, NNZ, MDATA, MRVALS, MCPTRS, 
+      &                      IPAR, RPAR, WK1, WK2, WK3, IER)
+
+     Typically this routine will use only M, N, NNZ, MDATA, MRVALS and 
+     MCPTRS. It must load the N by N compressed sparse column [or 
+     compressed sparse row] matrix with storage for NNZ nonzeros, stored 
+     in the arrays MDATA (nonzero values), MRVALS (row [or column] indices 
+     for each nonzero), MCOLPTRS (indices for start of each column [or row]), 
+     with the system mass matrix at the current (t) in CSC [or CSR] format 
+     (see sundials_sparse.h for more information).
+
+     The arguments are:
+         T    -- current time [realtype, input]
+         N    -- number of rows/columns in mass matrix [int, input]
+         NNZ  -- allocated length of nonzero storage [int, input]
+        MDATA -- nonzero values in mass matrix
+                 [realtype of length NNZ, output]
+       MRVALS -- row [or column] indices for each nonzero in mass matrix
+                  [int of length NNZ, output]
+       MCPTRS -- pointers to each mass matrix column [or row] in preceding arrays
+                 [int of length N+1, output]
+         IPAR -- array containing integer user data that was passed to
+                 FARKMALLOC [long int, input]
+         RPAR -- array containing real user data that was passed to
+                 FARKMALLOC [realtype, input]
+         WK*  -- array containing temporary workspace of same size as Y 
+                 [realtype, input]
+         IER  -- return flag [int, output]:
+                    0 if successful, 
+                   >0 if a recoverable error occurred,
+                   <0 if an unrecoverable error ocurred.
+ 
+ (7) Optional user-supplied Jacobian-vector product routine: FARKJTIMES
+
+     As an option when using the SP* linear solver, the user may supply a
+     routine that computes the product of the system Jacobian 
+     J = dfi(t,y)/dy and a given vector v.  If supplied, it must have the 
+     following form:
+
+       SUBROUTINE FARKJTIMES(V, JV, T, Y, FY, H, IPAR, RPAR, WORK, IER)
+
+     Typically this routine will use only NEQ, T, Y, V, and JV.  It must
+     compute the product vector J*v where v is stored in the vector V 
+     and the result J*v is stored in JV.  
+
+     The arguments are:
+       V    -- array containing vector to multiply [realtype, input]
+       JV   -- array containing product vector [realtype, output]
+       T    -- current time [realtype, input]
+       Y    -- array containing state variables [realtype, input]
+       FY   -- array containing state derivatives [realtype, input]
+       H    -- current step size [realtype, input]
+       IPAR -- array containing integer user data that was passed to
+               FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       WORK -- array containing temporary workspace of same size as Y 
+               [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                  nonzero if an error.
+ 
+ (8) User-supplied mass-matrix-vector product routine: FARKMTIMES
+
+     Required when using the SP* linear solvers, the user should supply a
+     routine that computes the product of the system mass matrix M and a 
+     given vector v.  It must have the following form:
+
+       SUBROUTINE FARKMTIMES(V, MV, T, IPAR, RPAR, IER)
+
+     Typically this routine will use only NEQ, T, V, and MV.  It must
+     compute the product vector M*v where v is stored in the vector V
+     and the result M*v is stored in MV.
+
+     The arguments are:
+       V    -- array containing vector to multiply [realtype, input]
+       MV   -- array containing product vector [realtype, output]
+       T    -- current time [realtype, input]
+       IPAR -- array containing integer user data that was passed to
+               FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                  nonzero if an error.
+ 
+ (9) Optional user-supplied error weight vector routine: FARKEWT
+ 
+     As an option to providing the relative and absolute tolerances, the user
+     may supply a routine that computes the weights used in the WRMS norms.
+     If supplied, it must have the following form:
+
+       SUBROUTINE FARKEWT(Y, EWT, IPAR, RPAR, IER)
+
+     It must store the error weights in EWT, given the current solution Y. 
+
+     The arguments are:
+       Y    -- array containing state variables [realtype, input]
+       EWT  -- array containing the error weight vector [realtype, output]
+       IPAR -- array containing integer user data that was passed to
+               FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                  nonzero if an error.
+
+ (10) Optional user-supplied error weight vector routine: FARKADAPT
+ 
+     As an option to providing the time step adaptivity, the user
+     may supply a routine that computes the new time step for ARKode to 
+     use, based on information about the three most recent errors and 
+     previous time steps taken by the solver. If supplied, it must have 
+     the following form:
+
+       SUBROUTINE FARKADAPT(Y, T, H1, H2, H3, E1, E2, E3, Q, P, HNEW, IPAR, RPAR, IER)
+
+     It must output the new time step in HNEW. 
+
+     The arguments are:
+       Y    -- array containing state variables [realtype, input]
+       T    -- current time [realtype, input]
+       H1   -- current step size [realtype, input]
+       H2   -- previous step size [realtype, input]
+       H3   -- previous-previous step size [realtype, input]
+       E1   -- estimated temporal error in current step [realtype, input]
+       E2   -- estimated temporal error in previous step [realtype, input]
+       E3   -- estimated temporal error in previous-previous step [realtype, input]
+       Q    -- global order of accuracy for RK method [int, input]
+       P    -- global order of accuracy for RK embedding [int, input]
+       HNEW -- predicted next step size [realtype, output]
+       IPAR -- array containing integer user data that was passed to
+               FARKMALLOC [long int, input]
+       RPAR -- array containing real user data that was passed to
+               FARKMALLOC [realtype, input]
+       IER  -- return flag [int, output]:
+                  0 if successful, 
+                  nonzero if an error.
+
+ (11) Optional user-supplied explicitly stable time step routine: FARKEXPSTAB
+ 
+     As an option, the user may provide a routine to return the maximum stable 
+     time step size for the explicit ODE RHS function.  If supplied, it must 
+     have the following form:
+
+       SUBROUTINE FARKEXPSTAB(Y, T, HSTAB, IPAR, RPAR, IER)
+
+     It must store the explicitly stable step size in the ouptut HSTAB. 
+
+     The arguments are:
+       Y     -- array containing state variables [realtype, input]
+       T     -- current time [realtype, input]
+       HSTAB -- explicitly-stable step size [realtype, output]
+       IPAR  -- array containing integer user data that was passed to
+                FARKMALLOC [long int, input]
+       RPAR  -- array containing real user data that was passed to
+                FARKMALLOC [realtype, input]
+       IER   -- return flag [int, output]:
+                  0 if successful, 
+                  nonzero if an error.
+
+ -----------------------------------------------------------------------------
+
+ (12) Initialization:  FNVINITS/FNVINITP/FNVINITOMP/FNVINITPTS, 
+                       FARKMALLOC, FARKREINIT, FARKRESIZE
+ 
+ (12.1s) To initialize the serial vector specification, the user must make the
+     following call:
+
+        CALL FNVINITS(4, NEQ, IER)
+
+     where the first argument is an int containing the ARKODE solver ID (4). 
+     The other arguments are:
+        NEQ = size of vectors [long int, input]
+	IER = return completion flag [int, output]:
+	          0 = success, 
+		 -1 = failure.
+ 
+ (12.1p) To initialize the distributed memory parallel machine environment, 
+        the user must make the following call:
+
+        CALL FNVINITP(COMM, 4, NLOCAL, NGLOBAL, IER)
+
+     The arguments are:
+        COMM = the MPI communicator [int, input]
+        NLOCAL = local size of vectors on this processor [long int, input]
+        NGLOBAL = the system size, and the global size of vectors (the sum 
+           of all values of NLOCAL) [long int, input]
+        IER = return completion flag [int, ouptut]. 
+                  0 = success, 
+                 -1 = failure.
+
+     Note: If MPI was initialized by the user, the communicator must be set to
+     MPI_COMM_WORLD.  If not, this routine initializes MPI and sets the
+     communicator equal to MPI_COMM_WORLD.
+ 
+ (12.1omp) To initialize the openMP threaded vector kernel, 
+          the user must make the following call:
+
+          CALL FNVINITOMP(3, NEQ, NUM_THREADS, IER)
+
+        The arguments are:
+          NEQ = size of vectors
+          NUM_THREADS = number of threads
+          IER = return completion flag. Values are 0 = success, -1 = failure.
+
+ (12.1pts) To initialize the Pthreads threaded vector kernel, 
+          the user must make the following call:
+
+          CALL FNVINITPTS(3, NEQ, NUM_THREADS, IER)
+
+        The arguments are:
+          NEQ = size of vectors
+          NUM_THREADS = number of threads
+          IER = return completion flag. Values are 0 = success, -1 = failure.
+
+ (12.2) To set various problem and solution parameters and allocate
+     internal memory, make the following call:
+
+       CALL FARKMALLOC(T0, Y0, IMEX, IATOL, RTOL, ATOL, IOUT, ROUT, 
+      &                IPAR, RPAR, IER)
+
+     The arguments are:
+        T0 = initial value of t [realtype, input]
+	Y0 = array of initial conditions [realtype, input]
+	IMEX = flag denoting basic integration method [int, input]: 
+                  0 = implicit, 
+                  1 = explicit, 
+                  2 = imex
+        IATOL = type for absolute tolerance ATOL [int, input]: 
+                  1 = scalar, 
+                  2 = array,
+                  3 = user-supplied function; the user must supply a routine
+		  FARKEWT to compute the error weight vector.
+        RTOL = scalar relative tolerance [realtype, input]
+	ATOL = scalar or array absolute tolerance [realtype, input]
+	IOUT = array of length 22 for integer optional outputs
+	   [long int, output]
+	ROUT = array of length 6 for real optional outputs [realtype, output]
+	IPAR = array of user integer data [long int, input/output]
+	RPAR = array with user real data [realtype, input/output]
+	IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+                 -1 = failure (see printed message for failure details).
+
+     The user data arrays IPAR and RPAR are passed unmodified to all 
+     subsequent calls to user-provided routines. Modifications to either array
+     inside a user-provided routine will be propagated. Using these two 
+     arrays, the user can dispense with COMMON blocks to pass data betwen 
+     user-provided routines. 
+ 
+     The optional outputs are:
+           LENRW   = IOUT( 1) from ARKodeGetWorkSpace
+           LENIW   = IOUT( 2) from ARKodeGetWorkSpace
+           NST     = IOUT( 3) from ARKodeGetNumSteps
+           NST_STB = IOUT( 4) from ARKodeGetNumExpSteps
+           NST_ACC = IOUT( 5) from ARKodeGetNumAccSteps
+           NST_ATT = IOUT( 6) from ARKodeGetNumStepAttempts
+           NFE     = IOUT( 7) from ARKodeGetNumRhsEvals (fe(t,y) calls)
+           NFI     = IOUT( 8) from ARKodeGetNumRhsEvals (fi(t,y) calls)
+           NSETUPS = IOUT( 9) from ARKodeGetNumLinSolvSetups
+           NETF    = IOUT(10) from ARKodeGetNumErrTestFails
+           NNI     = IOUT(11) from ARKodeGetNumNonlinSolvIters
+           NCFN    = IOUT(12) from ARKodeGetNumNonlinSolvConvFails
+           NGE     = IOUT(13) from ARKodeGetNumGEvals
+
+           H0U     = ROUT( 1) from ARKodeGetActualInitStep
+           HU      = ROUT( 2) from ARKodeGetLastStep
+           HCUR    = ROUT( 3) from ARKodeGetCurrentStep
+           TCUR    = ROUT( 4) from ARKodeGetCurrentTime
+           TOLSF   = ROUT( 5) from ARKodeGetTolScaleFactor
+           UROUND  = ROUT( 6) from UNIT_ROUNDOFF
+     See the ARKODE manual for details. 
+
+ (12.3) If the user program includes the FARKEWT routine for the evaluation 
+     of the error weights, the following call must be made
+
+       CALL FARKEWTSET(FLAG, IER)
+
+     with the int argument FLAG = 1 to specify that FARKEWT is provided and 
+     should be used; FLAG = 0 resets to the default EWT formulation.  The int 
+     return flag IER is 0 if successful, and nonzero otherwise.
+
+ (12.4) If the user program includes the FARKADAPT routine for performing 
+     step adaptivity, the following call must be made
+
+       CALL FARKADAPTSET(FLAG, IER)
+
+     with the int argument FLAG = 1 to specify that FARKADAPT is provided and 
+     should be used; FLAG = 0 resets to the default adaptivity formulation. 
+     The int return flag IER is 0 if successful, and nonzero otherwise.
+
+ (12.5) If the user program includes the FARKEXPSTAB routine for calculation of
+     the maximum explicitly stable step size, the following call must be made
+
+       CALL FARKEXPSTABSET(FLAG, IER)
+
+     with the int argument FLAG = 1 to specify that FARKEXPSTAB is provided and
+     should be used; FLAG = 0 resets to the default explicit stability formulation.
+     The int return flag IER is 0 if successful, and nonzero otherwise.
+
+ (12.6) To re-initialize the ARKODE solver for the solution of a new problem
+     of the same size as one already solved, make the following call:
+
+       CALL FARKREINIT(T0, Y0, IMEX, IATOL, RTOL, ATOL, IER)
+
+     The arguments have the same names and meanings as those of FARKMALLOC.  
+     FARKREINIT performs the same initializations as FARKMALLOC, but does no 
+     memory allocation, using instead the existing internal memory created by 
+     the previous FARKMALLOC call.  The subsequent call to specify the linear 
+     system solution method may or may not be needed; see paragraph (9) below.
+ 
+ (12.7) To re-initialize the ARKODE solver for the solution of a new problem
+     of a different size as one already solved, but with the same dynamical 
+     time scale and method choice, make the following call:
+
+       CALL FARKRESIZE(T0, Y0, HSCALE, ITOL, RTOL, ATOL, IER)
+
+     The arguments are:
+        T0 = initial value of t [realtype, input]
+	Y0 = array of initial conditions [realtype, input]
+	HSCALE = desired step size scale factor [realtype, input]
+	          1.0 is the default
+		  any value <= 0.0 results in the default.
+        ITOL = flag denoting that a new relative tolerance and vector of 
+	   absolute tolerances are supplied in the RTOL and ATOL arguments
+	   [int, input]: 
+                  0 = retain the current relative tolerance and current 
+		      scalar-valued or user-supplied function
+                  1 = RTOL contains the new scalar-valued relative tolerance 
+                      and ATOL contains a new array of absolute tolerances
+	RTOL = scalar-valued relative tolerance [realtype, input]
+	ATOL = array of absolute tolerances [realtype, input]
+	IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+                 -1 = failure (see printed message for failure details).
+
+     FARKRESIZE performs the opposite set of of operations as FARKREINIT: it 
+     does not reinitialize any of the time-step heuristics, but it does 
+     perform memory reallocation.  The subsequent call to specify the linear 
+     system solution method is required, since its internal memory 
+     structures will no longer be the correct size.; see paragraph (9) below.
+ 
+ (12.8) To set various integer optional inputs, make the folowing call:
+
+       CALL FARKSETIIN(KEY, VALUE, IER)
+
+     to set the integer value VALUE to the optional input specified by the 
+     quoted character string KEY. VALUE must be a Fortran integer of size 
+     commensurate with a C "long int".  KEY must be one of the following: 
+     ORDER, DENSE_ORDER, LINEAR, NONLINEAR, FIXEDPOINT, NEWTON, EXPLICIT, 
+     IMPLICIT, IMEX, IRK_TABLE_NUM, ERK_TABLE_NUM, ARK_TABLE_NUM (pass in an 
+     int array of length 2, implicit method first), MAX_NSTEPS, HNIL_WARNS, 
+     PREDICT_METHOD, MAX_ERRFAIL, MAX_CONVFAIL, MAX_NITERS, ADAPT_SMALL_NEF 
+     or LSETUP_MSBP.  The int return flag IER is 0 if successful, and 
+     nonzero otherwise.
+
+     To set various real optional inputs, make the following call:
+
+       CALL FARKSETRIN(KEY, VALUE, IER)
+
+     to set the realtype value VALUE to the optional input specified by the 
+     quoted character string KEY.  VALUE must be a Fortran real-valued number
+     of size commensurate with the SUNDIALS "realtype".  KEY must one of the 
+     following: INIT_STEP, MAX_STEP, MIN_STEP, STOP_TIME, NLCONV_COEF, 
+     ADAPT_CFL, ADAPT_SAFETY, ADAPT_BIAS, ADAPT_GROWTH, ADAPT_BOUNDS (pass in 
+     a realtype array of length 2), ADAPT_ETAMX1, ADAPT_ETAMXF, ADAPT_ETACF, 
+     NONLIN_CRDOWN, NONLIN_RDIV, LSETUP_DGMAX, or FIXED_STEP.
+
+     To set the time step adaptivity method (and its associated parameters), 
+     make the following call: 
+
+       CALL FARKSETADAPTIVITYMETHOD(IMETHOD, IDEFAULT, IPQ, PARAMS, IER)
+       
+     The arguments are:
+       IMETHOD  = the adaptivity method to use
+       IDEFAULT = flag to use (1) or not (0) the default adaptivity parameters
+       IPQ      = flag to use the embedding order p (0) or the method order 
+                  q (1) for error-based step adaptivity
+       PARAMS   = if IDEFAULT=0, this should be a realtype array of length 2 
+                  containing the custom adaptivity parameters to use in the 
+		  method.
+       IMETHOD  = integer error flag (0 = success, 1 = failure)
+
+     To reset all optional inputs to their default values, make the following 
+     call:
+
+       CALL FARKSETDEFAULTS(IER)
+
+     To set a custom explicit Runge-Kutta table, make the following call:
+
+       CALL FARKSETERKTABLE(S, Q, P, C, A, B, B2, IER)
+
+     The arguments are:
+       S = the number of stages in the table [int, input]
+       Q = the global order of accuracy of the method [int, input]
+       P = the global order of accuracy of the embedding [int, input]
+       C = array of length S containing the stage times [realtype, input]
+       A = array of length S*S containing the ERK coefficients (stored in 
+           row-major, "C", order) [realtype, input]
+       B = array of length S containing the solution coefficients
+           [realtype, input]
+       B2 = array of length S containing the embedding coefficients
+           [realtype, input]
+
+     To set a custom diagonally-implicit Runge-Kutta table, make the following
+     call:
+
+       CALL FARKSETIRKTABLE(S, Q, P, C, A, B, B2, IER)
+
+     The arguments are:
+       S = the number of stages in the table [int, input]
+       Q = the global order of accuracy of the method [int, input]
+       P = the global order of accuracy of the embedding [int, input]
+       C = array of length S containing the stage times [realtype, input]
+       A = array of length S*S containing the DIRK coefficients (stored in 
+           row-major, "C", order) [realtype, input]
+       B = array of length S containing the solution coefficients
+           [realtype, input]
+       B2 = array of length S containing the embedding coefficients
+           [realtype, input]
+
+     To set a custom additive Runge-Kutta table, make the following call:
+
+       CALL FARKSETARKTABLES(S, Q, P, CI, CE, AI, AE, BI, BE, B2I, B2E, IER)
+
+     The arguments are:
+       S = the number of stages in the table [int, input]
+       Q = the global order of accuracy of the method [int, input]
+       P = the global order of accuracy of the embedding [int, input]
+       CI = array of length S containing the implicit stage times
+           [realtype, input]
+       CE = array of length S containing the explicit stage times
+           [realtype, input]
+       AI = array of length S*S containing the DIRK coefficients (stored in 
+           row-major, "C", order) [realtype, input]
+       AE = array of length S*S containing the ERK coefficients (stored in 
+           row-major, "C", order) [realtype, input]
+       BI = array of length S containing the implicit solution coefficients
+           [realtype, input]
+       BE = array of length S containing the explicit solution coefficients
+           [realtype, input]
+       B2I = array of length S containing the implicit embedding coefficients
+           [realtype, input]
+       B2E = array of length S containing the explicit embedding coefficients
+           [realtype, input]
+
+     When using a non-identity mass matrix, to set an absolute residual 
+     tolerance (scalar or vector), call:
+
+       CALL FARKSETRESTOLERANCE(IATOL, ATOL, IER)
+
+     The arguments are:
+       IATOL = type for absolute tolerance ATOL [int, input]: 
+                 1 = scalar, 
+                 2 = array
+	ATOL = scalar or array absolute residual tolerance [realtype, input]
+	IER  = return completion flag [int, output]:
+                 0 = SUCCESS,
+                -1 = failure (see printed message for failure details).
+
+ (12.9) To set a solver diagnostics output file, make the folowing call:
+
+       CALL FARKSETDIAGNOSTICS(FNAME, FLEN, IER)
+
+     The desired diagnostics filename should be supplied by the 
+     quoted character string FNAME.  The integer argument FLEN should contain
+     the length (in characters) of FNAME (for portability).  The int return 
+     flag IER is 0 if successful (able to open file), and nonzero otherwise.
+
+ (12.10) To close the solver diagnostics output file, make the folowing call:
+
+       CALL FARKSTOPDIAGNOSTICS(IER)
+
+     The int return flag IER is 0 if successful (able to close file), and
+     nonzero otherwise.
+
+
+ -----------------------------------------------------------------------------
+
+ (13) Specification of linear system solution method.
+
+     In the case of using either an implicit or ImEx method and a Newton 
+     iteration, the solution of each Runge-Kutta stage may involve the 
+     solution of linear systems related to the Jacobian J = dfi(t,y)/dy of the 
+     implicit portion of the ODE system. ARKode presently includes a variety 
+     of choices for the treatment of these systems, and the user of FARKODE 
+     must call a routine with a specific name to make the desired choice.  
+     Following any call to FARKMALLOC or FARKRESIZE, one of these solver 
+     specification routines must be called again to set up the linear solver
+     memory.
+
+ (13.1s) DENSE treatment of the linear system.
+
+     The user must make the call
+
+       CALL FARKDENSE(NEQ, IER)
+
+     The arguments are:
+        NEQ = the problem size [long int; input]
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     If the user program includes the FARKDJAC routine for the evaluation of 
+     the dense approximation to the Jacobian, then after the call to 
+     FARKDENSE, the following call must be made 
+
+       CALL FARKDENSESETJAC(FLAG, IER)
+
+     with the int FLAG=1 to specify that FARKDJAC is provided and should be 
+     used; FLAG=0 specifies a reset to the internal finite difference Jacobian
+     approximation.  The int return flag IER=0 if successful, and nonzero 
+     otherwise.
+ 
+     Optional outputs specific to the DENSE case are:
+        LENRWLS = IOUT(14) from ARKDlsGetWorkSpace (realtype space)
+        LENIWLS = IOUT(15) from ARKDlsGetWorkSpace (integer space)
+        LSTF    = IOUT(16) from ARKDlsGetLastFlag
+        NFELS   = IOUT(17) from ARKDlsGetNumRhsEvals
+        NJED    = IOUT(18) from ARKDlsGetNumJacEvals
+     See the ARKODE manual for descriptions.
+ 
+ (13.2s) DENSE treatment of the mass matrix linear system.
+
+     The user must make the call
+
+       CALL FARKMASSDENSE(NEQ, IER)
+
+     The arguments are:
+        NEQ = the problem size [long int; input]
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     When using MASSDENSE, the user program must provide the FARKDMASS routine 
+     for the evaluation of the dense mass matrix.  To indicate that this routine
+     has been provided, following the call to FARKMASSDENSE, the following call 
+     must be made 
+
+       CALL FARKDENSESETMASS(IER)
+
+     The int return flag IER=0 if successful, nonzero otherwise.
+ 
+     Optional outputs specific to the MASSDENSE case are:
+        LENRWMS = IOUT(23) from ARKDlsGetMassWorkSpace (realtype space)
+        LENIWMS = IOUT(24) from ARKDlsGetMassWorkSpace (integer space)
+        LSTMF   = IOUT(25) from ARKDlsGetLastMassFlag
+        NME     = IOUT(26) from ARKDlsGetNumMassEvals
+     See the ARKODE manual for descriptions.
+ 
+ (13.3s) BAND treatment of the linear system
+
+     The user must make the call
+
+       CALL FARKBAND(NEQ, MU, ML, IER)
+
+     The arguments are:
+        NEQ = problem size [long int, input]
+	MU = upper bandwidth [long int, input]
+	ML = lower bandwidth [long int, input]
+        IER = return flag [int, output]; 0 if successful, nonzero otherwise.
+ 
+     If the user program includes the FARKBJAC routine for the evaluation of 
+     the band approximation to the Jacobian, then following the call to 
+     FARKBAND, the following call must be made 
+
+       CALL FARKBANDSETJAC(FLAG, IER)
+
+     with the int FLAG=1 to specify that FARKBJAC is provided and should be 
+     used; FLAG=0 specifies a reset to the internal finite difference Jacobian 
+     approximation.  The int return flag IER=0 if successful, nonzero otherwise.
+ 
+     Optional outputs specific to the BAND case are:
+        LENRWLS = IOUT(14) from ARKDlsGetWorkSpace (realtype space)
+        LENIWLS = IOUT(15) from ARKDlsGetWorkSpace (integer space)
+        LSTF    = IOUT(16) from ARKDlsGetLastFlag
+        NFELS   = IOUT(17) from ARKDlsGetNumRhsEvals
+        NJED    = IOUT(18) from ARKDlsGetNumJacEvals
+     See the ARKODE manual for descriptions.
+
+ (13.4s) BAND treatment of the mass matrix linear system
+
+     The user must make the call
+
+       CALL FARKMASSBAND(NEQ, MU, ML, IER)
+
+     The arguments are:
+        NEQ = problem size [long int, input]
+	MU = upper bandwidth [long int, input]
+	ML = lower bandwidth [long int, input]
+        IER = return flag [int, output]; 0 if successful, nonzero otherwise.
+ 
+     When using MASSBAND, the user program must provide the FARKBMASS routine 
+     for the evaluation of the band mass matrix.  To indicate that this routine
+     has been provided, following the call to FARKMASSBAND, the following call 
+     must be made 
+
+       CALL FARKBANDSETMASS(IER)
+
+     The int return flag IER=0 if successful, nonzero otherwise.
+ 
+     Optional outputs specific to the MASSBAND case are:
+        LENRWMS = IOUT(23) from ARKDlsGetMassWorkSpace (realtype space)
+        LENIWMS = IOUT(24) from ARKDlsGetMassWorkSpace (integer space)
+        LSTMF   = IOUT(25) from ARKDlsGetLastMassFlag
+        NME     = IOUT(26) from ARKDlsGetNumMassEvals
+     See the ARKODE manual for descriptions.
+
+ (13.5s) LAPACK dense treatment of the linear system
+
+     The user must make the call
+
+       CALL FARKLAPACKDENSE(NEQ, IER)
+
+     The arguments match those for FARKDENSE, except that NEQ is now a 
+     normal int (and not a long int).
+
+     Following the call to FARKLAPACKDENSE, the user may optionally call
+
+       CALL FARKLAPACKDENSESETJAC(FLAG, IER)
+       
+     with the int FLAG=1 if the user provides the function FARKDJAC (and 
+     wishes to use it); FLAG=0 implies a reset to the default finite 
+     difference Jacobian approximation.
+
+     The optional outputs when using FARKLAPACKDENSE match those from 
+     FARKDENSE.
+
+ (13.6s) LAPACK dense treatment of the mass matrix linear system
+
+     The user must make the call
+
+       CALL FARKMASSLAPACKDENSE(NEQ, IER)
+
+     The arguments match those for FARKMASSDENSE, except that NEQ is 
+     now a normal int (and not a long int).
+
+     Following the call to FARKMASSLAPACKDENSE, the user must call 
+
+       CALL FARKLAPACKDENSESETMASS(IER)
+
+     The int return flag IER=0 if successful, nonzero otherwise.
+ 
+     The optional outputs when using FARKMASSLAPACKDENSE match those 
+     from FARKMASSDENSE.
+
+ (13.7s) LAPACK band treatment of the linear system
+
+     The user must make the call
+
+       CALL FARKLAPACKBAND(NEQ, MUPPER, MLOWER, IER)
+
+     The arguments match those for FARKBAND, except that now all arguments 
+     have type 'int'.
+
+     Following the call to FARKLAPACKBAND, the user may optionally call
+
+       CALL FARKLAPACKBANDSETJAC(FLAG, IER)
+
+     with the int FLAG=1 if the user provides the function FARKBJAC (and 
+     wishes to use it); FLAG=0 implies a reset to the default finite 
+     difference Jacobian approximation.
+
+     The optional outputs when using FARKLAPACKBAND match those from FARKBAND.
+
+ (13.8s) LAPACK band treatment of the mass matrix linear system
+
+     The user must make the call
+
+       CALL FARKMASSLAPACKBAND(NEQ, MUPPER, MLOWER, IER)
+
+     The arguments match those for FARKMASSBAND, except that now all 
+     arguments have type 'int'.
+
+     Following the call to FARKMASSLAPACKBAND, the user must call 
+
+       CALL FARKLAPACKBANDSETMASS(IER)
+
+     The int return flag IER=0 if successful, nonzero otherwise.
+ 
+     The optional outputs when using FARKMASSLAPACKBAND match those from 
+     FARKMASSBAND.
+
+ (13.9s) SPARSE treatment of the linear system using the KLU solver.
+
+     The user must make the call
+
+       CALL FARKKLU(NEQ, NNZ, SPARSETYPE, ORDERING, IER)
+
+     The arguments are:
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	SPARSETYPE = choice between CSC and CSR format
+           (0 = CSC, 1 = CSR) [int; input]
+	ORDERING = the matrix ordering desired, possible values come
+	   from the KLU package (0 = AMD, 1 = COLAMD) [int; input]
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     When using the KLU solver the user must provide the FARKSPJAC routine for the 
+     evaluation of the sparse approximation to the Jacobian.  To indicate that this
+     routine has been provided, after the call to FARKKLU, the following call must 
+     be made 
+
+       CALL FARKSPARSESETJAC(IER)
+
+     The int return flag IER=0 if successful, and nonzero otherwise.
+ 
+ 
+     The ARKODE KLU solver will reuse much of the factorization information from one
+     nonlinear iteration to the next.  If at any time the user wants to force a full
+     refactorization or if the number of nonzeros in the Jacobian matrix changes, the
+     user should make the call
+
+       CALL FARKKLUREINIT(NEQ, NNZ, REINIT_TYPE)
+
+     The arguments are:
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	REINIT_TYPE = 1 or 2.  For a value of 1, the matrix will be destroyed and 
+          a new one will be allocated with NNZ nonzeros.  For a value of 2, 
+	  only symbolic and numeric factorizations will be completed. 
+ 
+     Optional outputs specific to the KLU case are:
+        LSTF    = IOUT(16) from ARKSlsGetLastFlag
+        NJES    = IOUT(18) from ARKSlsGetNumJacEvals
+     See the ARKODE manual for descriptions.
+ 
+ (13.10s) SPARSE treatment of the mass matrix linear system using the KLU solver.
+
+     The user must make the call
+
+       CALL FARKMASSKLU(NEQ, NNZ, SPARSETYPE, ORDERING, IER)
+
+     The arguments are:
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of mass matrix nonzeros [int; input]
+	SPARSETYPE = choice between CSC and CSR format
+           (0 = CSC, 1 = CSR) [int; input]
+	ORDERING = the matrix ordering desired, possible values
+	   come from the KLU package (0 = AMD, 1 = COLAMD) [int; input]
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     When using the MASSKLU solver the user must provide the FARKSPMASS routine for 
+     the evaluation of the sparse mass matrix.  To indicate that this routine has 
+     been provided, after the call to FARKMASSKLU, the following call must be made 
+
+       CALL FARKSPARSESETMASS(IER)
+
+     The int return flag IER=0 if successful, and nonzero otherwise.
+ 
+
+     The ARKODE KLU solver will reuse much of the factorization information from one
+     mass matrix solve to the next.  If at any time the user wants to force a full
+     refactorization or if the number of nonzeros in the mass matrix changes, the
+     user should make the call
+
+       CALL FARKMASSKLUREINIT(NEQ, NNZ, REINIT_TYPE)
+
+     The arguments are:
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	REINIT_TYPE = 1 or 2.  For a value of 1, the matrix will be destroyed and 
+          a new one will be allocated with NNZ nonzeros.  For a value of 2, 
+	  only symbolic and numeric factorizations will be completed. 
+ 
+     Optional outputs specific to the MASSKLU case are:
+        LSTMF = IOUT(25) from ARKSlsGetLastMassFlag
+        NME = IOUT(26) from ARKSlsGetNumMassEvals
+     See the ARKODE manual for descriptions.
+ 
+ (13.11s) SPARSE treatment of the linear system using the SuperLUMT solver.
+
+     The user must make the call
+
+       CALL FARKSUPERLUMT(NTHREADS, NEQ, NNZ, ORDERING, IER)
+
+     The arguments are:
+        NTHREADS = desired number of threads to use [int; input]
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	ORDERING = the matrix ordering desired, possible values
+	   come from the SuperLU_MT package [int; input]
+           0 = Natural
+           1 = Minimum degree on A^T A
+           2 = Minimum degree on A^T + A
+           3 = COLAMD
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     At this time, there is no reinitialization capability for the SUNDIALS 
+     interfaces to the SuperLUMT solver.
+
+     When using the SUPERLUMT solver the user must provide the FARKSPJAC routine
+     for the evaluation of the sparse approximation to the Jacobian.  To indicate 
+     that this routine has been provided, after the call to FARKKLU, the following 
+     call must be made 
+
+       CALL FARKSPARSESETJAC(IER)
+
+     The int return flag IER=0 if successful, and nonzero otherwise.
+ 
+     Optional outputs specific to the SUPERLUMT case are:
+        LSTF    = IOUT(16) from ARKSlsGetLastFlag
+        NJES    = IOUT(18) from ARKSlsGetNumJacEvals
+     See the ARKODE manual for descriptions.
+ 
+ (13.12s) SPARSE treatment of the mass matrix linear system using the SuperLUMT solver.
+
+     The user must make the call
+
+       CALL FARKMASSSUPERLUMT(NTHREADS, NEQ, NNZ, ORDERING, IER)
+
+     The arguments are:
+        NTHREADS = desired number of threads to use [int; input]
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	ORDERING = the matrix ordering desired, possible values
+	   come from the SuperLU_MT package [int; input]
+           0 = Natural
+           1 = Minimum degree on A^T A
+           2 = Minimum degree on A^T + A
+           3 = COLAMD
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     At this time, there is no reinitialization capability for the SUNDIALS 
+     interfaces to the SuperLUMT solver.
+
+     When using the MASSSUPERLUMT solver the user must provide the FARKSPJAC 
+     routine for the evaluation of the mass matrix.  To indicate that this 
+     routine has been provided, after the call to FARKKLU, the following call
+     must be made 
+
+       CALL FARKSPARSESETMASS(IER)
+
+     The int return flag IER=0 if successful, and nonzero otherwise.
+ 
+     Optional outputs specific to the MASSSUPERLUMT case are:
+        LSTMF = IOUT(25) from ARKSlsGetLastMassFlag
+        NME = IOUT(26) from ARKSlsGetNumMassEvals
+     See the ARKODE manual for descriptions.
+ 
+ (13.13) SPGMR treatment of the linear systems.
+
+     For the Scaled Preconditioned GMRES solution of the linear systems,
+     the user must make the following call:
+
+       CALL FARKSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = linear convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     Optional outputs specific to the SPGMR case are:
+        LENRWLS = IOUT(14) from ARKSpilsGetWorkSpace
+        LENIWLS = IOUT(15) from ARKSpilsGetWorkSpace
+        LSTF    = IOUT(16) from ARKSpilsGetLastFlag
+        NFELS   = IOUT(17) from ARKSpilsGetNumRhsEvals
+        NJTV    = IOUT(18) from ARKSpilsGetNumJtimesEvals
+        NPE     = IOUT(19) from ARKSpilsGetNumPrecEvals
+        NPS     = IOUT(20) from ARKSpilsGetNumPrecSolves
+        NLI     = IOUT(21) from ARKSpilsGetNumLinIters
+        NCFL    = IOUT(22) from ARKSpilsGetNumConvFails
+     See the ARKODE manual for descriptions.
+ 
+     If a sequence of problems of the same size is being solved using the
+     SPGMR linear solver, then following the call to FARKREINIT, a call to 
+     the FARKSPGMRREINIT routine is needed if any of IPRETYPE, IGSTYPE, DELT 
+     is being changed.  In that case, call FARKSPGMRREINIT as follows:
+
+       CALL FARKSPGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPGMR.  If MAXL is being
+     changed, then the user should call FARKSPGMR instead.  
+
+     Note: if the problem has been resized using FARKRESIZE, then FARKSPGMR 
+     must be called again. 
+ 
+ (13.14) SPGMR treatment of the mass matrix linear systems.
+
+     For the Scaled Preconditioned GMRES solution of the mass matrix 
+     linear systems, the user must make the following call:
+
+       CALL FARKMASSSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = linear convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     Optional outputs specific to the MASSSPGMR case are:
+        LENRWMS = IOUT(23) from ARKSpilsGetMassWorkSpace
+        LENIWMS = IOUT(24) from ARKSpilsGetMassWorkSpace
+        LSTMF   = IOUT(25) from ARKSpilsGetLastMassFlag
+        NMPE    = IOUT(26) from ARKSpilsGetNumMassPrecEvals
+        NMPS    = IOUT(27) from ARKSpilsGetNumMassPrecSolves
+        NMLI    = IOUT(28) from ARKSpilsGetNumMassIters
+        NMCFL   = IOUT(29) from ARKSpilsGetNumMassConvFails
+     See the ARKODE manual for descriptions.
+ 
+     If a sequence of problems of the same size is being solved using the
+     MASSSPGMR linear solver, then following the call to FARKREINIT, a call
+     to the FARKMASSSPGMRREINIT routine is needed if any of IPRETYPE, 
+     IGSTYPE, DELT is being changed.  In that case, call FARKMASSSPGMRREINIT 
+     as follows:
+
+       CALL FARKMASSSPGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKMASSSPGMR.  If MAXL is 
+     being changed, then the user should call FARKMASSSPGMR instead.  
+
+     Note: if the problem has been resized using FARKRESIZE, then 
+     FARKMASSSPGMR must be called again. 
+ 
+ (13.15) SPBCG treatment of the linear systems.
+
+     For the Scaled Preconditioned Bi-CGSTAB solution of the linear systems,
+     the user must make the following call:
+
+       CALL FARKSPBCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 0 = default.
+       DELT = linear convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     Optional outputs specific to the SPBCG case are identical to 
+     those from SPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     SPBCG linear solver, then following the call to FARKREINIT, a call to the
+     FARKSPBCGREINIT routine is needed if any of its arguments is being 
+     changed.  The call is:
+
+       CALL FARKSPBCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKSPBCG.
+
+     Note: if the problem has been resized using FARKRESIZE, then FARKSPBCG 
+     must be called again. 
+
+ (13.16) SPBCG treatment of the mass matrix linear systems.
+
+     For the Scaled Preconditioned Bi-CGSTAB solution of the mass matrix 
+     linear systems, the user must make the following call:
+
+       CALL FARKMASSSPBCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 0 = default.
+       DELT = linear convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     Optional outputs specific to the MASSSPBCG case are identical to 
+     those from MASSSPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     MASSSPBCG linear solver, then following the call to FARKREINIT, a call 
+     to the FARKMASSSPBCGREINIT routine is needed if any of its arguments 
+     is being changed.  The call is:
+
+       CALL FARKMASSSPBCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKMASSSPBCG.
+
+     Note: if the problem has been resized using FARKRESIZE, then 
+     FARKMASSSPBCG must be called again. 
+
+ (13.17) SPTFQMR treatment of the linear systems.
+
+     For the Scaled Preconditioned TFQMR solution of the linear systems, the
+     user must make the following call:
+
+       CALL FARKSPTFQMR(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 0 = default.
+       DELT = linear convergence tolerance factor [realtype, input]
+	      0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     Optional outputs specific to the SPTFQMR case are identical to 
+     those from SPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     SPTFQMR linear solver, then following the call to FARKREINIT, a call to 
+     the FARKSPTFQMRREINIT routine is needed if any of its arguments is
+     being changed.  The call is:
+
+       CALL FARKSPTFQMRREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKSPTFQMR.
+
+     Note: if the problem has been resized using FARKRESIZE, then FARKSPTFQMR 
+     must be called again. 
+
+ (13.18) SPTFQMR treatment of the mass matrix linear systems.
+
+     For the Scaled Preconditioned TFQMR solution of the mass matrix 
+     linear systems, the user must make the following call:
+
+       CALL FARKMASSSPTFQMR(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 0 = default.
+       DELT = linear convergence tolerance factor [realtype, input]
+	      0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     Optional outputs specific to the MASSSPTFQMR case are identical to 
+     those from MASSSPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     MASSSPTFQMR linear solver, then following the call to FARKREINIT, a 
+     call to the FARKMASSSPTFQMRREINIT routine is needed if any of its 
+     arguments is being changed.  The call is:
+
+       CALL FARKMASSSPTFQMRREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKMASSSPTFQMR.
+
+     Note: if the problem has been resized using FARKRESIZE, then 
+     FARKMASSSPTFQMR must be called again. 
+
+ (13.19) SPFGMR treatment of the linear systems.
+
+     For the Scaled Preconditioned Flexible GMRES solution of the linear 
+     systems, the user must make the following call:
+
+       CALL FARKSPFGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = linear convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     Optional outputs specific to the SPFGMR case are identical to 
+     those from SPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     SPFGMR linear solver, then following the call to FARKREINIT, a call to 
+     the FARKSPFGMRREINIT routine is needed if any of IPRETYPE, IGSTYPE, DELT 
+     is being changed.  In that case, call FARKSPFGMRREINIT as follows:
+
+       CALL FARKSPFGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKSPFGMR.  If MAXL is being
+     changed, then the user should call FARKSPFGMR instead.  
+
+     Note: if the problem has been resized using FARKRESIZE, then FARKSPFGMR 
+     must be called again. 
+ 
+ (13.20) SPFGMR treatment of the mass matrix linear systems.
+
+     For the Scaled Preconditioned Flexible GMRES solution of the mass 
+     matrix linear systems, the user must make the following call:
+
+       CALL FARKMASSSPFGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+        IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+	IGSTYPE = Gram-schmidt process type [int, input]: 
+              1 = modified G-S
+              2 = classical G-S.
+	MAXL = maximum Krylov subspace dimension [int; input]; 
+	      0 = default
+	DELT = linear convergence tolerance factor [realtype, input]; 
+	      0.0 = default.
+	IER = error return flag [int, output]: 
+	       0 = success; 
+	      <0 = an error occured
+ 
+     Optional outputs specific to the MASSSPFGMR case are identical to 
+     those from MASSSPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     MASSSPFGMR linear solver, then following the call to FARKREINIT, a 
+     call to the FARKMASSSPFGMRREINIT routine is needed if any of IPRETYPE, 
+     IGSTYPE, DELT is being changed.  In that case, call 
+     FARKMASSSPFGMRREINIT as follows:
+
+       CALL FARKMASSSPFGMRREINIT(IPRETYPE, IGSTYPE, DELT, IER)
+
+     The arguments have the same meanings as for FARKMASSSPFGMR.  If MAXL 
+     is being changed, then the user should call FARKMASSSPFGMR instead.  
+
+     Note: if the problem has been resized using FARKRESIZE, then 
+     FARKMASSSPFGMR must be called again. 
+ 
+ (13.21) PCG treatment of the linear systems.
+
+     For the Preconditioned Conjugate Gradient solution of the linear systems,
+     the user must make the following call:
+
+       CALL FARKPCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 0 = default.
+       DELT = linear convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     Optional outputs specific to the PCG case are identical to 
+     those from SPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     PCG linear solver, then following the call to FARKREINIT, a call to the
+     FARKPCGREINIT routine is needed if any of its arguments is being 
+     changed.  The call is:
+
+       CALL FARKPCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKPCG.
+
+     Note: if the problem has been resized using FARKRESIZE, then FARKPCG
+     must be called again. 
+
+ (13.22) PCG treatment of the mass matrix linear systems.
+
+     For the Preconditioned Conjugate Gradient solution of the mass matrix 
+     linear systems, the user must make the following call:
+
+       CALL FARKMASSPCG(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments are:
+       IPRETYPE = preconditioner type [int, input]: 
+              0 = none 
+              1 = left only
+              2 = right only
+              3 = both sides
+       MAXL = maximum Krylov subspace dimension [int, input]; 0 = default.
+       DELT = linear convergence tolerance factor [realtype, input]; 
+              0.0 = default.
+       IER = error return flag [int, output]: 
+              0 = success; 
+	     <0 = an error occured
+ 
+     Optional outputs specific to the MASSPCG case are identical to 
+     those from MASSSPGMR.
+ 
+     If a sequence of problems of the same size is being solved using the
+     MASSPCG linear solver, then following the call to FARKREINIT, a call 
+     to the FARKMASSPCGREINIT routine is needed if any of its arguments 
+     is being changed.  The call is:
+
+       CALL FARKMASSPCGREINIT(IPRETYPE, MAXL, DELT, IER)              
+
+     The arguments have the same meanings as for FARKMASSPCG.
+
+     Note: if the problem has been resized using FARKRESIZE, then 
+     FARKMASSPCG must be called again. 
+
+ (13.23) Usage of user-supplied routines for the system Krylov solvers
+
+     If the user program includes the FARKJTIMES routine for the evaluation of
+     the Jacobian vector product, then after specifying the linear solver 
+     choice (e.g. FARKSPGMR), the following call must be made
+
+       CALL FARKSPILSSETJAC(FLAG, IER)
+
+     with the int FLAG=1 to specify that FARKJTIMES is provided and should
+     be used; FLAG=0 specifies a reset to the internal finite difference 
+     approximation to this product).  The int return flag IER=0 if 
+     successful, and nonzero otherwise.
+ 
+     Usage of the user-supplied routines FARKPSOL and FARKPSET for solution of
+     the preconditioner linear system similarly requires the following call after 
+     specifying the linear solver module:
+
+       CALL FARKSPILSSETPREC(FLAG, IER)
+
+     with the int FLAG=1.  If FLAG=0 then preconditioning with these routines 
+     will be disabled. The return flag IER=0 if successful, nonzero otherwise.
+
+     NOTE: following any call to FARKRESIZE, either of the above routines must 
+     again be called following re-specification of the linear solver module.
+
+     The user-supplied routine FARKPSET must have the form:
+
+       SUBROUTINE FARKPSET(T,Y,FY,JOK,JCUR,GAMMA,H,IPAR,RPAR,V1,V2,V3,IER)
+
+     This routine must set up the preconditioner P to be used in the 
+     subsequent call to FARKPSOL.  The preconditioner (or the product of the 
+     left and right preconditioners if using both) should be an approximation 
+     to the matrix  M(T) - GAMMA*J  (M(T) = mass matrix, J = Jacobian),
+
+     The arguments are:
+       T = current time [realtype, input]
+       Y = current state variable array [realtype, input]
+       FY = current state variable derivative array [realtype, input]
+       JOK = flag indicating whether Jacobian-related data needs to be 
+           recomputed [int, input]:
+                  0 = recompute, 
+		  1 = reuse with the current value of GAMMA
+       JCUR = return flag to denote if Jacobian data was recomputed
+           [realtype, output], 1=yes, 0=no
+       GAMMA = Jacobian scaling factor [realtype, input]
+       H = current time step [realtype, input]
+       IPAR = array of user integer data [long int, input/output]
+       RPAR = array with user real data [realtype, input/output]
+       V* -- array containing temporary workspace of same size as Y 
+               [realtype, input]
+       IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+		 >0 = recoverable failure
+                 <0 = non-recoverable failure
+
+     The user-supplied routine FARKPSOL must have the form:
+
+       SUBROUTINE FARKPSOL(T,Y,FY,R,Z,GAMMA,DELTA,LR,IPAR,RPAR,VT,IER)
+
+       DIMENSION Y(*), FY(*), VT(*), R(*), Z(*), IPAR(*), RPAR(*)
+
+     Typically this routine will use only T, Y, GAMMA, R, LR, and Z.  It
+     must solve the preconditioner linear system Pz = r.  The preconditioner
+     (or the product of the left and right preconditioners if both are 
+     nontrivial) should be an approximation to the matrix  M(T) - GAMMA*J  
+     (M(T) = mass matrix, J = Jacobian).
+
+     The arguments are:
+       T = current time [realtype, input]
+       Y = current state variable array [realtype, input]
+       FY = current state variable derivative array [realtype, input]
+       R = right-hand side array [realtype, input]
+       Z = solution array [realtype, output]
+       GAMMA = Jacobian scaling factor [realtype, input]
+       DELTA = desired residual tolerance [realtype, input]
+       LR = flag denoting to solve the right or left preconditioner system
+                  1 = left preconditioner
+		  2 = right preconditioner
+       IPAR = array of user integer data [long int, input/output]
+       RPAR = array with user real data [realtype, input/output]
+       VT -- array containing temporary workspace of same size as Y 
+               [realtype, input]
+       IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+		 >0 = recoverable failure
+                 <0 = non-recoverable failure
+
+ (13.24) Usage of user-supplied routines for the mass matrix Krylov solvers
+
+     When using any of the MASSSPGMR, MASSSPBCG, MASSSPTFQMR, MASSSPFGMR or 
+     MASSPCG mass matrix linear solvers, the user must supply the 
+     FARKMTIMES routine for the evaluation of the mass matrix vector product.  
+     After specifying the linear solver choice (e.g. FARKMASSSPGMR), the 
+     following call must be made
+
+       CALL FARKSPILSSETMASS(IER)
+
+     The int return flag IER=0 if successful, and nonzero otherwise.
+
+ 
+     Usage of the user-supplied routines FARKMASSPSOL and FARKMASSPSET for 
+     solution of the mass matrix preconditioner linear system similarly 
+     requires the following call after specifying the mass matrix linear 
+     solver module:
+
+       CALL FARKSPILSSETMASSPREC(FLAG, IER)
+
+     with the int FLAG=1. If FLAG=0 then preconditioning with these routines 
+     will be disabled. The return flag IER=0 if successful, nonzero otherwise.
+
+     NOTE: following any call to FARKRESIZE, the above routine must again 
+     be called following re-specification of the linear solver module.
+
+     The user-supplied routine FARKMASSPSET must have the form:
+
+       SUBROUTINE FARKMASSPSET(T,IPAR,RPAR,V1,V2,V3,IER)
+
+     This routine must set up the preconditioner P to be used in the 
+     subsequent call to FARKMASSPSOL.  The preconditioner (or the product 
+     of the left and right preconditioners if using both) should be an 
+     approximation to the system mass matrix M.
+
+     The arguments are:
+       T = current time [realtype, input]
+       IPAR = array of user integer data [long int, input/output]
+       RPAR = array with user real data [realtype, input/output]
+       V* -- array containing temporary workspace of same size as Y 
+               [realtype, input]
+       IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+		 >0 = recoverable failure
+                 <0 = non-recoverable failure
+
+     The user-supplied routine FARKMASSPSOL must have the form:
+
+       SUBROUTINE FARKMASSPSOL(T,R,Z,DELTA,LR,IPAR,RPAR,VT,IER)
+
+       DIMENSION VT(*), R(*), Z(*), IPAR(*), RPAR(*)
+
+     Typically this routine will use only T, R, LR, and Z.  It
+     must solve the preconditioner linear system Pz = r.  The 
+     preconditioner (or the product of the left and right 
+     preconditioners if both are nontrivial) should be an 
+     approximation to the system mass matrix M.
+
+     The arguments are:
+       T = current time [realtype, input]
+       R = right-hand side array [realtype, input]
+       Z = solution array [realtype, output]
+       DELTA = desired residual tolerance [realtype, input]
+       LR = flag denoting to solve the right or left preconditioner system
+                  1 = left preconditioner
+		  2 = right preconditioner
+       IPAR = array of user integer data [long int, input/output]
+       RPAR = array with user real data [realtype, input/output]
+       VT -- array containing temporary workspace of same size as Y 
+               [realtype, input]
+       IER  = return completion flag [int, output]:
+                  0 = SUCCESS,
+		 >0 = recoverable failure
+                 <0 = non-recoverable failure
+
+ -----------------------------------------------------------------------------
+
+ (14) The integrator: FARKODE
+
+     Carrying out the integration is accomplished by making calls as follows:
+
+       CALL FARKODE(TOUT, T, Y, ITASK, IER)
+
+     The arguments are:
+       TOUT = next value of t at which a solution is desired [realtype, input]
+       T = value of t reached by the solver [realtype, output]
+       Y = array containing state variables on output (realtype, output]
+       ITASK = task indicator [int, input]:
+                  1 = normal mode (overshoot TOUT and interpolate)
+		  2 = one-step mode (return after each internal step taken)
+		  3 = normal tstop mode (like 1, but integration never 
+		      proceeds past TSTOP, which must be specified through a 
+		      call to FARKSETRIN using the key 'STOP_TIME')
+		  4 = one step tstop (like 2, but integration never goes 
+		      past TSTOP)
+       IER = completion flag [int, output]: 
+                  0 = success, 
+		  1 = tstop return, 
+		  2 = root return, 
+                  values -1 ... -10 are failure modes (see ARKODE manual).
+     The current values of the optional outputs are immediately available in
+     the IOUT and ROUT arrays.
+ 
+ -----------------------------------------------------------------------------
+
+ (15) Computing solution derivatives: FARKDKY
+
+     To obtain a derivative of the solution, of order up to the method order,
+     make the following call:
+
+       CALL FARKDKY(T, K, DKY, IER)
+
+     The arguments are:
+       T = time at which solution derivative is desired, within the interval
+           [TCUR-HU,TCUR], [realtype, input].
+       K = derivative order (0 .le. K .le. QU) [int, input]
+       DKY = array containing computed K-th derivative of y [realtype, output]
+       IER = return flag [int, output]: 0=success, <0 = illegal argument.
+ 
+ -----------------------------------------------------------------------------
+
+ (16) Get the current weight vector: FARKGETERRWEIGHTS
+
+     To obtain the current weight vector, make the following call:
+
+       CALL FARKGETERRWEIGHTS(EWT, IER)
+
+     The arguments are:
+       EWT = array containing the error weight vector [realtype, output]
+       IER = return flag [int, output]: 0=success, nonzero if an error.
+ 
+ -----------------------------------------------------------------------------
+
+ (17) Get an estimate of the local error: FARKGETESTLOCALERR
+
+     To obtain the current error estimate vector, make the following call:
+
+       CALL FARKGETESTLOCALERR(ELE, IER)
+
+     The arguments are:
+       ELE = array with the estimated local error vector [realtype, output]
+       IER = return flag [int, output]: 0=success, nonzero if an error.
+ 
+ -----------------------------------------------------------------------------
+
+ (18) Memory freeing: FARKFREE 
+
+     To free the internal memory created by the calls to FARKMALLOC and
+     FNVINITS, FNVINITOMP, FNVINITPTS or FNVINITP, make the call
+
+       CALL FARKFREE()
+ 
+===============================================================*/
+
+#ifndef _FARKODE_H
+#define _FARKODE_H
+
+/* header files  */
+#include <arkode/arkode.h>
+#include <sundials/sundials_direct.h>  /* definition of type DlsMat   */
+#include <sundials/sundials_sparse.h>  /* definition of type SlsMat   */
+#include <sundials/sundials_nvector.h> /* definition of type N_Vector */
+#include <sundials/sundials_types.h>   /* definition of type realtype */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* Definitions of interface function names */
+#if defined(SUNDIALS_F77_FUNC)
+
+#define FARK_MALLOC              SUNDIALS_F77_FUNC(farkmalloc,              FARKMALLOC)
+#define FARK_REINIT              SUNDIALS_F77_FUNC(farkreinit,              FARKREINIT)
+#define FARK_RESIZE              SUNDIALS_F77_FUNC(farkresize,              FARKRESIZE)
+#define FARK_SETDEFAULTS         SUNDIALS_F77_FUNC(farksetdefaults,         FARKSETDEFAULTS)
+#define FARK_SETIIN              SUNDIALS_F77_FUNC(farksetiin,              FARKSETIIN)
+#define FARK_SETRIN              SUNDIALS_F77_FUNC(farksetrin,              FARKSETRIN)
+#define FARK_SETERKTABLE         SUNDIALS_F77_FUNC(farkseterktable,         FARKSETERKTABLE)
+#define FARK_SETIRKTABLE         SUNDIALS_F77_FUNC(farksetirktable,         FARKSETIRKTABLE)
+#define FARK_SETARKTABLES        SUNDIALS_F77_FUNC(farksetarktables,        FARKSETARKTABLES)
+#define FARK_SETRESTOLERANCE     SUNDIALS_F77_FUNC(farksetrestolerance,     FARKSETRESTOLERANCE)
+#define FARK_SETDIAGNOSTICS      SUNDIALS_F77_FUNC(farksetdiagnostics,      FARKSETDIAGNOSTICS)
+#define FARK_STOPDIAGNOSTICS     SUNDIALS_F77_FUNC(farkstopdiagnostics,     FARKSTOPDIAGNOSTICS)
+#define FARK_DENSE               SUNDIALS_F77_FUNC(farkdense,               FARKDENSE)
+#define FARK_DENSESETJAC         SUNDIALS_F77_FUNC(farkdensesetjac,         FARKDENSESETJAC)
+#define FARK_MASSDENSE           SUNDIALS_F77_FUNC(farkmassdense,           FARKMASSDENSE)
+#define FARK_DENSESETMASS        SUNDIALS_F77_FUNC(farkdensesetmass,        FARKDENSESETMASS)
+#define FARK_BAND                SUNDIALS_F77_FUNC(farkband,                FARKBAND)
+#define FARK_BANDSETJAC          SUNDIALS_F77_FUNC(farkbandsetjac,          FARKBANDSETJAC)
+#define FARK_MASSBAND            SUNDIALS_F77_FUNC(farkmassband,            FARKMASSBAND)
+#define FARK_BANDSETMASS         SUNDIALS_F77_FUNC(farkbandsetmass,         FARKBANDSETMASS)
+#define FARK_LAPACKDENSE         SUNDIALS_F77_FUNC(farklapackdense,         FARKLAPACKDENSE)
+#define FARK_LAPACKDENSESETJAC   SUNDIALS_F77_FUNC(farklapackdensesetjac,   FARKLAPACKDENSESETJAC)
+#define FARK_MASSLAPACKDENSE     SUNDIALS_F77_FUNC(farkmasslapackdense,     FARKMASSLAPACKDENSE)
+#define FARK_LAPACKDENSESETMASS  SUNDIALS_F77_FUNC(farklapackdensesetmass,  FARKLAPACKDENSESETMASS)
+#define FARK_LAPACKBAND          SUNDIALS_F77_FUNC(farklapackband,          FARKLAPACKBAND)
+#define FARK_LAPACKBANDSETJAC    SUNDIALS_F77_FUNC(farklapackbandsetjac,    FARKLAPACKBANDSETJAC)
+#define FARK_MASSLAPACKBAND      SUNDIALS_F77_FUNC(farkmasslapackband,      FARKMASSLAPACKBAND)
+#define FARK_LAPACKBANDSETMASS   SUNDIALS_F77_FUNC(farklapackbandsetmass,   FARKLAPACKBANDSETMASS)
+#define FARK_KLU                 SUNDIALS_F77_FUNC(farkklu,                 FARKKLU)
+#define FARK_KLUREINIT           SUNDIALS_F77_FUNC(farkklureinit,           FARKKLUREINIT)
+#define FARK_SUPERLUMT           SUNDIALS_F77_FUNC(farksuperlumt,           FARKSUPERLUMT)
+#define FARK_SPARSESETJAC        SUNDIALS_F77_FUNC(farksparsesetjac,        FARKSPARSESETJAC)
+#define FARK_MASSKLU             SUNDIALS_F77_FUNC(farkmassklu,             FARKMASSKLU)
+#define FARK_MASSKLUREINIT       SUNDIALS_F77_FUNC(farkmassklureinit,       FARKMASSKLUREINIT)
+#define FARK_MASSSUPERLUMT       SUNDIALS_F77_FUNC(farkmasssuperlumt,       FARKMASSSUPERLUMT)
+#define FARK_SPARSESETMASS       SUNDIALS_F77_FUNC(farksparsesetmass,       FARKSPARSESETMASS)
+#define FARK_SPTFQMR             SUNDIALS_F77_FUNC(farksptfqmr,             FARKSPTFQMR)
+#define FARK_SPTFQMRREINIT       SUNDIALS_F77_FUNC(farksptfqmrreinit,       FARKSPTFQMRREINIT)
+#define FARK_MASSSPTFQMR         SUNDIALS_F77_FUNC(farkmasssptfqmr,         FARKMASSSPTFQMR)
+#define FARK_MASSSPTFQMRREINIT   SUNDIALS_F77_FUNC(farkmasssptfqmrreinit,   FARKMASSSPTFQMRREINIT)
+#define FARK_SPBCG               SUNDIALS_F77_FUNC(farkspbcg,               FARKSPBCG)
+#define FARK_SPBCGREINIT         SUNDIALS_F77_FUNC(farkspbcgreinit,         FARKSPBCGREINIT)
+#define FARK_MASSSPBCG           SUNDIALS_F77_FUNC(farkmassspbcg,           FARKMASSSPBCG)
+#define FARK_MASSSPBCGREINIT     SUNDIALS_F77_FUNC(farkmassspbcgreinit,     FARKMASSSPBCGREINIT)
+#define FARK_SPGMR               SUNDIALS_F77_FUNC(farkspgmr,               FARKSPGMR)
+#define FARK_SPGMRREINIT         SUNDIALS_F77_FUNC(farkspgmrreinit,         FARKSPGMRREINIT)
+#define FARK_MASSSPGMR           SUNDIALS_F77_FUNC(farkmassspgmr,           FARKMASSSPGMR)
+#define FARK_MASSSPGMRREINIT     SUNDIALS_F77_FUNC(farkmassspgmrreinit,     FARKMASSSPGMRREINIT)
+#define FARK_SPFGMR              SUNDIALS_F77_FUNC(farkspfgmr,              FARKSPFGMR)
+#define FARK_SPFGMRREINIT        SUNDIALS_F77_FUNC(farkspfgmrreinit,        FARKSPFGMRREINIT)
+#define FARK_MASSSPFGMR          SUNDIALS_F77_FUNC(farkmassspfgmr,          FARKMASSSPFGMR)
+#define FARK_MASSSPFGMRREINIT    SUNDIALS_F77_FUNC(farkmassspfgmrreinit,    FARKMASSSPFGMRREINIT)
+#define FARK_PCG                 SUNDIALS_F77_FUNC(farkpcg,                 FARKPCG)
+#define FARK_PCGREINIT           SUNDIALS_F77_FUNC(farkpcgreinit,           FARKPCGREINIT)
+#define FARK_MASSPCG             SUNDIALS_F77_FUNC(farkmasspcg,             FARKMASSPCG)
+#define FARK_MASSPCGREINIT       SUNDIALS_F77_FUNC(farkmasspcgreinit,       FARKMASSPCGREINIT)
+#define FARK_SPILSSETJAC         SUNDIALS_F77_FUNC(farkspilssetjac,         FARKSPILSSETJAC)
+#define FARK_SPILSSETPREC        SUNDIALS_F77_FUNC(farkspilssetprec,        FARKSPILSSETPREC)
+#define FARK_SPILSSETMASS        SUNDIALS_F77_FUNC(farkspilssetmass,        FARKSPILSSETMASS)
+#define FARK_SPILSSETMASSPREC    SUNDIALS_F77_FUNC(farkspilssetmassprec,    FARKSPILSSETMASSPREC)
+#define FARK_ARKODE              SUNDIALS_F77_FUNC(farkode,                 FARKODE)
+#define FARK_DKY                 SUNDIALS_F77_FUNC(farkdky,                 FARKDKY)
+#define FARK_FREE                SUNDIALS_F77_FUNC(farkfree,                FARKFREE)
+#define FARK_IMP_FUN             SUNDIALS_F77_FUNC(farkifun,                FARKIFUN)
+#define FARK_EXP_FUN             SUNDIALS_F77_FUNC(farkefun,                FARKEFUN)
+#define FARK_DJAC                SUNDIALS_F77_FUNC(farkdjac,                FARKDJAC)
+#define FARK_DMASS               SUNDIALS_F77_FUNC(farkdmass,               FARKDMASS)
+#define FARK_BJAC                SUNDIALS_F77_FUNC(farkbjac,                FARKBJAC)
+#define FARK_BMASS               SUNDIALS_F77_FUNC(farkbmass,               FARKBMASS)
+#define FARK_SPJAC               SUNDIALS_F77_FUNC(farkspjac,               FARKSPJAC)
+#define FARK_SPMASS              SUNDIALS_F77_FUNC(farkspmass,              FARKSPMASS)
+#define FARK_PSOL                SUNDIALS_F77_FUNC(farkpsol,                FARKPSOL)
+#define FARK_PSET                SUNDIALS_F77_FUNC(farkpset,                FARKPSET)
+#define FARK_MASSPSOL            SUNDIALS_F77_FUNC(farkmasspsol,            FARKMASSPSOL)
+#define FARK_MASSPSET            SUNDIALS_F77_FUNC(farkmasspset,            FARKMASSPSET)
+#define FARK_JTIMES              SUNDIALS_F77_FUNC(farkjtimes,              FARKJTIMES)
+#define FARK_MTIMES              SUNDIALS_F77_FUNC(farkmtimes,              FARKMTIMES)
+#define FARK_EWT                 SUNDIALS_F77_FUNC(farkewt,                 FARKEWT)
+#define FARK_EWTSET              SUNDIALS_F77_FUNC(farkewtset,              FARKEWTSET)
+#define FARK_GETERRWEIGHTS       SUNDIALS_F77_FUNC(farkgeterrweights,       FARKGETERRWEIGHTS)
+#define FARK_GETESTLOCALERR      SUNDIALS_F77_FUNC(farkgetestlocalerr,      FARKGETESTLOCALERR)
+#define FARK_WRITEPARAMETERS     SUNDIALS_F77_FUNC(farkwriteparameters,     FARKWRITEPARAMETERS)
+#define FARK_ADAPT               SUNDIALS_F77_FUNC(farkadapt,               FARKADAPT)
+#define FARK_ADAPTSET            SUNDIALS_F77_FUNC(farkadaptset,            FARKADAPTSET)
+#define FARK_EXPSTAB             SUNDIALS_F77_FUNC(farkexpstab,             FARKEXPSTAB)
+#define FARK_EXPSTABSET          SUNDIALS_F77_FUNC(farkexpstabset,          FARKEXPSTABSET)
+#define FARK_SETADAPTMETHOD      SUNDIALS_F77_FUNC(farksetadaptivitymethod, FARKSETADAPTIVITYMETHOD)
+
+#else
+
+#define FARK_MALLOC              farkmalloc_
+#define FARK_REINIT              farkreinit_
+#define FARK_RESIZE              farkresize_
+#define FARK_SETDEFAULTS         farksetdefaults_
+#define FARK_SETIIN              farksetiin_
+#define FARK_SETRIN              farksetrin_
+#define FARK_SETERKTABLE         farkseterktable_
+#define FARK_SETIRKTABLE         farksetirktable_
+#define FARK_SETARKTABLES        farksetarktables_
+#define FARK_SETRESTOLERANCE     farksetrestolerance_
+#define FARK_SETDIAGNOSTICS      farksetdiagnostics_
+#define FARK_STOPDIAGNOSTICS     farkstopdiagnostics_
+#define FARK_DENSE               farkdense_
+#define FARK_DENSESETJAC         farkdensesetjac_
+#define FARK_MASSDENSE           farkmassdense_
+#define FARK_DENSESETMASS        farkdensesetmass_
+#define FARK_BAND                farkband_
+#define FARK_BANDSETJAC          farkbandsetjac_
+#define FARK_MASSBAND            farkmassband_
+#define FARK_BANDSETMASS         farkbandsetmass_
+#define FARK_LAPACKDENSE         farklapackdense_
+#define FARK_LAPACKDENSESETJAC   farklapackdensesetjac_
+#define FARK_MASSLAPACKDENSE     farkmasslapackdense_
+#define FARK_LAPACKDENSESETMASS  farklapackdensesetmass_
+#define FARK_LAPACKBAND          farklapackband_
+#define FARK_LAPACKBANDSETJAC    farklapackbandsetjac_
+#define FARK_MASSLAPACKBAND      farkmasslapackband_
+#define FARK_LAPACKBANDSETMASS   farklapackbandsetmass_
+#define FARK_KLU                 farkklu_
+#define FARK_KLUREINIT           farkklureinit_
+#define FARK_SUPERLUMT           farksuperlumt_
+#define FARK_SPARSESETJAC        farksparsesetjac_
+#define FARK_MASSKLU             farkmassklu_
+#define FARK_MASSKLUREINIT       farkmassklureinit_
+#define FARK_MASSSUPERLUMT       farkmasssuperlumt_
+#define FARK_SPARSESETMASS       farksparsesetmass_
+#define FARK_SPTFQMR             farksptfqmr_
+#define FARK_SPTFQMRREINIT       farksptfqmrreinit_
+#define FARK_MASSSPTFQMR         farkmasssptfqmr_
+#define FARK_MASSSPTFQMRREINIT   farkmasssptfqmrreinit_
+#define FARK_SPBCG               farkspbcg_
+#define FARK_SPBCGREINIT         farkspbcgreinit_
+#define FARK_MASSSPBCG           farkmassspbcg_
+#define FARK_MASSSPBCGREINIT     farkmassspbcgreinit_
+#define FARK_SPGMR               farkspgmr_
+#define FARK_SPGMRREINIT         farkspgmrreinit_
+#define FARK_MASSSPGMR           farkmassspgmr_
+#define FARK_MASSSPGMRREINIT     farkmassspgmrreinit_
+#define FARK_SPFGMR              farkspfgmr_
+#define FARK_SPFGMRREINIT        farkspfgmrreinit_
+#define FARK_MASSSPFGMR          farkmassspfgmr_
+#define FARK_MASSSPFGMRREINIT    farkmassspfgmrreinit_
+#define FARK_PCG                 farkpcg_
+#define FARK_PCGREINIT           farkpcgreinit_
+#define FARK_MASSPCG             farkmasspcg_
+#define FARK_MASSPCGREINIT       farkmasspcgreinit_
+#define FARK_SPILSSETJAC         farkspilssetjac_
+#define FARK_SPILSSETPREC        farkspilssetprec_
+#define FARK_SPILSSETMASS        farkspilssetmass_
+#define FARK_SPILSSETMASSPREC    farkmassspilssetprec_
+#define FARK_ARKODE              farkode_
+#define FARK_DKY                 farkdky_
+#define FARK_FREE                farkfree_
+#define FARK_IMP_FUN             farkifun_
+#define FARK_EXP_FUN             farkefun_
+#define FARK_DJAC                farkdjac_
+#define FARK_DMASS               farkdmass_
+#define FARK_BJAC                farkbjac_
+#define FARK_BMASS               farkbmass_
+#define FARK_SPJAC               farkspjac_
+#define FARK_SPMASS              farkspmass_
+#define FARK_PSOL                farkpsol_
+#define FARK_PSET                farkpset_
+#define FARK_MASSPSOL            farkmasspsol_
+#define FARK_MASSPSET            farkmasspset_
+#define FARK_JTIMES              farkjtimes_
+#define FARK_MTIMES              farkmtimes_
+#define FARK_EWT                 farkewt_
+#define FARK_EWTSET              farkewtset_
+#define FARK_GETERRWEIGHTS       farkgeterrweights_
+#define FARK_GETESTLOCALERR      farkgetestlocalerr_
+#define FARK_WRITEPARAMETERS     farkwriteparameters_
+#define FARK_ADAPT               farkadapt_
+#define FARK_ADAPTSET            farkadaptset_
+#define FARK_EXPSTAB             farkexpstab_
+#define FARK_EXPSTABSET          farkexpstabset_
+#define FARK_SETADAPTMETHOD      farksetadaptivitymethod_
+
+#endif
+
+  /* Type for user data */
+  typedef struct {
+    realtype *rpar;
+    long int *ipar;
+  } *FARKUserData;
+  
+  /* Prototypes of exported functions */
+  void FARK_MALLOC(realtype *t0, realtype *y0, int *imex, 
+		   int *iatol, realtype *rtol, realtype *atol, 
+		   long int *iout, realtype *rout, 
+		   long int *ipar, realtype *rpar, int *ier);
+
+  void FARK_REINIT(realtype *t0, realtype *y0, int *imex,
+		   int *iatol, realtype *rtol, realtype *atol,
+		   int *ier);
+
+  void FARK_RESIZE(realtype *t0, realtype *y0, realtype *hscale, 
+		   int *itol, realtype *rtol, realtype *atol, int *ier);
+
+  void FARK_SETIIN(char key_name[], long int *ival, int *ier);
+  void FARK_SETRIN(char key_name[], realtype *rval, int *ier);
+  void FARK_SETDEFAULTS(int *ier);
+  void FARK_SETERKTABLE(int *s, int *q, int *p, realtype *c, realtype *A, 
+			realtype *b, realtype *b2, int *ier);
+  void FARK_SETIRKTABLE(int *s, int *q, int *p, realtype *c, 
+			realtype *A, realtype *b, realtype *b2, int *ier);
+  void FARK_SETARKTABLES(int *s, int *q, int *p, realtype *ci, realtype *ce, 
+			 realtype *Ai, realtype *Ae, realtype *bi, 
+			 realtype *be, realtype *b2i, realtype *b2e, int *ier);
+  void FARK_SETRESTOLERANCE(int *itol, realtype *atol, int *ier);
+  void FARK_SETDIAGNOSTICS(char fname[], int *flen, int *ier);
+  void FARK_STOPDIAGNOSTICS(int *ier);
+
+  void FARK_EWTSET(int *flag, int *ier);
+  void FARK_ADAPTSET(int *flag, int *ier);
+  void FARK_EXPSTABSET(int *flag, int *ier);
+
+  void FARK_DENSE(long int *neq, int *ier);
+  void FARK_DENSESETJAC(int *flag, int *ier);
+  void FARK_MASSDENSE(long int *neq, int *ier);
+  void FARK_DENSESETMASS(int *ier);
+
+  void FARK_BAND(long int *neq, long int *mupper, long int *mlower, int *ier);
+  void FARK_BANDSETJAC(int *flag, int *ier);
+  void FARK_MASSBAND(long int *neq, long int *mupper, long int *mlower, int *ier);
+  void FARK_BANDSETMASS(int *ier);
+
+  void FARK_LAPACKDENSE(int *neq, int *ier);
+  void FARK_LAPACKDENSESETJAC(int *flag, int *ier);
+  void FARK_MASSLAPACKDENSE(int *neq, int *ier);
+  void FARK_LAPACKDENSESETMASS(int *ier);
+
+  void FARK_LAPACKBAND(int *neq, int *mupper, int *mlower, int *ier);
+  void FARK_LAPACKBANDSETJAC(int *flag, int *ier);
+  void FARK_MASSLAPACKBAND(int *neq, int *mupper, int *mlower, int *ier);
+  void FARK_LAPACKBANDSETMASS(int *ier);
+
+  void FARK_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier);
+  void FARK_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier);
+  void FARK_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier);
+  void FARK_SPARSESETJAC(int *ier);
+  void FARK_MASSKLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier);
+  void FARK_MASSKLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier);
+  void FARK_MASSSUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier);
+  void FARK_SPARSESETMASS(int *ier);
+
+  void FARK_SPGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier);
+  void FARK_SPGMRREINIT(int *pretype, int *gstype, realtype *delt, int *ier);
+  void FARK_MASSSPGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSSPGMRREINIT(int *pretype, int *gstype, realtype *delt, int *ier);
+
+  void FARK_SPFGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier);
+  void FARK_SPFGMRREINIT(int *pretype, int *gstype, realtype *delt, int *ier);
+  void FARK_MASSSPFGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSSPFGMRREINIT(int *pretype, int *gstype, realtype *delt, int *ier);
+
+  void FARK_SPBCG(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_SPBCGREINIT(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSSPBCG(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSSPBCGREINIT(int *pretype, int *maxl, realtype *delt, int *ier);
+
+  void FARK_SPTFQMR(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_SPTFQMRREINIT(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSSPTFQMR(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSSPTFQMRREINIT(int *pretype, int *maxl, realtype *delt, int *ier);
+
+  void FARK_PCG(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_PCGREINIT(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSPCG(int *pretype, int *maxl, realtype *delt, int *ier);
+  void FARK_MASSPCGREINIT(int *pretype, int *maxl, realtype *delt, int *ier);
+
+  void FARK_SPILSSETJAC(int *flag, int *ier);
+  void FARK_SPILSSETPREC(int *flag, int *ier);
+  void FARK_SPILSSETMASS(int *ier);
+  void FARK_SPILSSETMASSPREC(int *flag, int *ier);
+  
+  void FARK_ARKODE(realtype *tout, realtype *t, realtype *y, int *itask, int *ier);
+
+  void FARK_DKY(realtype *t, int *k, realtype *dky, int *ier);
+
+  void FARK_GETERRWEIGHTS(realtype *eweight, int *ier);
+  void FARK_GETESTLOCALERR(realtype *ele, int *ier);
+
+  void FARK_FREE(void);
+
+  void FARK_WRITEPARAMETERS(int *ier);
+
+  void FARK_SETADAPTMETHOD(int *imethod, int *idefault, int *ipq, 
+			   realtype *params, int *ier);
+
+
+  /* Prototypes: Functions Called by the ARKODE Solver */
+  int FARKfi(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+  int FARKfe(realtype t, N_Vector y, N_Vector ydot, void *user_data);
+  
+  int FARKDenseJac(long int N, realtype t, 
+		   N_Vector y, N_Vector fy, 
+		   DlsMat J, void *user_data,
+		   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKDenseMass(long int N, realtype t, DlsMat M, void *user_data,
+		   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKBandJac(long int N, long int mupper, long int mlower,
+		  realtype t, N_Vector y, N_Vector fy,
+		  DlsMat J, void *user_data,
+		  N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKBandMass(long int N, long int mupper, long int mlower,
+		   realtype t, DlsMat M, void *user_data,
+		   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKLapackDenseJac(long int N, realtype t, 
+			 N_Vector y, N_Vector fy, 
+			 DlsMat J, void *user_data,
+			 N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKLapackDenseMass(long int N, realtype t, DlsMat M, void *user_data,
+			  N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+
+  int FARKLapackBandJac(long int N, long int mupper, long int mlower,
+			realtype t, N_Vector y, N_Vector fy,
+			DlsMat J, void *user_data,
+			N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKLapackBandMass(long int N, long int mupper, long int mlower,
+			 realtype t, DlsMat M, void *user_data,
+			 N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKSparseJac(realtype t, N_Vector y, N_Vector fy, 
+		    SlsMat J, void *user_data, N_Vector vtemp1, 
+		    N_Vector vtemp2, N_Vector vtemp3);
+
+  int FARKSparseMass(realtype t, SlsMat Mass, void *user_data, 
+		     N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKPSet(realtype tn, N_Vector y,N_Vector fy, booleantype jok,
+	       booleantype *jcurPtr, realtype gamma, void *user_data,
+	       N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKMassPSet(realtype tn, void *user_data, N_Vector vtemp1, 
+		   N_Vector vtemp2, N_Vector vtemp3);
+  
+  int FARKPSol(realtype tn, N_Vector y, N_Vector fy, 
+	       N_Vector r, N_Vector z,
+	       realtype gamma, realtype delta,
+	       int lr, void *user_data, N_Vector vtemp);
+  
+  int FARKMassPSol(realtype tn, N_Vector r, N_Vector z, realtype delta, 
+		   int lr, void *user_data, N_Vector vtemp);
+  
+  int FARKJtimes(N_Vector v, N_Vector Jv, realtype t, 
+		 N_Vector y, N_Vector fy,
+		 void *user_data, N_Vector work);
+  
+  int FARKMtimes(N_Vector v, N_Vector Mv, realtype t, void *user_data);
+  
+  int FARKEwt(N_Vector y, N_Vector ewt, void *user_data);
+
+  int FARKAdapt(N_Vector y, realtype t, realtype h1, realtype h2, 
+		realtype h3, realtype e1, realtype e2, realtype e3, 
+		int q, int p, realtype *hnew, void *user_data);
+
+  int FARKExpStab(N_Vector y, realtype t, realtype *hstab, void *user_data);
+
+  /* Declarations for global variables shared amongst various routines */
+  extern N_Vector F2C_ARKODE_vec;     /* defined in FNVECTOR module */
+
+  extern void *ARK_arkodemem;     /* defined in farkode.c */
+  extern long int *ARK_iout;      /* defined in farkode.c */
+  extern realtype *ARK_rout;      /* defined in farkode.c */
+  extern int ARK_nrtfn;           /* defined in farkode.c */
+  extern int ARK_ls;              /* defined in farkode.c */
+  extern int ARK_mass_ls;         /* defined in farkode.c */
+
+  /* Linear solver IDs */
+  enum { ARK_LS_DENSE       = 1, 
+	 ARK_LS_BAND        = 2, 
+         ARK_LS_LAPACKDENSE = 3, 
+	 ARK_LS_LAPACKBAND  = 4,
+	 ARK_LS_KLU         = 5, 
+	 ARK_LS_SUPERLUMT   = 6, 
+	 ARK_LS_SPGMR       = 7, 
+	 ARK_LS_SPBCG       = 8, 
+	 ARK_LS_SPTFQMR     = 9, 
+	 ARK_LS_SPFGMR      = 10, 
+	 ARK_LS_PCG         = 12 };
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkpreco.c b/src/arkode/fcmix/farkpreco.c
new file mode 100644
index 0000000..75f2c70
--- /dev/null
+++ b/src/arkode/fcmix/farkpreco.c
@@ -0,0 +1,124 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * The C function FARKPSet is to interface between the ARKSP*
+ * modules and the user-supplied preconditioner setup routine 
+ * FARKPSET. Note the use of the generic name FARK_PSET in the 
+ * code below.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_spils.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routines */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_PSET(realtype *T, realtype *Y, realtype *FY,
+			booleantype *JOK, booleantype *JCUR,
+			realtype *GAMMA, realtype *H,
+			long int *IPAR, realtype *RPAR, 
+			realtype *W1, realtype *W2, 
+			realtype *W3, int *IER);
+  extern void FARK_PSOL(realtype *T, realtype *Y, realtype *FY,
+			realtype *R, realtype *Z, 
+			realtype *GAMMA, realtype *DELTA,
+			int *LR, long int *IPAR, realtype *RPAR,
+			realtype *WRK, int *IER);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSpilsSetPreconditioner; see 
+   farkode.h for further details */
+void FARK_SPILSSETPREC(int *flag, int *ier)
+{
+  if (*flag == 0) {
+    *ier = ARKSpilsSetPreconditioner(ARK_arkodemem, NULL, NULL);
+  } else {
+    *ier = ARKSpilsSetPreconditioner(ARK_arkodemem, 
+				     FARKPSet, FARKPSol);
+  }
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKPSET; see 
+   farkode.h for further details */
+int FARKPSet(realtype t, N_Vector y, N_Vector fy, 
+	     booleantype jok, booleantype *jcurPtr, 
+	     realtype gamma, void *user_data, N_Vector vtemp1, 
+	     N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier = 0;
+  realtype *ydata, *fydata, *v1data, *v2data, *v3data;
+  realtype h;
+  FARKUserData ARK_userdata;
+
+  ARKodeGetLastStep(ARK_arkodemem, &h);
+  ydata  = N_VGetArrayPointer(y);
+  fydata = N_VGetArrayPointer(fy);
+  v1data = N_VGetArrayPointer(vtemp1);
+  v2data = N_VGetArrayPointer(vtemp2);
+  v3data = N_VGetArrayPointer(vtemp3);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_PSET(&t, ydata, fydata, &jok, jcurPtr, &gamma, &h,
+	    ARK_userdata->ipar, ARK_userdata->rpar,
+	    v1data, v2data, v3data, &ier);
+  return(ier);
+}
+
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKPSOL; see 
+   farkode.h for further details */
+int FARKPSol(realtype t, N_Vector y, N_Vector fy, N_Vector r, 
+	     N_Vector z, realtype gamma, realtype delta,
+	     int lr, void *user_data, N_Vector vtemp)
+{
+  int ier = 0;
+  realtype *ydata, *fydata, *vtdata, *rdata, *zdata;
+  FARKUserData ARK_userdata;
+
+  ydata  = N_VGetArrayPointer(y);
+  fydata = N_VGetArrayPointer(fy);
+  vtdata = N_VGetArrayPointer(vtemp);
+  rdata  = N_VGetArrayPointer(r);
+  zdata  = N_VGetArrayPointer(z);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_PSOL(&t, ydata, fydata, rdata, zdata, &gamma, &delta, &lr, 
+	    ARK_userdata->ipar, ARK_userdata->rpar, vtdata, &ier);
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkroot.c b/src/arkode/fcmix/farkroot.c
new file mode 100644
index 0000000..df1695d
--- /dev/null
+++ b/src/arkode/fcmix/farkroot.c
@@ -0,0 +1,100 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * The FARKROOT module contains the routines necessary to use
+ * the rootfinding feature of the ARKODE module and to interface
+ * with the user-supplied Fortran subroutine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "farkroot.h"
+#include "arkode_impl.h"
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+  extern void FARK_ROOTFN(realtype *T, realtype *Y, 
+			  realtype *G, long int *IPAR, 
+			  realtype *RPAR, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeRootInit; see farkroot.h
+   for further information. */
+void FARK_ROOTINIT(int *nrtfn, int *ier)
+{
+  *ier = ARKodeRootInit(ARK_arkodemem, *nrtfn, 
+			(ARKRootFn) FARKrootfunc);
+  ARK_nrtfn = *nrtfn;
+  return;
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeGetRootInfo; see 
+   farkroot.h for further information. */
+void FARK_ROOTINFO(int *nrtfn, int *info, int *ier)
+{
+  *ier = ARKodeGetRootInfo(ARK_arkodemem, info);
+  return; 
+}
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKodeRootInit, used to free 
+   existing memory resources; see farkroot.h for further 
+   information. */
+void FARK_ROOTFREE(void)
+{
+  ARKodeRootInit(ARK_arkodemem, 0, NULL);
+  return;
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied routine FARKROOTFN; see 
+   farkroot.h for further information. */
+int FARKrootfunc(realtype t, N_Vector y, 
+		 realtype *gout, void *user_data)
+{
+  int ier;
+  realtype *ydata;
+  FARKUserData ARK_userdata;
+
+  ydata = N_VGetArrayPointer(y);
+
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_ROOTFN(&t, ydata, gout, ARK_userdata->ipar, 
+	      ARK_userdata->rpar, &ier);
+
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farkroot.h b/src/arkode/fcmix/farkroot.h
new file mode 100644
index 0000000..59b103c
--- /dev/null
+++ b/src/arkode/fcmix/farkroot.h
@@ -0,0 +1,153 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * This is the Fortran interface include file for the rootfinding
+ * feature of ARKODE.
+ *--------------------------------------------------------------*/
+
+/*===============================================================
+                   FARKROOT Interface Package
+
+ The FARKROOT interface package allows programs written in 
+ FORTRAN to use the rootfinding feature of the ARKODE solver 
+ module.
+
+ The user-callable functions constituting the FARKROOT package 
+ are the following: FARKROOTINIT, FARKROOTINFO, and FARKROOTFREE. 
+ The corresponding ARKODE subroutine called by each interface 
+ function is given below.
+
+   FARKROOT routine      ARKODE equivalent
+   ----------------      -------------------
+     FARKROOTINIT    ->   ARKodeRootInit
+     FARKROOTINFO    ->   ARKodeGetRootInfo
+     FARKROOTFREE    ->   ARKodeRootInit
+
+ FARKROOTFN is a user-supplied subroutine defining the functions 
+ whose roots are sought.
+
+ ================================================================
+
+              Usage of the FARKROOT Interface Package
+
+ 1. In order to use the rootfinding feature of the ARKODE package 
+    the user must define the following subroutine:
+
+    SUBROUTINE FARKROOTFN(T, Y, G, IPAR, RPAR, IER)
+
+    The arguments are:
+      T = independent variable value t  [realtype, input]
+      Y = dependent variable array y  [realtype, input]
+      G = function value array g(t,y)  [realtype, output]
+      IPAR = user data array [long int, input/output]
+      RPAR = user data array [realtype, input/output]
+      IER = return flag [int, output]:
+            0 if success
+            non-zero if error
+
+ 2. After calling FARKMALLOC but prior to calling FARKODE, the 
+    user must allocate and initialize memory for the FARKROOT 
+    module by making the following call:
+
+    CALL FARKROOTINIT(NRTFN, IER)
+
+    The arguments are:
+      NRTFN = total number of root functions  [int, input]
+      IER   = return flag [int, output]:
+                 0 if success
+		-1 if ARKODE memory NULL 
+               -11 if memory allocation error
+
+ 3. After calling FARKODE, to see whether a root was found, test 
+    the FARKODE return flag IER.  The value IER = 2 means one or 
+    more roots were found.
+
+ 4. If a root was found, and if NRTFN>1, then to determine which 
+    root functions G(*) were found to have a root, make the 
+    following call:
+    
+    CALL FARKROOTINFO(NRTFN, INFO, IER)
+
+    The arguments are:
+      NRTFN = total number of root functions [int, input]
+      INFO = array of length NRTFN [int, output]:
+                if G(i) has a root, then INFO(i) = 1
+                if G(i) does not have a root, then INFO(i) = 0
+      IER = return flag [int, output]
+                0 if success
+                negative if failure
+
+ 5. The total number of calls made to the root function 
+    (FARKROOTFN), NGE, can be obtained from IOUT(13).
+
+    Note: if the FARKODE/ARKODE memory block is reinitialized to 
+    solve a different problem via a call to FARKREINIT, then the 
+    counter NGE is reset to zero.
+
+ 6. To free the memory resources allocated by a prior call to 
+    FARKROOTINIT make the following call:
+
+    CALL FARKROOTFREE()
+
+ For additional information, see the ARKODE documentation.
+===============================================================*/
+
+#ifndef _FARKROOT_H
+#define _FARKROOT_H
+
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_types.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/* Definitions of interface function names */
+#if defined(SUNDIALS_F77_FUNC)
+
+#define FARK_ROOTINIT SUNDIALS_F77_FUNC(farkrootinit, FARKROOTINIT)
+#define FARK_ROOTINFO SUNDIALS_F77_FUNC(farkrootinfo, FARKROOTINFO)
+#define FARK_ROOTFREE SUNDIALS_F77_FUNC(farkrootfree, FARKROOTFREE)
+#define FARK_ROOTFN   SUNDIALS_F77_FUNC(farkrootfn,   FARKROOTFN)
+
+#else
+
+#define FARK_ROOTINIT farkrootinit_
+#define FARK_ROOTINFO farkrootinfo_
+#define FARK_ROOTFREE farkrootfree_
+#define FARK_ROOTFN   farkrootfn_
+
+#endif
+
+/* Prototypes of exported function */
+void FARK_ROOTINIT(int *nrtfn, int *ier);
+void FARK_ROOTINFO(int *nrtfn, int *info, int *ier);
+void FARK_ROOTFREE(void);
+
+/* Prototype of function called by ARKODE module */
+int FARKrootfunc(realtype t, N_Vector y, 
+		 realtype *gout, void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farksparse.c b/src/arkode/fcmix/farksparse.c
new file mode 100644
index 0000000..c56ea43
--- /dev/null
+++ b/src/arkode/fcmix/farksparse.c
@@ -0,0 +1,86 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKKLU, for the case
+ * of a user-supplied sparse Jacobian routine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_sparse.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_SPJAC(realtype *T, realtype *Y, 
+			 realtype *FY, int *N, int *NNZ, 
+			 realtype *JDATA, int *JRVALS, 
+			 int *JCPTRS, realtype *H, 
+			 long int *IPAR, realtype *RPAR, 
+			 realtype *V1, realtype *V2, 
+			 realtype *V3, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSlsSetSparseJacFn; see 
+   farkode.h for further information */
+void FARK_SPARSESETJAC(int *ier)
+{
+  *ier = ARKSlsSetSparseJacFn(ARK_arkodemem, FARKSparseJac);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKSPJAC; see 
+   farkode.h for additional information  */
+int FARKSparseJac(realtype t, N_Vector y, N_Vector fy, 
+		  SlsMat J, void *user_data, N_Vector vtemp1, 
+		  N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *ydata, *fydata, *v1data, *v2data, *v3data;
+  realtype h;
+  FARKUserData ARK_userdata;
+
+  ARKodeGetLastStep(ARK_arkodemem, &h);
+  ydata   = N_VGetArrayPointer(y);
+  fydata  = N_VGetArrayPointer(fy);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_SPJAC(&t, ydata, fydata, &(J->NP), &(J->NNZ), J->data, 
+	     J->indexvals, J->indexptrs, &h, ARK_userdata->ipar, 
+	     ARK_userdata->rpar, v1data, v2data, v3data, &ier); 
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farksparsemass.c b/src/arkode/fcmix/farksparsemass.c
new file mode 100644
index 0000000..a8913a4
--- /dev/null
+++ b/src/arkode/fcmix/farksparsemass.c
@@ -0,0 +1,79 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKKLU, for the case
+ * of a user-supplied sparse Jacobian routine.
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_sparse.h>
+
+/*=============================================================*/
+
+/* Prototype of the Fortran routine */
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+  extern void FARK_SPMASS(realtype *T, int *N, int *NNZ, 
+			  realtype *MDATA, int *MRVALS, 
+			  int *MCPTRS, long int *IPAR, 
+			  realtype *RPAR, realtype *V1, 
+			  realtype *V2, realtype *V3, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSlsSetSparseMassFn; see 
+   farkode.h for further information */
+void FARK_SPARSESETMASS(int *ier)
+{
+  *ier = ARKSlsSetSparseMassFn(ARK_arkodemem, FARKSparseMass);
+}
+
+/*=============================================================*/
+
+/* C interface to user-supplied Fortran routine FARKSPMASS; see 
+   farkode.h for additional information  */
+int FARKSparseMass(realtype t, SlsMat MassMat, void *user_data, 
+		   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *v1data, *v2data, *v3data;
+  FARKUserData ARK_userdata;
+
+  v1data = N_VGetArrayPointer(vtemp1);
+  v2data = N_VGetArrayPointer(vtemp2);
+  v3data = N_VGetArrayPointer(vtemp3);
+  ARK_userdata = (FARKUserData) user_data;
+
+  FARK_SPMASS(&t, &(MassMat->NP), &(MassMat->NNZ), MassMat->data, 
+	      MassMat->indexvals, MassMat->indexptrs, ARK_userdata->ipar, 
+	      ARK_userdata->rpar, v1data, v2data, v3data, &ier); 
+  return(ier);
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/arkode/fcmix/farksuperlumt.c b/src/arkode/fcmix/farksuperlumt.c
new file mode 100644
index 0000000..80174f7
--- /dev/null
+++ b/src/arkode/fcmix/farksuperlumt.c
@@ -0,0 +1,53 @@
+/*---------------------------------------------------------------
+ * Programmer(s): Daniel R. Reynolds @ SMU
+ *---------------------------------------------------------------
+ * LLNS/SMU Copyright Start
+ * Copyright (c) 2015, Southern Methodist University and 
+ * Lawrence Livermore National Security
+ *
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Southern Methodist University and Lawrence Livermore 
+ * National Laboratory under Contract DE-AC52-07NA27344.
+ * Produced at Southern Methodist University and the Lawrence 
+ * Livermore National Laboratory.
+ *
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS/SMU Copyright End
+ *---------------------------------------------------------------
+ * Fortran/C interface routines for ARKODE/ARKSUPERLUMT
+ *--------------------------------------------------------------*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "farkode.h"
+#include "arkode_impl.h"
+#include <arkode/arkode_superlumt.h>
+
+/*=============================================================*/
+
+/* Fortran interface to C routine ARKSuperLUMT; see farkode.h for 
+   further details */
+void FARK_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier)
+{
+  *ier = ARKSuperLUMT(ARK_arkodemem, *nthreads, *neq, *nnz);
+  ARKSuperLUMTSetOrdering(ARK_arkodemem, *ordering);
+  ARK_ls = ARK_LS_SUPERLUMT;
+  return;
+}
+
+
+/* Fortran interface to C routine ARKMassSuperLUMT; see farkode.h for 
+   further details */
+void FARK_MASSSUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier)
+{
+  *ier = ARKMassSuperLUMT(ARK_arkodemem, *nthreads, *neq, *nnz, NULL);
+  ARKMassSuperLUMTSetOrdering(ARK_arkodemem, *ordering);
+  ARK_mass_ls = ARK_LS_SUPERLUMT;
+  return;
+}
+
+/*===============================================================
+   EOF
+===============================================================*/
+
diff --git a/src/cvode/CMakeLists.txt b/src/cvode/CMakeLists.txt
index 5756cab..d47cccc 100644
--- a/src/cvode/CMakeLists.txt
+++ b/src/cvode/CMakeLists.txt
@@ -1,18 +1,31 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4759 $
+# $Date: 2016-05-18 16:25:17 -0700 (Wed, 18 May 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the CVODE library
 
 INSTALL(CODE "MESSAGE(\"\nInstall CVODE\n\")")
 
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICC)
+
 # Add variable cvode_SOURCES with the sources for the CVODE library
 SET(cvode_SOURCES
   cvode.c
@@ -25,10 +38,23 @@ SET(cvode_SOURCES
   cvode_spbcgs.c
   cvode_spgmr.c
   cvode_sptfqmr.c
+  cvode_sparse.c
   cvode_bandpre.c
   cvode_bbdpre.c
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND cvode_SOURCES cvode_klu.c)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND cvode_SOURCES cvode_superlumt.c)
+ENDIF()
+
+# IF(HYPRE_FOUND)
+#      LIST(APPEND cvode_SOURCES cvode_hypamgpre.c)
+# ENDIF()
+
 # Add variable shared_SOURCES with the common SUNDIALS sources which will
 # also be included in the CVODE library
 SET(shared_SOURCES
@@ -38,6 +64,7 @@ SET(shared_SOURCES
   sundials_band.c
   sundials_dense.c
   sundials_iterative.c
+  sundials_sparse.c
   sundials_spbcgs.c
   sundials_spgmr.c
   sundials_sptfqmr.c
@@ -55,12 +82,25 @@ SET(cvode_HEADERS
   cvode_diag.h
   cvode_direct.h
   cvode.h
+  cvode_sparse.h
   cvode_spbcgs.h
   cvode_spgmr.h
   cvode_spils.h
   cvode_sptfqmr.h
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND cvode_HEADERS cvode_klu.h)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND cvode_HEADERS cvode_superlumt.h)
+ENDIF()
+
+# IF(HYPRE_FOUND)
+#      LIST(APPEND cvode_HEADERS cvode_hypamgpre.h)
+# ENDIF()
+
 # Add prefix with complete path to the CVODE header files
 ADD_PREFIX(${sundials_SOURCE_DIR}/include/cvode/ cvode_HEADERS)
 
diff --git a/src/cvode/LICENSE b/src/cvode/LICENSE
index c093380..574b0be 100644
--- a/src/cvode/LICENSE
+++ b/src/cvode/LICENSE
@@ -1,5 +1,5 @@
-Copyright (c) 2002, The Regents of the University of California. 
-Produced at the Lawrence Livermore National Laboratory. 
+Copyright (c) 2002-2015, Lawrence Livermore National Security. 
+Produced at the Lawrence Livermore National Laboratory.
 Written by Scott Cohen, Alan Hindmarsh, Radu Serban, Dan Shumaker.
 UCRL-CODE-155951
 All rights reserved. 
@@ -18,42 +18,43 @@ notice, this list of conditions and the disclaimer (as noted below)
 in the documentation and/or other materials provided with the
 distribution.
 
-3. Neither the name of the UC/LLNL nor the names of its contributors
+3. Neither the name of the LLNS/LLNL nor the names of its contributors
 may be used to endorse or promote products derived from this software
 without specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
+LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF 
+ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 Additional BSD Notice
 ---------------------
 1. This notice is required to be provided under our contract with
-the U.S. Department of Energy (DOE). This work was produced at the
-University of California, Lawrence Livermore National Laboratory
-under Contract No. W-7405-ENG-48 with the DOE.
+the U.S. Department of Energy (DOE). This work was produced at
+Lawrence Livermore National Laboratory under Contract 
+No. DE-AC52-07NA27344 with the DOE.
 
-2. Neither the United States Government nor the University of
-California nor any of their employees, makes any warranty, express
-or implied, or assumes any liability or responsibility for the
+2. Neither the United States Government nor Lawrence Livermore 
+National Security, LLC nor any of their employees, makes any warranty, 
+express or implied, or assumes any liability or responsibility for the
 accuracy, completeness, or usefulness of any information, apparatus,
 product, or process disclosed, or represents that its use would not
 infringe privately-owned rights.
 
-3. Also, reference herein to any specific commercial products,
-process, or services by trade name, trademark, manufacturer or
-otherwise does not necessarily constitute or imply its endorsement,
-recommendation, or favoring by the United States Government or the
-University of California. The views and opinions of authors expressed
-herein do not necessarily state or reflect those of the United States
-Government or the University of California, and shall not be used for
-advertising or product endorsement purposes.
+3. Also, reference herein to any specific commercial products, process, 
+or services by trade name, trademark, manufacturer or otherwise does 
+not necessarily constitute or imply its endorsement, recommendation, 
+or favoring by the United States Government or Lawrence Livermore 
+National Security, LLC. The views and opinions of authors expressed 
+herein do not necessarily state or reflect those of the United States 
+Government or Lawrence Livermore National Security, LLC, and shall 
+not be used for advertising or product endorsement purposes.
+
diff --git a/src/cvode/Makefile.in b/src/cvode/Makefile.in
deleted file mode 100644
index 268f043..0000000
--- a/src/cvode/Makefile.in
+++ /dev/null
@@ -1,175 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for CVODE module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-LIB_REVISION = 1:0:0
-
-CVODE_LIB    = libsundials_cvode.la
-
-CVODE_SRC_FILES = cvode.c cvode_io.c cvode_direct.c cvode_band.c cvode_dense.c cvode_diag.c cvode_spils.c cvode_spbcgs.c cvode_spgmr.c cvode_sptfqmr.c cvode_bandpre.c cvode_bbdpre.c
-CVODE_BL_SRC_FILES = cvode_lapack.c
-
-CVODE_OBJ_FILES = $(CVODE_SRC_FILES:.c=.o)
-CVODE_BL_OBJ_FILES = $(CVODE_BL_SRC_FILES:.c=.o)
-
-CVODE_LIB_FILES = $(CVODE_SRC_FILES:.c=.lo)
-CVODE_BL_LIB_FILES = $(CVODE_BL_SRC_FILES:.c=.lo)
-
-SHARED_LIB_FILES = $(top_builddir)/src/sundials/sundials_band.lo \
-                   $(top_builddir)/src/sundials/sundials_dense.lo \
-                   $(top_builddir)/src/sundials/sundials_direct.lo \
-                   $(top_builddir)/src/sundials/sundials_iterative.lo \
-                   $(top_builddir)/src/sundials/sundials_spgmr.lo \
-                   $(top_builddir)/src/sundials/sundials_spbcgs.lo \
-                   $(top_builddir)/src/sundials/sundials_sptfqmr.lo \
-                   $(top_builddir)/src/sundials/sundials_math.lo \
-                   $(top_builddir)/src/sundials/sundials_nvector.lo
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(CVODE_LIB)
-
-$(CVODE_LIB): shared $(CVODE_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: shared $(CVODE_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(CVODE_LIB) $(CVODE_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-lib_with_bl: shared $(CVODE_LIB_FILES) $(CVODE_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(CVODE_LIB) $(CVODE_LIB_FILES)  $(CVODE_BL_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-install: $(CVODE_LIB)
-	$(mkinstalldirs) $(includedir)/cvode
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(CVODE_LIB) $(libdir)
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode.h         $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_direct.h  $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_dense.h   $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_band.h    $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_diag.h    $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_spils.h   $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_spbcgs.h  $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_spgmr.h   $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_sptfqmr.h $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_bandpre.h $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_bbdpre.h  $(includedir)/cvode/
-	$(INSTALL_HEADER) $(top_srcdir)/src/cvode/cvode_impl.h        $(includedir)/cvode/
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  $(INSTALL_HEADER) $(top_srcdir)/include/cvode/cvode_lapack.h  $(includedir)/cvode/ ; \
-	fi
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(CVODE_LIB)
-	rm -f $(includedir)/cvode/cvode.h
-	rm -f $(includedir)/cvode/cvode_direct.h
-	rm -f $(includedir)/cvode/cvode_dense.h
-	rm -f $(includedir)/cvode/cvode_band.h
-	rm -f $(includedir)/cvode/cvode_diag.h
-	rm -f $(includedir)/cvode/cvode_lapack.h
-	rm -f $(includedir)/cvode/cvode_spils.h
-	rm -f $(includedir)/cvode/cvode_spbcgs.h
-	rm -f $(includedir)/cvode/cvode_spgmr.h
-	rm -f $(includedir)/cvode/cvode_sptfqmr.h
-	rm -f $(includedir)/cvode/cvode_bandpre.h
-	rm -f $(includedir)/cvode/cvode_bbdpre.h
-	rm -f $(includedir)/cvode/cvode_impl.h
-	$(rminstalldirs) $(includedir)/cvode
-
-shared:
-	@cd ${top_builddir}/src/sundials ; \
-	${MAKE} ;                         \
-	cd ${abs_builddir}
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(CVODE_LIB)
-	rm -f $(CVODE_LIB_FILES)
-	rm -f $(CVODE_BL_LIB_FILES)
-	rm -f $(CVODE_OBJ_FILES)
-	rm -f $(CVODE_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-cvode.lo: $(srcdir)/cvode.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode.c
-cvode_io.lo: $(srcdir)/cvode_io.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_io.c
-cvode_direct.lo: $(srcdir)/cvode_direct.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_direct.c
-cvode_dense.lo: $(srcdir)/cvode_dense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_dense.c
-cvode_band.lo: $(srcdir)/cvode_band.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_band.c
-cvode_diag.lo: $(srcdir)/cvode_diag.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_diag.c
-cvode_lapack.lo: $(srcdir)/cvode_lapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_lapack.c
-cvode_spils.lo: $(srcdir)/cvode_spils.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_spils.c
-cvode_spbcgs.lo: $(srcdir)/cvode_spbcgs.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_spbcgs.c
-cvode_spgmr.lo: $(srcdir)/cvode_spgmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_spgmr.c
-cvode_sptfqmr.lo: $(srcdir)/cvode_sptfqmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_sptfqmr.c
-cvode_bandpre.lo: $(srcdir)/cvode_bandpre.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_bandpre.c
-cvode_bbdpre.lo: $(srcdir)/cvode_bbdpre.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvode_bbdpre.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/cvode/README b/src/cvode/README
index fe98969..9e23bbf 100644
--- a/src/cvode/README
+++ b/src/cvode/README
@@ -1,17 +1,16 @@
                               CVODE
-                    Release 2.7.0, March 2012
+                    Release 2.9.0, September 2016
                  Alan C. Hindmarsh and Radu Serban
               Center for Applied Scientific Computing, LLNL
 
 CVODE is a solver for stiff and nonstiff ODE systems (initial value problem) 
 given in explicit form dy/dt = f(t,y). It is written in ANSI standard C.
 
-CVODE can be used both on serial and parallel (MPI) computers.  The main
+CVODE can be used both on serial and parallel computers.  The main
 difference is in the NVECTOR module of vector kernels.  The desired
 version is obtained when compiling the example files by linking the
-appropriate library of NVECTOR kernels.  In the parallel version,
-communication between processors is done with the MPI (Message Passage
-Interface) system. 
+appropriate library of NVECTOR kernels.  In the parallel versions,
+communication between processors is done with MPI, with OpenMP, or with Pthreads.
 
 When used with the serial NVECTOR module, CVODE provides both direct (dense 
 and band) and preconditioned Krylov (iterative) linear solvers. Three different
@@ -26,8 +25,9 @@ band-block-diagonal preconditioner.
 
 CVODE is part of a software family called SUNDIALS: SUite of Nonlinear
 and DIfferential/ALgebraic equation Solvers.  This suite consists of
-CVODE, KINSOL, IDAS, and IDA, and variants of these.  The directory
-structure of the package supplied reflects this family relationship.
+CVODE, CVODES, ARKode, KINSOL, IDAS, and IDA, and variants of these.  
+The directory structure of the package supplied reflects this family 
+relationship.
 
 For use with Fortran applications, a set of Fortran/C interface routines,
 called FCVODE, is also supplied.  These are written in C, but assume that
@@ -48,19 +48,19 @@ and the CVODE Examples [2] (cv_examples.pdf) documents.
 B. Installation
 ---------------
 
-For basic installation instructions see the file /sundials/INSTALL_NOTES. 
-For complete installation instructions see the "CVODE Installation Procedure"
+For basic installation instructions see the file /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see the "Installation Procedure"
 chapter in the CVODE User Guide.
 
 
 C. References
 -------------
 
-[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODE v2.7.0," 
-    LLNL technical report UCRL-SM-208108, December 2011.
+[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODE v2.9.0," 
+    LLNL technical report UCRL-SM-208108, March 2016.
 
-[2] A. C. Hindmarsh and R. Serban, "Example Programs for CVODE v2.7.0," 
-    LLNL technical report UCRL-SM-208110, December 2011.
+[2] A. C. Hindmarsh and R. Serban, "Example Programs for CVODE v2.9.0," 
+    LLNL technical report UCRL-SM-208110, March 2016.
 
 [3] S.D. Cohen and A.C. Hindmarsh, "CVODE, a Stiff/nonstiff ODE Solver in C,"
     Computers in Physics, 10(2), pp. 138-143, 1996.
@@ -74,6 +74,10 @@ C. References
 D. Releases
 -----------
 
+v. 2.9.0       - Sep. 2016
+v. 2.8.2       - Aug. 2015
+v. 2.8.1       - Mar. 2015
+v. 2.8.0       - Mar. 2015
 v. 2.7.0       - Mar. 2012
 v. 2.6.0       - May  2009
 v. 2.5.0       - Nov. 2006
@@ -87,376 +91,3 @@ v. 1.0         - Mar. 2002 (CVODE and PVODE combined)
 v. 1.0 (PVODE) - Jul. 1997 (date written)
 v. 1.0 (CVODE) - Sep. 1994 (date written)
 
-
-E. Revision History
--------------------
-
-v. 2.6.0 (May 2009) ---> v. 2.7.0 (Mar. 2012)
----------------------------------------------
-
-- Bug fixes
-   - in CVSetTqBDF, the logic was changed to avoid a divide by zero.
-   - after the solver memory is created, it is set to zero before being filled.
-   - in each linear solver interface function, the linear solver memory is
-     freed on an error return, and the **Free function now includes a line
-     setting to NULL the main memory pointer to the linear solver memory.
-   - in rootfinding functions CVRcheck1/CVRcheck2, when an exact zero is found,
-     the array glo at the left endpoint is adjusted instead of shifting tlo.
-
-- Changes to user interface
-   - One significant design change was made with this release: The problem
-     size and its relatives, bandwidth parameters, related internal indices,
-     pivot arrays, and the optional output lsflag, have all been
-     changed from type int to type long int, except for the
-     problem size and bandwidths in user calls to routines specifying
-     BLAS/LAPACK routines for the dense/band linear solvers.  The function
-     NewIntArray is replaced by a pair NewIntArray/NewLintArray,
-     for int and long int arrays, respectively.
-   - in the installation files, we modified the treatment of the macro
-     SUNDIALS_USE_GENERIC_MATH, so that the parameter GENERIC_MATH_LIB
-     is either defined (with no value) or not defined.
-
-v. 2.5.0 (Nov. 2006) ---> v. 2.6.0 (May 2009)
----------------------------------------------
-
-- New features
-   - added a new linear solver module based on Blas + Lapack for
-     both dense and banded matrices.
-   - added optional input to specify which direction of zero-crossing
-     is to be monitored while performing root-finding. The root information
-     array iroots (returned by CVodeGetRootInfo) also encodes the 
-     direction of zero-crossing.
-
-- Bug fixes
-   - in the rootfinding algorithm, fixed a bug resulting in unnecessary
-     evaluations of the root functions after reinitialization of the
-     solver right after a return at a root.
-   - in the initial step size calculation, restrict h based on tstop.
-   - modified the setting and use of the tq[] array.  Now tq[i] (i = 1,2,3)
-     are defined to be the reciprocals of what they were before.  This
-     eliminates a rare crash that can occur with xistar_inv = 0.
-
-- Changes to user interface
-   - renamed all **Malloc functions to **Init
-   - tolerances are now specified through separate functions instead of
-     the initialization functions CVodeInit (former CVodeMalloc) and 
-     CVodeReInit. Depending on the tolerance type, one of 3 functions
-     must be called before the first call to CVode.
-   - removed function inputs from argument lists of all re-initialization
-     functions.
-   - all user-supplied functions now receive the same pointer to user data
-     (instead of having different ones for the system evaluation, Jacobian
-     information functions, etc.).
-   - removed CV_NORMAL_TSTOP and CV_ONE_STEP_TSTOP named constants for the
-     itask argument to CVode. A tstop value is now both set and activated
-     through CVodeSetStopTime. Once tstop is reached it is also deactivated.
-     A new value can be then specified by calling again CVodeSetStopTime.
-   - common functionality for all direct linear solvers (dense, band, and
-     the new Lapack solver) has been collected into the DLS (Direct Linear
-     Solver) module, similar to the SPILS module for the iterative linear 
-     solvers. All optional input and output functions for these linear 
-     solver now have the prefix 'CVDls'. In addition, in order to include
-     the new Lapack-based linear solver, all dimensions for these linear
-     solvers (problem sizes, bandwidths, etc) are now of type 'int' 
-     (instead of 'long int').
-   - the initialization functions for the two preconditioner modules,
-     CVBANDPRE and CVBBDPRE were renamed ***Init (from ***Alloc) and they
-     do not return a pointer to preconditioner memory anymore. Instead,
-     all preconditioner module-related functions are now called with
-     the main solver memory pointer as their first argument. When using
-     one of these two modules, there is no need to use special functions
-     to attach one of the SPILS linear solvers (instead use one of
-     CVSpgmr, CVSpbcg, or CVSptfqmr). Moreover, there is no need to call
-     a memory deallocation function for the preconditioner module.
-   - changed names CVSpilsSetDelt and delt to CVSpilsSetEpsLin and eplifac.
-   - added the error return CV_RTFUNC_FAIL.
-   - changes corresponding to the above were made to the FCMIX interface.
-
-
-v. 2.4.0 (Mar. 2006) ---> v. 2.5.0 (Nov. 2006)
-----------------------------------------------
-
-- Bug fixes
-   - added a roundoff factor when testing whether tn was just returned
-     (in root finding) to prevent an unnecessary return.
-   - fixed wrong logic in final stopping tests: now we check if
-     tout was reached before checking if tstop was reached.
-
-- Changes related to the build system
-   - reorganized source tree: header files in ${srcdir}/include/cvode,
-     source files in ${srcdir}/src/cvode, fcmix source files in
-     ${srcdir}/src/cvode/fcmix, examples in ${srcdir}/examples/cvode
-   - exported header files are installed unde ${includedir}/cvode
-
-- Changes to user interface
-   - all included header files use relative paths from ${includedir}
-
-v. 2.3.0 (Apr. 2005) ---> v. 2.4.0 (Mar. 2006)
-----------------------------------------------
-
-- New features
-   - added CVSPBCG interface module to allow CVODE to interface with the
-     shared SPBCG (scaled preconditioned Bi-CGSTAB) linear solver module.
-   - added CVSPTFQMR interface module to allow CVODE to interface with
-     the shared SPTFQMR (scaled preconditioned TFQMR) linear solver module.
-   - added support for SPBCG and SPTFQMR to the CVBBDPRE and CVBANDPRE 
-     preconditioner modules.
-   - added support for interpreting failures in user-supplied functions.
-
-- Changes to user interface
-   - changed argument of CVodeFree, CVBandPrecFree, and CVBBDPrecFree to
-     be the address of the respective memory block pointer, so that its
-     NULL value is propagated back to the calling function.
-   - added CVSPBCG module which defines appropriate CVSpbcg* functions to
-     allow CVODE to interface with the shared SPBCG linear solver module.
-   - added CVBBDSpbcg function to CVBBDPRE module and CVBPSpbcg function to
-     CVBANDPRE module to support SPBCG linear solver module.
-   - added CVBBDSptfqmr function to CVBBDPRE module and CVBPSptfqmr function to
-     CVBANDPRE module to support SPTFQMR linear solver module.
-   - changed function type names (not the actual definition) to accomodate
-     all the Scaled Preconditioned Iterative Linear Solvers now available:
-       CVSpgmrJactimesVecFn -> CVSpilsJacTimesVecFn
-       CVSpgmrPrecSetupFn   -> CVSpilsPrecSetupFn
-       CVSpgmrPrecSolveFn   -> CVSpilsPrecSolveFn 
-   - changed function types so that all user-supplied functions return
-     an integer flag (not all of them currently used).
-   - changed some names for CVBBDPRE and CVBANDPRE function outputs
-   - added option for user-supplied error handler function.
-   - renamed all exported header files (except for cvode.h, all header files
-     have the prefix 'cvode_')
-   - changed naming scheme for CVODE examples
-
-- Changes to the FCVODE module
-   - added support for CVSPBCG/SPBCG (added FCV*SPBCG* functions).
-   - added support for CVSPTFQMR/SPTFQMR (added FCV*SPTFQMR* functions).
-   - optional inputs are now set using routines FCVSETIIN (integer inputs)
-     and FCVSETRIN (real inputs) through pairs key-value. Optional outputs
-     are still obtained from two arrays (IOUT and ROUT), owned by the user
-     and passed as arguments to FCVMALLOC. Note that the argument OPTIN
-     was removed from FCVMALLOC.
-   - changed the prototypes of user-supplied functions so that they all
-     return an error flag as their last argument (not all of them currently used).
-   - the arguments OPTIN, IOPT, and ROPT were removed from FCVREINIT
-
-- Changes related to the build system
-   - updated configure script and Makefiles for Fortran examples to avoid C++
-     compiler errors (now use CC and MPICC to link only if necessary)
-   - the main CVODE header file (cvode.h) is still exported to the install include
-     directory. However, all other CVODE header files are exported into a 'cvode'
-     subdirectory of the install include directory.
-   - the CVODE library now contains all shared object files (there is no separate
-     libsundials_shared library anymore)
-
-v. 2.2.2 (Mar. 2005) ---> v. 2.3.0 (Apr. 2005)
-----------------------------------------------
-
-- New features
-   - added option for user-provided error weight computation function
-     (of type CVEwtFn specified through CVodeSetEwtFn).
-
-- Changes to user interface
-   - CVODE now stores tolerances through values rather than references 
-     (to resolve potential scoping issues). 
-   - CVODE now passes information back to the user through values rather
-     than references (error weights, estimated local errors, root info)
-   - CVodeMalloc, CVodeReInit, CVodeSetTolerances: added option itol=CV_WF 
-     to indicate user-supplied function for computing the error weights; 
-     reltol is now declared as realtype. Note that it is now illegal to call
-     CVodeSetTolerances before CVodeMalloc. It is now legal to deallocate
-     the absolute tolerance N_Vector right after its use.
-   - CVodeGetErrorWeights: the user is now responsible for allocating space
-     for the N_Vector in which error weights will be copied.
-   - CVodeGetEstLocalErrors: the user is now responsible for allocating space
-     for the N_Vector in which estimated local errors will be copied.
-   - CVodeGetRootInfo: the user is now responsible for allocating space
-     for the int array in which root information will be copied.
-   - Passing a value of 0 for the maximum step size, the minimum step
-     size, or for maxsteps results in the solver using the corresponding
-     default value (infinity, 0, 500, respectively)
-   - Several optional input functions were combined into a single one
-     (CVodeRootInit and CvodeSetGdata, CVDenseSetJacFn and CVDenseSetJacData,
-     CVBandSetJacFn and CVBandSetJacData, CVSpgmrSetPrecSolveFn and 
-     CVSpgmrSetPrecSetFn and CVSpgmrSetPrecData, CVSpgmrSetJacTimesVecFn and
-     CVSpgmrSetJacData).
-
-- Changes to the FCVODE module:
-   - Added option for user-supplied error weight computation subroutine
-     (FCVEWT). Use FCVEWTSET to indicate that FCVEWT is provided.
-   - Due to the changes to the main solver, if FCVPSOL is provided then
-     FCVPSET must also be defined, even if it is empty.
-
-v. 2.2.1 (Jan. 2005) ---> v. 2.2.2 (Mar. 2005)
-----------------------------------------------
-
-- Bug fixes
-   - fixed bug in CVode function:  Initial setting of tretlast = *tret = tn removed
-     (correcting erroneous behavior at first call to CVRcheck3).
-   - removed redundant setting of tretlast = *tret = tn at CLOSE_ROOTS return from CVode.
-   - modified FCMIX files to avoid C++ compiler errors
-   - changed implicit type conversion to explicit in check_flag() routine in
-     examples to avoid C++ compiler errors
-
-- Changes to documentation
-   - added section with numerical values of all input and output solver constants
-   - added more detailed notes on the type of absolute tolerances
-   - added more details on ownership of memory for the array returned by CVodeGetRootInfo 
-   - corrected/added descriptions of error returns.
-   - added description of --with-mpi-flags option
-
-- Changes related to the build system
-   - fixed autoconf-related bug to allow configuration with the PGI Fortran compiler
-   - modified to use customized detection of the Fortran name mangling scheme 
-     (autoconf's AC_F77_WRAPPERS routine is problematic on some platforms)
-   - added --with-mpi-flags as a configure option to allow user to specify
-     MPI-specific flags
-   - updated Makefiles for Fortran examples to avoid C++ compiler errors (now use
-     CC and MPICC to link)
-
-v. 2.2.0 (Dec. 2004) ---> v. 2.2.1 (Jan. 2005)
-----------------------------------------------
-
-- Changes related to the build system
-   - changed order of compiler directives in header files to avoid compilation
-     errors when using a C++ compiler.
-
-v. 2.0 (Jul. 2002) ---> v. 2.2.0 (Dec. 2004)
---------------------------------------------
-
-- New features
-   - added option to specify a value of the independent variable (time)
-     past which the integration is never to proceed.
-   - added rootfinding capabilities.
-   - added option to disable all error messages.
-
-- Changes related to the NVECTOR module (see also file sundials/shared/README)
-   - removed machEnv, redefined table of vector operations (now contained
-     in the N_Vector structure itself).
-   - all CVODE functions create new N_Vector variables through cloning, using
-     an N_Vector passed by the user as a template.
-
-- Changes to type names and CVODE constants
-   - removed type 'integertype'; instead use int or long int, as appropriate.
-   - restructured the list of return values from the various CVODE functions.
-   - changed all CVODE constants (inputs and return values) to have the
-     prefix 'CV_' (e.g. CV_SUCCESS).
-   - renamed various function types to have the prefix 'CV' (e.g. CVRhsFn).
-
-- Changes to optional input/ouput
-   - added CVodeSet* and CVodeGet* functions for optional inputs/outputs, 
-     replacing the arrays iopt and ropt.
-   - added new optional inputs (e.g. maximum number of Newton iterations,
-     maximum number of convergence failures, etc).
-   - the value of the last return flag from any function within a linear
-     solver module can be obtained as an optional output (e.g. CVDenseGetLastFlag).
-  
-- Changes to user-callable functions
-   - added new function CVodeCreate which initializes the CVODE solver
-     object and returns a pointer to the CVODE memory block.
-   - removed N (problem size) from all functions except the initialization
-     functions for the direct linear solvers (CVDense and CVBand).
-   - shortened argument lists of most CVODE functions (the arguments that
-     were dropped can now be specified through CVodeSet* functions).
-   - removed reinitialization functions for band/dense/SPGMR linear
-     solvers (same functionality can be obtained using CV*Set* functions).
-   - in CVBBDPRE, added a new function, CVBBDSpgmr to initialize the
-     SPGMR linear solver with the BBD preconditioner.
-   - function names changed in CVBANDPRE and CVBBDPRE for uniformity.
-
-- Changes to user-supplied functions
-   - removed N (probem dimension) from argument lists.
-   - shortened argument lists for user dense/band/SPGMR Jacobian routines.
-     (Data needed to do difference quotients is accessible in other ways.) 
-   - in CVSPGMR, shortened argument lists for user preconditioner functions.
-
-- Changes to the FCVODE module
-   - revised to use underscore and precision flags at compile time (from
-     configure); example sources are preprocessed accordingly.
-   - reorganized FCVODE into fewer files.
-   - added tstop options, and interfaces to CVBANDPRE and rootfinding features.
-   - use CV*Set* and CV*Get* functions from CVODE (although the optional I/O 
-     is still communicated to the user of FCVODE through arrays IOPT and ROPT).
-   - added new optional inputs and outputs (e.g.tstop, nlscoef, maxnef, maxcor, 
-     maxncf, etc.) and rearranged locations in IOPT and ROPT for uniformity.
-
-
-Summary of previous revisions (YYYYMMDD) (significant revisions only)
----------------------------------------------------------------------
-
-Combined CVODE package (Mar. 2002 - Jul. 2002)
------------------------------------------------
-
-20020313  Modified to work with new NVECTOR abstraction.
-          Changed name PVBBDPRE to CVBBDPRE, etc.
-20020321  Revisions throughout to reflect usage changes for NVECTOR modules.
-          Changed dense/band backsolve argument b type from N_Vector to real*.
-20020328  In FCVODE, added interfaces to dense/band linear solvers.
-20020626  Changed type names real/integer to realtype/integertype.
-
-PVODE (Jul. 1995 - Mar. 2002)
------------------------------
-
-19950726  DATE WRITTEN; MPI version of VECTOR module written, creating 
-          MPI_PVODE; makefiles written with defs. specific to IBM-SP.
-19950929  Formed package directory structure; added Cray-T3D defs. to Makefiles.
-19970219  FPVODE package of Fortran/C interfaces written, with examples.
-19970724  Wrote preconditioner module BBDPRE and Fortran/C interface.
-19970811  Type names changed to LLNL_FLOAT etc.
-19970813  Changed first FFUN arg. in FPVODE to local length NLOC.
-19971103  Added argc,argv to PVInitMPI call list; removed ICOMM
-          argument to FPVINITMPI (pass MPI_COMM_WORLD).
-19971201  Name changes: PVInitMPI/PVFreeMPI to PVecInitMPI/PVecFreeMPI.
-19971208  Added optional argument dqrely to BBDPRE.
-19971217  Revised FPVODE to use name mappings via parameters in fcmixpar.h.
-19980120  Name changes: VECTOR to NVECTOR etc.
-19980206  Name changes: BBDPRE to PVBBDPRE, FFUN to PVFUN, etc.
-19980508  Wrappers on header files for C++ use; type bool changed to boole.
-19980923  In PVBBDPRE and Fortran interface, added two half-bandwidth arguments.
-20000316  SPGMR module modified for correct treatment of scalings.
-          added new routine CVReInit for re-initialization of CVODE.
-20000320  In NVECTOR module: removed comm = NULL option in PVecInitMPI.
-20000321  Added interface FPVREINIT, and expanded diagkf example.
-20000719  Fixed memory leak bugs in CVReInit and FPVREINIT.
-20000808  Fixed bug in N_VMin routine.
-20011114  Added option for stability limit detection algorithm STALD.
-20011220  Default type 'integer' changed to 'long int' in llnltyps.h.
-20011220  Optional input ropt[HMAX] examined on every call to CVode.
-20011221  Optional input iopt[MXHNIL] = -1 means no t+h=t messages.
-20011228  Added arguments to CVSpgmr: jtimes (user J*v routine), jac_data.
-          Added optional jtimes to FPVODE.  Revised examples accordingly.
-20020114  Linear solver modules reorganized: specification routines
-          CVDiag and CVSpgmr perform malloc operations and return a
-          completion flag.  Re-use of linear solver memory is allowed if
-          linear solver choice and parameters are unchanged.  Fortran
-          interface routines modified analogously.  All examples
-          modified to receive and test new return flag.
-20020301  Added CVReInitSpgmr routine to CVSPGMR module, and added Fortran
-          interfaces to it.  Revised cvdemk and pvdiagkf accordingly.
-20020306  Added PVReInitBBD routine to PVBBDPRE, and added Fortran interface
-          to it.  Revised pvkxb and pvidagkbf examples accordingly.
-
-CVODE (1993 - Mar. 2002)
-------------------------
-
-1993-94   DATE WRITTEN.  First released 2 September 1994.
-19970811  Type names changed to LLNL_FLOAT etc.
-19980120  Name changes: VECTOR to NVECTOR etc.
-19980508  Wrappers on header files for C++ use; type bool changed to boole.
-20000316  SPGMR module modified for correct treatment of scalings.
-          Added CVODE re-initialization routine CVReInit.
-20000323  Added band preconditioner module CVBANDPRE.
-20000719  Fixed memory leak bugs in CVReInit.
-20000808  Fixed bug in N_VMin routine.
-20011114  Added option for stability limit detection algorithm STALD.
-20011115  Reorganized DENSE module, with smalldense.* files separate.
-20011220  Default type 'integer' changed to 'long int' in llnltyps.h.
-20011220  Optional input ropt[HMAX] examined on every call to CVode.
-20011221  Optional input iopt[MXHNIL] = -1 means no t+h=t messages.
-20011228  Added arguments to CVSpgmr: jtimes (user J*v routine), jac_data.
-20020114  Linear solver modules reorganized: linear solver specification
-          routines perform malloc operations and return a completion flag.
-          Re-use of linear solver memory is allowed if linear solver choice
-          and parameters are unchanged.   All examples modified accordingly.
-20020301  Added ReInit routine to CVDENSE, CVBAND, CVSPGMR modules.
-20020305  Added CVReInitBandPre routine to CVBANDPRE module.
-
-
diff --git a/src/cvode/cvode.c b/src/cvode/cvode.c
index 466a6fe..dafab72 100644
--- a/src/cvode/cvode.c
+++ b/src/cvode/cvode.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.24 $
- * $Date: 2012/03/06 21:58:36 $
+ * $Revision: 4285 $
+ * $Date: 2014-12-12 13:39:23 -0800 (Fri, 12 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
  *                and Dan Shumaker @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the main CVODE integrator.
  * It is independent of the CVODE linear solver in use.
@@ -40,55 +45,55 @@
 /*             CVODE Private Constants                             */
 /*=================================================================*/
 
-#define ZERO   RCONST(0.0)     /* real 0.0     */
-#define TINY   RCONST(1.0e-10) /* small number */
-#define TENTH  RCONST(0.1)     /* real 0.1     */
-#define POINT2 RCONST(0.2)     /* real 0.2     */
-#define FOURTH RCONST(0.25)    /* real 0.25    */
-#define HALF   RCONST(0.5)     /* real 0.5     */
-#define ONE    RCONST(1.0)     /* real 1.0     */
-#define TWO    RCONST(2.0)     /* real 2.0     */
-#define THREE  RCONST(3.0)     /* real 3.0     */
-#define FOUR   RCONST(4.0)     /* real 4.0     */
-#define FIVE   RCONST(5.0)     /* real 5.0     */
-#define TWELVE RCONST(12.0)    /* real 12.0    */
-#define HUN    RCONST(100.0)   /* real 100.0   */
+#define ZERO    RCONST(0.0)     /* real 0.0     */
+#define TINY    RCONST(1.0e-10) /* small number */
+#define PT1     RCONST(0.1)     /* real 0.1     */
+#define POINT2  RCONST(0.2)     /* real 0.2     */
+#define FOURTH  RCONST(0.25)    /* real 0.25    */
+#define HALF    RCONST(0.5)     /* real 0.5     */
+#define ONE     RCONST(1.0)     /* real 1.0     */
+#define TWO     RCONST(2.0)     /* real 2.0     */
+#define THREE   RCONST(3.0)     /* real 3.0     */
+#define FOUR    RCONST(4.0)     /* real 4.0     */
+#define FIVE    RCONST(5.0)     /* real 5.0     */
+#define TWELVE  RCONST(12.0)    /* real 12.0    */
+#define HUNDRED RCONST(100.0)   /* real 100.0   */
 
 /*=================================================================*/
-/*             CVODE Routine-Specific Constants                   */
+/*             CVODE Routine-Specific Constants                    */
 /*=================================================================*/
 
 /* 
- * Control constants for lower-level functions used by CVStep 
+ * Control constants for lower-level functions used by cvStep 
  * ----------------------------------------------------------
  *
- * CVHin return values:
+ * cvHin return values:
  *    CV_SUCCESS
  *    CV_RHSFUNC_FAIL
  *    CV_TOO_CLOSE
  *
- * CVStep control constants:
+ * cvStep control constants:
  *    DO_ERROR_TEST
  *    PREDICT_AGAIN
  *
- * CVStep return values: 
+ * cvStep return values: 
  *    CV_SUCCESS,
  *    CV_LSETUP_FAIL,  CV_LSOLVE_FAIL, 
  *    CV_RHSFUNC_FAIL, CV_RTFUNC_FAIL
  *    CV_CONV_FAILURE, CV_ERR_FAILURE,
  *    CV_FIRST_RHSFUNC_ERR
  *
- * CVNls input nflag values:
+ * cvNls input nflag values:
  *    FIRST_CALL
  *    PREV_CONV_FAIL
  *    PREV_ERR_FAIL
  *    
- * CVNls return values: 
+ * cvNls return values: 
  *    CV_SUCCESS,
  *    CV_LSETUP_FAIL, CV_LSOLVE_FAIL, CV_RHSFUNC_FAIL,
  *    CONV_FAIL, RHSFUNC_RECVR
  * 
- * CVNewtonIteration return values:
+ * cvNewtonIteration return values:
  *    CV_SUCCESS, 
  *    CV_LSOLVE_FAIL, CV_RHSFUNC_FAIL
  *    CONV_FAIL, RHSFUNC_RECVR,
@@ -112,19 +117,19 @@
  * Control constants for lower-level rootfinding functions
  * -------------------------------------------------------
  *
- * CVRcheck1 return values:
+ * cvRcheck1 return values:
  *    CV_SUCCESS,
  *    CV_RTFUNC_FAIL,
- * CVRcheck2 return values:
+ * cvRcheck2 return values:
  *    CV_SUCCESS
  *    CV_RTFUNC_FAIL,
  *    CLOSERT
  *    RTFOUND
- * CVRcheck3 return values:
+ * cvRcheck3 return values:
  *    CV_SUCCESS
  *    CV_RTFUNC_FAIL,
  *    RTFOUND
- * CVRootfind return values:
+ * cvRootfind return values:
  *    CV_SUCCESS
  *    CV_RTFUNC_FAIL,
  *    RTFOUND
@@ -147,11 +152,11 @@
  * Algorithmic constants
  * ---------------------
  *
- * CVodeGetDky and CVStep
+ * CVodeGetDky and cvStep
  *
  *    FUZZ_FACTOR
  *
- * CVHin
+ * cvHin
  *
  *    HLB_FACTOR
  *    HUB_FACTOR
@@ -162,7 +167,7 @@
  *
  *   CORTES
  *
- * CVStep
+ * cvStep
  *
  *    THRESH
  *    ETAMX1
@@ -182,11 +187,11 @@
  *    MXNEF       max no. of error test failures during one step try
  *    MXNEF1      max no. of error test failures before forcing a reduction of order
  *    SMALL_NEF   if an error failure occurs and SMALL_NEF <= nef <= MXNEF1, then
- *                reset eta =  MIN(eta, ETAMXF)
+ *                reset eta =  SUNMIN(eta, ETAMXF)
  *    LONG_WAIT   number of steps to wait before considering an order change when
  *                q==1 and MXNEF1 error test failures have occurred
  *
- * CVNls
+ * cvNls
  *    
  *    NLS_MAXCOR  maximum no. of corrector iterations for the nonlinear solver
  *    CRDOWN      constant used in the estimation of the convergence rate (crate)
@@ -238,72 +243,72 @@
 /*             Private Helper Functions Prototypes                 */
 /*=================================================================*/
 
-static booleantype CVCheckNvector(N_Vector tmpl);
+static booleantype cvCheckNvector(N_Vector tmpl);
 
-static int CVInitialSetup(CVodeMem cv_mem);
+static int cvInitialSetup(CVodeMem cv_mem);
 
-static booleantype CVAllocVectors(CVodeMem cv_mem, N_Vector tmpl);
-static void CVFreeVectors(CVodeMem cv_mem);
+static booleantype cvAllocVectors(CVodeMem cv_mem, N_Vector tmpl);
+static void cvFreeVectors(CVodeMem cv_mem);
 
-static int CVEwtSetSS(CVodeMem cv_mem, N_Vector ycur, N_Vector weight);
-static int CVEwtSetSV(CVodeMem cv_mem, N_Vector ycur, N_Vector weight);
+static int cvEwtSetSS(CVodeMem cv_mem, N_Vector ycur, N_Vector weight);
+static int cvEwtSetSV(CVodeMem cv_mem, N_Vector ycur, N_Vector weight);
 
-static int CVHin(CVodeMem cv_mem, realtype tout);
-static realtype CVUpperBoundH0(CVodeMem cv_mem, realtype tdist);
-static int CVYddNorm(CVodeMem cv_mem, realtype hg, realtype *yddnrm);
+static int cvHin(CVodeMem cv_mem, realtype tout);
+static realtype cvUpperBoundH0(CVodeMem cv_mem, realtype tdist);
+static int cvYddNorm(CVodeMem cv_mem, realtype hg, realtype *yddnrm);
 
-static int CVStep(CVodeMem cv_mem);
+static int cvStep(CVodeMem cv_mem);
 
-static int CVsldet(CVodeMem cv_mem);
+static int cvSLdet(CVodeMem cv_mem);
 
-static void CVAdjustParams(CVodeMem cv_mem);
-static void CVAdjustOrder(CVodeMem cv_mem, int deltaq);
-static void CVAdjustAdams(CVodeMem cv_mem, int deltaq);
-static void CVAdjustBDF(CVodeMem cv_mem, int deltaq);
-static void CVIncreaseBDF(CVodeMem cv_mem);
-static void CVDecreaseBDF(CVodeMem cv_mem);
+static void cvAdjustParams(CVodeMem cv_mem);
+static void cvAdjustOrder(CVodeMem cv_mem, int deltaq);
+static void cvAdjustAdams(CVodeMem cv_mem, int deltaq);
+static void cvAdjustBDF(CVodeMem cv_mem, int deltaq);
+static void cvIncreaseBDF(CVodeMem cv_mem);
+static void cvDecreaseBDF(CVodeMem cv_mem);
 
-static void CVRescale(CVodeMem cv_mem);
+static void cvRescale(CVodeMem cv_mem);
 
-static void CVPredict(CVodeMem cv_mem);
+static void cvPredict(CVodeMem cv_mem);
 
-static void CVSet(CVodeMem cv_mem);
-static void CVSetAdams(CVodeMem cv_mem);
-static realtype CVAdamsStart(CVodeMem cv_mem, realtype m[]);
-static void CVAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype hsum);
-static realtype CVAltSum(int iend, realtype a[], int k);
-static void CVSetBDF(CVodeMem cv_mem);
-static void CVSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
+static void cvSet(CVodeMem cv_mem);
+static void cvSetAdams(CVodeMem cv_mem);
+static realtype cvAdamsStart(CVodeMem cv_mem, realtype m[]);
+static void cvAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype hsum);
+static realtype cvAltSum(int iend, realtype a[], int k);
+static void cvSetBDF(CVodeMem cv_mem);
+static void cvSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
                        realtype alpha0_hat, realtype xi_inv, realtype xistar_inv);
 
-static int CVNls(CVodeMem cv_mem, int nflag);
-static int CVNlsFunctional(CVodeMem cv_mem);
-static int CVNlsNewton(CVodeMem cv_mem, int nflag);
-static int CVNewtonIteration(CVodeMem cv_mem);
+static int cvNls(CVodeMem cv_mem, int nflag);
+static int cvNlsFunctional(CVodeMem cv_mem);
+static int cvNlsNewton(CVodeMem cv_mem, int nflag);
+static int cvNewtonIteration(CVodeMem cv_mem);
 
-static int CVHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
+static int cvHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
                          int *ncfPtr);
 
-static void CVRestore(CVodeMem cv_mem, realtype saved_t);
+static void cvRestore(CVodeMem cv_mem, realtype saved_t);
 
-static int CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr,
+static int cvDoErrorTest(CVodeMem cv_mem, int *nflagPtr,
                          realtype saved_t, int *nefPtr, realtype *dsmPtr);
 
-static void CVCompleteStep(CVodeMem cv_mem);
+static void cvCompleteStep(CVodeMem cv_mem);
 
-static void CVPrepareNextStep(CVodeMem cv_mem, realtype dsm);
-static void CVSetEta(CVodeMem cv_mem);
-static realtype CVComputeEtaqm1(CVodeMem cv_mem);
-static realtype CVComputeEtaqp1(CVodeMem cv_mem);
-static void CVChooseEta(CVodeMem cv_mem);
-static void CVBDFStab(CVodeMem cv_mem);
+static void cvPrepareNextStep(CVodeMem cv_mem, realtype dsm);
+static void cvSetEta(CVodeMem cv_mem);
+static realtype cvComputeEtaqm1(CVodeMem cv_mem);
+static realtype cvComputeEtaqp1(CVodeMem cv_mem);
+static void cvChooseEta(CVodeMem cv_mem);
+static void cvBDFStab(CVodeMem cv_mem);
 
-static int  CVHandleFailure(CVodeMem cv_mem,int flag);
+static int cvHandleFailure(CVodeMem cv_mem,int flag);
 
-static int CVRcheck1(CVodeMem cv_mem);
-static int CVRcheck2(CVodeMem cv_mem);
-static int CVRcheck3(CVodeMem cv_mem);
-static int CVRootfind(CVodeMem cv_mem);
+static int cvRcheck1(CVodeMem cv_mem);
+static int cvRcheck2(CVodeMem cv_mem);
+static int cvRcheck3(CVodeMem cv_mem);
+static int cvRootfind(CVodeMem cv_mem);
 
 /* 
  * =================================================================
@@ -330,19 +335,19 @@ void *CVodeCreate(int lmm, int iter)
   /* Test inputs */
 
   if ((lmm != CV_ADAMS) && (lmm != CV_BDF)) {
-    CVProcessError(NULL, 0, "CVODE", "CVodeCreate", MSGCV_BAD_LMM);
+    cvProcessError(NULL, 0, "CVODE", "CVodeCreate", MSGCV_BAD_LMM);
     return(NULL);
   }
   
   if ((iter != CV_FUNCTIONAL) && (iter != CV_NEWTON)) {
-    CVProcessError(NULL, 0, "CVODE", "CVodeCreate", MSGCV_BAD_ITER);
+    cvProcessError(NULL, 0, "CVODE", "CVodeCreate", MSGCV_BAD_ITER);
     return(NULL);
   }
 
   cv_mem = NULL;
   cv_mem = (CVodeMem) malloc(sizeof(struct CVodeMemRec));
   if (cv_mem == NULL) {
-    CVProcessError(NULL, 0, "CVODE", "CVodeCreate", MSGCV_CVMEM_FAIL);
+    cvProcessError(NULL, 0, "CVODE", "CVodeCreate", MSGCV_CVMEM_FAIL);
     return(NULL);
   }
 
@@ -365,7 +370,7 @@ void *CVodeCreate(int lmm, int iter)
   cv_mem->cv_user_efun  = FALSE;
   cv_mem->cv_efun       = NULL;
   cv_mem->cv_e_data     = NULL;
-  cv_mem->cv_ehfun      = CVErrHandler;
+  cv_mem->cv_ehfun      = cvErrHandler;
   cv_mem->cv_eh_data    = cv_mem;
   cv_mem->cv_errfp      = stderr;
   cv_mem->cv_qmax       = maxord;
@@ -440,7 +445,7 @@ int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0, N_Vector y0)
   /* Check cvode_mem */
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeInit", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeInit", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -448,20 +453,20 @@ int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0, N_Vector y0)
   /* Check for legal input parameters */
 
   if (y0==NULL) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeInit", MSGCV_NULL_Y0);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeInit", MSGCV_NULL_Y0);
     return(CV_ILL_INPUT);
   }
 
   if (f == NULL) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeInit", MSGCV_NULL_F);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeInit", MSGCV_NULL_F);
     return(CV_ILL_INPUT);
   }
 
   /* Test if all required vector operations are implemented */
 
-  nvectorOK = CVCheckNvector(y0);
+  nvectorOK = cvCheckNvector(y0);
   if(!nvectorOK) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeInit", MSGCV_BAD_NVECTOR);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeInit", MSGCV_BAD_NVECTOR);
     return(CV_ILL_INPUT);
   }
 
@@ -478,9 +483,9 @@ int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0, N_Vector y0)
 
   /* Allocate the vectors (using y0 as a template) */
 
-  allocOK = CVAllocVectors(cv_mem, y0);
+  allocOK = cvAllocVectors(cv_mem, y0);
   if (!allocOK) {
-    CVProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeInit", MSGCV_MEM_FAIL);
+    cvProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeInit", MSGCV_MEM_FAIL);
     return(CV_MEM_FAIL);
   }
 
@@ -580,7 +585,7 @@ int CVodeReInit(void *cvode_mem, realtype t0, N_Vector y0)
   /* Check cvode_mem */
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeReInit", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeReInit", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -588,14 +593,14 @@ int CVodeReInit(void *cvode_mem, realtype t0, N_Vector y0)
   /* Check if cvode_mem was allocated */
 
   if (cv_mem->cv_MallocDone == FALSE) {
-    CVProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeReInit", MSGCV_NO_MALLOC);
+    cvProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeReInit", MSGCV_NO_MALLOC);
     return(CV_NO_MALLOC);
   }
 
   /* Check for legal input parameters */
 
   if (y0 == NULL) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeReInit", MSGCV_NULL_Y0);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeReInit", MSGCV_NULL_Y0);
     return(CV_ILL_INPUT);
   }
   
@@ -674,25 +679,25 @@ int CVodeSStolerances(void *cvode_mem, realtype reltol, realtype abstol)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSStolerances", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSStolerances", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (cv_mem->cv_MallocDone == FALSE) {
-    CVProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeSStolerances", MSGCV_NO_MALLOC);
+    cvProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeSStolerances", MSGCV_NO_MALLOC);
     return(CV_NO_MALLOC);
   }
 
   /* Check inputs */
 
   if (reltol < ZERO) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSStolerances", MSGCV_BAD_RELTOL);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSStolerances", MSGCV_BAD_RELTOL);
     return(CV_ILL_INPUT);
   }
 
   if (abstol < ZERO) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSStolerances", MSGCV_BAD_ABSTOL);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSStolerances", MSGCV_BAD_ABSTOL);
     return(CV_ILL_INPUT);
   }
 
@@ -704,7 +709,7 @@ int CVodeSStolerances(void *cvode_mem, realtype reltol, realtype abstol)
   cv_mem->cv_itol = CV_SS;
 
   cv_mem->cv_user_efun = FALSE;
-  cv_mem->cv_efun = CVEwtSet;
+  cv_mem->cv_efun = cvEwtSet;
   cv_mem->cv_e_data = NULL; /* will be set to cvode_mem in InitialSetup */
 
   return(CV_SUCCESS);
@@ -716,25 +721,25 @@ int CVodeSVtolerances(void *cvode_mem, realtype reltol, N_Vector abstol)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSVtolerances", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSVtolerances", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (cv_mem->cv_MallocDone == FALSE) {
-    CVProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeSVtolerances", MSGCV_NO_MALLOC);
+    cvProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeSVtolerances", MSGCV_NO_MALLOC);
     return(CV_NO_MALLOC);
   }
 
   /* Check inputs */
 
   if (reltol < ZERO) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSVtolerances", MSGCV_BAD_RELTOL);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSVtolerances", MSGCV_BAD_RELTOL);
     return(CV_ILL_INPUT);
   }
 
   if (N_VMin(abstol) < ZERO) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSVtolerances", MSGCV_BAD_ABSTOL);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSVtolerances", MSGCV_BAD_ABSTOL);
     return(CV_ILL_INPUT);
   }
 
@@ -753,7 +758,7 @@ int CVodeSVtolerances(void *cvode_mem, realtype reltol, N_Vector abstol)
   cv_mem->cv_itol = CV_SV;
 
   cv_mem->cv_user_efun = FALSE;
-  cv_mem->cv_efun = CVEwtSet;
+  cv_mem->cv_efun = cvEwtSet;
   cv_mem->cv_e_data = NULL; /* will be set to cvode_mem in InitialSetup */
 
   return(CV_SUCCESS);
@@ -765,13 +770,13 @@ int CVodeWFtolerances(void *cvode_mem, CVEwtFn efun)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeWFtolerances", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeWFtolerances", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (cv_mem->cv_MallocDone == FALSE) {
-    CVProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeWFtolerances", MSGCV_NO_MALLOC);
+    cvProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVodeWFtolerances", MSGCV_NO_MALLOC);
     return(CV_NO_MALLOC);
   }
 
@@ -813,7 +818,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
 
   /* Check cvode_mem pointer */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeRootInit", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeRootInit", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -861,7 +866,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
         lrw -= 3*nrt;
         liw -= 3*nrt;
 
-        CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeRootInit", MSGCV_NULL_G);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeRootInit", MSGCV_NULL_G);
         return(CV_ILL_INPUT);
       }
       else {
@@ -875,7 +880,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
   /* Set variable values in CVode memory block */
   cv_mem->cv_nrtfn = nrt;
   if (g == NULL) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeRootInit", MSGCV_NULL_G);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeRootInit", MSGCV_NULL_G);
     return(CV_ILL_INPUT);
   }
   else gfun = g;
@@ -884,7 +889,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
   glo = NULL;
   glo = (realtype *) malloc(nrt*sizeof(realtype));
   if (glo == NULL) {
-    CVProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
+    cvProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
     return(CV_MEM_FAIL);
   }
 
@@ -892,7 +897,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
   ghi = (realtype *) malloc(nrt*sizeof(realtype));
   if (ghi == NULL) {
     free(glo); glo = NULL;
-    CVProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
+    cvProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
     return(CV_MEM_FAIL);
   }
 
@@ -901,7 +906,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
   if (grout == NULL) {
     free(glo); glo = NULL;
     free(ghi); ghi = NULL;
-    CVProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
+    cvProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
     return(CV_MEM_FAIL);
   }
 
@@ -911,7 +916,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
     free(glo); glo = NULL; 
     free(ghi); ghi = NULL;
     free(grout); grout = NULL;
-    CVProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
+    cvProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
     return(CV_MEM_FAIL);
   }
 
@@ -922,7 +927,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
     free(ghi); ghi = NULL;
     free(grout); grout = NULL;
     free(iroots); iroots = NULL;
-    CVProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
+    cvProcessError(cv_mem, CV_MEM_FAIL, "CVODE", "CVodeRootInit", MSGCV_MEM_FAIL);
     return(CV_MEM_FAIL);
   }
 
@@ -934,7 +939,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
     free(grout); grout = NULL;
     free(iroots); iroots = NULL;
     free(rootdir); rootdir = NULL;
-    CVProcessError(cv_mem, CV_MEM_FAIL, "CVODES", "CVodeRootInit", MSGCV_MEM_FAIL);
+    cvProcessError(cv_mem, CV_MEM_FAIL, "CVODES", "CVodeRootInit", MSGCV_MEM_FAIL);
     return(CV_MEM_FAIL);
   }
 
@@ -1055,7 +1060,7 @@ int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g)
  * This routine is the main driver of the CVODE package. 
  *
  * It integrates over a time interval defined by the user, by calling
- * CVStep to do internal time steps.
+ * cvStep to do internal time steps.
  *
  * The first time that CVode is called for a successfully initialized
  * problem, it computes a tentative initial step size h.
@@ -1084,32 +1089,32 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
 
   /* Check if cvode_mem exists */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVode", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVode", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Check if cvode_mem was allocated */
   if (cv_mem->cv_MallocDone == FALSE) {
-    CVProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVode", MSGCV_NO_MALLOC);
+    cvProcessError(cv_mem, CV_NO_MALLOC, "CVODE", "CVode", MSGCV_NO_MALLOC);
     return(CV_NO_MALLOC);
   }
   
   /* Check for yout != NULL */
   if ((y = yout) == NULL) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_YOUT_NULL);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_YOUT_NULL);
     return(CV_ILL_INPUT);
   }
 
   /* Check for tret != NULL */
   if (tret == NULL) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_TRET_NULL);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_TRET_NULL);
     return(CV_ILL_INPUT);
   }
 
   /* Check for valid itask */
   if ( (itask != CV_NORMAL) && (itask != CV_ONE_STEP) ) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_ITASK);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_ITASK);
     return(CV_ILL_INPUT);
   }
 
@@ -1130,51 +1135,58 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
 
   if (nst == 0) {
 
-    ier = CVInitialSetup(cv_mem);
+    tretlast = *tret = tn;
+
+    ier = cvInitialSetup(cv_mem);
     if (ier!= CV_SUCCESS) return(ier);
     
     /* Call f at (t0,y0), set zn[1] = y'(t0), 
-       set initial h (from H0 or CVHin), and scale zn[1] by h.
+       set initial h (from H0 or cvHin), and scale zn[1] by h.
        Also check for zeros of root function g at and near t0.    */
     
     retval = f(tn, zn[0], zn[1], user_data); 
     nfe++;
     if (retval < 0) {
-      CVProcessError(cv_mem, CV_RHSFUNC_FAIL, "CVODE", "CVode", MSGCV_RHSFUNC_FAILED, tn);
+      cvProcessError(cv_mem, CV_RHSFUNC_FAIL, "CVODE", "CVode", MSGCV_RHSFUNC_FAILED, tn);
       return(CV_RHSFUNC_FAIL);
     }
     if (retval > 0) {
-      CVProcessError(cv_mem, CV_FIRST_RHSFUNC_ERR, "CVODE", "CVode", MSGCV_RHSFUNC_FIRST);
+      cvProcessError(cv_mem, CV_FIRST_RHSFUNC_ERR, "CVODE", "CVode", MSGCV_RHSFUNC_FIRST);
       return(CV_FIRST_RHSFUNC_ERR);
     }
 
-    /* Set initial h (from H0 or CVHin). */
+    /* Test input tstop for legality. */
+
+    if (tstopset) {
+      if ( (tstop - tn)*(tout - tn) <= ZERO ) {
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_TSTOP, tstop, tn);
+        return(CV_ILL_INPUT);
+      }
+     }
+
+    /* Set initial h (from H0 or cvHin). */
 
     h = hin;
     if ( (h != ZERO) && ((tout-tn)*h < ZERO) ) {
-      CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_H0);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_H0);
       return(CV_ILL_INPUT);
     }
     if (h == ZERO) {
       tout_hin = tout;
-      if ( tstopset && (tout-tn)*(tout-tstop) > 0 ) tout_hin = tstop; 
-      hflag = CVHin(cv_mem, tout_hin);
+      if ( tstopset && (tout-tn)*(tout-tstop) > ZERO ) tout_hin = tstop; 
+      hflag = cvHin(cv_mem, tout_hin);
       if (hflag != CV_SUCCESS) {
-        istate = CVHandleFailure(cv_mem, hflag);
+        istate = cvHandleFailure(cv_mem, hflag);
         return(istate);
       }
     }
-    rh = ABS(h)*hmax_inv;
+    rh = SUNRabs(h)*hmax_inv;
     if (rh > ONE) h /= rh;
-    if (ABS(h) < hmin) h *= hmin/ABS(h);
+    if (SUNRabs(h) < hmin) h *= hmin/SUNRabs(h);
 
     /* Check for approach to tstop */
 
     if (tstopset) {
-      if ( (tstop - tn)*h < ZERO ) {
-        CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_TSTOP, tstop, tn);
-        return(CV_ILL_INPUT);
-      }
       if ( (tn + h - tstop)*h > ZERO ) 
         h = (tstop - tn)*(ONE-FOUR*uround);
     }
@@ -1191,10 +1203,10 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
 
     if (nrtfn > 0) {
 
-      retval = CVRcheck1(cv_mem);
+      retval = cvRcheck1(cv_mem);
 
       if (retval == CV_RTFUNC_FAIL) {
-        CVProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "CVRcheck1", MSGCV_RTFUNC_FAILED, tn);
+        cvProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "cvRcheck1", MSGCV_RTFUNC_FAILED, tn);
         return(CV_RTFUNC_FAIL);
       }
 
@@ -1219,7 +1231,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     /* Estimate an infinitesimal time interval to be used as
        a roundoff for time quantities (based on current time 
        and step size) */
-    troundoff = FUZZ_FACTOR*uround*(ABS(tn) + ABS(h));
+    troundoff = FUZZ_FACTOR*uround*(SUNRabs(tn) + SUNRabs(h));
 
     /* First, check for a root in the last step taken, other than the
        last root found, if any.  If itask = CV_ONE_STEP and y(tn) was not
@@ -1228,13 +1240,13 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
 
       irfndp = irfnd;
       
-      retval = CVRcheck2(cv_mem);
+      retval = cvRcheck2(cv_mem);
 
       if (retval == CLOSERT) {
-        CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVRcheck2", MSGCV_CLOSE_ROOTS, tlo);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "cvRcheck2", MSGCV_CLOSE_ROOTS, tlo);
         return(CV_ILL_INPUT);
       } else if (retval == CV_RTFUNC_FAIL) {
-        CVProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "CVRcheck2", MSGCV_RTFUNC_FAILED, tlo);
+        cvProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "cvRcheck2", MSGCV_RTFUNC_FAILED, tlo);
         return(CV_RTFUNC_FAIL);
       } else if (retval == RTFOUND) {
         tretlast = *tret = tlo;
@@ -1243,9 +1255,9 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
 
       /* If tn is distinct from tretlast (within roundoff),
          check remaining interval for roots */
-      if ( ABS(tn - tretlast) > troundoff ) {
+      if ( SUNRabs(tn - tretlast) > troundoff ) {
 
-        retval = CVRcheck3(cv_mem);
+        retval = cvRcheck3(cv_mem);
 
         if (retval == CV_SUCCESS) {     /* no root found */
           irfnd = 0;
@@ -1259,7 +1271,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
           tretlast = *tret = tlo;
           return(CV_ROOT_RETURN);
         } else if (retval == CV_RTFUNC_FAIL) {  /* g failed */
-          CVProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "CVRcheck3", MSGCV_RTFUNC_FAILED, tlo);
+          cvProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "cvRcheck3", MSGCV_RTFUNC_FAILED, tlo);
           return(CV_RTFUNC_FAIL);
         }
 
@@ -1272,14 +1284,14 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
       tretlast = *tret = tout;
       ier =  CVodeGetDky(cv_mem, tout, 0, yout);
       if (ier != CV_SUCCESS) {
-        CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_TOUT, tout);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_TOUT, tout);
         return(CV_ILL_INPUT);
       }
       return(CV_SUCCESS);
     }
 
     /* In CV_ONE_STEP mode, test if tn was returned */
-    if ( itask == CV_ONE_STEP && ABS(tn - tretlast) > troundoff ) {
+    if ( itask == CV_ONE_STEP && SUNRabs(tn - tretlast) > troundoff ) {
       tretlast = *tret = tn;
       N_VScale(ONE, zn[0], yout);
       return(CV_SUCCESS);
@@ -1288,10 +1300,10 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     /* Test for tn at tstop or near tstop */
     if ( tstopset ) {
 
-      if ( ABS(tn - tstop) <= troundoff) {
+      if ( SUNRabs(tn - tstop) <= troundoff) {
         ier =  CVodeGetDky(cv_mem, tstop, 0, yout);
         if (ier != CV_SUCCESS) {
-          CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_TSTOP, tstop, tn);
+          cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_BAD_TSTOP, tstop, tn);
           return(CV_ILL_INPUT);
         }
         tretlast = *tret = tstop;
@@ -1315,7 +1327,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
    *
    *    4.1. check for errors (too many steps, too much
    *         accuracy requested, step size too small)
-   *    4.2. take a new step (call CVStep)
+   *    4.2. take a new step (call cvStep)
    *    4.3. stop on error 
    *    4.4. perform stop tests:
    *         - check for root in last step
@@ -1339,9 +1351,9 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
       if (ewtsetOK != 0) {
 
         if (itol == CV_WF) 
-          CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_EWT_NOW_FAIL, tn);
+          cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_EWT_NOW_FAIL, tn);
         else 
-          CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_EWT_NOW_BAD, tn);
+          cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVode", MSGCV_EWT_NOW_BAD, tn);
 	
         istate = CV_ILL_INPUT;
         tretlast = *tret = tn;
@@ -1353,7 +1365,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     
     /* Check for too many steps */
     if ( (mxstep>0) && (nstloc >= mxstep) ) {
-      CVProcessError(cv_mem, CV_TOO_MUCH_WORK, "CVODE", "CVode", MSGCV_MAX_STEPS, tn);
+      cvProcessError(cv_mem, CV_TOO_MUCH_WORK, "CVODE", "CVode", MSGCV_MAX_STEPS, tn);
       istate = CV_TOO_MUCH_WORK;
       tretlast = *tret = tn;
       N_VScale(ONE, zn[0], yout);
@@ -1364,7 +1376,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     nrm = N_VWrmsNorm(zn[0], ewt);
     tolsf = uround * nrm;
     if (tolsf > ONE) {
-      CVProcessError(cv_mem, CV_TOO_MUCH_ACC, "CVODE", "CVode", MSGCV_TOO_MUCH_ACC, tn);
+      cvProcessError(cv_mem, CV_TOO_MUCH_ACC, "CVODE", "CVode", MSGCV_TOO_MUCH_ACC, tn);
       istate = CV_TOO_MUCH_ACC;
       tretlast = *tret = tn;
       N_VScale(ONE, zn[0], yout);
@@ -1378,17 +1390,17 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     if (tn + h == tn) {
       nhnil++;
       if (nhnil <= mxhnil) 
-        CVProcessError(cv_mem, CV_WARNING, "CVODE", "CVode", MSGCV_HNIL, tn, h);
+        cvProcessError(cv_mem, CV_WARNING, "CVODE", "CVode", MSGCV_HNIL, tn, h);
       if (nhnil == mxhnil) 
-        CVProcessError(cv_mem, CV_WARNING, "CVODE", "CVode", MSGCV_HNIL_DONE);
+        cvProcessError(cv_mem, CV_WARNING, "CVODE", "CVode", MSGCV_HNIL_DONE);
     }
 
-    /* Call CVStep to take a step */
-    kflag = CVStep(cv_mem);
+    /* Call cvStep to take a step */
+    kflag = cvStep(cv_mem);
 
     /* Process failed step cases, and exit loop */
     if (kflag != CV_SUCCESS) {
-      istate = CVHandleFailure(cv_mem, kflag);
+      istate = cvHandleFailure(cv_mem, kflag);
       tretlast = *tret = tn;
       N_VScale(ONE, zn[0], yout);
       break;
@@ -1399,7 +1411,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     /* Check for root in last step taken. */
     if (nrtfn > 0) {
 
-      retval = CVRcheck3(cv_mem);
+      retval = cvRcheck3(cv_mem);
 
       if (retval == RTFOUND) {  /* A new root was found */
         irfnd = 1;
@@ -1407,7 +1419,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
         tretlast = *tret = tlo;
         break;
       } else if (retval == CV_RTFUNC_FAIL) { /* g failed */
-        CVProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "CVRcheck3", MSGCV_RTFUNC_FAILED, tlo);
+        cvProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "cvRcheck3", MSGCV_RTFUNC_FAILED, tlo);
         istate = CV_RTFUNC_FAIL;
         break;
       }
@@ -1426,7 +1438,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
           }
         }
         if ((cv_mem->cv_mxgnull > 0) && inactive_roots) {
-          CVProcessError(cv_mem, CV_WARNING, "CVODES", "CVode", MSGCV_INACTIVE_ROOTS);
+          cvProcessError(cv_mem, CV_WARNING, "CVODES", "CVode", MSGCV_INACTIVE_ROOTS);
         }
       }
 
@@ -1445,8 +1457,8 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     /* Check if tn is at tstop or near tstop */
     if ( tstopset ) {
 
-      troundoff = FUZZ_FACTOR*uround*(ABS(tn) + ABS(h));
-      if ( ABS(tn - tstop) <= troundoff) {
+      troundoff = FUZZ_FACTOR*uround*(SUNRabs(tn) + SUNRabs(h));
+      if ( SUNRabs(tn - tstop) <= troundoff) {
         (void) CVodeGetDky(cv_mem, tstop, 0, yout);
         tretlast = *tret = tstop;
         tstopset = FALSE;
@@ -1504,28 +1516,28 @@ int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky)
   /* Check all inputs for legality */
  
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetDky", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetDky", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (dky == NULL) {
-    CVProcessError(cv_mem, CV_BAD_DKY, "CVODE", "CVodeGetDky", MSGCV_NULL_DKY);
+    cvProcessError(cv_mem, CV_BAD_DKY, "CVODE", "CVodeGetDky", MSGCV_NULL_DKY);
     return(CV_BAD_DKY);
   }
 
   if ((k < 0) || (k > q)) {
-    CVProcessError(cv_mem, CV_BAD_K, "CVODE", "CVodeGetDky", MSGCV_BAD_K);
+    cvProcessError(cv_mem, CV_BAD_K, "CVODE", "CVodeGetDky", MSGCV_BAD_K);
     return(CV_BAD_K);
   }
   
   /* Allow for some slack */
-  tfuzz = FUZZ_FACTOR * uround * (ABS(tn) + ABS(hu));
+  tfuzz = FUZZ_FACTOR * uround * (SUNRabs(tn) + SUNRabs(hu));
   if (hu < ZERO) tfuzz = -tfuzz;
   tp = tn - hu - tfuzz;
   tn1 = tn + tfuzz;
   if ((t-tp)*(t-tn1) > ZERO) {
-    CVProcessError(cv_mem, CV_BAD_T, "CVODE", "CVodeGetDky", MSGCV_BAD_T, t, tn-hu, tn);
+    cvProcessError(cv_mem, CV_BAD_T, "CVODE", "CVodeGetDky", MSGCV_BAD_T, t, tn-hu, tn);
     return(CV_BAD_T);
   }
 
@@ -1542,7 +1554,7 @@ int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky)
     }
   }
   if (k == 0) return(CV_SUCCESS);
-  r = RPowerI(h,-k);
+  r = SUNRpowerI(h,-k);
   N_VScale(r, dky, dky);
   return(CV_SUCCESS);
 }
@@ -1551,7 +1563,7 @@ int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky)
  * CVodeFree
  *
  * This routine frees the problem memory allocated by CVodeInit.
- * Such memory includes all the vectors allocated by CVAllocVectors,
+ * Such memory includes all the vectors allocated by cvAllocVectors,
  * and the memory lmem for the linear solver (deallocated by a call
  * to lfree).
  */
@@ -1564,7 +1576,7 @@ void CVodeFree(void **cvode_mem)
 
   cv_mem = (CVodeMem) (*cvode_mem);
   
-  CVFreeVectors(cv_mem);
+  cvFreeVectors(cv_mem);
 
   if (iter == CV_NEWTON && lfree != NULL) lfree(cv_mem);
 
@@ -1588,12 +1600,12 @@ void CVodeFree(void **cvode_mem)
  */
 
 /*
- * CVCheckNvector
+ * cvCheckNvector
  * This routine checks if all required vector operations are present.
  * If any of them is missing it returns FALSE.
  */
 
-static booleantype CVCheckNvector(N_Vector tmpl)
+static booleantype cvCheckNvector(N_Vector tmpl)
 {
   if((tmpl->ops->nvclone     == NULL) ||
      (tmpl->ops->nvdestroy   == NULL) ||
@@ -1614,18 +1626,18 @@ static booleantype CVCheckNvector(N_Vector tmpl)
 }
 
 /*
- * CVAllocVectors
+ * cvAllocVectors
  *
  * This routine allocates the CVODE vectors ewt, acor, tempv, ftemp, and
  * zn[0], ..., zn[maxord].
- * If all memory allocations are successful, CVAllocVectors returns TRUE. 
- * Otherwise all allocated memory is freed and CVAllocVectors returns FALSE.
+ * If all memory allocations are successful, cvAllocVectors returns TRUE. 
+ * Otherwise all allocated memory is freed and cvAllocVectors returns FALSE.
  * This routine also sets the optional outputs lrw and liw, which are
  * (respectively) the lengths of the real and integer work spaces
  * allocated here.
  */
 
-static booleantype CVAllocVectors(CVodeMem cv_mem, N_Vector tmpl)
+static booleantype cvAllocVectors(CVodeMem cv_mem, N_Vector tmpl)
 {
   int i, j;
 
@@ -1680,12 +1692,12 @@ static booleantype CVAllocVectors(CVodeMem cv_mem, N_Vector tmpl)
 }
 
 /*  
- * CVFreeVectors
+ * cvFreeVectors
  *
- * This routine frees the CVODE vectors allocated in CVAllocVectors.
+ * This routine frees the CVODE vectors allocated in cvAllocVectors.
  */
 
-static void CVFreeVectors(CVodeMem cv_mem)
+static void cvFreeVectors(CVodeMem cv_mem)
 {
   int j, maxord;
   
@@ -1695,7 +1707,7 @@ static void CVFreeVectors(CVodeMem cv_mem)
   N_VDestroy(acor);
   N_VDestroy(tempv);
   N_VDestroy(ftemp);
-  for(j=0; j <= maxord; j++) N_VDestroy(zn[j]);
+  for (j=0; j <= maxord; j++) N_VDestroy(zn[j]);
 
   lrw -= (maxord + 5)*lrw1;
   liw -= (maxord + 5)*liw1;
@@ -1708,20 +1720,20 @@ static void CVFreeVectors(CVodeMem cv_mem)
 }
 
 /*  
- * CVInitialSetup
+ * cvInitialSetup
  *
  * This routine performs input consistency checks at the first step.
  * If needed, it also checks the linear solver module and calls the
  * linear solver initialization routine.
  */
 
-static int CVInitialSetup(CVodeMem cv_mem)
+static int cvInitialSetup(CVodeMem cv_mem)
 {
   int ier;
 
   /* Did the user specify tolerances? */
   if (itol == CV_NN) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVInitialSetup", MSGCV_NO_TOLS);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "cvInitialSetup", MSGCV_NO_TOLS);
     return(CV_ILL_INPUT);
   }
 
@@ -1733,22 +1745,22 @@ static int CVInitialSetup(CVodeMem cv_mem)
   ier = efun(zn[0], ewt, e_data);
   if (ier != 0) {
     if (itol == CV_WF) 
-      CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVInitialSetup", MSGCV_EWT_FAIL);
-    else 
-      CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVInitialSetup", MSGCV_BAD_EWT);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "cvInitialSetup", MSGCV_EWT_FAIL);
+    else
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "cvInitialSetup", MSGCV_BAD_EWT);
     return(CV_ILL_INPUT);
   }
   
   /* Check if lsolve function exists (if needed) and call linit function (if it exists) */
   if (iter == CV_NEWTON) {
     if (lsolve == NULL) {
-      CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVInitialSetup", MSGCV_LSOLVE_NULL);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "cvInitialSetup", MSGCV_LSOLVE_NULL);
       return(CV_ILL_INPUT);
     }
     if (linit != NULL) {
       ier = linit(cv_mem);
       if (ier != 0) {
-        CVProcessError(cv_mem, CV_LINIT_FAIL, "CVODE", "CVInitialSetup", MSGCV_LINIT_FAIL);
+        cvProcessError(cv_mem, CV_LINIT_FAIL, "CVODE", "cvInitialSetup", MSGCV_LINIT_FAIL);
         return(CV_LINIT_FAIL);
       }
     }
@@ -1764,17 +1776,17 @@ static int CVInitialSetup(CVodeMem cv_mem)
  */
 
 /*
- * CVHin
+ * cvHin
  *
  * This routine computes a tentative initial step size h0. 
- * If tout is too close to tn (= t0), then CVHin returns CV_TOO_CLOSE
+ * If tout is too close to tn (= t0), then cvHin returns CV_TOO_CLOSE
  * and h remains uninitialized. Note that here tout is either the value
  * passed to CVode at the first call or the value of tstop (if tstop is 
  * enabled and it is closer to t0=tn than tout).
- * If the RHS function fails unrecoverably, CVHin returns CV_RHSFUNC_FAIL.
+ * If the RHS function fails unrecoverably, cvHin returns CV_RHSFUNC_FAIL.
  * If the RHS function fails recoverably too many times and recovery is
- * not possible, CVHin returns CV_REPTD_RHSFUNC_ERR.
- * Otherwise, CVHin sets h to the chosen value h0 and returns CV_SUCCESS.
+ * not possible, cvHin returns CV_REPTD_RHSFUNC_ERR.
+ * Otherwise, cvHin sets h to the chosen value h0 and returns CV_SUCCESS.
  *
  * The algorithm used seeks to find h0 as a solution of
  *       (WRMS norm of (h0^2 ydd / 2)) = 1, 
@@ -1797,7 +1809,7 @@ static int CVInitialSetup(CVodeMem cv_mem)
  * Finally, we apply a bias (0.5) and verify that h0 is within bounds.
  */
 
-static int CVHin(CVodeMem cv_mem, realtype tout)
+static int cvHin(CVodeMem cv_mem, realtype tout)
 {
   int retval, sign, count1, count2;
   realtype tdiff, tdist, tround, hlb, hub;
@@ -1809,8 +1821,8 @@ static int CVHin(CVodeMem cv_mem, realtype tout)
   if ((tdiff = tout-tn) == ZERO) return(CV_TOO_CLOSE);
   
   sign = (tdiff > ZERO) ? 1 : -1;
-  tdist = ABS(tdiff);
-  tround = uround * MAX(ABS(tn), ABS(tout));
+  tdist = SUNRabs(tdiff);
+  tround = uround * SUNMAX(SUNRabs(tn), SUNRabs(tout));
 
   if (tdist < TWO*tround) return(CV_TOO_CLOSE);
   
@@ -1821,9 +1833,9 @@ static int CVHin(CVodeMem cv_mem, realtype tout)
   */
 
   hlb = HLB_FACTOR * tround;
-  hub = CVUpperBoundH0(cv_mem, tdist);
+  hub = cvUpperBoundH0(cv_mem, tdist);
 
-  hg  = RSqrt(hlb*hub);
+  hg  = SUNRsqrt(hlb*hub);
 
   if (hub < hlb) {
     if (sign == -1) h = -hg;
@@ -1844,7 +1856,7 @@ static int CVHin(CVodeMem cv_mem, realtype tout)
 
     for (count2 = 1; count2 <= MAX_ITERS; count2++) {
       hgs = hg*sign;
-      retval = CVYddNorm(cv_mem, hgs, &yddnrm);
+      retval = cvYddNorm(cv_mem, hgs, &yddnrm);
       /* If f() failed unrecoverably, give up */
       if (retval < 0) return(CV_RHSFUNC_FAIL);
       /* If successful, we can use ydd */
@@ -1871,7 +1883,7 @@ static int CVHin(CVodeMem cv_mem, realtype tout)
     if ( (hnewOK) || (count1 == MAX_ITERS))  {hnew = hg; break;}
 
     /* Propose new step size */
-    hnew = (yddnrm*hub*hub > TWO) ? RSqrt(TWO/yddnrm) : RSqrt(hg*hub);
+    hnew = (yddnrm*hub*hub > TWO) ? SUNRsqrt(TWO/yddnrm) : SUNRsqrt(hg*hub);
     hrat = hnew/hg;
     
     /* Accept hnew if it does not differ from hg by more than a factor of 2 */
@@ -1902,13 +1914,13 @@ static int CVHin(CVodeMem cv_mem, realtype tout)
 }
 
 /*
- * CVUpperBoundH0
+ * cvUpperBoundH0
  *
  * This routine sets an upper bound on abs(h0) based on
  * tdist = tn - t0 and the values of y[i]/y'[i].
  */
 
-static realtype CVUpperBoundH0(CVodeMem cv_mem, realtype tdist)
+static realtype cvUpperBoundH0(CVodeMem cv_mem, realtype tdist)
 {
   realtype hub_inv, hub;
   N_Vector temp1, temp2;
@@ -1947,13 +1959,13 @@ static realtype CVUpperBoundH0(CVodeMem cv_mem, realtype tdist)
 }
 
 /*
- * CVYddNorm
+ * cvYddNorm
  *
  * This routine computes an estimate of the second derivative of y
  * using a difference quotient, and returns its WRMS norm.
  */
 
-static int CVYddNorm(CVodeMem cv_mem, realtype hg, realtype *yddnrm)
+static int cvYddNorm(CVodeMem cv_mem, realtype hg, realtype *yddnrm)
 {
   int retval;
 
@@ -1972,7 +1984,7 @@ static int CVYddNorm(CVodeMem cv_mem, realtype hg, realtype *yddnrm)
 }
 
 /* 
- * CVStep
+ * cvStep
  *
  * This routine performs one internal cvode step, from tn to tn + h.
  * It calls other routines to do all the work.
@@ -1990,7 +2002,7 @@ static int CVYddNorm(CVodeMem cv_mem, realtype hg, realtype *yddnrm)
  * step may be reattempted, depending on the nature of the failure.
  */
 
-static int CVStep(CVodeMem cv_mem)
+static int cvStep(CVodeMem cv_mem)
 {
   realtype saved_t, dsm;
   int ncf, nef;
@@ -2000,16 +2012,16 @@ static int CVStep(CVodeMem cv_mem)
   ncf = nef = 0;
   nflag = FIRST_CALL;
 
-  if ((nst > 0) && (hprime != h)) CVAdjustParams(cv_mem);
+  if ((nst > 0) && (hprime != h)) cvAdjustParams(cv_mem);
   
   /* Looping point for attempts to take a step */
   loop {  
 
-    CVPredict(cv_mem);  
-    CVSet(cv_mem);
+    cvPredict(cv_mem);  
+    cvSet(cv_mem);
 
-    nflag = CVNls(cv_mem, nflag);
-    kflag = CVHandleNFlag(cv_mem, &nflag, saved_t, &ncf);
+    nflag = cvNls(cv_mem, nflag);
+    kflag = cvHandleNFlag(cv_mem, &nflag, saved_t, &ncf);
 
     /* Go back in loop if we need to predict again (nflag=PREV_CONV_FAIL)*/
     if (kflag == PREDICT_AGAIN) continue;
@@ -2018,7 +2030,7 @@ static int CVStep(CVodeMem cv_mem)
     if (kflag != DO_ERROR_TEST) return(kflag);
 
     /* Perform error test (nflag=CV_SUCCESS) */
-    eflag = CVDoErrorTest(cv_mem, &nflag, saved_t, &nef, &dsm);
+    eflag = cvDoErrorTest(cv_mem, &nflag, saved_t, &nef, &dsm);
 
     /* Go back in loop if we need to predict again (nflag=PREV_ERR_FAIL) */
     if (eflag == TRY_AGAIN)  continue;
@@ -2034,14 +2046,14 @@ static int CVStep(CVodeMem cv_mem)
   /* Nonlinear system solve and error test were both successful.
      Update data, and consider change of step and/or order.       */
 
-  CVCompleteStep(cv_mem); 
+  cvCompleteStep(cv_mem); 
 
-  CVPrepareNextStep(cv_mem, dsm); 
+  cvPrepareNextStep(cv_mem, dsm); 
 
   /* If Stablilty Limit Detection is turned on, call stability limit
      detection routine for possible order reduction. */
 
-  if (sldeton) CVBDFStab(cv_mem);
+  if (sldeton) cvBDFStab(cv_mem);
 
   etamax = (nst <= SMALL_NST) ? ETAMX2 : ETAMX3;
 
@@ -2054,58 +2066,58 @@ static int CVStep(CVodeMem cv_mem)
 }
 
 /*
- * CVAdjustParams
+ * cvAdjustParams
  *
  * This routine is called when a change in step size was decided upon,
  * and it handles the required adjustments to the history array zn.
- * If there is to be a change in order, we call CVAdjustOrder and reset
- * q, L = q+1, and qwait.  Then in any case, we call CVRescale, which
+ * If there is to be a change in order, we call cvAdjustOrder and reset
+ * q, L = q+1, and qwait.  Then in any case, we call cvRescale, which
  * resets h and rescales the Nordsieck array.
  */
 
-static void CVAdjustParams(CVodeMem cv_mem)
+static void cvAdjustParams(CVodeMem cv_mem)
 {
   if (qprime != q) {
-    CVAdjustOrder(cv_mem, qprime-q);
+    cvAdjustOrder(cv_mem, qprime-q);
     q = qprime;
     L = q+1;
     qwait = L;
   }
-  CVRescale(cv_mem);
+  cvRescale(cv_mem);
 }
 
 /*
- * CVAdjustOrder
+ * cvAdjustOrder
  *
  * This routine is a high level routine which handles an order
  * change by an amount deltaq (= +1 or -1). If a decrease in order
  * is requested and q==2, then the routine returns immediately.
- * Otherwise CVAdjustAdams or CVAdjustBDF is called to handle the
+ * Otherwise cvAdjustAdams or cvAdjustBDF is called to handle the
  * order change (depending on the value of lmm).
  */
 
-static void CVAdjustOrder(CVodeMem cv_mem, int deltaq)
+static void cvAdjustOrder(CVodeMem cv_mem, int deltaq)
 {
   if ((q==2) && (deltaq != 1)) return;
   
   switch(lmm){
   case CV_ADAMS: 
-    CVAdjustAdams(cv_mem, deltaq);
+    cvAdjustAdams(cv_mem, deltaq);
     break;
   case CV_BDF:   
-    CVAdjustBDF(cv_mem, deltaq);
+    cvAdjustBDF(cv_mem, deltaq);
     break;
   }
 }
 
 /*
- * CVAdjustAdams
+ * cvAdjustAdams
  *
  * This routine adjusts the history array on a change of order q by
  * deltaq, in the case that lmm == CV_ADAMS.
  */
 
-static void CVAdjustAdams(CVodeMem cv_mem, int deltaq)
+static void cvAdjustAdams(CVodeMem cv_mem, int deltaq)
 {
   int i, j;
   realtype xi, hsum;
@@ -2142,28 +2154,28 @@ static void CVAdjustAdams(CVodeMem cv_mem, int deltaq)
 }
 
 /*
- * CVAdjustBDF
+ * cvAdjustBDF
  *
  * This is a high level routine which handles adjustments to the
  * history array on a change of order by deltaq in the case that 
- * lmm == CV_BDF.  CVAdjustBDF calls CVIncreaseBDF if deltaq = +1 and 
- * CVDecreaseBDF if deltaq = -1 to do the actual work.
+ * lmm == CV_BDF.  cvAdjustBDF calls cvIncreaseBDF if deltaq = +1 and 
+ * cvDecreaseBDF if deltaq = -1 to do the actual work.
  */
 
-static void CVAdjustBDF(CVodeMem cv_mem, int deltaq)
+static void cvAdjustBDF(CVodeMem cv_mem, int deltaq)
 {
   switch(deltaq) {
-  case 1 : 
-    CVIncreaseBDF(cv_mem);
+  case 1: 
+    cvIncreaseBDF(cv_mem);
     return;
   case -1: 
-    CVDecreaseBDF(cv_mem);
+    cvDecreaseBDF(cv_mem);
     return;
   }
 }
 
 /*
- * CVIncreaseBDF
+ * cvIncreaseBDF
  *
  * This routine adjusts the history array on an increase in the 
  * order q in the case that lmm == CV_BDF.  
@@ -2174,7 +2186,7 @@ static void CVAdjustBDF(CVodeMem cv_mem, int deltaq)
  * where xi_j = [t_n - t_(n-j)]/h.
  */
 
-static void CVIncreaseBDF(CVodeMem cv_mem)
+static void cvIncreaseBDF(CVodeMem cv_mem)
 {
   realtype alpha0, alpha1, prod, xi, xiold, hsum, A1;
   int i, j;
@@ -2196,13 +2208,12 @@ static void CVIncreaseBDF(CVodeMem cv_mem)
   }
   A1 = (-alpha0 - alpha1) / prod;
   N_VScale(A1, zn[indx_acor], zn[L]);
-  for (j=2; j <= q; j++) {
+  for (j=2; j <= q; j++)
     N_VLinearSum(l[j], zn[L], ONE, zn[j], zn[j]);
-  }  
 }
 
 /*
- * CVDecreaseBDF
+ * cvDecreaseBDF
  *
  * This routine adjusts the history array on a decrease in the 
  * order q in the case that lmm == CV_BDF.  
@@ -2211,7 +2222,7 @@ static void CVIncreaseBDF(CVodeMem cv_mem)
  *   x*x*(x+xi_1)*...*(x+xi_j), where xi_j = [t_n - t_(n-j)]/h.
  */
 
-static void CVDecreaseBDF(CVodeMem cv_mem)
+static void cvDecreaseBDF(CVodeMem cv_mem)
 {
   realtype hsum, xi;
   int i, j;
@@ -2219,25 +2230,25 @@ static void CVDecreaseBDF(CVodeMem cv_mem)
   for (i=0; i <= qmax; i++) l[i] = ZERO;
   l[2] = ONE;
   hsum = ZERO;
-  for(j=1; j <= q-2; j++) {
+  for (j=1; j <= q-2; j++) {
     hsum += tau[j];
     xi = hsum /hscale;
     for (i=j+2; i >= 2; i--) l[i] = l[i]*xi + l[i-1];
   }
   
-  for(j=2; j < q; j++)
+  for (j=2; j < q; j++)
     N_VLinearSum(-l[j], zn[q], ONE, zn[j], zn[j]);
 }
 
 /*
- * CVRescale
+ * cvRescale
  *
  * This routine rescales the Nordsieck array by multiplying the
  * jth column zn[j] by eta^j, j = 1, ..., q.  Then the value of
  * h is rescaled by eta, and hscale is reset to h.
  */
 
-static void CVRescale(CVodeMem cv_mem)
+static void cvRescale(CVodeMem cv_mem)
 {
   int j;
   realtype factor;
@@ -2254,7 +2265,7 @@ static void CVRescale(CVodeMem cv_mem)
 }
 
 /*
- * CVPredict
+ * cvPredict
  *
  * This routine advances tn by the tentative step size h, and computes
  * the predicted array z_n(0), which is overwritten on zn.  The
@@ -2263,7 +2274,7 @@ static void CVRescale(CVodeMem cv_mem)
  * and in that case, we reset tn (after incrementing by h) to tstop.
  */
 
-static void CVPredict(CVodeMem cv_mem)
+static void cvPredict(CVodeMem cv_mem)
 {
   int j, k;
   
@@ -2277,10 +2288,10 @@ static void CVPredict(CVodeMem cv_mem)
 }
 
 /*
- * CVSet
+ * cvSet
  *
- * This routine is a high level routine which calls CVSetAdams or
- * CVSetBDF to set the polynomial l, the test quantity array tq, 
+ * This routine is a high level routine which calls cvSetAdams or
+ * cvSetBDF to set the polynomial l, the test quantity array tq, 
  * and the related variables  rl1, gamma, and gamrat.
  *
  * The array tq is loaded with constants used in the control of estimated
@@ -2294,14 +2305,14 @@ static void CVPredict(CVodeMem cv_mem)
  *           the est. local error at order q+1
  */
 
-static void CVSet(CVodeMem cv_mem)
+static void cvSet(CVodeMem cv_mem)
 {
   switch(lmm) {
   case CV_ADAMS: 
-    CVSetAdams(cv_mem);
+    cvSetAdams(cv_mem);
     break;
   case CV_BDF:
-    CVSetBDF(cv_mem);
+    cvSetBDF(cv_mem);
     break;
   }
   rl1 = ONE / l[1];
@@ -2311,7 +2322,7 @@ static void CVSet(CVodeMem cv_mem)
 }
 
 /*
- * CVSetAdams
+ * cvSetAdams
  *
  * This routine handles the computation of l and tq for the
  * case lmm == CV_ADAMS.
@@ -2328,7 +2339,7 @@ static void CVSet(CVodeMem cv_mem)
  * test, the error test, and the selection of h at a new order.
  */
 
-static void CVSetAdams(CVodeMem cv_mem)
+static void cvSetAdams(CVodeMem cv_mem)
 {
   realtype m[L_MAX], M[3], hsum;
   
@@ -2340,22 +2351,22 @@ static void CVSetAdams(CVodeMem cv_mem)
     return;
   }
   
-  hsum = CVAdamsStart(cv_mem, m);
+  hsum = cvAdamsStart(cv_mem, m);
   
-  M[0] = CVAltSum(q-1, m, 1);
-  M[1] = CVAltSum(q-1, m, 2);
+  M[0] = cvAltSum(q-1, m, 1);
+  M[1] = cvAltSum(q-1, m, 2);
   
-  CVAdamsFinish(cv_mem, m, M, hsum);
+  cvAdamsFinish(cv_mem, m, M, hsum);
 }
 
 /*
- * CVAdamsStart
+ * cvAdamsStart
  *
  * This routine generates in m[] the coefficients of the product
  * polynomial needed for the Adams l and tq coefficients for q > 1.
  */
 
-static realtype CVAdamsStart(CVodeMem cv_mem, realtype m[])
+static realtype cvAdamsStart(CVodeMem cv_mem, realtype m[])
 {
   realtype hsum, xi_inv, sum;
   int i, j;
@@ -2365,7 +2376,7 @@ static realtype CVAdamsStart(CVodeMem cv_mem, realtype m[])
   for (i=1; i <= q; i++) m[i] = ZERO;
   for (j=1; j < q; j++) {
     if ((j==q-1) && (qwait == 1)) {
-      sum = CVAltSum(q-2, m, 2);
+      sum = cvAltSum(q-2, m, 2);
       tq[1] = q * sum / m[q-2];
     }
     xi_inv = h / hsum;
@@ -2377,12 +2388,12 @@ static realtype CVAdamsStart(CVodeMem cv_mem, realtype m[])
 }
 
 /*
- * CVAdamsFinish
+ * cvAdamsFinish
  *
  * This routine completes the calculation of the Adams l and tq.
  */
 
-static void CVAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype hsum)
+static void cvAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype hsum)
 {
   int i;
   realtype M0_inv, xi, xi_inv;
@@ -2399,7 +2410,7 @@ static void CVAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype
 
   if (qwait == 1) {
     for (i=q; i >= 1; i--) m[i] += m[i-1] * xi_inv;
-    M[2] = CVAltSum(q, m, 2);
+    M[2] = cvAltSum(q, m, 2);
     tq[3] = M[2] * M0_inv / L;
   }
 
@@ -2407,16 +2418,16 @@ static void CVAdamsFinish(CVodeMem cv_mem, realtype m[], realtype M[], realtype
 }
 
 /*  
- * CVAltSum
+ * cvAltSum
  *
- * CVAltSum returns the value of the alternating sum
+ * cvAltSum returns the value of the alternating sum
  *   sum (i= 0 ... iend) [ (-1)^i * (a[i] / (i + k)) ].
- * If iend < 0 then CVAltSum returns 0.
+ * If iend < 0 then cvAltSum returns 0.
  * This operation is needed to compute the integral, from -1 to 0,
  * of a polynomial x^(k-1) M(x) given the coefficients of M(x).
  */
 
-static realtype CVAltSum(int iend, realtype a[], int k)
+static realtype cvAltSum(int iend, realtype a[], int k)
 {
   int i, sign;
   realtype sum;
@@ -2433,10 +2444,10 @@ static realtype CVAltSum(int iend, realtype a[], int k)
 }
 
 /*
- * CVSetBDF
+ * cvSetBDF
  *
  * This routine computes the coefficients l and tq in the case
- * lmm == CV_BDF.  CVSetBDF calls CVSetTqBDF to set the test
+ * lmm == CV_BDF.  cvSetBDF calls cvSetTqBDF to set the test
  * quantity array tq. 
  * 
  * The components of the array l are the coefficients of a
@@ -2450,7 +2461,7 @@ static realtype CVAltSum(int iend, realtype a[], int k)
  * test, the error test, and the selection of h at a new order.
  */
 
-static void CVSetBDF(CVodeMem cv_mem)
+static void cvSetBDF(CVodeMem cv_mem)
 {
   realtype alpha0, alpha0_hat, xi_inv, xistar_inv, hsum;
   int i,j;
@@ -2464,7 +2475,7 @@ static void CVSetBDF(CVodeMem cv_mem)
       hsum += tau[j-1];
       xi_inv = h / hsum;
       alpha0 -= ONE / j;
-      for(i=j; i >= 1; i--) l[i] += l[i-1]*xi_inv;
+      for (i=j; i >= 1; i--) l[i] += l[i-1]*xi_inv;
       /* The l[i] are coefficients of product(1 to j) (1 + x/xi_i) */
     }
     
@@ -2477,17 +2488,17 @@ static void CVSetBDF(CVodeMem cv_mem)
     for (i=q; i >= 1; i--) l[i] += l[i-1]*xistar_inv;
   }
 
-  CVSetTqBDF(cv_mem, hsum, alpha0, alpha0_hat, xi_inv, xistar_inv);
+  cvSetTqBDF(cv_mem, hsum, alpha0, alpha0_hat, xi_inv, xistar_inv);
 }
 
 /*
- * CVSetTqBDF
+ * cvSetTqBDF
  *
  * This routine sets the test quantity array tq in the case
  * lmm == CV_BDF.
  */
 
-static void CVSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
+static void cvSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
                        realtype alpha0_hat, realtype xi_inv, realtype xistar_inv)
 {
   realtype A1, A2, A3, A4, A5, A6;
@@ -2495,15 +2506,15 @@ static void CVSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
   
   A1 = ONE - alpha0_hat + alpha0;
   A2 = ONE + q * A1;
-  tq[2] = ABS(A1 / (alpha0 * A2));
-  tq[5] = ABS(A2 * xistar_inv / (l[q] * xi_inv));
+  tq[2] = SUNRabs(A1 / (alpha0 * A2));
+  tq[5] = SUNRabs(A2 * xistar_inv / (l[q] * xi_inv));
   if (qwait == 1) {
     if (q > 1) {
       C = xistar_inv / l[q];
       A3 = alpha0 + ONE / q;
       A4 = alpha0_hat + xi_inv;
       Cpinv = (ONE - A4 + A3) / A3;
-      tq[1] = ABS(C * Cpinv);
+      tq[1] = SUNRabs(C * Cpinv);
     }
     else tq[1] = ONE;
     hsum += tau[q];
@@ -2511,30 +2522,30 @@ static void CVSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
     A5 = alpha0 - (ONE / (q+1));
     A6 = alpha0_hat - xi_inv;
     Cppinv = (ONE - A6 + A5) / A2;
-    tq[3] = ABS(Cppinv / (xi_inv * (q+2) * A5));
+    tq[3] = SUNRabs(Cppinv / (xi_inv * (q+2) * A5));
   }
   tq[4] = nlscoef / tq[2];
 }
 
 /*
- * CVNls
+ * cvNls
  *
  * This routine attempts to solve the nonlinear system associated
  * with a single implicit step of the linear multistep method.
- * Depending on iter, it calls CVNlsFunctional or CVNlsNewton
+ * Depending on iter, it calls cvNlsFunctional or cvNlsNewton
  * to do the work.
  */
 
-static int CVNls(CVodeMem cv_mem, int nflag)
+static int cvNls(CVodeMem cv_mem, int nflag)
 {
   int flag = CV_SUCCESS;
 
   switch(iter) {
   case CV_FUNCTIONAL: 
-    flag = CVNlsFunctional(cv_mem);
+    flag = cvNlsFunctional(cv_mem);
     break;
   case CV_NEWTON:
-    flag = CVNlsNewton(cv_mem, nflag);
+    flag = cvNlsNewton(cv_mem, nflag);
     break;
   }
 
@@ -2542,7 +2553,7 @@ static int CVNls(CVodeMem cv_mem, int nflag)
 }
 
 /*
- * CVNlsFunctional
+ * cvNlsFunctional
  *
  * This routine attempts to solve the nonlinear system using 
  * functional iteration (no matrices involved).
@@ -2558,7 +2569,7 @@ static int CVNls(CVodeMem cv_mem, int nflag)
  *
  */
 
-static int CVNlsFunctional(CVodeMem cv_mem)
+static int cvNlsFunctional(CVodeMem cv_mem)
 {
   int retval, m;
   realtype del, delp, dcon;
@@ -2595,8 +2606,8 @@ static int CVNlsFunctional(CVodeMem cv_mem)
     
     /* Test for convergence.  If m > 0, an estimate of the convergence
        rate constant is stored in crate, and used in the test.        */
-    if (m > 0) crate = MAX(CRDOWN * crate, del / delp);
-    dcon = del * MIN(ONE, crate) / tq[4];
+    if (m > 0) crate = SUNMAX(CRDOWN * crate, del / delp);
+    dcon = del * SUNMIN(ONE, crate) / tq[4];
     if (dcon <= ONE) {
       acnrm = (m == 0) ? del : N_VWrmsNorm(acor, ewt);
       return(CV_SUCCESS);  /* Convergence achieved */
@@ -2618,10 +2629,10 @@ static int CVNlsFunctional(CVodeMem cv_mem)
 }
 
 /*
- * CVNlsNewton
+ * cvNlsNewton
  *
  * This routine handles the Newton iteration. It calls lsetup if 
- * indicated, calls CVNewtonIteration to perform the iteration, and 
+ * indicated, calls cvNewtonIteration to perform the iteration, and 
  * retries a failed attempt at Newton iteration if that is indicated.
  *
  * Possible return values:
@@ -2637,7 +2648,7 @@ static int CVNlsFunctional(CVodeMem cv_mem)
  *
  */
 
-static int CVNlsNewton(CVodeMem cv_mem, int nflag)
+static int cvNlsNewton(CVodeMem cv_mem, int nflag)
 {
   N_Vector vtemp1, vtemp2, vtemp3;
   int convfail, retval, ier;
@@ -2654,7 +2665,7 @@ static int CVNlsNewton(CVodeMem cv_mem, int nflag)
   /* Decide whether or not to call setup routine (if one exists) */
   if (setupNonNull) {      
     callSetup = (nflag == PREV_CONV_FAIL) || (nflag == PREV_ERR_FAIL) ||
-      (nst == 0) || (nst >= nstlp + MSBP) || (ABS(gamrat-ONE) > DGMAX);
+      (nst == 0) || (nst >= nstlp + MSBP) || (SUNRabs(gamrat-ONE) > DGMAX);
   } else {  
     crate = ONE;
     callSetup = FALSE;
@@ -2662,8 +2673,9 @@ static int CVNlsNewton(CVodeMem cv_mem, int nflag)
   
   /* Looping point for the solution of the nonlinear system.
      Evaluate f at the predicted y, call lsetup if indicated, and
-     call CVNewtonIteration for the Newton iteration itself.      */
+     call cvNewtonIteration for the Newton iteration itself.      */
   
+
   loop {
 
     retval = f(tn, zn[0], ftemp, user_data);
@@ -2689,7 +2701,7 @@ static int CVNlsNewton(CVodeMem cv_mem, int nflag)
     N_VScale(ONE, zn[0], y);
 
     /* Do the Newton iteration */
-    ier = CVNewtonIteration(cv_mem);
+    ier = cvNewtonIteration(cv_mem);
 
     /* If there is a convergence failure and the Jacobian-related 
        data appears not to be current, loop again with a call to lsetup
@@ -2702,19 +2714,19 @@ static int CVNlsNewton(CVodeMem cv_mem, int nflag)
 }
 
 /*
- * CVNewtonIteration
+ * cvNewtonIteration
  *
  * This routine performs the Newton iteration. If the iteration succeeds,
- * it returns the value CV_SUCCESS. If not, it may signal the CVNlsNewton 
+ * it returns the value CV_SUCCESS. If not, it may signal the cvNlsNewton 
  * routine to call lsetup again and reattempt the iteration, by
- * returning the value TRY_AGAIN. (In this case, CVNlsNewton must set 
+ * returning the value TRY_AGAIN. (In this case, cvNlsNewton must set 
  * convfail to CV_FAIL_BAD_J before calling setup again). 
  * Otherwise, this routine returns one of the appropriate values 
  * CV_LSOLVE_FAIL, CV_RHSFUNC_FAIL, CONV_FAIL, or RHSFUNC_RECVR back 
- * to CVNlsNewton.
+ * to cvNlsNewton.
  */
 
-static int CVNewtonIteration(CVodeMem cv_mem)
+static int cvNewtonIteration(CVodeMem cv_mem)
 {
   int m, retval;
   realtype del, delp, dcon;
@@ -2728,7 +2740,7 @@ static int CVNewtonIteration(CVodeMem cv_mem)
   /* Looping point for Newton iteration */
   loop {
 
-    /* Evaluate the residual of the nonlinear system*/
+    /* Evaluate the residual of the nonlinear system */
     N_VLinearSum(rl1, zn[1], ONE, acor, tempv);
     N_VLinearSum(gamma, ftemp, -ONE, tempv, tempv);
 
@@ -2754,9 +2766,9 @@ static int CVNewtonIteration(CVodeMem cv_mem)
     /* Test for convergence.  If m > 0, an estimate of the convergence
        rate constant is stored in crate, and used in the test.        */
     if (m > 0) {
-      crate = MAX(CRDOWN * crate, del/delp);
+      crate = SUNMAX(CRDOWN * crate, del/delp);
     }
-    dcon = del * MIN(ONE, crate) / tq[4];
+    dcon = del * SUNMIN(ONE, crate) / tq[4];
     
     if (dcon <= ONE) {
       acnrm = (m==0) ? del : N_VWrmsNorm(acor, ewt);
@@ -2788,13 +2800,13 @@ static int CVNewtonIteration(CVodeMem cv_mem)
 }
 
 /*
- * CVHandleFlag
+ * cvHandleNFlag
  *
  * This routine takes action on the return value nflag = *nflagPtr
- * returned by CVNls, as follows:
+ * returned by cvNls, as follows:
  *
- * If CVNls succeeded in solving the nonlinear system, then
- * CVHandleNFlag returns the constant DO_ERROR_TEST, which tells CVStep
+ * If cvNls succeeded in solving the nonlinear system, then
+ * cvHandleNFlag returns the constant DO_ERROR_TEST, which tells cvStep
  * to perform the error test.
  *
  * If the nonlinear system was not solved successfully, then ncfn and
@@ -2810,16 +2822,16 @@ static int CVNewtonIteration(CVodeMem cv_mem)
  * the value CV_RHSFUNC_FAIL.
  *
  * Otherwise, a recoverable failure occurred when solving the 
- * nonlinear system (CVNls returned nflag == CONV_FAIL or RHSFUNC_RECVR). 
+ * nonlinear system (cvNls returned nflag == CONV_FAIL or RHSFUNC_RECVR). 
  * In this case, if ncf is now equal to maxncf or |h| = hmin, 
  * we return the value CV_CONV_FAILURE (if nflag=CONV_FAIL) or
  * CV_REPTD_RHSFUNC_ERR (if nflag=RHSFUNC_RECVR).
  * If not, we set *nflagPtr = PREV_CONV_FAIL and return the value
- * PREDICT_AGAIN, telling CVStep to reattempt the step.
+ * PREDICT_AGAIN, telling cvStep to reattempt the step.
  *
  */
 
-static int CVHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
+static int cvHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
                          int *ncfPtr)
 {
   int nflag;
@@ -2830,7 +2842,7 @@ static int CVHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
 
   /* The nonlinear soln. failed; increment ncfn and restore zn */
   ncfn++;
-  CVRestore(cv_mem, saved_t);
+  cvRestore(cv_mem, saved_t);
   
   /* Return if lsetup, lsolve, or rhs failed unrecoverably */
   if (nflag == CV_LSETUP_FAIL)  return(CV_LSETUP_FAIL);
@@ -2845,29 +2857,29 @@ static int CVHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
   /* If we had maxncf failures or |h| = hmin, 
      return CV_CONV_FAILURE or CV_REPTD_RHSFUNC_ERR. */
 
-  if ((ABS(h) <= hmin*ONEPSM) || (*ncfPtr == maxncf)) {
+  if ((SUNRabs(h) <= hmin*ONEPSM) || (*ncfPtr == maxncf)) {
     if (nflag == CONV_FAIL)     return(CV_CONV_FAILURE);
     if (nflag == RHSFUNC_RECVR) return(CV_REPTD_RHSFUNC_ERR);    
   }
 
   /* Reduce step size; return to reattempt the step */
 
-  eta = MAX(ETACF, hmin / ABS(h));
+  eta = SUNMAX(ETACF, hmin / SUNRabs(h));
   *nflagPtr = PREV_CONV_FAIL;
-  CVRescale(cv_mem);
+  cvRescale(cv_mem);
 
   return(PREDICT_AGAIN);
 }
 
 /*
- * CVRestore
+ * cvRestore
  *
  * This routine restores the value of tn to saved_t and undoes the
- * prediction.  After execution of CVRestore, the Nordsieck array zn has
- * the same values as before the call to CVPredict.
+ * prediction.  After execution of cvRestore, the Nordsieck array zn has
+ * the same values as before the call to cvPredict.
  */
 
-static void CVRestore(CVodeMem cv_mem, realtype saved_t)
+static void cvRestore(CVodeMem cv_mem, realtype saved_t)
 {
   int j, k;
   
@@ -2878,17 +2890,17 @@ static void CVRestore(CVodeMem cv_mem, realtype saved_t)
 }
 
 /*
- * CVDoErrorTest
+ * cvDoErrorTest
  *
  * This routine performs the local error test. 
  * The weighted local error norm dsm is loaded into *dsmPtr, and 
  * the test dsm ?<= 1 is made.
  *
- * If the test passes, CVDoErrorTest returns CV_SUCCESS. 
+ * If the test passes, cvDoErrorTest returns CV_SUCCESS. 
  *
- * If the test fails, we undo the step just taken (call CVRestore) and 
+ * If the test fails, we undo the step just taken (call cvRestore) and 
  *
- *   - if maxnef error test failures have occurred or if ABS(h) = hmin,
+ *   - if maxnef error test failures have occurred or if SUNRabs(h) = hmin,
  *     we return CV_ERR_FAILURE.
  *
  *   - if more than MXNEF1 error test failures have occurred, an order
@@ -2900,7 +2912,7 @@ static void CVRestore(CVodeMem cv_mem, realtype saved_t)
  *
  */
 
-static booleantype CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr,
+static booleantype cvDoErrorTest(CVodeMem cv_mem, int *nflagPtr,
                                 realtype saved_t, int *nefPtr, realtype *dsmPtr)
 {
   realtype dsm;
@@ -2916,37 +2928,37 @@ static booleantype CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr,
   (*nefPtr)++;
   netf++;
   *nflagPtr = PREV_ERR_FAIL;
-  CVRestore(cv_mem, saved_t);
+  cvRestore(cv_mem, saved_t);
 
   /* At maxnef failures or |h| = hmin, return CV_ERR_FAILURE */
-  if ((ABS(h) <= hmin*ONEPSM) || (*nefPtr == maxnef)) return(CV_ERR_FAILURE);
+  if ((SUNRabs(h) <= hmin*ONEPSM) || (*nefPtr == maxnef)) return(CV_ERR_FAILURE);
 
   /* Set etamax = 1 to prevent step size increase at end of this step */
   etamax = ONE;
 
   /* Set h ratio eta from dsm, rescale, and return for retry of step */
   if (*nefPtr <= MXNEF1) {
-    eta = ONE / (RPowerR(BIAS2*dsm,ONE/L) + ADDON);
-    eta = MAX(ETAMIN, MAX(eta, hmin / ABS(h)));
-    if (*nefPtr >= SMALL_NEF) eta = MIN(eta, ETAMXF);
-    CVRescale(cv_mem);
+    eta = ONE / (SUNRpowerR(BIAS2*dsm,ONE/L) + ADDON);
+    eta = SUNMAX(ETAMIN, SUNMAX(eta, hmin / SUNRabs(h)));
+    if (*nefPtr >= SMALL_NEF) eta = SUNMIN(eta, ETAMXF);
+    cvRescale(cv_mem);
     return(TRY_AGAIN);
   }
   
   /* After MXNEF1 failures, force an order reduction and retry step */
   if (q > 1) {
-    eta = MAX(ETAMIN, hmin / ABS(h));
-    CVAdjustOrder(cv_mem,-1);
+    eta = SUNMAX(ETAMIN, hmin / SUNRabs(h));
+    cvAdjustOrder(cv_mem,-1);
     L = q;
     q--;
     qwait = L;
-    CVRescale(cv_mem);
+    cvRescale(cv_mem);
     return(TRY_AGAIN);
   }
 
   /* If already at order 1, restart: reload zn from scratch */
 
-  eta = MAX(ETAMIN, hmin / ABS(h));
+  eta = SUNMAX(ETAMIN, hmin / SUNRabs(h));
   h *= eta;
   next_h = h;
   hscale = h;
@@ -2964,13 +2976,13 @@ static booleantype CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr,
 }
 
 /* 
- * =================================================================
- *  Private Functions Implementation after succesful step
- * =================================================================
+ * -----------------------------------------------------------------
+ * Functions called after succesful step
+ * -----------------------------------------------------------------
  */
 
 /*
- * CVCompleteStep
+ * cvCompleteStep
  *
  * This routine performs various update operations when the solution
  * to the nonlinear system has passed the local error test. 
@@ -2981,7 +2993,7 @@ static booleantype CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr,
  * we save acor and tq[5] for a possible order increase.
  */
 
-static void CVCompleteStep(CVodeMem cv_mem)
+static void cvCompleteStep(CVodeMem cv_mem)
 {
   int i, j;
   
@@ -2994,6 +3006,7 @@ static void CVCompleteStep(CVodeMem cv_mem)
   if ((q==1) && (nst > 1)) tau[2] = tau[1];
   tau[1] = h;
 
+  /* Apply correction to column j of zn: l_j * Delta_n */
   for (j=0; j <= q; j++) 
     N_VLinearSum(l[j], acor, ONE, zn[j], zn[j]);
   qwait--;
@@ -3005,7 +3018,7 @@ static void CVCompleteStep(CVodeMem cv_mem)
 }
 
 /*
- * CVprepareNextStep
+ * cvPrepareNextStep
  *
  * This routine handles the setting of stepsize and order for the
  * next step -- hprime and qprime.  Along with hprime, it sets the
@@ -3013,11 +3026,11 @@ static void CVCompleteStep(CVodeMem cv_mem)
  * related to a change of step size or order. 
  */
 
- static void CVPrepareNextStep(CVodeMem cv_mem, realtype dsm)
+static void cvPrepareNextStep(CVodeMem cv_mem, realtype dsm)
 {
   /* If etamax = 1, defer step size or order changes */
   if (etamax == ONE) {
-    qwait = MAX(qwait, 2);
+    qwait = SUNMAX(qwait, 2);
     qprime = q;
     hprime = h;
     eta = ONE;
@@ -3025,35 +3038,34 @@ static void CVCompleteStep(CVodeMem cv_mem)
   }
 
   /* etaq is the ratio of new to old h at the current order */  
-  etaq = ONE /(RPowerR(BIAS2*dsm,ONE/L) + ADDON);
+  etaq = ONE /(SUNRpowerR(BIAS2*dsm,ONE/L) + ADDON);
   
-  /* If no order change, adjust eta and acor in CVSetEta and return */
+  /* If no order change, adjust eta and acor in cvSetEta and return */
   if (qwait != 0) {
     eta = etaq;
     qprime = q;
-    CVSetEta(cv_mem);
+    cvSetEta(cv_mem);
     return;
   }
   
   /* If qwait = 0, consider an order change.   etaqm1 and etaqp1 are 
      the ratios of new to old h at orders q-1 and q+1, respectively.
-     CVChooseEta selects the largest; CVSetEta adjusts eta and acor */
+     cvChooseEta selects the largest; cvSetEta adjusts eta and acor */
   qwait = 2;
-  etaqm1 = CVComputeEtaqm1(cv_mem);
-  etaqp1 = CVComputeEtaqp1(cv_mem);  
-  CVChooseEta(cv_mem); 
-  CVSetEta(cv_mem);
+  etaqm1 = cvComputeEtaqm1(cv_mem);
+  etaqp1 = cvComputeEtaqp1(cv_mem);  
+  cvChooseEta(cv_mem); 
+  cvSetEta(cv_mem);
 }
 
 /*
- * CVsetEta
+ * cvSetEta
  *
  * This routine adjusts the value of eta according to the various
- * heuristic limits and the optional input hmax.  It also resets
- * etamax to be the estimated local error vector.
+ * heuristic limits and the optional input hmax.
  */
 
-static void CVSetEta(CVodeMem cv_mem)
+static void cvSetEta(CVodeMem cv_mem)
 {
 
   /* If eta below the threshhold THRESH, reject a change of step size */
@@ -3062,58 +3074,56 @@ static void CVSetEta(CVodeMem cv_mem)
     hprime = h;
   } else {
     /* Limit eta by etamax and hmax, then set hprime */
-    eta = MIN(eta, etamax);
-    eta /= MAX(ONE, ABS(h)*hmax_inv*eta);
+    eta = SUNMIN(eta, etamax);
+    eta /= SUNMAX(ONE, SUNRabs(h)*hmax_inv*eta);
     hprime = h * eta;
     if (qprime < q) nscon = 0;
   }
-  
-  /* Reset etamax for the next step size change, and scale acor */
 }
 
 /*
- * CVComputeEtaqm1
+ * cvComputeEtaqm1
  *
  * This routine computes and returns the value of etaqm1 for a
  * possible decrease in order by 1.
  */
 
-static realtype CVComputeEtaqm1(CVodeMem cv_mem)
+static realtype cvComputeEtaqm1(CVodeMem cv_mem)
 {
   realtype ddn;
   
   etaqm1 = ZERO;
   if (q > 1) {
     ddn = N_VWrmsNorm(zn[q], ewt) * tq[1];
-    etaqm1 = ONE/(RPowerR(BIAS1*ddn, ONE/q) + ADDON);
+    etaqm1 = ONE/(SUNRpowerR(BIAS1*ddn, ONE/q) + ADDON);
   }
   return(etaqm1);
 }
 
 /*
- * CVComputeEtaqp1
+ * cvComputeEtaqp1
  *
  * This routine computes and returns the value of etaqp1 for a
  * possible increase in order by 1.
  */
 
-static realtype CVComputeEtaqp1(CVodeMem cv_mem)
+static realtype cvComputeEtaqp1(CVodeMem cv_mem)
 {
   realtype dup, cquot;
   
   etaqp1 = ZERO;
   if (q != qmax) {
     if (saved_tq5 == ZERO) return(etaqp1);
-    cquot = (tq[5] / saved_tq5) * RPowerI(h/tau[2], L);
+    cquot = (tq[5] / saved_tq5) * SUNRpowerI(h/tau[2], L);
     N_VLinearSum(-cquot, zn[qmax], ONE, acor, tempv);
     dup = N_VWrmsNorm(tempv, ewt) * tq[3];
-    etaqp1 = ONE / (RPowerR(BIAS3*dup, ONE/(L+1)) + ADDON);
+    etaqp1 = ONE / (SUNRpowerR(BIAS3*dup, ONE/(L+1)) + ADDON);
   }
   return(etaqp1);
 }
 
 /*
- * CVChooseEta
+ * cvChooseEta
  * Given etaqm1, etaq, etaqp1 (the values of eta for qprime =
  * q - 1, q, or q + 1, respectively), this routine chooses the 
  * maximum eta value, sets eta to that value, and sets qprime to the
@@ -3124,11 +3134,11 @@ static realtype CVComputeEtaqp1(CVodeMem cv_mem)
  * eta is set to 1.
  */
 
-static void CVChooseEta(CVodeMem cv_mem)
+static void cvChooseEta(CVodeMem cv_mem)
 {
   realtype etam;
   
-  etam = MAX(etaqm1, MAX(etaq, etaqp1));
+  etam = SUNMAX(etaqm1, SUNMAX(etaq, etaqp1));
   
   if (etam < THRESH) {
     eta = ONE;
@@ -3152,7 +3162,6 @@ static void CVChooseEta(CVodeMem cv_mem)
     qprime = q + 1;
 
     if (lmm == CV_BDF) {
-
       /* 
        * Store Delta_n in zn[qmax] to be used in order increase 
        *
@@ -3163,20 +3172,18 @@ static void CVChooseEta(CVodeMem cv_mem)
       N_VScale(ONE, acor, zn[qmax]);
 
     }
-
   }
-
 }
 
 /*
- * CVHandleFailure
+ * cvHandleFailure
  *
  * This routine prints error messages for all cases of failure by
- * CVHin and CVStep. It returns to CVode the value that CVode is 
- * to return to the user.
+ * cvHin and cvStep.
+ * It returns to CVode the value that CVode is to return to the user.
  */
 
-static int CVHandleFailure(CVodeMem cv_mem, int flag)
+static int cvHandleFailure(CVodeMem cv_mem, int flag)
 {
 
   /* Set vector of  absolute weighted local errors */
@@ -3187,60 +3194,59 @@ static int CVHandleFailure(CVodeMem cv_mem, int flag)
 
   /* Depending on flag, print error message and return error flag */
   switch (flag) {
-  case CV_ERR_FAILURE: 
-    CVProcessError(cv_mem, CV_ERR_FAILURE, "CVODE", "CVode", MSGCV_ERR_FAILS, tn, h);
+  case CV_ERR_FAILURE:
+    cvProcessError(cv_mem, CV_ERR_FAILURE, "CVODE", "CVode", MSGCV_ERR_FAILS, tn, h);
     break;
   case CV_CONV_FAILURE:
-    CVProcessError(cv_mem, CV_CONV_FAILURE, "CVODE", "CVode", MSGCV_CONV_FAILS, tn, h);
+    cvProcessError(cv_mem, CV_CONV_FAILURE, "CVODE", "CVode", MSGCV_CONV_FAILS, tn, h);
     break;
   case CV_LSETUP_FAIL:
-    CVProcessError(cv_mem, CV_LSETUP_FAIL, "CVODE", "CVode", MSGCV_SETUP_FAILED, tn);
+    cvProcessError(cv_mem, CV_LSETUP_FAIL, "CVODE", "CVode", MSGCV_SETUP_FAILED, tn);
     break;
   case CV_LSOLVE_FAIL:
-    CVProcessError(cv_mem, CV_LSOLVE_FAIL, "CVODE", "CVode", MSGCV_SOLVE_FAILED, tn);
+    cvProcessError(cv_mem, CV_LSOLVE_FAIL, "CVODE", "CVode", MSGCV_SOLVE_FAILED, tn);
     break;
   case CV_RHSFUNC_FAIL:
-    CVProcessError(cv_mem, CV_RHSFUNC_FAIL, "CVODE", "CVode", MSGCV_RHSFUNC_FAILED, tn);
+    cvProcessError(cv_mem, CV_RHSFUNC_FAIL, "CVODE", "CVode", MSGCV_RHSFUNC_FAILED, tn);
     break;
   case CV_UNREC_RHSFUNC_ERR:
-    CVProcessError(cv_mem, CV_UNREC_RHSFUNC_ERR, "CVODE", "CVode", MSGCV_RHSFUNC_UNREC, tn);
+    cvProcessError(cv_mem, CV_UNREC_RHSFUNC_ERR, "CVODE", "CVode", MSGCV_RHSFUNC_UNREC, tn);
     break;
   case CV_REPTD_RHSFUNC_ERR:
-    CVProcessError(cv_mem, CV_REPTD_RHSFUNC_ERR, "CVODE", "CVode", MSGCV_RHSFUNC_REPTD, tn);
+    cvProcessError(cv_mem, CV_REPTD_RHSFUNC_ERR, "CVODE", "CVode", MSGCV_RHSFUNC_REPTD, tn);
     break;
-  case CV_RTFUNC_FAIL:    
-    CVProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "CVode", MSGCV_RTFUNC_FAILED, tn);
+  case CV_RTFUNC_FAIL:
+    cvProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODE", "CVode", MSGCV_RTFUNC_FAILED, tn);
     break;
   case CV_TOO_CLOSE:
-    CVProcessError(cv_mem, CV_TOO_CLOSE, "CVODE", "CVode", MSGCV_TOO_CLOSE);
+    cvProcessError(cv_mem, CV_TOO_CLOSE, "CVODE", "CVode", MSGCV_TOO_CLOSE);
     break;
   default:
-    return(CV_SUCCESS);   
+    return(CV_SUCCESS);
   }
 
   return(flag);
-
 }
 
 /* 
- * =================================================================
- * BDF Stability Limit Detection                       
- * =================================================================
+ * -----------------------------------------------------------------
+ * Functions for BDF Stability Limit Detection                       
+ * -----------------------------------------------------------------
  */
 
 /*
- * CVBDFStab
+ * cvBDFStab
  *
  * This routine handles the BDF Stability Limit Detection Algorithm
  * STALD.  It is called if lmm = CV_BDF and the SLDET option is on.
  * If the order is 3 or more, the required norm data is saved.
  * If a decision to reduce order has not already been made, and
- * enough data has been saved, CVsldet is called.  If it signals
+ * enough data has been saved, cvSLdet is called.  If it signals
  * a stability limit violation, the order is reduced, and the step
  * size is reset accordingly.
  */
 
-void CVBDFStab(CVodeMem cv_mem)
+static void cvBDFStab(CVodeMem cv_mem)
 {
   int i,k, ldflag, factorial;
   realtype sq, sqm1, sqm2;
@@ -3250,10 +3256,11 @@ void CVBDFStab(CVodeMem cv_mem)
 
   if (q >= 3) {
     for (k = 1; k <= 3; k++)
-      { for (i = 5; i >= 2; i--) ssdat[i][k] = ssdat[i-1][k]; }
+      for (i = 5; i >= 2; i--)
+        ssdat[i][k] = ssdat[i-1][k];
     factorial = 1;
     for (i = 1; i <= q-1; i++) factorial *= i;
-    sq = factorial*q*(q+1)*acnrm/MAX(tq[5],TINY);
+    sq = factorial*q*(q+1)*acnrm/SUNMAX(tq[5],TINY);
     sqm1 = factorial*q*N_VWrmsNorm(zn[q], ewt);
     sqm2 = factorial*N_VWrmsNorm(zn[q-1], ewt);
     ssdat[1][1] = sqm2*sqm2;
@@ -3261,21 +3268,22 @@ void CVBDFStab(CVodeMem cv_mem)
     ssdat[1][3] = sq*sq;
   }  
 
+
   if (qprime >= q) {
 
     /* If order is 3 or greater, and enough ssdat has been saved,
        nscon >= q+5, then call stability limit detection routine.  */
 
     if ( (q >= 3) && (nscon >= q+5) ) {
-      ldflag = CVsldet(cv_mem);
+      ldflag = cvSLdet(cv_mem);
       if (ldflag > 3) {
         /* A stability limit violation is indicated by
            a return flag of 4, 5, or 6.
            Reduce new order.                     */
         qprime = q-1;
         eta = etaqm1; 
-        eta = MIN(eta,etamax);
-        eta = eta/MAX(ONE,ABS(h)*hmax_inv*eta);
+        eta = SUNMIN(eta,etamax);
+        eta = eta/SUNMAX(ONE,SUNRabs(h)*hmax_inv*eta);
         hprime = h*eta;
         nor = nor + 1;
       }
@@ -3289,10 +3297,10 @@ void CVBDFStab(CVodeMem cv_mem)
 }
 
 /*
- * CVsldet
+ * cvSLdet
  *
  * This routine detects stability limitation using stored scaled 
- * derivatives data. CVsldet returns the magnitude of the
+ * derivatives data. cvSLdet returns the magnitude of the
  * dominate characteristic root, rr. The presents of a stability
  * limit is indicated by rr > "something a little less then 1.0",  
  * and a positive kflag. This routine should only be called if
@@ -3324,9 +3332,9 @@ void CVBDFStab(CVodeMem cv_mem)
  *    kflag = -9 -> R via sigsq[k] disagrees with R from data.
  */
 
-static int CVsldet(CVodeMem cv_mem)
+static int cvSLdet(CVodeMem cv_mem)
 {
-  int i, k, j, it, kmin, kflag = 0;
+  int i, k, j, it, kmin = 0, kflag = 0;
   realtype rat[5][4], rav[4], qkr[4], sigsq[4], smax[4], ssmax[4];
   realtype drr[4], rrc[4],sqmx[4], qjk[4][4], vrat[5], qc[6][4], qco[6][4];
   realtype rr, rrcut, vrrtol, vrrt2, sqtol, rrtol;
@@ -3343,26 +3351,26 @@ static int CVsldet(CVodeMem cv_mem)
   vrrt2  = RCONST(5.0e-4);
   sqtol  = RCONST(1.0e-3);
   rrtol  = RCONST(1.0e-2);
-  
+
   rr = ZERO;
-  
+
   /*  Index k corresponds to the degree of the interpolating polynomial. */
   /*      k = 1 -> q-1          */
   /*      k = 2 -> q            */
   /*      k = 3 -> q+1          */
-  
+
   /*  Index i is a backward-in-time index, i = 1 -> current time, */
   /*      i = 2 -> previous step, etc    */
-  
+
   /* get maxima, minima, and variances, and form quartic coefficients  */
-  
+
   for (k=1; k<=3; k++) {
     smink = ssdat[1][k];
     smaxk = ZERO;
     
     for (i=1; i<=5; i++) {
-      smink = MIN(smink,ssdat[i][k]);
-      smaxk = MAX(smaxk,ssdat[i][k]);
+      smink = SUNMIN(smink,ssdat[i][k]);
+      smaxk = SUNMAX(smaxk,ssdat[i][k]);
     }
     
     if (smink < TINY*smaxk) {
@@ -3371,7 +3379,7 @@ static int CVsldet(CVodeMem cv_mem)
     }
     smax[k] = smaxk;
     ssmax[k] = smaxk*smaxk;
-    
+
     sumrat = ZERO;
     sumrsq = ZERO;
     for (i=1; i<=4; i++) {
@@ -3380,14 +3388,14 @@ static int CVsldet(CVodeMem cv_mem)
       sumrsq = sumrsq + rat[i][k]*rat[i][k];
     } 
     rav[k] = FOURTH*sumrat;
-    vrat[k] = ABS(FOURTH*sumrsq - rav[k]*rav[k]);
-    
+    vrat[k] = SUNRabs(FOURTH*sumrsq - rav[k]*rav[k]);
+
     qc[5][k] = ssdat[1][k]*ssdat[3][k] - ssdat[2][k]*ssdat[2][k];
     qc[4][k] = ssdat[2][k]*ssdat[3][k] - ssdat[1][k]*ssdat[4][k];
     qc[3][k] = ZERO;
     qc[2][k] = ssdat[2][k]*ssdat[5][k] - ssdat[3][k]*ssdat[4][k];
     qc[1][k] = ssdat[4][k]*ssdat[4][k] - ssdat[3][k]*ssdat[5][k];
-    
+
     for (i=1; i<=5; i++) {
       qco[i][k] = qc[i][k];
     }
@@ -3398,144 +3406,139 @@ static int CVsldet(CVodeMem cv_mem)
      Return a kflag = 1 if this procedure works. If three root 
      differ more than vrrt2, return error kflag = -3.    */
   
-  vmin = MIN(vrat[1],MIN(vrat[2],vrat[3]));
-  vmax = MAX(vrat[1],MAX(vrat[2],vrat[3]));
+  vmin = SUNMIN(vrat[1],SUNMIN(vrat[2],vrat[3]));
+  vmax = SUNMAX(vrat[1],SUNMAX(vrat[2],vrat[3]));
   
-  if(vmin < vrrtol*vrrtol) {
+  if (vmin < vrrtol*vrrtol) {
+
     if (vmax > vrrt2*vrrt2) {
       kflag = -2;  
       return(kflag);
     } else {
       rr = (rav[1] + rav[2] + rav[3])/THREE;
-      
       drrmax = ZERO;
-      for(k = 1;k<=3;k++) {
-        adrr = ABS(rav[k] - rr);
-        drrmax = MAX(drrmax, adrr);
-      }
-      if (drrmax > vrrt2) {
-        kflag = -3;    
+      for (k = 1;k<=3;k++) {
+        adrr = SUNRabs(rav[k] - rr);
+        drrmax = SUNMAX(drrmax, adrr);
       }
-      
+      if (drrmax > vrrt2) kflag = -3;    
       kflag = 1;
 
       /*  can compute charactistic root, drop to next section   */
-      
     }
+
   } else {
 
     /* use the quartics to get rr. */
-    
-    if (ABS(qco[1][1]) < TINY*ssmax[1]) {
+
+    if (SUNRabs(qco[1][1]) < TINY*ssmax[1]) {
       kflag = -4;    
       return(kflag);
     }
-    
+
     tem = qco[1][2]/qco[1][1];
-    for(i=2; i<=5; i++) {
+    for (i=2; i<=5; i++) {
       qco[i][2] = qco[i][2] - tem*qco[i][1];
     }
 
     qco[1][2] = ZERO;
     tem = qco[1][3]/qco[1][1];
-    for(i=2; i<=5; i++) {
+    for (i=2; i<=5; i++) {
       qco[i][3] = qco[i][3] - tem*qco[i][1];
     }
     qco[1][3] = ZERO;
-    
-    if (ABS(qco[2][2]) < TINY*ssmax[2]) {
+
+    if (SUNRabs(qco[2][2]) < TINY*ssmax[2]) {
       kflag = -4;    
       return(kflag);
     }
-    
+
     tem = qco[2][3]/qco[2][2];
-    for(i=3; i<=5; i++) {
+    for (i=3; i<=5; i++) {
       qco[i][3] = qco[i][3] - tem*qco[i][2];
     }
-    
-    if (ABS(qco[4][3]) < TINY*ssmax[3]) {
+
+    if (SUNRabs(qco[4][3]) < TINY*ssmax[3]) {
       kflag = -4;    
       return(kflag);
     }
-    
+
     rr = -qco[5][3]/qco[4][3];
-    
-    if (rr < TINY || rr > HUN) {
+
+    if (rr < TINY || rr > HUNDRED) {
       kflag = -5;   
       return(kflag);
     }
-    
-    for(k=1; k<=3; k++) {
+
+    for (k=1; k<=3; k++)
       qkr[k] = qc[5][k] + rr*(qc[4][k] + rr*rr*(qc[2][k] + rr*qc[1][k]));
-    }  
-    
+
     sqmax = ZERO;
-    for(k=1; k<=3; k++) {
-      saqk = ABS(qkr[k])/ssmax[k];
+    for (k=1; k<=3; k++) {
+      saqk = SUNRabs(qkr[k])/ssmax[k];
       if (saqk > sqmax) sqmax = saqk;
     } 
-    
+
     if (sqmax < sqtol) {
       kflag = 2;
-      
+
       /*  can compute charactistic root, drop to "given rr,etc"   */
-      
+
     } else {
 
       /* do Newton corrections to improve rr.  */
-      
-      for(it=1; it<=3; it++) {
-        for(k=1; k<=3; k++) {
+
+      for (it=1; it<=3; it++) {
+        for (k=1; k<=3; k++) {
           qp = qc[4][k] + rr*rr*(THREE*qc[2][k] + rr*FOUR*qc[1][k]);
           drr[k] = ZERO;
-          if (ABS(qp) > TINY*ssmax[k]) drr[k] = -qkr[k]/qp;
+          if (SUNRabs(qp) > TINY*ssmax[k]) drr[k] = -qkr[k]/qp;
           rrc[k] = rr + drr[k];
         } 
-        
-        for(k=1; k<=3; k++) {
+
+        for (k=1; k<=3; k++) {
           s = rrc[k];
           sqmaxk = ZERO;
-          for(j=1; j<=3; j++) {
-            qjk[j][k] = qc[5][j] + s*(qc[4][j] + 
-                                      s*s*(qc[2][j] + s*qc[1][j]));
-            saqj = ABS(qjk[j][k])/ssmax[j];
+          for (j=1; j<=3; j++) {
+            qjk[j][k] = qc[5][j] + s*(qc[4][j] + s*s*(qc[2][j] + s*qc[1][j]));
+            saqj = SUNRabs(qjk[j][k])/ssmax[j];
             if (saqj > sqmaxk) sqmaxk = saqj;
           } 
           sqmx[k] = sqmaxk;
-        } 
+        }
 
-        sqmin = sqmx[1]; kmin = 1;
-        for(k=2; k<=3; k++) {
+        sqmin = sqmx[1] + ONE;
+        for (k=1; k<=3; k++) {
           if (sqmx[k] < sqmin) {
             kmin = k;
             sqmin = sqmx[k];
           }
         } 
         rr = rrc[kmin];
-        
+
         if (sqmin < sqtol) {
           kflag = 3;
           /*  can compute charactistic root   */
           /*  break out of Newton correction loop and drop to "given rr,etc" */ 
           break;
         } else {
-          for(j=1; j<=3; j++) {
+          for (j=1; j<=3; j++) {
             qkr[j] = qjk[j][kmin];
           }
         }     
-      }          /*  end of Newton correction loop  */ 
-      
+      } /*  end of Newton correction loop  */ 
+
       if (sqmin > sqtol) {
         kflag = -6;
         return(kflag);
       }
-    }     /*  end of if (sqmax < sqtol) else   */
-  }      /*  end of if(vmin < vrrtol*vrrtol) else, quartics to get rr. */
-  
+    } /*  end of if (sqmax < sqtol) else   */
+  } /*  end of if (vmin < vrrtol*vrrtol) else, quartics to get rr. */
+
   /* given rr, find sigsq[k] and verify rr.  */
   /* All positive kflag drop to this section  */
   
-  for(k=1; k<=3; k++) {
+  for (k=1; k<=3; k++) {
     rsa = ssdat[1][k];
     rsb = ssdat[2][k]*rr;
     rsc = ssdat[3][k]*rr*rr;
@@ -3547,7 +3550,7 @@ static int CVsldet(CVodeMem cv_mem)
     rd2b = rd1b - rd1c;
     rd3a = rd2a - rd2b;
     
-    if (ABS(rd1b) < TINY*smax[k]) {
+    if (SUNRabs(rd1b) < TINY*smax[k]) {
       kflag = -7;
       return(kflag);
     }
@@ -3573,14 +3576,14 @@ static int CVsldet(CVodeMem cv_mem)
   bb = ratp*ratm - ONE - qfac1*ratp;
   tem = ONE - qfac2*bb;
   
-  if (ABS(tem) < TINY) {
+  if (SUNRabs(tem) < TINY) {
     kflag = -8;
     return(kflag);
   }
   
   rrb = ONE/tem;
   
-  if (ABS(rrb - rr) > rrtol) {
+  if (SUNRabs(rrb - rr) > rrtol) {
     kflag = -9;
     return(kflag);
   }
@@ -3599,26 +3602,24 @@ static int CVsldet(CVodeMem cv_mem)
 }
 
 /* 
- * =================================================================
- * Root finding   
- * =================================================================
+ * -----------------------------------------------------------------
+ * Functions for rootfinding   
+ * -----------------------------------------------------------------
  */
 
-/*-----------------------------------------------------------------*/
-
 /* 
- * CVRcheck1
+ * cvRcheck1
  *
  * This routine completes the initialization of rootfinding memory
  * information, and checks whether g has a zero both at and very near
  * the initial point of the IVP.
  *
  * This routine returns an int equal to:
- *  CV_RTFUNC_FAIL = -12  if the g function failed, or
- *  CV_SUCCESS     =   0  otherwise.
+ *  CV_RTFUNC_FAIL < 0 if the g function failed, or
+ *  CV_SUCCESS     = 0 otherwise.
  */
 
-static int CVRcheck1(CVodeMem cv_mem)
+static int cvRcheck1(CVodeMem cv_mem)
 {
   int i, retval;
   realtype smallh, hratio, tplus;
@@ -3626,7 +3627,7 @@ static int CVRcheck1(CVodeMem cv_mem)
 
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   tlo = tn;
-  ttol = (ABS(tn) + ABS(h))*uround*HUN;
+  ttol = (SUNRabs(tn) + SUNRabs(h))*uround*HUNDRED;
 
   /* Evaluate g at initial t and check for zero values. */
   retval = gfun(tlo, zn[0], glo, user_data);
@@ -3635,7 +3636,7 @@ static int CVRcheck1(CVodeMem cv_mem)
 
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       gactive[i] = FALSE;
     }
@@ -3643,7 +3644,7 @@ static int CVRcheck1(CVodeMem cv_mem)
   if (!zroot) return(CV_SUCCESS);
 
   /* Some g_i is zero at t0; look at g at t0+(small increment). */
-  hratio = MAX(ttol/ABS(h), TENTH);
+  hratio = SUNMAX(ttol/SUNRabs(h), PT1);
   smallh = hratio*h;
   tplus = tlo + smallh;
   N_VLinearSum(ONE, zn[0], hratio, zn[1], y);
@@ -3654,7 +3655,7 @@ static int CVRcheck1(CVodeMem cv_mem)
   /* We check now only the components of g which were exactly 0.0 at t0
    * to see if we can 'activate' them. */
   for (i = 0; i < nrtfn; i++) {
-    if (!gactive[i] && ABS(ghi[i]) != ZERO) {
+    if (!gactive[i] && SUNRabs(ghi[i]) != ZERO) {
       gactive[i] = TRUE;
       glo[i] = ghi[i];
     }
@@ -3663,7 +3664,7 @@ static int CVRcheck1(CVodeMem cv_mem)
 }
 
 /*
- * CVRcheck2
+ * cvRcheck2
  *
  * This routine checks for exact zeros of g at the last root found,
  * if the last return was a root.  It then checks for a close pair of
@@ -3673,17 +3674,17 @@ static int CVRcheck1(CVodeMem cv_mem)
  * there, before returning to do a root search in the interval.
  *
  * On entry, tlo = tretlast is the last value of tret returned by
- * CVode.  This may be the previous tn, the previous tout value, or
- * the last root location.
+ * CVode.  This may be the previous tn, the previous tout value,
+ * or the last root location.
  *
  * This routine returns an int equal to:
- *      CV_RTFUNC_FAIL = -12 if the g function failed, or
- *      CLOSERT        =  3  if a close pair of zeros was found, or
- *      RTFOUND        =  1  if a new zero of g was found near tlo, or
- *      CV_SUCCESS     =  0  otherwise.
+ *     CV_RTFUNC_FAIL  < 0 if the g function failed, or
+ *     CLOSERT         = 3 if a close pair of zeros was found, or
+ *     RTFOUND         = 1 if a new zero of g was found near tlo, or
+ *     CV_SUCCESS      = 0 otherwise.
  */
 
-static int CVRcheck2(CVodeMem cv_mem)
+static int cvRcheck2(CVodeMem cv_mem)
 {
   int i, retval;
   realtype smallh, hratio, tplus;
@@ -3700,7 +3701,7 @@ static int CVRcheck2(CVodeMem cv_mem)
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   for (i = 0; i < nrtfn; i++) {
     if (!gactive[i]) continue;
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       iroots[i] = 1;
     }
@@ -3708,7 +3709,7 @@ static int CVRcheck2(CVodeMem cv_mem)
   if (!zroot) return(CV_SUCCESS);
 
   /* One or more g_i has a zero at tlo.  Check g at tlo+smallh. */
-  ttol = (ABS(tn) + ABS(h))*uround*HUN;
+  ttol = (SUNRabs(tn) + SUNRabs(h))*uround*HUNDRED;
   smallh = (h > ZERO) ? ttol : -ttol;
   tplus = tlo + smallh;
   if ( (tplus - tn)*h >= ZERO) {
@@ -3725,8 +3726,8 @@ static int CVRcheck2(CVodeMem cv_mem)
   and for a g_i that changed from zero to nonzero. */
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
-    if (ABS(ghi[i]) == ZERO) {
-      if (!gactive[i]) continue;
+    if (!gactive[i]) continue;
+    if (SUNRabs(ghi[i]) == ZERO) {
       if (iroots[i] == 1) return(CLOSERT);
       zroot = TRUE;
       iroots[i] = 1;
@@ -3739,21 +3740,21 @@ static int CVRcheck2(CVodeMem cv_mem)
 }
 
 /*
- * CVRcheck3
+ * cvRcheck3
  *
- * This routine interfaces to CVRootfind to look for a root of g
+ * This routine interfaces to cvRootfind to look for a root of g
  * between tlo and either tn or tout, whichever comes first.
  * Only roots beyond tlo in the direction of integration are sought.
  *
  * This routine returns an int equal to:
- *      CV_RTFUNC_FAIL = -12 if the g function failed, or
- *      RTFOUND        =  1  if a root of g was found, or
- *      CV_SUCCESS     =  0  otherwise.
+ *     CV_RTFUNC_FAIL  < 0 if the g function failed, or
+ *     RTFOUND         = 1 if a root of g was found, or
+ *     CV_SUCCESS      = 0 otherwise.
  */
 
-static int CVRcheck3(CVodeMem cv_mem)
+static int cvRcheck3(CVodeMem cv_mem)
 {
-  int i, retval, ier;
+  int i, ier, retval;
 
   /* Set thi = tn or tout, whichever comes first; set y = y(thi). */
   if (taskc == CV_ONE_STEP) {
@@ -3770,13 +3771,13 @@ static int CVRcheck3(CVodeMem cv_mem)
     }
   }
 
-  /* Set ghi = g(thi) and call CVRootfind to search (tlo,thi) for roots. */
+  /* Set ghi = g(thi) and call cvRootfind to search (tlo,thi) for roots. */
   retval = gfun(thi, y, ghi, user_data);
   nge++;
   if (retval != 0) return(CV_RTFUNC_FAIL);
 
-  ttol = (ABS(tn) + ABS(h))*uround*HUN;
-  ier = CVRootfind(cv_mem);
+  ttol = (SUNRabs(tn) + SUNRabs(h))*uround*HUNDRED;
+  ier = cvRootfind(cv_mem);
   if (ier == CV_RTFUNC_FAIL) return(CV_RTFUNC_FAIL);
   for(i=0; i<nrtfn; i++) {
     if(!gactive[i] && grout[i] != ZERO) gactive[i] = TRUE;
@@ -3790,11 +3791,10 @@ static int CVRcheck3(CVodeMem cv_mem)
   /* If a root was found, interpolate to get y(trout) and return.  */
   (void) CVodeGetDky(cv_mem, trout, 0, y);
   return(RTFOUND);
-
 }
 
 /*
- * CVRootfind
+ * cvRootfind
  *
  * This routine solves for a root of g(t) between tlo and thi, if
  * one exists.  Only roots of odd multiplicity (i.e. with a change
@@ -3835,11 +3835,11 @@ static int CVRcheck3(CVodeMem cv_mem)
  *            When a root at trout is found, it is located only to
  *            within a tolerance of ttol.  Typically, ttol should
  *            be set to a value on the order of
- *               100 * UROUND * max (ABS(tlo), ABS(thi))
+ *               100 * UROUND * max (SUNRabs(tlo), SUNRabs(thi))
  *            where UROUND is the unit roundoff of the machine.
  *
  * tlo, thi = endpoints of the interval in which roots are sought.
- *            On input, and must be distinct, but tlo - thi may
+ *            On input, these must be distinct, but tlo - thi may
  *            be of either sign.  The direction of integration is
  *            assumed to be from tlo to thi.  On return, tlo and thi
  *            are the endpoints of the final relevant interval.
@@ -3865,14 +3865,14 @@ static int CVRcheck3(CVodeMem cv_mem)
  *            to that indicated by rootdir[i].
  *
  * This routine returns an int equal to:
- *      CV_RTFUNC_FAIL = -12 if the g function failed, or
- *      RTFOUND        =  1  if a root of g was found, or
- *      CV_SUCCESS     =  0  otherwise.
+ *      CV_RTFUNC_FAIL  < 0 if the g function failed, or
+ *      RTFOUND         = 1 if a root of g was found, or
+ *      CV_SUCCESS      = 0 otherwise.
  */
 
-static int CVRootfind(CVodeMem cv_mem)
+static int cvRootfind(CVodeMem cv_mem)
 {
-  realtype alpha, tmid, gfrac, maxfrac, fracint, fracsub;
+  realtype alph, tmid, gfrac, maxfrac, fracint, fracsub;
   int i, retval, imax, side, sideprev;
   booleantype zroot, sgnchg;
 
@@ -3884,13 +3884,13 @@ static int CVRootfind(CVodeMem cv_mem)
   sgnchg = FALSE;
   for (i = 0;  i < nrtfn; i++) {
     if(!gactive[i]) continue;
-    if (ABS(ghi[i]) == ZERO) {
+    if (SUNRabs(ghi[i]) == ZERO) {
       if(rootdir[i]*glo[i] <= ZERO) {
         zroot = TRUE;
       }
     } else {
       if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-        gfrac = ABS(ghi[i]/(ghi[i] - glo[i]));
+        gfrac = SUNRabs(ghi[i]/(ghi[i] - glo[i]));
         if (gfrac > maxfrac) {
           sgnchg = TRUE;
           maxfrac = gfrac;
@@ -3909,47 +3909,51 @@ static int CVRootfind(CVodeMem cv_mem)
     for (i = 0; i < nrtfn; i++) {
       iroots[i] = 0;
       if(!gactive[i]) continue;
-      if (ABS(ghi[i]) == ZERO) iroots[i] = glo[i] > 0 ? -1:1;
+      if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
+        iroots[i] = glo[i] > 0 ? -1:1;
     }
     return(RTFOUND);
   }
 
-  /* Initialize alpha to avoid compiler warning */
-  alpha = ONE;
+  /* Initialize alph to avoid compiler warning */
+  alph = ONE;
 
   /* A sign change was found.  Loop to locate nearest root. */
 
   side = 0;  sideprev = -1;
   loop {                                    /* Looping point */
 
-    /* Set weight alpha.
-       On the first two passes, set alpha = 1.  Thereafter, reset alpha
+    /* If interval size is already less than tolerance ttol, break. */
+      if (SUNRabs(thi - tlo) <= ttol) break;
+
+    /* Set weight alph.
+       On the first two passes, set alph = 1.  Thereafter, reset alph
        according to the side (low vs high) of the subinterval in which
        the sign change was found in the previous two passes.
-       If the sides were opposite, set alpha = 1.
-       If the sides were the same, then double alpha (if high side),
-       or halve alpha (if low side).
-       The next guess tmid is the secant method value if alpha = 1, but
-       is closer to tlo if alpha < 1, and closer to thi if alpha > 1.    */
+       If the sides were opposite, set alph = 1.
+       If the sides were the same, then double alph (if high side),
+       or halve alph (if low side).
+       The next guess tmid is the secant method value if alph = 1, but
+       is closer to tlo if alph < 1, and closer to thi if alph > 1.    */
 
     if (sideprev == side) {
-      alpha = (side == 2) ? alpha*TWO : alpha*HALF;
+      alph = (side == 2) ? alph*TWO : alph*HALF;
     } else {
-      alpha = ONE;
+      alph = ONE;
     }
 
     /* Set next root approximation tmid and get g(tmid).
        If tmid is too close to tlo or thi, adjust it inward,
        by a fractional distance that is between 0.1 and 0.5.  */
-    tmid = thi - (thi - tlo)*ghi[imax]/(ghi[imax] - alpha*glo[imax]);
-    if (ABS(tmid - tlo) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
-      fracsub = (fracint > FIVE) ? TENTH : HALF/fracint;
+    tmid = thi - (thi - tlo)*ghi[imax]/(ghi[imax] - alph*glo[imax]);
+    if (SUNRabs(tmid - tlo) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
+      fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = tlo + fracsub*(thi - tlo);
     }
-    if (ABS(thi - tmid) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
-      fracsub = (fracint > FIVE) ? TENTH : HALF/fracint;
+    if (SUNRabs(thi - tmid) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
+      fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = thi - fracsub*(thi - tlo);
     }
 
@@ -3966,13 +3970,11 @@ static int CVRootfind(CVodeMem cv_mem)
     sideprev = side;
     for (i = 0;  i < nrtfn; i++) {
       if(!gactive[i]) continue;
-      if (ABS(grout[i]) == ZERO) {
-        if(rootdir[i]*glo[i] <= ZERO) {
-          zroot = TRUE;
-        }
+      if (SUNRabs(grout[i]) == ZERO) {
+        if(rootdir[i]*glo[i] <= ZERO) zroot = TRUE;
       } else {
         if ( (glo[i]*grout[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-          gfrac = ABS(grout[i]/(grout[i] - glo[i]));
+          gfrac = SUNRabs(grout[i]/(grout[i] - glo[i]));
           if (gfrac > maxfrac) {
             sgnchg = TRUE;
             maxfrac = gfrac;
@@ -3987,7 +3989,7 @@ static int CVRootfind(CVodeMem cv_mem)
       for (i = 0; i < nrtfn; i++) ghi[i] = grout[i];
       side = 1;
       /* Stop at root thi if converged; otherwise loop. */
-      if (ABS(thi - tlo) <= ttol) break;
+      if (SUNRabs(thi - tlo) <= ttol) break;
       continue;  /* Return to looping point. */
     }
 
@@ -4004,7 +4006,7 @@ static int CVRootfind(CVodeMem cv_mem)
     for (i = 0; i < nrtfn; i++) glo[i] = grout[i];
     side = 2;
     /* Stop at root thi if converged; otherwise loop back. */
-    if (ABS(thi - tlo) <= ttol) break;
+    if (SUNRabs(thi - tlo) <= ttol) break;
 
   } /* End of root-search loop */
 
@@ -4014,7 +4016,7 @@ static int CVRootfind(CVodeMem cv_mem)
     grout[i] = ghi[i];
     iroots[i] = 0;
     if(!gactive[i]) continue;
-    if ( (ABS(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
+    if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
       iroots[i] = glo[i] > 0 ? -1:1;
     if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
       iroots[i] = glo[i] > 0 ? -1:1;
@@ -4029,24 +4031,24 @@ static int CVRootfind(CVodeMem cv_mem)
  */
 
 /*
- * CVEwtSet
+ * cvEwtSet
  *
  * This routine is responsible for setting the error weight vector ewt,
  * according to tol_type, as follows:
  *
- * (1) ewt[i] = 1 / (reltol * ABS(ycur[i]) + *abstol), i=0,...,neq-1
+ * (1) ewt[i] = 1 / (reltol * SUNRabs(ycur[i]) + *abstol), i=0,...,neq-1
  *     if tol_type = CV_SS
- * (2) ewt[i] = 1 / (reltol * ABS(ycur[i]) + abstol[i]), i=0,...,neq-1
+ * (2) ewt[i] = 1 / (reltol * SUNRabs(ycur[i]) + abstol[i]), i=0,...,neq-1
  *     if tol_type = CV_SV
  *
- * CVEwtSet returns 0 if ewt is successfully set as above to a
+ * cvEwtSet returns 0 if ewt is successfully set as above to a
  * positive vector and -1 otherwise. In the latter case, ewt is
  * considered undefined.
  *
- * All the real work is done in the routines CVEwtSetSS, CVEwtSetSV.
+ * All the real work is done in the routines cvEwtSetSS, cvEwtSetSV.
  */
 
-int CVEwtSet(N_Vector ycur, N_Vector weight, void *data)
+int cvEwtSet(N_Vector ycur, N_Vector weight, void *data)
 {
   CVodeMem cv_mem;
   int flag = 0;
@@ -4057,10 +4059,10 @@ int CVEwtSet(N_Vector ycur, N_Vector weight, void *data)
 
   switch(itol) {
   case CV_SS: 
-    flag = CVEwtSetSS(cv_mem, ycur, weight);
+    flag = cvEwtSetSS(cv_mem, ycur, weight);
     break;
   case CV_SV: 
-    flag = CVEwtSetSV(cv_mem, ycur, weight);
+    flag = cvEwtSetSV(cv_mem, ycur, weight);
     break;
   }
   
@@ -4068,15 +4070,15 @@ int CVEwtSet(N_Vector ycur, N_Vector weight, void *data)
 }
 
 /*
- * CVEwtSetSS
+ * cvEwtSetSS
  *
  * This routine sets ewt as decribed above in the case tol_type = CV_SS.
- * It tests for non-positive components before inverting. CVEwtSetSS
+ * It tests for non-positive components before inverting. cvEwtSetSS
  * returns 0 if ewt is successfully set to a positive vector
  * and -1 otherwise. In the latter case, ewt is considered undefined.
  */
 
-static int CVEwtSetSS(CVodeMem cv_mem, N_Vector ycur, N_Vector weight)
+static int cvEwtSetSS(CVodeMem cv_mem, N_Vector ycur, N_Vector weight)
 {
   N_VAbs(ycur, tempv);
   N_VScale(reltol, tempv, tempv);
@@ -4087,15 +4089,15 @@ static int CVEwtSetSS(CVodeMem cv_mem, N_Vector ycur, N_Vector weight)
 }
 
 /*
- * CVEwtSetSV
+ * cvEwtSetSV
  *
  * This routine sets ewt as decribed above in the case tol_type = CV_SV.
- * It tests for non-positive components before inverting. CVEwtSetSV
+ * It tests for non-positive components before inverting. cvEwtSetSV
  * returns 0 if ewt is successfully set to a positive vector
  * and -1 otherwise. In the latter case, ewt is considered undefined.
  */
 
-static int CVEwtSetSV(CVodeMem cv_mem, N_Vector ycur, N_Vector weight)
+static int cvEwtSetSV(CVodeMem cv_mem, N_Vector ycur, N_Vector weight)
 {
   N_VAbs(ycur, tempv);
   N_VLinearSum(reltol, tempv, ONE, Vabstol, tempv);
@@ -4105,22 +4107,22 @@ static int CVEwtSetSV(CVodeMem cv_mem, N_Vector ycur, N_Vector weight)
 }
 
 /* 
- * =================================================================
- * CVODE Error Handling function   
- * =================================================================
+ * -----------------------------------------------------------------
+ * Error message handling functions   
+ * -----------------------------------------------------------------
  */
 
-/* 
- * CVProcessError is a high level error handling function
- * - if cv_mem==NULL it prints the error message to stderr
- * - otherwise, it sets-up and calls the error hadling function 
- *   pointed to by cv_ehfun
+/*
+ * cvProcessError is a high level error handling function.
+ * - If cv_mem==NULL it prints the error message to stderr.
+ * - Otherwise, it sets up and calls the error handling function 
+ *   pointed to by cv_ehfun.
  */
 
 #define ehfun    (cv_mem->cv_ehfun)
 #define eh_data  (cv_mem->cv_eh_data)
 
-void CVProcessError(CVodeMem cv_mem, 
+void cvProcessError(CVodeMem cv_mem, 
                     int error_code, const char *module, const char *fname, 
                     const char *msgfmt, ...)
 {
@@ -4128,44 +4130,38 @@ void CVProcessError(CVodeMem cv_mem,
   char msg[256];
 
   /* Initialize the argument pointer variable 
-     (msgfmt is the last required argument to CVProcessError) */
+     (msgfmt is the last required argument to cvProcessError) */
 
   va_start(ap, msgfmt);
 
-  if (cv_mem == NULL) {    /* We write to stderr */
+  /* Compose the message */
+
+  vsprintf(msg, msgfmt, ap);
 
+  if (cv_mem == NULL) {    /* We write to stderr */
 #ifndef NO_FPRINTF_OUTPUT
     fprintf(stderr, "\n[%s ERROR]  %s\n  ", module, fname);
-    fprintf(stderr, msgfmt);
-    fprintf(stderr, "\n\n");
+    fprintf(stderr, "%s\n\n", msg);
 #endif
 
   } else {                 /* We can call ehfun */
-
-    /* Compose the message */
-
-    vsprintf(msg, msgfmt, ap);
-
-    /* Call ehfun */
-
     ehfun(error_code, module, fname, msg, eh_data);
-
   }
 
   /* Finalize argument processing */
-  
   va_end(ap);
 
   return;
-
 }
 
-/* CVErrHandler is the default error handling function.
-   It sends the error message to the stream pointed to by cv_errfp */
+/*
+ * cvErrHandler is the default error handling function.
+ * It sends the error message to the stream pointed to by cv_errfp.
+ */
 
 #define errfp    (cv_mem->cv_errfp)
 
-void CVErrHandler(int error_code, const char *module,
+void cvErrHandler(int error_code, const char *module,
                   const char *function, char *msg, void *data)
 {
   CVodeMem cv_mem;
diff --git a/src/cvode/cvode_band.c b/src/cvode/cvode_band.c
index 9ea0b4a..a4913d8 100644
--- a/src/cvode/cvode_band.c
+++ b/src/cvode/cvode_band.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2011/03/23 22:27:43 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVBAND linear solver.
  * -----------------------------------------------------------------
@@ -41,7 +46,7 @@ static int cvBandSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int cvBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                        N_Vector ycur, N_Vector fcur);
 
-static void cvBandFree(CVodeMem cv_mem);
+static int cvBandFree(CVodeMem cv_mem);
 
 /* Readability Replacements */
 
@@ -111,14 +116,14 @@ int CVBand(void *cvode_mem, long int N, long int mupper, long int mlower)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVBAND", "CVBand", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVBAND", "CVBand", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Test if the NVECTOR package is compatible with the BAND solver */
   if (vec_tmpl->ops->nvgetarraypointer == NULL) {
-    CVProcessError(cv_mem, CVDLS_ILL_INPUT, "CVBAND", "CVBand", MSGD_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVBAND", "CVBand", MSGD_BAD_NVECTOR);
     return(CVDLS_ILL_INPUT);
   }
 
@@ -134,7 +139,7 @@ int CVBand(void *cvode_mem, long int N, long int mupper, long int mlower)
   cvdls_mem = NULL;
   cvdls_mem = (CVDlsMem) malloc(sizeof(struct CVDlsMemRec));
   if (cvdls_mem == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
     return(CVDLS_MEM_FAIL);
   }
 
@@ -148,6 +153,8 @@ int CVBand(void *cvode_mem, long int N, long int mupper, long int mlower)
 
   last_flag = CVDLS_SUCCESS;
 
+  cvDlsInitializeCounters(cvdls_mem);
+
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -159,26 +166,26 @@ int CVBand(void *cvode_mem, long int N, long int mupper, long int mlower)
 
   /* Test ml and mu for legality */
   if ((ml < 0) || (mu < 0) || (ml >= N) || (mu >= N)) {
-    CVProcessError(cv_mem, CVDLS_ILL_INPUT, "CVBAND", "CVBand", MSGD_BAD_SIZES);
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVBAND", "CVBand", MSGD_BAD_SIZES);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_ILL_INPUT);
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(N-1, mu + ml);
+  smu = SUNMIN(N-1, mu + ml);
 
   /* Allocate memory for M, savedJ, and pivot arrays */
   M = NULL;
   M = NewBandMat(N, mu, ml, smu);
   if (M == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
   }
   savedJ = NULL;
   savedJ = NewBandMat(N, mu, ml, mu);
   if (savedJ == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
     DestroyMat(M);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
@@ -186,7 +193,7 @@ int CVBand(void *cvode_mem, long int N, long int mupper, long int mlower)
   lpivots = NULL;
   lpivots = NewLintArray(N);
   if (lpivots == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVBAND", "CVBand", MSGD_MEM_FAIL);
     DestroyMat(M);
     DestroyMat(savedJ);
     free(cvdls_mem); cvdls_mem = NULL;
@@ -214,9 +221,7 @@ static int cvBandInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
 
-  nje   = 0;
-  nfeDQ  = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -257,7 +262,7 @@ static int cvBandSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
 
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
          ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
          (convfail == CV_FAIL_OTHER);
@@ -279,7 +284,7 @@ static int cvBandSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 
     retval = jac(n, mu, ml, tn, ypred, fpred, M, J_data, vtemp1, vtemp2, vtemp3);
     if (retval < 0) {
-      CVProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVBAND", "cvBandSetup", MSGD_JACFUNC_FAILED);
+      cvProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVBAND", "cvBandSetup", MSGD_JACFUNC_FAILED);
       last_flag = CVDLS_JACFUNC_UNRECVR;
       return(-1);
     }
@@ -346,7 +351,7 @@ static int cvBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void cvBandFree(CVodeMem cv_mem)
+static int cvBandFree(CVodeMem cv_mem)
 {
   CVDlsMem cvdls_mem;
 
@@ -357,5 +362,7 @@ static void cvBandFree(CVodeMem cv_mem)
   DestroyArray(lpivots);
   free(cvdls_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
 
diff --git a/src/cvode/cvode_bandpre.c b/src/cvode/cvode_bandpre.c
index 6892ba6..661e0dd 100644
--- a/src/cvode/cvode_bandpre.c
+++ b/src/cvode/cvode_bandpre.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:21:04 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file contains implementations of the banded difference
  * quotient Jacobian-based preconditioner and solver routines for
@@ -49,7 +54,7 @@ static int CVBandPrecSolve(realtype t, N_Vector y, N_Vector fy,
 
 /* Prototype for CVBandPrecFree */
 
-static void CVBandPrecFree(CVodeMem cv_mem);
+static int CVBandPrecFree(CVodeMem cv_mem);
 
 /* Prototype for difference quotient Jacobian calculation routine */
 
@@ -80,36 +85,36 @@ int CVBandPrecInit(void *cvode_mem, long int N, long int mu, long int ml)
   int flag;
 
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Test if one of the SPILS linear solvers has been attached */
   if (cv_mem->cv_lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBANDPRE", "CVBandPrecInit", MSGBP_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBANDPRE", "CVBandPrecInit", MSGBP_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
 
   /* Test if the NVECTOR package is compatible with the BAND preconditioner */
   if(vec_tmpl->ops->nvgetarraypointer == NULL) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVBANDPRE", "CVBandPrecInit", MSGBP_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVBANDPRE", "CVBandPrecInit", MSGBP_BAD_NVECTOR);
     return(CVSPILS_ILL_INPUT);
   }
 
   pdata = NULL;
   pdata = (CVBandPrecData) malloc(sizeof *pdata);  /* Allocate data memory */
   if (pdata == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
   /* Load pointers and bandwidths into pdata block. */
   pdata->cvode_mem = cvode_mem;
   pdata->N = N;
-  pdata->mu = mup = MIN(N-1, MAX(0,mu));
-  pdata->ml = mlp = MIN(N-1, MAX(0,ml));
+  pdata->mu = mup = SUNMIN(N-1, SUNMAX(0,mu));
+  pdata->ml = mlp = SUNMIN(N-1, SUNMAX(0,ml));
 
   /* Initialize nfeBP counter */
   pdata->nfeBP = 0;
@@ -119,18 +124,18 @@ int CVBandPrecInit(void *cvode_mem, long int N, long int mu, long int ml)
   pdata->savedJ = NewBandMat(N, mup, mlp, mup);
   if (pdata->savedJ == NULL) {
     free(pdata); pdata = NULL;
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
   /* Allocate memory for banded preconditioner. */
-  storagemu = MIN(N-1, mup+mlp);
+  storagemu = SUNMIN(N-1, mup+mlp);
   pdata->savedP = NULL;
   pdata->savedP = NewBandMat(N, mup, mlp, storagemu);
   if (pdata->savedP == NULL) {
     DestroyMat(pdata->savedJ);
     free(pdata); pdata = NULL;
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
@@ -141,11 +146,16 @@ int CVBandPrecInit(void *cvode_mem, long int N, long int mu, long int ml)
     DestroyMat(pdata->savedP);
     DestroyMat(pdata->savedJ);
     free(pdata); pdata = NULL;
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBANDPRE", "CVBandPrecInit", MSGBP_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
-  /* Overwrite the P_data field in the SPILS memory */
+  /* make sure s_P_data is free from any previous allocations */
+  if (cvspils_mem->s_pfree != NULL) {
+    cvspils_mem->s_pfree(cv_mem);
+  }
+
+  /* Point to the new P_data field in the SPILS memory */
   cvspils_mem->s_P_data = pdata;
 
   /* Attach the pfree function */
@@ -166,19 +176,19 @@ int CVBandPrecGetWorkSpace(void *cvode_mem, long int *lenrwBP, long int *leniwBP
 
   
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVBANDPRE", "CVBandPrecGetWorkSpace", MSGBP_MEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVBANDPRE", "CVBandPrecGetWorkSpace", MSGBP_MEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (cv_mem->cv_lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBANDPRE", "CVBandPrecGetWorkSpace", MSGBP_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBANDPRE", "CVBandPrecGetWorkSpace", MSGBP_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
 
   if (cvspils_mem->s_P_data == NULL) {
-    CVProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBANDPRE", "CVBandPrecGetWorkSpace", MSGBP_PMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBANDPRE", "CVBandPrecGetWorkSpace", MSGBP_PMEM_NULL);
     return(CVSPILS_PMEM_NULL);
   } 
   pdata = (CVBandPrecData) cvspils_mem->s_P_data;
@@ -186,7 +196,7 @@ int CVBandPrecGetWorkSpace(void *cvode_mem, long int *lenrwBP, long int *leniwBP
   N   = pdata->N;
   mu  = pdata->mu;
   ml  = pdata->ml;
-  smu = MIN( N-1, mu + ml);
+  smu = SUNMIN( N-1, mu + ml);
 
   *leniwBP = pdata->N;
   *lenrwBP = N * ( 2*ml + smu + mu + 2 );
@@ -201,19 +211,19 @@ int CVBandPrecGetNumRhsEvals(void *cvode_mem, long int *nfevalsBP)
   CVBandPrecData pdata;
 
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVBANDPRE", "CVBandPrecGetNumRhsEvals", MSGBP_MEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVBANDPRE", "CVBandPrecGetNumRhsEvals", MSGBP_MEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (cv_mem->cv_lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBANDPRE", "CVBandPrecGetNumRhsEvals", MSGBP_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBANDPRE", "CVBandPrecGetNumRhsEvals", MSGBP_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
 
   if (cvspils_mem->s_P_data == NULL) {
-    CVProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBANDPRE", "CVBandPrecGetNumRhsEvals", MSGBP_PMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBANDPRE", "CVBandPrecGetNumRhsEvals", MSGBP_PMEM_NULL);
     return(CVSPILS_PMEM_NULL);
   } 
   pdata = (CVBandPrecData) cvspils_mem->s_P_data;
@@ -310,7 +320,7 @@ static int CVBandPrecSetup(realtype t, N_Vector y, N_Vector fy,
 
     retval = CVBandPDQJac(pdata, t, y, fy, tmp1, tmp2);
     if (retval < 0) {
-      CVProcessError(cv_mem, -1, "CVBANDPRE", "CVBandPrecSetup", MSGBP_RHSFUNC_FAILED);
+      cvProcessError(cv_mem, -1, "CVBANDPRE", "CVBandPrecSetup", MSGBP_RHSFUNC_FAILED);
       return(-1);
     }
     if (retval > 0) {
@@ -376,15 +386,15 @@ static int CVBandPrecSolve(realtype t, N_Vector y, N_Vector fy,
 }
 
 
-static void CVBandPrecFree(CVodeMem cv_mem)
+static int CVBandPrecFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   CVBandPrecData pdata;
 
-  if (cv_mem->cv_lmem == NULL) return;
+  if (cv_mem->cv_lmem == NULL) return(0);
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
   
-  if (cvspils_mem->s_P_data == NULL) return;
+  if (cvspils_mem->s_P_data == NULL) return(0);
   pdata = (CVBandPrecData) cvspils_mem->s_P_data;
 
   DestroyMat(savedJ);
@@ -393,6 +403,8 @@ static void CVBandPrecFree(CVodeMem cv_mem)
 
   free(pdata);
   pdata = NULL;
+
+  return(0);
 }
 
 #define ewt       (cv_mem->cv_ewt)
@@ -437,20 +449,20 @@ static int CVBandPDQJac(CVBandPrecData pdata,
   N_VScale(ONE, y, ytemp);
 
   /* Set minimum increment based on uround and norm of f. */
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   fnorm = N_VWrmsNorm(fy, ewt);
   minInc = (fnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * N * fnorm) : ONE;
 
   /* Set bandwidth and number of column groups for band differencing. */
   width = ml + mu + 1;
-  ngroups = MIN(width, N);
+  ngroups = SUNMIN(width, N);
   
   for (group = 1; group <= ngroups; group++) {
     
     /* Increment all y_j in group. */
     for(j = group-1; j < N; j += width) {
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       ytemp_data[j] += inc;
     }
 
@@ -464,10 +476,10 @@ static int CVBandPDQJac(CVBandPrecData pdata,
     for (j = group-1; j < N; j += width) {
       ytemp_data[j] = y_data[j];
       col_j = BAND_COL(savedJ,j);
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mu);
-      i2 = MIN(j+ml, N-1);
+      i1 = SUNMAX(0, j-mu);
+      i2 = SUNMIN(j+ml, N-1);
       for (i=i1; i <= i2; i++)
         BAND_COL_ELEM(col_j,i,j) =
           inc_inv * (ftemp_data[i] - fy_data[i]);
diff --git a/src/cvode/cvode_bandpre_impl.h b/src/cvode/cvode_bandpre_impl.h
index 09e56d3..9b2b7ec 100644
--- a/src/cvode/cvode_bandpre_impl.h
+++ b/src/cvode/cvode_bandpre_impl.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:19:48 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Michael Wittman, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the CVBANDPRE module.
  * -----------------------------------------------------------------
@@ -18,14 +23,14 @@
 #ifndef _CVBANDPRE_IMPL_H
 #define _CVBANDPRE_IMPL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <cvode/cvode_bandpre.h>
 #include <sundials/sundials_band.h>
 #include <sundials/sundials_direct.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /*
  * -----------------------------------------------------------------
  * Type: CVBandPrecData
diff --git a/src/cvode/cvode_bbdpre.c b/src/cvode/cvode_bbdpre.c
index 30f6844..4a3f63a 100644
--- a/src/cvode/cvode_bbdpre.c
+++ b/src/cvode/cvode_bbdpre.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:21:04 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Michael Wittman, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file contains implementations of routines for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -49,7 +54,7 @@ static int CVBBDPrecSolve(realtype t, N_Vector y, N_Vector fy,
                           int lr, void *bbd_data, N_Vector tmp);
 
 /* Prototype for CVBBDPrecFree */
-static void CVBBDPrecFree(CVodeMem cv_mem);
+static int CVBBDPrecFree(CVodeMem cv_mem);
 
 
 /* Prototype for difference quotient Jacobian calculation routine */
@@ -82,21 +87,21 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   int flag;
 
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Test if one of the SPILS linear solvers has been attached */
   if (cv_mem->cv_lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
 
   /* Test if the NVECTOR package is compatible with the BLOCK BAND preconditioner */
   if(vec_tmpl->ops->nvgetarraypointer == NULL) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_BAD_NVECTOR);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -104,7 +109,7 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   pdata = NULL;
   pdata = (CVBBDPrecData) malloc(sizeof *pdata);  
   if (pdata == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
@@ -112,10 +117,10 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   pdata->cvode_mem = cvode_mem;
   pdata->gloc = gloc;
   pdata->cfn = cfn;
-  pdata->mudq = MIN(Nlocal-1, MAX(0,mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0,mldq));
-  muk = MIN(Nlocal-1, MAX(0,mukeep));
-  mlk = MIN(Nlocal-1, MAX(0,mlkeep));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0,mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0,mldq));
+  muk = SUNMIN(Nlocal-1, SUNMAX(0,mukeep));
+  mlk = SUNMIN(Nlocal-1, SUNMAX(0,mlkeep));
   pdata->mukeep = muk;
   pdata->mlkeep = mlk;
 
@@ -123,18 +128,18 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   pdata->savedJ = NewBandMat(Nlocal, muk, mlk, muk);
   if (pdata->savedJ == NULL) { 
     free(pdata); pdata = NULL; 
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
     return(CVSPILS_MEM_FAIL); 
   }
 
   /* Allocate memory for preconditioner matrix */
-  storage_mu = MIN(Nlocal-1, muk + mlk);
+  storage_mu = SUNMIN(Nlocal-1, muk + mlk);
   pdata->savedP = NULL;
   pdata->savedP = NewBandMat(Nlocal, muk, mlk, storage_mu);
   if (pdata->savedP == NULL) {
     DestroyMat(pdata->savedJ);
     free(pdata); pdata = NULL;
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
   /* Allocate memory for lpivots */
@@ -144,12 +149,12 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
     DestroyMat(pdata->savedP);
     DestroyMat(pdata->savedJ);
     free(pdata); pdata = NULL;
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVBBDPRE", "CVBBDPrecInit", MSGBBD_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
   /* Set pdata->dqrely based on input dqrely (0 implies default). */
-  pdata->dqrely = (dqrely > ZERO) ? dqrely : RSqrt(uround);
+  pdata->dqrely = (dqrely > ZERO) ? dqrely : SUNRsqrt(uround);
 
   /* Store Nlocal to be used in CVBBDPrecSetup */
   pdata->n_local = Nlocal;
@@ -159,7 +164,12 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   pdata->ipwsize = Nlocal;
   pdata->nge = 0;
 
-  /* Overwrite the P_data field in the SPILS memory */
+  /* make sure s_P_data is free from any previous allocations */
+  if (cvspils_mem->s_pfree != NULL) {
+    cvspils_mem->s_pfree(cv_mem);
+  }
+
+  /* Point to the new P_data field in the SPILS memory */
   cvspils_mem->s_P_data = pdata;
 
   /* Attach the pfree function */
@@ -182,32 +192,32 @@ int CVBBDPrecReInit(void *cvode_mem,
   long int Nlocal;
 
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecReInit", MSGBBD_MEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecReInit", MSGBBD_MEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Test if one of the SPILS linear solvers has been attached */
   if (cv_mem->cv_lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecReInit", MSGBBD_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecReInit", MSGBBD_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
 
   /* Test if the preconditioner data is non-NULL */
   if (cvspils_mem->s_P_data == NULL) {
-    CVProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBBDPRE", "CVBBDPrecReInit", MSGBBD_PMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBBDPRE", "CVBBDPrecReInit", MSGBBD_PMEM_NULL);
     return(CVSPILS_PMEM_NULL);
   } 
   pdata = (CVBBDPrecData) cvspils_mem->s_P_data;
 
   /* Load half-bandwidths */
   Nlocal = pdata->n_local;
-  pdata->mudq = MIN(Nlocal-1, MAX(0,mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0,mldq));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0,mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0,mldq));
 
   /* Set pdata->dqrely based on input dqrely (0 implies default). */
-  pdata->dqrely = (dqrely > ZERO) ? dqrely : RSqrt(uround);
+  pdata->dqrely = (dqrely > ZERO) ? dqrely : SUNRsqrt(uround);
 
   /* Re-initialize nge */
   pdata->nge = 0;
@@ -222,19 +232,19 @@ int CVBBDPrecGetWorkSpace(void *cvode_mem, long int *lenrwBBDP, long int *leniwB
   CVBBDPrecData pdata;
 
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecGetWorkSpace", MSGBBD_MEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecGetWorkSpace", MSGBBD_MEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (cv_mem->cv_lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecGetWorkSpace", MSGBBD_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecGetWorkSpace", MSGBBD_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
 
   if (cvspils_mem->s_P_data == NULL) {
-    CVProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBBDPRE", "CVBBDPrecGetWorkSpace", MSGBBD_PMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBBDPRE", "CVBBDPrecGetWorkSpace", MSGBBD_PMEM_NULL);
     return(CVSPILS_PMEM_NULL);
   } 
   pdata = (CVBBDPrecData) cvspils_mem->s_P_data;
@@ -252,19 +262,19 @@ int CVBBDPrecGetNumGfnEvals(void *cvode_mem, long int *ngevalsBBDP)
   CVBBDPrecData pdata;
 
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecGetNumGfnEvals", MSGBBD_MEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVBBDPRE", "CVBBDPrecGetNumGfnEvals", MSGBBD_MEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (cv_mem->cv_lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecGetNumGfnEvals", MSGBBD_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVBBDPRE", "CVBBDPrecGetNumGfnEvals", MSGBBD_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
 
   if (cvspils_mem->s_P_data == NULL) {
-    CVProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBBDPRE", "CVBBDPrecGetNumGfnEvals", MSGBBD_PMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_PMEM_NULL, "CVBBDPRE", "CVBBDPrecGetNumGfnEvals", MSGBBD_PMEM_NULL);
     return(CVSPILS_PMEM_NULL);
   } 
   pdata = (CVBBDPrecData) cvspils_mem->s_P_data;
@@ -370,7 +380,7 @@ static int CVBBDPrecSetup(realtype t, N_Vector y, N_Vector fy,
 
     retval = CVBBDDQJac(pdata, t, y, tmp1, tmp2, tmp3);
     if (retval < 0) {
-      CVProcessError(cv_mem, -1, "CVBBDPRE", "CVBBDPrecSetup", MSGBBD_FUNC_FAILED);
+      cvProcessError(cv_mem, -1, "CVBBDPRE", "CVBBDPrecSetup", MSGBBD_FUNC_FAILED);
       return(-1);
     }
     if (retval > 0) {
@@ -436,15 +446,15 @@ static int CVBBDPrecSolve(realtype t, N_Vector y, N_Vector fy,
 }
 
 
-static void CVBBDPrecFree(CVodeMem cv_mem)
+static int CVBBDPrecFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   CVBBDPrecData pdata;
   
-  if (cv_mem->cv_lmem == NULL) return;
+  if (cv_mem->cv_lmem == NULL) return(0);
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
   
-  if (cvspils_mem->s_P_data == NULL) return;
+  if (cvspils_mem->s_P_data == NULL) return(0);
   pdata = (CVBBDPrecData) cvspils_mem->s_P_data;
 
   DestroyMat(savedJ);
@@ -453,6 +463,8 @@ static void CVBBDPrecFree(CVodeMem cv_mem)
 
   free(pdata);
   pdata = NULL;
+
+  return(0);
 }
 
 
@@ -512,18 +524,18 @@ static int CVBBDDQJac(CVBBDPrecData pdata, realtype t,
   /* Set minimum increment based on uround and norm of g */
   gnorm = N_VWrmsNorm(gy, ewt);
   minInc = (gnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * Nlocal * gnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * Nlocal * gnorm) : ONE;
 
   /* Set bandwidth and number of column groups for band differencing */
   width = mldq + mudq + 1;
-  ngroups = MIN(width, Nlocal);
+  ngroups = SUNMIN(width, Nlocal);
 
   /* Loop over groups */  
   for (group=1; group <= ngroups; group++) {
     
     /* Increment all y_j in group */
     for(j=group-1; j < Nlocal; j+=width) {
-      inc = MAX(dqrely*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(dqrely*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       ytemp_data[j] += inc;
     }
 
@@ -536,10 +548,10 @@ static int CVBBDDQJac(CVBBDPrecData pdata, realtype t,
     for (j=group-1; j < Nlocal; j+=width) {
       ytemp_data[j] = y_data[j];
       col_j = BAND_COL(savedJ,j);
-      inc = MAX(dqrely*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(dqrely*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mukeep);
-      i2 = MIN(j+mlkeep, Nlocal-1);
+      i1 = SUNMAX(0, j-mukeep);
+      i2 = SUNMIN(j+mlkeep, Nlocal-1);
       for (i=i1; i <= i2; i++)
         BAND_COL_ELEM(col_j,i,j) =
           inc_inv * (gtemp_data[i] - gy_data[i]);
diff --git a/src/cvode/cvode_bbdpre_impl.h b/src/cvode/cvode_bbdpre_impl.h
index 10bb8bc..3415b95 100644
--- a/src/cvode/cvode_bbdpre_impl.h
+++ b/src/cvode/cvode_bbdpre_impl.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:19:48 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Michael Wittman, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the CVBBDPRE module.
  * -----------------------------------------------------------------
@@ -18,13 +23,13 @@
 #ifndef _CVBBDPRE_IMPL_H
 #define _CVBBDPRE_IMPL_H
 
+#include <cvode/cvode_bbdpre.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_bbdpre.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Type: CVBBDPrecData
diff --git a/src/cvode/cvode_dense.c b/src/cvode/cvode_dense.c
index a2e9f3b..77c986e 100644
--- a/src/cvode/cvode_dense.c
+++ b/src/cvode/cvode_dense.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2010/12/01 22:21:04 $
+ * $Revision: 4951 $
+ * $Date: 2016-09-22 10:21:00 -0700 (Thu, 22 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the impleentation file for the CVDENSE linear solver.
  * -----------------------------------------------------------------
@@ -41,7 +46,7 @@ static int cvDenseSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int cvDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                         N_Vector ycur, N_Vector fcur);
 
-static void cvDenseFree(CVodeMem cv_mem);
+static int cvDenseFree(CVodeMem cv_mem);
 
 /* Readability Replacements */
 
@@ -106,7 +111,7 @@ int CVDense(void *cvode_mem, long int N)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVDENSE", "CVDense", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVDENSE", "CVDense", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -114,7 +119,7 @@ int CVDense(void *cvode_mem, long int N)
   /* Test if the NVECTOR package is compatible with the DENSE solver */
   if (vec_tmpl->ops->nvgetarraypointer == NULL ||
       vec_tmpl->ops->nvsetarraypointer == NULL) {
-    CVProcessError(cv_mem, CVDLS_ILL_INPUT, "CVDENSE", "CVDense", MSGD_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVDENSE", "CVDense", MSGD_BAD_NVECTOR);
     return(CVDLS_ILL_INPUT);
   }
 
@@ -130,7 +135,7 @@ int CVDense(void *cvode_mem, long int N)
   cvdls_mem = NULL;
   cvdls_mem = (CVDlsMem) malloc(sizeof(struct CVDlsMemRec));
   if (cvdls_mem == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
     return(CVDLS_MEM_FAIL);
   }
 
@@ -144,6 +149,8 @@ int CVDense(void *cvode_mem, long int N)
 
   last_flag = CVDLS_SUCCESS;
 
+  cvDlsInitializeCounters(cvdls_mem);
+
   setupNonNull = TRUE;
 
   /* Set problem dimension */
@@ -154,14 +161,14 @@ int CVDense(void *cvode_mem, long int N)
   M = NULL;
   M = NewDenseMat(N, N);
   if (M == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
   }
   savedJ = NULL;
   savedJ = NewDenseMat(N, N);
   if (savedJ == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
     DestroyMat(M);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
@@ -169,7 +176,7 @@ int CVDense(void *cvode_mem, long int N)
   lpivots = NULL;
   lpivots = NewLintArray(N);
   if (lpivots == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVDENSE", "CVDense", MSGD_MEM_FAIL);
     DestroyMat(M);
     DestroyMat(savedJ);
     free(cvdls_mem); cvdls_mem = NULL;
@@ -197,9 +204,11 @@ static int cvDenseInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
   
-  nje   = 0;
-  nfeDQ = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);
+  /*   nje   = 0;
+   nfeDQ = 0;
+   nstlj = 0;
+  */
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -240,7 +249,7 @@ static int cvDenseSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
  
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
  
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
          ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
          (convfail == CV_FAIL_OTHER);
@@ -262,7 +271,7 @@ static int cvDenseSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 
     retval = jac(n, tn, ypred, fpred, M, J_data, vtemp1, vtemp2, vtemp3);
     if (retval < 0) {
-      CVProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVDENSE", "cvDenseSetup", MSGD_JACFUNC_FAILED);
+      cvProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVDENSE", "cvDenseSetup", MSGD_JACFUNC_FAILED);
       last_flag = CVDLS_JACFUNC_UNRECVR;
       return(-1);
     }
@@ -326,7 +335,7 @@ static int cvDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void cvDenseFree(CVodeMem cv_mem)
+static int cvDenseFree(CVodeMem cv_mem)
 {
   CVDlsMem  cvdls_mem;
 
@@ -337,5 +346,7 @@ static void cvDenseFree(CVodeMem cv_mem)
   DestroyArray(lpivots);
   free(cvdls_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
 
diff --git a/src/cvode/cvode_diag.c b/src/cvode/cvode_diag.c
index b7cfba2..1f1a055 100644
--- a/src/cvode/cvode_diag.c
+++ b/src/cvode/cvode_diag.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:21:04 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVDIAG linear solver.
  * -----------------------------------------------------------------
@@ -37,7 +42,7 @@ static int CVDiagSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                        N_Vector ycur, N_Vector fcur);
 
-static void CVDiagFree(CVodeMem cv_mem);
+static int CVDiagFree(CVodeMem cv_mem);
 
 /* Readability Replacements */
 
@@ -92,7 +97,7 @@ int CVDiag(void *cvode_mem)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiag", MSGDG_CVMEM_NULL);
+    cvProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiag", MSGDG_CVMEM_NULL);
     return(CVDIAG_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -100,7 +105,7 @@ int CVDiag(void *cvode_mem)
   /* Check if N_VCompare and N_VInvTest are present */
   if(vec_tmpl->ops->nvcompare == NULL ||
      vec_tmpl->ops->nvinvtest == NULL) {
-    CVProcessError(cv_mem, CVDIAG_ILL_INPUT, "CVDIAG", "CVDiag", MSGDG_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVDIAG_ILL_INPUT, "CVDIAG", "CVDiag", MSGDG_BAD_NVECTOR);
     return(CVDIAG_ILL_INPUT);
   }
 
@@ -116,7 +121,7 @@ int CVDiag(void *cvode_mem)
   cvdiag_mem = NULL;
   cvdiag_mem = (CVDiagMem) malloc(sizeof(CVDiagMemRec));
   if (cvdiag_mem == NULL) {
-    CVProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
+    cvProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
     return(CVDIAG_MEM_FAIL);
   }
 
@@ -129,14 +134,14 @@ int CVDiag(void *cvode_mem)
     
   M = N_VClone(vec_tmpl);
   if (M == NULL) {
-    CVProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
+    cvProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
     free(cvdiag_mem); cvdiag_mem = NULL;
     return(CVDIAG_MEM_FAIL);
   }
 
   bit = N_VClone(vec_tmpl);
   if (bit == NULL) {
-    CVProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
+    cvProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
     N_VDestroy(M);
     free(cvdiag_mem); cvdiag_mem = NULL;
     return(CVDIAG_MEM_FAIL);
@@ -144,7 +149,7 @@ int CVDiag(void *cvode_mem)
 
   bitcomp = N_VClone(vec_tmpl);
   if (bitcomp == NULL) {
-    CVProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
+    cvProcessError(cv_mem, CVDIAG_MEM_FAIL, "CVDIAG", "CVDiag", MSGDG_MEM_FAIL);
     N_VDestroy(M);
     N_VDestroy(bit);
     free(cvdiag_mem); cvdiag_mem = NULL;
@@ -169,7 +174,7 @@ int CVDiagGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiagGetWorkSpace", MSGDG_CVMEM_NULL);
+    cvProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiagGetWorkSpace", MSGDG_CVMEM_NULL);
     return(CVDIAG_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -193,13 +198,13 @@ int CVDiagGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiagGetNumRhsEvals", MSGDG_CVMEM_NULL);
+    cvProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiagGetNumRhsEvals", MSGDG_CVMEM_NULL);
     return(CVDIAG_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDIAG_LMEM_NULL, "CVDIAG", "CVDiagGetNumRhsEvals", MSGDG_LMEM_NULL);
+    cvProcessError(cv_mem, CVDIAG_LMEM_NULL, "CVDIAG", "CVDiagGetNumRhsEvals", MSGDG_LMEM_NULL);
     return(CVDIAG_LMEM_NULL);
   }
   cvdiag_mem = (CVDiagMem) lmem;
@@ -222,13 +227,13 @@ int CVDiagGetLastFlag(void *cvode_mem, long int *flag)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiagGetLastFlag", MSGDG_CVMEM_NULL);
+    cvProcessError(NULL, CVDIAG_MEM_NULL, "CVDIAG", "CVDiagGetLastFlag", MSGDG_CVMEM_NULL);
     return(CVDIAG_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDIAG_LMEM_NULL, "CVDIAG", "CVDiagGetLastFlag", MSGDG_LMEM_NULL);
+    cvProcessError(cv_mem, CVDIAG_LMEM_NULL, "CVDIAG", "CVDiagGetLastFlag", MSGDG_LMEM_NULL);
     return(CVDIAG_LMEM_NULL);
   }
   cvdiag_mem = (CVDiagMem) lmem;
@@ -338,7 +343,7 @@ static int CVDiagSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   retval = f(tn, y, M, cv_mem->cv_user_data);
   nfeDI++;
   if (retval < 0) {
-    CVProcessError(cv_mem, CVDIAG_RHSFUNC_UNRECVR, "CVDIAG", "CVDiagSetup", MSGDG_RHSFUNC_FAILED);
+    cvProcessError(cv_mem, CVDIAG_RHSFUNC_UNRECVR, "CVDIAG", "CVDiagSetup", MSGDG_RHSFUNC_FAILED);
     last_flag = CVDIAG_RHSFUNC_UNRECVR;
     return(-1);
   }
@@ -423,7 +428,7 @@ static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVDiagFree(CVodeMem cv_mem)
+static int CVDiagFree(CVodeMem cv_mem)
 {
   CVDiagMem cvdiag_mem;
   
@@ -434,4 +439,6 @@ static void CVDiagFree(CVodeMem cv_mem)
   N_VDestroy(bitcomp);
   free(cvdiag_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
diff --git a/src/cvode/cvode_diag_impl.h b/src/cvode/cvode_diag_impl.h
index 9ccf5ad..f39b214 100644
--- a/src/cvode/cvode_diag_impl.h
+++ b/src/cvode/cvode_diag_impl.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:19:48 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the diagonal linear solver, CVDIAG.
  * -----------------------------------------------------------------
@@ -18,12 +23,12 @@
 #ifndef _CVDIAG_IMPL_H
 #define _CVDIAG_IMPL_H
 
+#include <cvode/cvode_diag.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_diag.h>
-
 /*
  * -----------------------------------------------------------------
  * Types: CVDiagMemRec, CVDiagMem
diff --git a/src/cvode/cvode_direct.c b/src/cvode/cvode_direct.c
index 0e2d6e0..da6eba6 100644
--- a/src/cvode/cvode_direct.c
+++ b/src/cvode/cvode_direct.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:21:04 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVDLS linear solvers
  * -----------------------------------------------------------------
@@ -88,13 +93,13 @@ int CVDlsSetDenseJacFn(void *cvode_mem, CVDlsDenseJacFn jac)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsSetDenseJacFn", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsSetDenseJacFn", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsSetDenseJacFn", MSGD_LMEM_NULL);
+    cvProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsSetDenseJacFn", MSGD_LMEM_NULL);
     return(CVDLS_LMEM_NULL);
   }
   cvdls_mem = (CVDlsMem) lmem;
@@ -119,13 +124,13 @@ int CVDlsSetBandJacFn(void *cvode_mem, CVDlsBandJacFn jac)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsSetBandJacFn", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsSetBandJacFn", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsSetBandJacFn", MSGD_LMEM_NULL);
+    cvProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsSetBandJacFn", MSGD_LMEM_NULL);
     return(CVDLS_LMEM_NULL);
   }
   cvdls_mem = (CVDlsMem) lmem;
@@ -151,13 +156,13 @@ int CVDlsGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetWorkSpace", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetWorkSpace", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetWorkSpace", MSGD_LMEM_NULL);
+    cvProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetWorkSpace", MSGD_LMEM_NULL);
     return(CVDLS_LMEM_NULL);
   }
   cvdls_mem = (CVDlsMem) lmem;
@@ -183,13 +188,13 @@ int CVDlsGetNumJacEvals(void *cvode_mem, long int *njevals)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetNumJacEvals", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetNumJacEvals", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetNumJacEvals", MSGD_LMEM_NULL);
+    cvProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetNumJacEvals", MSGD_LMEM_NULL);
     return(CVDLS_LMEM_NULL);
   }
   cvdls_mem = (CVDlsMem) lmem;
@@ -210,13 +215,13 @@ int CVDlsGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetNumRhsEvals", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetNumRhsEvals", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetNumRhsEvals", MSGD_LMEM_NULL);
+    cvProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetNumRhsEvals", MSGD_LMEM_NULL);
     return(CVDLS_LMEM_NULL);
   }
   cvdls_mem = (CVDlsMem) lmem;
@@ -275,13 +280,13 @@ int CVDlsGetLastFlag(void *cvode_mem, long int *flag)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetLastFlag", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVDLS", "CVDlsGetLastFlag", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetLastFlag", MSGD_LMEM_NULL);
+    cvProcessError(cv_mem, CVDLS_LMEM_NULL, "CVDLS", "CVDlsGetLastFlag", MSGD_LMEM_NULL);
     return(CVDLS_LMEM_NULL);
   }
   cvdls_mem = (CVDlsMem) lmem;
@@ -342,10 +347,10 @@ int cvDlsDenseDQJac(long int N, realtype t,
   y_data   = N_VGetArrayPointer(y);
 
   /* Set minimum increment based on uround and norm of f */
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   fnorm = N_VWrmsNorm(fy, ewt);
   minInc = (fnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * N * fnorm) : ONE;
 
   for (j = 0; j < N; j++) {
 
@@ -354,7 +359,7 @@ int cvDlsDenseDQJac(long int N, realtype t,
     N_VSetArrayPointer(DENSE_COL(Jac,j), jthCol);
 
     yjsaved = y_data[j];
-    inc = MAX(srur*ABS(yjsaved), minInc/ewt_data[j]);
+    inc = SUNMAX(srur*SUNRabs(yjsaved), minInc/ewt_data[j]);
     y_data[j] += inc;
 
     retval = f(t, y, ftemp, user_data);
@@ -421,21 +426,21 @@ int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
   N_VScale(ONE, y, ytemp);
 
   /* Set minimum increment based on uround and norm of f */
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   fnorm = N_VWrmsNorm(fy, ewt);
   minInc = (fnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * N * fnorm) : ONE;
 
   /* Set bandwidth and number of column groups for band differencing */
   width = mlower + mupper + 1;
-  ngroups = MIN(width, N);
+  ngroups = SUNMIN(width, N);
 
   /* Loop over column groups. */
   for (group=1; group <= ngroups; group++) {
     
     /* Increment all y_j in group */
     for(j=group-1; j < N; j+=width) {
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       ytemp_data[j] += inc;
     }
 
@@ -449,10 +454,10 @@ int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
     for (j=group-1; j < N; j+=width) {
       ytemp_data[j] = y_data[j];
       col_j = BAND_COL(Jac,j);
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mupper);
-      i2 = MIN(j+mlower, N-1);
+      i1 = SUNMAX(0, j-mupper);
+      i2 = SUNMIN(j+mlower, N-1);
       for (i=i1; i <= i2; i++)
         BAND_COL_ELEM(col_j,i,j) = inc_inv * (ftemp_data[i] - fy_data[i]);
     }
@@ -461,3 +466,10 @@ int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
   return(retval);
 }
 
+int cvDlsInitializeCounters(CVDlsMem cvdls_mem)
+{
+  cvdls_mem->d_nje   = 0;
+  cvdls_mem->d_nfeDQ = 0;
+  cvdls_mem->d_nstlj = 0;
+  return(0);
+}
diff --git a/src/cvode/cvode_direct_impl.h b/src/cvode/cvode_direct_impl.h
index 75ee016..e189b5f 100644
--- a/src/cvode/cvode_direct_impl.h
+++ b/src/cvode/cvode_direct_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:19:48 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common implementation header file for the CVDLS linear solvers.
  * -----------------------------------------------------------------
@@ -17,12 +22,12 @@
 #ifndef _CVDLS_IMPL_H
 #define _CVDLS_IMPL_H
 
+#include "cvode/cvode_direct.h"
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_direct.h>
-
 /*
  * -----------------------------------------------------------------
  * CVDLS solver constants
@@ -81,15 +86,17 @@ typedef struct CVDlsMemRec {
  */
 
 int cvDlsDenseDQJac(long int N, realtype t,
-		    N_Vector y, N_Vector fy, 
-		    DlsMat Jac, void *data,
-		    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                    N_Vector y, N_Vector fy, 
+                    DlsMat Jac, void *data,
+                    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
   
 int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
-		   realtype t, N_Vector y, N_Vector fy, 
-		   DlsMat Jac, void *data,
-		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                   realtype t, N_Vector y, N_Vector fy, 
+                   DlsMat Jac, void *data,
+                   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
 
+/* Auxilliary functions */
+int cvDlsInitializeCounters(CVDlsMem cvdls_mem);
 
 /*
  * -----------------------------------------------------------------
diff --git a/src/cvode/cvode_impl.h b/src/cvode/cvode_impl.h
index 5c4010f..21d9f38 100644
--- a/src/cvode/cvode_impl.h
+++ b/src/cvode/cvode_impl.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2007/11/26 16:19:59 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban
  *                and Dan Shumaker @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the main CVODE integrator.
  * -----------------------------------------------------------------
@@ -18,14 +23,13 @@
 #ifndef _CVODE_IMPL_H
 #define _CVODE_IMPL_H
 
+#include <stdarg.h>
+#include <cvode/cvode.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <stdarg.h>
-
-#include <cvode/cvode.h>
-
 /*
  * =================================================================
  *   M A I N    I N T E G R A T O R    M E M O R Y    B L O C K
@@ -200,7 +204,7 @@ typedef struct CVodeMemRec {
   int (*cv_lsolve)(struct CVodeMemRec *cv_mem, N_Vector b, N_Vector weight,
 		   N_Vector ycur, N_Vector fcur);
 
-  void (*cv_lfree)(struct CVodeMemRec *cv_mem);
+  int (*cv_lfree)(struct CVodeMemRec *cv_mem);
 
   /* Linear Solver specific memory */
 
@@ -389,11 +393,12 @@ typedef struct CVodeMemRec {
 
 /*
  * -----------------------------------------------------------------
- * void (*cv_lfree)(CVodeMem cv_mem);
+ * int (*cv_lfree)(CVodeMem cv_mem);
  * -----------------------------------------------------------------
  * cv_lfree should free up any memory allocated by the linear
  * solver. This routine is called once a problem has been
- * completed and the linear solver is no longer needed.
+ * completed and the linear solver is no longer needed.  It should 
+ * return 0 upon success, nonzero on failure.
  * -----------------------------------------------------------------
  */
   
@@ -405,17 +410,17 @@ typedef struct CVodeMemRec {
 
 /* Prototype of internal ewtSet function */
 
-int CVEwtSet(N_Vector ycur, N_Vector weight, void *data);
+int cvEwtSet(N_Vector ycur, N_Vector weight, void *data);
 
 /* High level error handler */
 
-void CVProcessError(CVodeMem cv_mem, 
+void cvProcessError(CVodeMem cv_mem, 
 		    int error_code, const char *module, const char *fname, 
 		    const char *msgfmt, ...);
 
-/* Prototype of internal errHandler function */
+/* Prototype of internal ErrHandler function */
 
-void CVErrHandler(int error_code, const char *module, const char *function, 
+void cvErrHandler(int error_code, const char *module, const char *function, 
 		  char *msg, void *data);
 
 /*
diff --git a/src/cvode/cvode_io.c b/src/cvode/cvode_io.c
index 2645ca1..bc50ffb 100644
--- a/src/cvode/cvode_io.c
+++ b/src/cvode/cvode_io.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2010/12/01 22:21:04 $
+ * $Revision: 4210 $
+ * $Date: 2014-08-27 15:40:02 -0700 (Wed, 27 Aug 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the optional input and output
  * functions for the CVODE solver.
@@ -46,7 +51,7 @@ int CVodeSetErrHandlerFn(void *cvode_mem, CVErrHandlerFn ehfun, void *eh_data)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetErrHandlerFn", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetErrHandlerFn", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -69,7 +74,7 @@ int CVodeSetErrFile(void *cvode_mem, FILE *errfp)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetErrFile", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetErrFile", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -91,14 +96,14 @@ int CVodeSetIterType(void *cvode_mem, int iter)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetIterType", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetIterType", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
   cv_mem = (CVodeMem) cvode_mem;
 
   if ((iter != CV_FUNCTIONAL) && (iter != CV_NEWTON)) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetIterType", MSGCV_BAD_ITER);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetIterType", MSGCV_BAD_ITER);
     return (CV_ILL_INPUT);
   }
 
@@ -118,7 +123,7 @@ int CVodeSetUserData(void *cvode_mem, void *user_data)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetUserData", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetUserData", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -141,14 +146,14 @@ int CVodeSetMaxOrd(void *cvode_mem, int maxord)
   int qmax_alloc;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxOrd", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxOrd", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
   cv_mem = (CVodeMem) cvode_mem;
 
   if (maxord <= 0) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxOrd", MSGCV_NEG_MAXORD);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxOrd", MSGCV_NEG_MAXORD);
     return(CV_ILL_INPUT);
   }
   
@@ -157,7 +162,7 @@ int CVodeSetMaxOrd(void *cvode_mem, int maxord)
   qmax_alloc = cv_mem->cv_qmax_alloc;
 
   if (maxord > qmax_alloc) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxOrd", MSGCV_BAD_MAXORD);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxOrd", MSGCV_BAD_MAXORD);
     return(CV_ILL_INPUT);
   }
 
@@ -177,7 +182,7 @@ int CVodeSetMaxNumSteps(void *cvode_mem, long int mxsteps)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxNumSteps", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxNumSteps", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -204,7 +209,7 @@ int CVodeSetMaxHnilWarns(void *cvode_mem, int mxhnil)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxHnilWarns", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxHnilWarns", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -226,14 +231,14 @@ int CVodeSetStabLimDet(void *cvode_mem, booleantype sldet)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetStabLimDet", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetStabLimDet", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
   cv_mem = (CVodeMem) cvode_mem;
 
   if( sldet && (cv_mem->cv_lmm != CV_BDF) ) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetStabLimDet", MSGCV_SET_SLDET);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetStabLimDet", MSGCV_SET_SLDET);
     return(CV_ILL_INPUT);
   }
 
@@ -253,7 +258,7 @@ int CVodeSetInitStep(void *cvode_mem, realtype hin)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetInitStep", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetInitStep", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -275,14 +280,14 @@ int CVodeSetMinStep(void *cvode_mem, realtype hmin)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMinStep", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMinStep", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
   cv_mem = (CVodeMem) cvode_mem;
 
   if (hmin<0) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMinStep", MSGCV_NEG_HMIN);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMinStep", MSGCV_NEG_HMIN);
     return(CV_ILL_INPUT);
   }
 
@@ -293,7 +298,7 @@ int CVodeSetMinStep(void *cvode_mem, realtype hmin)
   }
 
   if (hmin * cv_mem->cv_hmax_inv > ONE) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMinStep", MSGCV_BAD_HMIN_HMAX);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMinStep", MSGCV_BAD_HMIN_HMAX);
     return(CV_ILL_INPUT);
   }
 
@@ -314,14 +319,14 @@ int CVodeSetMaxStep(void *cvode_mem, realtype hmax)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxStep", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxStep", MSGCV_NO_MEM);
     return (CV_MEM_NULL);
   }
 
   cv_mem = (CVodeMem) cvode_mem;
 
   if (hmax < 0) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxStep", MSGCV_NEG_HMAX);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxStep", MSGCV_NEG_HMAX);
     return(CV_ILL_INPUT);
   }
 
@@ -333,7 +338,7 @@ int CVodeSetMaxStep(void *cvode_mem, realtype hmax)
 
   hmax_inv = ONE/hmax;
   if (hmax_inv * cv_mem->cv_hmin > ONE) {
-    CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxStep", MSGCV_BAD_HMIN_HMAX);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetMaxStep", MSGCV_BAD_HMIN_HMAX);
     return(CV_ILL_INPUT);
   }
 
@@ -353,7 +358,7 @@ int CVodeSetStopTime(void *cvode_mem, realtype tstop)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetStopTime", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetStopTime", MSGCV_NO_MEM);
     return (CV_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -365,7 +370,7 @@ int CVodeSetStopTime(void *cvode_mem, realtype tstop)
   if (cv_mem->cv_nst > 0) {
 
     if ( (tstop - cv_mem->cv_tn) * cv_mem->cv_h < ZERO ) {
-      CVProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetStopTime", MSGCV_BAD_TSTOP, cv_mem->cv_tn);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODE", "CVodeSetStopTime", MSGCV_BAD_TSTOP, tstop, cv_mem->cv_tn);
       return(CV_ILL_INPUT);
     }
 
@@ -389,7 +394,7 @@ int CVodeSetMaxErrTestFails(void *cvode_mem, int maxnef)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxErrTestFails", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxErrTestFails", MSGCV_NO_MEM);
     return (CV_MEM_NULL);
   }
 
@@ -412,7 +417,7 @@ int CVodeSetMaxConvFails(void *cvode_mem, int maxncf)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxConvFails", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxConvFails", MSGCV_NO_MEM);
     return (CV_MEM_NULL);
   }
 
@@ -435,7 +440,7 @@ int CVodeSetMaxNonlinIters(void *cvode_mem, int maxcor)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxNonlinIters", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetMaxNonlinIters", MSGCV_NO_MEM);
     return (CV_MEM_NULL);
   }
 
@@ -458,7 +463,7 @@ int CVodeSetNonlinConvCoef(void *cvode_mem, realtype nlscoef)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetNonlinConvCoef", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetNonlinConvCoef", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -482,7 +487,7 @@ int CVodeSetRootDirection(void *cvode_mem, int *rootdir)
   int i, nrt;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetRootDirection", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetRootDirection", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -490,7 +495,7 @@ int CVodeSetRootDirection(void *cvode_mem, int *rootdir)
 
   nrt = cv_mem->cv_nrtfn;
   if (nrt==0) {
-    CVProcessError(NULL, CV_ILL_INPUT, "CVODE", "CVodeSetRootDirection", MSGCV_NO_ROOT);
+    cvProcessError(NULL, CV_ILL_INPUT, "CVODE", "CVodeSetRootDirection", MSGCV_NO_ROOT);
     return(CV_ILL_INPUT);    
   }
 
@@ -511,7 +516,7 @@ int CVodeSetNoInactiveRootWarn(void *cvode_mem)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetNoInactiveRootWarn", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeSetNoInactiveRootWarn", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -567,7 +572,7 @@ int CVodeGetNumSteps(void *cvode_mem, long int *nsteps)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumSteps", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumSteps", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -589,7 +594,7 @@ int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevals)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumRhsEvals", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumRhsEvals", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -611,7 +616,7 @@ int CVodeGetNumLinSolvSetups(void *cvode_mem, long int *nlinsetups)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumLinSolvSetups", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumLinSolvSetups", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -633,7 +638,7 @@ int CVodeGetNumErrTestFails(void *cvode_mem, long int *netfails)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumErrTestFails", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumErrTestFails", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -655,7 +660,7 @@ int CVodeGetLastOrder(void *cvode_mem, int *qlast)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetLastOrder", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetLastOrder", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -677,7 +682,7 @@ int CVodeGetCurrentOrder(void *cvode_mem, int *qcur)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetCurrentOrder", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetCurrentOrder", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -700,7 +705,7 @@ int CVodeGetNumStabLimOrderReds(void *cvode_mem, long int *nslred)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumStabLimOrderReds", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumStabLimOrderReds", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -725,7 +730,7 @@ int CVodeGetActualInitStep(void *cvode_mem, realtype *hinused)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetActualInitStep", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetActualInitStep", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -747,7 +752,7 @@ int CVodeGetLastStep(void *cvode_mem, realtype *hlast)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetLastStep", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetLastStep", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -769,7 +774,7 @@ int CVodeGetCurrentStep(void *cvode_mem, realtype *hcur)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetCurrentStep", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetCurrentStep", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -791,7 +796,7 @@ int CVodeGetCurrentTime(void *cvode_mem, realtype *tcur)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetCurrentTime", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetCurrentTime", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -813,7 +818,7 @@ int CVodeGetTolScaleFactor(void *cvode_mem, realtype *tolsfact)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetTolScaleFactor", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetTolScaleFactor", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -835,7 +840,7 @@ int CVodeGetErrWeights(void *cvode_mem, N_Vector eweight)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetErrWeights", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetErrWeights", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -857,7 +862,7 @@ int CVodeGetEstLocalErrors(void *cvode_mem, N_Vector ele)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetEstLocalErrors", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetEstLocalErrors", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -879,7 +884,7 @@ int CVodeGetWorkSpace(void *cvode_mem, long int *lenrw, long int *leniw)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetWorkSpace", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetWorkSpace", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -905,7 +910,7 @@ int CVodeGetIntegratorStats(void *cvode_mem, long int *nsteps, long int *nfevals
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetIntegratorStats", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetIntegratorStats", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -936,7 +941,7 @@ int CVodeGetNumGEvals(void *cvode_mem, long int *ngevals)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumGEvals", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumGEvals", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -959,7 +964,7 @@ int CVodeGetRootInfo(void *cvode_mem, int *rootsfound)
   int i, nrt;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetRootInfo", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetRootInfo", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -984,7 +989,7 @@ int CVodeGetNumNonlinSolvIters(void *cvode_mem, long int *nniters)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumNonlinSolvIters", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumNonlinSolvIters", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -1007,7 +1012,7 @@ int CVodeGetNumNonlinSolvConvFails(void *cvode_mem, long int *nncfails)
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumNonlinSolvConvFails", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNumNonlinSolvConvFails", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
@@ -1030,7 +1035,7 @@ int CVodeGetNonlinSolvStats(void *cvode_mem, long int *nniters,
   CVodeMem cv_mem;
 
   if (cvode_mem==NULL) {
-    CVProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNonlinSolvStats", MSGCV_NO_MEM);
+    cvProcessError(NULL, CV_MEM_NULL, "CVODE", "CVodeGetNonlinSolvStats", MSGCV_NO_MEM);
     return(CV_MEM_NULL);
   }
 
diff --git a/src/cvode/cvode_klu.c b/src/cvode/cvode_klu.c
new file mode 100644
index 0000000..9814c39
--- /dev/null
+++ b/src/cvode/cvode_klu.c
@@ -0,0 +1,612 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the CVKLU linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cvode/cvode_klu.h"
+#include "cvode_impl.h"
+#include "cvode_sparse_impl.h"
+#include "sundials/sundials_klu_impl.h"
+#include "sundials/sundials_math.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+#define TWOTHIRDS    RCONST(0.6666666666666667)
+
+/* CVKLU linit, lsetup, lsolve, and lfree routines */
+ 
+static int cvKLUInit(CVodeMem cv_mem);
+
+static int cvKLUSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+		      N_Vector fpred, booleantype *jcurPtr,
+		      N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int cvKLUSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+		      N_Vector ycur, N_Vector fcur);
+
+static int cvKLUFree(CVodeMem cv_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLU
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the CVODE / KLU linear solver module.  
+ * CVKLU first calls the existing lfree routine if this is not NULL.
+ * Then it sets the cv_linit, cv_lsetup, cv_lsolve, cv_lperf, and
+ * cv_lfree fields in (*cv_mem) to be CVKLUInit, CVKLUSetup,
+ * CVKLUSolve, NULL, and CVKLUFree, respectively.
+ * It allocates memory for a structure of type CVkluMemRec and sets
+ * the cv_lmem field in (*cvode_mem) to the address of this structure.
+ * It sets setupNonNull in (*cvode_mem) to TRUE.
+ * Finally, it allocates memory for KLU.
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_LMEM_FAIL = -1,
+ * or CVSLS_ILL_INPUT = -2.
+ *
+ * NOTE: The KLU linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, CVKLU will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int CVKLU(void *cvode_mem, int n, int nnz, int sparsetype)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+  int flag;
+
+  /* Return immediately if cv_mem is NULL. */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "cvKLU", 
+                   MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (cv_mem->cv_tempv->ops->nvgetarraypointer == NULL) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSLS", "cvKLU", 
+                   MSGSP_BAD_NVECTOR);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  if (cv_mem->cv_lfree != NULL) cv_mem->cv_lfree(cv_mem);
+
+  /* Set five main function fields in cv_mem. */
+  cv_mem->cv_linit  = cvKLUInit;
+  cv_mem->cv_lsetup = cvKLUSetup;
+  cv_mem->cv_lsolve = cvKLUSolve;
+  cv_mem->cv_lfree  = cvKLUFree;
+
+  /* Get memory for CVSlsMemRec. */
+  cvsls_mem = (CVSlsMem) malloc(sizeof(struct CVSlsMemRec));
+  if (cvsls_mem == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Get memory for KLUData. */
+  klu_data = (KLUData)malloc(sizeof(struct KLUDataRec));
+  if (klu_data == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  cv_mem->cv_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  cvsls_mem->s_jaceval = NULL;
+  cvsls_mem->s_jacdata = NULL;
+  cvsls_mem->sparsetype = sparsetype;
+
+  /* Allocate memory for the sparse Jacobian */
+  cvsls_mem->s_JacMat = SparseNewMat(n, n, nnz, sparsetype);
+  if (cvsls_mem->s_JacMat == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Allocate memory for saved sparse Jacobian */
+  cvsls_mem->s_savedJ = SparseNewMat(n, n, nnz, sparsetype);
+  if (cvsls_mem->s_savedJ == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Initialize KLU structures */
+  switch (sparsetype) {
+    case CSC_MAT:
+      klu_data->sun_klu_solve = &klu_solve;
+      break;
+    case CSR_MAT:
+      klu_data->sun_klu_solve = &klu_tsolve;
+      break;
+    default:
+      SparseDestroyMat(cvsls_mem->s_JacMat);
+      free(klu_data);
+      free(cvsls_mem);
+      return(CVSLS_ILL_INPUT);
+  }
+  klu_data->s_Symbolic = NULL;
+  klu_data->s_Numeric = NULL;
+
+  /* Set default parameters for KLU */
+  flag = klu_defaults(&klu_data->s_Common);
+  if (flag == 0) {
+    cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_PACKAGE_FAIL);
+    return(CVSLS_PACKAGE_FAIL);
+  }
+
+  /* Set ordering to COLAMD as the cvode default use.
+     Users can set a different value with CVKLUSetOrdering,
+     and the user-set value is loaded before any call to klu_analyze in
+     CVKLUSetup.  */
+  klu_data->s_ordering = 1;
+  klu_data->s_Common.ordering = klu_data->s_ordering;
+
+  /* Attach linear solver memory to the integrator memory */
+  cvsls_mem->s_solver_data = (void *) klu_data;
+  cv_mem->cv_lmem = cvsls_mem;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to CVKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_MEM_NULL = -1,
+ * CVSLS_LMEM_NULL = -2, CVSLS_ILL_INPUT = -3, or CVSLS_MEM_FAIL = -4.
+ * -----------------------------------------------------------------
+ */
+
+int CVKLUReInit(void *cvode_mem, int n, int nnz, int reinit_type)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if cv_mem is NULL. */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVKLUReInit", 
+                   MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Return immediately if cv_lmem is NULL. */
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(NULL, CVSLS_LMEM_NULL, "CVSLS", "CVKLUReInit", 
+                   MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) (cv_mem->cv_lmem);
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  /* Return if reinit_type is not valid */
+  if ((reinit_type != 1) && (reinit_type != 2)) {
+    cvProcessError(NULL, CVSLS_ILL_INPUT, "CVSLS", "CVKLUReInit", 
+                   MSGSP_ILL_INPUT);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  if (reinit_type == 1) {
+
+    /* Destroy previous Jacobian information */
+    if (cvsls_mem->s_JacMat) {
+      SparseDestroyMat(cvsls_mem->s_JacMat);
+    }
+
+    /* Allocate memory for the sparse Jacobian */
+    cvsls_mem->s_JacMat = SparseNewMat(n, n, nnz, cvsls_mem->sparsetype);
+    if (cvsls_mem->s_JacMat == NULL) {
+      cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "CVKLU", 
+                     MSGSP_MEM_FAIL);
+      return(CVSLS_MEM_FAIL);
+    }
+  }
+
+  /* Free the prior factorazation and reset for first factorization */
+  if( klu_data->s_Symbolic != NULL)
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  if( klu_data->s_Numeric != NULL)
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  cvsls_mem->s_first_factorize = 1;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLU interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the CVKLU
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int cvKLUInit(CVodeMem cv_mem)
+{
+  CVSlsMem cvsls_mem;
+
+  cvsls_mem = (CVSlsMem)cv_mem->cv_lmem;
+
+  cvsls_mem->s_jacdata = cv_mem->cv_user_data;
+
+  cvsls_mem->s_nje = 0;
+  /* This forces factorization for every call to CVODE */
+  cvsls_mem->s_first_factorize = 1;
+  cvsls_mem->s_nstlj = 0;
+
+  cvsls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the CVKLU linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     CVSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int cvKLUSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+		      N_Vector fpred, booleantype *jcurPtr,
+		      N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  int retval;
+  long int nst, nstlj;
+  realtype tn, gamma, gammap, dgamma;
+  CVSlsMem cvsls_mem;
+  CVSlsSparseJacFn jaceval;
+  KLUData klu_data;
+  SlsMat JacMat, savedJ;
+  void *jacdata;
+  
+  realtype uround_twothirds;
+
+  uround_twothirds = SUNRpowerR(cv_mem->cv_uround,TWOTHIRDS);
+
+  cvsls_mem = (CVSlsMem) (cv_mem->cv_lmem);
+  tn = cv_mem->cv_tn; 
+  gamma = cv_mem->cv_gamma;
+  gammap = cv_mem->cv_gammap;
+  nst = cv_mem->cv_nst;
+
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  jaceval = cvsls_mem->s_jaceval;
+  jacdata = cvsls_mem->s_jacdata;
+  JacMat = cvsls_mem->s_JacMat;
+  savedJ = cvsls_mem->s_savedJ;
+  nstlj = cvsls_mem->s_nstlj;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    cvProcessError(cv_mem, CVSLS_JAC_NOSET, "CVSLS", "cvKLUSetup", 
+		    MSGSP_JAC_NOSET);
+    free(cvsls_mem); cvsls_mem = NULL;
+    return(CVSLS_JAC_NOSET);
+  }
+
+  /* Determine whether Jacobian needs to be recalculated */
+  dgamma = SUNRabs((gamma/gammap) - ONE);
+  jbad = (nst == 0) || (nst > nstlj + CVS_MSBJ) ||
+         ((convfail == CV_FAIL_BAD_J) && (dgamma < CVS_DGMAX)) ||
+         (convfail == CV_FAIL_OTHER);
+  jok = !jbad;
+  
+  if (jok) {
+    /* If jok = TRUE, use saved copy of J */
+    *jcurPtr = FALSE;
+    SparseCopyMat(savedJ, JacMat);
+  } else {
+    /* If jok = FALSE, call jac routine for new J value */
+    cvsls_mem->s_nje++;
+    cvsls_mem->s_nstlj = nst;
+    *jcurPtr = TRUE;
+    SparseSetMatToZero(JacMat);
+    retval = jaceval(tn, ypred, fpred, JacMat, jacdata, vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      cvProcessError(cv_mem, CVSLS_JACFUNC_UNRECVR, "CVSLS", "cvKLUSetup", MSGSP_JACFUNC_FAILED);
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_RECVR;
+      return(1);
+    }
+
+    SparseCopyMat(JacMat, savedJ);
+  }
+
+  /* Scale and add I to get M = I - gamma*J */
+  SparseScaleMat(-gamma, JacMat);
+  SparseAddIdentityMat(JacMat);
+
+  if (cvsls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get the symbolic factorization
+       ------------------------------------------------------------*/ 
+    /* Update the ordering option with any user-updated values from 
+       calls to CVKLUSetOrdering */
+    klu_data->s_Common.ordering = klu_data->s_ordering;
+
+    if (klu_data->s_Symbolic != NULL) {
+       klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    }
+    klu_data->s_Symbolic = klu_analyze(JacMat->NP, JacMat->indexptrs, 
+				       JacMat->indexvals, &(klu_data->s_Common));
+    if (klu_data->s_Symbolic == NULL) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+
+    /* ------------------------------------------------------------
+       Compute the LU factorization of  the Jacobian.
+       ------------------------------------------------------------*/
+    /* If klu_factor previously called, free data */
+    if( klu_data->s_Numeric != NULL) {
+       klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    }
+    klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+				     JacMat->data, 
+				     klu_data->s_Symbolic, &(klu_data->s_Common));
+
+    if (klu_data->s_Numeric == NULL) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+
+    cvsls_mem->s_first_factorize = 0;
+  }
+  else {
+
+    retval = klu_refactor(JacMat->indexptrs, JacMat->indexvals, JacMat->data, 
+			  klu_data->s_Symbolic, klu_data->s_Numeric,
+			  &(klu_data->s_Common));
+    if (retval == 0) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "cvKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+    
+    /*-----------------------------------------------------------
+      Check if a cheap estimate of the reciprocal of the condition 
+      number is getting too small.  If so, delete
+      the prior numeric factorization and recompute it.
+      -----------------------------------------------------------*/
+    
+    retval = klu_rcond(klu_data->s_Symbolic, klu_data->s_Numeric,
+		       &(klu_data->s_Common));
+    if (retval == 0) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+
+    if ( (klu_data->s_Common.rcond)  < uround_twothirds ) {
+      
+      /* Condition number may be getting large.  
+	 Compute more accurate estimate */
+      retval = klu_condest(JacMat->indexptrs, JacMat->data, 
+			   klu_data->s_Symbolic, klu_data->s_Numeric,
+			   &(klu_data->s_Common));
+      if (retval == 0) {
+	cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		       MSGSP_PACKAGE_FAIL);
+	return(CVSLS_PACKAGE_FAIL);
+      }
+      
+      if ( (klu_data->s_Common.condest) > 
+	   (1.0/uround_twothirds) ) {
+
+	/* More accurate estimate also says condition number is 
+	   large, so recompute the numeric factorization */
+
+	klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+	
+	klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+					 JacMat->data, klu_data->s_Symbolic, 
+					 &(klu_data->s_Common));
+
+	if (klu_data->s_Numeric == NULL) {
+	  cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+			 MSGSP_PACKAGE_FAIL);
+	  return(CVSLS_PACKAGE_FAIL);
+	}
+      }
+    }
+  }
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+  
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the CVKLU linear
+  solver module.  It calls the KLU solve routine,
+  then returns CVSLS_SUCCESS = 0.
+*/
+
+static int cvKLUSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+		      N_Vector ycur, N_Vector fcur)
+{
+  int flag, lmm;
+  realtype gamrat;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+  SlsMat JacMat;
+  realtype *bd;
+  
+  gamrat = cv_mem->cv_gamrat;
+  lmm = cv_mem->cv_lmm;
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  JacMat = cvsls_mem->s_JacMat;
+
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  bd = N_VGetArrayPointer(b);
+
+  /* Call KLU to solve the linear system */
+  flag = klu_data->sun_klu_solve(klu_data->s_Symbolic, klu_data->s_Numeric, JacMat->NP, 1, bd, 
+                                 &(klu_data->s_Common));
+  if (flag == 0) {
+    cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSolve", 
+		    MSGSP_PACKAGE_FAIL);
+    return(CVSLS_PACKAGE_FAIL);
+  }
+
+  /* Scale the correction to account for change in gamma. */
+  if ((lmm == CV_BDF) && (gamrat != ONE)) {
+    N_VScale(TWO/(ONE + gamrat), b, b);
+  }
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+  return(CVSLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the CVKLU linear solver.
+*/
+
+static int cvKLUFree(CVodeMem cv_mem)
+{
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+  
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  if( klu_data->s_Numeric != NULL)
+  {
+     klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  }
+  if( klu_data->s_Symbolic != NULL)
+  {
+     klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  }
+
+  if (cvsls_mem->s_JacMat) {
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    cvsls_mem->s_JacMat = NULL;
+  }
+
+  if (cvsls_mem->s_savedJ) {
+    SparseDestroyMat(cvsls_mem->s_savedJ);
+    cvsls_mem->s_savedJ = NULL;
+  }
+
+  free(klu_data); 
+  free(cv_mem->cv_lmem); 
+
+  return(0);
+}
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in CVODE is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int CVKLUSetOrdering(void *cv_mem_v, int ordering_choice)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+
+ /* Return immediately if cv_mem is NULL */
+  if (cv_mem_v == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVKLUSetOrdering",
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cv_mem_v;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) ) {
+    cvProcessError(NULL, CVSLS_ILL_INPUT, "CVSLS", "CVKLUSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  klu_data->s_ordering = ordering_choice;
+
+  return(CVSLS_SUCCESS);
+}
diff --git a/src/cvode/cvode_lapack.c b/src/cvode/cvode_lapack.c
index c058bea..bb26876 100644
--- a/src/cvode/cvode_lapack.c
+++ b/src/cvode/cvode_lapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.15 $
- * $Date: 2011/03/23 22:45:54 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a CVODE dense linear solver
  * using BLAS and LAPACK functions.
@@ -55,7 +60,7 @@ static int cvLapackDenseSetup(CVodeMem cv_mem, int convfail,
                               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
 static int cvLapackDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                               N_Vector yC, N_Vector fctC);
-static void cvLapackDenseFree(CVodeMem cv_mem);
+static int cvLapackDenseFree(CVodeMem cv_mem);
 
 /* CVLAPACK BAND linit, lsetup, lsolve, and lfree routines */ 
 static int cvLapackBandInit(CVodeMem cv_mem);
@@ -65,7 +70,7 @@ static int cvLapackBandSetup(CVodeMem cv_mem, int convfail,
                              N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
 static int cvLapackBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                              N_Vector yC, N_Vector fctC);
-static void cvLapackBandFree(CVodeMem cv_mem);
+static int cvLapackBandFree(CVodeMem cv_mem);
 
 /*
  * =================================================================
@@ -145,7 +150,7 @@ int CVLapackDense(void *cvode_mem, int N)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVLAPACK", "CVLapackDense", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVLAPACK", "CVLapackDense", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
@@ -153,7 +158,7 @@ int CVLapackDense(void *cvode_mem, int N)
   /* Test if the NVECTOR package is compatible with the LAPACK solver */
   if (tempv->ops->nvgetarraypointer == NULL ||
       tempv->ops->nvsetarraypointer == NULL) {
-    CVProcessError(cv_mem, CVDLS_ILL_INPUT, "CVLAPACK", "CVLapackDense", MSGD_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVLAPACK", "CVLapackDense", MSGD_BAD_NVECTOR);
     return(CVDLS_ILL_INPUT);
   }
 
@@ -169,7 +174,7 @@ int CVLapackDense(void *cvode_mem, int N)
   cvdls_mem = NULL;
   cvdls_mem = (CVDlsMem) malloc(sizeof(struct CVDlsMemRec));
   if (cvdls_mem == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
     return(CVDLS_MEM_FAIL);
   }
 
@@ -182,6 +187,7 @@ int CVLapackDense(void *cvode_mem, int N)
   J_data = NULL;
 
   last_flag = CVDLS_SUCCESS;
+  cvDlsInitializeCounters(cvdls_mem);
   setupNonNull = TRUE;
 
   /* Set problem dimension */
@@ -194,20 +200,20 @@ int CVLapackDense(void *cvode_mem, int N)
 
   M = NewDenseMat(n, n);
   if (M == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
   }
   pivots = NewIntArray(N);
   if (pivots == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
     DestroyMat(M);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
   }
   savedJ = NewDenseMat(n, n);
   if (savedJ == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackDense", MSGD_MEM_FAIL);
     DestroyMat(M);
     DestroyArray(pivots);
     free(cvdls_mem); cvdls_mem = NULL;
@@ -252,14 +258,14 @@ int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVDLS_MEM_NULL, "CVLAPACK", "CVLapackBand", MSGD_CVMEM_NULL);
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVLAPACK", "CVLapackBand", MSGD_CVMEM_NULL);
     return(CVDLS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Test if the NVECTOR package is compatible with the BAND solver */
   if (tempv->ops->nvgetarraypointer == NULL) {
-    CVProcessError(cv_mem, CVDLS_ILL_INPUT, "CVLAPACK", "CVLapackBand", MSGD_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVLAPACK", "CVLapackBand", MSGD_BAD_NVECTOR);
     return(CVDLS_ILL_INPUT);
   }
 
@@ -275,7 +281,7 @@ int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
   cvdls_mem = NULL;
   cvdls_mem = (CVDlsMem) malloc(sizeof(struct CVDlsMemRec));
   if (cvdls_mem == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
     return(CVDLS_MEM_FAIL);
   }
 
@@ -288,6 +294,7 @@ int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
   J_data = NULL;
 
   last_flag = CVDLS_SUCCESS;
+  cvDlsInitializeCounters(cvdls_mem);
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -299,13 +306,13 @@ int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
 
   /* Test ml and mu for legality */
   if ((ml < 0) || (mu < 0) || (ml >= n) || (mu >= n)) {
-    CVProcessError(cv_mem, CVDLS_ILL_INPUT, "CVLAPACK", "CVLapackBand", MSGD_BAD_SIZES);
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVLAPACK", "CVLapackBand", MSGD_BAD_SIZES);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_ILL_INPUT);
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(n-1, mu + ml);
+  smu = mu + ml;
 
   /* Allocate memory for M, pivot array, and savedJ */
   M = NULL;
@@ -314,20 +321,20 @@ int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
 
   M = NewBandMat(n, mu, ml, smu);
   if (M == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
   }  
   pivots = NewIntArray(N);
   if (pivots == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
     DestroyMat(M);
     free(cvdls_mem); cvdls_mem = NULL;
     return(CVDLS_MEM_FAIL);
   }
   savedJ = NewBandMat(n, mu, ml, smu);
   if (savedJ == NULL) {
-    CVProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
+    cvProcessError(cv_mem, CVDLS_MEM_FAIL, "CVLAPACK", "CVLapackBand", MSGD_MEM_FAIL);
     DestroyMat(M);
     DestroyArray(pivots);
     free(cvdls_mem); cvdls_mem = NULL;
@@ -356,9 +363,7 @@ static int cvLapackDenseInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
   
-  nje   = 0;
-  nfeDQ = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -395,7 +400,7 @@ static int cvLapackDenseSetup(CVodeMem cv_mem, int convfail,
   lenmat = M->ldata ;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
     ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
     (convfail == CV_FAIL_OTHER);
@@ -420,7 +425,7 @@ static int cvLapackDenseSetup(CVodeMem cv_mem, int convfail,
     if (retval == 0) {
       dcopy_f77(&lenmat, M->data, &one, savedJ->data, &one);
     } else if (retval < 0) {
-      CVProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVLAPACK", "cvLapackDenseSetup", MSGD_JACFUNC_FAILED);
+      cvProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVLAPACK", "cvLapackDenseSetup", MSGD_JACFUNC_FAILED);
       last_flag = CVDLS_JACFUNC_UNRECVR;
       return(-1);
     } else if (retval > 0) {
@@ -480,7 +485,7 @@ static int cvLapackDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
 /*
  * cvLapackDenseFree frees memory specific to the dense linear solver.
  */
-static void cvLapackDenseFree(CVodeMem cv_mem)
+static int cvLapackDenseFree(CVodeMem cv_mem)
 {
   CVDlsMem  cvdls_mem;
 
@@ -491,6 +496,8 @@ static void cvLapackDenseFree(CVodeMem cv_mem)
   DestroyMat(savedJ);
   free(cvdls_mem); 
   cvdls_mem = NULL;
+
+  return(0);
 }
 
 /* 
@@ -509,9 +516,7 @@ static int cvLapackBandInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
 
-  nje   = 0;
-  nfeDQ = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -551,7 +556,7 @@ static int cvLapackBandSetup(CVodeMem cv_mem, int convfail,
   ldmat = M->ldim;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
     ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
     (convfail == CV_FAIL_OTHER);
@@ -575,7 +580,7 @@ static int cvLapackBandSetup(CVodeMem cv_mem, int convfail,
     if (retval == 0) {
       dcopy_f77(&lenmat, M->data, &one, savedJ->data, &one);
     } else if (retval < 0) {
-      CVProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVLAPACK", "cvLapackBandSetup", MSGD_JACFUNC_FAILED);
+      cvProcessError(cv_mem, CVDLS_JACFUNC_UNRECVR, "CVLAPACK", "cvLapackBandSetup", MSGD_JACFUNC_FAILED);
       last_flag = CVDLS_JACFUNC_UNRECVR;
       return(-1);
     } else if (retval > 0) {
@@ -638,7 +643,7 @@ static int cvLapackBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
 /*
  * cvLapackBandFree frees memory specific to the band linear solver.
  */
-static void cvLapackBandFree(CVodeMem cv_mem)
+static int cvLapackBandFree(CVodeMem cv_mem)
 {
   CVDlsMem  cvdls_mem;
 
@@ -649,5 +654,7 @@ static void cvLapackBandFree(CVodeMem cv_mem)
   DestroyMat(savedJ);
   free(cvdls_mem); 
   cvdls_mem = NULL;
+
+  return(0);
 }
 
diff --git a/src/cvode/cvode_sparse.c b/src/cvode/cvode_sparse.c
new file mode 100644
index 0000000..c71996d
--- /dev/null
+++ b/src/cvode/cvode_sparse.c
@@ -0,0 +1,175 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for an CVSLS linear solver.
+ * -----------------------------------------------------------------
+ */
+
+/* 
+ * =================================================================
+ * IMPORTED HEADER FILES
+ * =================================================================
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cvode_impl.h"
+#include "cvode_sparse_impl.h"
+#include <sundials/sundials_math.h>
+
+/* 
+ * =================================================================
+ * FUNCTION SPECIFIC CONSTANTS
+ * =================================================================
+ */
+
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* 
+ * =================================================================
+ * EXPORTED FUNCTIONS FOR IMPLICIT INTEGRATION
+ * =================================================================
+ */
+              
+/*
+ * CVSlsSetSparseJacFn specifies the sparse Jacobian function.
+ */
+int CVSlsSetSparseJacFn(void *cvode_mem, CVSlsSparseJacFn jac)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+
+  /* Return immediately if cvode_mem is NULL */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSlsSetSparseJacFn", 
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEM_NULL, "CVSLS", 
+		    "CVSlsSetSparseJacFn", MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  cvsls_mem->s_jaceval = jac;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * CVSlsGetNumJacEvals returns the number of Jacobian evaluations.
+ */
+int CVSlsGetNumJacEvals(void *cvode_mem, long int *njevals)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+
+  /* Return immediately if cvode_mem is NULL */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSlsGetNumJacEvals", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEM_NULL, "CVSLS", 
+		    "CVSlsGetNumJacEvals", MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  *njevals = cvsls_mem->s_nje;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * CVSlsGetReturnFlagName returns the name associated with a CVSLS
+ * return value.
+ */
+char *CVSlsGetReturnFlagName(long int flag)
+{
+  char *name;
+
+  name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case CVSLS_SUCCESS:
+    sprintf(name,"CVSLS_SUCCESS");
+    break;   
+  case CVSLS_MEM_NULL:
+    sprintf(name,"CVSLS_MEM_NULL");
+    break;
+  case CVSLS_LMEM_NULL:
+    sprintf(name,"CVSLS_LMEM_NULL");
+    break;
+  case CVSLS_ILL_INPUT:
+    sprintf(name,"CVSLS_ILL_INPUT");
+    break;
+  case CVSLS_MEM_FAIL:
+    sprintf(name,"CVSLS_MEM_FAIL");
+    break;
+  case CVSLS_JAC_NOSET:
+    sprintf(name,"CVSLS_JAC_NOSET");
+    break;
+  case CVSLS_JACFUNC_UNRECVR:
+    sprintf(name,"CVSLS_JACFUNC_UNRECVR");
+    break;
+  case CVSLS_JACFUNC_RECVR:
+    sprintf(name,"CVSLS_JACFUNC_RECVR");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+/*
+ * CVSlsGetLastFlag returns the last flag set in a CVSLS function.
+ */
+int CVSlsGetLastFlag(void *cvode_mem, long int *flag)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+
+  /* Return immediately if cvode_mem is NULL */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSlsGetLastFlag", 
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEM_NULL, "CVSLS", 
+		    "CVSlsGetLastFlag", MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  *flag = cvsls_mem->s_last_flag;
+
+  return(CVSLS_SUCCESS);
+}
+
diff --git a/src/cvode/cvode_sparse_impl.h b/src/cvode/cvode_sparse_impl.h
new file mode 100644
index 0000000..f50e046
--- /dev/null
+++ b/src/cvode/cvode_sparse_impl.h
@@ -0,0 +1,109 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the CVSLS linear solvers.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSPARSE_IMPL_H
+#define _CVSPARSE_IMPL_H
+
+#include "cvode/cvode_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * C V S P A R S E    I N T E R N A L    C O N S T A N T S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * CVSLS solver constants
+ * -----------------------------------------------------------------
+ * CVS_MSBJ   maximum number of steps between Jacobian evaluations
+ * CVS_DGMAX  maximum change in gamma between Jacobian evaluations
+ * -----------------------------------------------------------------
+ */
+ 
+#define CVS_MSBJ  50
+#define CVS_DGMAX RCONST(0.2)
+ 
+/*
+ * -----------------------------------------------------------------
+ * Types : CVSlsMemRec, CVSlsMem                             
+ * -----------------------------------------------------------------
+ * CVSlsMem is pointer to a CVSlsMemRec structure.
+ * -----------------------------------------------------------------
+ */
+
+typedef struct CVSlsMemRec {
+
+  CVSlsSparseJacFn s_jaceval; /* user Jacobian evaluation routine 
+				  to be called */
+  void *s_jacdata;           /* J_data is passed to djac or bjac */
+
+  long int s_nje;           /* nje = no. of calls to jac */
+
+  long int s_last_flag;     /* last error return flag */
+
+  int s_first_factorize;    /* flag telling whether the first 
+			       factorization needs to happen */
+
+  int s_nstlj;              /* time step of last Jacobian evaluation */
+
+  SlsMat s_JacMat;          /* M = I - gamma * df/dy */
+
+  SlsMat s_savedJ;          /* saved copy of Jacobian */
+
+  int sparsetype;           /* matrix type: compressed sparse column or row */
+
+  void *s_solver_data;      /* structure for solver-specific data */
+  
+
+} *CVSlsMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Prototypes of internal functions
+ * -----------------------------------------------------------------
+ */
+  
+
+/*
+ * =================================================================
+ * E R R O R   M E S S A G E S
+ * =================================================================
+ */
+
+#define MSGSP_CVMEM_NULL "Integrator memory is NULL."
+#define MSGSP_BAD_NVECTOR "A required vector operation is not implemented."
+#define MSGSP_MEM_FAIL "A memory request failed."
+#define MSGSP_LMEM_NULL "Linear solver memory is NULL."
+#define MSGSP_ILL_INPUT "Invalid input detected."
+#define MSGSP_JAC_NOSET "Jacobian evaluation function has not been set."
+#define MSGSP_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
+#define MSGSP_PACKAGE_FAIL "A call to an external package failed."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/cvode/cvode_spbcgs.c b/src/cvode/cvode_spbcgs.c
index ffe1090..3fd7ad6 100644
--- a/src/cvode/cvode_spbcgs.c
+++ b/src/cvode/cvode_spbcgs.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2011/03/23 22:27:43 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPBCG linear solver.
  * -----------------------------------------------------------------
@@ -40,7 +45,7 @@ static int CVSpbcgSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int CVSpbcgSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                         N_Vector ynow, N_Vector fnow);
 
-static void CVSpbcgFree(CVodeMem cv_mem);
+static int CVSpbcgFree(CVodeMem cv_mem);
 
 
 /* Readability Replacements */
@@ -112,14 +117,14 @@ int CVSpbcg(void *cvode_mem, int pretype, int maxl)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPBCG", "CVSpbcg", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPBCG", "CVSpbcg", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Check if N_VDotProd is present */
   if (vec_tmpl->ops->nvdotprod == NULL) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPBCG", "CVSpbcg", MSGS_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPBCG", "CVSpbcg", MSGS_BAD_NVECTOR);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -135,7 +140,7 @@ int CVSpbcg(void *cvode_mem, int pretype, int maxl)
   cvspils_mem = NULL;
   cvspils_mem = (CVSpilsMem) malloc(sizeof(struct CVSpilsMemRec));
   if (cvspils_mem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
@@ -162,12 +167,14 @@ int CVSpbcg(void *cvode_mem, int pretype, int maxl)
 
   cvspils_mem->s_last_flag = CVSPILS_SUCCESS;
 
+  cvSpilsInitializeCounters(cvspils_mem);
+
   setupNonNull = FALSE;
 
   /* Check for legal pretype */ 
   if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
       (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPBCG", "CVSpbcg", MSGS_BAD_PRETYPE);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPBCG", "CVSpbcg", MSGS_BAD_PRETYPE);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_ILL_INPUT);
   }
@@ -176,14 +183,14 @@ int CVSpbcg(void *cvode_mem, int pretype, int maxl)
 
   ytemp = N_VClone(vec_tmpl);
   if (ytemp == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_MEM_FAIL);
   }
 
   x = N_VClone(vec_tmpl);
   if (x == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
     N_VDestroy(ytemp);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_MEM_FAIL);
@@ -191,13 +198,13 @@ int CVSpbcg(void *cvode_mem, int pretype, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SpbcgMalloc to allocate workspace for Spbcg */
   spbcg_mem = NULL;
   spbcg_mem = SpbcgMalloc(mxl, vec_tmpl);
   if (spbcg_mem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPBCG", "CVSpbcg", MSGS_MEM_FAIL);
     N_VDestroy(ytemp);
     N_VDestroy(x);
     free(cvspils_mem); cvspils_mem = NULL;
@@ -242,12 +249,11 @@ static int CVSpbcgInit(CVodeMem cv_mem)
   spbcg_mem = (SpbcgMem) spils_mem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = nstlpre = 0;
-  njtimes = nfes = 0;
+  cvSpilsInitializeCounters(cvspils_mem);
 
   /* Check for legal combination pretype - psolve */
   if ((pretype != PREC_NONE) && (psolve == NULL)) {
-    CVProcessError(cv_mem, -1, "CVSPBCG", "CVSpbcgInit", MSGS_PSOLVE_REQ);
+    cvProcessError(cv_mem, -1, "CVSPBCG", "CVSpbcgInit", MSGS_PSOLVE_REQ);
     last_flag = CVSPILS_ILL_INPUT;
     return(-1);
   }
@@ -297,7 +303,7 @@ static int CVSpbcgSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlpre + CVSPILS_MSBPRE) ||
       ((convfail == CV_FAIL_BAD_J) && (dgamma < CVSPILS_DGMAX)) ||
       (convfail == CV_FAIL_OTHER);
@@ -308,7 +314,7 @@ static int CVSpbcgSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   retval = pset(tn, ypred, fpred, jok, jcurPtr, gamma, P_data, 
                 vtemp1, vtemp2, vtemp3);
   if (retval < 0) {
-    CVProcessError(cv_mem, SPBCG_PSET_FAIL_UNREC, "CVSPBCG", "CVSpbcgSetup", MSGS_PSET_FAILED);
+    cvProcessError(cv_mem, SPBCG_PSET_FAIL_UNREC, "CVSPBCG", "CVSpbcgSetup", MSGS_PSET_FAILED);
     last_flag = SPBCG_PSET_FAIL_UNREC;
   }
   if (retval > 0) {
@@ -418,11 +424,11 @@ static int CVSpbcgSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
     return(-1);
     break;
   case SPBCG_ATIMES_FAIL_UNREC:
-    CVProcessError(cv_mem, SPBCG_ATIMES_FAIL_UNREC, "CVSPBCG", "CVSpbcgSolve", MSGS_JTIMES_FAILED);    
+    cvProcessError(cv_mem, SPBCG_ATIMES_FAIL_UNREC, "CVSPBCG", "CVSpbcgSolve", MSGS_JTIMES_FAILED);    
     return(-1);
     break;
   case SPBCG_PSOLVE_FAIL_UNREC:
-    CVProcessError(cv_mem, SPBCG_PSOLVE_FAIL_UNREC, "CVSPBCG", "CVSpbcgSolve", MSGS_PSOLVE_FAILED);
+    cvProcessError(cv_mem, SPBCG_PSOLVE_FAIL_UNREC, "CVSPBCG", "CVSpbcgSolve", MSGS_PSOLVE_FAILED);
     return(-1);
     break;
   }
@@ -438,7 +444,7 @@ static int CVSpbcgSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVSpbcgFree(CVodeMem cv_mem)
+static int CVSpbcgFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   SpbcgMem spbcg_mem;
@@ -455,5 +461,7 @@ static void CVSpbcgFree(CVodeMem cv_mem)
 
   free(cvspils_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
 
diff --git a/src/cvode/cvode_spgmr.c b/src/cvode/cvode_spgmr.c
index 08d85da..1f53d7c 100644
--- a/src/cvode/cvode_spgmr.c
+++ b/src/cvode/cvode_spgmr.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2011/03/23 22:27:43 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPGMR linear solver.
  * -----------------------------------------------------------------
@@ -41,7 +46,7 @@ static int CVSpgmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int CVSpgmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                         N_Vector ynow, N_Vector fnow);
 
-static void CVSpgmrFree(CVodeMem cv_mem);
+static int CVSpgmrFree(CVodeMem cv_mem);
 
 /* Readability Replacements */
 
@@ -113,14 +118,14 @@ int CVSpgmr(void *cvode_mem, int pretype, int maxl)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPGMR", "CVSpgmr", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPGMR", "CVSpgmr", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Check if N_VDotProd is present */
   if(vec_tmpl->ops->nvdotprod == NULL) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPGMR", "CVSpgmr", MSGS_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPGMR", "CVSpgmr", MSGS_BAD_NVECTOR);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -136,7 +141,7 @@ int CVSpgmr(void *cvode_mem, int pretype, int maxl)
   cvspils_mem = NULL;
   cvspils_mem = (CVSpilsMem) malloc(sizeof(struct CVSpilsMemRec));
   if (cvspils_mem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
@@ -164,12 +169,14 @@ int CVSpgmr(void *cvode_mem, int pretype, int maxl)
 
   cvspils_mem->s_last_flag  = CVSPILS_SUCCESS;
 
+  cvSpilsInitializeCounters(cvspils_mem);
+
   setupNonNull = FALSE;
 
   /* Check for legal pretype */ 
   if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
       (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPGMR", "CVSpgmr", MSGS_BAD_PRETYPE);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPGMR", "CVSpgmr", MSGS_BAD_PRETYPE);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_ILL_INPUT);
   }
@@ -178,14 +185,14 @@ int CVSpgmr(void *cvode_mem, int pretype, int maxl)
 
   ytemp = N_VClone(vec_tmpl);
   if (ytemp == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_MEM_FAIL);
   }
 
   x = N_VClone(vec_tmpl);
   if (x == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
     N_VDestroy(ytemp);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_MEM_FAIL);
@@ -193,13 +200,13 @@ int CVSpgmr(void *cvode_mem, int pretype, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt( N_VDotProd(ytemp, ytemp) );
+  sqrtN = SUNRsqrt( N_VDotProd(ytemp, ytemp) );
 
   /* Call SpgmrMalloc to allocate workspace for Spgmr */
   spgmr_mem = NULL;
   spgmr_mem = SpgmrMalloc(mxl, vec_tmpl);
   if (spgmr_mem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPGMR", "CVSpgmr", MSGS_MEM_FAIL);
     N_VDestroy(ytemp);
     N_VDestroy(x);
     free(cvspils_mem); cvspils_mem = NULL;
@@ -241,12 +248,11 @@ static int CVSpgmrInit(CVodeMem cv_mem)
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = nstlpre = 0;
-  njtimes = nfes = 0;
+  cvSpilsInitializeCounters(cvspils_mem);
 
   /* Check for legal combination pretype - psolve */
   if ((pretype != PREC_NONE) && (psolve == NULL)) {
-    CVProcessError(cv_mem, -1, "CVSPGMR", "CVSpgmrInit", MSGS_PSOLVE_REQ);
+    cvProcessError(cv_mem, -1, "CVSPGMR", "CVSpgmrInit", MSGS_PSOLVE_REQ);
     last_flag = CVSPILS_ILL_INPUT;
     return(-1);
   }
@@ -292,7 +298,7 @@ static int CVSpgmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlpre + CVSPILS_MSBPRE) ||
     ((convfail == CV_FAIL_BAD_J) && (dgamma < CVSPILS_DGMAX)) ||
     (convfail == CV_FAIL_OTHER);
@@ -303,7 +309,7 @@ static int CVSpgmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   retval = pset(tn, ypred, fpred, jok, jcurPtr, gamma, P_data, 
                 vtemp1, vtemp2, vtemp3);
   if (retval < 0) {
-    CVProcessError(cv_mem, SPGMR_PSET_FAIL_UNREC, "CVSPGMR", "CVSpgmrSetup", MSGS_PSET_FAILED);
+    cvProcessError(cv_mem, SPGMR_PSET_FAIL_UNREC, "CVSPGMR", "CVSpgmrSetup", MSGS_PSET_FAILED);
     last_flag = SPGMR_PSET_FAIL_UNREC;
   }
   if (retval > 0) {
@@ -416,11 +422,11 @@ static int CVSpgmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
     return(-1);
     break;
   case SPGMR_ATIMES_FAIL_UNREC:
-    CVProcessError(cv_mem, SPGMR_ATIMES_FAIL_UNREC, "CVSPGMR", "CVSpgmrSolve", MSGS_JTIMES_FAILED);    
+    cvProcessError(cv_mem, SPGMR_ATIMES_FAIL_UNREC, "CVSPGMR", "CVSpgmrSolve", MSGS_JTIMES_FAILED);    
     return(-1);
     break;
   case SPGMR_PSOLVE_FAIL_UNREC:
-    CVProcessError(cv_mem, SPGMR_PSOLVE_FAIL_UNREC, "CVSPGMR", "CVSpgmrSolve", MSGS_PSOLVE_FAILED);
+    cvProcessError(cv_mem, SPGMR_PSOLVE_FAIL_UNREC, "CVSPGMR", "CVSpgmrSolve", MSGS_PSOLVE_FAILED);
     return(-1);
     break;
   case SPGMR_GS_FAIL:
@@ -442,7 +448,7 @@ static int CVSpgmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVSpgmrFree(CVodeMem cv_mem)
+static int CVSpgmrFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   SpgmrMem spgmr_mem;
@@ -459,5 +465,7 @@ static void CVSpgmrFree(CVodeMem cv_mem)
 
   free(cvspils_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
 
diff --git a/src/cvode/cvode_spils.c b/src/cvode/cvode_spils.c
index 2fa5e4e..5bcdc9e 100644
--- a/src/cvode/cvode_spils.c
+++ b/src/cvode/cvode_spils.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2011/06/23 00:19:54 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPILS linear solvers.
  * -----------------------------------------------------------------
@@ -84,13 +89,13 @@ int CVSpilsSetPrecType(void *cvode_mem, int pretype)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetPrecType", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetPrecType", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetPrecType", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetPrecType", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -98,7 +103,7 @@ int CVSpilsSetPrecType(void *cvode_mem, int pretype)
   /* Check for legal pretype */ 
   if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
       (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetPrecType", MSGS_BAD_PRETYPE);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetPrecType", MSGS_BAD_PRETYPE);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -120,25 +125,25 @@ int CVSpilsSetGSType(void *cvode_mem, int gstype)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetGSType", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetGSType", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetGSType", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetGSType", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
 
   if (ils_type != SPILS_SPGMR) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetGSType", MSGS_BAD_LSTYPE);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetGSType", MSGS_BAD_LSTYPE);
     return(CVSPILS_ILL_INPUT);
   }
 
   /* Check for legal gstype */
   if ((gstype != MODIFIED_GS) && (gstype != CLASSICAL_GS)) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetGSType", MSGS_BAD_GSTYPE);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetGSType", MSGS_BAD_GSTYPE);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -161,19 +166,19 @@ int CVSpilsSetMaxl(void *cvode_mem, int maxl)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetMaxl", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetMaxl", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(NULL, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetMaxl", MSGS_LMEM_NULL);
+    cvProcessError(NULL, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetMaxl", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
 
   if (ils_type == SPILS_SPGMR) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetMaxl", MSGS_BAD_LSTYPE);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetMaxl", MSGS_BAD_LSTYPE);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -197,20 +202,20 @@ int CVSpilsSetEpsLin(void *cvode_mem, realtype eplifac)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetEpsLin", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetEpsLin", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetEpsLin", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetEpsLin", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Check for legal eplifac */
   if(eplifac < ZERO) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetEpsLin", MSGS_BAD_EPLIN);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetEpsLin", MSGS_BAD_EPLIN);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -233,13 +238,13 @@ int CVSpilsSetPreconditioner(void *cvode_mem,
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetPreconditioner", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetPreconditioner", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetPreconditioner", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetPreconditioner", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -263,13 +268,13 @@ int CVSpilsSetJacTimesVecFn(void *cvode_mem, CVSpilsJacTimesVecFn jtv)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetJacTimesVecFn", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetJacTimesVecFn", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetJacTimesVecFn", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsSetJacTimesVecFn", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -298,13 +303,13 @@ int CVSpilsGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetWorkSpace", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetWorkSpace", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetWorkSpace", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetWorkSpace", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -343,13 +348,13 @@ int CVSpilsGetNumPrecEvals(void *cvode_mem, long int *npevals)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumPrecEvals", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumPrecEvals", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumPrecEvals", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumPrecEvals", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -372,13 +377,13 @@ int CVSpilsGetNumPrecSolves(void *cvode_mem, long int *npsolves)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumPrecSolves", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumPrecSolves", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumPrecSolves", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumPrecSolves", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -401,13 +406,13 @@ int CVSpilsGetNumLinIters(void *cvode_mem, long int *nliters)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumLinIters", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumLinIters", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumLinIters", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumLinIters", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -430,13 +435,13 @@ int CVSpilsGetNumConvFails(void *cvode_mem, long int *nlcfails)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumConvFails", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumConvFails", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumConvFails", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumConvFails", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -459,13 +464,13 @@ int CVSpilsGetNumJtimesEvals(void *cvode_mem, long int *njvevals)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumJtimesEvals", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumJtimesEvals", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumJtimesEvals", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumJtimesEvals", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -488,13 +493,13 @@ int CVSpilsGetNumRhsEvals(void *cvode_mem, long int *nfevalsLS)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumRhsEvals", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetNumRhsEvals", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumRhsEvals", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetNumRhsEvals", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -517,13 +522,13 @@ int CVSpilsGetLastFlag(void *cvode_mem, long int *flag)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetLastFlag", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsGetLastFlag", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   if (lmem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetLastFlag", MSGS_LMEM_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEM_NULL, "CVSPILS", "CVSpilsGetLastFlag", MSGS_LMEM_NULL);
     return(CVSPILS_LMEM_NULL);
   }
   cvspils_mem = (CVSpilsMem) lmem;
@@ -695,3 +700,16 @@ int CVSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t,
 
   return(0);
 }
+
+
+int cvSpilsInitializeCounters(CVSpilsMem cvspils_mem)
+{
+  cvspils_mem->s_npe     = 0;
+  cvspils_mem->s_nli     = 0;
+  cvspils_mem->s_nps     = 0;
+  cvspils_mem->s_ncfl    = 0;
+  cvspils_mem->s_nstlpre = 0;
+  cvspils_mem->s_njtimes = 0;
+  cvspils_mem->s_nfes    = 0;
+  return(0);
+}
diff --git a/src/cvode/cvode_spils_impl.h b/src/cvode/cvode_spils_impl.h
index be5491f..5e3f199 100644
--- a/src/cvode/cvode_spils_impl.h
+++ b/src/cvode/cvode_spils_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:19:48 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common implementation header file for the scaled, preconditioned
  * linear solver modules.
@@ -18,13 +23,13 @@
 #ifndef _CVSPILS_IMPL_H
 #define _CVSPILS_IMPL_H
 
+#include <cvode/cvode_spils.h>
+#include "cvode_impl.h"
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvode/cvode_spils.h>
-#include "cvode_impl.h"
-
 /* Types of iterative linear solvers */
 
 #define SPILS_SPGMR   1
@@ -77,7 +82,7 @@ typedef struct CVSpilsMemRec {
    */
   CVSpilsPrecSetupFn s_pset;
   CVSpilsPrecSolveFn s_psolve;
-  void (*s_pfree)(CVodeMem cv_mem);
+  int (*s_pfree)(CVodeMem cv_mem);
   void *s_P_data;
 
   /* Jacobian times vector compuation
@@ -114,6 +119,10 @@ int CVSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t,
                     N_Vector y, N_Vector fy, void *data,
                     N_Vector work);
 
+/* Auxilliary functions */
+int cvSpilsInitializeCounters(CVSpilsMem cvspils_mem);
+
+
 /*
  * -----------------------------------------------------------------
  * Error Messages
diff --git a/src/cvode/cvode_sptfqmr.c b/src/cvode/cvode_sptfqmr.c
index bf84290..abf2d02 100644
--- a/src/cvode/cvode_sptfqmr.c
+++ b/src/cvode/cvode_sptfqmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2011/03/23 22:27:43 $
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPTFQMR linear solver.
  * -----------------------------------------------------------------
@@ -34,13 +39,13 @@
 static int CVSptfqmrInit(CVodeMem cv_mem);
 
 static int CVSptfqmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
-			  N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
-			  N_Vector vtemp2, N_Vector vtemp3);
+                          N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
+                          N_Vector vtemp2, N_Vector vtemp3);
 
 static int CVSptfqmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
-			  N_Vector ynow, N_Vector fnow);
+                          N_Vector ynow, N_Vector fnow);
 
-static void CVSptfqmrFree(CVodeMem cv_mem);
+static int CVSptfqmrFree(CVodeMem cv_mem);
 
 
 /* Readability Replacements */
@@ -112,14 +117,14 @@ int CVSptfqmr(void *cvode_mem, int pretype, int maxl)
 
   /* Return immediately if cvode_mem is NULL */
   if (cvode_mem == NULL) {
-    CVProcessError(NULL, CVSPILS_MEM_NULL, "CVSPTFQMR", "CVSptfqmr", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPTFQMR", "CVSptfqmr", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Check if N_VDotProd is present */
   if (vec_tmpl->ops->nvdotprod == NULL) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPTFQMR", "CVSptfqmr", MSGS_BAD_NVECTOR);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPTFQMR", "CVSptfqmr", MSGS_BAD_NVECTOR);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -135,7 +140,7 @@ int CVSptfqmr(void *cvode_mem, int pretype, int maxl)
   cvspils_mem = NULL;
   cvspils_mem = (CVSpilsMem) malloc(sizeof(struct CVSpilsMemRec));
   if (cvspils_mem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
     return(CVSPILS_MEM_FAIL);
   }
 
@@ -162,12 +167,14 @@ int CVSptfqmr(void *cvode_mem, int pretype, int maxl)
 
   cvspils_mem->s_last_flag = CVSPILS_SUCCESS;
 
+  cvSpilsInitializeCounters(cvspils_mem);
+
   setupNonNull = FALSE;
 
   /* Check for legal pretype */ 
   if ((pretype != PREC_NONE) && (pretype != PREC_LEFT) &&
       (pretype != PREC_RIGHT) && (pretype != PREC_BOTH)) {
-    CVProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPTFQMR", "CVSptfqmr", MSGS_BAD_PRETYPE);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPTFQMR", "CVSptfqmr", MSGS_BAD_PRETYPE);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_ILL_INPUT);
   }
@@ -176,14 +183,14 @@ int CVSptfqmr(void *cvode_mem, int pretype, int maxl)
 
   ytemp = N_VClone(vec_tmpl);
   if (ytemp == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_MEM_FAIL);
   }
 
   x = N_VClone(vec_tmpl);
   if (x == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
     N_VDestroy(ytemp);
     free(cvspils_mem); cvspils_mem = NULL;
     return(CVSPILS_MEM_FAIL);
@@ -191,13 +198,13 @@ int CVSptfqmr(void *cvode_mem, int pretype, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SptfqmrMalloc to allocate workspace for Sptfqmr */
   sptfqmr_mem = NULL;
   sptfqmr_mem = SptfqmrMalloc(mxl, vec_tmpl);
   if (sptfqmr_mem == NULL) {
-    CVProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
+    cvProcessError(cv_mem, CVSPILS_MEM_FAIL, "CVSPTFQMR", "CVSptfqmr", MSGS_MEM_FAIL);
     N_VDestroy(ytemp);
     N_VDestroy(x);
     free(cvspils_mem); cvspils_mem = NULL;
@@ -240,12 +247,11 @@ static int CVSptfqmrInit(CVodeMem cv_mem)
   sptfqmr_mem = (SptfqmrMem) spils_mem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = nstlpre = 0;
-  njtimes = nfes = 0;
+  cvSpilsInitializeCounters(cvspils_mem);
 
   /* Check for legal combination pretype - psolve */
   if ((pretype != PREC_NONE) && (psolve == NULL)) {
-    CVProcessError(cv_mem, -1, "CVSPTFQMR", "CVSptfqmrInit", MSGS_PSOLVE_REQ);
+    cvProcessError(cv_mem, -1, "CVSPTFQMR", "CVSptfqmrInit", MSGS_PSOLVE_REQ);
     last_flag = CVSPILS_ILL_INPUT;
     return(-1);
   }
@@ -295,7 +301,7 @@ static int CVSptfqmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlpre + CVSPILS_MSBPRE) ||
       ((convfail == CV_FAIL_BAD_J) && (dgamma < CVSPILS_DGMAX)) ||
       (convfail == CV_FAIL_OTHER);
@@ -306,7 +312,7 @@ static int CVSptfqmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   retval = pset(tn, ypred, fpred, jok, jcurPtr, gamma, P_data, 
                 vtemp1, vtemp2, vtemp3);
   if (retval < 0) {
-    CVProcessError(cv_mem, SPTFQMR_PSET_FAIL_UNREC, "CVSPTFQMR", "CVSptfqmrSetup", MSGS_PSET_FAILED);
+    cvProcessError(cv_mem, SPTFQMR_PSET_FAIL_UNREC, "CVSPTFQMR", "CVSptfqmrSetup", MSGS_PSET_FAILED);
     last_flag = SPTFQMR_PSET_FAIL_UNREC;
   }
   if (retval > 0) {
@@ -416,11 +422,11 @@ static int CVSptfqmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
     return(-1);
     break;
   case SPTFQMR_ATIMES_FAIL_UNREC:
-    CVProcessError(cv_mem, SPTFQMR_ATIMES_FAIL_UNREC, "CVSPTFQMR", "CVSptfqmrSolve", MSGS_JTIMES_FAILED);    
+    cvProcessError(cv_mem, SPTFQMR_ATIMES_FAIL_UNREC, "CVSPTFQMR", "CVSptfqmrSolve", MSGS_JTIMES_FAILED);    
     return(-1);
     break;
   case SPTFQMR_PSOLVE_FAIL_UNREC:
-    CVProcessError(cv_mem, SPTFQMR_PSOLVE_FAIL_UNREC, "CVSPTFQMR", "CVSptfqmrSolve", MSGS_PSOLVE_FAILED);
+    cvProcessError(cv_mem, SPTFQMR_PSOLVE_FAIL_UNREC, "CVSPTFQMR", "CVSptfqmrSolve", MSGS_PSOLVE_FAILED);
     return(-1);
     break;
   }
@@ -436,7 +442,7 @@ static int CVSptfqmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVSptfqmrFree(CVodeMem cv_mem)
+static int CVSptfqmrFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   SptfqmrMem sptfqmr_mem;
@@ -454,6 +460,6 @@ static void CVSptfqmrFree(CVodeMem cv_mem)
   free(cvspils_mem);
   cv_mem->cv_lmem = NULL;
 
-  return;
+  return(0);
 }
 
diff --git a/src/cvode/cvode_superlumt.c b/src/cvode/cvode_superlumt.c
new file mode 100644
index 0000000..f601898
--- /dev/null
+++ b/src/cvode/cvode_superlumt.c
@@ -0,0 +1,554 @@
+
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4922 $
+ * $Date: 2016-09-19 14:35:32 -0700 (Mon, 19 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the CVSUPERLUMT linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cvode_impl.h"
+#include "cvode_sparse_impl.h"
+#include "cvode/cvode_superlumt.h"
+#include "sundials/sundials_superlumt_impl.h"
+#include "sundials/sundials_math.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* CVSUPERLUMT linit, lsetup, lsolve, and lfree routines */
+ 
+static int cvSuperLUMTInit(CVodeMem cv_mem);
+
+static int cvSuperLUMTSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+			    N_Vector fpred, booleantype *jcurPtr,
+			    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int cvSuperLUMTSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+			    N_Vector ycur, N_Vector fcur);
+
+static int cvSuperLUMTFree(CVodeMem cv_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * CVSuperLUMT
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the CVODE / SuperLUMT linear solver module.  
+ * CVSUPERLUMT first calls the existing lfree routine if this is not NULL.
+ * Then it sets the cv_linit, cv_lsetup, cv_lsolve, and
+ * cv_lfree fields in (*cv_mem) to be cvSuperLUMTInit, cvSuperLUMTSetup,
+ * cvSuperLUMTSolve, and cvSuperLUMTFree, respectively.
+ * It allocates memory for a structure of type CVsluMemRec and sets
+ * the cv_lmem field in (*cvode_mem) to the address of this structure.
+ * It sets setupNonNull in (*cvode_mem) to TRUE.
+ * Finally, it allocates memory for SuperLUMT.
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_LMEM_FAIL = -1,
+ * or CVSLS_ILL_INPUT = -2.
+ *
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, CVSuperLUMT will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int CVSuperLUMT(void *cvode_mem, int num_threads, int n, int nnz)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+  int *perm_c, *perm_r;
+  int nrhs, panel_size, relax;
+  double *bd;
+  SuperMatrix *B;
+
+  /* Return immediately if cv_mem is NULL. */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (cv_mem->cv_tempv->ops->nvgetarraypointer == NULL) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_BAD_NVECTOR);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  if (cv_mem->cv_lfree != NULL) cv_mem->cv_lfree(cv_mem);
+
+  /* Set five main function fields in cv_mem. */
+  cv_mem->cv_linit  = cvSuperLUMTInit;
+  cv_mem->cv_lsetup = cvSuperLUMTSetup;
+  cv_mem->cv_lsolve = cvSuperLUMTSolve;
+  cv_mem->cv_lfree  = cvSuperLUMTFree;
+
+  /* Get memory for CVSlsMemRec. */
+  cvsls_mem = (CVSlsMem) malloc(sizeof(struct CVSlsMemRec));
+  if (cvsls_mem == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Get memory for SLUMT_data. */
+  slumt_data = (SLUMTData)malloc(sizeof(struct SLUMTDataRec));
+  if (slumt_data == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  cv_mem->cv_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  cvsls_mem->s_jaceval = NULL;
+  cvsls_mem->s_jacdata = cv_mem->cv_user_data;
+
+  /* Allocate memory for the sparse Jacobian */
+  cvsls_mem->s_JacMat = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (cvsls_mem->s_JacMat == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Allocate memory for saved sparse Jacobian */
+  cvsls_mem->s_savedJ = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (cvsls_mem->s_savedJ == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Set up memory for the permutations */
+  perm_r = (int *)malloc(n*sizeof(int));
+  if (perm_r == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		   MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+  perm_c = (int *)malloc(n*sizeof(int));
+  if (perm_c == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		   MSGSP_MEM_FAIL);
+    free(perm_r);
+    return(CVSLS_MEM_FAIL);
+  }
+  slumt_data->perm_r = perm_r;
+  slumt_data->perm_c = perm_c;
+
+  /* Set default parameters for SuperLU */
+  slumt_data->num_threads = num_threads;
+  slumt_data->diag_pivot_thresh = 1.0;
+
+  /* Allocate structures for SuperLU */
+  slumt_data->Gstat = (Gstat_t *)malloc(sizeof(Gstat_t));
+  slumt_data->s_A = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_AC = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_L = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_U = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_A->Store  = NULL;
+  slumt_data->s_AC->Store = NULL;
+  slumt_data->s_L->Store  = NULL;
+  slumt_data->s_U->Store  = NULL;
+  slumt_data->superlumt_options = (superlumt_options_t *)malloc(sizeof(superlumt_options_t));
+
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  StatAlloc(cvsls_mem->s_JacMat->N, num_threads, panel_size, relax, 
+	    slumt_data->Gstat);
+  
+  /* Create RHS matrix */
+  nrhs = 1;
+  bd = NULL;
+  B = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  B->Store = NULL;
+  dCreate_Dense_Matrix(B, n, nrhs, bd, n, 
+		       SLU_DN, SLU_D, SLU_GE);
+  slumt_data->s_B = B;
+
+  /* Set ordering to COLAMD as the cvode default use.
+     Users can set a different value with CVSuperLUMTSetOrdering,
+     and the user-set value is loaded before any call to factorize the
+     matrix in cvSuperLUMTSetup.  */
+  slumt_data->s_ordering = 3;
+
+  /* Attach linear solver memory to the integrator memory */
+  cvsls_mem->s_solver_data = (void *) slumt_data;
+  cv_mem->cv_lmem = cvsls_mem;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * CVSuperLUMT interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the CVSuperLUMT
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int cvSuperLUMTInit(CVodeMem cv_mem)
+{
+  int num_threads, n;
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+
+  cvsls_mem = (CVSlsMem)cv_mem->cv_lmem;
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  cvsls_mem->s_nje = 0;
+  cvsls_mem->s_first_factorize = 1;
+  cvsls_mem->s_nstlj = 0;
+
+  /* ------------------------------------------------------------
+     Allocate storage and initialize statistics variables. 
+     ------------------------------------------------------------*/
+  n = cvsls_mem->s_JacMat->N;
+  num_threads = slumt_data->num_threads;
+
+  StatInit(n, num_threads, slumt_data->Gstat);
+
+  cvsls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the CVSuperLUMT linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     CVSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int cvSuperLUMTSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+			   N_Vector fpred, booleantype *jcurPtr,
+			   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  int retval, info;
+  int nprocs, panel_size, relax, permc_spec, lwork;
+  int *perm_r, *perm_c;
+  long int nst, nstlj;
+  realtype tn, gamma, gammap, dgamma;
+  double diag_pivot_thresh, drop_tol;
+  fact_t fact;
+  trans_t trans;
+  yes_no_t refact, usepr;
+  CVSlsMem cvsls_mem;
+  CVSlsSparseJacFn jaceval;
+  SuperMatrix *A, *AC, *L, *U;
+  Gstat_t *Gstat;
+  superlumt_options_t *superlumt_options;
+  SLUMTData slumt_data;
+  SlsMat JacMat, savedJ;
+  void *jacdata;
+  void *work;
+  
+  cvsls_mem = (CVSlsMem) (cv_mem->cv_lmem);
+  tn = cv_mem->cv_tn; 
+  gamma = cv_mem->cv_gamma;
+  gammap = cv_mem->cv_gammap;
+  nst = cv_mem->cv_nst;
+
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  jaceval = cvsls_mem->s_jaceval;
+  jacdata = cvsls_mem->s_jacdata;
+  JacMat = cvsls_mem->s_JacMat;
+  savedJ = cvsls_mem->s_savedJ;
+  nstlj = cvsls_mem->s_nstlj;
+
+  superlumt_options = slumt_data->superlumt_options;
+  A = slumt_data->s_A;
+  AC = slumt_data->s_AC;
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  Gstat = slumt_data->Gstat;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  nprocs = slumt_data->num_threads;
+  diag_pivot_thresh = slumt_data->diag_pivot_thresh;
+
+  /* Set option values for SuperLU_MT */
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  fact = EQUILIBRATE;
+  trans = NOTRANS;
+  usepr = NO;
+  drop_tol = 0.0;
+  lwork = 0;
+  work = NULL;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    cvProcessError(cv_mem, CVSLS_JAC_NOSET, "CVSLS", "cvSuperLUMTSetup", 
+		    MSGSP_JAC_NOSET);
+    free(cvsls_mem); cvsls_mem = NULL;
+    return(CVSLS_JAC_NOSET);
+  }
+
+  /* Determine whether Jacobian needs to be recalculated */
+  dgamma = SUNRabs((gamma/gammap) - ONE);
+  jbad = (nst == 0) || (nst > nstlj + CVS_MSBJ) ||
+         ((convfail == CV_FAIL_BAD_J) && (dgamma < CVS_DGMAX)) ||
+         (convfail == CV_FAIL_OTHER);
+  jok = !jbad;
+  
+  if (jok) {
+    /* If jok = TRUE, use saved copy of J */
+    *jcurPtr = FALSE;
+    SparseCopyMat(savedJ, JacMat);
+  } else {
+    /* If jok = FALSE, call jac routine for new J value */
+    cvsls_mem->s_nje++;
+    cvsls_mem->s_nstlj = nst;
+    *jcurPtr = TRUE;
+    SparseSetMatToZero(JacMat);
+    retval = jaceval(tn, ypred, fpred, JacMat, jacdata, vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      cvProcessError(cv_mem, CVSLS_JACFUNC_UNRECVR, "CVSLS", "cvSuperLUMTSetup", MSGSP_JACFUNC_FAILED);
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_RECVR;
+      return(1);
+    }
+
+    SparseCopyMat(JacMat, savedJ);
+  }
+
+  /* Scale and add I to get M = I - gamma*J */
+  SparseScaleMat(-gamma, JacMat);
+  SparseAddIdentityMat(JacMat);
+
+  if (A->Store) {
+    SUPERLU_FREE(A->Store);
+  }
+  dCreate_CompCol_Matrix(A, JacMat->M, JacMat->N, JacMat->NNZ, 
+			 JacMat->data, JacMat->indexvals, JacMat->indexptrs, 
+			 SLU_NC, SLU_D, SLU_GE);
+
+  if (cvsls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get column permutation vector perm_c[], according to permc_spec:
+       permc_spec = 3: approximate minimum degree for unsymmetric matrices
+       ------------------------------------------------------------*/ 
+    permc_spec = slumt_data->s_ordering;
+    get_perm_c(permc_spec, A, perm_c);
+
+    refact= NO;
+    cvsls_mem->s_first_factorize = 0;
+  }
+  else {
+    /* ------------------------------------------------------------
+       Re-initialize statistics variables 
+       ------------------------------------------------------------*/
+    StatInit(JacMat->N, nprocs, Gstat);
+    Destroy_CompCol_Permuted(AC);
+    refact= YES;
+  }
+
+  /* ------------------------------------------------------------
+     Initialize the option structure superlumt_options using the
+     user-input parameters;  Subsequent calls will re-initialize
+     options.
+     Apply perm_c to the columns of original A to form AC.
+     ------------------------------------------------------------*/
+  pdgstrf_init(nprocs, fact, trans, refact, panel_size, relax,
+	       diag_pivot_thresh, usepr, drop_tol, perm_c, perm_r,
+	       work, lwork, A, AC, superlumt_options, Gstat);
+  /* ------------------------------------------------------------
+     Compute the LU factorization of A.
+     The following routine will create nprocs threads.
+     ------------------------------------------------------------*/
+  pdgstrf(superlumt_options, AC, perm_r, L, U, Gstat, &info);
+    
+  if (info != 0) {
+    cvsls_mem->s_last_flag = info;
+    return(+1);
+  }
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the CVSuperLUMT linear
+  solver module.  It calls the SuperLU_MT solve routine,
+  then returns CVSLS_SUCCESS = 0.
+*/
+
+static int cvSuperLUMTSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+			    N_Vector ycur, N_Vector fcur)
+{
+  int info, trans, lmm;
+  int *perm_r, *perm_c;
+  realtype gamrat;
+  CVSlsMem cvsls_mem;
+  SuperMatrix *L, *U, *B;
+  Gstat_t *Gstat;
+  DNformat *Bstore;
+  SLUMTData slumt_data;
+  realtype *bd;
+  
+  gamrat = cv_mem->cv_gamrat;
+  lmm = cv_mem->cv_lmm;
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  Gstat = slumt_data->Gstat;
+  B = slumt_data->s_B;
+   
+  bd = N_VGetArrayPointer(b);
+  Bstore = (DNformat *) (B->Store);
+  Bstore->nzval = bd;
+
+  /* Call SuperLUMT to solve the linear system using L and U */
+  trans = NOTRANS;
+  dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, &info);
+
+  /* Scale the correction to account for change in gamma. */
+  if ((lmm == CV_BDF) && (gamrat != ONE)) {
+    N_VScale(TWO/(ONE + gamrat), b, b);
+  }
+
+  Bstore->nzval = NULL;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+  return(CVSLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the CVSuperLUMT linear solver.
+*/
+
+static int cvSuperLUMTFree(CVodeMem cv_mem)
+{
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+  
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  pxgstrf_finalize(slumt_data->superlumt_options, slumt_data->s_AC);
+
+  free(slumt_data->perm_r);
+  free(slumt_data->perm_c);
+  free(slumt_data->superlumt_options);
+  Destroy_SuperNode_SCP( (slumt_data->s_L) );
+  Destroy_CompCol_NCP( (slumt_data->s_U) );
+  StatFree( (slumt_data->Gstat) );
+  free(slumt_data->Gstat);
+  
+  Destroy_SuperMatrix_Store(slumt_data->s_B);
+  SUPERLU_FREE(slumt_data->s_A->Store);
+  if (cvsls_mem->s_JacMat) {
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    cvsls_mem->s_JacMat = NULL;
+  }
+  if (cvsls_mem->s_savedJ) {
+    SparseDestroyMat(cvsls_mem->s_savedJ);
+    cvsls_mem->s_savedJ = NULL;
+  }
+
+  free(slumt_data->s_B);
+  free(slumt_data->s_A);
+  free(slumt_data->s_AC);
+  free(slumt_data->s_L);
+  free(slumt_data->s_U);
+
+  free(slumt_data); 
+  slumt_data = NULL;
+  free(cv_mem->cv_lmem); 
+
+  return(0);
+}
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVSuperLUMTSetOrdering sets the ordering used by SuperLUMT for reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int CVSuperLUMTSetOrdering(void *cv_mem_v, int ordering_choice)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+
+ /* Return immediately if cv_mem is NULL */
+  if (cv_mem_v == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSuperLUMTSetOrdering",
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cv_mem_v;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) && (ordering_choice != 3) ) {
+    cvProcessError(NULL, CVSLS_ILL_INPUT, "CVSLS", "CVSuperLUMTSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  slumt_data->s_ordering = ordering_choice;
+
+  return(CVSLS_SUCCESS);
+}
diff --git a/src/cvode/fcmix/CMakeLists.txt b/src/cvode/fcmix/CMakeLists.txt
index 0c19eaa..44a82d4 100644
--- a/src/cvode/fcmix/CMakeLists.txt
+++ b/src/cvode/fcmix/CMakeLists.txt
@@ -19,6 +19,24 @@ ELSE(LAPACK_FOUND)
   SET(fcvode_BL_SOURCES "")
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND OR SUPERLUMT_FOUND)
+  SET(fcvode_SPARSE_SOURCES fcvsparse.c)
+ELSE(SPARSE_FOUND)
+  SET(fcvode_SPARSE_SOURCES "")
+ENDIF(KLU_FOUND OR SUPERLUMT_FOUND)
+
+IF(KLU_FOUND)
+  SET(fcvode_KLU_SOURCES fcvklu.c)
+ELSE(KLU_FOUND)
+  SET(fcvode_KLU_SOURCES "")
+ENDIF(KLU_FOUND)
+
+IF(SUPERLUMT_FOUND)
+  SET(fcvode_SUPERLUMT_SOURCES fcvsuperlumt.c)
+ELSE(SUPERLUMT_FOUND)
+  SET(fcvode_SUPERLUMT_SOURCES "")
+ENDIF(SUPERLUMT_FOUND)
+
 # Add source directories to include directories for access to
 # implementation only header files (both for fcvode and cvode)
 INCLUDE_DIRECTORIES(.)
@@ -32,7 +50,7 @@ ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
 # coming from inexistent user-provided functions)
 
 # Add the build target for the FCVODE library
-ADD_LIBRARY(sundials_fcvode_static STATIC ${fcvode_SOURCES} ${fcvode_BL_SOURCES})
+ADD_LIBRARY(sundials_fcvode_static STATIC ${fcvode_SOURCES} ${fcvode_BL_SOURCES} ${fcvode_SPARSE_SOURCES} ${fcvode_KLU_SOURCES} ${fcvode_SUPERLUMT_SOURCES})
 
 # Set the library name and make sure it is not deleted
 SET_TARGET_PROPERTIES(sundials_fcvode_static
diff --git a/src/cvode/fcmix/Makefile.in b/src/cvode/fcmix/Makefile.in
deleted file mode 100644
index 9dec9a6..0000000
--- a/src/cvode/fcmix/Makefile.in
+++ /dev/null
@@ -1,125 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FCVODE module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/cvode -I$(top_builddir)/include
-
-LIB_REVISION = 0:1:0
-
-FCVODE_LIB    = libsundials_fcvode.la
-
-FCVODE_SRC_FILES = fcvode.c fcvband.c fcvdense.c fcvjtimes.c fcvpreco.c fcvbbd.c fcvbp.c fcvroot.c fcvewt.c
-FCVODE_BL_SRC_FILES = fcvlapack.c fcvlapband.c fcvlapdense.c 
-
-FCVODE_OBJ_FILES = $(FCVODE_SRC_FILES:.c=.o)
-FCVODE_BL_OBJ_FILES = $(FCVODE_BL_SRC_FILES:.c=.o)
-
-FCVODE_LIB_FILES = $(FCVODE_SRC_FILES:.c=.lo)
-FCVODE_BL_LIB_FILES = $(FCVODE_BL_SRC_FILES:.c=.lo)
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(FCVODE_LIB)
-
-$(FCVODE_LIB): $(FCVODE_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: $(FCVODE_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(FCVODE_LIB) $(FCVODE_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -static -version-info $(LIB_REVISION)
-
-lib_with_bl: $(FCVODE_LIB_FILES) $(FCVODE_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(FCVODE_LIB) $(FCVODE_LIB_FILES) $(FCVODE_BL_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -static -version-info $(LIB_REVISION)
-
-install: $(FCVODE_LIB)
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(FCVODE_LIB) $(libdir)
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(FCVODE_LIB)
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(FCVODE_LIB)
-	rm -f $(FCVODE_LIB_FILES)
-	rm -f $(FCVODE_BL_LIB_FILES)
-	rm -f $(FCVODE_OBJ_FILES)
-	rm -f $(FCVODE_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-fcvode.lo: $(srcdir)/fcvode.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvode.c
-fcvewt.lo: $(srcdir)/fcvewt.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvewt.c
-fcvband.lo: $(srcdir)/fcvband.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvband.c
-fcvdense.lo: $(srcdir)/fcvdense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvdense.c
-fcvlapack.lo: $(srcdir)/fcvlapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvlapack.c
-fcvlapband.lo: $(srcdir)/fcvlapband.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvlapband.c
-fcvlapdense.lo: $(srcdir)/fcvlapdense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvlapdense.c
-fcvjtimes.lo: $(srcdir)/fcvjtimes.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvjtimes.c
-fcvpreco.lo: $(srcdir)/fcvpreco.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvpreco.c
-fcvbbd.lo: $(srcdir)/fcvbbd.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvbbd.c
-fcvbp.lo: $(srcdir)/fcvbp.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvbp.c
-fcvroot.lo: $(srcdir)/fcvroot.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fcvroot.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/cvode/fcmix/fcvband.c b/src/cvode/fcmix/fcvband.c
index e7d75f0..8d40052 100644
--- a/src/cvode/fcmix/fcvband.c
+++ b/src/cvode/fcmix/fcvband.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:27:37 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for CVODE/CVBAND, for the case of 
  * a user-supplied Jacobian approximation routine.                
@@ -45,12 +50,9 @@ extern "C" {
 
 void FCV_BANDSETJAC(int *flag, int *ier)
 {
-  CVodeMem cv_mem;
-
   if (*flag == 0) {
     *ier = CVDlsSetBandJacFn(CV_cvodemem, NULL);
   } else {
-    cv_mem = (CVodeMem) CV_cvodemem;
     *ier = CVDlsSetBandJacFn(CV_cvodemem, FCVBandJac);
   }
 }
diff --git a/src/cvode/fcmix/fcvbbd.c b/src/cvode/fcmix/fcvbbd.c
index 30400da..38674b1 100644
--- a/src/cvode/fcmix/fcvbbd.c
+++ b/src/cvode/fcmix/fcvbbd.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:27:37 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This module contains the routines necessary to interface with the
  * CVBBDPRE module and user-supplied Fortran routines.
diff --git a/src/cvode/fcmix/fcvbbd.h b/src/cvode/fcmix/fcvbbd.h
index 9401141..c47aba6 100644
--- a/src/cvode/fcmix/fcvbbd.h
+++ b/src/cvode/fcmix/fcvbbd.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the Fortran interface include file for the BBD
  * preconditioner (CVBBDPRE)
@@ -36,9 +41,6 @@
  * The user-callable functions in this package, with the corresponding
  * CVODE and CVBBDPRE functions, are as follows: 
  *   FCVBBDININT   interfaces to CVBBDPrecInit
- *   FCVBBDSPTFQMR interfaces to CVBBDSptfqmr
- *   FCVBBDSPBCG   interfaces to CVBBDSpbcg
- *   FCVBBDPSGMR   interfaces to CVBBDSpgmr
  *   FCVBBDREINIT  interfaces to CVBBDPrecReInit
  *   FCVBBDOPT     accesses optional outputs
  * 
@@ -170,7 +172,7 @@
  *          See printed message for details in case of failure.
  * 
  * (4.3) Attach one of the 3 SPILS linear solvers. Make one of the 
- * following calls (see fcvode.h) for more details.
+ * following calls (see fcvode.h for more details).
  *       CALL FCVSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)
  *       CALL FCVSPBCG(IPRETYPE, MAXL, DELT, IER)
  *       CALL FCVSPTFQMR(IPRETYPE, MAXL, DELT, IER)
@@ -193,7 +195,6 @@
  *             (optional). 0.0 indicates the default, sqrt(unit roundoff).
  * IER       = return completion flag: IER=0: success, IER<0: an error occurred
  *
- *       CALL FCVBBDSPTFQMR(IPRETYPE, MAXL, DELT, IER)
  * (4.5) To specify whether the Krylov linear solver (GMRES, Bi-CGSTAB, or TFQMR)
  * should use the supplied FCVJTIMES or the internal finite difference approximation, 
  * make the call
@@ -276,23 +277,19 @@
 #ifndef _FCVBBD_H
 #define _FCVBBD_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 /* header files  */
-
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector */
 #include <sundials/sundials_types.h>   /* definition of type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* Definitions of interface function names */
 
 #if defined(SUNDIALS_F77_FUNC)
 
 #define FCV_BBDINIT    SUNDIALS_F77_FUNC(fcvbbdinit, FCVBBDINIT)
-#define FCV_BBDSPTFQMR SUNDIALS_F77_FUNC(fcvbbdsptfqmr, FCVBBDSPTFQMR)
-#define FCV_BBDSPBCG   SUNDIALS_F77_FUNC(fcvbbdspbcg, FCVBBDSPBCG)
-#define FCV_BBDSPGMR   SUNDIALS_F77_FUNC(fcvbbdspgmr, FCVBBDSPGMR)
 #define FCV_BBDREINIT  SUNDIALS_F77_FUNC(fcvbbdreinit, FCVBBDREINIT)
 #define FCV_BBDOPT     SUNDIALS_F77_FUNC(fcvbbdopt, FCVBBDOPT)
 #define FCV_GLOCFN     SUNDIALS_F77_FUNC(fcvglocfn, FCVGLOCFN)
@@ -301,9 +298,6 @@ extern "C" {
 #else
 
 #define FCV_BBDINIT    fcvbbdinit_
-#define FCV_BBDSPTFQMR fcvbbdsptfqmr_
-#define FCV_BBDSPBCG   fcvbbdspbcg_
-#define FCV_BBDSPGMR   fcvbbdspgmr_
 #define FCV_BBDREINIT  fcvbbdreinit_
 #define FCV_BBDOPT     fcvbbdopt_
 #define FCV_GLOCFN     fcvglocfn_
diff --git a/src/cvode/fcmix/fcvbp.c b/src/cvode/fcmix/fcvbp.c
index 4c6b110..204c129 100644
--- a/src/cvode/fcmix/fcvbp.c
+++ b/src/cvode/fcmix/fcvbp.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/09/30 20:51:36 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This module contains the routines necessary to interface with the
  * CVBANDPRE module and user-supplied Fortran routines.
diff --git a/src/cvode/fcmix/fcvbp.h b/src/cvode/fcmix/fcvbp.h
index 2312e9e..51d5793 100644
--- a/src/cvode/fcmix/fcvbp.h
+++ b/src/cvode/fcmix/fcvbp.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the Fortran interface include file for the BAND
  * preconditioner (CVBANDPRE).
@@ -32,9 +37,6 @@
  * The user-callable functions in this package, with the corresponding
  * CVODE and CVBBDPRE functions, are as follows: 
  *   FCVBPINIT    interfaces to CVBandPrecInit
- *   FCVBPSPTFQMR interfaces to CVBPSptfqmr
- *   FCVBPSPBCG   interfaces to CVBPSpbcg
- *   FCVBPSPGMR   interfaces to CVBPSpgmr
  *   FCVBPOPT     accesses optional outputs
  * 
  * In addition to the Fortran right-hand side function FCVFUN, the
@@ -121,7 +123,7 @@
  *
  * (3.4A) To specify the SPGMR linear solver with the CVBANDPRE preconditioner,
  * make the following call
- *       CALL FCVBPSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)
+ *       CALL FCVSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)
  * The arguments are:
  * IPRETYPE  = preconditioner type: 
  *            0 = none
@@ -135,7 +137,7 @@
  *
  * (3.4B) To specify the SPBCG linear solver with the CVBANDPRE preconditioner,
  * make the following call
- *       CALL FCVBPSPBCG(IPRETYPE, MAXL, DELT, IER)
+ *       CALL FCVSPBCG(IPRETYPE, MAXL, DELT, IER)
  * The arguments are:
  * IPRETYPE  = preconditioner type: 
  *            0 = none
@@ -148,7 +150,7 @@
  *
  * (3.4C) To specify the SPTFQMR linear solver with the CVBANDPRE preconditioner,
  * make the following call
- *       CALL FCVBPSPTFQMR(IPRETYPE, MAXL, DELT, IER)
+ *       CALL FCVSPTFQMR(IPRETYPE, MAXL, DELT, IER)
  * The arguments are:
  * IPRETYPE  = preconditioner type: 
  *            0 = none
@@ -213,40 +215,30 @@
 #ifndef _FCVBP_H
 #define _FCVBP_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 /* header files  */
-
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector */
 #include <sundials/sundials_types.h>   /* definition of type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* Definitions of interface function names */
 
 #if defined(SUNDIALS_F77_FUNC)
 
 #define FCV_BPINIT    SUNDIALS_F77_FUNC(fcvbpinit, FCVBPINIT)
-#define FCV_BPSPTFQMR SUNDIALS_F77_FUNC(fcvbpsptfqmr, FCVBPSPTFQMR)
-#define FCV_BPSPBCG   SUNDIALS_F77_FUNC(fcvbpspbcg, FCVBPSPBCG)
-#define FCV_BPSPGMR   SUNDIALS_F77_FUNC(fcvbpspgmr, FCVBPSPGMR)
 #define FCV_BPOPT     SUNDIALS_F77_FUNC(fcvbpopt, FCVBPOPT)
 
 #else
 
 #define FCV_BPINIT    fcvbpinit_
-#define FCV_BPSPTFQMR fcvbpsptfqmr_
-#define FCV_BPSPBCG   fcvbpspbcg_
-#define FCV_BPSPGMR   fcvbpspgmr_
 #define FCV_BPOPT     fcvbpopt_
 
 #endif
 
 /* Prototypes of exported function */
 void FCV_BPINIT(long int *N, long int *mu, long int *ml, int *ier);
-void FCV_BPSPTFQMR(int *pretype, int *maxl, realtype *delt, int *ier);
-void FCV_BPSPBCG(int *pretype, int *maxl, realtype *delt, int *ier);
-void FCV_BPSPGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier);
 void FCV_BPOPT(long int *lenrwbp, long int *leniwbp, long int *nfebp);
 
 #ifdef __cplusplus
diff --git a/src/cvode/fcmix/fcvdense.c b/src/cvode/fcmix/fcvdense.c
index fa7cd4c..70f8609 100644
--- a/src/cvode/fcmix/fcvdense.c
+++ b/src/cvode/fcmix/fcvdense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:27:37 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for CVODE/CVDENSE, for the case
  * of a user-supplied Jacobian approximation routine.
@@ -45,12 +50,9 @@ extern "C" {
 
 void FCV_DENSESETJAC(int *flag, int *ier)
 {
-  CVodeMem cv_mem;
-
   if (*flag == 0) {
     *ier = CVDlsSetDenseJacFn(CV_cvodemem, NULL);
   } else {
-    cv_mem = (CVodeMem) CV_cvodemem;
     *ier = CVDlsSetDenseJacFn(CV_cvodemem, FCVDenseJac);
   }
 }
diff --git a/src/cvode/fcmix/fcvewt.c b/src/cvode/fcmix/fcvewt.c
index 60a1f8d..e18ed81 100644
--- a/src/cvode/fcmix/fcvewt.c
+++ b/src/cvode/fcmix/fcvewt.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:28:59 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for CVODE, for the case of a 
  * user-supplied error weight calculation routine.
@@ -43,10 +48,7 @@ extern "C" {
 
 void FCV_EWTSET(int *flag, int *ier)
 {
-  CVodeMem cv_mem;
-
   if (*flag != 0) {
-    cv_mem = (CVodeMem) CV_cvodemem;
     *ier = CVodeWFtolerances(CV_cvodemem, FCVEwtSet);
   }
 }
diff --git a/src/cvode/fcmix/fcvjtimes.c b/src/cvode/fcmix/fcvjtimes.c
index eb5f20e..0ad26d8 100644
--- a/src/cvode/fcmix/fcvjtimes.c
+++ b/src/cvode/fcmix/fcvjtimes.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:28:59 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * The C function FCVJtimes is to interface between the
  * CVSP* module and the user-supplied Jacobian-vector
@@ -49,12 +54,9 @@ extern "C" {
 
 void FCV_SPILSSETJAC(int *flag, int *ier)
 {
-  CVodeMem cv_mem;
-
   if (*flag == 0) {
     *ier = CVSpilsSetJacTimesVecFn(CV_cvodemem, NULL);
   } else {
-    cv_mem = (CVodeMem) CV_cvodemem;
     *ier = CVSpilsSetJacTimesVecFn(CV_cvodemem, FCVJtimes);
   }
 }
diff --git a/src/cvode/fcmix/fcvklu.c b/src/cvode/fcmix/fcvklu.c
new file mode 100644
index 0000000..ec6c77d
--- /dev/null
+++ b/src/cvode/fcmix/fcvklu.c
@@ -0,0 +1,52 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4654 $
+ * $Date: 2016-02-17 20:12:58 -0800 (Wed, 17 Feb 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the Fortran interface to
+ * the CVKLU solver. See fcvode.h for usage.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fcvode.h"
+#include "cvode_impl.h"
+#include <cvode/cvode_klu.h>
+ 
+/*
+ * ----------------------------------------------------------------
+ * Function : FCV_KLU
+ * ----------------------------------------------------------------
+ */
+
+void FCV_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier)
+{
+  *ier = CVKLU(CV_cvodemem, *neq, *nnz, *sparsetype);
+  CVKLUSetOrdering(CV_cvodemem, *ordering);
+  CV_ls = CV_LS_KLU;
+}
+
+/*
+ * ----------------------------------------------------------------
+ * Function : FCV_KLUReinit
+ * ----------------------------------------------------------------
+ */
+
+void FCV_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier)
+{
+  *ier = CVKLUReInit(CV_cvodemem, *neq, *nnz, *reinit_type);
+}
+
diff --git a/src/cvode/fcmix/fcvlapack.c b/src/cvode/fcmix/fcvlapack.c
index 62ec757..af265d9 100644
--- a/src/cvode/fcmix/fcvlapack.c
+++ b/src/cvode/fcmix/fcvlapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/11/10 21:04:11 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for CVODE/CVLAPACK
  * -----------------------------------------------------------------
diff --git a/src/cvode/fcmix/fcvlapband.c b/src/cvode/fcmix/fcvlapband.c
index e3fe9f6..476e94e 100644
--- a/src/cvode/fcmix/fcvlapband.c
+++ b/src/cvode/fcmix/fcvlapband.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:27:37 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for CVODE/CVLAPACK, for the case
  * of a user-supplied band Jacobian approximation routine.
@@ -47,19 +52,11 @@ extern "C" {
 
 void FCV_LAPACKBANDSETJAC(int *flag, int *ier)
 {
-  CVodeMem cv_mem;
-
   if (*flag == 0) {
-
     *ier = CVDlsSetBandJacFn(CV_cvodemem, NULL);
-
   } else {
-
-    cv_mem = (CVodeMem) CV_cvodemem;
     *ier = CVDlsSetBandJacFn(CV_cvodemem, FCVLapackBandJac);
-
   }
-
 }
 
 /***************************************************************************/
diff --git a/src/cvode/fcmix/fcvlapdense.c b/src/cvode/fcmix/fcvlapdense.c
index bb87e24..9c72630 100644
--- a/src/cvode/fcmix/fcvlapdense.c
+++ b/src/cvode/fcmix/fcvlapdense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:27:37 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for CVODE/CVLAPACK, for the case
  * of a user-supplied dense Jacobian approximation routine.
@@ -45,12 +50,9 @@ extern "C" {
 
 void FCV_LAPACKDENSESETJAC(int *flag, int *ier)
 {
-  CVodeMem cv_mem;
-
   if (*flag == 0) {
     *ier = CVDlsSetDenseJacFn(CV_cvodemem, NULL);
   } else {
-    cv_mem = (CVodeMem) CV_cvodemem;
     *ier = CVDlsSetDenseJacFn(CV_cvodemem, FCVLapackDenseJac);
   }
 }
diff --git a/src/cvode/fcmix/fcvode.c b/src/cvode/fcmix/fcvode.c
index 883c58d..c8c2dca 100644
--- a/src/cvode/fcmix/fcvode.c
+++ b/src/cvode/fcmix/fcvode.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/09 19:36:24 $
+ * $Revision: 4474 $
+ * $Date: 2015-04-03 10:14:53 -0700 (Fri, 03 Apr 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the Fortran interface to
  * the CVODE package.  See fcvode.h for usage.
@@ -29,6 +34,8 @@
 #include <cvode/cvode_band.h>          /* prototypes for CVBAND interface routines       */
 #include <cvode/cvode_dense.h>         /* prototypes for CVDENSE interface routines      */
 #include <cvode/cvode_diag.h>          /* prototypes for CVDIAG interface routines       */
+#include <cvode/cvode_klu.h>           /* prototypes for CVKLU interface routines        */
+#include <cvode/cvode_superlumt.h>     /* prototypes for CVSUPERLUMT interface routines  */
 #include <cvode/cvode_spgmr.h>         /* prototypes for CVSPGMR interface routines      */
 #include <cvode/cvode_spbcgs.h>        /* prototypes for CVSPBCG interface routines      */
 #include <cvode/cvode_sptfqmr.h>       /* prototypes for CVSPTFQMR interface routines    */
@@ -227,21 +234,21 @@ void FCV_REINIT(realtype *t0, realtype *y0,
 
 /***************************************************************************/
 
-void FCV_SETIIN(char key_name[], long int *ival, int *ier, int key_len)
+void FCV_SETIIN(char key_name[], long int *ival, int *ier)
 {
-  if (!strncmp(key_name,"MAX_ORD", (size_t)key_len)) 
+  if (!strncmp(key_name,"MAX_ORD",7))
     *ier = CVodeSetMaxOrd(CV_cvodemem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NSTEPS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NSTEPS",10))
     *ier = CVodeSetMaxNumSteps(CV_cvodemem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_ERRFAIL", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_ERRFAIL",11))
     *ier = CVodeSetMaxErrTestFails(CV_cvodemem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NITERS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NITERS",10))
     *ier = CVodeSetMaxNonlinIters(CV_cvodemem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_CONVFAIL", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_CONVFAIL",12))
     *ier = CVodeSetMaxConvFails(CV_cvodemem, (int) *ival);
-  else if (!strncmp(key_name,"HNIL_WARNS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"HNIL_WARNS",10))
     *ier = CVodeSetMaxHnilWarns(CV_cvodemem, (int) *ival);
-  else if (!strncmp(key_name,"STAB_LIM", (size_t)key_len)) 
+  else if (!strncmp(key_name,"STAB_LIM",8))
     *ier = CVodeSetStabLimDet(CV_cvodemem, (int) *ival);
   else {
     *ier = -99;
@@ -252,17 +259,17 @@ void FCV_SETIIN(char key_name[], long int *ival, int *ier, int key_len)
 
 /***************************************************************************/
 
-void FCV_SETRIN(char key_name[], realtype *rval, int *ier, int key_len)
+void FCV_SETRIN(char key_name[], realtype *rval, int *ier)
 {
-  if (!strncmp(key_name,"INIT_STEP", (size_t)key_len)) 
+  if (!strncmp(key_name,"INIT_STEP",9))
     *ier = CVodeSetInitStep(CV_cvodemem, *rval);
-  else if (!strncmp(key_name,"MAX_STEP", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_STEP",8))
     *ier = CVodeSetMaxStep(CV_cvodemem, *rval);
-  else if (!strncmp(key_name,"MIN_STEP", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MIN_STEP",8))
     *ier = CVodeSetMinStep(CV_cvodemem, *rval);
-  else if (!strncmp(key_name,"STOP_TIME", (size_t)key_len)) 
+  else if (!strncmp(key_name,"STOP_TIME",9))
     *ier = CVodeSetStopTime(CV_cvodemem, *rval);
-  else if (!strncmp(key_name,"NLCONV_COEF", (size_t)key_len)) 
+  else if (!strncmp(key_name,"NLCONV_COEF",11))
     *ier = CVodeSetNonlinConvCoef(CV_cvodemem, *rval);
   else {
     *ier = -99;
@@ -496,6 +503,11 @@ void FCV_CVODE(realtype *tout, realtype *t, realtype *y, int *itask, int *ier)
     CVDiagGetLastFlag(CV_cvodemem, &CV_iout[14]);                 /* LSTF */
     CVDiagGetNumRhsEvals(CV_cvodemem, &CV_iout[15]);              /* NFELS */
     break;
+  case CV_LS_KLU:
+  case CV_LS_SUPERLUMT:
+    CVSlsGetLastFlag(CV_cvodemem, &CV_iout[14]);                  /* LSTF  */
+    CVSlsGetNumJacEvals(CV_cvodemem, &CV_iout[16]);               /* NJE   */
+    break;
   case CV_LS_SPGMR:
   case CV_LS_SPBCG:
   case CV_LS_SPTFQMR:
@@ -520,12 +532,13 @@ void FCV_DKY (realtype *t, int *k, realtype *dky, int *ier)
      F2C_CVODE_vec is the N_Vector containing the solution derivative on return 
   */
 
+  realtype *f2c_data = N_VGetArrayPointer(F2C_CVODE_vec);
   N_VSetArrayPointer(dky, F2C_CVODE_vec);
 
   *ier = 0;
   *ier = CVodeGetDky(CV_cvodemem, *t, *k, F2C_CVODE_vec);
 
-  N_VSetArrayPointer(NULL, F2C_CVODE_vec);
+  N_VSetArrayPointer(f2c_data, F2C_CVODE_vec);
 
 }
 
@@ -534,13 +547,14 @@ void FCV_DKY (realtype *t, int *k, realtype *dky, int *ier)
 void FCV_GETERRWEIGHTS(realtype *eweight, int *ier)
 {
   /* Attach user data to vector */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_CVODE_vec);
   N_VSetArrayPointer(eweight, F2C_CVODE_vec);
 
   *ier = 0;
   *ier = CVodeGetErrWeights(CV_cvodemem, F2C_CVODE_vec);
 
   /* Reset data pointers */
-  N_VSetArrayPointer(NULL, F2C_CVODE_vec);
+  N_VSetArrayPointer(f2c_data, F2C_CVODE_vec);
 
   return;
 }
@@ -550,13 +564,14 @@ void FCV_GETERRWEIGHTS(realtype *eweight, int *ier)
 void FCV_GETESTLOCALERR(realtype *ele, int *ier)
 {
   /* Attach user data to vector */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_CVODE_vec);
   N_VSetArrayPointer(ele, F2C_CVODE_vec);
 
   *ier = 0;
   *ier = CVodeGetEstLocalErrors(CV_cvodemem, F2C_CVODE_vec);
 
   /* Reset data pointers */
-  N_VSetArrayPointer(NULL, F2C_CVODE_vec);
+  N_VSetArrayPointer(f2c_data, F2C_CVODE_vec);
 
   return;
 }
diff --git a/src/cvode/fcmix/fcvode.h b/src/cvode/fcmix/fcvode.h
index 08232af..8552987 100644
--- a/src/cvode/fcmix/fcvode.h
+++ b/src/cvode/fcmix/fcvode.h
@@ -1,15 +1,21 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:27:37 $
+ * $Revision: 4795 $
+ * $Date: 2016-07-01 15:10:25 -0700 (Fri, 01 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
+ *                Ting Yan and Daniel R. Reynolds @ SMU
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for FCVODE, the Fortran interface to
  * the CVODE package.                                            
@@ -34,6 +40,8 @@
  * 
  *   FNVINITS and FNVINITP interface to N_VNew_Serial and
  *               N_VNew_Parallel, respectively
+ *   FNVINITOMP               N_VNew_OpenMP
+ *   FNVINITPTS               N_VNew_Pthreads
  * 
  *   FCVMALLOC  interfaces to CVodeCreate, CVodeSetUserData, and CVodeInit
  * 
@@ -56,6 +64,11 @@
  *   FCVLAPACKDENSESETJAC  interfaces to CVLapackSetJacFn
  *   FCVLAPACKBANDSETJAC   interfaces to CVLapackSetJacFn
  *
+ *   FCVKLU             interfaces to CVKLU
+ *   FCVKLUReinit       interfaces to CVKLUReinit
+ *   FCVSUPERLUMT       interfaces to CVSuperLUMT
+ *   FCVSPARSESETJAC    interfaces to CVSlsSetSparseJacFn
+ *
  *   FCVSPGMR and FCVSPGMRREINIT interface to CVSpgmr and CVSpilsSet*
  *   FCVSPBCG, FCVSPBCGREINIT interface to CVSpbcg and CVSpilsSet*
  *   FCVSPTFQMR, FCVSPTFQMRREINIT interface to CVSptfqmr and CVSpilsSet*
@@ -83,6 +96,7 @@
  *   FCVPSOL   is called by the interface fn. FCVPSol of type CVSpilsPrecSolveFn
  *   FCVPSET   is called by the interface fn. FCVPSet of type CVSpilsPrecSetupFn
  *   FCVJTIMES is called by interface fn. FCVJtimes of type CVSpilsJacTimesVecFn
+ *   FCVSPJAC  is called by interface fn. FCVSparseJac of type CVSlsSparseJacFn
  *   FCVEWT    is called by interface fn. FCVEwtSet of type CVEwtFn
  * In contrast to the case of direct use of CVODE, and of most Fortran ODE
  * solvers, the names of all user-supplied routines here are fixed, in
@@ -153,15 +167,55 @@
  * On return, set IER = 0 if successful, IER > 0 if a recoverable error occurred,
  * and IER < 0 if an unrecoverable error ocurred.
  * 
- * (4s) Optional user-supplied Lapack dense Jacobian routine: FCVLDJAC
+ * (4s) User-supplied sparse Jacobian approximation routine: FCVSPJAC
+ *
+ * Required when using the CVKLU or CVSuperLUMT linear solvers, the 
+ * user must supply a routine that computes a compressed-sparse-column [or 
+ * compressed-sparse-row] approximation of the system Jacobian J = dfi(t,y)/dy.  
+ * If supplied, it must have the following form:
+ *
+ *       SUBROUTINE FCVSPJAC(T, Y, FY, N, NNZ, JDATA, JRVALS, 
+ *      &                     JCPTRS, H, IPAR, RPAR, WK1, WK2, WK3, IER)
+ *
+ * This routine must load the N by N compressed sparse column [or row] matrix 
+ * with storage for NNZ nonzeros, stored in the arrays JDATA (nonzero
+ * values), JRVALS (row [or column] indices for each nonzero), JCOLPTRS (indices 
+ * for start of each column [or row]), with the Jacobian matrix at the current
+ * (t,y) in CSC [or CSR] form (see sundials_sparse.h for more information).
+ *
+ * The arguments are:
+ *         T    -- current time [realtype, input]
+ *         Y    -- array containing state variables [realtype, input]
+ *         FY   -- array containing state derivatives [realtype, input]
+ *         N    -- number of matrix rows/columns in Jacobian [int, input]
+ *         NNZ  -- allocated length of nonzero storage [int, input]
+ *        JDATA -- nonzero values in Jacobian
+ *                 [realtype of length NNZ, output]
+ *       JRVALS -- row [or column] indices for each nonzero in Jacobian
+ *                  [int of length NNZ, output]
+ *       JCPTRS -- pointers to each Jacobian column [or row] in preceding arrays
+ *                 [int of length N+1, output]
+ *         H    -- current step size [realtype, input]
+ *         IPAR -- array containing integer user data that was passed to
+ *                 FCVMALLOC [long int, input]
+ *         RPAR -- array containing real user data that was passed to
+ *                 FCVMALLOC [realtype, input]
+ *         WK*  -- array containing temporary workspace of same size as Y 
+ *                 [realtype, input]
+ *         IER  -- return flag [int, output]:
+ *                    0 if successful, 
+ *                   >0 if a recoverable error occurred,
+ *                   <0 if an unrecoverable error ocurred.
+ *
+ * (5s) Optional user-supplied Lapack dense Jacobian routine: FCVLDJAC
  * See the description for FCVDJAC. NOTE: the dense Jacobian matrix
  * is NOT set to zero before calling the user's FCVLDJAC.
  *
- * (5s) Optional user-supplied Lapack band Jacobian routine: FCVLBJAC
+ * (6s) Optional user-supplied Lapack band Jacobian routine: FCVLBJAC
  * See the description for FCVBJAC. NOTE: the band Jacobian matrix
  * is NOT set to zero before calling the user's FCVLBJAC.
  *
- * (6) Optional user-supplied Jacobian-vector product routine: FCVJTIMES
+ * (7) Optional user-supplied Jacobian-vector product routine: FCVJTIMES
  * As an option when using the SP* linear solver, the user may supply
  * a routine that computes the product of the system Jacobian J = df/dy and 
  * a given vector v.  If supplied, it must have the following form:
@@ -173,7 +227,7 @@
  * and nonzero otherwise.
  * IPAR and RPAR are user (integer and real) arrays passed to FCVMALLOC.
  * 
- * (7) Optional user-supplied error weight vector routine: FCVEWT
+ * (8) Optional user-supplied error weight vector routine: FCVEWT
  * As an option to providing the relative and absolute tolerances, the user
  * may supply a routine that computes the weights used in the WRMS norms.
  * If supplied, it must have the following form:
@@ -185,17 +239,18 @@
  *
  * -----------------------------------------------------------------------------
  *
- * (8) Initialization:  FNVINITS / FNVINITP , FCVMALLOC, FCVREINIT
+ * (9) Initialization:  FNVINITS/FNVINITP/FNVINITOMP/FNVINITPTS, 
+ *                      FCVMALLOC, FCVREINIT
  * 
- * (8.1s) To initialize the serial machine environment, the user must make
+ * (9.1s) To initialize the serial machine environment, the user must make
  * the following call:
  *        CALL FNVINITS (1, NEQ, IER)
  * where the first argument is the CVODE solver ID. The other arguments are:
  * NEQ     = size of vectors
  * IER     = return completion flag. Values are 0 = success, -1 = failure.
  * 
- * (8.1p) To initialize the parallel machine environment, the user must make 
- * the following call:
+ * (9.1p) To initialize the distributed memory parallel machine environment, 
+ * the user must make the following call:
  *        CALL FNVINITP (1, NLOCAL, NGLOBAL, IER)
  * The arguments are:
  * NLOCAL  = local size of vectors on this processor
@@ -206,7 +261,27 @@
  * set to MPI_COMM_WORLD.  If not, this routine initializes MPI and sets
  * the communicator equal to MPI_COMM_WORLD.
  * 
- * (8.2) To set various problem and solution parameters and allocate
+ * (9.1omp) To initialize the openMP threaded vector kernel, 
+ *          the user must make the following call:
+ *
+ *          CALL FNVINITOMP (1, NEQ, NUM_THREADS, IER)
+ *
+ *        The arguments are:
+ *          NEQ = size of vectors
+ *          NUM_THREADS = number of threads
+ *          IER = return completion flag. Values are 0 = success, -1 = failure.
+ *
+ * (9.1pts) To initialize the Pthreads threaded vector kernel, 
+ *          the user must make the following call:
+ *
+ *          CALL FNVINITOMP (1, NEQ, NUM_THREADS, IER)
+ *
+ *        The arguments are:
+ *          NEQ = size of vectors
+ *          NUM_THREADS = number of threads
+ *          IER = return completion flag. Values are 0 = success, -1 = failure.
+ *
+ * (9.2) To set various problem and solution parameters and allocate
  * internal memory, make the following call:
  *       CALL FCVMALLOC(T0, Y0, METH, ITMETH, IATOL, RTOL, ATOL,
  *      1               IOUT, ROUT, IPAR, RPAR, IER)
@@ -262,7 +337,7 @@
  * with FLAG = 1 to specify that FCVEWT is provided.
  * The return flag IER is 0 if successful, and nonzero otherwise.
  *
- * (8.3) To re-initialize the CVODE solver for the solution of a new problem
+ * (9.3) To re-initialize the CVODE solver for the solution of a new problem
  * of the same size as one already solved, make the following call:
  *       CALL FCVREINIT(T0, Y0, IATOL, RTOL, ATOL, IER)
  * The arguments have the same names and meanings as those of FCVMALLOC,
@@ -273,7 +348,7 @@
  * previous  FCVMALLOC call.  The call to specify the linear system solution
  * method may or may not be needed; see paragraph (7) below.
  * 
- * (8.4) To set various integer optional inputs, make the folowing call:
+ * (9.4) To set various integer optional inputs, make the folowing call:
  *       CALL FCVSETIIN(KEY, VALUE, IER)
  * to set the integer value VAL to the optional input specified by the
  * quoted character string KEY.
@@ -292,14 +367,14 @@
  *
  * -----------------------------------------------------------------------------
  *
- * (9) Specification of linear system solution method.
+ * (10) Specification of linear system solution method.
  * In the case of a stiff system, the implicit BDF method involves the solution
  * of linear systems related to the Jacobian J = df/dy of the ODE system.
  * CVODE presently includes four choices for the treatment of these systems,
  * and the user of FCVODE must call a routine with a specific name to make the
  * desired choice.
  * 
- * (9.1) Diagonal approximate Jacobian.
+ * (10.1) Diagonal approximate Jacobian.
  * This choice is appropriate when the Jacobian can be well approximated by
  * a diagonal matrix.  The user must make the call:
  *       CALL FCVDIAG(IER)
@@ -313,7 +388,7 @@
  *        NFELS   = IOUT(16) from CVDiagGetNumRhsEvals
  * See the CVODE manual for descriptions.
  * 
- * (9.2s) DENSE treatment of the linear system.
+ * (10.2s) DENSE treatment of the linear system.
  * The user must make the call
  *       CALL FCVDENSE(NEQ, IER)
  * The argument is:
@@ -334,7 +409,7 @@
  *        NJED    = IOUT(17) from CVDenseGetNumJacEvals
  * See the CVODE manual for descriptions.
  * 
- * (9.3s) BAND treatment of the linear system
+ * (10.3s) BAND treatment of the linear system
  * The user must make the call
  *       CALL FCVBAND(NEQ, MU, ML, IER)
  * The arguments are:
@@ -357,7 +432,7 @@
  *        NJEB    = IOUT(17) from CVBandGetNumJacEvals
  * See the CVODE manual for descriptions.
  *
- * (9.4s) LAPACK dense treatment of the linear system
+ * (10.4s) LAPACK dense treatment of the linear system
  * The user must make the call
  *       CALL FCVLAPACKDENSE(NEQ, IER)
  * and, optionally
@@ -365,7 +440,7 @@
  * with FLAG=1 if the user provides the function FCVLDJAC. 
  * See (9.2s) for more details.
  *
- * (9.5s) LAPACK band treatment of the linear system
+ * (10.5s) LAPACK band treatment of the linear system
  * The user must make the call
  *       CALL FCVLAPACKBAND(NEQ, IER)
  * and, optionally
@@ -373,7 +448,95 @@
  * with FLAG=1 if the user provides the function FCVLBJAC. 
  * See (9.3s)
  *
- * (9.6) SPGMR treatment of the linear systems.
+ *  (10.6s) SPARSE treatment of the linear system using the KLU solver.
+ *
+ *     The user must make the call
+ *
+ *       CALL FCVKLU(NEQ, NNZ, SPARSETYPE, ORDERING, IER)
+ *
+ *     The arguments are:
+ *        NEQ = the problem size [int; input]
+ *        NNZ = the maximum number of nonzeros [int; input]
+ *        SPARSETYPE = choice between CSC and CSR format
+ *           (0 = CSC, 1 = CSR) [int; input]
+ *        ORDERING = the matrix ordering desired, possible values
+ *           come from the KLU package (0 = AMD, 1 = COLAMD) [int; input]
+ *        IER = error return flag [int, output]: 
+ *	         0 = success, 
+ *		 negative = error.
+ *
+ *     When using the KLU solver the user must provide the FCVSPJAC routine for the 
+ *     evalution of the sparse approximation to the Jacobian. To indicate that this
+ *     routine has been provided, after the call to FCVKLU, the following call must 
+ *     be made    
+ *
+ *       CALL FCVSPARSESETJAC(IER) 
+ *
+ *     The int return flag IER=0 if successful, and nonzero otherwise.
+ *
+ *  
+ *     The CVODE KLU solver will reuse much of the factorization information from one
+ *     nonlinear iteration to the next.  If at any time the user wants to force a full
+ *     refactorization or if the number of nonzeros in the Jacobian matrix changes, the
+ *     user should make the call
+ *
+ *       CALL FCVKLUREINIT(NEQ, NNZ, REINIT_TYPE)
+ *
+ *     The arguments are:
+ *        NEQ = the problem size [int; input]
+ *        NNZ = the maximum number of nonzeros [int; input]
+ *	REINIT_TYPE = 1 or 2.  For a value of 1, the matrix will be destroyed and 
+ *          a new one will be allocated with NNZ nonzeros.  For a value of 2, 
+ *	  only symbolic and numeric factorizations will be completed. 
+ * 
+ *     When using FCVKLU, the user is required to supply the FCVSPJAC 
+ *     routine for the evaluation of the sparse approximation to the 
+ *     Jacobian, as discussed above with the other user-supplied routines.
+ * 
+ *     Optional outputs specific to the KLU case are:
+ *        LSTF    = IOUT(14) from CVSlsGetLastFlag
+ *        NJES    = IOUT(16) from CVSlsGetNumJacEvals
+ *     See the CVODE manual for descriptions.
+ * 
+ * (10.7s) SPARSE treatment of the linear system using the SuperLUMT solver.
+ *
+ *     The user must make the call
+ *
+ *       CALL FCVSUPERLUMT(NTHREADS, NEQ, NNZ, ORDERING, IER)
+ *
+ *     The arguments are:
+ *        NTHREADS = desired number of threads to use [int; input]
+ *        NEQ = the problem size [int; input]
+ *        NNZ = the maximum number of nonzeros [int; input]
+ *	ORDERING = the matrix ordering desired, possible values
+ *	   come from the SuperLU_MT package [int; input]
+ *           0 = Natural
+ *           1 = Minimum degree on A^T A
+ *           2 = Minimum degree on A^T + A
+ *           3 = COLAMD
+ *	IER = error return flag [int, output]: 
+ *	         0 = success, 
+ *		 negative = error.
+ *	 
+ *     At this time, there is no reinitialization capability for the SUNDIALS 
+ *     interfaces to the SuperLUMT solver.
+ *
+ *     When using the SuperLUMT solver the user must providing the FCVSPJAC routine
+ *     for the evalution of the CSC approximation to the Jacobian (note: the current 
+ *     SuperLU_MT interface in SUNDIALS does not support CSR matrices). To indicate 
+ *     that this routine has been provided, after the call to FCVSUPERLUMT, the following
+ *     call must be made    
+ *
+ *       CALL FCVSPARSESETJAC(IER) 
+ *
+ *     The int return flag IER=0 if successful, and nonzero otherwise.
+ * 
+ *     Optional outputs specific to the SUPERLUMT case are:
+ *        LSTF    = IOUT(14) from CVSlsGetLastFlag
+ *        NJES    = IOUT(16) from CVSlsGetNumJacEvals
+ *     See the CVODE manual for descriptions.
+ * 
+ * (10.8) SPGMR treatment of the linear systems.
  * For the Scaled Preconditioned GMRES solution of the linear systems,
  * the user must make the following call:
  *       CALL FCVSPGMR(IPRETYPE, IGSTYPE, MAXL, DELT, IER)              
@@ -411,7 +574,7 @@
  * The arguments have the same meanings as for FCVSPGMR.  If MAXL is being
  * changed, then call FCVSPGMR instead.
  * 
- * (9.7) SPBCG treatment of the linear systems.
+ * (10.9) SPBCG treatment of the linear systems.
  * For the Scaled Preconditioned Bi-CGSTAB solution of the linear systems,
  * the user must make the following call:
  *       CALL FCVSPBCG(IPRETYPE, MAXL, DELT, IER)              
@@ -444,7 +607,7 @@
  *       CALL FCVSPBCGREINIT(IPRETYPE, MAXL, DELT, IER)              
  * The arguments have the same meanings as for FCVSPBCG.
  *
- * (9.8) SPTFQMR treatment of the linear systems.
+ * (10.10) SPTFQMR treatment of the linear systems.
  * For the Scaled Preconditioned TFQMR solution of the linear systems,
  * the user must make the following call:
  *       CALL FCVSPTFQMR(IPRETYPE, MAXL, DELT, IER)              
@@ -477,7 +640,7 @@
  *       CALL FCVSPTFQMRREINIT(IPRETYPE, MAXL, DELT, IER)              
  * The arguments have the same meanings as for FCVSPTFQMR.
  *
- * (9.9) Usage of user-supplied routines for the Krylov solvers
+ * (10.11) Usage of user-supplied routines for the Krylov solvers
  *
  * If the user program includes the FCVJTIMES routine for the evaluation of the 
  * Jacobian vector product, the following call must be made
@@ -505,7 +668,7 @@
  *
  * -----------------------------------------------------------------------------
  *
- * (10) The integrator: FCVODE
+ * (11) The integrator: FCVODE
  * Carrying out the integration is accomplished by making calls as follows:
  *       CALL FCVODE (TOUT, T, Y, ITASK, IER)
  * The arguments are:
@@ -524,7 +687,7 @@
  * 
  * -----------------------------------------------------------------------------
  *
- * (11) Computing solution derivatives: FCVDKY
+ * (12) Computing solution derivatives: FCVDKY
  * To obtain a derivative of the solution, of order up to the current method
  * order, make the following call:
  *       CALL FCVDKY (T, K, DKY, IER)
@@ -536,7 +699,7 @@
  * 
  * -----------------------------------------------------------------------------
  *
- * (12) Memory freeing: FCVFREE 
+ * (13) Memory freeing: FCVFREE 
  * To free the internal memory created by the calls to FCVMALLOC and
  * FNVINITS or FNVINITP, make the call
  *       CALL FCVFREE
@@ -547,17 +710,17 @@
 #ifndef _FCVODE_H
 #define _FCVODE_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 /* header files  */
-
 #include <cvode/cvode.h>
 #include <sundials/sundials_direct.h>  /* definition of type DlsMat   */
+#include <sundials/sundials_sparse.h>  /* definition of type SlsMat   */
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector */
 #include <sundials/sundials_types.h>   /* definition of type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* Definitions of interface function names */
 
 #if defined(SUNDIALS_F77_FUNC)
@@ -576,6 +739,10 @@ extern "C" {
 #define FCV_LAPACKDENSESETJAC   SUNDIALS_F77_FUNC(fcvlapackdensesetjac, FCVLAPACKDENSESETJAC)
 #define FCV_LAPACKBAND     SUNDIALS_F77_FUNC(fcvlapackband, FCVLAPACKBAND)
 #define FCV_LAPACKBANDSETJAC    SUNDIALS_F77_FUNC(fcvlapackbandsetjac, FCVLAPACKBANDSETJAC)
+#define FCV_KLU            SUNDIALS_F77_FUNC(fcvklu, FCVKLU)
+#define FCV_KLUREINIT      SUNDIALS_F77_FUNC(fcvklureinit, FCVKLUREINIT)
+#define FCV_SUPERLUMT      SUNDIALS_F77_FUNC(fcvsuperlumt, FCVSUPERLUMT)
+#define FCV_SPARSESETJAC   SUNDIALS_F77_FUNC(fcvsparsesetjac, FCVSPARSESETJAC)  
 #define FCV_SPTFQMR        SUNDIALS_F77_FUNC(fcvsptfqmr, FCVSPTFQMR)
 #define FCV_SPTFQMRREINIT  SUNDIALS_F77_FUNC(fcvsptfqmrreinit, FCVSPTFQMRREINIT)
 #define FCV_SPBCG          SUNDIALS_F77_FUNC(fcvspbcg, FCVSPBCG)
@@ -590,6 +757,7 @@ extern "C" {
 #define FCV_FUN            SUNDIALS_F77_FUNC(fcvfun, FCVFUN)
 #define FCV_DJAC           SUNDIALS_F77_FUNC(fcvdjac, FCVDJAC)
 #define FCV_BJAC           SUNDIALS_F77_FUNC(fcvbjac, FCVBJAC)
+#define FCV_SPJAC          SUNDIALS_F77_FUNC(fcvspjac, FCVSPJAC)
 #define FCV_PSOL           SUNDIALS_F77_FUNC(fcvpsol, FCVPSOL)
 #define FCV_PSET           SUNDIALS_F77_FUNC(fcvpset, FCVPSET)
 #define FCV_JTIMES         SUNDIALS_F77_FUNC(fcvjtimes, FCVJTIMES)
@@ -613,6 +781,10 @@ extern "C" {
 #define FCV_LAPACKDENSESETJAC   fcvlapackdensesetjac_
 #define FCV_LAPACKBAND     fcvlapackband_
 #define FCV_LAPACKBANDSETJAC    fcvlapackbandsetjac_
+#define FCV_KLU            fcvklu_
+#define FCV_KLUREINIT      fcvklureinit_
+#define FCV_SUPERLUMT      fcvsuperlumt_
+#define FCV_SPARSESETJAC   fcvsparsesetjac_
 #define FCV_SPTFQMR        fcvsptfqmr_
 #define FCV_SPTFQMRREINIT  fcvsptfqmrreinit_
 #define FCV_SPBCG          fcvspbcg_
@@ -627,6 +799,7 @@ extern "C" {
 #define FCV_FUN            fcvfun_
 #define FCV_DJAC           fcvdjac_
 #define FCV_BJAC           fcvbjac_
+#define FCV_SPJAC          fcvspjac_
 #define FCV_PSOL           fcvpsol_
 #define FCV_PSET           fcvpset_
 #define FCV_JTIMES         fcvjtimes_
@@ -656,9 +829,9 @@ extern "C" {
                   int *iatol, realtype *rtol, realtype *atol,
                   int *ier);
 
-  void FCV_SETIIN(char key_name[], long int *ival, int *ier, int key_len);
+  void FCV_SETIIN(char key_name[], long int *ival, int *ier);
 
-  void FCV_SETRIN(char key_name[], realtype *rval, int *ier, int key_len);
+  void FCV_SETRIN(char key_name[], realtype *rval, int *ier);
 
   void FCV_EWTSET(int *flag, int *ier);
 
@@ -675,6 +848,11 @@ extern "C" {
   void FCV_LAPACKBAND(int *neq, int *mupper, int *mlower, int *ier);
   void FCV_LAPACKBANDSETJAC(int *flag, int *ier);
 
+  void FCV_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier);
+  void FCV_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier);
+  void FCV_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier);
+  void FCV_SPARSESETJAC(int *ier);
+
   void FCV_SPGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier);
   void FCV_SPGMRREINIT(int *pretype, int *gstype, realtype *delt, int *ier);
 
@@ -720,7 +898,11 @@ extern "C" {
                        DlsMat Jac, void *user_data,
                        N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
 
-  int FCVPSet(realtype tn, N_Vector y,N_Vector fy, booleantype jok,
+  int FCVSparseJac(realtype t, N_Vector y, N_Vector fy, SlsMat J,
+		   void *user_data, N_Vector vtemp1,
+		   N_Vector vtemp2, N_Vector vtemp3);
+
+  int FCVPSet(realtype tn, N_Vector y, N_Vector fy, booleantype jok,
               booleantype *jcurPtr, realtype gamma, void *user_data,
               N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
   
@@ -749,7 +931,8 @@ extern "C" {
 
   enum { CV_LS_DENSE = 1, CV_LS_BAND = 2, CV_LS_DIAG = 3,
          CV_LS_LAPACKDENSE = 4, CV_LS_LAPACKBAND = 5,
-	 CV_LS_SPGMR = 6, CV_LS_SPBCG = 7, CV_LS_SPTFQMR = 8 };
+	 CV_LS_KLU = 6, CV_LS_SUPERLUMT = 7, 
+	 CV_LS_SPGMR = 8, CV_LS_SPBCG = 9, CV_LS_SPTFQMR = 10 };
 
 #ifdef __cplusplus
 }
diff --git a/src/cvode/fcmix/fcvpreco.c b/src/cvode/fcmix/fcvpreco.c
index eb4203e..dcf4a80 100644
--- a/src/cvode/fcmix/fcvpreco.c
+++ b/src/cvode/fcmix/fcvpreco.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:28:59 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * The C function FCVPSet is to interface between the CVSP*
  * module and the user-supplied preconditioner setup routine FCVPSET.
@@ -56,12 +61,9 @@ extern "C" {
 
 void FCV_SPILSSETPREC(int *flag, int *ier)
 {
-  CVodeMem cv_mem;
-
   if (*flag == 0) {
     *ier = CVSpilsSetPreconditioner(CV_cvodemem, NULL, NULL);
   } else {
-    cv_mem = (CVodeMem) CV_cvodemem;
     *ier = CVSpilsSetPreconditioner(CV_cvodemem, FCVPSet, FCVPSol);
   }
 }
diff --git a/src/cvode/fcmix/fcvroot.c b/src/cvode/fcmix/fcvroot.c
index 1317f19..44eb352 100644
--- a/src/cvode/fcmix/fcvroot.c
+++ b/src/cvode/fcmix/fcvroot.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:28:59 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * The FCVROOT module contains the routines necessary to use
  * the rootfinding feature of the CVODE module and to interface
@@ -41,9 +46,6 @@ extern "C" {
 
 void FCV_ROOTINIT(int *nrtfn, int *ier)
 {
-  CVodeMem cv_mem;
-  
-  cv_mem = (CVodeMem) CV_cvodemem;
   *ier = CVodeRootInit(CV_cvodemem, *nrtfn, (CVRootFn) FCVrootfunc);
   CV_nrtfn = *nrtfn;
 
diff --git a/src/cvode/fcmix/fcvroot.h b/src/cvode/fcmix/fcvroot.h
index 5733189..8ee21b0 100644
--- a/src/cvode/fcmix/fcvroot.h
+++ b/src/cvode/fcmix/fcvroot.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the Fortran interface include file for the rootfinding
  * feature of CVODE.
@@ -95,15 +100,14 @@
 #ifndef _FCVROOT_H
 #define _FCVROOT_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 /* header files */
-
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector          */
 #include <sundials/sundials_types.h>   /* definition of SUNDIALS type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* Definitions of interface function names */
 
 #if defined(SUNDIALS_F77_FUNC)
diff --git a/src/cvode/fcmix/fcvsparse.c b/src/cvode/fcmix/fcvsparse.c
new file mode 100644
index 0000000..9dab7bc
--- /dev/null
+++ b/src/cvode/fcmix/fcvsparse.c
@@ -0,0 +1,81 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4815 $
+ * $Date: 2016-07-20 16:51:55 -0700 (Wed, 20 Jul 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ *                Ting Yan and Daniel R. Reynolds @ SMU
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fcvode.h"
+#include "cvode_impl.h"
+#include <cvode/cvode_sparse.h>
+
+/* Prototype of the Fortran routine */
+ 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+ 
+extern void FCV_SPJAC(realtype *T, realtype *Y, 
+		       realtype *FY, int *N, int *NNZ, 
+		       realtype *JDATA, int *JRVALS, 
+		       int *JCPTRS, realtype *H, 
+		       long int *IPAR, realtype *RPAR, 
+		       realtype *V1, realtype *V2, 
+		       realtype *V3, int *ier);
+ 
+#ifdef __cplusplus
+}
+#endif
+ 
+/*=============================================================*/
+
+/* Fortran interface to C routine CVSlsSetSparseJacFn; see
+   fcvode.h for further information */
+void FCV_SPARSESETJAC(int *ier)
+{
+  *ier = CVSlsSetSparseJacFn(CV_cvodemem, FCVSparseJac);
+}
+
+/*=============================================================*/
+ 
+/* C interface to user-supplied Fortran routine FCVSPJAC; see 
+   fcvode.h for additional information  */
+int FCVSparseJac(realtype t, N_Vector y, N_Vector fy, 
+		 SlsMat J, void *user_data, N_Vector vtemp1, 
+		 N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *ydata, *fydata, *v1data, *v2data, *v3data;
+  realtype h;
+  FCVUserData CV_userdata;
+
+  CVodeGetLastStep(CV_cvodemem, &h);
+  ydata   = N_VGetArrayPointer(y);
+  fydata  = N_VGetArrayPointer(fy);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  CV_userdata = (FCVUserData) user_data;
+
+  FCV_SPJAC(&t, ydata, fydata, &(J->NP), &(J->NNZ),
+	    J->data, J->indexvals, J->indexptrs, &h, 
+	    CV_userdata->ipar, CV_userdata->rpar, v1data, 
+	    v2data, v3data, &ier); 
+  return(ier);
+}
+
diff --git a/src/cvode/fcmix/fcvsuperlumt.c b/src/cvode/fcmix/fcvsuperlumt.c
new file mode 100644
index 0000000..eec7fbd
--- /dev/null
+++ b/src/cvode/fcmix/fcvsuperlumt.c
@@ -0,0 +1,42 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4402 $
+ * $Date: 2015-02-28 19:35:39 -0800 (Sat, 28 Feb 2015) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the Fortran interface to
+ * the CVSuperLUMT solver. See fcvode.h for usage.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fcvode.h"
+#include "cvode_impl.h"
+#include <cvode/cvode_superlumt.h>
+ 
+/*
+ * ----------------------------------------------------------------
+ * Function : FCV_SUPERLUMT
+ * ----------------------------------------------------------------
+ */
+
+void FCV_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier)
+{
+  *ier = CVSuperLUMT(CV_cvodemem, *nthreads, *neq, *nnz);
+  CVSuperLUMTSetOrdering(CV_cvodemem, *ordering);
+  CV_ls = CV_LS_SUPERLUMT;
+}
+
+
diff --git a/src/cvodes/CMakeLists.txt b/src/cvodes/CMakeLists.txt
index d1724b7..38229df 100644
--- a/src/cvodes/CMakeLists.txt
+++ b/src/cvodes/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:47 $
+# $Revision: 4759 $
+# $Date: 2016-05-18 16:25:17 -0700 (Wed, 18 May 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the CVODES library
 
@@ -23,6 +28,7 @@ SET(cvodes_SOURCES
   cvodes_band.c
   cvodes_dense.c
   cvodes_diag.c
+  cvodes_sparse.c
   cvodes_spils.c
   cvodes_spbcgs.c
   cvodes_spgmr.c
@@ -31,6 +37,14 @@ SET(cvodes_SOURCES
   cvodes_bbdpre.c
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND cvodes_SOURCES cvodes_klu.c)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND cvodes_SOURCES cvodes_superlumt.c)
+ENDIF()
+
 # Add variable shared_SOURCES with the common SUNDIALS sources which will
 # also be included in the CVODES library
 SET(shared_SOURCES
@@ -40,6 +54,7 @@ SET(shared_SOURCES
   sundials_band.c
   sundials_dense.c
   sundials_iterative.c
+  sundials_sparse.c
   sundials_spbcgs.c
   sundials_spgmr.c
   sundials_sptfqmr.c
@@ -57,12 +72,21 @@ SET(cvodes_HEADERS
   cvodes_diag.h
   cvodes_direct.h
   cvodes.h
+  cvodes_sparse.h
   cvodes_spbcgs.h
   cvodes_spgmr.h
   cvodes_spils.h
   cvodes_sptfqmr.h
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND cvodes_HEADERS cvodes_klu.h)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND cvodes_HEADERS cvodes_superlumt.h)
+ENDIF()
+
 # Add prefix with complete path to the CVODES header files
 ADD_PREFIX(${sundials_SOURCE_DIR}/include/cvodes/ cvodes_HEADERS)
 
diff --git a/src/cvodes/LICENSE b/src/cvodes/LICENSE
index dd9a383..7fd3a7b 100644
--- a/src/cvodes/LICENSE
+++ b/src/cvodes/LICENSE
@@ -1,10 +1,10 @@
-Copyright (c) 2002, The Regents of the University of California. 
+Copyright (c) 2002-2015, Lawrence Livermore National Security. 
 Produced at the Lawrence Livermore National Laboratory 
 Written by A.C. Hindmarsh and R. Serban.
 UCRL-CODE-155950
 All rights reserved. 
 
-This file is part of CVODES v2.1.0.
+This file is part of CVODES.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
@@ -18,42 +18,43 @@ notice, this list of conditions and the disclaimer (as noted below)
 in the documentation and/or other materials provided with the
 distribution.
 
-3. Neither the name of the UC/LLNL nor the names of its contributors
+3. Neither the name of the LLNS/LLNL nor the names of its contributors
 may be used to endorse or promote products derived from this software
 without specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
+LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF 
+ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 Additional BSD Notice
 ---------------------
 1. This notice is required to be provided under our contract with
-the U.S. Department of Energy (DOE). This work was produced at the
-University of California, Lawrence Livermore National Laboratory
-under Contract No. W-7405-ENG-48 with the DOE.
+the U.S. Department of Energy (DOE). This work was produced at
+Lawrence Livermore National Laboratory under Contract 
+No. DE-AC52-07NA27344 with the DOE.
 
-2. Neither the United States Government nor the University of
-California nor any of their employees, makes any warranty, express
-or implied, or assumes any liability or responsibility for the
+2. Neither the United States Government nor Lawrence Livermore 
+National Security, LLC nor any of their employees, makes any warranty, 
+express or implied, or assumes any liability or responsibility for the
 accuracy, completeness, or usefulness of any information, apparatus,
 product, or process disclosed, or represents that its use would not
 infringe privately-owned rights.
 
-3. Also, reference herein to any specific commercial products,
-process, or services by trade name, trademark, manufacturer or
-otherwise does not necessarily constitute or imply its endorsement,
-recommendation, or favoring by the United States Government or the
-University of California. The views and opinions of authors expressed
-herein do not necessarily state or reflect those of the United States
-Government or the University of California, and shall not be used for
-advertising or product endorsement purposes.
+3. Also, reference herein to any specific commercial products, process, 
+or services by trade name, trademark, manufacturer or otherwise does 
+not necessarily constitute or imply its endorsement, recommendation, 
+or favoring by the United States Government or Lawrence Livermore 
+National Security, LLC. The views and opinions of authors expressed 
+herein do not necessarily state or reflect those of the United States 
+Government or Lawrence Livermore National Security, LLC, and shall 
+not be used for advertising or product endorsement purposes.
+
diff --git a/src/cvodes/Makefile.in b/src/cvodes/Makefile.in
deleted file mode 100644
index 9cf23cb..0000000
--- a/src/cvodes/Makefile.in
+++ /dev/null
@@ -1,180 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2005, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for CVODES module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-LIB_REVISION = 2:0:0
-
-CVODES_LIB    = libsundials_cvodes.la
-
-CVODES_SRC_FILES = cvodes.c cvodes_io.c cvodea.c cvodea_io.c cvodes_direct.c cvodes_band.c cvodes_dense.c cvodes_diag.c cvodes_spils.c cvodes_spbcgs.c cvodes_spgmr.c cvodes_sptfqmr.c cvodes_bandpre.c cvodes_bbdpre.c
-CVODES_BL_SRC_FILES = cvodes_lapack.c
-
-CVODES_OBJ_FILES = $(CVODES_SRC_FILES:.c=.o)
-CVODES_BL_OBJ_FILES = $(CVODES_BL_SRC_FILES:.c=.o)
-
-CVODES_LIB_FILES = $(CVODES_SRC_FILES:.c=.lo)
-CVODES_BL_LIB_FILES = $(CVODES_BL_SRC_FILES:.c=.lo)
-
-SHARED_LIB_FILES = $(top_builddir)/src/sundials/sundials_band.lo \
-                   $(top_builddir)/src/sundials/sundials_dense.lo \
-                   $(top_builddir)/src/sundials/sundials_direct.lo \
-                   $(top_builddir)/src/sundials/sundials_iterative.lo \
-                   $(top_builddir)/src/sundials/sundials_spgmr.lo \
-                   $(top_builddir)/src/sundials/sundials_spbcgs.lo \
-                   $(top_builddir)/src/sundials/sundials_sptfqmr.lo \
-                   $(top_builddir)/src/sundials/sundials_math.lo \
-                   $(top_builddir)/src/sundials/sundials_nvector.lo
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(CVODES_LIB)
-
-$(CVODES_LIB): shared $(CVODES_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: shared $(CVODES_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(CVODES_LIB) $(CVODES_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-lib_with_bl: shared $(CVODES_LIB_FILES) $(CVODES_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(CVODES_LIB) $(CVODES_LIB_FILES) $(CVODES_BL_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-install: $(CVODES_LIB)
-	$(mkinstalldirs) $(includedir)/cvodes
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(CVODES_LIB) $(libdir)
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes.h         $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_direct.h  $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_dense.h   $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_band.h    $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_diag.h    $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_spils.h   $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_spbcgs.h  $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_spgmr.h   $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_sptfqmr.h $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_bandpre.h $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_bbdpre.h  $(includedir)/cvodes/
-	$(INSTALL_HEADER) $(top_srcdir)/src/cvodes/cvodes_impl.h        $(includedir)/cvodes/
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  $(INSTALL_HEADER) $(top_srcdir)/include/cvodes/cvodes_lapack.h  $(includedir)/cvodes/ ; \
-	fi
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(CVODES_LIB)
-	rm -f $(includedir)/cvodes/cvodes.h
-	rm -f $(includedir)/cvodes/cvodes_direct.h
-	rm -f $(includedir)/cvodes/cvodes_dense.h
-	rm -f $(includedir)/cvodes/cvodes_band.h
-	rm -f $(includedir)/cvodes/cvodes_diag.h
-	rm -f $(includedir)/cvodes/cvodes_lapack.h
-	rm -f $(includedir)/cvodes/cvodes_spils.h
-	rm -f $(includedir)/cvodes/cvodes_spbcgs.h
-	rm -f $(includedir)/cvodes/cvodes_spgmr.h
-	rm -f $(includedir)/cvodes/cvodes_sptfqmr.h
-	rm -f $(includedir)/cvodes/cvodes_bandpre.h
-	rm -f $(includedir)/cvodes/cvodes_bbdpre.h
-	rm -f $(includedir)/cvodes/cvodes_impl.h
-	$(rminstalldirs) ${includedir}/cvodes
-
-shared:
-	@cd ${top_builddir}/src/sundials ; \
-	 ${MAKE} ;                         \
-	 cd ${abs_builddir}
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(CVODES_LIB)
-	rm -f $(CVODES_LIB_FILES)
-	rm -f $(CVODES_BL_LIB_FILES)
-	rm -f $(CVODES_OBJ_FILES)
-	rm -f $(CVODES_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-cvodes.lo: $(srcdir)/cvodes.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes.c
-cvodes_io.lo: $(srcdir)/cvodes_io.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_io.c
-cvodea.lo: $(srcdir)/cvodea.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodea.c
-cvodea_io.lo: $(srcdir)/cvodea_io.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodea_io.c
-cvodes_direct.lo: $(srcdir)/cvodes_direct.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_direct.c
-cvodes_dense.lo: $(srcdir)/cvodes_dense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_dense.c
-cvodes_band.lo: $(srcdir)/cvodes_band.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_band.c
-cvodes_diag.lo: $(srcdir)/cvodes_diag.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_diag.c
-cvodes_lapack.lo: $(srcdir)/cvodes_lapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_lapack.c
-cvodes_spils.lo: $(srcdir)/cvodes_spils.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_spils.c
-cvodes_spbcgs.lo: $(srcdir)/cvodes_spils.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_spbcgs.c
-cvodes_spgmr.lo: $(srcdir)/cvodes_spgmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_spgmr.c
-cvodes_sptfqmr.lo: $(srcdir)/cvodes_sptfqmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_sptfqmr.c
-cvodes_bandpre.lo: $(srcdir)/cvodes_bandpre.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_bandpre.c
-cvodes_bbdpre.lo: $(srcdir)/cvodes_bbdpre.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/cvodes_bbdpre.c
-
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/cvodes/README b/src/cvodes/README
index d42a27e..cdebabc 100644
--- a/src/cvodes/README
+++ b/src/cvodes/README
@@ -1,5 +1,5 @@
                            CVODES 
-                 Release 2.7.0, March 2012
+                 Release 2.9.0, September, 2016
                Alan C. Hindmarsh and Radu Serban
           Center for Applied Scientific Computing, LLNL
 
@@ -8,12 +8,11 @@ problem) given in explicit form y' = f(t,y,p) with sensitivity analysis
 capabilities (both forward and adjoint modes). 
 It is written in ANSI standard C.
 
-CVODES can be used both on serial and parallel (MPI) computers.  The 
+CVODES can be used both on serial and parallel computers.  The 
 main difference is in the NVECTOR module of vector kernels.  The desired 
 version is obtained when compiling the example files by linking the 
-appropriate library of NVECTOR kernels.  In the parallel version,
-communication between processors is done with the MPI (Message Passage
-Interface) system.
+appropriate library of NVECTOR kernels.  In the parallel versions,
+communication between processors is done with MPI, with OpenMP, or with Pthreads.
 
 When used with the serial NVECTOR module, CVODES provides both direct (dense 
 and band) and preconditioned Krylov (iterative) linear solvers. Three different
@@ -28,8 +27,8 @@ band-block-diagonal preconditioner.
 
 CVODES is part of a software family called SUNDIALS: SUite of Nonlinear and 
 DIfferential/ALgebraic equation Solvers [4].  This suite consists of CVODE, 
-CVODES, IDA, IDAS, and KINSOL.  The directory structure of the package supplied 
-reflects this family relationship.
+CVODES, ARKode, IDA, IDAS, and KINSOL.  The directory structure of the 
+package supplied reflects this family relationship.
 
 The notes below provide the location of documentation, directions for the 
 installation of the CVODES package, and relevant references. Following that 
@@ -46,19 +45,19 @@ and the CVODES Examples [2] (cvs_examples.pdf) documents.
 B. Installation
 ---------------
 
-For basic installation instructions see /sundials/INSTALL_NOTES. 
-For complete installation instructions see the "CVODES Installation Procedure"
+For basic installation instructions see the file /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see the "Installation Procedure"
 chapter in the CVODES User Guide.
 
 
 C. References
 -------------
 
-[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODES v2.7.0," 
-    LLNL technical report UCRL-SM-208111, December 2011.
+[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODES v2.9.0," 
+    LLNL technical report UCRL-SM-208111, March 2016.
 
-[2] A. C. Hindmarsh and R. Serban, "Example Programs for CVODES v2.7.0," 
-    LLNL technical report UCRL-SM-208115, December 2011.
+[2] A. C. Hindmarsh and R. Serban, "Example Programs for CVODES v2.9.0," 
+    LLNL technical report UCRL-SM-208115, March 2016.
 
 [3] R. Serban and A. C. Hindmarsh, "CVODES: the Sensitivity-Enabled ODE 
     solver in SUNDIALS," Proceedings of IDETC/CIE 2005, Sept. 2005, 
@@ -73,6 +72,10 @@ C. References
 D. Releases
 -----------
 
+v. 2.9.0   - Sep. 2016
+v. 2.8.2   - Aug. 2015
+v. 2.8.1   - Mar. 2015
+v. 2.8.0   - Mar. 2015
 v. 2.7.0   - Mar. 2012
 v. 2.6.0   - May  2009
 v. 2.5.0   - Nov. 2006
@@ -84,385 +87,3 @@ v. 2.1.1   - Jan. 2005
 v. 2.1.0   - Dec. 2004
 v. 1.0     - Jul. 2002 (first SUNDIALS release)
 
-
-E. Revision History
--------------------
-
-
-v. 2.6.0 (May 2009) ---> v. 2.7.0 (Mar. 2012)
----------------------------------------------
-
-- Bug fixes
-   - errors in the logic for the integration of backward problems were
-     identified and fixed.
-   - in CVSetTqBDF, the logic was changed to avoid a divide by zero.
-   - after the solver memory is created, it is set to zero before being filled.
-   - in each linear solver interface function, the linear solver memory is
-     freed on an error return, and the **Free function now includes a
-     line setting to NULL the main memory pointer to the linear solver memory.
-   - in rootfinding functions cvRcheck1/cvRcheck2, when an exact zero is found,
-     the array glo at the left endpoint is adjusted instead of shifting tlo.
-
-- Changes to user interface
-   - One significant design change was made with this release: The problem
-     size and its relatives, bandwidth parameters, related internal indices,
-     pivot arrays, and the optional output lsflag have all been
-     changed from type int to type long int, except for the
-     problem size and bandwidths in user calls to routines specifying
-     BLAS/LAPACK routines for the dense/band linear solvers.  The function
-     NewIntArray is replaced by a pair NewIntArray/NewLintArray,
-     for int and long int arrays, respectively.
-   - in a minor change to the user interface, the type of the index
-     which in CVODES was changed from long int to int.
-   - in the installation files, we modified the treatment of the macro
-     SUNDIALS_USE_GENERIC_MATH, so that the parameter GENERIC_MATH_LIB is
-     either defined (with no value) or not defined.
-
-v. 2.5.0 (Nov. 2006) ---> v. 2.6.0 (May 2009)
----------------------------------------------
-
-- New features
-   - added a new linear solver module based on Blas + Lapack for
-     both dense and banded matrices.
-   - added optional input to specify which direction of zero-crossing
-     is to be monitored while performing root-finding. The root information
-     array iroots (returned by CVodeGetRootInfo) also encodes the 
-     direction of zero-crossing.
-   - added support for performing FSA of quadrature variables (see functions
-     CVode**QuadSens**).
-   - in the adjoint module, added support for integrating forward sensitivities
-     of states and quadrature variables during the forward integration
-     phase (e.g. for computing 2nd order sensitivity information using
-     the "forward over adjoint" method).
-   - in the adjoint module, added support for propagating backwards in time
-     multiple adjoint systems, each initialized at posibly different times.
-   - added option for reinitializing the adjoint module in order to
-     solve a new adjoint problem (with same number of steps between
-     check points and the same interpolation type).
-
-- Bug fixes
-   - in the rootfinding algorithm, fixed a bug resulting in unnecessary
-     evaluations of the root functions after reinitialization of the
-     solver right after a return at a root.
-   - in the initial step size calculation, restrict h based on tstop.
-   - modified the setting and use of the tq[] array.  Now tq[i] (i = 1,2,3)
-     are defined to be the reciprocals of what they were before.  This
-     eliminates a rare crash that can occur with xistar_inv = 0.
-
-- Changes to user interface
-   - renamed all **Malloc functions to **Init
-   - tolerances are now specified through separate functions instead of
-     the initialization functions CVodeInit (former CVodeMalloc) and 
-     CVodeReInit. Depending on the tolerance type, one of 3 functions
-     must be called before the first call to CVode.
-   - tolerances for quadratures, sensitivities, and quadrature sensitivities
-     are specified in a manner similar to that for state variables, with the
-     exception that toelrances for quadratures and quadrature sensitivities
-     are required only if the corresponding variables are included in the
-     error test.
-   - removed function inputs from argument lists of all re-initialization
-     functions.
-   - all user-supplied functions now receive the same pointer to user data
-     (instead of having different ones for the system evaluation, Jacobian
-     information functions, etc.)
-   - removed CV_NORMAL_TSTOP and CV_ONE_STEP_TSTOP named constants for the
-     itask argument to CVode/CVodeF. A tstop value is now both set and activated
-     through CVodeSetStopTime. Once tstop is reached it is also deactivated.
-     A new value can be then specified by calling again CVodeSetStopTime.
-   - common functionality for all direct linear solvers (dense, band, and
-     the new Lapack solver) has been collected into the DLS (Direct Linear
-     Solver) module, similar to the SPILS module for the iterative linear 
-     solvers. All optional input and output functions for these linear 
-     solver now have the prefix 'CVDls'. In addition, in order to include
-     the new Lapack-based linear solver, all dimensions for these linear
-     solvers (problem sizes, bandwidths, etc) are now of type 'int' 
-     (instead of 'long int').
-   - the initialization functions for the two preconditioner modules,
-     CVBANDPRE and CVBBDPRE were renamed ***Init (from ***Alloc) and they
-     do not return a pointer to preconditioner memory anymore. Instead,
-     all preconditioner module-related functions are now called with
-     the main solver memory pointer as their first argument. When using
-     one of these two modules, there is no need to use special functions
-     to attach one of the SPILS linear solvers (instead use one of
-     CVSpgmr, CVSpbcg, or CVSptfqmr). Moreover, there is no need to call
-     a memory deallocation function for the preconditioner module.
-   - CVodeSensMalloc was replaced by CVodeSensInit and CvodeSensInit1. 
-     The sensitivity RHS function is now passed as an argument to these
-     initialization functions. The former takes as argument fS a function
-     of type CVSensRhsFn, while the latter takes as argument fS1 of type
-     CVSensRhs1Fn. Removed the functions CVodeSetSensRhsFn and CVodeSetSensRhs1Fn.
-   - changed the API for all functions in the adjoint module related to 
-     initialization, set-up, and solution of backward problems. A backward problem
-     is always identified by its index (of type int) returned by the CvodeCreateB
-     function.
-   - the extraction functions CVodeGetQuad, CVodeGetSens, and CVodeGetSens1
-     now return the values of quadrature and sensitivity variables, respectively,
-     at the same time as that at which CVode returned the solution (for dense
-     output of quadrature or sensitivity variables, the user can only use
-     CVodeGetQuadDky, CVodeGetSensDky, or CVodeGetSensDky1). Similar functions are
-     available for the new quadrature sensitivity feature.
-   - changed names CVSpilsSetDelt and delt to CVSpilsSetEpsLin and eplifac.
-   - added the error return CV_RTFUNC_FAIL.
-
-v. 2.4.0 (Mar. 2006) ---> v. 2.5.0 (Nov. 2006)
-----------------------------------------------
-
-- Bug fixes
-   - fixed wrong logic in final stopping tests: now we check if
-     tout was reached before checking if tstop was reached.
-   - added a roundoff factor when testing whether tn was just returned
-     (in root finding) to prevent an unnecessary return.
-  - fixed bug in CVodeB in searching for the current check point
-     (i.e. the check point for which interpolation data is available)
-   - fixed bug in CVodeF to ensure that in NORMAL mode no extra
-     step is taken (which sometimes resulted in an error from the 
-     interpolated output function).
-   - changed address variable type in CVadjCheckPointRec structure from
-     'unsigned int' to 'void *' to avoid address truncation/mangling on
-     64-bit platforms (see CVS_P1).
-
-- Changes related to the build system
-   - reorganized source tree: header files in ${srcdir}/include/cvodes,
-     source files in ${srcdir}/src/cvodes,examples in ${srcdir}/examples/cvodes
-   - exported header files are installed unde ${includedir}/cvodes
-
-- Changes to user interface
-   - all included header files use relative paths from ${includedir}
-   - changed the API for specifying the DQ method used to approximate 
-     the sensitivity equations: renamed CVodeSetSensRho to CVodeSetSensDQMethod.
-     The user passes two values: DQtype (CV_CENTERED or CV_FORWARD) and
-     DQrhomax (the cut-off value for switching between simultaneous and
-     separate approximations of the two terms in the sensi. eqs.)
-
-v. 2.3.0 (May. 2005) ---> v. 2.4.0 (Mar. 2006)
-----------------------------------------------
-
-- New features
-   - added CVSPBCG interface module to allow CVODES to interface with the
-     shared SPBCG (scaled preconditioned Bi-CGSTAB) linear solver module.
-   - added CVSPTFQMR interface module to allow CVODES to interface with
-     the shared SPTFQMR (scaled preconditioned TFQMR) linear solver module.
-   - added support for SPBCG and SPTFQMR to the CVBBDPRE and CVBANDPRE 
-     preconditioner modules.
-   - added support for interpreting failures in user-supplied functions.
-   - added a new variable-degree polynomial interpolation method as an
-     an alternative to the current cubic Hermite interpolation for the
-     adjoint module.
-
-- Changes to user interface
-   - changed argument of CVodeFree, CVBandPrecFree, CVBBDPrecFree, and 
-     CVadjFree to be the address of the respective memory block pointer, 
-     so that its NULL value is propagated back to the calling function.
-   - added CVSPBCG module which defines appropriate CVSpbcg* functions to
-     allow CVODES to interface with the shared SPBCG linear solver module.
-   - added CVBBDSpbcg function to CVBBDPRE module and CVBPSpbcg function to
-     CVBANDPRE module to support SPBCG linear solver module.
-   - added CVBBDSptfqmr function to CVBBDPRE module and CVBPSptfqmr function to
-     CVBANDPRE module to support SPTFQMR linear solver module.
-   - changed function type names (not the actual definition) to accomodate
-     all the Scaled Preconditioned Iterative Linear Solvers now available:
-       CVSpgmrJactimesVecFn -> CVSpilsJacTimesVecFn
-       CVSpgmrPrecSetupFn   -> CVSpilsPrecSetupFn
-       CVSpgmrPrecSolveFn   -> CVSpilsPrecSolveFn 
-   - changed function types so that all user-supplied functions return
-     an integer flag (not all of them currently used).
-   - changed some names for CVBBDPRE and CVBANDPRE function outputs
-   - added option for user-supplied error handler function.
-   - added a argument to CVadjMalloc to specify the type of interpolation 
-     (possible values are CV_HERMITE for cubic Hermite and CV_POLYNOMIAL
-     for variable-order polynomial interpolation)
-   - renamed all exported header files (except for cvodes.h and cvodea.h all 
-     header files have the prefix 'cvodes_')
-   - changed naming scheme for CVODES examples
-
-- Changes related to the build system
-   - the main CVODES header files (cvodes.h and cvodea.h) are still exported to 
-     the install include directory. However, all other CVODES header files are 
-     exported into a 'cvodes' subdirectory of the install include directory.
-   - the CVODES library now contains all shared object files (there is no separate
-     libsundials_shared library anymore)
-
-v. 2.2.0 (Apr. 2005) ---> v. 2.3.0 (May. 2005)
-----------------------------------------------
-
-- Bug fixes
-   - in the adjoint module, fixed bug in storing interpolation data at
-     a point corresponding to a check point (improperly scaled y').
-
-- Changes to user interface
-   - removed CVadjGetcheckPointsList from the list of user-callable functions.
-
-v. 2.1.2 (Mar. 2005) ---> v. 2.2.0 (Apr. 2005)
-----------------------------------------------
-
-- New features
-   - added option for user-provided error weight computation function for
-     the solution vector (of type CVEwtFn specified through CVodeSetEwtFn).
-
-- Changes to user interface
-   - CVODES now stores tolerances through values rather than references 
-     (to resolve potential scoping issues). 
-   - CVODES now passes information back to the user through values rather
-     than references (error weights, estimated local errors, root info,
-     STAGGERED1 statistics, etc.)
-   - CVodeMalloc, CVodeReInit, CVodeSetTolerances: added option itol=CV_WF 
-     to indicate user-supplied function for computing the error weights; 
-     reltol is now declared as realtype. Note that it is now illegal to call
-     CVodeSetTolerances before CVodeMalloc. It is now legal to deallocate
-     the absolute tolerance N_Vector right after its use.
-   - Several optional input functions were combined into a single one
-     (CVodeRootInit and CvodeSetGdata, CVDenseSetJacFn and CVDenseSetJacData,
-     CVBandSetJacFn and CVBandSetJacData, CVSpgmrSetPrecSolveFn and 
-     CVSpgmrSetPrecSetFn and CVSpgmrSetPrecData, CVSpgmrSetJacTimesVecFn and
-     CVSpgmrSetJacData).
-   - Removed CVodeSetQuadtolerances. CVodeSetQuadErrCon now sets both the
-     error control flag and the tolerances for quadratures.
-   - CVodeSetQuadErrCon, CVodeSetSensTolerances: the relative tolerance
-     must now be passed as a realtype. It is now illegal to call 
-     CVodeSetQuadErrCon before CVodeQuadMalloc or to call CVodeSetSensTolerances
-     before CVodeSensMalloc.
-   - CvodeSensMalloc: removed p and plist from argument list.
-   - CVodeSensParams replaces CVodeSensPbar and sets p, pbar, and plist. NULL
-     can be passed for any of them if it will not be needed given the current
-     set of options. The array pbar must now contain Ns non-zero realtype
-     values giving order of magnitude for the parameters with respect to which
-     sensitivities will be computed. The array plist can now only have positive 
-     entries. 
-   - CVodeGetErrorWeights, CVodeGetQuadErrorWeights: the user is now responsible 
-     for allocating space for the N_Vector in which error weights will be copied.
-   - CVodeGetEstLocalErrors: the user is now responsible for allocating space
-     for the N_Vector in which estimated local errors will be copied.
-   - CVodeGetRootInfo: the user is now responsible for allocating space
-     for the int array in which root information will be copied.
-   - CVodeGetNumStgrSensNonlinSolvIters, CVodeGetNumStgrSensNonlinSolvConvFails:
-     the user is now responsible for allocating space for the long int arrays 
-     in which STAGGERED1 statistics will be copied.
-   - CVodeMallocB, CVodeReInitB, CVodeSetQuadErrConB: the relative tolerance
-     for the backward integration must now be passed as a realtype. It is now
-     illegal to call CVodeSetQuadErrConB before CVQuadMallocB.
-   - Passing a value of 0 for the maximum step size, the minimum step
-     size, or for maxsteps results in the solver using the corresponding
-     default value (infinity, 0, 500, respectively)
-   - User-callable functions in the adjoint module were modified similarly
-     to their corresponding counterparts for forward simulation.
-
-
-v. 2.1.1 (Jan. 2005) ---> v. 2.1.2 (Mar. 2005)
-----------------------------------------------
-
-- Bug fixes
-   - fixed bug in CVode function:  Initial setting of tretlast = *tret = tn removed
-     (correcting erroneous behavior at first call to CVRcheck3).
-   - removed redundant setting of tretlast = *tret = tn at CLOSE_ROOTS return from CVode.
-   - fixed bug in CVCompleteStep related to quadrature and sensitivity variables
-     (leading to wrong values at a BDF order increase)
-   - in CVUpperBoundH0, fixed a potential, although not harmful, use of 
-     uninitialized memory
-   - changed implicit type conversion to explicit in check_flag() routine in
-     examples to avoid C++ compiler errors
-
-- Changes to documentation
-   - added section with numerical values of all input and output solver constants
-   - added more detailed notes on the type of absolute tolerances
-   - added more details on ownership of memory for the array returned by CVodeGetRootInfo 
-   - corrected/added descriptions of error returns.
-   - added description of --with-mpi-flags option
-
-- Changes related to the build system
-   - fixed autoconf-related bug to allow configuration with the PGI Fortran compiler
-   - modified to use customized detection of the Fortran name mangling scheme 
-     (autoconf's AC_F77_WRAPPERS routine is problematic on some platforms)
-   - added --with-mpi-flags as a configure option to allow user to specify
-     MPI-specific flags
-   - updated Makefiles for Fortran examples to avoid C++ compiler errors (now use
-     CC and MPICC to link)
-
-
-v. 2.1.0 (Dec. 2004) ---> v. 2.1.1 (Jan. 2005)
-----------------------------------------------
-
-- New features
-   - added function CVodeSensToggle to allow activation/deactivation of
-     sensitivity calculations without memory allocation/deallocation.
-
-- Bug fixes
-   - fixed bug in CVCompleteStep related to quadrature and sensitivity variables
-     (leading to wrong values at a BDF order increase).
-   - in CVUpperBoundH0, fixed a potential, although not harmful, use of 
-     uninitialized memory.
-   - fixed logic in testing for negative values of user-supplied absolute tolerances
-     for sensitivity variables.
-  
-- Changes related to the build system
-   - changed order of compiler directives in header files to avoid compilation
-     errors when using a C++ compiler.
-
-v. 1.0 (Jul. 2002) ---> v. 2.1.0 (Dec. 2004)
---------------------------------------------
-
-- New features
-   - added quadrature integration capabilities.
-   - added root finding capabilities.
-   - added option for different user data structures for ODE r.h.s.
-     and sensitivity r.h.s.
-   - in adjoint module, added interface to CVBBDPRE for the backward 
-     phase.
-   - in adjoint module, added option for using CVDIAG during backward 
-     phase.
-   - in adjoint module, added option for ONE_STEP integration during 
-     backward phase.
-   - in adjoint module, added option to reinitialize the backward 
-     integration phase (and perform a new backward integration using
-     the same check points).
-   - in adjoint module, relaxed assumption that t_final > t_0 (now
-     accepts t_final < t_0).
-
-- Bug fixes
-   - fixed bug in adjustment of sensitivity Nordsieck history array on an
-     order decrease (when using BDF).
-   - in adjoint module, fixed a potential use of memory before being set.
-   - in adjoint module, fixed a bug related to data saved at check points.
-     This addresses the case in which an order increase is deemed necessary
-     at the very first step after a check-point.
-
-- Changes related to the NVECTOR module 
-  (see also the file sundials/shared/README)
-   - removed machEnv, redefined table of vector operations (now contained
-     in the N_Vector structure itself).
-   - all CVODES functions create new N_Vector variables through cloning, using
-     an N_Vector passed by the user as a template.
-
-- Changes to type names and CVODES constants
-   - removed type 'integertype'; instead use int or long int, as appropriate.
-   - restructured the list of return values from the various CVODES functions.
-   - changed all CVODES constants (inputs and return values) to have the
-     prefix 'CV_' (e.g. CV_SUCCESS).
-   - renamed various function types to have the prefix 'CV' (e.g. CVRhsFn).
-
-- Changes to optional input/ouput
-   - added CVodeSet* and CVodeGet* functions for optional inputs/outputs, 
-     replacing the arrays iopt and ropt.
-   - added new optional inputs (e.g. maximum number of Newton iterations,
-     maximum number of convergence failures, etc).
-   - the value of the last return flag from any function within a linear
-     solver module can be obtained as an optional output (e.g. CVDenseGetLastFlag).
-  
-- Changes to user-callable functions
-   - renamed header files to have prefix 'cv' instead of 'cvs' (e.g. cvdense.h
-     replaces cvsdense.h).
-   - added new function CVodeCreate which initializes the CVODES solver
-     object and returns a pointer to the CVODES memory block.
-   - removed N (problem size) from all functions except the initialization
-     functions for the direct linear solvers (CVDense and CVBand).
-   - shortened argument lists of most CVODES functions (the arguments that
-     were dropped can now be specified through CVodeSet* functions).
-   - removed reinitialization functions for band/dense/SPGMR linear
-     solvers (same functionality can be obtained using CV*Set* functions).
-   - in CVBBDPRE, added a new function, CVBBDSpgmr to initialize the
-     SPGMR linear solver with the BBD preconditioner.
-   - function names changed in CVBANDPRE and CVBBDPRE for uniformity.
-
-- Changes to user-supplied functions
-   - removed N (probem dimension) from argument lists.
-   - shortened argument lists for user dense/band/SPGMR Jacobian routines.
-   - in CVSPGMR, shortened argument lists for user preconditioner functions.
diff --git a/src/cvodes/cvodea.c b/src/cvodes/cvodea.c
index 44c55a1..d218fe7 100644
--- a/src/cvodes/cvodea.c
+++ b/src/cvodes/cvodea.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.25 $
- * $Date: 2011/12/07 23:12:46 $
+ * $Revision: 4846 $
+ * $Date: 2016-08-03 15:47:48 -0700 (Wed, 03 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVODEA adjoint integrator.
  * -----------------------------------------------------------------
@@ -1260,7 +1265,7 @@ int CVodeB(void *cvode_mem, realtype tBout, int itaskB)
   CVadjMem ca_mem;
   CVodeBMem cvB_mem, tmp_cvB_mem;
   CkpntMem ck_mem;
-  int sign, flag;
+  int sign, flag=0;
   realtype tfuzz, tBret, tBn;
   booleantype gotCheckpoint, isActive, reachedTBout;
   
@@ -1347,8 +1352,8 @@ int CVodeB(void *cvode_mem, realtype tBout, int itaskB)
   /* Check if tBout is legal */
 
   if ( (sign*(tBout-tinitial) < ZERO) || (sign*(tfinal-tBout) < ZERO) ) {
-    tfuzz = HUNDRED*uround*(ABS(tinitial) + ABS(tfinal));
-    if ( (sign*(tBout-tinitial) < ZERO) && (ABS(tBout-tinitial) < tfuzz) ) {
+    tfuzz = HUNDRED*uround*(SUNRabs(tinitial) + SUNRabs(tfinal));
+    if ( (sign*(tBout-tinitial) < ZERO) && (SUNRabs(tBout-tinitial) < tfuzz) ) {
       tBout = tinitial;
     } else {
       cvProcessError(cv_mem, CV_ILL_INPUT, "CVODEA", "CVodeB", MSGCV_BAD_TBOUT);
@@ -2226,7 +2231,7 @@ static int CVAfindIndex(CVodeMem cv_mem, realtype t,
 
     if ( *indx == 0 ) {
       /* t is beyond leftmost limit. Is it too far? */  
-      if ( ABS(t - dt_mem[0]->t) > FUZZ_FACTOR * uround ) {
+      if ( SUNRabs(t - dt_mem[0]->t) > FUZZ_FACTOR * uround ) {
         return(CV_GETY_BADT);
       }
     }
@@ -2458,7 +2463,8 @@ static int CVAhermiteStorePnt(CVodeMem cv_mem, DtpntMem d)
 {
   CVadjMem ca_mem;
   HermiteDataMem content;
-  int is, retval;
+  int is;
+  /* int retval; */
 
   ca_mem = cv_mem->cv_adj_mem;
 
@@ -2477,10 +2483,10 @@ static int CVAhermiteStorePnt(CVodeMem cv_mem, DtpntMem d)
 
   if (nst == 0) {
 
-    retval = f(tn, content->y, content->yd, user_data);
+    /* retval = */ f(tn, content->y, content->yd, user_data);
 
     if (IMstoreSensi) {
-      retval = cvSensRhsWrapper(cv_mem, tn, content->y, content->yd,
+      /* retval = */ cvSensRhsWrapper(cv_mem, tn, content->y, content->yd,
                                 content->yS, content->ySd,
                                 cv_mem->cv_tempv, cv_mem->cv_ftemp);
     }
@@ -2520,7 +2526,7 @@ static int CVAhermiteGetY(CVodeMem cv_mem, realtype t,
   realtype factor1, factor2, factor3;
 
   N_Vector y0, yd0, y1, yd1;
-  N_Vector *yS0, *ySd0, *yS1, *ySd1;
+  N_Vector *yS0=NULL, *ySd0=NULL, *yS1, *ySd1;
 
   int flag, is, NS;
   long int indx;
@@ -2532,7 +2538,7 @@ static int CVAhermiteGetY(CVodeMem cv_mem, realtype t,
  
   /* Local value of Ns */
  
-  NS = IMinterpSensi ? Ns : 0;
+  NS = (IMinterpSensi && (yS != NULL)) ? Ns : 0;
 
   /* Get the index in dt_mem */
 
@@ -2808,7 +2814,7 @@ static int CVApolynomialGetY(CVodeMem cv_mem, realtype t,
   
   /* Local value of Ns */
  
-  NS = IMinterpSensi ? Ns : 0;
+  NS = (IMinterpSensi && (yS != NULL)) ? Ns : 0;
 
   /* Get the index in dt_mem */
 
@@ -2827,7 +2833,7 @@ static int CVApolynomialGetY(CVodeMem cv_mem, realtype t,
 
   /* Scaling factor */
 
-  dt = ABS(dt_mem[indx]->t - dt_mem[indx-1]->t);
+  dt = SUNRabs(dt_mem[indx]->t - dt_mem[indx-1]->t);
 
   /* Find the direction of the forward integration */
 
@@ -2954,7 +2960,8 @@ static int CVArhsQ(realtype t, N_Vector yB,
   CVodeMem cv_mem;
   CVadjMem ca_mem;
   CVodeBMem cvB_mem;
-  int flag, retval;
+  /* int flag; */
+  int retval;
 
   cv_mem = (CVodeMem) cvode_mem;
 
@@ -2965,9 +2972,9 @@ static int CVArhsQ(realtype t, N_Vector yB,
   /* Get forward solution from interpolation */
 
   if (IMinterpSensi)
-    flag = IMget(cv_mem, t, ytmp, yStmp);
+    /* flag = */ IMget(cv_mem, t, ytmp, yStmp);
   else 
-    flag = IMget(cv_mem, t, ytmp, NULL);
+    /* flag = */ IMget(cv_mem, t, ytmp, NULL);
 
   /* Call the user's RHS function */
 
diff --git a/src/cvodes/cvodea_io.c b/src/cvodes/cvodea_io.c
index e4bc16c..7cb8fe2 100644
--- a/src/cvodes/cvodea_io.c
+++ b/src/cvodes/cvodea_io.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2010/12/01 22:33:22 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the optional input and output
  * functions for the adjoint module in the CVODES solver.
diff --git a/src/cvodes/cvodes.c b/src/cvodes/cvodes.c
index df7ab91..44f2494 100644
--- a/src/cvodes/cvodes.c
+++ b/src/cvodes/cvodes.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.34 $
- * $Date: 2012/03/06 21:58:49 $
+ * $Revision: 4826 $
+ * $Date: 2016-07-26 16:00:58 -0700 (Tue, 26 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the main CVODES integrator
  * with sensitivity analysis capabilities.
@@ -165,7 +170,7 @@
  *      cvRcheck1
  *      cvRcheck2         
  *      cvRcheck3
- *      cvRootFind  
+ *      cvRootfind  
  *
  *   Functions for combined norms
  *      cvQuadUpdateNorm
@@ -220,19 +225,19 @@
  * =================================================================
  */
 
-#define ZERO   RCONST(0.0)
-#define TINY   RCONST(1.0e-10)
-#define TENTH  RCONST(0.1)
-#define POINT2 RCONST(0.2)
-#define FOURTH RCONST(0.25)
-#define HALF   RCONST(0.5)
-#define ONE    RCONST(1.0)
-#define TWO    RCONST(2.0)
-#define THREE  RCONST(3.0)
-#define FOUR   RCONST(4.0)
-#define FIVE   RCONST(5.0)
-#define TWELVE RCONST(12.0)
-#define HUN    RCONST(100.0)
+#define ZERO    RCONST(0.0)
+#define TINY    RCONST(1.0e-10)
+#define PT1     RCONST(0.1)
+#define POINT2  RCONST(0.2)
+#define FOURTH  RCONST(0.25)
+#define HALF    RCONST(0.5)
+#define ONE     RCONST(1.0)
+#define TWO     RCONST(2.0)
+#define THREE   RCONST(3.0)
+#define FOUR    RCONST(4.0)
+#define FIVE    RCONST(5.0)
+#define TWELVE  RCONST(12.0)
+#define HUNDRED RCONST(100.0)
 
 /* 
  * =================================================================
@@ -318,7 +323,7 @@
  *    CV_SUCCESS,
  *    CV_RTFUNC_FAIL,
  *    RTFOUND
- * cvRootFind return values:
+ * cvRootfind return values:
  *    CV_SUCCESS,
  *    CV_RTFUNC_FAIL,
  *    RTFOUND
@@ -368,7 +373,7 @@
  *
  *    HLB_FACTOR  factor for upper bound on initial step size
  *    HUB_FACTOR  factor for lower bound on initial step size
- *    H_BIAS      bias factor in selection of intial step size
+ *    H_BIAS      bias factor in selection of initial step size
  *    MAX_ITERS   maximum attempts to compute the initial step size
  *
  * CVodeCreate 
@@ -395,7 +400,7 @@
  *    MXNEF       max no. of error test failures during one step try
  *    MXNEF1      max no. of error test failures before forcing a reduction of order
  *    SMALL_NEF   if an error failure occurs and SMALL_NEF <= nef <= MXNEF1, then
- *                reset eta =  MIN(eta, ETAMXF)
+ *                reset eta =  SUNMIN(eta, ETAMXF)
  *    LONG_WAIT   number of steps to wait before considering an order change when
  *                q==1 and MXNEF1 error test failures have occurred
  *
@@ -574,7 +579,7 @@ static int cvSLdet(CVodeMem cv_mem);
 static int cvRcheck1(CVodeMem cv_mem);
 static int cvRcheck2(CVodeMem cv_mem);
 static int cvRcheck3(CVodeMem cv_mem);
-static int cvRootFind(CVodeMem cv_mem);
+static int cvRootfind(CVodeMem cv_mem);
 
 /* Function for combined norms */
 
@@ -1972,7 +1977,7 @@ int CVodeQuadSensInit(void *cvode_mem, CVQuadSensRhsFn fQS, N_Vector *yQS0)
     cv_mem->cv_fQSDQ = FALSE;
     cv_mem->cv_fQS = fQS;
 
-    cv_mem->cv_fS_data = cv_mem->cv_user_data;
+    cv_mem->cv_fQS_data = cv_mem->cv_user_data;
 
   }
 
@@ -2680,6 +2685,8 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
 
   if (nst == 0) {
 
+    tretlast = *tret = tn;
+
     /* Check inputs for corectness */
 
     ier = cvInitialSetup(cv_mem);
@@ -2741,6 +2748,15 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
       }
     }
 
+    /* Test input tstop for legality. */
+
+    if (tstopset) {
+      if ( (tstop - tn)*(tout - tn) <= ZERO ) {
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_BAD_TSTOP, tstop, tn);
+        return(CV_ILL_INPUT);
+      }
+    }
+
     /* Set initial h (from H0 or cvHin). */
     
     h = hin;
@@ -2750,24 +2766,20 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     }
     if (h == ZERO) {
       tout_hin = tout;
-      if ( tstopset && (tout-tn)*(tout-tstop) > 0 ) tout_hin = tstop; 
+      if ( tstopset && (tout-tn)*(tout-tstop) > ZERO ) tout_hin = tstop; 
       hflag = cvHin(cv_mem, tout_hin);
       if (hflag != CV_SUCCESS) {
         istate = cvHandleFailure(cv_mem, hflag);
         return(istate);
       }
     }
-    rh = ABS(h)*hmax_inv;
+    rh = SUNRabs(h)*hmax_inv;
     if (rh > ONE) h /= rh;
-    if (ABS(h) < hmin) h *= hmin/ABS(h);
+    if (SUNRabs(h) < hmin) h *= hmin/SUNRabs(h);
 
     /* Check for approach to tstop */
 
     if (tstopset) {
-      if ( (tstop - tn)*h < ZERO ) {
-        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_BAD_TSTOP, tstop, tn);
-        return(CV_ILL_INPUT);
-      }
       if ( (tn + h - tstop)*h > ZERO ) 
         h = (tstop - tn)*(ONE-FOUR*uround);
     }
@@ -2828,7 +2840,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     /* Estimate an infinitesimal time interval to be used as
        a roundoff for time quantities (based on current time 
        and step size) */
-    troundoff = FUZZ_FACTOR*uround*(ABS(tn) + ABS(h));
+    troundoff = FUZZ_FACTOR*uround*(SUNRabs(tn) + SUNRabs(h));
 
     /* First check for a root in the last step taken, other than the
        last root found, if any.  If itask = CV_ONE_STEP and y(tn) was not
@@ -2852,7 +2864,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
       
       /* If tn is distinct from tretlast (within roundoff),
          check remaining interval for roots */
-      if ( ABS(tn - tretlast) > troundoff ) {
+      if ( SUNRabs(tn - tretlast) > troundoff ) {
 
         retval = cvRcheck3(cv_mem);
 
@@ -2888,7 +2900,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     }
     
     /* In CV_ONE_STEP mode, test if tn was returned */
-    if ( itask == CV_ONE_STEP && ABS(tn - tretlast) > troundoff ) {
+    if ( itask == CV_ONE_STEP && SUNRabs(tn - tretlast) > troundoff ) {
       tretlast = *tret = tn;
       N_VScale(ONE, zn[0], yout);
       return(CV_SUCCESS);
@@ -2897,7 +2909,7 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     /* Test for tn at tstop or near tstop */
     if ( tstopset ) {
       
-      if ( ABS(tn - tstop) <= troundoff ) {
+      if ( SUNRabs(tn - tstop) <= troundoff ) {
         ier =  CVodeGetDky(cv_mem, tstop, 0, yout);
         if (ier != CV_SUCCESS) {
           cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_BAD_TSTOP, tstop, tn);
@@ -3044,8 +3056,8 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
 
     /* If tstop is set and was reached, reset tn = tstop */
     if ( tstopset ) {
-      troundoff = FUZZ_FACTOR*uround*(ABS(tn) + ABS(h));
-      if ( ABS(tn - tstop) <= troundoff) tn = tstop;
+      troundoff = FUZZ_FACTOR*uround*(SUNRabs(tn) + SUNRabs(h));
+      if ( SUNRabs(tn - tstop) <= troundoff) tn = tstop;
     }
 
     /* Check for root in last step taken. */    
@@ -3097,8 +3109,8 @@ int CVode(void *cvode_mem, realtype tout, N_Vector yout,
     /* Check if tn is at tstop, or about to pass tstop */
     if ( tstopset ) {
 
-      troundoff = FUZZ_FACTOR*uround*(ABS(tn) + ABS(h));
-      if ( ABS(tn - tstop) <= troundoff) {
+      troundoff = FUZZ_FACTOR*uround*(SUNRabs(tn) + SUNRabs(h));
+      if ( SUNRabs(tn - tstop) <= troundoff) {
         (void) CVodeGetDky(cv_mem, tstop, 0, yout);
         tretlast = *tret = tstop;
         tstopset = FALSE;
@@ -3187,7 +3199,7 @@ int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky)
   }
   
   /* Allow for some slack */
-  tfuzz = FUZZ_FACTOR * uround * (ABS(tn) + ABS(hu));
+  tfuzz = FUZZ_FACTOR * uround * (SUNRabs(tn) + SUNRabs(hu));
   if (hu < ZERO) tfuzz = -tfuzz;
   tp = tn - hu - tfuzz;
   tn1 = tn + tfuzz;
@@ -3209,7 +3221,7 @@ int CVodeGetDky(void *cvode_mem, realtype t, int k, N_Vector dky)
     }
   }
   if (k == 0) return(CV_SUCCESS);
-  r = RPowerI(h,-k);
+  r = SUNRpowerI(h,-k);
   N_VScale(r, dky, dky);
   return(CV_SUCCESS);
 }
@@ -3285,7 +3297,7 @@ int CVodeGetQuadDky(void *cvode_mem, realtype t, int k, N_Vector dkyQ)
   }
   
   /* Allow for some slack */
-  tfuzz = FUZZ_FACTOR * uround * (ABS(tn) + ABS(hu));
+  tfuzz = FUZZ_FACTOR * uround * (SUNRabs(tn) + SUNRabs(hu));
   if (hu < ZERO) tfuzz = -tfuzz;
   tp = tn - hu - tfuzz;
   tn1 = tn + tfuzz;
@@ -3307,7 +3319,7 @@ int CVodeGetQuadDky(void *cvode_mem, realtype t, int k, N_Vector dkyQ)
     }
   }
   if (k == 0) return(CV_SUCCESS);
-  r = RPowerI(h,-k);
+  r = SUNRpowerI(h,-k);
   N_VScale(r, dkyQ, dkyQ);
   return(CV_SUCCESS);
   
@@ -3449,7 +3461,7 @@ int CVodeGetSensDky1(void *cvode_mem, realtype t, int k, int is, N_Vector dkyS)
   }
   
   /* Allow for some slack */
-  tfuzz = FUZZ_FACTOR * uround * (ABS(tn) + ABS(hu));
+  tfuzz = FUZZ_FACTOR * uround * (SUNRabs(tn) + SUNRabs(hu));
   if (hu < ZERO) tfuzz = -tfuzz;
   tp = tn - hu - tfuzz;
   tn1 = tn + tfuzz;
@@ -3471,7 +3483,7 @@ int CVodeGetSensDky1(void *cvode_mem, realtype t, int k, int is, N_Vector dkyS)
     }
   }
   if (k == 0) return(CV_SUCCESS);
-  r = RPowerI(h,-k);
+  r = SUNRpowerI(h,-k);
   N_VScale(r, dkyS, dkyS);
   return(CV_SUCCESS);
   
@@ -3588,7 +3600,7 @@ int CVodeGetQuadSensDky1(void *cvode_mem, realtype t, int k, int is, N_Vector dk
   }
   
   /* Allow for some slack */
-  tfuzz = FUZZ_FACTOR * uround * (ABS(tn) + ABS(hu));
+  tfuzz = FUZZ_FACTOR * uround * (SUNRabs(tn) + SUNRabs(hu));
   if (hu < ZERO) tfuzz = -tfuzz;
   tp = tn - hu - tfuzz;
   tn1 = tn + tfuzz;
@@ -3610,7 +3622,7 @@ int CVodeGetQuadSensDky1(void *cvode_mem, realtype t, int k, int is, N_Vector dk
     }
   }
   if (k == 0) return(CV_SUCCESS);
-  r = RPowerI(h,-k);
+  r = SUNRpowerI(h,-k);
   N_VScale(r, dkyQS, dkyQS);
   return(CV_SUCCESS);
 }
@@ -3857,8 +3869,7 @@ static void cvFreeVectors(CVodeMem cv_mem)
   N_VDestroy(acor);
   N_VDestroy(tempv);
   N_VDestroy(ftemp);
-  for (j=0; j <= maxord; j++) 
-    N_VDestroy(zn[j]);
+  for (j=0; j <= maxord; j++) N_VDestroy(zn[j]);
 
   lrw -= (maxord + 5)*lrw1;
   liw -= (maxord + 5)*liw1;
@@ -4277,8 +4288,8 @@ static int cvHin(CVodeMem cv_mem, realtype tout)
   if ((tdiff = tout-tn) == ZERO) return(CV_TOO_CLOSE);
   
   sign = (tdiff > ZERO) ? 1 : -1;
-  tdist = ABS(tdiff);
-  tround = uround * MAX(ABS(tn), ABS(tout));
+  tdist = SUNRabs(tdiff);
+  tround = uround * SUNMAX(SUNRabs(tn), SUNRabs(tout));
 
   if (tdist < TWO*tround) return(CV_TOO_CLOSE);
   
@@ -4291,7 +4302,7 @@ static int cvHin(CVodeMem cv_mem, realtype tout)
   hlb = HLB_FACTOR * tround;
   hub = cvUpperBoundH0(cv_mem, tdist);
 
-  hg  = RSqrt(hlb*hub);
+  hg  = SUNRsqrt(hlb*hub);
 
   if (hub < hlb) {
     if (sign == -1) h = -hg;
@@ -4342,7 +4353,7 @@ static int cvHin(CVodeMem cv_mem, realtype tout)
     if ( (hnewOK) || (count1 == MAX_ITERS))  {hnew = hg; break;}
 
     /* Propose new step size */
-    hnew = (yddnrm*hub*hub > TWO) ? RSqrt(TWO/yddnrm) : RSqrt(hg*hub);
+    hnew = (yddnrm*hub*hub > TWO) ? SUNRsqrt(TWO/yddnrm) : SUNRsqrt(hg*hub);
     hrat = hnew/hg;
     
     /* Accept hnew if it does not differ from hg by more than a factor of 2 */
@@ -4600,7 +4611,7 @@ static int cvInitialSetup(CVodeMem cv_mem)
 
   /* Did the user specify tolerances? */
   if (itol == CV_NN) {
-    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NO_TOL);
+    cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NO_TOL);
     return(CV_ILL_INPUT);
   }
 
@@ -4608,13 +4619,13 @@ static int cvInitialSetup(CVodeMem cv_mem)
   if (cv_mem->cv_user_efun) e_data = user_data;
   else                      e_data = cv_mem;
 
-  /* Load intial error weights */
+  /* Load initial error weights */
   ier = efun(zn[0], ewt, e_data);
   if (ier != 0) {
     if (itol == CV_WF) 
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_EWT_FAIL);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_EWT_FAIL);
     else
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_BAD_EWT);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_BAD_EWT);
     return(CV_ILL_INPUT);
   }
   
@@ -4624,14 +4635,14 @@ static int cvInitialSetup(CVodeMem cv_mem)
 
     /* Did the user specify tolerances? */
     if (itolQ == CV_NN) {
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NO_TOLQ);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NO_TOLQ);
       return(CV_ILL_INPUT);
     }
 
     /* Load ewtQ */
     ier = cvQuadEwtSet(cv_mem, znQ[0], ewtQ);
     if (ier != 0) {
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_BAD_EWTQ);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_BAD_EWTQ);
       return(CV_ILL_INPUT);
     }
 
@@ -4645,20 +4656,20 @@ static int cvInitialSetup(CVodeMem cv_mem)
 
     /* Did the user specify tolerances? */
     if (itolS == CV_NN) {
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NO_TOLS);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NO_TOLS);
       return(CV_ILL_INPUT);
     }
 
     /* If using the internal DQ functions, we must have access to the problem parameters */
     if(fSDQ && (p == NULL)) {
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NULL_P);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NULL_P);
       return(CV_ILL_INPUT);
     }
 
     /* Load ewtS */
     ier = cvSensEwtSet(cv_mem, znS[0], ewtS);
     if (ier != 0) {
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_BAD_EWTS);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_BAD_EWTS);
       return(CV_ILL_INPUT);
     }
 
@@ -4675,13 +4686,13 @@ static int cvInitialSetup(CVodeMem cv_mem)
 
       /* Test if quadratures are defined, so we can use fQ */
       if (!quadr) {
-        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NULL_FQ);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NULL_FQ);
         return(CV_ILL_INPUT);
       }
 
       /* Test if we have the problem parameters */
       if(p == NULL) {
-        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NULL_P);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NULL_P);
         return(CV_ILL_INPUT);
       }
 
@@ -4691,20 +4702,20 @@ static int cvInitialSetup(CVodeMem cv_mem)
       
       /* Did the user specify tolerances? */
       if (itolQS == CV_NN) {
-        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NO_TOLQS);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NO_TOLQS);
         return(CV_ILL_INPUT);
       }
 
       /* If needed, did the user provide quadrature tolerances? */
       if ( (itolQS == CV_EE) && (itolQ == CV_NN) ) {
-        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_NO_TOLQ);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_NO_TOLQ);
         return(CV_ILL_INPUT);
       }
 
       /* Load ewtQS */
       ier = cvQuadSensEwtSet(cv_mem, znQS[0], ewtQS);
       if (ier != 0) {
-        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_BAD_EWTQS);
+        cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_BAD_EWTQS);
         return(CV_ILL_INPUT);
       }
 
@@ -4719,13 +4730,13 @@ static int cvInitialSetup(CVodeMem cv_mem)
   /* Check if lsolve function exists (if needed) and call linit function (if it exists) */
   if (iter == CV_NEWTON) {
     if (lsolve == NULL) {
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVode", MSGCV_LSOLVE_NULL);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "cvInitialSetup", MSGCV_LSOLVE_NULL);
       return(CV_ILL_INPUT);
     }
     if (linit != NULL) {
       ier = linit(cv_mem);
       if (ier != 0) {
-        cvProcessError(cv_mem, CV_LINIT_FAIL, "CVODES", "CVode", MSGCV_LINIT_FAIL);
+        cvProcessError(cv_mem, CV_LINIT_FAIL, "CVODES", "cvInitialSetup", MSGCV_LINIT_FAIL);
         return(CV_LINIT_FAIL);
       }
     }
@@ -4740,9 +4751,9 @@ static int cvInitialSetup(CVodeMem cv_mem)
  * This routine is responsible for setting the error weight vector ewt,
  * according to tol_type, as follows:
  *
- * (1) ewt[i] = 1 / (reltol * ABS(ycur[i]) + *abstol), i=0,...,neq-1
+ * (1) ewt[i] = 1 / (reltol * SUNRabs(ycur[i]) + *abstol), i=0,...,neq-1
  *     if tol_type = CV_SS
- * (2) ewt[i] = 1 / (reltol * ABS(ycur[i]) + abstol[i]), i=0,...,neq-1
+ * (2) ewt[i] = 1 / (reltol * SUNRabs(ycur[i]) + abstol[i]), i=0,...,neq-1
  *     if tol_type = CV_SV
  *
  * cvEwtSet returns 0 if ewt is successfully set as above to a
@@ -4762,10 +4773,10 @@ int cvEwtSet(N_Vector ycur, N_Vector weight, void *data)
   cv_mem = (CVodeMem) data;
 
   switch(itol) {
-  case CV_SS: 
+  case CV_SS:
     flag = cvEwtSetSS(cv_mem, ycur, weight);
     break;
-  case CV_SV: 
+  case CV_SV:
     flag = cvEwtSetSV(cv_mem, ycur, weight);
     break;
   }
@@ -4821,10 +4832,10 @@ static int cvQuadEwtSet(CVodeMem cv_mem, N_Vector qcur, N_Vector weightQ)
   int flag=0;
 
   switch (itolQ) {
-  case CV_SS: 
+  case CV_SS:
     flag = cvQuadEwtSetSS(cv_mem, qcur, weightQ);
     break;
-  case CV_SV: 
+  case CV_SV:
     flag = cvQuadEwtSetSV(cv_mem, qcur, weightQ);
     break;
   }
@@ -4877,10 +4888,10 @@ static int cvSensEwtSet(CVodeMem cv_mem, N_Vector *yScur, N_Vector *weightS)
   case CV_EE:
     flag = cvSensEwtSetEE(cv_mem, yScur, weightS);
     break;
-  case CV_SS: 
+  case CV_SS:
     flag = cvSensEwtSetSS(cv_mem, yScur, weightS);
     break;
-  case CV_SV: 
+  case CV_SV:
     flag = cvSensEwtSetSV(cv_mem, yScur, weightS);
     break;
   }
@@ -4970,10 +4981,10 @@ static int cvQuadSensEwtSet(CVodeMem cv_mem, N_Vector *yQScur, N_Vector *weightQ
   case CV_EE:
     flag = cvQuadSensEwtSetEE(cv_mem, yQScur, weightQS);
     break;
-  case CV_SS: 
+  case CV_SS:
     flag = cvQuadSensEwtSetSS(cv_mem, yQScur, weightQS);
     break;
-  case CV_SV: 
+  case CV_SV:
     flag = cvQuadSensEwtSetSV(cv_mem, yQScur, weightQS);
     break;
   }
@@ -5085,7 +5096,7 @@ static int cvStep(CVodeMem cv_mem)
   /* Initialize local counters for convergence and error test failures */
 
   ncf  = nef  = 0;
-  nefQ = 0;
+  nefQ = nefQS = 0;
   ncfS = nefS = 0;
   if (do_sensi_stg1) {
     for (is=0; is<Ns; is++) ncfS1[is] = 0;
@@ -5324,10 +5335,10 @@ static void cvAdjustOrder(CVodeMem cv_mem, int deltaq)
   if ((q==2) && (deltaq != 1)) return;
   
   switch(lmm){
-  case CV_ADAMS: 
+  case CV_ADAMS:
     cvAdjustAdams(cv_mem, deltaq);
     break;
-  case CV_BDF:   
+  case CV_BDF:
     cvAdjustBDF(cv_mem, deltaq);
     break;
   }
@@ -5640,10 +5651,10 @@ static void cvPredict(CVodeMem cv_mem)
 static void cvSet(CVodeMem cv_mem)
 {
   switch(lmm) {
-  case CV_ADAMS: 
+  case CV_ADAMS:
     cvSetAdams(cv_mem);
     break;
-  case CV_BDF: 
+  case CV_BDF:
     cvSetBDF(cv_mem);
     break;
   }
@@ -5838,15 +5849,15 @@ static void cvSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
   
   A1 = ONE - alpha0_hat + alpha0;
   A2 = ONE + q * A1;
-  tq[2] = ABS(A1 / (alpha0 * A2));
-  tq[5] = ABS(A2 * xistar_inv / (l[q] * xi_inv));
+  tq[2] = SUNRabs(A1 / (alpha0 * A2));
+  tq[5] = SUNRabs(A2 * xistar_inv / (l[q] * xi_inv));
   if (qwait == 1) {
     if (q > 1) {
       C = xistar_inv / l[q];
       A3 = alpha0 + ONE / q;
       A4 = alpha0_hat + xi_inv;
       Cpinv = (ONE - A4 + A3) / A3;
-      tq[1] = ABS(C * Cpinv);
+      tq[1] = SUNRabs(C * Cpinv);
     }
     else tq[1] = ONE;
     hsum += tau[q];
@@ -5854,7 +5865,7 @@ static void cvSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
     A5 = alpha0 - (ONE / (q+1));
     A6 = alpha0_hat - xi_inv;
     Cppinv = (ONE - A6 + A5) / A2;
-    tq[3] = ABS(Cppinv / (xi_inv * (q+2) * A5));
+    tq[3] = SUNRabs(Cppinv / (xi_inv * (q+2) * A5));
   }
   tq[4] = nlscoef / tq[2];
 }
@@ -5876,13 +5887,13 @@ static void cvSetTqBDF(CVodeMem cv_mem, realtype hsum, realtype alpha0,
 
 static int cvNls(CVodeMem cv_mem, int nflag)
 {
-  int flag=CV_SUCCESS;
+  int flag = CV_SUCCESS;
 
   switch(iter) {
-  case CV_FUNCTIONAL: 
+  case CV_FUNCTIONAL:
     flag = cvNlsFunctional(cv_mem);
     break;
-  case CV_NEWTON: 
+  case CV_NEWTON:
     flag = cvNlsNewton(cv_mem, nflag);
     break;
   }
@@ -5999,8 +6010,8 @@ static int cvNlsFunctional(CVodeMem cv_mem)
     */
     
     Del = (do_sensi_sim) ? delS : del;
-    if (m > 0) crate = MAX(CRDOWN * crate, Del / Delp);
-    dcon = Del * MIN(ONE, crate) / tq[4];
+    if (m > 0) crate = SUNMAX(CRDOWN * crate, Del / Delp);
+    dcon = Del * SUNMIN(ONE, crate) / tq[4];
 
     if (dcon <= ONE) {
       if (m == 0)
@@ -6093,7 +6104,7 @@ static int cvNlsNewton(CVodeMem cv_mem, int nflag)
   /* Decide whether or not to call setup routine (if one exists) */
   if (setupNonNull) {      
     callSetup = (nflag == PREV_CONV_FAIL) || (nflag == PREV_ERR_FAIL) ||
-      (nst == 0) || (nst >= nstlp + MSBP) || (ABS(gamrat-ONE) > DGMAX);
+      (nst == 0) || (nst >= nstlp + MSBP) || (SUNRabs(gamrat-ONE) > DGMAX);
 
     /* Decide whether to force a call to setup */
     if (forceSetup) {
@@ -6217,7 +6228,6 @@ static int cvNewtonIteration(CVodeMem cv_mem)
 
     /* Call the lsolve function */
     b = tempv;
-
     retval = lsolve(cv_mem, b, ewt, y, ftemp); 
     nni++;
 
@@ -6268,8 +6278,8 @@ static int cvNewtonIteration(CVodeMem cv_mem)
        rate constant is stored in crate, and used in the test.        */
 
     Del = (do_sensi_sim) ? delS : del;
-    if (m > 0) crate = MAX(CRDOWN * crate, Del/Delp);
-    dcon = Del * MIN(ONE, crate) / tq[4];
+    if (m > 0) crate = SUNMAX(CRDOWN * crate, Del/Delp);
+    dcon = Del * SUNMIN(ONE, crate) / tq[4];
     
     if (dcon <= ONE) {
       if (m == 0)
@@ -6412,10 +6422,10 @@ static int cvStgrNls(CVodeMem cv_mem)
   int flag=CV_SUCCESS;
 
   switch(iter) {
-  case CV_FUNCTIONAL: 
+  case CV_FUNCTIONAL:
     flag = cvStgrNlsFunctional(cv_mem);
     break;
-  case CV_NEWTON:     
+  case CV_NEWTON:
     flag = cvStgrNlsNewton(cv_mem);
     break;
   }
@@ -6484,8 +6494,8 @@ static int cvStgrNlsFunctional(CVodeMem cv_mem)
        rate constant is stored in crateS, and used in the test. 
        acnrmS contains the norm of the corrections (yS_n-yS_n(0)) and
        will be used in the error test (if errconS==TRUE)              */
-    if (m > 0) crateS = MAX(CRDOWN * crateS, Del / Delp);
-    dcon = Del * MIN(ONE, crateS) / tq[4];
+    if (m > 0) crateS = SUNMAX(CRDOWN * crateS, Del / Delp);
+    dcon = Del * SUNMIN(ONE, crateS) / tq[4];
     
     if (dcon <= ONE) {
       if (errconS)
@@ -6654,8 +6664,8 @@ static int cvStgrNewtonIteration(CVodeMem cv_mem)
 
     /* Test for convergence.  If m > 0, an estimate of the convergence
        rate constant is stored in crateS, and used in the test.        */
-    if (m > 0) crateS = MAX(CRDOWN * crateS, Del/Delp);
-    dcon = Del * MIN(ONE, crateS) / tq[4];
+    if (m > 0) crateS = SUNMAX(CRDOWN * crateS, Del/Delp);
+    dcon = Del * SUNMIN(ONE, crateS) / tq[4];
     if (dcon <= ONE) {
       if (errconS)
         acnrmS = (m==0) ? Del : cvSensNorm(cv_mem, acorS, ewtS);
@@ -6703,10 +6713,10 @@ static int cvStgr1Nls(CVodeMem cv_mem, int is)
   int flag=CV_SUCCESS;
 
   switch(iter) {
-  case CV_FUNCTIONAL: 
+  case CV_FUNCTIONAL:
     flag = cvStgr1NlsFunctional(cv_mem,is);
     break;
-  case CV_NEWTON:     
+  case CV_NEWTON:
     flag = cvStgr1NlsNewton(cv_mem,is);
     break;
   }
@@ -6769,8 +6779,8 @@ static int cvStgr1NlsFunctional(CVodeMem cv_mem, int is)
     /* Test for convergence.  If m > 0, an estimate of the convergence
        rate constant is stored in crateS, and used in the test. */
 
-    if (m > 0) crateS = MAX(CRDOWN * crateS, Del / Delp);
-    dcon = Del * MIN(ONE, crateS) / tq[4];
+    if (m > 0) crateS = SUNMAX(CRDOWN * crateS, Del / Delp);
+    dcon = Del * SUNMIN(ONE, crateS) / tq[4];
 
     if (dcon <= ONE) {
       return(CV_SUCCESS);  /* Convergence achieved */
@@ -6930,8 +6940,8 @@ static int cvStgr1NewtonIteration(CVodeMem cv_mem, int is)
 
     /* Test for convergence.  If m > 0, an estimate of the convergence
        rate constant is stored in crateS, and used in the test.        */
-    if (m > 0) crateS = MAX(CRDOWN * crateS, Del/Delp);
-    dcon = Del * MIN(ONE, crateS) / tq[4];
+    if (m > 0) crateS = SUNMAX(CRDOWN * crateS, Del/Delp);
+    dcon = Del * SUNMIN(ONE, crateS) / tq[4];
     if (dcon <= ONE) {
       jcur = FALSE;
       return(CV_SUCCESS);  /* Convergence achieved */
@@ -7034,7 +7044,7 @@ static int cvHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
      return CV_CONV_FAILURE, CV_REPTD_RHSFUNC_ERR, 
      CV_REPTD_QRHSFUNC_ERR, or CV_REPTD_SRHSFUNC_ERR */
 
-  if ((ABS(h) <= hmin*ONEPSM) || (*ncfPtr == maxncf)) {
+  if ((SUNRabs(h) <= hmin*ONEPSM) || (*ncfPtr == maxncf)) {
     if (nflag == CONV_FAIL)       return(CV_CONV_FAILURE);
     if (nflag == RHSFUNC_RECVR)   return(CV_REPTD_RHSFUNC_ERR);    
     if (nflag == QRHSFUNC_RECVR)  return(CV_REPTD_QRHSFUNC_ERR);    
@@ -7044,7 +7054,7 @@ static int cvHandleNFlag(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
 
   /* Reduce step size; return to reattempt the step */
 
-  eta = MAX(ETACF, hmin / ABS(h));
+  eta = SUNMAX(ETACF, hmin / SUNRabs(h));
   *nflagPtr = PREV_CONV_FAIL;
   cvRescale(cv_mem);
 
@@ -7112,7 +7122,7 @@ static void cvRestore(CVodeMem cv_mem, realtype saved_t)
  *
  * If the test fails, we undo the step just taken (call cvRestore) and 
  *
- *   - if maxnef error test failures have occurred or if ABS(h) = hmin,
+ *   - if maxnef error test failures have occurred or if SUNRabs(h) = hmin,
  *     we return CV_ERR_FAILURE.
  *
  *   - if more than MXNEF1 error test failures have occurred, an order
@@ -7148,23 +7158,23 @@ static int cvDoErrorTest(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
   cvRestore(cv_mem, saved_t);
 
   /* At maxnef failures or |h| = hmin, return CV_ERR_FAILURE */
-  if ((ABS(h) <= hmin*ONEPSM) || (*nefPtr == maxnef)) return(CV_ERR_FAILURE);
+  if ((SUNRabs(h) <= hmin*ONEPSM) || (*nefPtr == maxnef)) return(CV_ERR_FAILURE);
 
   /* Set etamax = 1 to prevent step size increase at end of this step */
   etamax = ONE;
 
   /* Set h ratio eta from dsm, rescale, and return for retry of step */
   if (*nefPtr <= MXNEF1) {
-    eta = ONE / (RPowerR(BIAS2*dsm,ONE/L) + ADDON);
-    eta = MAX(ETAMIN, MAX(eta, hmin / ABS(h)));
-    if (*nefPtr >= SMALL_NEF) eta = MIN(eta, ETAMXF);
+    eta = ONE / (SUNRpowerR(BIAS2*dsm,ONE/L) + ADDON);
+    eta = SUNMAX(ETAMIN, SUNMAX(eta, hmin / SUNRabs(h)));
+    if (*nefPtr >= SMALL_NEF) eta = SUNMIN(eta, ETAMXF);
     cvRescale(cv_mem);
     return(TRY_AGAIN);
   }
   
   /* After MXNEF1 failures, force an order reduction and retry step */
   if (q > 1) {
-    eta = MAX(ETAMIN, hmin / ABS(h));
+    eta = SUNMAX(ETAMIN, hmin / SUNRabs(h));
     cvAdjustOrder(cv_mem,-1);
     L = q;
     q--;
@@ -7174,7 +7184,7 @@ static int cvDoErrorTest(CVodeMem cv_mem, int *nflagPtr, realtype saved_t,
   }
 
   /* If already at order 1, restart: reload zn, znQ, znS, znQS from scratch */
-  eta = MAX(ETAMIN, hmin / ABS(h));
+  eta = SUNMAX(ETAMIN, hmin / SUNRabs(h));
   h *= eta;
   next_h = h;
   hscale = h;
@@ -7265,7 +7275,6 @@ static void cvCompleteStep(CVodeMem cv_mem)
   tau[1] = h;
 
   /* Apply correction to column j of zn: l_j * Delta_n */
-
   for (j=0; j <= q; j++) 
     N_VLinearSum(l[j], acor, ONE, zn[j], zn[j]);
 
@@ -7327,7 +7336,7 @@ static void cvPrepareNextStep(CVodeMem cv_mem, realtype dsm)
 {
   /* If etamax = 1, defer step size or order changes */
   if (etamax == ONE) {
-    qwait = MAX(qwait, 2);
+    qwait = SUNMAX(qwait, 2);
     qprime = q;
     hprime = h;
     eta = ONE;
@@ -7335,7 +7344,7 @@ static void cvPrepareNextStep(CVodeMem cv_mem, realtype dsm)
   }
 
   /* etaq is the ratio of new to old h at the current order */  
-  etaq = ONE /(RPowerR(BIAS2*dsm,ONE/L) + ADDON);
+  etaq = ONE /(SUNRpowerR(BIAS2*dsm,ONE/L) + ADDON);
   
   /* If no order change, adjust eta and acor in cvSetEta and return */
   if (qwait != 0) {
@@ -7359,8 +7368,7 @@ static void cvPrepareNextStep(CVodeMem cv_mem, realtype dsm)
  * cvSetEta
  *
  * This routine adjusts the value of eta according to the various
- * heuristic limits and the optional input hmax.  It also resets
- * etamax to be the estimated local error vector.
+ * heuristic limits and the optional input hmax.
  */
 
 static void cvSetEta(CVodeMem cv_mem)
@@ -7372,13 +7380,11 @@ static void cvSetEta(CVodeMem cv_mem)
     hprime = h;
   } else {
     /* Limit eta by etamax and hmax, then set hprime */
-    eta = MIN(eta, etamax);
-    eta /= MAX(ONE, ABS(h)*hmax_inv*eta);
+    eta = SUNMIN(eta, etamax);
+    eta /= SUNMAX(ONE, SUNRabs(h)*hmax_inv*eta);
     hprime = h * eta;
     if (qprime < q) nscon = 0;
   }
-
-  /* Reset etamx for the next step size change, and scale acor */
 }
 
 /*
@@ -7398,22 +7404,17 @@ static realtype cvComputeEtaqm1(CVodeMem cv_mem)
 
     ddn = N_VWrmsNorm(zn[q], ewt);
 
-    if ( quadr && errconQ) {
+    if ( quadr && errconQ )
       ddn = cvQuadUpdateNorm(cv_mem, ddn, znQ[q], ewtQ);
-    }
 
-    if ( sensi && errconS ) {
+    if ( sensi && errconS )
       ddn = cvSensUpdateNorm(cv_mem, ddn, znS[q], ewtS);
-    }
 
-    if ( quadr_sensi && errconQS ) {
+    if ( quadr_sensi && errconQS )
       ddn = cvQuadSensUpdateNorm(cv_mem, ddn, znQS[q], ewtQS);
-    }
 
     ddn = ddn * tq[1];
-
-    etaqm1 = ONE/(RPowerR(BIAS1*ddn, ONE/q) + ADDON);
-
+    etaqm1 = ONE/(SUNRpowerR(BIAS1*ddn, ONE/q) + ADDON);
   }
 
   return(etaqm1);
@@ -7437,10 +7438,8 @@ static realtype cvComputeEtaqp1(CVodeMem cv_mem)
 
     if (saved_tq5 == ZERO) return(etaqp1);
 
-    cquot = (tq[5] / saved_tq5) * RPowerI(h/tau[2], L);
-
+    cquot = (tq[5] / saved_tq5) * SUNRpowerI(h/tau[2], L);
     N_VLinearSum(-cquot, zn[qmax], ONE, acor, tempv);
-
     dup = N_VWrmsNorm(tempv, ewt);
 
     if ( quadr && errconQ ) {
@@ -7461,9 +7460,7 @@ static realtype cvComputeEtaqp1(CVodeMem cv_mem)
     }
 
     dup = dup * tq[3];
-
-    etaqp1 = ONE / (RPowerR(BIAS3*dup, ONE/(L+1)) + ADDON);
-
+    etaqp1 = ONE / (SUNRpowerR(BIAS3*dup, ONE/(L+1)) + ADDON);
   }
 
   return(etaqp1);
@@ -7486,7 +7483,7 @@ static void cvChooseEta(CVodeMem cv_mem)
   realtype etam;
   int is;
   
-  etam = MAX(etaqm1, MAX(etaq, etaqp1));
+  etam = SUNMAX(etaqm1, SUNMAX(etaq, etaqp1));
   
   if (etam < THRESH) {
     eta = ONE;
@@ -7532,9 +7529,7 @@ static void cvChooseEta(CVodeMem cv_mem)
           N_VScale(ONE, acorQS[is], znQS[qmax][is]);
 
     }
-
   }
-
 }
 
 /* 
@@ -7558,20 +7553,20 @@ static int cvHandleFailure(CVodeMem cv_mem, int flag)
   /*
   N_VProd(acor, ewt, tempv);
   N_VAbs(tempv, tempv);
-  */  
+  */
 
   /* Depending on flag, print error message and return error flag */
   switch (flag) {
-  case CV_ERR_FAILURE:  
+  case CV_ERR_FAILURE:
     cvProcessError(cv_mem, CV_ERR_FAILURE, "CVODES", "CVode", MSGCV_ERR_FAILS, tn, h);
     break;
-  case CV_CONV_FAILURE: 
+  case CV_CONV_FAILURE:
     cvProcessError(cv_mem, CV_CONV_FAILURE, "CVODES", "CVode", MSGCV_CONV_FAILS, tn, h);
     break;
-  case CV_LSETUP_FAIL:  
+  case CV_LSETUP_FAIL:
     cvProcessError(cv_mem, CV_LSETUP_FAIL, "CVODES", "CVode", MSGCV_SETUP_FAILED, tn);
     break;
-  case CV_LSOLVE_FAIL:  
+  case CV_LSOLVE_FAIL:
     cvProcessError(cv_mem, CV_LSOLVE_FAIL, "CVODES", "CVode", MSGCV_SOLVE_FAILED, tn);
     break;
   case CV_RHSFUNC_FAIL:
@@ -7583,7 +7578,7 @@ static int cvHandleFailure(CVodeMem cv_mem, int flag)
   case CV_REPTD_RHSFUNC_ERR:
     cvProcessError(cv_mem, CV_REPTD_RHSFUNC_ERR, "CVODES", "CVode", MSGCV_RHSFUNC_REPTD, tn);
     break;
-  case CV_RTFUNC_FAIL:    
+  case CV_RTFUNC_FAIL:
     cvProcessError(cv_mem, CV_RTFUNC_FAIL, "CVODES", "CVode", MSGCV_RTFUNC_FAILED, tn);
     break;
   case CV_QRHSFUNC_FAIL:
@@ -7604,7 +7599,6 @@ static int cvHandleFailure(CVodeMem cv_mem, int flag)
   case CV_REPTD_SRHSFUNC_ERR:
     cvProcessError(cv_mem, CV_REPTD_SRHSFUNC_ERR, "CVODES", "CVode", MSGCV_SRHSFUNC_REPTD, tn);
     break;
-
   case CV_QSRHSFUNC_FAIL:
     cvProcessError(cv_mem, CV_QSRHSFUNC_FAIL, "CVODES", "CVode", MSGCV_QSRHSFUNC_FAILED, tn);
     break;
@@ -7614,8 +7608,6 @@ static int cvHandleFailure(CVodeMem cv_mem, int flag)
   case CV_REPTD_QSRHSFUNC_ERR:
     cvProcessError(cv_mem, CV_REPTD_QSRHSFUNC_ERR, "CVODES", "CVode", MSGCV_QSRHSFUNC_REPTD, tn);
     break;
-
-
   case CV_TOO_CLOSE:
     cvProcessError(cv_mem, CV_TOO_CLOSE, "CVODES", "CVode", MSGCV_TOO_CLOSE);
     break;
@@ -7624,7 +7616,6 @@ static int cvHandleFailure(CVodeMem cv_mem, int flag)
   }
 
   return(flag);
-
 }
 
 /* 
@@ -7655,11 +7646,11 @@ static void cvBDFStab(CVodeMem cv_mem)
 
   if (q >= 3) {
     for (k = 1; k <= 3; k++)
-      for (i = 5; i >= 2; i--) 
-        ssdat[i][k] = ssdat[i-1][k]; 
+      for (i = 5; i >= 2; i--)
+        ssdat[i][k] = ssdat[i-1][k];
     factorial = 1;
     for (i = 1; i <= q-1; i++) factorial *= i;
-    sq = factorial*q*(q+1)*acnrm/MAX(tq[5],TINY);
+    sq = factorial*q*(q+1)*acnrm/SUNMAX(tq[5],TINY);
     sqm1 = factorial*q*N_VWrmsNorm(zn[q], ewt);
     sqm2 = factorial*N_VWrmsNorm(zn[q-1], ewt);
     ssdat[1][1] = sqm2*sqm2;
@@ -7680,8 +7671,8 @@ static void cvBDFStab(CVodeMem cv_mem)
            Reduce new order.                     */
         qprime = q-1;
         eta = etaqm1; 
-        eta = MIN(eta,etamax);
-        eta = eta/MAX(ONE,ABS(h)*hmax_inv*eta);
+        eta = SUNMIN(eta,etamax);
+        eta = eta/SUNMAX(ONE,SUNRabs(h)*hmax_inv*eta);
         hprime = h*eta;
         nor = nor + 1;
       }
@@ -7732,7 +7723,7 @@ static void cvBDFStab(CVodeMem cv_mem)
 
 static int cvSLdet(CVodeMem cv_mem)
 {
-  int i, k, j, it, kmin=0, kflag=0;
+  int i, k, j, it, kmin = 0, kflag = 0;
   realtype rat[5][4], rav[4], qkr[4], sigsq[4], smax[4], ssmax[4];
   realtype drr[4], rrc[4],sqmx[4], qjk[4][4], vrat[5], qc[6][4], qco[6][4];
   realtype rr, rrcut, vrrtol, vrrt2, sqtol, rrtol;
@@ -7767,8 +7758,8 @@ static int cvSLdet(CVodeMem cv_mem)
     smaxk = ZERO;
     
     for (i=1; i<=5; i++) {
-      smink = MIN(smink,ssdat[i][k]);
-      smaxk = MAX(smaxk,ssdat[i][k]);
+      smink = SUNMIN(smink,ssdat[i][k]);
+      smaxk = SUNMAX(smaxk,ssdat[i][k]);
     }
     
     if (smink < TINY*smaxk) {
@@ -7777,7 +7768,7 @@ static int cvSLdet(CVodeMem cv_mem)
     }
     smax[k] = smaxk;
     ssmax[k] = smaxk*smaxk;
-    
+
     sumrat = ZERO;
     sumrsq = ZERO;
     for (i=1; i<=4; i++) {
@@ -7786,14 +7777,14 @@ static int cvSLdet(CVodeMem cv_mem)
       sumrsq = sumrsq + rat[i][k]*rat[i][k];
     } 
     rav[k] = FOURTH*sumrat;
-    vrat[k] = ABS(FOURTH*sumrsq - rav[k]*rav[k]);
-      
+    vrat[k] = SUNRabs(FOURTH*sumrsq - rav[k]*rav[k]);
+
     qc[5][k] = ssdat[1][k]*ssdat[3][k] - ssdat[2][k]*ssdat[2][k];
     qc[4][k] = ssdat[2][k]*ssdat[3][k] - ssdat[1][k]*ssdat[4][k];
     qc[3][k] = ZERO;
     qc[2][k] = ssdat[2][k]*ssdat[5][k] - ssdat[3][k]*ssdat[4][k];
     qc[1][k] = ssdat[4][k]*ssdat[4][k] - ssdat[3][k]*ssdat[5][k];
-    
+
     for (i=1; i<=5; i++) {
       qco[i][k] = qc[i][k];
     }
@@ -7804,8 +7795,8 @@ static int cvSLdet(CVodeMem cv_mem)
      Return a kflag = 1 if this procedure works. If three root 
      differ more than vrrt2, return error kflag = -3.    */
   
-  vmin = MIN(vrat[1],MIN(vrat[2],vrat[3]));
-  vmax = MAX(vrat[1],MAX(vrat[2],vrat[3]));
+  vmin = SUNMIN(vrat[1],SUNMIN(vrat[2],vrat[3]));
+  vmax = SUNMAX(vrat[1],SUNMAX(vrat[2],vrat[3]));
   
   if (vmin < vrrtol*vrrtol) {
 
@@ -7816,97 +7807,95 @@ static int cvSLdet(CVodeMem cv_mem)
       rr = (rav[1] + rav[2] + rav[3])/THREE;
       drrmax = ZERO;
       for (k = 1;k<=3;k++) {
-        adrr = ABS(rav[k] - rr);
-        drrmax = MAX(drrmax, adrr);
+        adrr = SUNRabs(rav[k] - rr);
+        drrmax = SUNMAX(drrmax, adrr);
       }
-      if (drrmax > vrrt2)
-        kflag = -3;    
+      if (drrmax > vrrt2) kflag = -3;    
       kflag = 1;
+
       /*  can compute charactistic root, drop to next section   */
     }
 
   } else {
-      
+
     /* use the quartics to get rr. */
-      
-    if (ABS(qco[1][1]) < TINY*ssmax[1]) {
+
+    if (SUNRabs(qco[1][1]) < TINY*ssmax[1]) {
       kflag = -4;    
       return(kflag);
     }
-      
+
     tem = qco[1][2]/qco[1][1];
     for (i=2; i<=5; i++) {
       qco[i][2] = qco[i][2] - tem*qco[i][1];
     }
-      
+
     qco[1][2] = ZERO;
     tem = qco[1][3]/qco[1][1];
     for (i=2; i<=5; i++) {
       qco[i][3] = qco[i][3] - tem*qco[i][1];
     }
     qco[1][3] = ZERO;
-      
-    if (ABS(qco[2][2]) < TINY*ssmax[2]) {
+
+    if (SUNRabs(qco[2][2]) < TINY*ssmax[2]) {
       kflag = -4;    
       return(kflag);
     }
-      
+
     tem = qco[2][3]/qco[2][2];
     for (i=3; i<=5; i++) {
       qco[i][3] = qco[i][3] - tem*qco[i][2];
     }
-      
-    if (ABS(qco[4][3]) < TINY*ssmax[3]) {
+
+    if (SUNRabs(qco[4][3]) < TINY*ssmax[3]) {
       kflag = -4;    
       return(kflag);
     }
-      
+
     rr = -qco[5][3]/qco[4][3];
-      
-    if (rr < TINY || rr > HUN) {
+
+    if (rr < TINY || rr > HUNDRED) {
       kflag = -5;   
       return(kflag);
     }
-      
-    for (k=1; k<=3; k++) {
+
+    for (k=1; k<=3; k++)
       qkr[k] = qc[5][k] + rr*(qc[4][k] + rr*rr*(qc[2][k] + rr*qc[1][k]));
-    }  
-      
+
     sqmax = ZERO;
     for (k=1; k<=3; k++) {
-      saqk = ABS(qkr[k])/ssmax[k];
+      saqk = SUNRabs(qkr[k])/ssmax[k];
       if (saqk > sqmax) sqmax = saqk;
     } 
-      
+
     if (sqmax < sqtol) {
       kflag = 2;
-        
+
       /*  can compute charactistic root, drop to "given rr,etc"   */
-        
+
     } else {
-          
+
       /* do Newton corrections to improve rr.  */
-        
+
       for (it=1; it<=3; it++) {
         for (k=1; k<=3; k++) {
           qp = qc[4][k] + rr*rr*(THREE*qc[2][k] + rr*FOUR*qc[1][k]);
           drr[k] = ZERO;
-          if (ABS(qp) > TINY*ssmax[k]) drr[k] = -qkr[k]/qp;
+          if (SUNRabs(qp) > TINY*ssmax[k]) drr[k] = -qkr[k]/qp;
           rrc[k] = rr + drr[k];
         } 
-          
+
         for (k=1; k<=3; k++) {
           s = rrc[k];
           sqmaxk = ZERO;
           for (j=1; j<=3; j++) {
-            qjk[j][k] = qc[5][j] + s*(qc[4][j] + 
-                                      s*s*(qc[2][j] + s*qc[1][j]));
-            saqj = ABS(qjk[j][k])/ssmax[j];
+            qjk[j][k] = qc[5][j] + s*(qc[4][j] + s*s*(qc[2][j] + s*qc[1][j]));
+            saqj = SUNRabs(qjk[j][k])/ssmax[j];
             if (saqj > sqmaxk) sqmaxk = saqj;
           } 
           sqmx[k] = sqmaxk;
-        } 
-              
+        }
+
         sqmin = sqmx[1] + ONE;
         for (k=1; k<=3; k++) {
           if (sqmx[k] < sqmin) {
@@ -7915,7 +7904,7 @@ static int cvSLdet(CVodeMem cv_mem)
           }
         } 
         rr = rrc[kmin];
-              
+
         if (sqmin < sqtol) {
           kflag = 3;
           /*  can compute charactistic root   */
@@ -7927,14 +7916,14 @@ static int cvSLdet(CVodeMem cv_mem)
           }
         }     
       } /*  end of Newton correction loop  */ 
-          
+
       if (sqmin > sqtol) {
         kflag = -6;
         return(kflag);
       }
     } /*  end of if (sqmax < sqtol) else   */
   } /*  end of if (vmin < vrrtol*vrrtol) else, quartics to get rr. */
-  
+
   /* given rr, find sigsq[k] and verify rr.  */
   /* All positive kflag drop to this section  */
   
@@ -7950,7 +7939,7 @@ static int cvSLdet(CVodeMem cv_mem)
     rd2b = rd1b - rd1c;
     rd3a = rd2a - rd2b;
     
-    if (ABS(rd1b) < TINY*smax[k]) {
+    if (SUNRabs(rd1b) < TINY*smax[k]) {
       kflag = -7;
       return(kflag);
     }
@@ -7976,14 +7965,14 @@ static int cvSLdet(CVodeMem cv_mem)
   bb = ratp*ratm - ONE - qfac1*ratp;
   tem = ONE - qfac2*bb;
   
-  if (ABS(tem) < TINY) {
+  if (SUNRabs(tem) < TINY) {
     kflag = -8;
     return(kflag);
   }
   
   rrb = ONE/tem;
   
-  if (ABS(rrb - rr) > rrtol) {
+  if (SUNRabs(rrb - rr) > rrtol) {
     kflag = -9;
     return(kflag);
   }
@@ -8015,8 +8004,8 @@ static int cvSLdet(CVodeMem cv_mem)
  * the initial point of the IVP.
  *
  * This routine returns an int equal to:
- *  CV_RTFUNC_FAIL = -12  if the g function failed, or
- *  CV_SUCCESS     =   0  otherwise.
+ *  CV_RTFUNC_FAIL < 0 if the g function failed, or
+ *  CV_SUCCESS     = 0 otherwise.
  */
 
 static int cvRcheck1(CVodeMem cv_mem)
@@ -8027,16 +8016,16 @@ static int cvRcheck1(CVodeMem cv_mem)
 
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   tlo = tn;
-  ttol = (ABS(tn) + ABS(h))*uround*HUN;
+  ttol = (SUNRabs(tn) + SUNRabs(h))*uround*HUNDRED;
 
   /* Evaluate g at initial t and check for zero values. */
   retval = gfun(tlo, zn[0], glo, user_data);
   nge = 1;
   if (retval != 0) return(CV_RTFUNC_FAIL);
-  
+
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       gactive[i] = FALSE;
     }
@@ -8044,7 +8033,7 @@ static int cvRcheck1(CVodeMem cv_mem)
   if (!zroot) return(CV_SUCCESS);
 
   /* Some g_i is zero at t0; look at g at t0+(small increment). */
-  hratio = MAX(ttol/ABS(h), TENTH);
+  hratio = SUNMAX(ttol/SUNRabs(h), PT1);
   smallh = hratio*h;
   tplus = tlo + smallh;
   N_VLinearSum(ONE, zn[0], hratio, zn[1], y);
@@ -8054,9 +8043,8 @@ static int cvRcheck1(CVodeMem cv_mem)
 
   /* We check now only the components of g which were exactly 0.0 at t0
    * to see if we can 'activate' them. */
-
   for (i = 0; i < nrtfn; i++) {
-    if (!gactive[i] && ABS(ghi[i]) != ZERO) {
+    if (!gactive[i] && SUNRabs(ghi[i]) != ZERO) {
       gactive[i] = TRUE;
       glo[i] = ghi[i];
     }
@@ -8075,14 +8063,14 @@ static int cvRcheck1(CVodeMem cv_mem)
  * there, before returning to do a root search in the interval.
  *
  * On entry, tlo = tretlast is the last value of tret returned by
- * CVode.  This may be the previous tn, the previous tout value, or
- * the last root location.
+ * CVode.  This may be the previous tn, the previous tout value,
+ * or the last root location.
  *
  * This routine returns an int equal to:
- *      CV_RTFUNC_FAIL = -12 if the g function failed, or
- *      CLOSERT        =  3  if a close pair of zeros was found, or
- *      RTFOUND        =  1  if a new zero of g was found near tlo, or
- *      CV_SUCCESS     =  0  otherwise.
+ *     CV_RTFUNC_FAIL  < 0 if the g function failed, or
+ *     CLOSERT         = 3 if a close pair of zeros was found, or
+ *     RTFOUND         = 1 if a new zero of g was found near tlo, or
+ *     CV_SUCCESS      = 0 otherwise.
  */
 
 static int cvRcheck2(CVodeMem cv_mem)
@@ -8102,7 +8090,7 @@ static int cvRcheck2(CVodeMem cv_mem)
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   for (i = 0; i < nrtfn; i++) {
     if (!gactive[i]) continue;
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       iroots[i] = 1;
     }
@@ -8110,7 +8098,7 @@ static int cvRcheck2(CVodeMem cv_mem)
   if (!zroot) return(CV_SUCCESS);
 
   /* One or more g_i has a zero at tlo.  Check g at tlo+smallh. */
-  ttol = (ABS(tn) + ABS(h))*uround*HUN;
+  ttol = (SUNRabs(tn) + SUNRabs(h))*uround*HUNDRED;
   smallh = (h > ZERO) ? ttol : -ttol;
   tplus = tlo + smallh;
   if ( (tplus - tn)*h >= ZERO) {
@@ -8127,8 +8115,8 @@ static int cvRcheck2(CVodeMem cv_mem)
   and for a g_i that changed from zero to nonzero. */
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
-    if (ABS(ghi[i]) == ZERO) {
-      if (!gactive[i]) continue;
+    if (!gactive[i]) continue;
+    if (SUNRabs(ghi[i]) == ZERO) {
       if (iroots[i] == 1) return(CLOSERT);
       zroot = TRUE;
       iroots[i] = 1;
@@ -8143,19 +8131,19 @@ static int cvRcheck2(CVodeMem cv_mem)
 /*
  * cvRcheck3
  *
- * This routine interfaces to cvRootFind to look for a root of g
+ * This routine interfaces to cvRootfind to look for a root of g
  * between tlo and either tn or tout, whichever comes first.
  * Only roots beyond tlo in the direction of integration are sought.
  *
  * This routine returns an int equal to:
- *      CV_RTFUNC_FAIL = -12 if the g function failed, or
- *      RTFOUND        =  1  if a root of g was found, or
- *      CV_SUCCESS     =  0  otherwise.
+ *     CV_RTFUNC_FAIL  < 0 if the g function failed, or
+ *     RTFOUND         = 1 if a root of g was found, or
+ *     CV_SUCCESS      = 0 otherwise.
  */
 
 static int cvRcheck3(CVodeMem cv_mem)
 {
-  int i, retval, ier;
+  int i, ier, retval;
 
   /* Set thi = tn or tout, whichever comes first; set y = y(thi). */
   if (taskc == CV_ONE_STEP) {
@@ -8172,13 +8160,13 @@ static int cvRcheck3(CVodeMem cv_mem)
     }
   }
 
-  /* Set ghi = g(thi) and call cvRootFind to search (tlo,thi) for roots. */
+  /* Set ghi = g(thi) and call cvRootfind to search (tlo,thi) for roots. */
   retval = gfun(thi, y, ghi, user_data);
   nge++;
   if (retval != 0) return(CV_RTFUNC_FAIL);
 
-  ttol = (ABS(tn) + ABS(h))*uround*HUN;
-  ier = cvRootFind(cv_mem);
+  ttol = (SUNRabs(tn) + SUNRabs(h))*uround*HUNDRED;
+  ier = cvRootfind(cv_mem);
   if (ier == CV_RTFUNC_FAIL) return(CV_RTFUNC_FAIL);
   for(i=0; i<nrtfn; i++) {
     if(!gactive[i] && grout[i] != ZERO) gactive[i] = TRUE;
@@ -8192,11 +8180,10 @@ static int cvRcheck3(CVodeMem cv_mem)
   /* If a root was found, interpolate to get y(trout) and return.  */
   (void) CVodeGetDky(cv_mem, trout, 0, y);
   return(RTFOUND);
-
 }
 
 /*
- * cvRootFind
+ * cvRootfind
  *
  * This routine solves for a root of g(t) between tlo and thi, if
  * one exists.  Only roots of odd multiplicity (i.e. with a change
@@ -8237,11 +8224,11 @@ static int cvRcheck3(CVodeMem cv_mem)
  *            When a root at trout is found, it is located only to
  *            within a tolerance of ttol.  Typically, ttol should
  *            be set to a value on the order of
- *               100 * UROUND * max (ABS(tlo), ABS(thi))
+ *               100 * UROUND * max (SUNRabs(tlo), SUNRabs(thi))
  *            where UROUND is the unit roundoff of the machine.
  *
  * tlo, thi = endpoints of the interval in which roots are sought.
- *            On input, and must be distinct, but tlo - thi may
+ *            On input, these must be distinct, but tlo - thi may
  *            be of either sign.  The direction of integration is
  *            assumed to be from tlo to thi.  On return, tlo and thi
  *            are the endpoints of the final relevant interval.
@@ -8267,14 +8254,14 @@ static int cvRcheck3(CVodeMem cv_mem)
  *            to that indicated by rootdir[i].
  *
  * This routine returns an int equal to:
- *      CV_RTFUNC_FAIL = -12 if the g function failed, or
- *      RTFOUND        =  1  if a root of g was found, or
- *      CV_SUCCESS     =  0  otherwise.
+ *      CV_RTFUNC_FAIL  < 0 if the g function failed, or
+ *      RTFOUND         = 1 if a root of g was found, or
+ *      CV_SUCCESS      = 0 otherwise.
  */
 
-static int cvRootFind(CVodeMem cv_mem)
+static int cvRootfind(CVodeMem cv_mem)
 {
-  realtype alpha, tmid, gfrac, maxfrac, fracint, fracsub;
+  realtype alph, tmid, gfrac, maxfrac, fracint, fracsub;
   int i, retval, imax, side, sideprev;
   booleantype zroot, sgnchg;
 
@@ -8286,13 +8273,13 @@ static int cvRootFind(CVodeMem cv_mem)
   sgnchg = FALSE;
   for (i = 0;  i < nrtfn; i++) {
     if(!gactive[i]) continue;
-    if (ABS(ghi[i]) == ZERO) {
+    if (SUNRabs(ghi[i]) == ZERO) {
       if(rootdir[i]*glo[i] <= ZERO) {
         zroot = TRUE;
       }
     } else {
       if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-        gfrac = ABS(ghi[i]/(ghi[i] - glo[i]));
+        gfrac = SUNRabs(ghi[i]/(ghi[i] - glo[i]));
         if (gfrac > maxfrac) {
           sgnchg = TRUE;
           maxfrac = gfrac;
@@ -8311,47 +8298,51 @@ static int cvRootFind(CVodeMem cv_mem)
     for (i = 0; i < nrtfn; i++) {
       iroots[i] = 0;
       if(!gactive[i]) continue;
-      if (ABS(ghi[i]) == ZERO) iroots[i] = glo[i] > 0 ? -1:1;
+      if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
+        iroots[i] = glo[i] > 0 ? -1:1;
     }
     return(RTFOUND);
   }
 
-  /* Initialize alpha to avoid compiler warning */
-  alpha = ONE;
+  /* Initialize alph to avoid compiler warning */
+  alph = ONE;
 
   /* A sign change was found.  Loop to locate nearest root. */
 
   side = 0;  sideprev = -1;
   loop {                                    /* Looping point */
 
-    /* Set weight alpha.
-       On the first two passes, set alpha = 1.  Thereafter, reset alpha
+    /* If interval size is already less than tolerance ttol, break. */
+      if (SUNRabs(thi - tlo) <= ttol) break;
+
+    /* Set weight alph.
+       On the first two passes, set alph = 1.  Thereafter, reset alph
        according to the side (low vs high) of the subinterval in which
        the sign change was found in the previous two passes.
-       If the sides were opposite, set alpha = 1.
-       If the sides were the same, then double alpha (if high side),
-       or halve alpha (if low side).
-       The next guess tmid is the secant method value if alpha = 1, but
-       is closer to tlo if alpha < 1, and closer to thi if alpha > 1.    */
+       If the sides were opposite, set alph = 1.
+       If the sides were the same, then double alph (if high side),
+       or halve alph (if low side).
+       The next guess tmid is the secant method value if alph = 1, but
+       is closer to tlo if alph < 1, and closer to thi if alph > 1.    */
 
     if (sideprev == side) {
-      alpha = (side == 2) ? alpha*TWO : alpha*HALF;
+      alph = (side == 2) ? alph*TWO : alph*HALF;
     } else {
-      alpha = ONE;
+      alph = ONE;
     }
 
     /* Set next root approximation tmid and get g(tmid).
        If tmid is too close to tlo or thi, adjust it inward,
        by a fractional distance that is between 0.1 and 0.5.  */
-    tmid = thi - (thi - tlo)*ghi[imax]/(ghi[imax] - alpha*glo[imax]);
-    if (ABS(tmid - tlo) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
-      fracsub = (fracint > FIVE) ? TENTH : HALF/fracint;
+    tmid = thi - (thi - tlo)*ghi[imax]/(ghi[imax] - alph*glo[imax]);
+    if (SUNRabs(tmid - tlo) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
+      fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = tlo + fracsub*(thi - tlo);
     }
-    if (ABS(thi - tmid) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
-      fracsub = (fracint > FIVE) ? TENTH : HALF/fracint;
+    if (SUNRabs(thi - tmid) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
+      fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = thi - fracsub*(thi - tlo);
     }
 
@@ -8368,13 +8359,11 @@ static int cvRootFind(CVodeMem cv_mem)
     sideprev = side;
     for (i = 0;  i < nrtfn; i++) {
       if(!gactive[i]) continue;
-      if (ABS(grout[i]) == ZERO) {
-        if(rootdir[i]*glo[i] <= ZERO) {
-          zroot = TRUE;
-        }
+      if (SUNRabs(grout[i]) == ZERO) {
+        if(rootdir[i]*glo[i] <= ZERO) zroot = TRUE;
       } else {
         if ( (glo[i]*grout[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-          gfrac = ABS(grout[i]/(grout[i] - glo[i]));
+          gfrac = SUNRabs(grout[i]/(grout[i] - glo[i]));
           if (gfrac > maxfrac) {
             sgnchg = TRUE;
             maxfrac = gfrac;
@@ -8389,7 +8378,7 @@ static int cvRootFind(CVodeMem cv_mem)
       for (i = 0; i < nrtfn; i++) ghi[i] = grout[i];
       side = 1;
       /* Stop at root thi if converged; otherwise loop. */
-      if (ABS(thi - tlo) <= ttol) break;
+      if (SUNRabs(thi - tlo) <= ttol) break;
       continue;  /* Return to looping point. */
     }
 
@@ -8406,7 +8395,7 @@ static int cvRootFind(CVodeMem cv_mem)
     for (i = 0; i < nrtfn; i++) glo[i] = grout[i];
     side = 2;
     /* Stop at root thi if converged; otherwise loop back. */
-    if (ABS(thi - tlo) <= ttol) break;
+    if (SUNRabs(thi - tlo) <= ttol) break;
 
   } /* End of root-search loop */
 
@@ -8416,7 +8405,7 @@ static int cvRootFind(CVodeMem cv_mem)
     grout[i] = ghi[i];
     iroots[i] = 0;
     if(!gactive[i]) continue;
-    if ( (ABS(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
+    if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
       iroots[i] = glo[i] > 0 ? -1:1;
     if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
       iroots[i] = glo[i] > 0 ? -1:1;
@@ -8672,7 +8661,7 @@ int cvSensRhs1InternalDQ(int Ns, realtype t,
   /* cvode_mem is passed here as user data */
   cv_mem = (CVodeMem) cvode_mem;
 
-  delta = RSqrt(MAX(reltol, uround));
+  delta = SUNRsqrt(SUNMAX(reltol, uround));
   rdelta = ONE/delta;
   
   pbari = pbar[is];
@@ -8684,7 +8673,7 @@ int cvSensRhs1InternalDQ(int Ns, realtype t,
   Deltap  = pbari * delta;
   rDeltap = ONE/Deltap;
   norms   = N_VWrmsNorm(yS, ewt) * pbari;
-  rDeltay = MAX(norms, rdelta) / pbari;
+  rDeltay = SUNMAX(norms, rdelta) / pbari;
   Deltay  = ONE/rDeltay;
   
   if (DQrhomax == ZERO) {
@@ -8693,7 +8682,7 @@ int cvSensRhs1InternalDQ(int Ns, realtype t,
   } else {
     /* switch between simultaneous/separate DQ */
     ratio = Deltay * rDeltap;
-    if ( MAX(ONE/ratio, ratio) <= DQrhomax ) 
+    if ( SUNMAX(ONE/ratio, ratio) <= DQrhomax )
       method = (DQtype==CV_CENTERED) ? CENTERED1 : FORWARD1;
     else
       method = (DQtype==CV_CENTERED) ? CENTERED2 : FORWARD2;
@@ -8703,7 +8692,7 @@ int cvSensRhs1InternalDQ(int Ns, realtype t,
     
   case CENTERED1:
     
-    Delta = MIN(Deltay, Deltap);
+    Delta = SUNMIN(Deltay, Deltap);
     r2Delta = HALF/Delta;
     
     N_VLinearSum(ONE,y,Delta,yS,ytemp);
@@ -8761,7 +8750,7 @@ int cvSensRhs1InternalDQ(int Ns, realtype t,
     
   case FORWARD1:
     
-    Delta = MIN(Deltay, Deltap);
+    Delta = SUNMIN(Deltay, Deltap);
     rDelta = ONE/Delta;
     
     N_VLinearSum(ONE,y,Delta,yS,ytemp);
@@ -8847,12 +8836,12 @@ static int cvQuadSensRhs1InternalDQ(CVodeMem cv_mem, int is, realtype t,
   int nfel = 0, which;
   realtype psave, pbari;
   realtype delta , rdelta;
-  realtype Deltap, rDeltap;
+  realtype Deltap;
   realtype Deltay, rDeltay;
   realtype Delta , rDelta , r2Delta ;
   realtype norms;
 
-  delta = RSqrt(MAX(reltol, uround));
+  delta = SUNRsqrt(SUNMAX(reltol, uround));
   rdelta = ONE/delta;
   
   pbari = pbar[is];
@@ -8862,9 +8851,8 @@ static int cvQuadSensRhs1InternalDQ(CVodeMem cv_mem, int is, realtype t,
   psave = p[which];
   
   Deltap  = pbari * delta;
-  rDeltap = ONE/Deltap;
   norms   = N_VWrmsNorm(yS, ewt) * pbari;
-  rDeltay = MAX(norms, rdelta) / pbari;
+  rDeltay = SUNMAX(norms, rdelta) / pbari;
   Deltay  = ONE/rDeltay;
   
   method = (DQtype==CV_CENTERED) ? CENTERED1 : FORWARD1;
@@ -8873,7 +8861,7 @@ static int cvQuadSensRhs1InternalDQ(CVodeMem cv_mem, int is, realtype t,
 
   case CENTERED1:
     
-    Delta = MIN(Deltay, Deltap);
+    Delta = SUNMIN(Deltay, Deltap);
     r2Delta = HALF/Delta;
     
     N_VLinearSum(ONE, y, Delta, yS, tmp);
@@ -8896,7 +8884,7 @@ static int cvQuadSensRhs1InternalDQ(CVodeMem cv_mem, int is, realtype t,
 
   case FORWARD1:
     
-    Delta = MIN(Deltay, Deltap);
+    Delta = SUNMIN(Deltay, Deltap);
     rDelta = ONE/Delta;
     
     N_VLinearSum(ONE, y, Delta, yS, tmp);
@@ -8928,11 +8916,11 @@ static int cvQuadSensRhs1InternalDQ(CVodeMem cv_mem, int is, realtype t,
  * -----------------------------------------------------------------
  */
 
-/* 
- * cvProcessError is a high level error handling function
- * - if cv_mem==NULL it prints the error message to stderr
- * - otherwise, it sets-up and calls the error hadling function 
- *   pointed to by cv_ehfun
+/*
+ * cvProcessError is a high level error handling function.
+ * - If cv_mem==NULL it prints the error message to stderr.
+ * - Otherwise, it sets up and calls the error handling function 
+ *   pointed to by cv_ehfun.
  */
 
 #define ehfun    (cv_mem->cv_ehfun)
@@ -8955,32 +8943,24 @@ void cvProcessError(CVodeMem cv_mem,
   vsprintf(msg, msgfmt, ap);
 
   if (cv_mem == NULL) {    /* We write to stderr */
-
 #ifndef NO_FPRINTF_OUTPUT
     fprintf(stderr, "\n[%s ERROR]  %s\n  ", module, fname);
-    fprintf(stderr, msg);
-    fprintf(stderr, "\n\n");
+    fprintf(stderr, "%s\n\n", msg);
 #endif
 
   } else {                 /* We can call ehfun */
-
-    /* Call ehfun */
-
     ehfun(error_code, module, fname, msg, eh_data);
-
   }
 
   /* Finalize argument processing */
-  
   va_end(ap);
 
   return;
-
 }
 
 /* 
  * cvErrHandler is the default error handling function.
- * It sends the error message to the stream pointed to by cv_errfp 
+ * It sends the error message to the stream pointed to by cv_errfp.
  */
 
 #define errfp    (cv_mem->cv_errfp)
diff --git a/src/cvodes/cvodes_band.c b/src/cvodes/cvodes_band.c
index 4a96404..ba46f4f 100644
--- a/src/cvodes/cvodes_band.c
+++ b/src/cvodes/cvodes_band.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.16 $
- * $Date: 2011/03/23 22:58:46 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSBAND linear solver.
  * -----------------------------------------------------------------
@@ -36,10 +41,10 @@ static int cvBandSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
                        N_Vector vtemp2, N_Vector vtemp3);
 static int cvBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                        N_Vector ycur, N_Vector fcur);
-static void cvBandFree(CVodeMem cv_mem);
+static int cvBandFree(CVodeMem cv_mem);
 
 /* CVSBAND lfreeB function */
-static void cvBandFreeB(CVodeBMem cvB_mem);
+static int cvBandFreeB(CVodeBMem cvB_mem);
 
 /* 
  * ================================================================
@@ -155,6 +160,8 @@ int CVBand(void *cvode_mem, long int N, long int mupper, long int mlower)
 
   last_flag = CVDLS_SUCCESS;
 
+  cvDlsInitializeCounters(cvdls_mem);  
+
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -172,7 +179,7 @@ int CVBand(void *cvode_mem, long int N, long int mupper, long int mlower)
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(N-1, mu + ml);
+  smu = SUNMIN(N-1, mu + ml);
 
   /* Allocate memory for M, savedJ, and pivot arrays */
   M = NULL;
@@ -221,9 +228,7 @@ static int cvBandInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
 
-  nje   = 0;
-  nfeDQ = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);  
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -264,7 +269,7 @@ static int cvBandSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
 
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
          ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
          (convfail == CV_FAIL_OTHER);
@@ -353,7 +358,7 @@ static int cvBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void cvBandFree(CVodeMem cv_mem)
+static int cvBandFree(CVodeMem cv_mem)
 {
   CVDlsMem cvdls_mem;
 
@@ -364,6 +369,8 @@ static void cvBandFree(CVodeMem cv_mem)
   DestroyArray(lpivots);
   free(cvdls_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
 
 /* 
@@ -450,12 +457,14 @@ int CVBandB(void *cvode_mem, int which,
  * solver for backward integration.
  */
 
-static void cvBandFreeB(CVodeBMem cvB_mem)
+static int cvBandFreeB(CVodeBMem cvB_mem)
 {
   CVDlsMemB cvdlsB_mem;
 
   cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
 
   free(cvdlsB_mem);
+
+  return(0);
 }
 
diff --git a/src/cvodes/cvodes_bandpre.c b/src/cvodes/cvodes_bandpre.c
index df311de..8b63137 100644
--- a/src/cvodes/cvodes_bandpre.c
+++ b/src/cvodes/cvodes_bandpre.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2010/12/01 22:30:43 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file contains implementations of the banded difference
  * quotient Jacobian-based preconditioner and solver routines for
@@ -47,7 +52,7 @@ static int cvBandPrecSolve(realtype t, N_Vector y, N_Vector fy,
 
 /* Prototype for cvBandPrecFree */
 
-static void cvBandPrecFree(CVodeMem cv_mem);
+static int cvBandPrecFree(CVodeMem cv_mem);
 
 /* Prototype for difference quotient Jacobian calculation routine */
 
@@ -113,8 +118,8 @@ int CVBandPrecInit(void *cvode_mem, long int N, long int mu, long int ml)
   /* Load pointers and bandwidths into pdata block. */
   pdata->cvode_mem = cvode_mem;
   pdata->N = N;
-  pdata->mu = mup = MIN(N-1, MAX(0,mu));
-  pdata->ml = mlp = MIN(N-1, MAX(0,ml));
+  pdata->mu = mup = SUNMIN(N-1, SUNMAX(0,mu));
+  pdata->ml = mlp = SUNMIN(N-1, SUNMAX(0,ml));
 
   /* Initialize nfeBP counter */
   pdata->nfeBP = 0;
@@ -130,7 +135,7 @@ int CVBandPrecInit(void *cvode_mem, long int N, long int mu, long int ml)
 
 
   /* Allocate memory for banded preconditioner. */
-  storagemu = MIN(N-1, mup+mlp);
+  storagemu = SUNMIN(N-1, mup+mlp);
   pdata->savedP = NULL;
   pdata->savedP = NewBandMat(N, mup, mlp, storagemu);
   if (pdata->savedP == NULL) {
@@ -151,7 +156,12 @@ int CVBandPrecInit(void *cvode_mem, long int N, long int mu, long int ml)
     return(CVSPILS_MEM_FAIL);
   }
 
-  /* Overwrite the P_data field in the SPILS memory */
+  /* make sure s_P_data is free from any previous allocations */
+  if (cvspils_mem->s_pfree != NULL) {
+    cvspils_mem->s_pfree(cv_mem);
+  }
+
+  /* Point to the new P_data field in the SPILS memory */
   cvspils_mem->s_P_data = pdata;
 
   /* Attach the pfree function */
@@ -192,7 +202,7 @@ int CVBandPrecGetWorkSpace(void *cvode_mem, long int *lenrwBP, long int *leniwBP
   N   = pdata->N;
   mu  = pdata->mu;
   ml  = pdata->ml;
-  smu = MIN( N-1, mu + ml);
+  smu = SUNMIN( N-1, mu + ml);
 
   *leniwBP = pdata->N;
   *lenrwBP = N * ( 2*ml + smu + mu + 2 );
@@ -382,15 +392,15 @@ static int cvBandPrecSolve(realtype t, N_Vector y, N_Vector fy,
 }
 
 
-static void cvBandPrecFree(CVodeMem cv_mem)
+static int cvBandPrecFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   CVBandPrecData pdata;
 
-  if (cv_mem->cv_lmem == NULL) return;
+  if (cv_mem->cv_lmem == NULL) return(0);
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
   
-  if (cvspils_mem->s_P_data == NULL) return;
+  if (cvspils_mem->s_P_data == NULL) return(0);
   pdata = (CVBandPrecData) cvspils_mem->s_P_data;
 
   DestroyMat(savedJ);
@@ -399,6 +409,8 @@ static void cvBandPrecFree(CVodeMem cv_mem)
 
   free(pdata);
   pdata = NULL;
+
+  return(0);
 }
 
 
@@ -444,20 +456,20 @@ static int cvBandPrecDQJac(CVBandPrecData pdata,
   N_VScale(ONE, y, ytemp);
 
   /* Set minimum increment based on uround and norm of f. */
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   fnorm = N_VWrmsNorm(fy, ewt);
   minInc = (fnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * N * fnorm) : ONE;
 
   /* Set bandwidth and number of column groups for band differencing. */
   width = ml + mu + 1;
-  ngroups = MIN(width, N);
+  ngroups = SUNMIN(width, N);
   
   for (group = 1; group <= ngroups; group++) {
     
     /* Increment all y_j in group. */
     for(j = group-1; j < N; j += width) {
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       ytemp_data[j] += inc;
     }
 
@@ -471,10 +483,10 @@ static int cvBandPrecDQJac(CVBandPrecData pdata,
     for (j = group-1; j < N; j += width) {
       ytemp_data[j] = y_data[j];
       col_j = BAND_COL(savedJ,j);
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mu);
-      i2 = MIN(j+ml, N-1);
+      i1 = SUNMAX(0, j-mu);
+      i2 = SUNMIN(j+ml, N-1);
       for (i=i1; i <= i2; i++)
         BAND_COL_ELEM(col_j,i,j) =
           inc_inv * (ftemp_data[i] - fy_data[i]);
diff --git a/src/cvodes/cvodes_bandpre_impl.h b/src/cvodes/cvodes_bandpre_impl.h
index b1f2302..dd752c2 100644
--- a/src/cvodes/cvodes_bandpre_impl.h
+++ b/src/cvodes/cvodes_bandpre_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2010/12/01 22:30:42 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the CVBANDPRE module.
  * -----------------------------------------------------------------
@@ -17,14 +22,14 @@
 #ifndef _CVSBANDPRE_IMPL_H
 #define _CVSBANDPRE_IMPL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <cvodes/cvodes_bandpre.h>
 #include <sundials/sundials_band.h>
 #include <sundials/sundials_direct.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /*
  * -----------------------------------------------------------------
  * Type: CVBandPrecData
diff --git a/src/cvodes/cvodes_bbdpre.c b/src/cvodes/cvodes_bbdpre.c
index 0c848fc..1d472ed 100644
--- a/src/cvodes/cvodes_bbdpre.c
+++ b/src/cvodes/cvodes_bbdpre.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.14 $
- * $Date: 2010/12/01 22:30:43 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file contains implementations of routines for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -46,7 +51,7 @@ static int cvBBDPrecSolve(realtype t, N_Vector y, N_Vector fy,
                           int lr, void *bbd_data, N_Vector tmp);
 
 /* Prototype for cvBBDPrecFree */
-static void cvBBDPrecFree(CVodeMem cv_mem);
+static int cvBBDPrecFree(CVodeMem cv_mem);
 
 /* Wrapper functions for adjoint code */
 static int cvGlocWrapper(long int NlocalB, realtype t, N_Vector yB, N_Vector gB, 
@@ -59,7 +64,7 @@ static int cvBBDDQJac(CVBBDPrecData pdata, realtype t,
                       N_Vector ytemp, N_Vector gtemp);
 
 /* Prototype for the pfree routine */
-static void CVBBDPrecFreeB(CVodeBMem cvB_mem);
+static int CVBBDPrecFreeB(CVodeBMem cvB_mem);
 
 /* 
  * ================================================================
@@ -123,10 +128,10 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   pdata->cvode_mem = cvode_mem;
   pdata->gloc = gloc;
   pdata->cfn = cfn;
-  pdata->mudq = MIN(Nlocal-1, MAX(0,mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0,mldq));
-  muk = MIN(Nlocal-1, MAX(0,mukeep));
-  mlk = MIN(Nlocal-1, MAX(0,mlkeep));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0,mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0,mldq));
+  muk = SUNMIN(Nlocal-1, SUNMAX(0,mukeep));
+  mlk = SUNMIN(Nlocal-1, SUNMAX(0,mlkeep));
   pdata->mukeep = muk;
   pdata->mlkeep = mlk;
 
@@ -139,7 +144,7 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   }
 
   /* Allocate memory for preconditioner matrix */
-  storage_mu = MIN(Nlocal-1, muk + mlk);
+  storage_mu = SUNMIN(Nlocal-1, muk + mlk);
   pdata->savedP = NULL;
   pdata->savedP = NewBandMat(Nlocal, muk, mlk, storage_mu);
   if (pdata->savedP == NULL) {
@@ -160,7 +165,7 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   }
 
   /* Set pdata->dqrely based on input dqrely (0 implies default). */
-  pdata->dqrely = (dqrely > ZERO) ? dqrely : RSqrt(uround);
+  pdata->dqrely = (dqrely > ZERO) ? dqrely : SUNRsqrt(uround);
 
   /* Store Nlocal to be used in CVBBDPrecSetup */
   pdata->n_local = Nlocal;
@@ -170,7 +175,12 @@ int CVBBDPrecInit(void *cvode_mem, long int Nlocal,
   pdata->ipwsize = Nlocal;
   pdata->nge = 0;
 
-  /* Overwrite the P_data field in the SPILS memory */
+  /* make sure s_P_data is free from any previous allocations */
+  if (cvspils_mem->s_pfree != NULL) {
+    cvspils_mem->s_pfree(cv_mem);
+  }
+
+  /* Point to the new P_data field in the SPILS memory */
   cvspils_mem->s_P_data = pdata;
 
   /* Attach the pfree function */
@@ -214,11 +224,11 @@ int CVBBDPrecReInit(void *cvode_mem,
 
   /* Load half-bandwidths */
   Nlocal = pdata->n_local;
-  pdata->mudq = MIN(Nlocal-1, MAX(0,mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0,mldq));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0,mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0,mldq));
 
   /* Set pdata->dqrely based on input dqrely (0 implies default). */
-  pdata->dqrely = (dqrely > ZERO) ? dqrely : RSqrt(uround);
+  pdata->dqrely = (dqrely > ZERO) ? dqrely : SUNRsqrt(uround);
 
   /* Re-initialize nge */
   pdata->nge = 0;
@@ -447,15 +457,15 @@ static int cvBBDPrecSolve(realtype t, N_Vector y, N_Vector fy,
 }
 
 
-static void cvBBDPrecFree(CVodeMem cv_mem)
+static int cvBBDPrecFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   CVBBDPrecData pdata;
   
-  if (cv_mem->cv_lmem == NULL) return;
+  if (cv_mem->cv_lmem == NULL) return(0);
   cvspils_mem = (CVSpilsMem) cv_mem->cv_lmem;
   
-  if (cvspils_mem->s_P_data == NULL) return;
+  if (cvspils_mem->s_P_data == NULL) return(0);
   pdata = (CVBBDPrecData) cvspils_mem->s_P_data;
 
   DestroyMat(savedJ);
@@ -464,6 +474,8 @@ static void cvBBDPrecFree(CVodeMem cv_mem)
 
   free(pdata);
   pdata = NULL;
+  
+  return(0);
 }
 
 
@@ -524,18 +536,18 @@ static int cvBBDDQJac(CVBBDPrecData pdata, realtype t,
   /* Set minimum increment based on uround and norm of g */
   gnorm = N_VWrmsNorm(gy, ewt);
   minInc = (gnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * Nlocal * gnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * Nlocal * gnorm) : ONE;
 
   /* Set bandwidth and number of column groups for band differencing */
   width = mldq + mudq + 1;
-  ngroups = MIN(width, Nlocal);
+  ngroups = SUNMIN(width, Nlocal);
 
   /* Loop over groups */  
   for (group=1; group <= ngroups; group++) {
     
     /* Increment all y_j in group */
     for(j=group-1; j < Nlocal; j+=width) {
-      inc = MAX(dqrely*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(dqrely*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       ytemp_data[j] += inc;
     }
 
@@ -548,10 +560,10 @@ static int cvBBDDQJac(CVBBDPrecData pdata, realtype t,
     for (j=group-1; j < Nlocal; j+=width) {
       ytemp_data[j] = y_data[j];
       col_j = BAND_COL(savedJ,j);
-      inc = MAX(dqrely*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(dqrely*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mukeep);
-      i2 = MIN(j+mlkeep, Nlocal-1);
+      i1 = SUNMAX(0, j-mukeep);
+      i2 = SUNMIN(j+mlkeep, Nlocal-1);
       for (i=i1; i <= i2; i++)
         BAND_COL_ELEM(col_j,i,j) =
           inc_inv * (gtemp_data[i] - gy_data[i]);
@@ -702,10 +714,11 @@ int CVBBDPrecReInitB(void *cvode_mem, int which,
 }
 
 
-static void CVBBDPrecFreeB(CVodeBMem cvB_mem)
+static int CVBBDPrecFreeB(CVodeBMem cvB_mem)
 {
   free(cvB_mem->cv_pmem); 
   cvB_mem->cv_pmem = NULL;
+  return(0);
 }
 
 
diff --git a/src/cvodes/cvodes_bbdpre_impl.h b/src/cvodes/cvodes_bbdpre_impl.h
index 7ea5695..67327e9 100644
--- a/src/cvodes/cvodes_bbdpre_impl.h
+++ b/src/cvodes/cvodes_bbdpre_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:30:42 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the CVBBDPRE module.
  * -----------------------------------------------------------------
@@ -17,13 +22,13 @@
 #ifndef _CVSBBDPRE_IMPL_H
 #define _CVSBBDPRE_IMPL_H
 
+#include <cvodes/cvodes_bbdpre.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_bbdpre.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Type: CVBBDPrecData
diff --git a/src/cvodes/cvodes_dense.c b/src/cvodes/cvodes_dense.c
index 6a1f733..beb64cb 100644
--- a/src/cvodes/cvodes_dense.c
+++ b/src/cvodes/cvodes_dense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.15 $
- * $Date: 2010/12/01 22:30:43 $
+ * $Revision: 4951 $
+ * $Date: 2016-09-22 10:21:00 -0700 (Thu, 22 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSDENSE linear solver.
  * -----------------------------------------------------------------
@@ -36,10 +41,10 @@ static int cvDenseSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
                         N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
 static int cvDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                         N_Vector ycur, N_Vector fcur);
-static void cvDenseFree(CVodeMem cv_mem);
+static int cvDenseFree(CVodeMem cv_mem);
 
 /* CVSDENSE lfreeB function */
-static void cvDenseFreeB(CVodeBMem cvb_mem);
+static int cvDenseFreeB(CVodeBMem cvb_mem);
 
 /* 
  * ================================================================
@@ -151,6 +156,8 @@ int CVDense(void *cvode_mem, long int N)
 
   last_flag = CVDLS_SUCCESS;
 
+  cvDlsInitializeCounters(cvdls_mem);  
+
   setupNonNull = TRUE;
 
   /* Set problem dimension */
@@ -204,9 +211,13 @@ static int cvDenseInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
   
-  nje   = 0;
-  nfeDQ = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);  
+
+  /*
+   nje   = 0;
+   nfeDQ = 0;
+   nstlj = 0;
+  */
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -247,7 +258,7 @@ static int cvDenseSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
  
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
  
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
          ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
          (convfail == CV_FAIL_OTHER);
@@ -333,7 +344,7 @@ static int cvDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void cvDenseFree(CVodeMem cv_mem)
+static int cvDenseFree(CVodeMem cv_mem)
 {
   CVDlsMem  cvdls_mem;
 
@@ -344,6 +355,8 @@ static void cvDenseFree(CVodeMem cv_mem)
   DestroyArray(lpivots);
   free(cvdls_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
 
 /* 
@@ -355,7 +368,7 @@ static void cvDenseFree(CVodeMem cv_mem)
  */
 
 /*
- * CVDenseB is a wraper around CVDense. It attaches the CVSDENSE linear solver
+ * CVDenseB is a wrapper around CVDense. It attaches the CVSDENSE linear solver
  * to the backward problem memory block.
  */
 
@@ -429,12 +442,14 @@ int CVDenseB(void *cvode_mem, int which, long int nB)
  * solver for backward integration.
  */
 
-static void cvDenseFreeB(CVodeBMem cvB_mem)
+static int cvDenseFreeB(CVodeBMem cvB_mem)
 {
   CVDlsMemB cvdlsB_mem;
 
   cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
 
   free(cvdlsB_mem);
+
+  return(0);
 }
 
diff --git a/src/cvodes/cvodes_diag.c b/src/cvodes/cvodes_diag.c
index 88ccd31..e04b173 100644
--- a/src/cvodes/cvodes_diag.c
+++ b/src/cvodes/cvodes_diag.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:30:43 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVDIAG linear solver.
  * -----------------------------------------------------------------
@@ -36,7 +41,7 @@ static int CVDiagSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                        N_Vector ycur, N_Vector fcur);
 
-static void CVDiagFree(CVodeMem cv_mem);
+static int CVDiagFree(CVodeMem cv_mem);
 
 
 /* 
@@ -434,7 +439,7 @@ static int CVDiagSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVDiagFree(CVodeMem cv_mem)
+static int CVDiagFree(CVodeMem cv_mem)
 {
   CVDiagMem cvdiag_mem;
   
@@ -445,6 +450,8 @@ static void CVDiagFree(CVodeMem cv_mem)
   N_VDestroy(bitcomp);
   free(cvdiag_mem);
   cv_mem->cv_lmem = NULL;
+  
+  return(0);
 }
 
 
diff --git a/src/cvodes/cvodes_diag_impl.h b/src/cvodes/cvodes_diag_impl.h
index f500187..bd84ab4 100644
--- a/src/cvodes/cvodes_diag_impl.h
+++ b/src/cvodes/cvodes_diag_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:30:42 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the diagonal linear solver, CVDIAG.
  * -----------------------------------------------------------------
@@ -17,12 +22,12 @@
 #ifndef _CVSDIAG_IMPL_H
 #define _CVSDIAG_IMPL_H
 
+#include <cvodes/cvodes_diag.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_diag.h>
-
 /*
  * -----------------------------------------------------------------
  * Types: CVDiagMemRec, CVDiagMem
diff --git a/src/cvodes/cvodes_direct.c b/src/cvodes/cvodes_direct.c
index 04430a0..8575679 100644
--- a/src/cvodes/cvodes_direct.c
+++ b/src/cvodes/cvodes_direct.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2010/12/01 22:30:43 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSDLS linear solvers
  * -----------------------------------------------------------------
@@ -51,11 +56,21 @@ static int cvDlsDenseJacBWrapper(long int nB, realtype t,
                                  DlsMat JB, void *cvode_mem,
                                  N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
 
+static int cvDlsDenseJacBSWrapper(long int nB, realtype t,
+                                 N_Vector yB, N_Vector fyB, 
+                                 DlsMat JB, void *cvode_mem,
+                                 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
 static int cvDlsBandJacBWrapper(long int nB, long int mupperB, long int mlowerB, 
                                 realtype t, N_Vector yB, N_Vector fyB, 
                                 DlsMat Jac, void *cvode_mem, 
                                 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
 
+static int cvDlsBandJacBSWrapper(long int nB, long int mupperB, long int mlowerB, 
+                                realtype t, N_Vector yB, N_Vector fyB, 
+                                DlsMat Jac, void *cvode_mem, 
+                                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
 
 /*
  * =================================================================
@@ -362,10 +377,10 @@ int cvDlsDenseDQJac(long int N, realtype t,
   y_data   = N_VGetArrayPointer(y);
 
   /* Set minimum increment based on uround and norm of f */
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   fnorm = N_VWrmsNorm(fy, ewt);
   minInc = (fnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * N * fnorm) : ONE;
 
   for (j = 0; j < N; j++) {
 
@@ -374,7 +389,7 @@ int cvDlsDenseDQJac(long int N, realtype t,
     N_VSetArrayPointer(DENSE_COL(Jac,j), jthCol);
 
     yjsaved = y_data[j];
-    inc = MAX(srur*ABS(yjsaved), minInc/ewt_data[j]);
+    inc = SUNMAX(srur*SUNRabs(yjsaved), minInc/ewt_data[j]);
     y_data[j] += inc;
 
     retval = f(t, y, ftemp, user_data);
@@ -441,21 +456,21 @@ int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
   N_VScale(ONE, y, ytemp);
 
   /* Set minimum increment based on uround and norm of f */
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   fnorm = N_VWrmsNorm(fy, ewt);
   minInc = (fnorm != ZERO) ?
-           (MIN_INC_MULT * ABS(h) * uround * N * fnorm) : ONE;
+           (MIN_INC_MULT * SUNRabs(h) * uround * N * fnorm) : ONE;
 
   /* Set bandwidth and number of column groups for band differencing */
   width = mlower + mupper + 1;
-  ngroups = MIN(width, N);
+  ngroups = SUNMIN(width, N);
 
   /* Loop over column groups. */
   for (group=1; group <= ngroups; group++) {
     
     /* Increment all y_j in group */
     for(j=group-1; j < N; j+=width) {
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       ytemp_data[j] += inc;
     }
 
@@ -469,10 +484,10 @@ int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
     for (j=group-1; j < N; j+=width) {
       ytemp_data[j] = y_data[j];
       col_j = BAND_COL(Jac,j);
-      inc = MAX(srur*ABS(y_data[j]), minInc/ewt_data[j]);
+      inc = SUNMAX(srur*SUNRabs(y_data[j]), minInc/ewt_data[j]);
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mupper);
-      i2 = MIN(j+mlower, N-1);
+      i1 = SUNMAX(0, j-mupper);
+      i2 = SUNMIN(j+mlower, N-1);
       for (i=i1; i <= i2; i++)
         BAND_COL_ELEM(col_j,i,j) = inc_inv * (ftemp_data[i] - fy_data[i]);
     }
@@ -481,6 +496,17 @@ int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
   return(retval);
 }
 
+
+int cvDlsInitializeCounters(CVDlsMem cvdls_mem)
+{
+  cvdls_mem->d_nje   = 0;
+  cvdls_mem->d_nfeDQ = 0;
+  cvdls_mem->d_nstlj = 0;
+  
+  return(0);
+}
+
+
 /* 
  * =================================================================
  * BACKWARD INTEGRATION SUPPORT
@@ -496,10 +522,13 @@ int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
 #define ytmp  (ca_mem->ca_ytmp)
 #define yStmp (ca_mem->ca_yStmp)
 #define IMget (ca_mem->ca_IMget)
+#define IMinterpSensi (ca_mem->ca_IMinterpSensi)
 
 #define mtypeB     (cvdlsB_mem->d_typeB)
 #define djacB      (cvdlsB_mem->d_djacB)
+#define djacBS     (cvdlsB_mem->d_djacBS)
 #define bjacB      (cvdlsB_mem->d_bjacB)
+#define bjacBS     (cvdlsB_mem->d_bjacBS)
 
 /*
  * -----------------------------------------------------------------
@@ -562,6 +591,61 @@ int CVDlsSetDenseJacFnB(void *cvode_mem, int which, CVDlsDenseJacFnB jacB)
   return(flag);
 }
 
+int CVDlsSetDenseJacFnBS(void *cvode_mem, int which, CVDlsDenseJacFnBS jacBS)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVDlsMemB cvdlsB_mem;
+  void *cvodeB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVSDLS", "CVDlsSetDenseJacFnBS", MSGD_CVMEM_NULL);
+    return(CVDLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVDLS_NO_ADJ, "CVSDLS", "CVDlsSetDenseJacFnBS", MSGD_NO_ADJ);
+    return(CVDLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVSDLS", "CVDlsSetDenseJacFnBS", MSGD_BAD_WHICH);
+    return(CVDLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  if (cvB_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVDLS_LMEMB_NULL, "CVSDLS", "CVDlsSetDenseJacFnBS", MSGD_LMEMB_NULL);
+    return(CVDLS_LMEMB_NULL);
+  }
+  cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
+
+  djacBS = jacBS;
+
+  if (jacBS != NULL) {
+    flag = CVDlsSetDenseJacFn(cvodeB_mem, cvDlsDenseJacBSWrapper);
+  } else {
+    flag = CVDlsSetDenseJacFn(cvodeB_mem, NULL);
+  }
+
+  return(flag);
+}
+
 int CVDlsSetBandJacFnB(void *cvode_mem, int which, CVDlsBandJacFnB jacB)
 {
   CVodeMem cv_mem;
@@ -617,6 +701,61 @@ int CVDlsSetBandJacFnB(void *cvode_mem, int which, CVDlsBandJacFnB jacB)
   return(flag);
 }
 
+int CVDlsSetBandJacFnBS(void *cvode_mem, int which, CVDlsBandJacFnBS jacBS)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVDlsMemB cvdlsB_mem;
+  void *cvodeB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVDLS_MEM_NULL, "CVSDLS", "CVDlsSetBandJacFnBS", MSGD_CVMEM_NULL);
+    return(CVDLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVDLS_NO_ADJ, "CVSDLS", "CVDlsSetBandJacFnBS", MSGD_NO_ADJ);
+    return(CVDLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVDLS_ILL_INPUT, "CVSDLS", "CVDlsSetBandJacFnBS", MSGD_BAD_WHICH);
+    return(CVDLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  if (cvB_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVDLS_LMEMB_NULL, "CVSDLS", "CVDlsSetBandJacFnBS", MSGD_LMEMB_NULL);
+    return(CVDLS_LMEMB_NULL);
+  }
+  cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
+
+  bjacBS = jacBS;
+
+  if (jacBS != NULL) {
+    flag = CVDlsSetBandJacFn(cvodeB_mem, cvDlsBandJacBSWrapper);
+  } else {
+    flag = CVDlsSetBandJacFn(cvodeB_mem, NULL);
+  }
+
+  return(flag);
+}
+
 
 /*
  * -----------------------------------------------------------------
@@ -632,7 +771,6 @@ int CVDlsSetBandJacFnB(void *cvode_mem, int which, CVDlsBandJacFnB jacB)
  * NOTE: data here contains cvode_mem
  */
 
-
 static int cvDlsDenseJacBWrapper(long int nB, realtype t,
                                  N_Vector yB, N_Vector fyB, 
                                  DlsMat JB, void *cvode_mem,
@@ -664,7 +802,50 @@ static int cvDlsDenseJacBWrapper(long int nB, realtype t,
                  tmp1B, tmp2B, tmp3B);
 
   return(retval);
+}
+
+/*
+ * cvDlsDenseJacBSWrapper
+ *
+ * This routine interfaces to the CVDlsDenseJacFnBS routine provided 
+ * by the user. cvDlsDenseJacBSWrapper is of type CVDlsDenseJacFn.
+ * NOTE: data here contains cvode_mem
+ */
+
+static int cvDlsDenseJacBSWrapper(long int nB, realtype t,
+                                 N_Vector yB, N_Vector fyB, 
+                                 DlsMat JB, void *cvode_mem,
+                                 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVDlsMemB cvdlsB_mem;
+  int retval, flag;
+
+  cv_mem = (CVodeMem) cvode_mem;
+
+  ca_mem = cv_mem->cv_adj_mem;
 
+  cvB_mem = ca_mem->ca_bckpbCrt;
+
+  cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
+
+  /* Forward solution from interpolation */
+  if (IMinterpSensi)
+    flag = IMget(cv_mem, t, ytmp, yStmp);
+  else 
+    flag = IMget(cv_mem, t, ytmp, NULL);
+  if (flag != CV_SUCCESS) {
+    cvProcessError(cv_mem, -1, "CVSDLS", "cvDlsDenseJacBSWrapper", MSGD_BAD_TINTERP);
+    return(-1);
+  }
+
+  /* Call user's adjoint dense djacBS routine (of type CVDlsDenseJacFnBS) */
+  retval = djacBS(nB, t, ytmp, yStmp, yB, fyB, JB, cvB_mem->cv_user_data, 
+                  tmp1B, tmp2B, tmp3B);
+
+  return(retval);
 }
 
 
@@ -709,3 +890,47 @@ static int cvDlsBandJacBWrapper(long int nB, long int mupperB, long int mlowerB,
   return(retval);
 }
 
+/*
+ * cvDlsBandJacBSWrapper
+ *
+ * This routine interfaces to the CVBandJacFnBS routine provided 
+ * by the user. cvDlsBandJacBSWrapper is of type CVDlsBandJacFn.
+ * NOTE: data here contains cvode_mem
+ */
+
+static int cvDlsBandJacBSWrapper(long int nB, long int mupperB, long int mlowerB, 
+                                realtype t, N_Vector yB, N_Vector fyB, 
+                                DlsMat JB, void *cvode_mem, 
+                                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVDlsMemB cvdlsB_mem;
+  int retval, flag;
+
+  cv_mem = (CVodeMem) cvode_mem;
+
+  ca_mem = cv_mem->cv_adj_mem;
+
+  cvB_mem = ca_mem->ca_bckpbCrt;
+
+  cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
+
+  /* Forward solution from interpolation */
+  if (IMinterpSensi)
+    flag = IMget(cv_mem, t, ytmp, yStmp);
+  else 
+    flag = IMget(cv_mem, t, ytmp, NULL);
+  if (flag != CV_SUCCESS) {
+    cvProcessError(cv_mem, -1, "CVSDLS", "cvDlsBandJacBSWrapper", MSGD_BAD_TINTERP);
+    return(-1);
+  }
+
+  /* Call user's adjoint band bjacBS routine (of type CVDlsBandJacFnBS) */
+  retval = bjacBS(nB, mupperB, mlowerB, t, ytmp, yStmp, yB, fyB, JB,
+                  cvB_mem->cv_user_data, tmp1B, tmp2B, tmp3B);
+
+  return(retval);
+}
+
diff --git a/src/cvodes/cvodes_direct_impl.h b/src/cvodes/cvodes_direct_impl.h
index ce803b6..2fa8a7d 100644
--- a/src/cvodes/cvodes_direct_impl.h
+++ b/src/cvodes/cvodes_direct_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:30:42 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common implementation header file for the CVDLS linear solvers.
  * -----------------------------------------------------------------
@@ -17,12 +22,12 @@
 #ifndef _CVSDLS_IMPL_H
 #define _CVSDLS_IMPL_H
 
+#include <cvodes/cvodes_direct.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_direct.h>
-
 /*
  * =================================================================
  * C V S D I R E C T    I N T E R N A L    C O N S T A N T S
@@ -93,14 +98,17 @@ typedef struct CVDlsMemRec {
  */
 
 int cvDlsDenseDQJac(long int N, realtype t,
-		    N_Vector y, N_Vector fy, 
-		    DlsMat Jac, void *data,
-		    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                    N_Vector y, N_Vector fy, 
+                    DlsMat Jac, void *data,
+                    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
   
 int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
-		   realtype t, N_Vector y, N_Vector fy, 
-		   DlsMat Jac, void *data,
-		   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                   realtype t, N_Vector y, N_Vector fy, 
+                   DlsMat Jac, void *data,
+                   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Auxilliary functions */
+int cvDlsInitializeCounters(CVDlsMem cvdls_mem);
 
 
 /*
@@ -123,7 +131,9 @@ typedef struct CVDlsMemRecB {
   int d_typeB;
 
   CVDlsDenseJacFnB d_djacB;
+  CVDlsDenseJacFnBS d_djacBS;
   CVDlsBandJacFnB d_bjacB;
+  CVDlsBandJacFnBS d_bjacBS;
 
 } *CVDlsMemB;
 
diff --git a/src/cvodes/cvodes_impl.h b/src/cvodes/cvodes_impl.h
index 8683633..41409b0 100644
--- a/src/cvodes/cvodes_impl.h
+++ b/src/cvodes/cvodes_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.21 $
- * $Date: 2007/11/26 16:19:59 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the main CVODES integrator.
  * -----------------------------------------------------------------
@@ -17,16 +22,16 @@
 #ifndef _CVODES_IMPL_H
 #define _CVODES_IMPL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <stdarg.h>
 
 #include <cvodes/cvodes.h>
 #include <sundials/sundials_nvector.h>
 #include <sundials/sundials_types.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* 
  * =================================================================
  *   I N T E R N A L   C V O D E S   C O N S T A N T S
@@ -350,7 +355,7 @@ typedef struct CVodeMemRec {
   int (*cv_lsolve)(struct CVodeMemRec *cv_mem, N_Vector b, N_Vector weight,
 		   N_Vector ycur, N_Vector fcur);
 
-  void (*cv_lfree)(struct CVodeMemRec *cv_mem);
+  int (*cv_lfree)(struct CVodeMemRec *cv_mem);
 
   /* Linear Solver specific memory */
 
@@ -591,7 +596,7 @@ struct CVodeBMemRec {
   /* Index of this backward problem */
   int cv_index;
 
-  /* Time at which the backward problem is intialized */
+  /* Time at which the backward problem is initialized */
   realtype cv_t0;
   
   /* CVODES memory for this backward problem */
@@ -617,13 +622,13 @@ struct CVodeBMemRec {
   void *cv_lmem;
 
   /* Function to free any memory allocated by the linear solver */
-  void (*cv_lfree)(CVodeBMem cvB_mem);
+  int (*cv_lfree)(CVodeBMem cvB_mem);
 
   /* Memory block for a preconditioner's module interface to CVODEA */ 
   void *cv_pmem;
 
   /* Function to free any memory allocated by the preconditioner module */
-  void (*cv_pfree)(CVodeBMem cvB_mem);
+  int (*cv_pfree)(CVodeBMem cvB_mem);
 
   /* Time at which to extract solution / quadratures */
   realtype cv_tout;
@@ -858,11 +863,12 @@ struct CVadjMemRec {
 
 /*
  * -----------------------------------------------------------------
- * void (*cv_lfree)(CVodeMem cv_mem);
+ * int (*cv_lfree)(CVodeMem cv_mem);
  * -----------------------------------------------------------------
  * cv_lfree should free up any memory allocated by the linear
  * solver. This routine is called once a problem has been
- * completed and the linear solver is no longer needed.
+ * completed and the linear solver is no longer needed.  It should 
+ * return 0 upon success, nonzero on failure.
  * -----------------------------------------------------------------
  */
 
diff --git a/src/cvodes/cvodes_io.c b/src/cvodes/cvodes_io.c
index 0ebd0e7..8468429 100644
--- a/src/cvodes/cvodes_io.c
+++ b/src/cvodes/cvodes_io.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.19 $
- * $Date: 2010/12/01 22:30:43 $
+ * $Revision: 4272 $
+ * $Date: 2014-12-02 11:19:41 -0800 (Tue, 02 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the optional input and output
  * functions for the CVODES solver.
@@ -152,8 +157,8 @@ int CVodeSetMaxOrd(void *cvode_mem, int maxord)
   /* Cannot increase maximum order beyond the value that
      was used when allocating memory */
   qmax_alloc = cv_mem->cv_qmax_alloc;
-  qmax_alloc = MIN(qmax_alloc, cv_mem->cv_qmax_allocQ);
-  qmax_alloc = MIN(qmax_alloc, cv_mem->cv_qmax_allocS);  
+  qmax_alloc = SUNMIN(qmax_alloc, cv_mem->cv_qmax_allocQ);
+  qmax_alloc = SUNMIN(qmax_alloc, cv_mem->cv_qmax_allocS);
 
   if (maxord > qmax_alloc) {
     cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVodeSetMaxOrd", MSGCV_BAD_MAXORD);
@@ -363,7 +368,7 @@ int CVodeSetStopTime(void *cvode_mem, realtype tstop)
   if (cv_mem->cv_nst > 0) {
 
     if ( (tstop - cv_mem->cv_tn) * cv_mem->cv_h < ZERO ) {
-      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVodeSetStopTime", MSGCV_BAD_TSTOP, cv_mem->cv_tn);
+      cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVodeSetStopTime", MSGCV_BAD_TSTOP, tstop, cv_mem->cv_tn);
       return(CV_ILL_INPUT);
     }
 
@@ -645,7 +650,7 @@ int CVodeSetSensParams(void *cvode_mem, realtype *p, realtype *pbar, int *plist)
         cvProcessError(cv_mem, CV_ILL_INPUT, "CVODES", "CVodeSetSensParams", MSGCV_BAD_PBAR);
         return(CV_ILL_INPUT);
       }
-      cv_mem->cv_pbar[is] = ABS(pbar[is]);
+      cv_mem->cv_pbar[is] = SUNRabs(pbar[is]);
     }
   else
     for (is=0; is<Ns; is++)
diff --git a/src/cvodes/cvodes_klu.c b/src/cvodes/cvodes_klu.c
new file mode 100644
index 0000000..575cd82
--- /dev/null
+++ b/src/cvodes/cvodes_klu.c
@@ -0,0 +1,818 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4951 $
+ * $Date: 2016-09-22 10:21:00 -0700 (Thu, 22 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the CVKLU linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cvodes/cvodes_klu.h"
+#include "cvodes_impl.h"
+#include "cvodes_sparse_impl.h"
+#include "sundials/sundials_klu_impl.h"
+#include "sundials/sundials_math.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+#define TWOTHIRDS    RCONST(0.6666666666666667)
+
+/* CVKLU linit, lsetup, lsolve, and lfree routines */
+ 
+static int cvKLUInit(CVodeMem cv_mem);
+
+static int cvKLUSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+		      N_Vector fpred, booleantype *jcurPtr,
+		      N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int cvKLUSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+		      N_Vector ycur, N_Vector fcur);
+
+static int cvKLUFree(CVodeMem cv_mem);
+
+/* CVKLU lfreeB function */
+static int cvKLUFreeB(CVodeBMem cvb_mem);
+
+/* 
+ * ================================================================
+ *
+ *                   PART I - forward problems
+ *
+ * ================================================================
+ */
+
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLU
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the CVODE / KLU linear solver module.  
+ * CVKLU first calls the existing lfree routine if this is not NULL.
+ * Then it sets the cv_linit, cv_lsetup, cv_lsolve, cv_lperf, and
+ * cv_lfree fields in (*cv_mem) to be CVKLUInit, CVKLUSetup,
+ * CVKLUSolve, NULL, and CVKLUFree, respectively.
+ * It allocates memory for a structure of type CVkluMemRec and sets
+ * the cv_lmem field in (*cvode_mem) to the address of this structure.
+ * It sets setupNonNull in (*cvode_mem) to TRUE.
+ * Finally, it allocates memory for KLU.
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_LMEM_FAIL = -1,
+ * or CVSLS_ILL_INPUT = -2.
+ *
+ * NOTE: The KLU linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, CVKLU will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int CVKLU(void *cvode_mem, int n, int nnz, int sparsetype)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+  int flag;
+
+  /* Return immediately if cv_mem is NULL. */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "cvKLU", 
+                   MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (cv_mem->cv_tempv->ops->nvgetarraypointer == NULL) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSLS", "cvKLU", 
+                   MSGSP_BAD_NVECTOR);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  if (cv_mem->cv_lfree != NULL) cv_mem->cv_lfree(cv_mem);
+
+  /* Set five main function fields in cv_mem. */
+  cv_mem->cv_linit  = cvKLUInit;
+  cv_mem->cv_lsetup = cvKLUSetup;
+  cv_mem->cv_lsolve = cvKLUSolve;
+  cv_mem->cv_lfree  = cvKLUFree;
+
+  /* Get memory for CVSlsMemRec. */
+  cvsls_mem = (CVSlsMem) malloc(sizeof(struct CVSlsMemRec));
+  if (cvsls_mem == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Get memory for KLUData. */
+  klu_data = (KLUData)malloc(sizeof(struct KLUDataRec));
+  if (klu_data == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  cv_mem->cv_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  cvsls_mem->s_jaceval = NULL;
+  cvsls_mem->s_jacdata = NULL;
+  cvsls_mem->sparsetype = sparsetype;
+
+  /* Allocate memory for the sparse Jacobian */
+  cvsls_mem->s_JacMat = SparseNewMat(n, n, nnz, sparsetype);
+  if (cvsls_mem->s_JacMat == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Allocate memory for saved sparse Jacobian */
+  cvsls_mem->s_savedJ = SparseNewMat(n, n, nnz, sparsetype);
+  if (cvsls_mem->s_savedJ == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_MEM_FAIL);
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Initialize KLU structures */
+  switch (sparsetype) {
+    case CSC_MAT:
+      klu_data->sun_klu_solve = &klu_solve;
+      break;
+    case CSR_MAT:
+      klu_data->sun_klu_solve = &klu_tsolve;
+      break;
+    default:
+      SparseDestroyMat(cvsls_mem->s_JacMat);
+      SparseDestroyMat(cvsls_mem->s_savedJ);
+      free(klu_data);
+      free(cvsls_mem);
+      return(CVSLS_ILL_INPUT);
+  }
+  klu_data->s_Symbolic = NULL;
+  klu_data->s_Numeric = NULL;
+
+  /* Set default parameters for KLU */
+  flag = klu_defaults(&klu_data->s_Common);
+  if (flag == 0) {
+    cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "cvKLU", 
+                   MSGSP_PACKAGE_FAIL);
+    return(CVSLS_PACKAGE_FAIL);
+  }
+
+  /* Set ordering to COLAMD as the cvode default use.
+     Users can set a different value with CVKLUSetOrdering,
+     and the user-set value is loaded before any call to klu_analyze in
+     CVKLUSetup.  */
+  klu_data->s_ordering = 1;
+  klu_data->s_Common.ordering = klu_data->s_ordering;
+
+  /* Attach linear solver memory to the integrator memory */
+  cvsls_mem->s_solver_data = (void *) klu_data;
+  cv_mem->cv_lmem = cvsls_mem;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to CVKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_MEM_NULL = -1,
+ * CVSLS_LMEM_NULL = -2, CVSLS_ILL_INPUT = -3, or CVSLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+int CVKLUReInit(void *cvode_mem, int n, int nnz, int reinit_type)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if cv_mem is NULL. */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVKLUReInit", 
+                   MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Return immediately if cv_lmem is NULL. */
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(NULL, CVSLS_LMEM_NULL, "CVSLS", "CVKLUReInit", 
+                   MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) (cv_mem->cv_lmem);
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  /* Return if reinit_type is not valid */
+  if ((reinit_type != 1) && (reinit_type != 2)) {
+    cvProcessError(NULL, CVSLS_ILL_INPUT, "CVSLS", "CVKLUReInit", 
+                   MSGSP_ILL_INPUT);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  if (reinit_type == 1) {
+
+    /* Destroy previous Jacobian information */
+    if (cvsls_mem->s_JacMat) {
+      SparseDestroyMat(cvsls_mem->s_JacMat);
+    }
+
+    /* Allocate memory for the sparse Jacobian */
+    cvsls_mem->s_JacMat = SparseNewMat(n, n, nnz, cvsls_mem->sparsetype);
+    if (cvsls_mem->s_JacMat == NULL) {
+      cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "CVKLU", 
+                     MSGSP_MEM_FAIL);
+      return(CVSLS_MEM_FAIL);
+    }
+  }
+
+  /* Free the prior factorazation and reset for first factorization */
+  if( klu_data->s_Symbolic != NULL)
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  if( klu_data->s_Numeric != NULL)
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  cvsls_mem->s_first_factorize = 1;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * CVKLU interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the CVKLU
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int cvKLUInit(CVodeMem cv_mem)
+{
+  CVSlsMem cvsls_mem;
+
+  cvsls_mem = (CVSlsMem)cv_mem->cv_lmem;
+
+  cvsls_mem->s_jacdata = cv_mem->cv_user_data;
+
+  cvsls_mem->s_nje = 0;
+  /* This forces factorization for every call to CVODE */
+  cvsls_mem->s_first_factorize = 1;
+  cvsls_mem->s_nstlj = 0;
+
+  cvsls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the CVKLU linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     CVSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int cvKLUSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+		      N_Vector fpred, booleantype *jcurPtr,
+		      N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  int retval;
+  long int nst, nstlj;
+  realtype tn, gamma, gammap, dgamma;
+  CVSlsMem cvsls_mem;
+  CVSlsSparseJacFn jaceval;
+  KLUData klu_data;
+  SlsMat JacMat, savedJ;
+  void *jacdata;
+  
+  realtype uround_twothirds;
+
+  uround_twothirds = SUNRpowerR(cv_mem->cv_uround,TWOTHIRDS);
+
+  cvsls_mem = (CVSlsMem) (cv_mem->cv_lmem);
+  tn = cv_mem->cv_tn; 
+  gamma = cv_mem->cv_gamma;
+  gammap = cv_mem->cv_gammap;
+  nst = cv_mem->cv_nst;
+
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  jaceval = cvsls_mem->s_jaceval;
+  jacdata = cvsls_mem->s_jacdata;
+  JacMat = cvsls_mem->s_JacMat;
+  savedJ = cvsls_mem->s_savedJ;
+  nstlj = cvsls_mem->s_nstlj;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    cvProcessError(cv_mem, CVSLS_JAC_NOSET, "CVSLS", "cvKLUSetup", 
+		    MSGSP_JAC_NOSET);
+    free(cvsls_mem); cvsls_mem = NULL;
+    return(CVSLS_JAC_NOSET);
+  }
+
+  /* Determine whether Jacobian needs to be recalculated */
+  dgamma = SUNRabs((gamma/gammap) - ONE);
+  jbad = (nst == 0) || (nst > nstlj + CVS_MSBJ) ||
+         ((convfail == CV_FAIL_BAD_J) && (dgamma < CVS_DGMAX)) ||
+         (convfail == CV_FAIL_OTHER);
+  jok = !jbad;
+  
+  if (jok) {
+    /* If jok = TRUE, use saved copy of J */
+    *jcurPtr = FALSE;
+    SparseCopyMat(savedJ, JacMat);
+  } else {
+    /* If jok = FALSE, call jac routine for new J value */
+    cvsls_mem->s_nje++;
+    cvsls_mem->s_nstlj = nst;
+    *jcurPtr = TRUE;
+    SparseSetMatToZero(JacMat);
+    retval = jaceval(tn, ypred, fpred, JacMat, jacdata, vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      cvProcessError(cv_mem, CVSLS_JACFUNC_UNRECVR, "CVSLS", "cvKLUSetup", MSGSP_JACFUNC_FAILED);
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_RECVR;
+      return(1);
+    }
+
+    SparseCopyMat(JacMat, savedJ);
+  }
+
+  /* Scale and add I to get M = I - gamma*J */
+  SparseScaleMat(-gamma, JacMat);
+  SparseAddIdentityMat(JacMat);
+
+  if (cvsls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get the symbolic factorization
+       ------------------------------------------------------------*/ 
+    /* Update the ordering option with any user-updated values from 
+       calls to CVKLUSetOrdering */
+    klu_data->s_Common.ordering = klu_data->s_ordering;
+
+     if (klu_data->s_Symbolic != NULL) {
+       klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+     }
+     klu_data->s_Symbolic = klu_analyze(JacMat->NP, JacMat->indexptrs, 
+				       JacMat->indexvals, &(klu_data->s_Common));
+    if (klu_data->s_Symbolic == NULL) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+
+    /* ------------------------------------------------------------
+       Compute the LU factorization of  the Jacobian.
+       ------------------------------------------------------------*/
+    /* If klu_factor previously called, free data */
+    if( klu_data->s_Numeric != NULL) {
+       klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    }
+    klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+				     JacMat->data, 
+				     klu_data->s_Symbolic, &(klu_data->s_Common));
+
+    if (klu_data->s_Numeric == NULL) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		     MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+
+    cvsls_mem->s_first_factorize = 0;
+  }
+  else {
+    
+    retval = klu_refactor(JacMat->indexptrs, JacMat->indexvals, JacMat->data, 
+			  klu_data->s_Symbolic, klu_data->s_Numeric,
+			  &(klu_data->s_Common));
+    if (retval == 0) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "cvKLUSetup", 
+		     MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+    
+    /*-----------------------------------------------------------
+      Check if a cheap estimate of the reciprocal of the condition 
+      number is getting too small.  If so, delete
+      the prior numeric factorization and recompute it.
+      -----------------------------------------------------------*/
+    
+    retval = klu_rcond(klu_data->s_Symbolic, klu_data->s_Numeric,
+		       &(klu_data->s_Common));
+    if (retval == 0) {
+      cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		     MSGSP_PACKAGE_FAIL);
+      return(CVSLS_PACKAGE_FAIL);
+    }
+
+    if ( (klu_data->s_Common.rcond)  < uround_twothirds ) {
+      
+      /* Condition number may be getting large.  
+	 Compute more accurate estimate */
+      retval = klu_condest(JacMat->indexptrs, JacMat->data, 
+			   klu_data->s_Symbolic, klu_data->s_Numeric,
+			   &(klu_data->s_Common));
+      if (retval == 0) {
+	cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+		       MSGSP_PACKAGE_FAIL);
+	return(CVSLS_PACKAGE_FAIL);
+      }
+      
+      if ( (klu_data->s_Common.condest) > 
+	   (1.0/uround_twothirds) ) {
+
+	/* More accurate estimate also says condition number is 
+	   large, so recompute the numeric factorization */
+
+	klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+	
+	klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+					 JacMat->data, klu_data->s_Symbolic, 
+					 &(klu_data->s_Common));
+
+	if (klu_data->s_Numeric == NULL) {
+	  cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSetup", 
+			 MSGSP_PACKAGE_FAIL);
+	  return(CVSLS_PACKAGE_FAIL);
+	}
+      }
+    }
+  }
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+  
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the CVKLU linear
+  solver module.  It calls the KLU solve routine,
+  then returns CVSLS_SUCCESS = 0.
+*/
+
+static int cvKLUSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+		      N_Vector ycur, N_Vector fcur)
+{
+  int flag, lmm;
+  realtype gamrat;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+  SlsMat JacMat;
+  realtype *bd;
+  
+  gamrat = cv_mem->cv_gamrat;
+  lmm = cv_mem->cv_lmm;
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  JacMat = cvsls_mem->s_JacMat;
+
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  bd = N_VGetArrayPointer(b);
+
+  /* Call KLU to solve the linear system */
+  flag = klu_data->sun_klu_solve(klu_data->s_Symbolic, klu_data->s_Numeric, JacMat->NP, 1, bd, 
+                                 &(klu_data->s_Common));
+  if (flag == 0) {
+    cvProcessError(cv_mem, CVSLS_PACKAGE_FAIL, "CVSLS", "CVKLUSolve", 
+		    MSGSP_PACKAGE_FAIL);
+    return(CVSLS_PACKAGE_FAIL);
+  }
+
+  /* Scale the correction to account for change in gamma. */
+  if ((lmm == CV_BDF) && (gamrat != ONE)) {
+    N_VScale(TWO/(ONE + gamrat), b, b);
+  }
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+  return(CVSLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the CVKLU linear solver.
+*/
+
+static int cvKLUFree(CVodeMem cv_mem)
+{
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+  
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  if( klu_data->s_Numeric != NULL)
+  {
+     klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  }
+  if( klu_data->s_Symbolic != NULL)
+  {
+     klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  }
+
+  if (cvsls_mem->s_JacMat) {
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    cvsls_mem->s_JacMat = NULL;
+  }
+
+  if (cvsls_mem->s_savedJ) {
+    SparseDestroyMat(cvsls_mem->s_savedJ);
+    cvsls_mem->s_savedJ = NULL;
+  }
+
+  free(klu_data); 
+  free(cv_mem->cv_lmem); 
+
+  return(0);
+}
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in CVODE is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int CVKLUSetOrdering(void *cv_mem_v, int ordering_choice)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  KLUData klu_data;
+
+ /* Return immediately if cv_mem is NULL */
+  if (cv_mem_v == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVKLUSetOrdering",
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cv_mem_v;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) ) {
+    cvProcessError(NULL, CVSLS_ILL_INPUT, "CVSLS", "CVKLUSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  klu_data = (KLUData) cvsls_mem->s_solver_data;
+
+  klu_data->s_ordering = ordering_choice;
+
+  return(CVSLS_SUCCESS);
+}
+
+
+/* 
+ * ================================================================
+ *
+ *                   PART II - backward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * CVKLUB is a wrapper around CVKLU. It attaches the CVKLU linear solver
+ * to the backward problem memory block.
+ */
+
+int CVKLUB(void *cvode_mem, int which, int n, int nnz, int sparsetype)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  void *cvodeB_mem;
+  CVSlsMemB cvslsB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSKLU", "CVKLUB", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSLS_NO_ADJ, "CVSKLU", "CVKLUB", MSGSP_NO_ADJ);
+    return(CVSLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSKLU", "CVKLUB", MSGSP_BAD_WHICH);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  /* Get memory for CVSlsMemRecB */
+  cvslsB_mem = (CVSlsMemB) malloc(sizeof(struct CVSlsMemRecB));
+  if (cvslsB_mem == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSKLU", "CVKLUB", MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* initialize Jacobian function */
+  cvslsB_mem->s_djacB = NULL;
+
+  /* attach lmemB and lfreeB */
+  cvB_mem->cv_lmem = cvslsB_mem;
+  cvB_mem->cv_lfree = cvKLUFreeB;
+
+  flag = CVKLU(cvodeB_mem, n, nnz, sparsetype);
+
+  if (flag != CVSLS_SUCCESS) {
+    free(cvslsB_mem);
+    cvslsB_mem = NULL;
+  }
+
+  return(flag);
+}
+
+
+/*
+ * CVKLUReInitB is a wrapper around CVKLUReInit. 
+ * CVKLUReInitB pulls off the memory block associated with the
+ * which parameter and reinitializes the KLU solver associated with that block.
+ * The 'which' argument is the int returned by CVodeCreateB.
+ */
+int CVKLUReInitB(void *cvode_mem, int which, int n, int nnz, int reinit_type)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  void *cvodeB_mem;
+  /* CVSlsMemB cvslsB_mem; */
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSKLU", "CVKLUReInitB", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSLS_NO_ADJ, "CVSKLU", "CVKLUReInitB", MSGSP_NO_ADJ);
+    return(CVSLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSKLU", "CVKLUReInitB", MSGSP_BAD_WHICH);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  flag = CVKLUReInit(cvodeB_mem, n, nnz, reinit_type);
+
+  return(flag);
+}
+
+/*
+ * CVKLUSetOrderingB is a wrapper around CVKLUSetOrdering. 
+ * CVKLUSetOrderingB pulls off the memory block associated with the
+ * which parameter and sets the ordering for the solver associated with that block.
+ */
+int CVKLUSetOrderingB(void *cvode_mem, int which, int ordering_choice)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  void *cvodeB_mem;
+  /* CVSlsMemB cvslsB_mem; */
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSKLU", "CVKLUSetOrderingB", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSLS_NO_ADJ, "CVSKLU", "CVKLUSetOrderingB", MSGSP_NO_ADJ);
+    return(CVSLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSKLU", "CVKLUSetOrderingB", MSGSP_BAD_WHICH);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  flag = CVKLUSetOrdering(cvodeB_mem, ordering_choice);
+
+  return(flag);
+}
+
+
+/*
+ * cvKLUFreeB frees the memory associated with the CVSKLU linear
+ * solver for backward integration.
+ */
+
+static int cvKLUFreeB(CVodeBMem cvB_mem)
+{
+  CVSlsMemB cvslsB_mem;
+
+  cvslsB_mem = (CVSlsMemB) (cvB_mem->cv_lmem);
+
+  free(cvslsB_mem);
+
+  return(0);
+}
+
diff --git a/src/cvodes/cvodes_lapack.c b/src/cvodes/cvodes_lapack.c
index 931ba86..5209b5d 100644
--- a/src/cvodes/cvodes_lapack.c
+++ b/src/cvodes/cvodes_lapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.15 $
- * $Date: 2011/03/23 22:58:46 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a dense or banded CVODES 
  * linear solver using BLAS and LAPACK functions.
@@ -50,7 +55,7 @@ static int cvLapackDenseSetup(CVodeMem cv_mem, int convfail,
                               N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
 static int cvLapackDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                               N_Vector yC, N_Vector fctC);
-static void cvLapackDenseFree(CVodeMem cv_mem);
+static int cvLapackDenseFree(CVodeMem cv_mem);
 
 /* CVSLAPACK BAND linit, lsetup, lsolve, and lfree routines */ 
 static int cvLapackBandInit(CVodeMem cv_mem);
@@ -60,11 +65,11 @@ static int cvLapackBandSetup(CVodeMem cv_mem, int convfail,
                              N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
 static int cvLapackBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                              N_Vector yC, N_Vector fctC);
-static void cvLapackBandFree(CVodeMem cv_mem);
+static int cvLapackBandFree(CVodeMem cv_mem);
 
 /* CVSLAPACK lfreeB functions */
-static void cvLapackDenseFreeB(CVodeBMem cvB_mem);
-static void cvLapackBandFreeB(CVodeBMem cvB_mem);
+static int cvLapackDenseFreeB(CVodeBMem cvB_mem);
+static int cvLapackBandFreeB(CVodeBMem cvB_mem);
 
 /* 
  * ================================================================
@@ -180,6 +185,7 @@ int CVLapackDense(void *cvode_mem, int N)
   J_data = NULL;
 
   last_flag = CVDLS_SUCCESS;
+  cvDlsInitializeCounters(cvdls_mem);  
   setupNonNull = TRUE;
 
   /* Set problem dimension */
@@ -286,6 +292,7 @@ int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
   J_data = NULL;
 
   last_flag = CVDLS_SUCCESS;
+  cvDlsInitializeCounters(cvdls_mem);  
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -303,7 +310,7 @@ int CVLapackBand(void *cvode_mem, int N, int mupper, int mlower)
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(n-1, mu + ml);
+  smu = mu + ml;
 
   /* Allocate memory for M, savedJ, and pivot arrays */
   M = NULL;
@@ -354,9 +361,7 @@ static int cvLapackDenseInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
   
-  nje   = 0;
-  nfeDQ = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);  
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -393,7 +398,7 @@ static int cvLapackDenseSetup(CVodeMem cv_mem, int convfail,
   lenmat = M->ldata;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
     ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
     (convfail == CV_FAIL_OTHER);
@@ -477,7 +482,7 @@ static int cvLapackDenseSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
 /*
  * cvLapackDenseFree frees memory specific to the dense linear solver.
  */
-static void cvLapackDenseFree(CVodeMem cv_mem)
+static int cvLapackDenseFree(CVodeMem cv_mem)
 {
   CVDlsMem  cvdls_mem;
 
@@ -488,6 +493,8 @@ static void cvLapackDenseFree(CVodeMem cv_mem)
   DestroyMat(savedJ);
   free(cvdls_mem); 
   cvdls_mem = NULL;
+
+  return(0);
 }
 
 /* 
@@ -506,9 +513,7 @@ static int cvLapackBandInit(CVodeMem cv_mem)
 
   cvdls_mem = (CVDlsMem) lmem;
 
-  nje   = 0;
-  nfeDQ = 0;
-  nstlj = 0;
+  cvDlsInitializeCounters(cvdls_mem);  
 
   /* Set Jacobian function and data, depending on jacDQ */
   if (jacDQ) {
@@ -549,7 +554,7 @@ static int cvLapackBandSetup(CVodeMem cv_mem, int convfail,
   ldmat = M->ldim;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlj + CVD_MSBJ) ||
     ((convfail == CV_FAIL_BAD_J) && (dgamma < CVD_DGMAX)) ||
     (convfail == CV_FAIL_OTHER);
@@ -637,7 +642,7 @@ static int cvLapackBandSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
 /*
  * cvLapackBandFree frees memory specific to the band linear solver.
  */
-static void cvLapackBandFree(CVodeMem cv_mem)
+static int cvLapackBandFree(CVodeMem cv_mem)
 {
   CVDlsMem  cvdls_mem;
 
@@ -648,6 +653,8 @@ static void cvLapackBandFree(CVodeMem cv_mem)
   DestroyMat(savedJ);
   free(cvdls_mem); 
   cvdls_mem = NULL;
+
+  return(0);
 }
 
 /* 
@@ -659,7 +666,7 @@ static void cvLapackBandFree(CVodeMem cv_mem)
  */
 
 /*
- * CVLapackDenseB is a wraper around CVLapackDense. It attaches the
+ * CVLapackDenseB is a wrapper around CVLapackDense. It attaches the
  * dense CVSLAPACK linear solver to the backward problem memory block.
  */
 
@@ -733,17 +740,19 @@ int CVLapackDenseB(void *cvode_mem, int which, int nB)
  * linear solver for backward integration.
  */
 
-static void cvLapackDenseFreeB(CVodeBMem cvB_mem)
+static int cvLapackDenseFreeB(CVodeBMem cvB_mem)
 {
   CVDlsMemB cvdlsB_mem;
 
   cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
 
   free(cvdlsB_mem);
+
+  return(0);
 }
 
 /*
- * CVLapackBandB is a wraper around CVLapackBand. It attaches the band
+ * CVLapackBandB is a wrapper around CVLapackBand. It attaches the band
  * CVSLAPACK linear solver to the backward problem memory block.
  */
 
@@ -818,11 +827,13 @@ int CVLapackBandB(void *cvode_mem, int which,
  * linear solver for backward integration.
  */
 
-static void cvLapackBandFreeB(CVodeBMem cvB_mem)
+static int cvLapackBandFreeB(CVodeBMem cvB_mem)
 {
   CVDlsMemB cvdlsB_mem;
 
   cvdlsB_mem = (CVDlsMemB) (cvB_mem->cv_lmem);
 
   free(cvdlsB_mem);
+
+  return(0);
 }
diff --git a/src/cvodes/cvodes_sparse.c b/src/cvodes/cvodes_sparse.c
new file mode 100644
index 0000000..b1d35e3
--- /dev/null
+++ b/src/cvodes/cvodes_sparse.c
@@ -0,0 +1,407 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4086 $
+ * $Date: 2014-04-30 16:04:45 -0700 (Wed, 30 Apr 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for an CVSLS linear solver.
+ * -----------------------------------------------------------------
+ */
+
+/* 
+ * =================================================================
+ * IMPORTED HEADER FILES
+ * =================================================================
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cvodes_impl.h"
+#include "cvodes_sparse_impl.h"
+#include <sundials/sundials_math.h>
+
+/* 
+ * =================================================================
+ * FUNCTION SPECIFIC CONSTANTS
+ * =================================================================
+ */
+
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* 
+ * =================================================================
+ * PRIVATE FUNCTION PROTOTYPES
+ * =================================================================
+ */
+
+static int cvSlsSparseJacBWrapper(realtype t,
+				  N_Vector yB, N_Vector fyB, 
+				  SlsMat JB, void *cvode_mem,
+				  N_Vector tmp1B, N_Vector tmp2B, 
+				  N_Vector tmp3B);
+
+static int cvSlsSparseJacBSWrapper(realtype t,
+				   N_Vector yB, N_Vector fyB, 
+				   SlsMat JB, void *cvode_mem,
+				   N_Vector tmp1B, N_Vector tmp2B, 
+				   N_Vector tmp3B);
+
+/* 
+ * =================================================================
+ * EXPORTED FUNCTIONS FOR IMPLICIT INTEGRATION
+ * =================================================================
+ */
+              
+/*
+ * CVSlsSetSparseJacFn specifies the sparse Jacobian function.
+ */
+int CVSlsSetSparseJacFn(void *cvode_mem, CVSlsSparseJacFn jac)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+
+  /* Return immediately if cvode_mem is NULL */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSlsSetSparseJacFn", 
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEM_NULL, "CVSLS", 
+		    "CVSlsSetSparseJacFn", MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  cvsls_mem->s_jaceval = jac;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * CVSlsGetNumJacEvals returns the number of Jacobian evaluations.
+ */
+int CVSlsGetNumJacEvals(void *cvode_mem, long int *njevals)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+
+  /* Return immediately if cvode_mem is NULL */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSlsGetNumJacEvals", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEM_NULL, "CVSLS", 
+		    "CVSlsGetNumJacEvals", MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  *njevals = cvsls_mem->s_nje;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * CVSlsGetReturnFlagName returns the name associated with a CVSLS
+ * return value.
+ */
+char *CVSlsGetReturnFlagName(long int flag)
+{
+  char *name;
+
+  name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case CVSLS_SUCCESS:
+    sprintf(name,"CVSLS_SUCCESS");
+    break;   
+  case CVSLS_MEM_NULL:
+    sprintf(name,"CVSLS_MEM_NULL");
+    break;
+  case CVSLS_LMEM_NULL:
+    sprintf(name,"CVSLS_LMEM_NULL");
+    break;
+  case CVSLS_ILL_INPUT:
+    sprintf(name,"CVSLS_ILL_INPUT");
+    break;
+  case CVSLS_MEM_FAIL:
+    sprintf(name,"CVSLS_MEM_FAIL");
+    break;
+  case CVSLS_JAC_NOSET:
+    sprintf(name,"CVSLS_JAC_NOSET");
+    break;
+  case CVSLS_JACFUNC_UNRECVR:
+    sprintf(name,"CVSLS_JACFUNC_UNRECVR");
+    break;
+  case CVSLS_JACFUNC_RECVR:
+    sprintf(name,"CVSLS_JACFUNC_RECVR");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+/*
+ * CVSlsGetLastFlag returns the last flag set in a CVSLS function.
+ */
+int CVSlsGetLastFlag(void *cvode_mem, long int *flag)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+
+  /* Return immediately if cvode_mem is NULL */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSlsGetLastFlag", 
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  if (cv_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEM_NULL, "CVSLS", 
+		    "CVSlsGetLastFlag", MSGSP_LMEM_NULL);
+    return(CVSLS_LMEM_NULL);
+  }
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  *flag = cvsls_mem->s_last_flag;
+
+  return(CVSLS_SUCCESS);
+}
+
+/* 
+ * =================================================================
+ * BACKWARD INTEGRATION SUPPORT
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * EXPORTED FUNCTIONS
+ * -----------------------------------------------------------------
+ */
+
+int CVSlsSetSparseJacFnB(void *cvode_mem, int which, CVSlsSparseJacFnB jacB)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSlsMemB cvslsB_mem;
+  void *cvodeB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSSLS", "CVSlsSetSparseJacFnB", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSLS_NO_ADJ, "CVSSLS", "CVSlsSetSparseJacFnB", MSGSP_NO_ADJ);
+    return(CVSLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSSLS", "CVSlsSetSparseJacFnB", MSGSP_BAD_WHICH);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  if (cvB_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEMB_NULL, "CVSSLS", "CVSlsSetSparseJacFnB", MSGSP_LMEMB_NULL);
+    return(CVSLS_LMEMB_NULL);
+  }
+  cvslsB_mem = (CVSlsMemB) (cvB_mem->cv_lmem);
+
+  cvslsB_mem->s_djacB = jacB;
+
+  if (jacB != NULL) {
+    flag = CVSlsSetSparseJacFn(cvodeB_mem, cvSlsSparseJacBWrapper);
+  } else {
+    flag = CVSlsSetSparseJacFn(cvodeB_mem, NULL);
+  }
+
+  return(flag);
+}
+
+int CVSlsSetSparseJacFnBS(void *cvode_mem, int which, CVSlsSparseJacFnBS jacBS)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSlsMemB cvslsB_mem;
+  void *cvodeB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSSLS", "CVSlsSetSparseJacFnBS", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSLS_NO_ADJ, "CVSSLS", "CVSlsSetSparseJacFnBS", MSGSP_NO_ADJ);
+    return(CVSLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSSLS", "CVSlsSetSparseJacFnBS", MSGSP_BAD_WHICH);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  if (cvB_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSLS_LMEMB_NULL, "CVSSLS", "CVSlsSetSparseJacFnBS", MSGSP_LMEMB_NULL);
+    return(CVSLS_LMEMB_NULL);
+  }
+  cvslsB_mem = (CVSlsMemB) (cvB_mem->cv_lmem);
+
+  cvslsB_mem->s_djacBS = jacBS;
+
+  if (jacBS != NULL) {
+    flag = CVSlsSetSparseJacFn(cvodeB_mem, cvSlsSparseJacBSWrapper);
+  } else {
+    flag = CVSlsSetSparseJacFn(cvodeB_mem, NULL);
+  }
+
+  return(flag);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * PRIVATE INTERFACE FUNCTIONS
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * cvSlsSparseJacBWrapper
+ *
+ * This routine interfaces to the CVSlsSparseJacFnB routine provided 
+ * by the user. cvSlsSparseJacBWrapper is of type CVSlsSparseJacFn.
+ * NOTE: data here contains cvode_mem
+ */
+
+static int cvSlsSparseJacBWrapper(realtype t,
+				  N_Vector yB, N_Vector fyB, 
+				  SlsMat JB, void *cvode_mem,
+				  N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSlsMemB cvslsB_mem;
+  int retval, flag;
+
+  cv_mem = (CVodeMem) cvode_mem;
+
+  ca_mem = cv_mem->cv_adj_mem;
+
+  cvB_mem = ca_mem->ca_bckpbCrt;
+
+  cvslsB_mem = (CVSlsMemB) (cvB_mem->cv_lmem);
+
+  /* Forward solution from interpolation */
+  flag = ca_mem->ca_IMget(cv_mem, t, ca_mem->ca_ytmp, NULL);
+  if (flag != CV_SUCCESS) {
+    cvProcessError(cv_mem, -1, "CVSSLS", "cvSlsSparseJacBWrapper", MSGSP_BAD_TINTERP);
+    return(-1);
+  }
+
+  /* Call user's adjoint dense djacB routine (of type CVSlsSparseJacFnB) */
+  retval = cvslsB_mem->s_djacB(t, ca_mem->ca_ytmp, yB, fyB, JB, 
+			       cvB_mem->cv_user_data, 
+			       tmp1B, tmp2B, tmp3B);
+
+  return(retval);
+}
+
+/*
+ * cvSlsSparseJacBSWrapper
+ *
+ * This routine interfaces to the CVSlsSparseJacFnBS routine provided 
+ * by the user. cvSlsSparseJacBSWrapper is of type CVSlsSparseJacFn.
+ * NOTE: data here contains cvode_mem
+ */
+
+static int cvSlsSparseJacBSWrapper(realtype t,
+				   N_Vector yB, N_Vector fyB, 
+				   SlsMat JB, void *cvode_mem,
+				   N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSlsMemB cvslsB_mem;
+  int retval, flag;
+
+  cv_mem = (CVodeMem) cvode_mem;
+
+  ca_mem = cv_mem->cv_adj_mem;
+
+  cvB_mem = ca_mem->ca_bckpbCrt;
+
+  cvslsB_mem = (CVSlsMemB) (cvB_mem->cv_lmem);
+
+  /* Forward solution from interpolation */
+  if (ca_mem->ca_IMinterpSensi)
+    flag = ca_mem->ca_IMget(cv_mem, t, ca_mem->ca_ytmp, ca_mem->ca_yStmp);
+  else 
+    flag = ca_mem->ca_IMget(cv_mem, t, ca_mem->ca_ytmp, NULL);
+  if (flag != CV_SUCCESS) {
+    cvProcessError(cv_mem, -1, "CVSSLS", "cvSlsSparseJacBSWrapper", MSGSP_BAD_TINTERP);
+    return(-1);
+  }
+
+  /* Call user's adjoint dense djacBS routine (of type CVSlsSparseJacFnBS) */
+  retval = cvslsB_mem->s_djacBS(t, ca_mem->ca_ytmp, ca_mem->ca_yStmp, 
+				yB, fyB, JB, cvB_mem->cv_user_data, 
+				tmp1B, tmp2B, tmp3B);
+
+  return(retval);
+}
diff --git a/src/cvodes/cvodes_sparse_impl.h b/src/cvodes/cvodes_sparse_impl.h
new file mode 100644
index 0000000..b526278
--- /dev/null
+++ b/src/cvodes/cvodes_sparse_impl.h
@@ -0,0 +1,137 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the CVSLS linear solvers.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _CVSSPARSE_IMPL_H
+#define _CVSSPARSE_IMPL_H
+
+#include "cvodes/cvodes_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * C V S P A R S E    I N T E R N A L    C O N S T A N T S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * CVSLS solver constants
+ * -----------------------------------------------------------------
+ * CVS_MSBJ   maximum number of steps between Jacobian evaluations
+ * CVS_DGMAX  maximum change in gamma between Jacobian evaluations
+ * -----------------------------------------------------------------
+ */
+ 
+#define CVS_MSBJ  50
+#define CVS_DGMAX RCONST(0.2)
+ 
+/*
+ * -----------------------------------------------------------------
+ * Types : CVSlsMemRec, CVSlsMem                             
+ * -----------------------------------------------------------------
+ * CVSlsMem is pointer to a CVSlsMemRec structure.
+ * -----------------------------------------------------------------
+ */
+
+typedef struct CVSlsMemRec {
+
+  CVSlsSparseJacFn s_jaceval; /* user Jacobian evaluation routine 
+				  to be called */
+  void *s_jacdata;           /* J_data is passed to djac or bjac */
+
+  long int s_nje;           /* nje = no. of calls to jac */
+
+  long int s_last_flag;     /* last error return flag */
+
+  int s_first_factorize;    /* flag telling whether the first 
+			       factorization needs to happen */
+
+  int s_nstlj;              /* time step of last Jacobian evaluation */
+
+  SlsMat s_JacMat;          /* M = I - gamma * df/dy */
+
+  SlsMat s_savedJ;          /* saved copy of Jacobian */
+
+  int sparsetype;           /* matrix type: compressed sparse column or row */
+
+  void *s_solver_data;      /* structure for solver-specific data */
+  
+
+} *CVSlsMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Prototypes of internal functions
+ * -----------------------------------------------------------------
+ */
+  
+/*
+ * =================================================================
+ * PART II:  B A C K W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : CVSlsMemRecB, CVSlsMemB       
+ * -----------------------------------------------------------------
+ * A CVSLS linear solver's specification function attaches such
+ * a structure to the lmemB filed of CVodeBMem
+ * -----------------------------------------------------------------
+ */
+
+typedef struct CVSlsMemRecB {
+
+  CVSlsSparseJacFnB s_djacB;
+  CVSlsSparseJacFnBS s_djacBS;
+
+} *CVSlsMemB;
+
+
+/*
+ * =================================================================
+ * E R R O R   M E S S A G E S
+ * =================================================================
+ */
+
+#define MSGSP_CVMEM_NULL "Integrator memory is NULL."
+#define MSGSP_BAD_NVECTOR "A required vector operation is not implemented."
+#define MSGSP_MEM_FAIL "A memory request failed."
+#define MSGSP_LMEM_NULL "Linear solver memory is NULL."
+#define MSGSP_ILL_INPUT "Invalid input detected."
+#define MSGSP_JAC_NOSET "Jacobian evaluation function has not been set."
+#define MSGSP_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
+#define MSGSP_PACKAGE_FAIL "A call to an external package failed."
+
+#define MSGSP_NO_ADJ "Illegal attempt to call before calling CVodeAdjMalloc."
+#define MSGSP_BAD_WHICH "Illegal value for which."
+#define MSGSP_LMEMB_NULL "Linear solver memory is NULL for the backward integration."
+#define MSGSP_BAD_TINTERP "Bad t for interpolation."
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/cvodes/cvodes_spbcgs.c b/src/cvodes/cvodes_spbcgs.c
index fe2df25..2153de5 100644
--- a/src/cvodes/cvodes_spbcgs.c
+++ b/src/cvodes/cvodes_spbcgs.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2011/03/23 22:58:46 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPBCG linear solver.
  * -----------------------------------------------------------------
@@ -40,11 +45,11 @@ static int CVSpbcgSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int CVSpbcgSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                         N_Vector ynow, N_Vector fnow);
 
-static void CVSpbcgFree(CVodeMem cv_mem);
+static int CVSpbcgFree(CVodeMem cv_mem);
 
 /* CVSPBCG lfreeB function */
 
-static void CVSpbcgFreeB(CVodeBMem cvB_mem);
+static int CVSpbcgFreeB(CVodeBMem cvB_mem);
 
 /* 
  * ================================================================
@@ -173,6 +178,8 @@ int CVSpbcg(void *cvode_mem, int pretype, int maxl)
 
   cvspils_mem->s_last_flag = CVSPILS_SUCCESS;
 
+  cvSpilsInitializeCounters(cvspils_mem);
+
   setupNonNull = FALSE;
 
   /* Check for legal pretype */ 
@@ -200,7 +207,7 @@ int CVSpbcg(void *cvode_mem, int pretype, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SpbcgMalloc to allocate workspace for Spbcg */
   spbcg_mem = NULL;
@@ -252,8 +259,7 @@ static int CVSpbcgInit(CVodeMem cv_mem)
 
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = nstlpre = 0;
-  njtimes = nfes = 0;
+  cvSpilsInitializeCounters(cvspils_mem);
 
   /* Check for legal combination pretype - psolve */
   if ((pretype != PREC_NONE) && (psolve == NULL)) {
@@ -307,7 +313,7 @@ static int CVSpbcgSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlpre + CVSPILS_MSBPRE) ||
       ((convfail == CV_FAIL_BAD_J) && (dgamma < CVSPILS_DGMAX)) ||
       (convfail == CV_FAIL_OTHER);
@@ -449,7 +455,7 @@ static int CVSpbcgSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVSpbcgFree(CVodeMem cv_mem)
+static int CVSpbcgFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   SpbcgMem spbcg_mem;
@@ -466,6 +472,8 @@ static void CVSpbcgFree(CVodeMem cv_mem)
 
   free(cvspils_mem);
   cv_mem->cv_lmem = NULL;
+  
+  return(0);
 }
 
 
@@ -563,11 +571,13 @@ int CVSpbcgB(void *cvode_mem, int which, int pretypeB, int maxlB)
  */
 
 
-static void CVSpbcgFreeB(CVodeBMem cvB_mem)
+static int CVSpbcgFreeB(CVodeBMem cvB_mem)
 {
   CVSpilsMemB cvspilsB_mem;
 
   cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
 
   free(cvspilsB_mem);
+
+  return(0);
 }
diff --git a/src/cvodes/cvodes_spgmr.c b/src/cvodes/cvodes_spgmr.c
index a8a8391..c18d3da 100644
--- a/src/cvodes/cvodes_spgmr.c
+++ b/src/cvodes/cvodes_spgmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2011/03/23 22:58:46 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPGMR linear solver.
  * -----------------------------------------------------------------
@@ -40,11 +45,11 @@ static int CVSpgmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
 static int CVSpgmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
                         N_Vector ynow, N_Vector fnow);
 
-static void CVSpgmrFree(CVodeMem cv_mem);
+static int CVSpgmrFree(CVodeMem cv_mem);
 
 /* CVSPGMR lfreeB function */
 
-static void CVSpgmrFreeB(CVodeBMem cvB_mem);
+static int CVSpgmrFreeB(CVodeBMem cvB_mem);
 
 /* 
  * ================================================================
@@ -176,6 +181,8 @@ int CVSpgmr(void *cvode_mem, int pretype, int maxl)
   
   cvspils_mem->s_last_flag  = CVSPILS_SUCCESS;
 
+  cvSpilsInitializeCounters(cvspils_mem);
+
   setupNonNull = FALSE;
 
   /* Check for legal pretype */ 
@@ -203,7 +210,7 @@ int CVSpgmr(void *cvode_mem, int pretype, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt( N_VDotProd(ytemp, ytemp) );
+  sqrtN = SUNRsqrt( N_VDotProd(ytemp, ytemp) );
 
   /* Call SpgmrMalloc to allocate workspace for Spgmr */
   spgmr_mem = NULL;
@@ -251,8 +258,7 @@ static int CVSpgmrInit(CVodeMem cv_mem)
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = nstlpre = 0;
-  njtimes = nfes = 0;
+  cvSpilsInitializeCounters(cvspils_mem);
 
   /* Check for legal combination pretype - psolve */
   if ((pretype != PREC_NONE) && (psolve == NULL)) {
@@ -302,7 +308,7 @@ static int CVSpgmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlpre + CVSPILS_MSBPRE) ||
     ((convfail == CV_FAIL_BAD_J) && (dgamma < CVSPILS_DGMAX)) ||
     (convfail == CV_FAIL_OTHER);
@@ -453,7 +459,7 @@ static int CVSpgmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVSpgmrFree(CVodeMem cv_mem)
+static int CVSpgmrFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   SpgmrMem spgmr_mem;
@@ -470,6 +476,8 @@ static void CVSpgmrFree(CVodeMem cv_mem)
 
   free(cvspils_mem);
   cv_mem->cv_lmem = NULL;
+
+  return(0);
 }
 
 
@@ -569,11 +577,13 @@ int CVSpgmrB(void *cvode_mem, int which, int pretypeB, int maxlB)
  */
 
 
-static void CVSpgmrFreeB(CVodeBMem cvB_mem)
+static int CVSpgmrFreeB(CVodeBMem cvB_mem)
 {
   CVSpilsMemB cvspilsB_mem;
 
   cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
 
   free(cvspilsB_mem);
+
+  return(0);
 }
diff --git a/src/cvodes/cvodes_spils.c b/src/cvodes/cvodes_spils.c
index 295be45..559b44b 100644
--- a/src/cvodes/cvodes_spils.c
+++ b/src/cvodes/cvodes_spils.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2011/06/23 00:31:01 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s):Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPILS linear solvers.
  *
@@ -39,20 +44,28 @@
  * =================================================================
  */
 
-/* 
- * cvSpilsPrecSetupBWrapper has type CVSpilsPrecSetupFn
- * It wraps around the user-provided function of type CVSpilsPrecSetupFnB
+/*
+ * cvSpilsPrecSetupBWrapper and cvSpilsPrecSetupBSWrapper have type
+ * CVSpilsPrecSetupFn, and wrap around user-provided functions of
+ * type CVSpilsPrecSetupFnB and CVSpilsPrecSetupFnBS, respectively.
  */
 
-static int cvSpilsPrecSetupBWrapper(realtype t, N_Vector yB, 
-                                    N_Vector fyB, booleantype jokB, 
+static int cvSpilsPrecSetupBWrapper(realtype t, N_Vector yB,
+                                    N_Vector fyB, booleantype jokB,
                                     booleantype *jcurPtrB, realtype gammaB,
                                     void *cvode_mem,
                                     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
 
-/* 
- * cvSpilsPrecSolveBWrapper has type CVSpilsPrecSolveFn 
- * It wraps around the user-provided function of type CVSpilsPrecSolveFnB
+static int cvSpilsPrecSetupBSWrapper(realtype t, N_Vector yB,
+                                     N_Vector fyB, booleantype jokB,
+                                     booleantype *jcurPtrB, realtype gammaB,
+                                     void *cvode_mem,
+                                     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+/*
+ * cvSpilsPrecSolveBWrapper and cvSpilsPrecSolveBSWrapper have type
+ * CVSpilsPrecSolveFn, and wrap around user-provided functions of
+ * type CVSpilsPrecSolveFnB and CVSpilsPrecSolveFnBS, respectively.
  */
 
 static int cvSpilsPrecSolveBWrapper(realtype t, N_Vector yB, N_Vector fyB,
@@ -60,15 +73,25 @@ static int cvSpilsPrecSolveBWrapper(realtype t, N_Vector yB, N_Vector fyB,
                                     realtype gammaB, realtype deltaB,
                                     int lrB, void *cvode_mem, N_Vector tmpB);
   
-/* 
- * cvSpilsJacTimesVecBWrapper has type CVSpilsJacTimesVecFn 
- * It wraps around the user-provided function of type CVSpilsJacTimesVecFnB
+static int cvSpilsPrecSolveBSWrapper(realtype t, N_Vector yB, N_Vector fyB,
+                                     N_Vector rB, N_Vector zB,
+                                     realtype gammaB, realtype deltaB,
+                                     int lrB, void *cvode_mem, N_Vector tmpB);
+  
+/*
+ * cvSpilsJacTimesVecBWrapper and cvSpilsJacTimesVecBSWrapper have type
+ * CVSpilsJacTimesVecFn, and wrap around user-provided functions of
+ * type CVSpilsJacTimesVecFnB and CVSpilsJacTimesVecFnBS, respectively.
  */
 
 static int cvSpilsJacTimesVecBWrapper(N_Vector vB, N_Vector JvB, realtype t, 
                                       N_Vector yB, N_Vector fyB, 
                                       void *cvode_mem, N_Vector tmpB);
 
+static int cvSpilsJacTimesVecBSWrapper(N_Vector vB, N_Vector JvB, realtype t, 
+                                       N_Vector yB, N_Vector fyB, 
+                                       void *cvode_mem, N_Vector tmpB);
+
 /* 
  * ================================================================
  *
@@ -752,6 +775,21 @@ int CVSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t,
   return(0);
 }
 
+
+int cvSpilsInitializeCounters(CVSpilsMem cvspils_mem)
+{
+  cvspils_mem->s_npe     = 0;
+  cvspils_mem->s_nli     = 0;
+  cvspils_mem->s_nps     = 0;
+  cvspils_mem->s_ncfl    = 0;
+  cvspils_mem->s_nstlpre = 0;
+  cvspils_mem->s_njtimes = 0;
+  cvspils_mem->s_nfes    = 0;
+
+  return(0);
+}
+
+
 /* 
  * ================================================================
  *
@@ -765,10 +803,14 @@ int CVSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t,
 #define ytmp  (ca_mem->ca_ytmp)
 #define yStmp (ca_mem->ca_yStmp)
 #define IMget (ca_mem->ca_IMget)
+#define IMinterpSensi (ca_mem->ca_IMinterpSensi)
 
 #define pset_B     (cvspilsB_mem->s_psetB)
+#define pset_BS     (cvspilsB_mem->s_psetBS)
 #define psolve_B   (cvspilsB_mem->s_psolveB)
+#define psolve_BS   (cvspilsB_mem->s_psolveBS)
 #define jtimes_B   (cvspilsB_mem->s_jtimesB)
+#define jtimes_BS   (cvspilsB_mem->s_jtimesBS)
 
 /*
  * -----------------------------------------------------------------
@@ -957,21 +999,21 @@ int CVSpilsSetPreconditionerB(void *cvode_mem, int which,
 
   /* Check if cvode_mem exists */
   if (cvode_mem == NULL) {
-    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetPreconsitionerB", MSGS_CVMEM_NULL);
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetPreconditionerB", MSGS_CVMEM_NULL);
     return(CVSPILS_MEM_NULL);
   }
   cv_mem = (CVodeMem) cvode_mem;
 
   /* Was ASA initialized? */
   if (cv_mem->cv_adjMallocDone == FALSE) {
-    cvProcessError(cv_mem, CVSPILS_NO_ADJ, "CVSPILS", "CVSpilsSetPreconsitionerB", MSGS_NO_ADJ);
+    cvProcessError(cv_mem, CVSPILS_NO_ADJ, "CVSPILS", "CVSpilsSetPreconditionerB", MSGS_NO_ADJ);
     return(CVSPILS_NO_ADJ);
   } 
   ca_mem = cv_mem->cv_adj_mem;
 
   /* Check which */
   if ( which >= ca_mem->ca_nbckpbs ) {
-    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetPreconsitionerB", MSGS_BAD_WHICH);
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetPreconditionerB", MSGS_BAD_WHICH);
     return(CVSPILS_ILL_INPUT);
   }
 
@@ -985,7 +1027,7 @@ int CVSpilsSetPreconditionerB(void *cvode_mem, int which,
   cvodeB_mem = (void *) (cvB_mem->cv_mem);
 
   if (cvB_mem->cv_lmem == NULL) {
-    cvProcessError(cv_mem, CVSPILS_LMEMB_NULL, "CVSPILS", "CVSpilsSetPreconditonerB", MSGS_LMEMB_NULL);
+    cvProcessError(cv_mem, CVSPILS_LMEMB_NULL, "CVSPILS", "CVSpilsSetPreconditionerB", MSGS_LMEMB_NULL);
     return(CVSPILS_LMEMB_NULL);
   }
   cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
@@ -993,7 +1035,69 @@ int CVSpilsSetPreconditionerB(void *cvode_mem, int which,
   pset_B   = psetB;
   psolve_B = psolveB;
 
-  flag = CVSpilsSetPreconditioner(cvodeB_mem, cvSpilsPrecSetupBWrapper, cvSpilsPrecSolveBWrapper);
+  if (psetB == NULL) {
+    flag = CVSpilsSetPreconditioner(cvodeB_mem, NULL, cvSpilsPrecSolveBWrapper);
+  } else {
+    flag = CVSpilsSetPreconditioner(cvodeB_mem, cvSpilsPrecSetupBWrapper, cvSpilsPrecSolveBWrapper);
+  }
+
+  return(flag);
+}
+
+int CVSpilsSetPreconditionerBS(void *cvode_mem, int which, 
+                               CVSpilsPrecSetupFnBS psetBS,
+                               CVSpilsPrecSolveFnBS psolveBS)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSpilsMemB cvspilsB_mem; 
+  void *cvodeB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetPreconditionerBS", MSGS_CVMEM_NULL);
+    return(CVSPILS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSPILS_NO_ADJ, "CVSPILS", "CVSpilsSetPreconditionerBS", MSGS_NO_ADJ);
+    return(CVSPILS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetPreconditionerBS", MSGS_BAD_WHICH);
+    return(CVSPILS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  if (cvB_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSPILS_LMEMB_NULL, "CVSPILS", "CVSpilsSetPreconditionerBS", MSGS_LMEMB_NULL);
+    return(CVSPILS_LMEMB_NULL);
+  }
+  cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
+
+  pset_BS   = psetBS;
+  psolve_BS = psolveBS;
+
+  if (psetBS == NULL) {
+    flag = CVSpilsSetPreconditioner(cvodeB_mem, NULL, cvSpilsPrecSolveBSWrapper);
+  } else {
+    flag = CVSpilsSetPreconditioner(cvodeB_mem, cvSpilsPrecSetupBSWrapper, cvSpilsPrecSolveBSWrapper);
+  }
 
   return(flag);
 }
@@ -1053,6 +1157,61 @@ int CVSpilsSetJacTimesVecFnB(void *cvode_mem, int which, CVSpilsJacTimesVecFnB j
   return(flag);
 }
 
+int CVSpilsSetJacTimesVecFnBS(void *cvode_mem, int which, CVSpilsJacTimesVecFnBS jtvBS)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSpilsMemB cvspilsB_mem; 
+  void *cvodeB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSPILS_MEM_NULL, "CVSPILS", "CVSpilsSetJacTimesVecFnBS", MSGS_CVMEM_NULL);
+    return(CVSPILS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSPILS_NO_ADJ, "CVSPILS", "CVSpilsSetJacTimesVecFnBS", MSGS_NO_ADJ);
+    return(CVSPILS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSPILS_ILL_INPUT, "CVSPILS", "CVSpilsSetJacTimesVecFnBS", MSGS_BAD_WHICH);
+    return(CVSPILS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  if (cvB_mem->cv_lmem == NULL) {
+    cvProcessError(cv_mem, CVSPILS_LMEMB_NULL, "CVSPILS", "CVSpilsSetJacTimesVecFnBS", MSGS_LMEMB_NULL);
+    return(CVSPILS_LMEMB_NULL);
+  }
+  cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
+
+  jtimes_BS = jtvBS;
+
+  if (jtvBS != NULL) {
+    flag = CVSpilsSetJacTimesVecFn(cvodeB_mem, cvSpilsJacTimesVecBSWrapper);
+  } else {
+    flag = CVSpilsSetJacTimesVecFn(cvodeB_mem, NULL);
+  }
+
+  return(flag);
+}
+
 
 /*
  * -----------------------------------------------------------------
@@ -1101,6 +1260,49 @@ static int cvSpilsPrecSetupBWrapper(realtype t, N_Vector yB,
   return(retval);
 }
 
+/*
+ * cvSpilsPrecSetupBSWrapper
+ *
+ * This routine interfaces to the CVSpilsPrecSetupFnBS routine 
+ * provided by the user.
+ */
+
+static int cvSpilsPrecSetupBSWrapper(realtype t, N_Vector yB, 
+                                     N_Vector fyB, booleantype jokB, 
+                                     booleantype *jcurPtrB, realtype gammaB,
+                                     void *cvode_mem,
+                                     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSpilsMemB cvspilsB_mem;
+  int retval, flag;
+
+  cv_mem = (CVodeMem) cvode_mem;
+
+  ca_mem = cv_mem->cv_adj_mem;
+
+  cvB_mem = ca_mem->ca_bckpbCrt;
+
+  cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
+
+  /* Forward solution from interpolation */
+  if (IMinterpSensi)
+    flag = IMget(cv_mem, t, ytmp, yStmp);
+  else
+    flag = IMget(cv_mem, t, ytmp, NULL);
+  if (flag != CV_SUCCESS) {
+    cvProcessError(cv_mem, -1, "CVSPILS", "cvSpilsPrecSetupBSWrapper", MSGS_BAD_TINTERP);
+    return(-1);
+  } 
+
+  /* Call user's adjoint precondB routine */
+  retval = pset_BS(t, ytmp, yStmp, yB, fyB, jokB, jcurPtrB, gammaB,
+                   cvB_mem->cv_user_data, tmp1B, tmp2B, tmp3B);
+
+  return(retval);
+}
 
 /*
  * cvSpilsPrecSolveBWrapper
@@ -1142,6 +1344,48 @@ static int cvSpilsPrecSolveBWrapper(realtype t, N_Vector yB, N_Vector fyB,
   return(retval);
 }
 
+/*
+ * cvSpilsPrecSolveBSWrapper
+ *
+ * This routine interfaces to the CVSpilsPrecSolveFnBS routine 
+ * provided by the user.
+ */
+
+static int cvSpilsPrecSolveBSWrapper(realtype t, N_Vector yB, N_Vector fyB,
+                                     N_Vector rB, N_Vector zB,
+                                     realtype gammaB, realtype deltaB,
+                                     int lrB, void *cvode_mem, N_Vector tmpB)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSpilsMemB cvspilsB_mem;
+  int retval, flag;
+
+  cv_mem = (CVodeMem) cvode_mem;
+
+  ca_mem = cv_mem->cv_adj_mem;
+
+  cvB_mem = ca_mem->ca_bckpbCrt;
+
+  cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
+
+  /* Forward solution from interpolation */
+  if (IMinterpSensi)
+    flag = IMget(cv_mem, t, ytmp, yStmp);
+  else
+    flag = IMget(cv_mem, t, ytmp, NULL);
+  if (flag != CV_SUCCESS) {
+    cvProcessError(cv_mem, -1, "CVSPILS", "cvSpilsPrecSolveBSWrapper", MSGS_BAD_TINTERP);
+    return(-1);
+  }
+
+  /* Call user's adjoint psolveBS routine */
+  retval = psolve_BS(t, ytmp, yStmp, yB, fyB, rB, zB, gammaB, deltaB, 
+                     lrB, cvB_mem->cv_user_data, tmpB);
+
+  return(retval);
+}
 
 /*
  * cvSpilsJacTimesVecBWrapper
@@ -1181,3 +1425,43 @@ static int cvSpilsJacTimesVecBWrapper(N_Vector vB, N_Vector JvB, realtype t,
   return(retval);
 }
 
+/*
+ * cvSpilsJacTimesVecBSWrapper
+ *
+ * This routine interfaces to the CVSpilsJacTimesVecFnBS routine 
+ * provided by the user.
+ */
+
+static int cvSpilsJacTimesVecBSWrapper(N_Vector vB, N_Vector JvB, realtype t, 
+                                       N_Vector yB, N_Vector fyB, 
+                                       void *cvode_mem, N_Vector tmpB)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  CVSpilsMemB cvspilsB_mem;
+  int retval, flag;
+
+  cv_mem = (CVodeMem) cvode_mem;
+
+  ca_mem = cv_mem->cv_adj_mem;
+
+  cvB_mem = ca_mem->ca_bckpbCrt;
+
+  cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
+
+  /* Forward solution from interpolation */
+  if (IMinterpSensi)
+    flag = IMget(cv_mem, t, ytmp, yStmp);
+  else
+    flag = IMget(cv_mem, t, ytmp, NULL);
+  if (flag != CV_SUCCESS) {
+    cvProcessError(cv_mem, -1, "CVSPILS", "cvSpilsJacTimesVecBSWrapper", MSGS_BAD_TINTERP);
+    return(-1);
+  } 
+
+  /* Call user's adjoint jtimesBS routine */
+  retval = jtimes_BS(vB, JvB, t, ytmp, yStmp, yB, fyB, cvB_mem->cv_user_data, tmpB);
+
+  return(retval);
+}
diff --git a/src/cvodes/cvodes_spils_impl.h b/src/cvodes/cvodes_spils_impl.h
index 137c38f..57313f8 100644
--- a/src/cvodes/cvodes_spils_impl.h
+++ b/src/cvodes/cvodes_spils_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:30:42 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common implementation header file for the scaled, preconditioned
  * iterative linear solvers
@@ -18,13 +23,13 @@
 #ifndef _CVSSPILS_IMPL_H
 #define _CVSSPILS_IMPL_H
 
+#include <cvodes/cvodes_spils.h>
+#include "cvodes_impl.h"
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <cvodes/cvodes_spils.h>
-#include "cvodes_impl.h"
-
 /*
  * =================================================================
  * C V S P I L S    I N T E R N A L    C O N S T A N T S
@@ -89,7 +94,7 @@ typedef struct CVSpilsMemRec {
    */
   CVSpilsPrecSetupFn s_pset;
   CVSpilsPrecSolveFn s_psolve;
-  void (*s_pfree)(CVodeMem cv_mem);
+  int (*s_pfree)(CVodeMem cv_mem);
   void *s_P_data;
 
   /* Jacobian times vector compuation
@@ -123,8 +128,13 @@ int CVSpilsPSolve(void *cv_mem, N_Vector r, N_Vector z, int lr);
 /* Difference quotient approximation for Jac times vector */
 
 int CVSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t,
-		    N_Vector y, N_Vector fy, void *data,
-		    N_Vector work);
+                    N_Vector y, N_Vector fy, void *data,
+                    N_Vector work);
+
+/* Auxilliary functions */
+int cvSpilsInitializeCounters(CVSpilsMem cvspils_mem);
+
+
 /*
  * =================================================================
  * PART II:  B A C K W A R D    P R O B L E M S
@@ -143,8 +153,11 @@ int CVSpilsDQJtimes(N_Vector v, N_Vector Jv, realtype t,
 typedef struct CVSpilsMemRecB {
 
   CVSpilsJacTimesVecFnB s_jtimesB;
+  CVSpilsJacTimesVecFnBS s_jtimesBS;
   CVSpilsPrecSetupFnB s_psetB;
+  CVSpilsPrecSetupFnBS s_psetBS;
   CVSpilsPrecSolveFnB s_psolveB;
+  CVSpilsPrecSolveFnBS s_psolveBS;
   void *s_P_dataB;
 
 } *CVSpilsMemB;
diff --git a/src/cvodes/cvodes_sptfqmr.c b/src/cvodes/cvodes_sptfqmr.c
index cbb84ee..90c2169 100644
--- a/src/cvodes/cvodes_sptfqmr.c
+++ b/src/cvodes/cvodes_sptfqmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2011/03/23 22:58:47 $
+ * $Revision: 4923 $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the CVSPTFQMR linear solver.
  * -----------------------------------------------------------------
@@ -34,17 +39,17 @@
 static int CVSptfqmrInit(CVodeMem cv_mem);
 
 static int CVSptfqmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
-			  N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
-			  N_Vector vtemp2, N_Vector vtemp3);
+                          N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1,
+                          N_Vector vtemp2, N_Vector vtemp3);
 
 static int CVSptfqmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
-			  N_Vector ynow, N_Vector fnow);
+                          N_Vector ynow, N_Vector fnow);
 
-static void CVSptfqmrFree(CVodeMem cv_mem);
+static int CVSptfqmrFree(CVodeMem cv_mem);
 
 /* CVSPTFQMR lfreeB function */
 
-static void CVSptfqmrFreeB(CVodeBMem cvB_mem);
+static int CVSptfqmrFreeB(CVodeBMem cvB_mem);
 
 /* 
  * ================================================================
@@ -173,6 +178,8 @@ int CVSptfqmr(void *cvode_mem, int pretype, int maxl)
 
   cvspils_mem->s_last_flag = CVSPILS_SUCCESS;
 
+  cvSpilsInitializeCounters(cvspils_mem);
+
   setupNonNull = FALSE;
 
   /* Check for legal pretype */ 
@@ -200,7 +207,7 @@ int CVSptfqmr(void *cvode_mem, int pretype, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SptfqmrMalloc to allocate workspace for Sptfqmr */
   sptfqmr_mem = NULL;
@@ -249,8 +256,7 @@ static int CVSptfqmrInit(CVodeMem cv_mem)
   sptfqmr_mem = (SptfqmrMem) spils_mem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = nstlpre = 0;
-  njtimes = nfes = 0;
+  cvSpilsInitializeCounters(cvspils_mem);
 
   /* Check for legal combination pretype - psolve */
   if ((pretype != PREC_NONE) && (psolve == NULL)) {
@@ -304,7 +310,7 @@ static int CVSptfqmrSetup(CVodeMem cv_mem, int convfail, N_Vector ypred,
   cvspils_mem = (CVSpilsMem) lmem;
 
   /* Use nst, gamma/gammap, and convfail to set J eval. flag jok */
-  dgamma = ABS((gamma/gammap) - ONE);
+  dgamma = SUNRabs((gamma/gammap) - ONE);
   jbad = (nst == 0) || (nst > nstlpre + CVSPILS_MSBPRE) ||
       ((convfail == CV_FAIL_BAD_J) && (dgamma < CVSPILS_DGMAX)) ||
       (convfail == CV_FAIL_OTHER);
@@ -446,7 +452,7 @@ static int CVSptfqmrSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
  * -----------------------------------------------------------------
  */
 
-static void CVSptfqmrFree(CVodeMem cv_mem)
+static int CVSptfqmrFree(CVodeMem cv_mem)
 {
   CVSpilsMem cvspils_mem;
   SptfqmrMem sptfqmr_mem;
@@ -464,7 +470,7 @@ static void CVSptfqmrFree(CVodeMem cv_mem)
   free(cvspils_mem);
   cv_mem->cv_lmem = NULL;
 
-  return;
+  return(0);
 }
 
 /* 
@@ -560,11 +566,13 @@ int CVSptfqmrB(void *cvode_mem, int which, int pretypeB, int maxlB)
  */
 
 
-static void CVSptfqmrFreeB(CVodeBMem cvB_mem)
+static int CVSptfqmrFreeB(CVodeBMem cvB_mem)
 {
   CVSpilsMemB cvspilsB_mem;
 
   cvspilsB_mem = (CVSpilsMemB) (cvB_mem->cv_lmem);
 
   free(cvspilsB_mem);
+
+  return(0);
 }
diff --git a/src/cvodes/cvodes_superlumt.c b/src/cvodes/cvodes_superlumt.c
new file mode 100644
index 0000000..0f73c7f
--- /dev/null
+++ b/src/cvodes/cvodes_superlumt.c
@@ -0,0 +1,705 @@
+/*
+ * -----------------------------------------------------------------
+ * $Rev $
+ * $Date: 2016-09-19 14:35:51 -0700 (Mon, 19 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the CVSUPERLUMT linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cvodes_impl.h"
+#include "cvodes_sparse_impl.h"
+#include "cvodes/cvodes_superlumt.h"
+#include "sundials/sundials_superlumt_impl.h"
+#include "sundials/sundials_math.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* CVSUPERLUMT linit, lsetup, lsolve, and lfree routines */
+ 
+static int cvSuperLUMTInit(CVodeMem cv_mem);
+
+static int cvSuperLUMTSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+			    N_Vector fpred, booleantype *jcurPtr,
+			    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+static int cvSuperLUMTSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+			    N_Vector ycur, N_Vector fcur);
+
+static int cvSuperLUMTFree(CVodeMem cv_mem);
+
+/* CVKLU lfreeB function */
+static int cvSuperLUMTFreeB(CVodeBMem cvb_mem);
+
+/* 
+ * ================================================================
+ *
+ *                   PART I - forward problems
+ *
+ * ================================================================
+ */
+
+
+/*
+ * -----------------------------------------------------------------
+ * CVSuperLUMT
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the CVODE / SuperLUMT linear solver module.  
+ * CVSUPERLUMT first calls the existing lfree routine if this is not NULL.
+ * Then it sets the cv_linit, cv_lsetup, cv_lsolve, and
+ * cv_lfree fields in (*cv_mem) to be cvSuperLUMTInit, cvSuperLUMTSetup,
+ * cvSuperLUMTSolve, and cvSuperLUMTFree, respectively.
+ * It allocates memory for a structure of type CVsluMemRec and sets
+ * the cv_lmem field in (*cvode_mem) to the address of this structure.
+ * It sets setupNonNull in (*cvode_mem) to TRUE.
+ * Finally, it allocates memory for SuperLUMT.
+ * The return value is CVSLS_SUCCESS = 0, CVSLS_LMEM_FAIL = -1,
+ * or CVSLS_ILL_INPUT = -2.
+ *
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, CVSuperLUMT will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int CVSuperLUMT(void *cvode_mem, int num_threads, int n, int nnz)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+  int *perm_c, *perm_r;
+  int nrhs, panel_size, relax;
+  double *bd;
+  SuperMatrix *B;
+
+  /* Return immediately if cv_mem is NULL. */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (cv_mem->cv_tempv->ops->nvgetarraypointer == NULL) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_BAD_NVECTOR);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  if (cv_mem->cv_lfree != NULL) cv_mem->cv_lfree(cv_mem);
+
+  /* Set five main function fields in cv_mem. */
+  cv_mem->cv_linit  = cvSuperLUMTInit;
+  cv_mem->cv_lsetup = cvSuperLUMTSetup;
+  cv_mem->cv_lsolve = cvSuperLUMTSolve;
+  cv_mem->cv_lfree  = cvSuperLUMTFree;
+
+  /* Get memory for CVSlsMemRec. */
+  cvsls_mem = (CVSlsMem) malloc(sizeof(struct CVSlsMemRec));
+  if (cvsls_mem == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Get memory for SLUMT_data. */
+  slumt_data = (SLUMTData)malloc(sizeof(struct SLUMTDataRec));
+  if (slumt_data == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  cv_mem->cv_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  cvsls_mem->s_jaceval = NULL;
+  cvsls_mem->s_jacdata = cv_mem->cv_user_data;
+
+  /* Allocate memory for the sparse Jacobian */
+  cvsls_mem->s_JacMat = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (cvsls_mem->s_JacMat == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Allocate memory for saved sparse Jacobian */
+  cvsls_mem->s_savedJ = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (cvsls_mem->s_savedJ == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    free(cvsls_mem);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* Set up memory for the permutations */
+  perm_r = (int *)malloc(n*sizeof(int));
+  if (perm_r == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		   MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+  perm_c = (int *)malloc(n*sizeof(int));
+  if (perm_c == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSLS", "cvSuperLUMT", 
+		   MSGSP_MEM_FAIL);
+    free(perm_r);
+    return(CVSLS_MEM_FAIL);
+  }
+  slumt_data->perm_r = perm_r;
+  slumt_data->perm_c = perm_c;
+
+  /* Set default parameters for SuperLU */
+  slumt_data->num_threads = num_threads;
+  slumt_data->diag_pivot_thresh = 1.0;
+
+  /* Allocate structures for SuperLU */
+  slumt_data->Gstat = (Gstat_t *)malloc(sizeof(Gstat_t));
+  slumt_data->s_A = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_AC = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_L = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_U = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_A->Store  = NULL;
+  slumt_data->s_AC->Store = NULL;
+  slumt_data->s_L->Store  = NULL;
+  slumt_data->s_U->Store  = NULL;
+  slumt_data->superlumt_options = (superlumt_options_t *)malloc(sizeof(superlumt_options_t));
+
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  StatAlloc(cvsls_mem->s_JacMat->N, num_threads, panel_size, relax, 
+	    slumt_data->Gstat);
+  
+  /* Create RHS matrix */
+  nrhs = 1;
+  bd = NULL;
+  B = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  B->Store = NULL;
+  dCreate_Dense_Matrix(B, n, nrhs, bd, n, 
+		       SLU_DN, SLU_D, SLU_GE);
+  slumt_data->s_B = B;
+
+  /* Set ordering to COLAMD as the cvode default use.
+     Users can set a different value with CVSuperLUMTSetOrdering,
+     and the user-set value is loaded before any call to factorize the
+     matrix in cvSuperLUMTSetup.  */
+  slumt_data->s_ordering = 3;
+
+  /* Attach linear solver memory to the integrator memory */
+  cvsls_mem->s_solver_data = (void *) slumt_data;
+  cv_mem->cv_lmem = cvsls_mem;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(CVSLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * CVSuperLUMT interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the CVSuperLUMT
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int cvSuperLUMTInit(CVodeMem cv_mem)
+{
+  int num_threads, n;
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+
+  cvsls_mem = (CVSlsMem)cv_mem->cv_lmem;
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  cvsls_mem->s_nje = 0;
+  cvsls_mem->s_first_factorize = 1;
+  cvsls_mem->s_nstlj = 0;
+
+  /* ------------------------------------------------------------
+     Allocate storage and initialize statistics variables. 
+     ------------------------------------------------------------*/
+  n = cvsls_mem->s_JacMat->N;
+  num_threads = slumt_data->num_threads;
+
+  StatInit(n, num_threads, slumt_data->Gstat);
+
+  cvsls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the CVSuperLUMT linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     CVSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int cvSuperLUMTSetup(CVodeMem cv_mem, int convfail, N_Vector ypred, 
+			   N_Vector fpred, booleantype *jcurPtr,
+			   N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  booleantype jbad, jok;
+  int retval, info;
+  int nprocs, panel_size, relax, permc_spec, lwork;
+  int *perm_r, *perm_c;
+  long int nst, nstlj;
+  realtype tn, gamma, gammap, dgamma;
+  double diag_pivot_thresh, drop_tol;
+  fact_t fact;
+  trans_t trans;
+  yes_no_t refact, usepr;
+  CVSlsMem cvsls_mem;
+  CVSlsSparseJacFn jaceval;
+  SuperMatrix *A, *AC, *L, *U;
+  Gstat_t *Gstat;
+  superlumt_options_t *superlumt_options;
+  SLUMTData slumt_data;
+  SlsMat JacMat, savedJ;
+  void *jacdata;
+  void *work;
+  
+  cvsls_mem = (CVSlsMem) (cv_mem->cv_lmem);
+  tn = cv_mem->cv_tn; 
+  gamma = cv_mem->cv_gamma;
+  gammap = cv_mem->cv_gammap;
+  nst = cv_mem->cv_nst;
+
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  jaceval = cvsls_mem->s_jaceval;
+  jacdata = cvsls_mem->s_jacdata;
+  JacMat = cvsls_mem->s_JacMat;
+  savedJ = cvsls_mem->s_savedJ;
+  nstlj = cvsls_mem->s_nstlj;
+
+  superlumt_options = slumt_data->superlumt_options;
+  A = slumt_data->s_A;
+  AC = slumt_data->s_AC;
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  Gstat = slumt_data->Gstat;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  nprocs = slumt_data->num_threads;
+  diag_pivot_thresh = slumt_data->diag_pivot_thresh;
+
+  /* Set option values for SuperLU_MT */
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  fact = EQUILIBRATE;
+  trans = NOTRANS;
+  usepr = NO;
+  drop_tol = 0.0;
+  lwork = 0;
+  work = NULL;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    cvProcessError(cv_mem, CVSLS_JAC_NOSET, "CVSLS", "cvSuperLUMTSetup", 
+		    MSGSP_JAC_NOSET);
+    free(cvsls_mem); cvsls_mem = NULL;
+    return(CVSLS_JAC_NOSET);
+  }
+
+  /* Determine whether Jacobian needs to be recalculated */
+  dgamma = SUNRabs((gamma/gammap) - ONE);
+  jbad = (nst == 0) || (nst > nstlj + CVS_MSBJ) ||
+         ((convfail == CV_FAIL_BAD_J) && (dgamma < CVS_DGMAX)) ||
+         (convfail == CV_FAIL_OTHER);
+  jok = !jbad;
+  
+  if (jok) {
+    /* If jok = TRUE, use saved copy of J */
+    *jcurPtr = FALSE;
+    SparseCopyMat(savedJ, JacMat);
+  } else {
+    /* If jok = FALSE, call jac routine for new J value */
+    cvsls_mem->s_nje++;
+    cvsls_mem->s_nstlj = nst;
+    *jcurPtr = TRUE;
+    SparseSetMatToZero(JacMat);
+    retval = jaceval(tn, ypred, fpred, JacMat, jacdata, vtemp1, vtemp2, vtemp3);
+    if (retval < 0) {
+      cvProcessError(cv_mem, CVSLS_JACFUNC_UNRECVR, "CVSLS", "cvSuperLUMTSetup", MSGSP_JACFUNC_FAILED);
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_UNRECVR;
+      return(-1);
+    }
+    if (retval > 0) {
+      cvsls_mem->s_last_flag = CVSLS_JACFUNC_RECVR;
+      return(1);
+    }
+
+    SparseCopyMat(JacMat, savedJ);
+  }
+
+  /* Scale and add I to get M = I - gamma*J */
+  SparseScaleMat(-gamma, JacMat);
+  SparseAddIdentityMat(JacMat);
+
+  if (A->Store) {
+    SUPERLU_FREE(A->Store);
+  }
+  dCreate_CompCol_Matrix(A, JacMat->M, JacMat->N, JacMat->NNZ, 
+			 JacMat->data, JacMat->indexvals, JacMat->indexptrs, 
+			 SLU_NC, SLU_D, SLU_GE);
+
+  if (cvsls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get column permutation vector perm_c[], according to permc_spec:
+       permc_spec = 3: approximate minimum degree for unsymmetric matrices
+       ------------------------------------------------------------*/ 
+    permc_spec = slumt_data->s_ordering;
+    get_perm_c(permc_spec, A, perm_c);
+
+    refact= NO;
+    cvsls_mem->s_first_factorize = 0;
+  }
+  else {
+    /* ------------------------------------------------------------
+       Re-initialize statistics variables 
+       ------------------------------------------------------------*/
+    StatInit(JacMat->N, nprocs, Gstat);
+    Destroy_CompCol_Permuted(AC);
+    refact= YES;
+  }
+
+  /* ------------------------------------------------------------
+     Initialize the option structure superlumt_options using the
+     user-input parameters;  Subsequent calls will re-initialize
+     options.
+     Apply perm_c to the columns of original A to form AC.
+     ------------------------------------------------------------*/
+  pdgstrf_init(nprocs, fact, trans, refact, panel_size, relax,
+	       diag_pivot_thresh, usepr, drop_tol, perm_c, perm_r,
+	       work, lwork, A, AC, superlumt_options, Gstat);
+  /* ------------------------------------------------------------
+     Compute the LU factorization of A.
+     The following routine will create nprocs threads.
+     ------------------------------------------------------------*/
+  pdgstrf(superlumt_options, AC, perm_r, L, U, Gstat, &info);
+    
+  if (info != 0) {
+    cvsls_mem->s_last_flag = info;
+    return(+1);
+  }
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the CVSuperLUMT linear
+  solver module.  It calls the SuperLU_MT solve routine,
+  then returns CVSLS_SUCCESS = 0.
+*/
+
+static int cvSuperLUMTSolve(CVodeMem cv_mem, N_Vector b, N_Vector weight,
+			    N_Vector ycur, N_Vector fcur)
+{
+  int info, trans, lmm;
+  int *perm_r, *perm_c;
+  realtype gamrat;
+  CVSlsMem cvsls_mem;
+  SuperMatrix *L, *U, *B;
+  Gstat_t *Gstat;
+  DNformat *Bstore;
+  SLUMTData slumt_data;
+  realtype *bd;
+  
+  gamrat = cv_mem->cv_gamrat;
+  lmm = cv_mem->cv_lmm;
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  Gstat = slumt_data->Gstat;
+  B = slumt_data->s_B;
+   
+  bd = N_VGetArrayPointer(b);
+  Bstore = (DNformat *) (B->Store);
+  Bstore->nzval = bd;
+
+  /* Call SuperLUMT to solve the linear system using L and U */
+  trans = NOTRANS;
+  dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, &info);
+
+  /* Scale the correction to account for change in gamma. */
+  if ((lmm == CV_BDF) && (gamrat != ONE)) {
+    N_VScale(TWO/(ONE + gamrat), b, b);
+  }
+
+  Bstore->nzval = NULL;
+
+  cvsls_mem->s_last_flag = CVSLS_SUCCESS;
+  return(CVSLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the CVSuperLUMT linear solver.
+*/
+
+static int cvSuperLUMTFree(CVodeMem cv_mem)
+{
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+  
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  pxgstrf_finalize(slumt_data->superlumt_options, slumt_data->s_AC);
+
+  free(slumt_data->perm_r);
+  free(slumt_data->perm_c);
+  free(slumt_data->superlumt_options);
+  Destroy_SuperNode_SCP( (slumt_data->s_L) );
+  Destroy_CompCol_NCP( (slumt_data->s_U) );
+  StatFree( (slumt_data->Gstat) );
+  free(slumt_data->Gstat);
+  
+  Destroy_SuperMatrix_Store(slumt_data->s_B);
+  SUPERLU_FREE(slumt_data->s_A->Store);
+  if (cvsls_mem->s_JacMat) {
+    SparseDestroyMat(cvsls_mem->s_JacMat);
+    cvsls_mem->s_JacMat = NULL;
+  }
+  if (cvsls_mem->s_savedJ) {
+    SparseDestroyMat(cvsls_mem->s_savedJ);
+    cvsls_mem->s_savedJ = NULL;
+  }
+
+  free(slumt_data->s_B);
+  free(slumt_data->s_A);
+  free(slumt_data->s_AC);
+  free(slumt_data->s_L);
+  free(slumt_data->s_U);
+
+  free(slumt_data); 
+  slumt_data = NULL;
+  free(cv_mem->cv_lmem); 
+
+  return(0);
+}
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * CVSuperLUMTSetOrdering sets the ordering used by SuperLUMT for reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int CVSuperLUMTSetOrdering(void *cv_mem_v, int ordering_choice)
+{
+  CVodeMem cv_mem;
+  CVSlsMem cvsls_mem;
+  SLUMTData slumt_data;
+
+ /* Return immediately if cv_mem is NULL */
+  if (cv_mem_v == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSLS", "CVSuperLUMTSetOrdering",
+		    MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cv_mem_v;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) && (ordering_choice != 3) ) {
+    cvProcessError(NULL, CVSLS_ILL_INPUT, "CVSLS", "CVSuperLUMTSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  cvsls_mem = (CVSlsMem) cv_mem->cv_lmem;
+  slumt_data = (SLUMTData) cvsls_mem->s_solver_data;
+
+  slumt_data->s_ordering = ordering_choice;
+
+  return(CVSLS_SUCCESS);
+}
+
+/* 
+ * ================================================================
+ *
+ *                   PART II - backward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * CVSuperLUMTB is a wrapper around CVSuperLUMT. It attaches the CVSuperLUMT 
+ * linear solver to the backward problem memory block.
+ */
+
+int CVSuperLUMTB(void *cvode_mem, int which, int num_threads, 
+		 int n, int nnz)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  void *cvodeB_mem;
+  CVSlsMemB cvslsB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSSuperLUMT", "CVSuperLUMTB", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSLS_NO_ADJ, "CVSSuperLUMT", "CVSuperLUMTB", MSGSP_NO_ADJ);
+    return(CVSLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSSuperLUMT", "CVSuperLUMTB", MSGSP_BAD_WHICH);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  /* Get memory for CVSlsMemRecB */
+  cvslsB_mem = (CVSlsMemB) malloc(sizeof(struct CVSlsMemRecB));
+  if (cvslsB_mem == NULL) {
+    cvProcessError(cv_mem, CVSLS_MEM_FAIL, "CVSSuperLUMT", "CVSuperLUMTB", MSGSP_MEM_FAIL);
+    return(CVSLS_MEM_FAIL);
+  }
+
+  /* initialize Jacobian function */
+  cvslsB_mem->s_djacB = NULL;
+
+  /* attach lmemB and lfreeB */
+  cvB_mem->cv_lmem = cvslsB_mem;
+  cvB_mem->cv_lfree = cvSuperLUMTFreeB;
+
+  flag = CVSuperLUMT(cvodeB_mem, num_threads, n, nnz);
+
+  if (flag != CVSLS_SUCCESS) {
+    free(cvslsB_mem);
+    cvslsB_mem = NULL;
+  }
+
+  return(flag);
+}
+
+/*
+ * CVSuperLUMTSetOrderingB is a wrapper around CVSuperLUMTSetOrdering. 
+ * CVSuperLUMTSetOrderingB pulls off the memory block associated with the
+ * which parameter and sets the ordering for the solver associated with that block.
+ */
+
+int CVSuperLUMTSetOrderingB(void *cvode_mem, int which, int ordering_choice)
+{
+  CVodeMem cv_mem;
+  CVadjMem ca_mem;
+  CVodeBMem cvB_mem;
+  void *cvodeB_mem;
+  int flag;
+
+  /* Check if cvode_mem exists */
+  if (cvode_mem == NULL) {
+    cvProcessError(NULL, CVSLS_MEM_NULL, "CVSSuperLUMT", "CVSuperLUMTSetOrderingB", MSGSP_CVMEM_NULL);
+    return(CVSLS_MEM_NULL);
+  }
+  cv_mem = (CVodeMem) cvode_mem;
+
+  /* Was ASA initialized? */
+  if (cv_mem->cv_adjMallocDone == FALSE) {
+    cvProcessError(cv_mem, CVSLS_NO_ADJ, "CVSSuperLUMT", "CVSuperLUMTSetOrderingB", MSGSP_NO_ADJ);
+    return(CVSLS_NO_ADJ);
+  } 
+  ca_mem = cv_mem->cv_adj_mem;
+
+  /* Check which */
+  if ( which >= ca_mem->ca_nbckpbs ) {
+    cvProcessError(cv_mem, CVSLS_ILL_INPUT, "CVSSuperLUMT", "CVSuperLUMTSetOrderingB", MSGSP_BAD_WHICH);
+    return(CVSLS_ILL_INPUT);
+  }
+
+  /* Find the CVodeBMem entry in the linked list corresponding to which */
+  cvB_mem = ca_mem->cvB_mem;
+  while (cvB_mem != NULL) {
+    if ( which == cvB_mem->cv_index ) break;
+    cvB_mem = cvB_mem->cv_next;
+  }
+
+  cvodeB_mem = (void *) (cvB_mem->cv_mem);
+
+  flag = CVSuperLUMTSetOrdering(cvodeB_mem, ordering_choice);
+
+  return(flag);
+}
+
+/*
+ * cvSuperLUMTFreeB frees the memory associated with the CVSSuperLUMT linear
+ * solver for backward integration.
+ */
+
+static int cvSuperLUMTFreeB(CVodeBMem cvB_mem)
+{
+  CVSlsMemB cvslsB_mem;
+
+  cvslsB_mem = (CVSlsMemB) (cvB_mem->cv_lmem);
+
+  free(cvslsB_mem);
+
+  return(0);
+}
+
diff --git a/src/ida/CMakeLists.txt b/src/ida/CMakeLists.txt
index 438ee2d..7aa8c84 100644
--- a/src/ida/CMakeLists.txt
+++ b/src/ida/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:48 $
+# $Revision: 4961 $
+# $Date: 2016-09-26 07:58:48 -0700 (Mon, 26 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the IDA library
 
@@ -21,6 +26,7 @@ SET(ida_SOURCES
   ida_direct.c
   ida_band.c
   ida_dense.c
+  ida_sparse.c
   ida_spils.c
   ida_spbcgs.c
   ida_spgmr.c
@@ -28,6 +34,20 @@ SET(ida_SOURCES
   ida_bbdpre.c
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND ida_SOURCES ida_klu.c)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND ida_SOURCES ida_superlumt.c)
+ENDIF()
+
+# IF(PETSC_FOUND)
+#    # use MPI_MPICC as the compiler
+#    SET(CMAKE_C_COMPILER ${MPI_MPICC})
+#    LIST(APPEND ida_SOURCES ida_petsc.c)
+# ENDIF()
+
 # Add variable shared_SOURCES with the common SUNDIALS sources which will
 # also be included in the IDA library
 SET(shared_SOURCES
@@ -37,6 +57,7 @@ SET(shared_SOURCES
   sundials_band.c
   sundials_dense.c
   sundials_iterative.c
+  sundials_sparse.c
   sundials_spbcgs.c
   sundials_spgmr.c
   sundials_sptfqmr.c
@@ -58,6 +79,18 @@ SET(ida_HEADERS
   ida_sptfqmr.h
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND ida_HEADERS ida_klu.h ida_sparse.h)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND ida_HEADERS ida_superlumt.h ida_sparse.h)
+ENDIF()
+
+# IF(PETSC_FOUND)
+#     LIST(APPEND ida_HEADERS ida_petsc.h)
+# ENDIF()
+
 # Add prefix with complete path to the IDA header files
 ADD_PREFIX(${sundials_SOURCE_DIR}/include/ida/ ida_HEADERS)
 
diff --git a/src/ida/LICENSE b/src/ida/LICENSE
index d50d177..94d26a8 100644
--- a/src/ida/LICENSE
+++ b/src/ida/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2002, The Regents of the University of California. 
+Copyright (c) 2002-2015, Lawrence Livermore National Security. 
 Produced at the Lawrence Livermore National Laboratory.
 Written by Alan Hindmarsh, Allan Taylor, Radu Serban.
 UCRL-CODE-155952
diff --git a/src/ida/Makefile.in b/src/ida/Makefile.in
deleted file mode 100644
index 8c83d7a..0000000
--- a/src/ida/Makefile.in
+++ /dev/null
@@ -1,169 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for IDA module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-LIB_REVISION = 2:0:0
-
-IDA_LIB = libsundials_ida.la
-
-IDA_SRC_FILES = ida.c ida_ic.c ida_io.c ida_direct.c ida_dense.c ida_band.c ida_spils.c ida_spbcgs.c ida_spgmr.c ida_sptfqmr.c ida_bbdpre.c
-IDA_BL_SRC_FILES = ida_lapack.c
-
-IDA_OBJ_FILES = $(IDA_SRC_FILES:.c=.o)
-IDA_BL_OBJ_FILES = $(IDA_BL_SRC_FILES:.c=.o)
-
-IDA_LIB_FILES = $(IDA_SRC_FILES:.c=.lo)
-IDA_BL_LIB_FILES = $(IDA_BL_SRC_FILES:.c=.lo)
-
-SHARED_LIB_FILES = $(top_builddir)/src/sundials/sundials_band.lo \
-                   $(top_builddir)/src/sundials/sundials_dense.lo \
-                   $(top_builddir)/src/sundials/sundials_direct.lo \
-                   $(top_builddir)/src/sundials/sundials_iterative.lo \
-                   $(top_builddir)/src/sundials/sundials_spgmr.lo \
-                   $(top_builddir)/src/sundials/sundials_spbcgs.lo \
-                   $(top_builddir)/src/sundials/sundials_sptfqmr.lo \
-                   $(top_builddir)/src/sundials/sundials_math.lo \
-                   $(top_builddir)/src/sundials/sundials_nvector.lo
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(IDA_LIB)
-
-$(IDA_LIB): shared $(IDA_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: shared $(IDA_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(IDA_LIB) $(IDA_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-lib_with_bl: shared $(IDA_LIB_FILES) $(IDA_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(IDA_LIB) $(IDA_LIB_FILES) $(IDA_BL_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-install: $(IDA_LIB)
-	$(mkinstalldirs) $(includedir)/ida
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(IDA_LIB) $(libdir)
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida.h         $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_direct.h  $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_dense.h   $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_band.h    $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_spbcgs.h  $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_spgmr.h   $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_sptfqmr.h $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_bbdpre.h  $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_spils.h   $(includedir)/ida/
-	$(INSTALL_HEADER) $(top_srcdir)/src/ida/ida_impl.h        $(includedir)/ida/
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  $(INSTALL_HEADER) $(top_srcdir)/include/ida/ida_lapack.h  $(includedir)/ida/ ; \
-	fi
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(IDA_LIB)
-	rm -f $(includedir)/ida/ida.h
-	rm -f $(includedir)/ida/ida_direct.h
-	rm -f $(includedir)/ida/ida_dense.h
-	rm -f $(includedir)/ida/ida_band.h
-	rm -f $(includedir)/ida/ida_lapack.h
-	rm -f $(includedir)/ida/ida_spbcgs.h
-	rm -f $(includedir)/ida/ida_spgmr.h
-	rm -f $(includedir)/ida/ida_sptfqmr.h
-	rm -f $(includedir)/ida/ida_bbdpre.h
-	rm -f $(includedir)/ida/ida_spils.h
-	rm -f $(includedir)/ida/ida_impl.h
-	$(rminstalldirs) ${includedir}/ida
-
-shared:
-	@cd ${top_builddir}/src/sundials ; \
-	 ${MAKE} ;                         \
-	 cd ${abs_builddir}
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(IDA_LIB)
-	rm -f $(IDA_LIB_FILES)
-	rm -f $(IDA_BL_LIB_FILES)
-	rm -f $(IDA_OBJ_FILES)
-	rm -f $(IDA_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-ida.lo: $(srcdir)/ida.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida.c
-ida_ic.lo: $(srcdir)/ida_ic.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_ic.c
-ida_io.lo: $(srcdir)/ida_io.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_io.c
-ida_direct.lo: $(srcdir)/ida_direct.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_direct.c
-ida_dense.lo: $(srcdir)/ida_dense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_dense.c
-ida_band.lo: $(srcdir)/ida_band.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_band.c
-ida_lapack.lo: $(srcdir)/ida_lapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_lapack.c
-ida_spils.lo: $(srcdir)/ida_spils.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_spils.c
-ida_spbcgs.lo: $(srcdir)/ida_spbcgs.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_spbcgs.c
-ida_spgmr.lo: $(srcdir)/ida_spgmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_spgmr.c
-ida_sptfqmr.lo: $(srcdir)/ida_sptfqmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_sptfqmr.c
-ida_bbdpre.lo: $(srcdir)/ida_bbdpre.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/ida_bbdpre.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/ida/README b/src/ida/README
index b8e6d8b..f11af32 100644
--- a/src/ida/README
+++ b/src/ida/README
@@ -1,5 +1,5 @@
                                IDA
-                    Release 2.7.0, March 2012
+                    Release 2.9.0, September 2016
                  Alan C. Hindmarsh and Radu Serban 
             Center for Applied Scientific Computing, LLNL
 
@@ -8,12 +8,12 @@ IDA is a package for the solution of differential-algebraic equation
 (DAE) systems.  It is written in C, but derived from the package DASPK
 [4,5], which is written in FORTRAN. 
 
-IDA can be used both on serial and parallel (MPI) computers.  The main
+IDA can be used both on serial and parallel computers.  The main
 difference is in the NVECTOR module of vector kernels.  The desired
 version is obtained when compiling the example files by linking the
-appropriate library of NVECTOR kernels.  In the parallel version,
-communication between processors is done with the MPI (Message Passage
-Interface) system.
+appropriate library of NVECTOR kernels.  In the parallel versions,
+communication between processors is done with MPI, with OpenMP, 
+or with Pthreads.
 
 When used with the serial NVECTOR module, IDA provides both direct 
 (dense and band) linear solvers and preconditioned Krylov (iterative) 
@@ -27,8 +27,8 @@ preconditioner.
 
 IDA is part of a software family called SUNDIALS: SUite of Nonlinear and 
 DIfferential/ALgebraic equation Solvers [3].  This suite consists of CVODE, 
-CVODES, IDA, IDAS, and KINSOL.  The directory structure of the package supplied 
-reflects this family relationship.
+CVODES, ARKode, IDA, IDAS, and KINSOL.  The directory structure of the 
+package supplied reflects this family relationship.
 
 For use with Fortran applications, a set of Fortran/C interface routines,
 called FIDA, is also supplied.  These are written in C, but assume that
@@ -53,19 +53,19 @@ and the IDA Examples [2] (ida_examples.pdf) documents.
 B. Installation
 ---------------
 
-For basic installation instructions see the file /sundials/INSTALL_NOTES. 
-For complete installation instructions see the "IDA Installation Procedure"
+For basic installation instructions see the file /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see the "Installation Procedure"
 chapter in the IDA User Guide.
 
 
 C. References
 -------------
 
-[1] A. C. Hindmarsh, R. Serban, and A. Collier, "User Documentation for IDA v2.7.0," 
-    LLNL technical report UCRL-SM-208112, December 2011.
+[1] A. C. Hindmarsh, R. Serban, and A. Collier, "User Documentation for IDA v2.9.0," 
+    LLNL technical report UCRL-SM-208112, March 2016.
 
-[2] A. C. Hindmarsh, R. Serban, and A. Collier, "Example Programs for IDA v2.7.0," 
-    LLNL technical report UCRL-SM-208113, December 2011.
+[2] A. C. Hindmarsh, R. Serban, and A. Collier, "Example Programs for IDA v2.9.0," 
+    LLNL technical report UCRL-SM-208113, March 2016.
 
 [3] A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, 
     D. E. Shumaker, and C. S. Woodward, "SUNDIALS, Suite of Nonlinear and 
@@ -84,7 +84,11 @@ C. References
 D. Releases
 -----------
 
-v. 2.6.0   - Mar. 2012
+v. 2.9.0   - Sep. 2016
+v. 2.8.2   - Aug. 2015
+v. 2.8.1   - Mar. 2015
+v. 2.8.0   - Mar. 2015
+v. 2.7.0   - Mar. 2012
 v. 2.6.0   - May  2009
 v. 2.5.0   - Nov. 2006
 v. 2.4.0   - Mar. 2006
@@ -94,302 +98,3 @@ v. 2.2.1   - Jan. 2005
 v. 2.2.0   - Dec. 2004
 v. 2.0     - Jul. 2002 (first SUNDIALS release)
 v. 1.0     - Feb. 1999 (date written)
-
-
-E. Revision History
--------------------
-
-v. 2.6.0 (May 2009) ---> v. 2.7.0 (Mar. 2012)
----------------------------------------------
-
-- Bug fixes
-   - after the solver memory is created, it is set to zero before being filled.
-   - to be consistent with IDAS, IDA uses the function IDAGetDky for
-     optional output retrieval.
-   - in each linear solver interface function, the linear solver memory is
-     freed on an error return, and the **Free function now includes a
-     line setting to NULL the main memory pointer to the linear solver memory.
-   - a memory leak was fixed in two of the IDASp***Free functions.
-   - in rootfinding functions IDARcheck1/IDARcheck2, when an exact zero is found,
-     the array glo at the left endpoint is adjusted instead of shifting tlo.
-
-- Changes to user interface
-   - One significant design change was made with this release: The problem
-     size and its relatives, bandwidth parameters, related internal indices,
-     pivot arrays, and the optional output lsflag, have all been
-     changed from type int to type long int, except for the
-     problem size and bandwidths in user calls to routines specifying
-     BLAS/LAPACK routines for the dense/band linear solvers.  The function
-     NewIntArray is replaced by a pair NewIntArray/NewLintArray,
-     for int and long int arrays, respectively.
-   - in the installation files, we modified the treatment of the macro
-     SUNDIALS_USE_GENERIC_MATH, so that the parameter GENERIC_MATH_LIB
-     is either defined (with no value) or not defined.
-
-
-v. 2.5.0 (Nov. 2006) ---> v. 2.6.0 (May 2009)
----------------------------------------------
-
-- New features
-   - added a new linear solver module based on Blas + Lapack for
-     both dense and banded matrices.
-   - added optional input to specify which direction of zero-crossing
-     is to be monitored while performing root-finding. The root information
-     array iroots (returned by IDAGetRootInfo) also encodes the 
-     direction of zero-crossing.
-
-- Bug fixes
-   - in the rootfinding algorithm, fixed a bug resulting in unnecessary
-     evaluations of the root functions after reinitialization of the
-     solver right after a return at a root.
-
-- Changes to user interface
-   - renamed all **Malloc functions to **Init
-   - tolerances are now specified through separate functions instead of
-     the initialization functions IDAInit (former IDAMalloc) and 
-     IDAReInit. Depending on the tolerance type, one of 3 functions
-     must be called before the first call to IDASolve.
-   - removed function inputs from argument lists of all re-initialization
-     functions.
-   - all user-supplied functions now receive the same pointer to user data
-     (instead of having different ones for the system evaluation, Jacobian
-     information functions, etc.)
-   - removed IDA_NORMAL_TSTOP and IDA_ONE_STEP_TSTOP named constants for the
-     itask argument to IDASolve. A tstop value is now both set and activated
-     through IDASetStopTime. Once tstop is reached it is also deactivated.
-     A new value can be then specified by calling again IDASetStopTime.
-   - common functionality for all direct linear solvers (dense, band, and
-     the new Lapack solver) has been collected into the DLS (Direct Linear
-     Solver) module, similar to the SPILS module for the iterative linear 
-     solvers. All optional input and output functions for these linear 
-     solver now have the prefix 'IDADls'. In addition, in order to include
-     the new Lapack-based linear solver, all dimensions for these linear
-     solvers (problem sizes, bandwidths, etc) are now of type 'int' 
-     (instead of 'long int').
-   - the initialization function for the preconditioner module IDABBDPRE
-     was renamed IDABBDInit (from IDABBDAlloc) and it does not return
-     a pointer to preconditioner memory anymore. Instead, all preconditioner
-     module-related functions are now called with the main solver memory 
-     pointer as their first argument. When using the IDABBDPRE module,
-     there is no need to use special functions to attach one of the SPILS
-     linear solvers (instead use one of IDASpgmr, IDASpbcg, or IDASptfqmr).
-     Moreover, there is no need to call a memory deallocation function for
-     the preconditioner module.
-   - minor changes to legality requirements for real optional inputs.
-   - added the error return IDA_RTFUNC_FAIL.
-   - changes corresponding to the above were made to the FCMIX interface.
-
-v. 2.4.0 (Mar. 2006) ---> v. 2.5.0 (Oct. 2006)
-----------------------------------------------
-
-- Bug fixes
-   - fixed wrong logic in final stopping tests: now we check if
-     tout was reached before checking if tstop was reached.
-   - added a roundoff factor when testing whether tn was just returned
-     (in root finding) to prevent an unnecessary return.
-   - fixed perturbation factor "underflow" issue in IDADenseDQJac and
-     IDABandDQJac routines which are used to compute a difference quotient
-     approximation to the system Jacobian (see IDA_P1).
-
-- Changes related to the build system
-   - reorganized source tree: header files in ${srcdir}/include/ida,
-     source files in ${srcdir}/src/ida, fcmix source files in
-     ${srcdir}/src/ida/fcmix, examples in ${srcdir}/examples/ida
-   - exported header files are installed unde ${includedir}/ida
-
-- Changes to user interface
-   - all included header files use relative paths from ${includedir}
-   - modified prototype and implementation of IDACalcIC (removed
-     arguments t0, yy0, yp0). IDACalcIC will always correct the
-     initial conditions passed through IDAMalloc (or IDAReInit)
-     which were stored in the Nordsieck history array
-   - added optional output IDAGetConsistentIC function (which can 
-     only be called before any IDASolve calls) to obtain the corrected 
-     initial conditions.
-
-v. 2.3.0 (Apr. 2005) ---> v. 2.4.0 (Mar. 2006)
-----------------------------------------------
-
-- New features
-   - added IDASPBCG interface module to allow IDA to interface with the
-     shared SPBCG (scaled preconditioned Bi-CGSTAB) linear solver module.
-   - added IDASPTFQMR interface module to allow IDA to interface with the
-     shared SPTFQMR (scaled preconditioned TFQMR) linear solver module.
-   - added support for SPBCG and SPTFQMR to the IDABBDPRE preconditioner module.
-   - added FIDA (Fortran interface to IDA).
-   - added rootfinding feature in IDA; modified irobx example problem.
-   - added support for interpreting failures in user-supplied functions.
-
-- Changes to user-callable functions
-   - changed argument of IDAFree and IDABBDPrecFree to be the address 
-     of the respective memory block pointer, so that its NULL value is 
-     propagated back to the calling function.
-   - added IDASPBCG module which defines appropriate IDSpbcg* functions to
-     allow IDA to interface with the shared SPBCG linear solver module.
-   - added IDABBDSpbcg function to IDABBDPRE module to support SPBCG linear
-     solver module.
-   - changed function type names (not the actual definition) to accomodate
-     all the Scaled Preconditioned Iterative Linear Solvers now available:
-       IDASpgmrJactimesVecFn -> IDASpilsJacTimesVecFn
-       IDASpgmrPrecSetupFn   -> IDASpilsPrecSetupFn
-       IDASpgmrPrecSolveFn   -> IDASpilsPrecSolveFn
-   - changed some names for IDABBDPRE function outputs
-   - added option for user-supplied error handler function.
-   - added IDAGetEstLocalErrors() to return estimated local errors.
-   - renamed all exported header files (except for ida.h, all header files
-     have the prefix 'ida_')
-   - changed naming scheme for IDA examples
-
-- Changes related to the build system
-   - the main IDA header file (ida.h) is still exported to the install include
-     directory. However, all other IDA header files are exported into an 'ida'
-     subdirectory of the install include directory.
-   - the IDA library now contains all shared object files (there is no separate
-     libsundials_shared library anymore)
-
-v. 2.2.2 (Mar. 2005) ---> v. 2.3.0 (Apr. 2005)
-----------------------------------------------
-
-- New features
-   - added option for user-provided error weight computation function
-     (of type IDAEwtFn specified through IDASetEwtFn).
-
-- Changes to user interface
-   - IDA now stores tolerances through values rather than references 
-     (to resolve potential scoping issues). 
-   - IDA now stores the constraints and id vectors (if defined) through
-     values ratherthan references.
-   - IDA now passes information back to the user through values rather
-     than references (error weights)
-   - IDAMalloc, IDAReInit, IDASetTolerances: added option itol=IDA_WF 
-     to indicate user-supplied function for computing the error weights; 
-     reltol is now declared as realtype. Note that it is now illegal to call
-     IDASetTolerances before IDAMalloc. It is now legal to deallocate
-     the absolute tolerance N_Vector right after its use.
-   - IDAGetErrorWeights: the user is now responsible for allocating space
-     for the N_Vector in which error weights will be copied.
-   - IDACalcIC takes as additional arguments (t0,y0,yp0). As a consequence,
-     it can be called at any time to correct a pair (y,y').
-   - Passing a value of 0 for the maximum step size or for maxsteps results 
-     in the solver using the corresponding default value (infinity, and 500, 
-     respectively)
-   - Several optional input functions were combined into a single one
-     (IDADenseSetJacFn and IDADenseSetJacData, IDABandSetJacFn and IDABandSetJacData, 
-     IDASpgmrSetPrecSolveFn and IDASpgmrSetPrecSetFn and IDASpgmrSetPrecData, 
-     IDASpgmrSetJacTimesVecFn and IDASpgmrSetJacData).
-
-v. 2.2.1 (Jan. 2005) ---> v. 2.2.2 (Mar. 2005)
-----------------------------------------------
-
-- Bug fixes
-   - changed implicit type conversion to explicit in check_flag() routine in
-     examples to avoid C++ compiler errors
-
-- Changes to documentation
-   - added section with numerical values of all input and output solver constants
-   - added more detailed notes on the type of absolute tolerances
-   - fixed several typos and removed reference to inexistent function IDASetMinStep 
-   - added description of --with-mpi-flags option
-
-- Changes related to the build system
-   - fixed autoconf-related bug to allow configuration with the PGI Fortran compiler
-   - modified to use customized detection of the Fortran name mangling scheme 
-     (autoconf's AC_F77_WRAPPERS routine is problematic on some platforms)
-   - added --with-mpi-flags as a configure option to allow user to specify
-     MPI-specific flags
-   - updated Makefiles for Fortran examples to avoid C++ compiler errors (now use
-     CC and MPICC to link)
-
-
-v. 2.2.0 (Dec. 2004) ---> v. 2.2.1 (Jan. 2005)
-----------------------------------------------
-
-- Changes related to the build system
-   - changed order of compiler directives in header files to avoid compilation
-     errors when using a C++ compiler.
-
-- Changes to documentation
-   - fixed various mistakes and typos in the user guide and example program
-     documents.
-
-v. 2.0 (Jul. 2002) ---> v. 2.2.0 (Dec. 2004)
---------------------------------------------
-
-- New features
-   - added option to disable all error messages.
-
-- Bug fixes
-   - in the solution of the nonlinear system, the correction for small constraint 
-     violation is to ee, not y.
-   - besides delaying the order increase until the 2nd step, we now also delay
-     doubling the step size, to avoid using information from times before t0.
-
-- Changes related to the NVECTOR module 
-  (see also the file sundials/shared/README)
-   - removed machEnv, redefined table of vector operations (now contained
-     in the N_Vector structure itself).
-   - all IDA functions create new N_Vector variables through cloning, using
-     an N_Vector passed by the user as a template.
-
-- Changes to type names and IDA constants
-   - removed type 'integertype'; instead use int or long int, as appropriate.
-   - restructured the list of return values from the various IDA functions.
-   - changed all IDA constants (inputs and return values) to have the
-     prefix 'IDA_' (e.g. IDA_SUCCESS).
-   - renamed various function types to have the prefix 'IDA' (e.g. IDAResFn).
-
-- Changes to optional input/ouput
-   - added IDASet* and IDAGet* functions for optional inputs/outputs, 
-     replacing the arrays iopt and ropt.
-   - added new optional inputs (e.g. maximum number of Newton iterations,
-     maximum number of convergence failures, etc).
-   - added new function IDAGetSolution for dense output.
-   - the value of the last return flag from any function within a linear
-     solver module can be obtained as an optional output (e.g. IDADenseGetLastFlag).
-  
-- Changes to user-callable functions
-   - added new function IDACreate which initializes the IDA solver
-     object and returns a pointer to the IDA memory block.
-   - removed N (problem size) from all functions except the initialization
-     functions for the direct linear solvers (IDADense and IDABand).
-   - shortened argument lists of most IDA functions (the arguments that
-     were dropped can now be specified through IDASet* functions).
-   - removed reinitialization functions for band/dense/SPGMR linear
-     solvers (same functionality can be obtained using IDA*Set* functions).
-   - in IDABBDPRE, added a new function, IDABBDSpgmr to initialize the
-     SPGMR linear solver with the BBD preconditioner.
-   - function names changed in IDABBDPRE for uniformity.
-
-- Changes to user-supplied functions
-   - removed N (probem dimension) from argument lists.
-   - shortened argument lists for user dense/band/SPGMR Jacobian routines.
-   - in IDASPGMR, shortened argument lists for user preconditioner functions.
-   - in IDABBDPRE, added Nlocal, the local vector size, as an argument to 
-     IDABBDLocalFn and IDABBDCommFn.
-
-v. 1.0 (Feb. 1999) ---> v. 2.0 (Jul. 2002)
-------------------------------------------
-
-YYYYMMDD
-
-19990212  DATE WRITTEN; initial internal release (incomplete).
-19990514  IDABBDPRE preconditioner module added.
-19990720  Initial condition calculation routines (IDACalcIC) added.
-19991208  In IDABBDPRE, user routine argument lists changed.
-19991217  Generic SPGMR module revised to correct scalings.
-20000316  In parallel NVECTOR, comm arg. to PVecInitMPI is non-NULL.
-20000808  Fixed bug in N_VMin.  In IDACalcIC: added calculation of system
-          index in CALC_YA_YDP_INIT case, added scaling of fnorm when index = 0.
-20010110  Fixed two bugs in IDACalcIC and subordinate routines:
-          (1) Set hh in IDACalcIC independent of icopt, for lsetup.
-          (2) Set ypnew = yp0 in IDALineSrch in CALC_Y_INIT case.
-          Corrected #define ncfl0 line in idaspgmr.c.
-20011015  Fixed bug in IDAInterp (tn test).
-          Fixed minor bugs in error messages (missing arguments etc.)
-20011220  Default type 'integer' changed to 'long int' in llnltyps.h.
-20020313  Modified to work with new NVECTOR abstraction.
-20020626  Renamed types real, integer, boole as realtype, integertype,
-          and booleantype, and renamed related constants.  Renamed files
-          llnlmath.*, llnltypes.h as sundialsmath.*, sundialstypes.h.
-20020703  Added reinitialization routines for IDA, for each linear
-          solver module, and for IDABBDPRE.
diff --git a/src/ida/fcmix/CMakeLists.txt b/src/ida/fcmix/CMakeLists.txt
index d1a4ae5..1a4944b 100644
--- a/src/ida/fcmix/CMakeLists.txt
+++ b/src/ida/fcmix/CMakeLists.txt
@@ -18,6 +18,24 @@ ELSE(LAPACK_FOUND)
   SET(fida_BL_SOURCES "")
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND OR SUPERLUMT_FOUND)
+  SET(fida_SPARSE_SOURCES fidasparse.c)
+ELSE(SPARSE_FOUND)
+  SET(fida_SPARSE_SOURCES "")
+ENDIF(KLU_FOUND OR SUPERLUMT_FOUND)
+ 
+IF(KLU_FOUND)
+  SET(fida_KLU_SOURCES fidaklu.c)
+ELSE(KLU_FOUND)
+  SET(fida_KLU_SOURCES "")
+ENDIF(KLU_FOUND)
+ 
+IF(SUPERLUMT_FOUND)
+  SET(fida_SUPERLUMT_SOURCES fidasuperlumt.c)
+ELSE(SUPERLUMT_FOUND)
+  SET(fida_SUPERLUMT_SOURCES "")
+ENDIF(SUPERLUMT_FOUND)
+
 # Add source directories to include directories for access to
 # implementation only header files (both for fida and ida)
 INCLUDE_DIRECTORIES(.)
@@ -31,7 +49,7 @@ ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
 # coming from inexistent user-provided functions)
 
 # Add the build target for the FIDA library
-ADD_LIBRARY(sundials_fida_static STATIC ${fida_SOURCES} ${fida_BL_SOURCES})
+ADD_LIBRARY(sundials_fida_static STATIC ${fida_SOURCES} ${fida_BL_SOURCES} ${fida_SPARSE_SOURCES} ${fida_KLU_SOURCES} ${fida_SUPERLUMT_SOURCES})
 
 # Set the library name and make sure it is not deleted
 SET_TARGET_PROPERTIES(sundials_fida_static
diff --git a/src/ida/fcmix/Makefile.in b/src/ida/fcmix/Makefile.in
deleted file mode 100644
index 58a5e8d..0000000
--- a/src/ida/fcmix/Makefile.in
+++ /dev/null
@@ -1,123 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.8 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2005, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FIDA module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/ida -I$(top_builddir)/include
-
-LIB_REVISION = 1:0:0
-
-FIDA_LIB = libsundials_fida.la
-
-FIDA_SRC_FILES = fida.c fidaband.c fidadense.c fidajtimes.c fidapreco.c fidaewt.c fidaroot.c fidabbd.c 
-FIDA_BL_SRC_FILES = fidalapack.c fidalapdense.c fidalapband.c
-
-FIDA_OBJ_FILES = $(FIDA_SRC_FILES:.c=.o)
-FIDA_BL_OBJ_FILES = $(FIDA_BL_SRC_FILES:.c=.o)
-
-FIDA_LIB_FILES = $(FIDA_SRC_FILES:.c=.lo)
-FIDA_BL_LIB_FILES = $(FIDA_BL_SRC_FILES:.c=.lo)
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(FIDA_LIB)
-
-$(FIDA_LIB): $(FIDA_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: $(FIDA_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(FIDA_LIB) $(FIDA_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -static -version-info $(LIB_REVISION)
-
-lib_with_bl: $(FIDA_LIB_FILES) $(FIDA_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(FIDA_LIB) $(FIDA_LIB_FILES) $(FIDA_BL_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -static -version-info $(LIB_REVISION)
-
-install: $(FIDA_LIB)
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(FIDA_LIB) $(libdir)
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(FIDA_LIB)
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(FIDA_LIB)
-	rm -f $(FIDA_LIB_FILES)
-	rm -f $(FIDA_BL_LIB_FILES)
-	rm -f $(FIDA_OBJ_FILES)
-	rm -f $(FIDA_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-fida.lo: $(srcdir)/fida.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fida.c
-fidaewt.lo: $(srcdir)/fidaewt.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidaewt.c
-fidaband.lo: $(srcdir)/fidaband.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidaband.c
-fidadense.lo: $(srcdir)/fidadense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidadense.c
-fidalapack.lo: $(srcdir)/fidalapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidalapack.c
-fidalapband.lo: $(srcdir)/fidalapband.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidalapband.c
-fidalapdense.lo: $(srcdir)/fidalapdense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidalapdense.c
-fidajtimes.lo: $(srcdir)/fidajtimes.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidajtimes.c
-fidapreco.lo: $(srcdir)/fidapreco.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidapreco.c
-fidabbd.lo: $(srcdir)/fidabbd.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidabbd.c
-fidaroot.lo: $(srcdir)/fidaroot.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fidaroot.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/ida/fcmix/fida.c b/src/ida/fcmix/fida.c
index 9336f47..e504d19 100644
--- a/src/ida/fcmix/fida.c
+++ b/src/ida/fcmix/fida.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2010/12/01 22:37:20 $
+ * $Revision: 4825 $
+ * $Date: 2016-07-26 15:56:58 -0700 (Tue, 26 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the Fortran interface to
  * the IDA package. See fida.h for usage.
@@ -26,6 +31,8 @@
 
 #include <ida/ida_band.h>    /* prototypes for IDABAND interface routines      */
 #include <ida/ida_dense.h>   /* prototypes for IDADENSE interface routines     */
+#include <ida/ida_klu.h>     /* prototypes for IDAKLU interface routines       */
+#include <ida/ida_superlumt.h> /* prototypes for IDASUPERLUMT interface routines */
 #include <ida/ida_sptfqmr.h> /* prototypes for IDASPTFQMR interface routines   */
 #include <ida/ida_spbcgs.h>  /* prototypes for IDASPBCG interface routines     */
 #include <ida/ida_spgmr.h>   /* prototypes for IDASPGMR interface routines     */
@@ -244,27 +251,27 @@ void FIDA_REINIT(realtype *t0, realtype *yy0, realtype *yp0,
 
 /*************************************************/
 
-void FIDA_SETIIN(char key_name[], long int *ival, int *ier, int key_len)
+void FIDA_SETIIN(char key_name[], long int *ival, int *ier)
 {
-  if (!strncmp(key_name,"MAX_ORD", (size_t)key_len)) 
+  if (!strncmp(key_name,"MAX_ORD",7))
     *ier = IDASetMaxOrd(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NSTEPS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NSTEPS",10))
     *ier = IDASetMaxNumSteps(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_ERRFAIL", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_ERRFAIL",11))
     *ier = IDASetMaxErrTestFails(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NITERS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NITERS",10))
     *ier = IDASetMaxNonlinIters(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_CONVFAIL", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_CONVFAIL",12))
     *ier = IDASetMaxConvFails(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"SUPPRESS_ALG", (size_t)key_len)) 
+  else if (!strncmp(key_name,"SUPPRESS_ALG",12))
     *ier = IDASetSuppressAlg(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NSTEPS_IC", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NSTEPS_IC",13))
     *ier = IDASetMaxNumStepsIC(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NITERS_IC", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NITERS_IC",13)) 
     *ier = IDASetMaxNumItersIC(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NJE_IC", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NJE_IC",10))
     *ier = IDASetMaxNumJacsIC(IDA_idamem, (int) *ival);
-  else if (!strncmp(key_name,"LS_OFF_IC", (size_t)key_len)) 
+  else if (!strncmp(key_name,"LS_OFF_IC",9))
     *ier = IDASetLineSearchOffIC(IDA_idamem, (int) *ival);
   else {
     *ier = -99;
@@ -275,20 +282,20 @@ void FIDA_SETIIN(char key_name[], long int *ival, int *ier, int key_len)
 
 /***************************************************************************/
 
-void FIDA_SETRIN(char key_name[], realtype *rval, int *ier, int key_len)
+void FIDA_SETRIN(char key_name[], realtype *rval, int *ier)
 {
 
-  if (!strncmp(key_name,"INIT_STEP", (size_t)key_len)) 
+  if (!strncmp(key_name,"INIT_STEP",9))
     *ier = IDASetInitStep(IDA_idamem, *rval);
-  else if (!strncmp(key_name,"MAX_STEP", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_STEP",8))
     *ier = IDASetMaxStep(IDA_idamem, *rval);
-  else if (!strncmp(key_name,"STOP_TIME", (size_t)key_len)) 
+  else if (!strncmp(key_name,"STOP_TIME",9))
     *ier = IDASetStopTime(IDA_idamem, *rval);
-  else if (!strncmp(key_name,"NLCONV_COEF", (size_t)key_len)) 
-    *ier = IDASetNonlinConvCoef(IDA_idamem, *rval);
-  else if (!strncmp(key_name,"NLCONV_COEF_IC", (size_t)key_len)) 
+  else if (!strncmp(key_name,"NLCONV_COEF_IC",14))
     *ier = IDASetNonlinConvCoefIC(IDA_idamem, *rval);
-  else if (!strncmp(key_name,"STEP_TOL_IC", (size_t)key_len)) 
+  else if (!strncmp(key_name,"NLCONV_COEF",11))
+    *ier = IDASetNonlinConvCoef(IDA_idamem, *rval);
+  else if (!strncmp(key_name,"STEP_TOL_IC",11))
     *ier = IDASetStepToleranceIC(IDA_idamem, *rval);
   else {
     *ier = -99;
@@ -299,13 +306,13 @@ void FIDA_SETRIN(char key_name[], realtype *rval, int *ier, int key_len)
 
 /*************************************************/
 
-void FIDA_SETVIN(char key_name[], realtype *vval, int *ier, int key_len)
+void FIDA_SETVIN(char key_name[], realtype *vval, int *ier)
 {
   N_Vector Vec;
 
   *ier = 0;
 
-  if (!strncmp(key_name,"ID_VEC", (size_t)key_len)) {
+  if (!strncmp(key_name,"ID_VEC",6)) {
     Vec = NULL;
     Vec = N_VCloneEmpty(F2C_IDA_vec);
     if (Vec == NULL) {
@@ -315,7 +322,7 @@ void FIDA_SETVIN(char key_name[], realtype *vval, int *ier, int key_len)
     N_VSetArrayPointer(vval, Vec);
     IDASetId(IDA_idamem, Vec);
     N_VDestroy(Vec);
-  } else if (!strncmp(key_name,"CONSTR_VEC", (size_t)key_len)) {
+  } else if (!strncmp(key_name,"CONSTR_VEC",10)) {
     Vec = NULL;
     Vec = N_VCloneEmpty(F2C_IDA_vec);
     if (Vec == NULL) {
@@ -336,12 +343,10 @@ void FIDA_SETVIN(char key_name[], realtype *vval, int *ier, int key_len)
 
 void FIDA_TOLREINIT(int *iatol, realtype *rtol, realtype *atol, int *ier)
 {
-  int itol;
   N_Vector Vatol=NULL;
 
   *ier = 0;
 
-  itol = -1;
   if (*iatol == 1) {
     *ier = IDASStolerances(IDA_idamem, *rtol, *atol);
   } else {
@@ -629,6 +634,11 @@ void FIDA_SOLVE(realtype *tout, realtype *tret, realtype *yret,
     IDADlsGetNumResEvals(IDA_idamem, &IDA_iout[15]);                /* NRE */
     IDADlsGetNumJacEvals(IDA_idamem, &IDA_iout[16]);                /* NJE */
     break;
+  case IDA_LS_KLU:
+  case IDA_LS_SUPERLUMT:
+    IDASlsGetLastFlag(IDA_idamem, &IDA_iout[14]);                  /* LSTF  */
+    IDASlsGetNumJacEvals(IDA_idamem, &IDA_iout[16]);               /* NJE   */
+    break;
   case IDA_LS_SPGMR:
   case IDA_LS_SPBCG:
   case IDA_LS_SPTFQMR:
@@ -651,6 +661,9 @@ void FIDA_SOLVE(realtype *tout, realtype *tret, realtype *yret,
 
 void FIDA_GETDKY(realtype *t, int *k, realtype *dky, int *ier)
 {
+  /* Store existing F2C_IDA_vec data pointer */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_IDA_vec);
+
   /* Attach user data to vectors */
   N_VSetArrayPointer(dky, F2C_IDA_vec);
 
@@ -658,7 +671,7 @@ void FIDA_GETDKY(realtype *t, int *k, realtype *dky, int *ier)
   *ier = IDAGetDky(IDA_idamem, *t, *k, F2C_IDA_vec);
 
   /* Reset data pointers */
-  N_VSetArrayPointer(NULL, F2C_IDA_vec);
+  N_VSetArrayPointer(f2c_data, F2C_IDA_vec);
 
   return;
 }
@@ -667,6 +680,9 @@ void FIDA_GETDKY(realtype *t, int *k, realtype *dky, int *ier)
 
 void FIDA_GETERRWEIGHTS(realtype *eweight, int *ier)
 {
+  /* Store existing F2C_IDA_vec data pointer */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_IDA_vec);
+
   /* Attach user data to vector */
   N_VSetArrayPointer(eweight, F2C_IDA_vec);
 
@@ -674,7 +690,7 @@ void FIDA_GETERRWEIGHTS(realtype *eweight, int *ier)
   *ier = IDAGetErrWeights(IDA_idamem, F2C_IDA_vec);
 
   /* Reset data pointer */
-  N_VSetArrayPointer(NULL, F2C_IDA_vec);
+  N_VSetArrayPointer(f2c_data, F2C_IDA_vec);
 
   return;
 }
@@ -683,6 +699,9 @@ void FIDA_GETERRWEIGHTS(realtype *eweight, int *ier)
 
 void FIDA_GETESTLOCALERR(realtype *ele, int *ier)
 {
+  /* Store existing F2C_IDA_vec data pointer */
+  realtype *f2c_data = N_VGetArrayPointer(F2C_IDA_vec);
+
   /* Attach user data to vector */
   N_VSetArrayPointer(ele, F2C_IDA_vec);
 
@@ -690,7 +709,7 @@ void FIDA_GETESTLOCALERR(realtype *ele, int *ier)
   *ier = IDAGetEstLocalErrors(IDA_idamem, F2C_IDA_vec);
 
   /* Reset data pointers */
-  N_VSetArrayPointer(NULL, F2C_IDA_vec);
+  N_VSetArrayPointer(f2c_data, F2C_IDA_vec);
 
   return;
 }
diff --git a/src/ida/fcmix/fida.h b/src/ida/fcmix/fida.h
index 081d835..f2281ad 100644
--- a/src/ida/fcmix/fida.h
+++ b/src/ida/fcmix/fida.h
@@ -1,14 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:37:20 $
+ * $Revision: 4795 $
+ * $Date: 2016-07-01 15:10:25 -0700 (Fri, 01 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
+ *                Daniel R. Reynolds @ SMU
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for FIDA, the Fortran interface to
  * the IDA package.
@@ -33,6 +39,8 @@
  *
  *   FNVINITS* and FNVINITP*  interface to N_VNew_Serial and
  *                            N_VNew_Parallel, respectively
+ *   FNVINITOMP               N_VNew_OpenMP
+ *   FNVINITPTS               N_VNew_Pthreads
  *
  *   FIDAMALLOC  interfaces to IDACreate and IDAInit
  *
@@ -52,6 +60,11 @@
  *   FIDABAND        interfaces to IDABand
  *   FIDABANDSETJAC  interfaces to IDABandSetJacFn
  *
+ *   FIDAKLU         interfaces to IDAKLU
+ *   FIDAKLUReinit   interfaces to IDAKLUReinit
+ *   FIDASUPERLUMT   interfaces to IDASuperLUMT
+ *   FIDASPARSESETJAC    interfaces to IDASlsSetSparseJacFn
+ *
  *   FIDASPTFQMR/FIDASPTFQMRREINIT  interface to IDASptfqmr and IDASptfqmrSet*
  *   FIDASPBCG/FIDASPBCGREINIT      interface to IDASpbcg and IDASpbcgSet*
  *   FIDASPGMR/FIDASPGMRREINIT      interface to IDASpgmr and IDASpgmrSet*
@@ -76,6 +89,7 @@
  *   FIDAPSOL   is called by the interface fn. FIDAPSol of type IDASpilsPrecSolveFn
  *   FIDAPSET   is called by the interface fn. FIDAPSet of type IDASpilsPrecSetupFn
  *   FIDAJTIMES is called by interface fn. FIDAJtimes of type IDASpilsJacTimesVecFn
+ *   FIDASPJAC  is called by interface fn. FIDASparseJac of type IDASlsSparseJacFn
  *   FIDAEWT    is called by interface fn. FIDAEwtSet of type IDAEwtFn
  * In contrast to the case of direct use of IDA, the names of all user-supplied
  * routines here are fixed, in order to maximize portability for the resulting
@@ -155,7 +169,50 @@
  * successful, and nonzero otherwise.
  * IPAR and RPAR are user (integer and real) arrays passed to FIDAMALLOC.
  *
- * (5) Optional user-supplied error weight vector routine: FIDAEWT
+ * (5s) User-supplied sparse Jacobian approximation routine: FIDASPJAC
+ *
+ * Required when using the IDAKLU or IDASuperLUMT linear solvers, the 
+ * user must supply a routine that computes a compressed-sparse-column [or 
+ * compressed-sparse-row] approximation of the system Jacobian 
+ * J = dF/dy' + c_j*dF/dy.  If supplied, it must have the following form:
+ *
+ *       SUBROUTINE FIDASPJAC(T, CJ, Y, YP, R, N, NNZ, JDATA, JRVALS, 
+ *      &                    JCPTRS, H, IPAR, RPAR, WK1, WK2, WK3, IER)
+ *
+ * It must load the N by N compressed sparse column [row] matrix 
+ * with storage for NNZ nonzeros, stored in the arrays JDATA (nonzero
+ * values), JRVALS (row [column] indices for each nonzero), JCOLPTRS (indices 
+ * for start of each column [row]), with the Jacobian matrix at the current
+ * (t,y) in CSC [CSR] form (see sundials_sparse.h for more information).
+ *
+ * The arguments are:
+ *         T    -- current time [realtype, input]
+ *         CJ   -- Scalar in the system Jacobian proportional 
+ *                 to inverse step size [realtype, input]
+ *         Y    -- array containing state variables [realtype, input]
+ *         YP   -- array containing state derivatives [realtype, input]
+ *         R    -- array containing system residual F(T, Y, YP) [realtype, input]
+ *         N    -- number of matrix rows/columns in Jacobian [int, input]
+ *         NNZ  -- allocated length of nonzero storage [int, input]
+ *        JDATA -- nonzero values in Jacobian
+ *                 [realtype of length NNZ, output]
+ *       JRVALS -- row [column] indices for each nonzero in Jacobian
+ *                  [int of length NNZ, output]
+ *       JCPTRS -- pointers to each Jacobian column [row] in preceding arrays
+ *                 [int of length N+1, output]
+ *         H    -- current step size [realtype, input]
+ *         IPAR -- array containing integer user data that was passed to
+ *                 FIDAMALLOC [long int, input]
+ *         RPAR -- array containing real user data that was passed to
+ *                 FIDAMALLOC [realtype, input]
+ *         WK*  -- array containing temporary workspace of same size as Y 
+ *                 [realtype, input]
+ *         IER  -- return flag [int, output]:
+ *                    0 if successful, 
+ *                   >0 if a recoverable error occurred,
+ *                   <0 if an unrecoverable error ocurred.
+ *
+ * (6) Optional user-supplied error weight vector routine: FIDAEWT
  * As an option to providing the relative and absolute tolerances, the user
  * may supply a routine that computes the weights used in the WRMS norms.
  * If supplied, it must have the following form:
@@ -167,10 +224,11 @@
  *
  * -----------------------------------------------------------------------------
  *
- * (6) Initialization:  FNVINITS / FNVINITP , FIDAMALLOC, FIDAREINIT,
+ * (7) Initialization:  FNVINITS/FNVINITP/FNVINITOMP/FNVINITPTS, 
+ *                      FIDAMALLOC, FIDAREINIT,
  *                      FIDATOLREINIT, and FIDACALCIC
  *
- * (6.1s) To initialize the serial machine environment, the user must make
+ * (7.1s) To initialize the serial machine environment, the user must make
  * the following call:
  *        CALL FNVINITS(KEY, NEQ, IER)
  * The arguments are:
@@ -178,8 +236,8 @@
  * NEQ = size of vectors
  * IER = return completion flag. Values are 0 = success, -1 = failure.
  *
- * (6.1p) To initialize the parallel machine environment, the user must make 
- * one of the following calls:
+ * (7.1p) To initialize the distributed memory parallel machine environment, 
+ * the user must make one of the following calls:
  *        CALL FNVINITP(KEY, NLOCAL, NGLOBAL, IER)
  *                     -or-
  *        CALL FNVINITP(COMM, KEY, NLOCAL, NGLOBAL, IER)
@@ -196,7 +254,29 @@
  * look for the line "#define SUNDIALS_MPI_COMM_F2C 1" in the sundials_config.h
  * header file.
  *
- * (6.2) To set various problem and solution parameters and allocate
+ (7.1omp) To initialize the openMP threaded vector kernel, 
+          the user must make the following call:
+
+          CALL FNVINITOMP (KEY, NEQ, NUM_THREADS, IER)
+
+        The arguments are:
+	  KEY = 2 for IDA
+          NEQ = size of vectors
+          NUM_THREADS = number of threads
+          IER = return completion flag. Values are 0 = success, -1 = failure.
+
+ (7.1pts) To initialize the Pthreads threaded vector kernel, 
+          the user must make the following call:
+
+          CALL FNVINITOMP (KEY, NEQ, NUM_THREADS, IER)
+
+        The arguments are:
+	  KEY = 2 for IDA
+          NEQ = size of vectors
+          NUM_THREADS = number of threads
+          IER = return completion flag. Values are 0 = success, -1 = failure.
+ *
+ * (7.2) To set various problem and solution parameters and allocate
  * internal memory, make the following call:
  *       CALL FIDAMALLOC(T0, Y0, YP0, IATOL, RTOL, ATOL, 
  *      1                IOUT, ROUT, IPAR, RPAR, IER)
@@ -251,7 +331,7 @@
  * with FLAG = 1 to specify that FIDAEWT is provided.
  * The return flag IER is 0 if successful, and nonzero otherwise.
  *
- * (6.3) To set various integer optional inputs, make the folowing call:
+ * (7.3) To set various integer optional inputs, make the folowing call:
  *       CALL FIDASETIIN(KEY, VALUE, IER)
  * to set the optional input specified by the character key KEY to the 
  * integer value VAL.
@@ -273,7 +353,7 @@
  * FIDASETIIN, FIDASETRIN, and FIDASETVIN return IER=0 if successful and 
  * IER<0 if an error occured.
  *
- * (6.4) To re-initialize the FIDA solver for the solution of a new problem
+ * (7.4) To re-initialize the FIDA solver for the solution of a new problem
  * of the same size as one already solved, make the following call:
  *       CALL FIDAREINIT(T0, Y0, YP0, IATOL, RTOL, ATOL, ID, CONSTR, IER)
  * The arguments have the same names and meanings as those of FIDAMALLOC.
@@ -282,12 +362,12 @@
  * created by the previous FIDAMALLOC call.  The call to specify the linear system
  * solution method may or may not be needed.  See below.
  *
- * (6.5) To modify the tolerance parameters, make the following call:
+ * (7.5) To modify the tolerance parameters, make the following call:
  *       CALL FIDATOLREINIT(IATOL, RTOL, ATOL, IER)
  * The arguments have the same names and meanings as those of FIDAMALLOC.
  * FIDATOLREINIT simple calls IDASetTolerances with the given arguments.
  *
- * (6.6) To compute consistent initial conditions for an index-one DAE system,
+ * (7.6) To compute consistent initial conditions for an index-one DAE system,
  * make the following call:
  *       CALL FIDACALCIC(ICOPT, TOUT, IER)
  * The arguments are:
@@ -299,12 +379,12 @@
  * 
  * -----------------------------------------------------------------------------
  *
- * (7) Specification of linear system solution method.
+ * (8) Specification of linear system solution method.
  * FIDA presently includes four choices for the treatment of these systems,
  * and the user of FIDA must call a routine with a specific name to make the
  * desired choice.
  * 
- * (7.1s) DENSE treatment of the linear system.
+ * (8.1s) DENSE treatment of the linear system.
  * The user must make the call
  *       CALL FIDADENSE(NEQ, IER)
  * The arguments are:
@@ -325,7 +405,7 @@
  *        NRELS   = IOUT(16) -> IDADenseGetNumResEvals
  *        NJE     = IOUT(17) -> IDADenseGetNumJacEvals
  *
- * (7.2s) BAND treatment of the linear system
+ * (8.2s) BAND treatment of the linear system
  * The user must make the call
  *       CALL FIDABAND(NEQ, MU, ML, IER)
  * The arguments are:
@@ -348,7 +428,95 @@
  *        NRELS   = IOUT(16) -> IDABandGetNumResEvals
  *        NJE     = IOUT(17) -> IDABandGetNumJacEvals
  *
- * (7.3) SPGMR treatment of the linear systems.
+ *  (8.3s) SPARSE treatment of the linear system using the KLU solver.
+ *
+ *     The user must make the call
+ *
+ *       CALL FIDAKLU(NEQ, NNZ, SPARSETYPE, ORDERING, IER)
+ *
+ *     The arguments are:
+ *        NEQ = the problem size [int; input]
+ *        NNZ = the maximum number of nonzeros [int; input]
+ *        SPARSETYPE = choice between CSC and CSR format
+ *           (0 = CSC, 1 = CSR) [int; input]
+ *        ORDERING = the matrix ordering desired, possible values
+ *           come from the KLU package (0 = AMD, 1 = COLAMD) [int; input]
+ *        IER = error return flag [int, output]: 
+ *	         0 = success, 
+ *		 negative = error.
+ * 
+ *     When using the KLU solver the user must provide the FIDASPJAC routine for the 
+ *     evalution of the sparse approximation to the Jacobian. To indicate that this
+ *     routine has been provided, after the call to FIDAKLU, the following call must 
+ *     be made    
+ *
+ *       CALL FIDASPARSESETJAC(IER) 
+ *
+ *     The int return flag IER=0 if successful, and nonzero otherwise.
+ *
+ *  
+ *     The IDA KLU solver will reuse much of the factorization information from one
+ *     nonlinear iteration to the next.  If at any time the user wants to force a full
+ *     refactorization or if the number of nonzeros in the Jacobian matrix changes, the
+ *     user should make the call
+ *
+ *       CALL FIDAKLUREINIT(NEQ, NNZ, REINIT_TYPE)
+ *
+ *     The arguments are:
+ *        NEQ = the problem size [int; input]
+ *        NNZ = the maximum number of nonzeros [int; input]
+ *	REINIT_TYPE = 1 or 2.  For a value of 1, the matrix will be destroyed and 
+ *          a new one will be allocated with NNZ nonzeros.  For a value of 2, 
+ *	  only symbolic and numeric factorizations will be completed. 
+ * 
+ *     When using FIDAKLU, the user is required to supply the FIDASPJAC 
+ *     routine for the evaluation of the sparse approximation to the 
+ *     Jacobian, as discussed above with the other user-supplied routines.
+ * 
+ *     Optional outputs specific to the KLU case are:
+ *        LSTF    = IOUT(16) from IDASlsGetLastFlag
+ *        NJES    = IOUT(18) from IDASlsGetNumJacEvals
+ *     See the IDA manual for descriptions.
+ * 
+ * (8.4s) SPARSE treatment of the linear system using the SuperLUMT solver.
+ *
+ *     The user must make the call
+ *
+ *       CALL FIDASUPERLUMT(NTHREADS, NEQ, NNZ, ORDERING, IER)
+ *
+ *     The arguments are:
+ *        NTHREADS = desired number of threads to use [int; input]
+ *        NEQ = the problem size [int; input]
+ *        NNZ = the maximum number of nonzeros [int; input]
+ *	ORDERING = the matrix ordering desired, possible values
+ *	   come from the SuperLU_MT package [int; input]
+ *           0 = Natural
+ *           1 = Minimum degree on A^T A
+ *           2 = Minimum degree on A^T + A
+ *           3 = COLAMD
+ *	IER = error return flag [int, output]: 
+ *	         0 = success, 
+ *		 negative = error.
+ *	 
+ *     At this time, there is no reinitialization capability for the SUNDIALS 
+ *     interfaces to the SuperLUMT solver.
+ *
+ *     When using FIDASUPERLUMT, the user is required to supply the FIDASPJAC 
+ *     routine for the evaluation of the CSC approximation to the Jacobian (note: the 
+ *     current SuperLU_MT interface in SUNDIALS does not support CSR matrices). To 
+ *     indicate that this routine has been provided, after the call to FIDASUPERLUMT,
+ *     the following call must be made    
+ *
+ *       CALL FIDASPARSESETJAC(IER) 
+ *
+ *     The int return flag IER=0 if successful, and nonzero otherwise.
+ * 
+ *     Optional outputs specific to the SUPERLUMT case are:
+ *        LSTF    = IOUT(14) from IDASlsGetLastFlag
+ *        NJES    = IOUT(16) from IDASlsGetNumJacEvals
+ *     See the IDA manual for descriptions.
+ * 
+ * (8.5) SPGMR treatment of the linear systems.
  * For the Scaled Preconditioned GMRES solution of the linear systems,
  * the user must make the following call:
  *       CALL FIDASPGMR(MAXL, IGSTYPE, MAXRS, EPLIFAC, DQINCFAC, IER)
@@ -380,7 +548,7 @@
  * The arguments have the same meanings as for FIDASPGMR.  If MAXL is being
  * changed, then call FIDASPGMR instead.
  *
- * (7.4) SPBCG treatment of the linear systems.
+ * (8.6) SPBCG treatment of the linear systems.
  * For the Scaled Preconditioned Bi-CGSTAB solution of the linear systems,
  * the user must make the following call:
  *       CALL FIDASPBCG(MAXL, EPLIFAC, DQINCFAC, IER)              
@@ -409,7 +577,7 @@
  *       CALL FIDASPBCGREINIT(MAXL, EPLIFAC, DQINCFAC, IER)
  * The arguments have the same meanings as for FIDASPBCG.
  *
- * (7.5) SPTFQMR treatment of the linear systems.
+ * (8.7) SPTFQMR treatment of the linear systems.
  * For the Scaled Preconditioned TFQMR solution of the linear systems,
  * the user must make the following call:
  *       CALL FIDASPTFQMR(MAXL, EPLIFAC, DQINCFAC, IER)              
@@ -438,7 +606,7 @@
  *       CALL FIDASPTFQMRREINIT (MAXL, EPLIFAC, DQINCFAC, IER)
  * The arguments have the same meanings as for FIDASPTFQMR.
  *
- * (7.6) Using user-provided functions for the iterative linear solvers
+ * (8.8) Using user-provided functions for the iterative linear solvers
  * 
  * If the user program includes the FIDAJTIMES routine for the evaluation of the 
  * Jacobian vector product, the following call must be made
@@ -473,7 +641,7 @@
  *
  * -----------------------------------------------------------------------------
  *
- * (8) The solver: FIDASOLVE
+ * (9) The solver: FIDASOLVE
  * To solve the DAE system, make the following call:
  *       CALL FIDASOLVE(TOUT, TRET, Y, YP, ITASK, IER)
  * The arguments are:
@@ -493,7 +661,7 @@
  *
  * -----------------------------------------------------------------------------
  *
- * (9) Getting current solution derivative: FIDAGETDKY
+ * (10) Getting current solution derivative: FIDAGETDKY
  * To obtain interpolated values of y and y' for any value of t in the last
  * internal step taken by IDA, make the following call:
  *       CALL FIDAGETDKY(T, K, DKY, IER)
@@ -505,7 +673,7 @@
  *
  * -----------------------------------------------------------------------------
  *
- * (10) Memory freeing: FIDAFREE
+ * (11) Memory freeing: FIDAFREE
  * To the free the internal memory created by the calls to FIDAMALLOC and
  * FNVINITS or FNVINITP, depending on the version (serial/parallel), make
  * the following call:
@@ -517,15 +685,16 @@
 #ifndef _FIDA_H
 #define _FIDA_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <ida/ida.h>                   /* definition of type IDAResFn */
 #include <sundials/sundials_direct.h>  /* definition of type DlsMat  */
+#include <sundials/sundials_sparse.h>  /* definition of type SlsMat  */
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector */
 #include <sundials/sundials_types.h>   /* definition of type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 #if defined(SUNDIALS_F77_FUNC)
 
 #define FIDA_MALLOC         SUNDIALS_F77_FUNC(fidamalloc, FIDAMALLOC)
@@ -545,6 +714,10 @@ extern "C" {
 #define FIDA_LAPACKBANDSETJAC  SUNDIALS_F77_FUNC(fidalapackbandsetjac, FIDALAPACKBANDSETJAC)
 #define FIDA_LAPACKDENSE       SUNDIALS_F77_FUNC(fidalapackdense, FIDALAPACKDENSE)
 #define FIDA_LAPACKDENSESETJAC SUNDIALS_F77_FUNC(fidalapackdensesetjac, FIDALAPACKDENSESETJAC)
+#define FIDA_KLU            SUNDIALS_F77_FUNC(fidaklu, FIDAKLU)
+#define FIDA_KLUREINIT      SUNDIALS_F77_FUNC(fidaklureinit, FIDAKLUREINIT)
+#define FIDA_SUPERLUMT      SUNDIALS_F77_FUNC(fidasuperlumt, FIDASUPERLUMT)
+#define FIDA_SPARSESETJAC   SUNDIALS_F77_FUNC(fidasparsesetjac, FIDASPARSESETJAC)
 #define FIDA_SPTFQMR        SUNDIALS_F77_FUNC(fidasptfqmr, FIDASPTFQMR)
 #define FIDA_SPBCG          SUNDIALS_F77_FUNC(fidaspbcg, FIDASPBCG)
 #define FIDA_SPGMR          SUNDIALS_F77_FUNC(fidaspgmr, FIDASPGMR)
@@ -560,6 +733,7 @@ extern "C" {
 #define FIDA_PSOL           SUNDIALS_F77_FUNC(fidapsol, FIDAPSOL)
 #define FIDA_JTIMES         SUNDIALS_F77_FUNC(fidajtimes, FIDAJTIMES)
 #define FIDA_EWT            SUNDIALS_F77_FUNC(fidaewt, FIDAEWT)
+#define FIDA_EWTSET         SUNDIALS_F77_FUNC(fidaewtset, FIDAEWTSET)
 #define FIDA_GETDKY         SUNDIALS_F77_FUNC(fidagetdky, FIDAGETDKY)
 #define FIDA_GETERRWEIGHTS  SUNDIALS_F77_FUNC(fidageterrweights, FIDAGETERRWEIGHTS)
 #define FIDA_GETESTLOCALERR SUNDIALS_F77_FUNC(fidagetestlocalerr, FIDAGETESTLOCALERR)
@@ -583,6 +757,10 @@ extern "C" {
 #define FIDA_LAPACKBANDSETJAC  fidalapackbandsetjac_
 #define FIDA_LAPACKDENSE       fidalapackdense_
 #define FIDA_LAPACKDENSESETJAC fidalapackdensesetjac_
+#define FIDA_KLU            fidaklu_
+#define FIDA_KLUREINIT      fidaklureinit_
+#define FIDA_SUPERLUMT      fidasuperlumt_
+#define FIDA_SPARSESETJAC   fidasparsesetjac_
 #define FIDA_SPTFQMR        fidasptfqmr_
 #define FIDA_SPBCG          fidaspbcg_
 #define FIDA_SPGMR          fidaspgmr_
@@ -622,11 +800,11 @@ void FIDA_REINIT(realtype *t0, realtype *yy0, realtype *yp0,
                  int *iatol, realtype *rtol, realtype *atol,
                  int *ier);
 
-void FIDA_SETIIN(char key_name[], long int *ival, int *ier, int key_len);
+void FIDA_SETIIN(char key_name[], long int *ival, int *ier);
 
-void FIDA_SETRIN(char key_name[], realtype *rval, int *ier, int key_len);
+void FIDA_SETRIN(char key_name[], realtype *rval, int *ier);
 
-void FIDA_SETVIN(char key_name[], realtype *vval, int *ier, int key_len);
+void FIDA_SETVIN(char key_name[], realtype *vval, int *ier);
 
 void FIDA_TOLREINIT(int *iatol, realtype *rtol, realtype *atol, int *ier);
 void FIDA_CALCIC(int *icopt, realtype *tout1, int *ier);
@@ -641,6 +819,11 @@ void FIDA_LAPACKDENSESETJAC(int *flag, int *ier);
 void FIDA_LAPACKBAND(int *neq, int *mupper, int *mlower, int *ier);
 void FIDA_LAPACKBANDSETJAC(int *flag, int *ier);
 
+void FIDA_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier);
+void FIDA_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier);
+void FIDA_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier);
+void FIDA_SPARSESETJAC(int *ier);
+
 void FIDA_SPTFQMR(int *maxl, realtype *eplifac, realtype *dqincfac, int *ier);
 void FIDA_SPBCG(int *maxl, realtype *eplifac, realtype *dqincfac, int *ier);
 void FIDA_SPGMR(int *maxl, int *gstype, int *maxrs, realtype *eplifac,
@@ -686,6 +869,10 @@ int FIDALapackBandJac(long int N, long int mupper, long int mlower,
                       DlsMat J, void *user_data,
                       N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
 
+int FIDASparseJac(realtype t, realtype cj, N_Vector y, N_Vector yp,
+		  N_Vector fval, SlsMat J, void *user_data, 
+		  N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
+
 int FIDAJtimes(realtype t, N_Vector yy, N_Vector yp, N_Vector rr,
                N_Vector v, N_Vector Jv,
                realtype c_j, void *user_data,
@@ -718,7 +905,8 @@ extern int IDA_nrtfn;           /* defined in fida.c */
 
 enum { IDA_LS_DENSE = 1, IDA_LS_BAND = 2, 
        IDA_LS_LAPACKDENSE = 3, IDA_LS_LAPACKBAND = 4, 
-       IDA_LS_SPGMR = 5, IDA_LS_SPBCG = 6, IDA_LS_SPTFQMR = 7 };
+       IDA_LS_KLU = 5, IDA_LS_SUPERLUMT = 6, 
+       IDA_LS_SPGMR = 7, IDA_LS_SPBCG = 8, IDA_LS_SPTFQMR = 9 };
 
 #ifdef __cplusplus
 }
diff --git a/src/ida/fcmix/fidaband.c b/src/ida/fcmix/fidaband.c
index 7d7d50e..ac2ab3f 100644
--- a/src/ida/fcmix/fidaband.c
+++ b/src/ida/fcmix/fidaband.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:37:20 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for IDA/IDABAND, for the case of
  * a user-supplied Jacobian approximation routine.
diff --git a/src/ida/fcmix/fidabbd.c b/src/ida/fcmix/fidabbd.c
index c01daa6..44e425c 100644
--- a/src/ida/fcmix/fidabbd.c
+++ b/src/ida/fcmix/fidabbd.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:37:20 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This module contains the routines necessary to interface with the
  * IDABBDPRE module and user-supplied Fortran routines.
diff --git a/src/ida/fcmix/fidabbd.h b/src/ida/fcmix/fidabbd.h
index 879b01f..e1cd9bd 100644
--- a/src/ida/fcmix/fidabbd.h
+++ b/src/ida/fcmix/fidabbd.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the Fortran interface include file for the BBD
  * preconditioner (IDABBDPRE)
@@ -35,9 +40,6 @@
  * The user-callable functions in this package, with the corresponding
  * IDA and IDABBDPRE functions, are as follows: 
  *   FIDABBDININT   interfaces to IDABBDPrecInit
- *   FIDABBDSPGMR   interfaces to IDABBDSpgmr and IDASpilsSet*
- *   FIDABBDSPBCG   interfaces to IDABBDSpbcg and IDASpilsSet*
- *   FIDABBDSPTFQMR interfaces to IDABBDSptfqmr and IDASpilsSet*
  *   FIDABBDREINIT  interfaces to IDABBDPrecReInit
  *   FIDABBDOPT     accesses optional outputs
  *   FIDABBDFREE    interfaces to IDABBDPrecFree
@@ -202,7 +204,7 @@
  * The return flag IER is 0 if successful, and nonzero otherwise.
  *
  * (4.3) Attach one of the 3 SPILS linear solvers. Make one of the 
- * following calls (see fida.h) for more details.
+ * following calls (see fida.h for more details).
  *       CALL FIDASPGMR(MAXL, IGSTYPE, MAXRS, EPLIFAC, DQINCFAC, IER)
  *       CALL FIDASPBCG(MAXL, EPLIFAC, DQINCFAC, IER)
  *       CALL FIDASPTFQMR(MAXL, EPLIFAC, DQINCFAC, IER)
@@ -291,13 +293,13 @@
 #ifndef _FIDABBD_H
 #define _FIDABBD_H
 
+#include <sundials/sundials_nvector.h>
+#include <sundials/sundials_types.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <sundials/sundials_nvector.h>
-#include <sundials/sundials_types.h>
-
 #if defined(SUNDIALS_F77_FUNC)
 
 #define FIDA_BBDINIT    SUNDIALS_F77_FUNC(fidabbdinit, FIDABBDINIT)
diff --git a/src/ida/fcmix/fidadense.c b/src/ida/fcmix/fidadense.c
index 60f3337..897e1ed 100644
--- a/src/ida/fcmix/fidadense.c
+++ b/src/ida/fcmix/fidadense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:37:20 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for IDA/IDADENSE, for the case
  * of a user-supplied Jacobian approximation routine.
diff --git a/src/ida/fcmix/fidaewt.c b/src/ida/fcmix/fidaewt.c
index 53ecf9c..f7a229a 100644
--- a/src/ida/fcmix/fidaewt.c
+++ b/src/ida/fcmix/fidaewt.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:29:00 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for IDA, for the case of a 
  * user-supplied error weight calculation routine.
diff --git a/src/ida/fcmix/fidajtimes.c b/src/ida/fcmix/fidajtimes.c
index cbd1adb..360beae 100644
--- a/src/ida/fcmix/fidajtimes.c
+++ b/src/ida/fcmix/fidajtimes.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:29:00 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * The C function FIDAJtimes is to interface between the
  * IDASPILS modules and the user-supplied Jacobian-vector
diff --git a/src/ida/fcmix/fidaklu.c b/src/ida/fcmix/fidaklu.c
new file mode 100644
index 0000000..4191bd6
--- /dev/null
+++ b/src/ida/fcmix/fidaklu.c
@@ -0,0 +1,52 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4654 $
+ * $Date: 2016-02-17 20:12:58 -0800 (Wed, 17 Feb 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the Fortran interface to
+ * the IDAKLU solver. See fida.h for usage.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fida.h"
+#include "ida_impl.h"
+#include <ida/ida_klu.h>
+ 
+/*
+ * ----------------------------------------------------------------
+ * Function : FIDA_KLU
+ * ----------------------------------------------------------------
+ */
+
+void FIDA_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier)
+{
+  *ier = IDAKLU(IDA_idamem, *neq, *nnz, *sparsetype);
+  IDAKLUSetOrdering(IDA_idamem, *ordering);
+  IDA_ls = IDA_LS_KLU;
+}
+
+/*
+ * ----------------------------------------------------------------
+ * Function : FIDA_KLUReinit
+ * ----------------------------------------------------------------
+ */
+
+void FIDA_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier)
+{
+  *ier = IDAKLUReInit(IDA_idamem, *neq, *nnz, *reinit_type);
+}
+
diff --git a/src/ida/fcmix/fidalapack.c b/src/ida/fcmix/fidalapack.c
index 0ba0dfa..2faf2ea 100644
--- a/src/ida/fcmix/fidalapack.c
+++ b/src/ida/fcmix/fidalapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/11/22 00:12:50 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for IDA/IDALAPACK.
  * -----------------------------------------------------------------
diff --git a/src/ida/fcmix/fidalapband.c b/src/ida/fcmix/fidalapband.c
index cfb8faf..4b6ecba 100644
--- a/src/ida/fcmix/fidalapband.c
+++ b/src/ida/fcmix/fidalapband.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:37:20 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for IDA/IDALAPACK, for the case of
  * a user-supplied Jacobian approximation routine.
diff --git a/src/ida/fcmix/fidalapdense.c b/src/ida/fcmix/fidalapdense.c
index a06cf87..7cdbc5c 100644
--- a/src/ida/fcmix/fidalapdense.c
+++ b/src/ida/fcmix/fidalapdense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:37:20 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for IDA/IDALAPACK, for the case
  * of a user-supplied Jacobian approximation routine.
diff --git a/src/ida/fcmix/fidapreco.c b/src/ida/fcmix/fidapreco.c
index 61d9afa..14b8b21 100644
--- a/src/ida/fcmix/fidapreco.c
+++ b/src/ida/fcmix/fidapreco.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/03/17 21:01:08 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * The C function FIDAPSet is to interface between the IDASPILS
  * modules and the user-supplied preconditioner setup routine FIDAPSET.
diff --git a/src/ida/fcmix/fidaroot.c b/src/ida/fcmix/fidaroot.c
index 0548dbb..9d19b8c 100644
--- a/src/ida/fcmix/fidaroot.c
+++ b/src/ida/fcmix/fidaroot.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:29:00 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Alan C. Hindmarsh @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * The FIDAROOT module contains the routines necessary to use
  * the rootfinding feature of the IDA module and to interface
diff --git a/src/ida/fcmix/fidaroot.h b/src/ida/fcmix/fidaroot.h
index 68538a1..73b71b2 100644
--- a/src/ida/fcmix/fidaroot.h
+++ b/src/ida/fcmix/fidaroot.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Alan C. Hindmarsh @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the Fortran interface include file for the rootfinding
  * feature of IDA.
@@ -96,15 +101,14 @@
 #ifndef _FIDAROOT_H
 #define _FIDAROOT_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 /* header files */
-
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector          */
 #include <sundials/sundials_types.h>   /* definition of SUNDIALS type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* Definitions of interface function names */
 
 #if defined(SUNDIALS_F77_FUNC)
diff --git a/src/ida/fcmix/fidasparse.c b/src/ida/fcmix/fidasparse.c
new file mode 100644
index 0000000..5253d47
--- /dev/null
+++ b/src/ida/fcmix/fidasparse.c
@@ -0,0 +1,82 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4815 $
+ * $Date: 2016-07-20 16:51:55 -0700 (Wed, 20 Jul 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ *                Daniel R. Reynolds @ SMU
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fida.h"
+#include "ida_impl.h"
+#include <ida/ida_sparse.h>
+
+/* Prototype of the Fortran routine */
+ 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+ 
+extern void FIDA_SPJAC(realtype *T, realtype *CJ, realtype *Y, 
+		       realtype *YP, realtype *R, int *N, int *NNZ, 
+		       realtype *JDATA, int *JRVALS, 
+		       int *JCPTRS, realtype *H, 
+		       long int *IPAR, realtype *RPAR, 
+		       realtype *V1, realtype *V2, 
+		       realtype *V3, int *ier);
+ 
+#ifdef __cplusplus
+}
+#endif
+ 
+/*=============================================================*/
+
+/* Fortran interface to C routine IDASlsSetSparseJacFn; see
+   fida.h for further information */
+void FIDA_SPARSESETJAC(int *ier)
+{
+  *ier = IDASlsSetSparseJacFn(IDA_idamem, FIDASparseJac);
+}
+
+/*=============================================================*/
+ 
+/* C interface to user-supplied Fortran routine FIDASPJAC; see 
+   fida.h for additional information  */
+int FIDASparseJac(realtype t, realtype cj, N_Vector y, N_Vector yp,
+		  N_Vector fval, SlsMat J, void *user_data, 
+		  N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
+{
+  int ier;
+  realtype *ydata, *ypdata, *rdata, *v1data, *v2data, *v3data;
+  realtype h;
+  FIDAUserData IDA_userdata;
+
+  IDAGetLastStep(IDA_idamem, &h);
+  ydata   = N_VGetArrayPointer(y);
+  ypdata  = N_VGetArrayPointer(yp);
+  rdata  = N_VGetArrayPointer(fval);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+  v3data  = N_VGetArrayPointer(vtemp3);
+  IDA_userdata = (FIDAUserData) user_data;
+
+  FIDA_SPJAC(&t, &cj, ydata, ypdata, rdata, &(J->NP), &(J->NNZ),
+	    J->data, J->indexvals, J->indexptrs, &h, 
+	    IDA_userdata->ipar, IDA_userdata->rpar, v1data, 
+	    v2data, v3data, &ier); 
+  return(ier);
+}
+
diff --git a/src/ida/fcmix/fidasuperlumt.c b/src/ida/fcmix/fidasuperlumt.c
new file mode 100644
index 0000000..c3c9d71
--- /dev/null
+++ b/src/ida/fcmix/fidasuperlumt.c
@@ -0,0 +1,42 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4402 $
+ * $Date: 2015-02-28 19:35:39 -0800 (Sat, 28 Feb 2015) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the Fortran interface to
+ * the IDASuperLUMT solver. See fida.h for usage.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fida.h"
+#include "ida_impl.h"
+#include <ida/ida_superlumt.h>
+ 
+/*
+ * ----------------------------------------------------------------
+ * Function : FIDA_SUPERLUMT
+ * ----------------------------------------------------------------
+ */
+
+void FIDA_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier)
+{
+  *ier = IDASuperLUMT(IDA_idamem, *nthreads, *neq, *nnz);
+  IDASuperLUMTSetOrdering(IDA_idamem, *ordering);
+  IDA_ls = IDA_LS_SUPERLUMT;
+}
+
+
diff --git a/src/ida/ida.c b/src/ida/ida.c
index 7c05cae..4dd8217 100644
--- a/src/ida/ida.c
+++ b/src/ida/ida.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.25 $
- * $Date: 2012/03/06 21:58:52 $
+ * $Revision: 4845 $
+ * $Date: 2016-08-03 15:45:09 -0700 (Wed, 03 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan Hindmarsh, Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the main IDA solver.
  * It is independent of the linear solver in use.
@@ -188,6 +193,7 @@
 #define MAXNJ            4  /* max. number of J tries in IC calc. */
 #define MAXNI           10  /* max. Newton iterations in IC calc. */
 #define EPCON RCONST(0.33)  /* Newton convergence test constant */
+#define MAXBACKS       100  /* max backtracks per Newton step in IDACalcIC */
 
 /* IDANewtonIter constants */
 
@@ -339,8 +345,9 @@ void *IDACreate(void)
   IDA_mem->ida_maxnh   = MAXNH;
   IDA_mem->ida_maxnj   = MAXNJ;
   IDA_mem->ida_maxnit  = MAXNI;
+  IDA_mem->ida_maxbacks  = MAXBACKS;
   IDA_mem->ida_lsoff   = FALSE;
-  IDA_mem->ida_steptol = RPowerR(IDA_mem->ida_uround, TWOTHIRDS);
+  IDA_mem->ida_steptol = SUNRpowerR(IDA_mem->ida_uround, TWOTHIRDS);
 
   /* Initialize lrw and liw */
   IDA_mem->ida_lrw = 25 + 5*MXORDP1;
@@ -505,7 +512,7 @@ int IDAInit(void *ida_mem, IDAResFn res,
  * IDAReInit re-initializes IDA's memory for a problem, assuming
  * it has already beeen allocated in a prior IDAInit call.
  * All problem specification inputs are checked for errors.
- * The problem size Neq is assumed to be unchaged since the call
+ * The problem size Neq is assumed to be unchanged since the call
  * to IDAInit, and the maximum order maxord must not be larger.
  * If any error occurs during reinitialization, it is reported to
  * the error handler function.
@@ -947,6 +954,7 @@ int IDARootInit(void *ida_mem, int nrtfn, IDARootFn g)
 #define netf           (IDA_mem->ida_netf)
 #define nni            (IDA_mem->ida_nni)
 #define nsetups        (IDA_mem->ida_nsetups)
+
 #define ns             (IDA_mem->ida_ns)
 #define linit          (IDA_mem->ida_linit)
 #define lsetup         (IDA_mem->ida_lsetup)
@@ -1089,12 +1097,12 @@ int IDASolve(void *ida_mem, realtype tout, realtype *tret,
        check for approach to tstop, and scale phi[1] by hh.
        Also check for zeros of root function g at and near t0.    */
 
-    tdist = ABS(tout - tn);
+    tdist = SUNRabs(tout - tn);
     if (tdist == ZERO) {
       IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASolve", MSG_TOO_CLOSE);
       return(IDA_ILL_INPUT);
     }
-    troundoff = TWO*uround*(ABS(tn) + ABS(tout));    
+    troundoff = TWO*uround*(SUNRabs(tn) + SUNRabs(tout));
     if (tdist < troundoff) {
       IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASolve", MSG_TOO_CLOSE);
       return(IDA_ILL_INPUT);
@@ -1113,11 +1121,11 @@ int IDASolve(void *ida_mem, realtype tout, realtype *tret,
       if (tout < tn) hh = -hh;
     }
 
-    rh = ABS(hh)*hmax_inv;
+    rh = SUNRabs(hh)*hmax_inv;
     if (rh > ONE) hh /= rh;
 
     if (tstopset) {
-      if ( (tstop - tn)*hh < ZERO) {
+      if ( (tstop - tn)*hh <= ZERO) {
         IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASolve", MSG_BAD_TSTOP, tstop, tn);
         return(IDA_ILL_INPUT);
       }
@@ -1177,8 +1185,8 @@ int IDASolve(void *ida_mem, realtype tout, realtype *tret,
 
       /* If tn is distinct from tretlast (within roundoff),
          check remaining interval for roots */
-      troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-      if ( ABS(tn - tretlast) > troundoff ) {
+      troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+      if ( SUNRabs(tn - tretlast) > troundoff ) {
         ier = IDARcheck3(IDA_mem);
         if (ier == IDA_SUCCESS) {     /* no root found */
           irfnd = 0;
@@ -1371,7 +1379,7 @@ int IDAGetDky(void *ida_mem, realtype t, int k, N_Vector dky)
 
   /* Check t for legality.  Here tn - hused is t_{n-1}. */
 
-  tfuzz = HUNDRED * uround * (ABS(tn) + ABS(hh));
+  tfuzz = HUNDRED * uround * (SUNRabs(tn) + SUNRabs(hh));
   if (hh < ZERO) tfuzz = - tfuzz;
   tp = tn - hused - tfuzz;
   if ((t - tp)*hh < ZERO) {
@@ -1574,7 +1582,7 @@ static booleantype IDAAllocVectors(IDAMem IDA_mem, N_Vector tmpl)
   /* Allocate phi[0] ... phi[maxord].  Make sure phi[2] and phi[3] are
   allocated (for use as temporary vectors), regardless of maxord.       */
 
-  maxcol = MAX(maxord,3);
+  maxcol = SUNMAX(maxord,3);
   for (j=0; j <= maxcol; j++) {
     phi[j] = N_VClone(tmpl);
     if (phi[j] == NULL) {
@@ -1613,7 +1621,7 @@ static void IDAFreeVectors(IDAMem IDA_mem)
   N_VDestroy(delta);
   N_VDestroy(tempv1);
   N_VDestroy(tempv2);
-  maxcol = MAX(IDA_mem->ida_maxord_alloc,3);
+  maxcol = SUNMAX(IDA_mem->ida_maxord_alloc,3);
   for(j=0; j <= maxcol; j++) N_VDestroy(phi[j]);
 
   lrw -= (maxcol + 6)*lrw1;
@@ -1652,7 +1660,7 @@ static void IDAFreeVectors(IDAMem IDA_mem)
  * It performs all checks on optional inputs and inputs to 
  * IDAInit/IDAReInit that could not be done before.
  *
- * If no merror is encountered, IDAInitialSetup returns IDA_SUCCESS. 
+ * If no error is encountered, IDAInitialSetup returns IDA_SUCCESS. 
  * Otherwise, it returns an error flag and reported to the error 
  * handler function.
  */
@@ -1664,7 +1672,7 @@ int IDAInitialSetup(IDAMem IDA_mem)
 
   /* Test for more vector operations, depending on options */
   if (suppressalg)
-    if (id->ops->nvwrmsnormmask == NULL) {
+    if (phi[0]->ops->nvwrmsnormmask == NULL) {
       IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDAInitialSetup", MSG_BAD_NVECTOR);
       return(IDA_ILL_INPUT);
   }
@@ -1726,9 +1734,9 @@ int IDAInitialSetup(IDAMem IDA_mem)
  *
  * This routine is responsible for loading the error weight vector
  * ewt, according to itol, as follows:
- * (1) ewt[i] = 1 / (rtol * ABS(ycur[i]) + atol), i=0,...,Neq-1
+ * (1) ewt[i] = 1 / (rtol * SUNRabs(ycur[i]) + atol), i=0,...,Neq-1
  *     if itol = IDA_SS
- * (2) ewt[i] = 1 / (rtol * ABS(ycur[i]) + atol[i]), i=0,...,Neq-1
+ * (2) ewt[i] = 1 / (rtol * SUNRabs(ycur[i]) + atol[i]), i=0,...,Neq-1
  *     if itol = IDA_SV
  *
  *  IDAEwtSet returns 0 if ewt is successfully set as above to a
@@ -1854,8 +1862,8 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
     }
 
     if (tstopset) {
-      troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-      if (ABS(tn - tstop) <= troundoff) {
+      troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+      if (SUNRabs(tn - tstop) <= troundoff) {
         ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
         if (ier != IDA_SUCCESS) {
           IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASolve", MSG_BAD_TSTOP, tstop, tn);
@@ -1889,8 +1897,8 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
     }
 
     if (tstopset) {
-      troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-      if (ABS(tn - tstop) <= troundoff) {
+      troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+      if (SUNRabs(tn - tstop) <= troundoff) {
         ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
         if (ier != IDA_SUCCESS) {
           IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASolve", MSG_BAD_TSTOP, tstop, tn);
@@ -1907,7 +1915,7 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
     return(CONTINUE_STEPS);
         
   }
-  return(-99);
+  return(IDA_ILL_INPUT);
 }
 
 /*
@@ -1934,7 +1942,7 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
 static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret, 
                         N_Vector yret, N_Vector ypret, int itask)
 {
-  int ier;
+  /* int ier; */
   realtype troundoff;
 
   switch (itask) {
@@ -1943,16 +1951,16 @@ static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret,
 
       /* Test for tn past tout. */
       if ((tn - tout)*hh >= ZERO) {
-        ier = IDAGetSolution(IDA_mem, tout, yret, ypret);
+        /* ier = */ IDAGetSolution(IDA_mem, tout, yret, ypret);
         *tret = tretlast = tout;
         return(IDA_SUCCESS);
       }
 
       if (tstopset) {
         /* Test for tn at tstop and for tn near tstop */
-        troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-        if (ABS(tn - tstop) <= troundoff) {
-          ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
+        troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+        if (SUNRabs(tn - tstop) <= troundoff) {
+          /* ier = */ IDAGetSolution(IDA_mem, tstop, yret, ypret);
           *tret = tretlast = tstop;
           tstopset = FALSE;
           return(IDA_TSTOP_RETURN);
@@ -1967,9 +1975,9 @@ static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret,
 
       if (tstopset) {
         /* Test for tn at tstop and for tn near tstop */
-        troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-        if (ABS(tn - tstop) <= troundoff) {
-          ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
+        troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+        if (SUNRabs(tn - tstop) <= troundoff) {
+          /* ier = */ IDAGetSolution(IDA_mem, tstop, yret, ypret);
           *tret = tretlast = tstop;
           tstopset = FALSE;
           return(IDA_TSTOP_RETURN);
@@ -1982,7 +1990,7 @@ static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret,
       return(IDA_SUCCESS);
 
   }
-  return -99;
+  return IDA_ILL_INPUT;
 }
 
 /* 
@@ -2034,7 +2042,7 @@ static int IDAHandleFailure(IDAMem IDA_mem, int sflag)
 
   }
 
-  return -99;
+  return (IDA_UNRECOGNISED_ERROR);
 }
 
 /* 
@@ -2212,7 +2220,7 @@ static void IDASetCoeffs(IDAMem IDA_mem, realtype *ck)
   /* Set coefficients for the current stepsize h */
 
   if (hh != hused || kk != kused) ns = 0;
-  ns = MIN(ns+1,kused+2);
+  ns = SUNMIN(ns+1,kused+2);
   if (kk+1 >= ns){
     beta[0] = ONE;
     alpha[0] = ONE;
@@ -2244,8 +2252,8 @@ static void IDASetCoeffs(IDAMem IDA_mem, realtype *ck)
   
   /* compute variable stepsize error coefficient ck */
 
-  *ck = ABS(alpha[kk] + alphas - alpha0);
-  *ck = MAX(*ck, alpha[kk]);
+  *ck = SUNRabs(alpha[kk] + alphas - alpha0);
+  *ck = SUNMAX(*ck, alpha[kk]);
 
  /* change phi to phi-star  */
 
@@ -2376,7 +2384,7 @@ static int IDANls(IDAMem IDA_mem)
         N_VLinearSum(ONE, phi[0], -ONE, yy, tempv1);
         N_VProd(mm, tempv1, tempv1);
         rr = PT9*N_VMinQuotient(phi[0], tempv1);
-        rr = MAX(rr,PT1);
+        rr = SUNMAX(rr,PT1);
         return(IDA_CONSTR_RECVR);
       }
     }
@@ -2461,7 +2469,7 @@ static int IDANewtonIter(IDAMem IDA_mem)
        if (delnrm <= toldel) return(IDA_SUCCESS);
     }
     else {
-      rate = RPowerR( delnrm/oldnrm, ONE/mnewt );
+      rate = SUNRpowerR( delnrm/oldnrm, ONE/mnewt );
       if (rate > RATEMAX) return(IDA_NCONV_RECVR); 
       ss = rate/(ONE - rate);
     }
@@ -2534,7 +2542,7 @@ static int IDATestError(IDAMem IDA_mem, realtype ck,
       terr_km2 = (kk-1) * err_km2;
 
       /* Decrease order if errors are reduced */
-      if (MAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1; 
+      if (SUNMAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1;
 
     } else {
 
@@ -2665,8 +2673,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, realtype err_k, realtype er
       err_knew = (kk==knew)? err_k : err_km1;
 
       kk = knew;      
-      rr = PT9 * RPowerR( TWO * err_knew + PT0001,(-ONE/(kk+1)) );
-      rr = MAX(QUARTER, MIN(PT9,rr));
+      rr = PT9 * SUNRpowerR( TWO * err_knew + PT0001,(-ONE/(kk+1)) );
+      rr = SUNMAX(QUARTER, SUNMIN(PT9,rr));
       hh *=rr;
       return(PREDICT_AGAIN);
       
@@ -2755,7 +2763,7 @@ static void IDACompleteStep(IDAMem IDA_mem, realtype err_k, realtype err_km1)
     if(nst > 1) {
       kk++;
       hnew = TWO * hh;
-      if( (tmp = ABS(hnew)*hmax_inv) > ONE ) hnew /= tmp;
+      if( (tmp = SUNRabs(hnew)*hmax_inv) > ONE ) hnew /= tmp;
       hh = hnew;
     }
 
@@ -2787,7 +2795,7 @@ static void IDACompleteStep(IDAMem IDA_mem, realtype err_k, realtype err_km1)
       else                                   {action = RAISE;    goto takeaction;}
     } else {
       terr_km1 = kk * err_km1;
-      if (terr_km1 <= MIN(terr_k, terr_kp1)) {action = LOWER;    goto takeaction;}
+      if (terr_km1 <= SUNMIN(terr_k, terr_kp1)) {action = LOWER;    goto takeaction;}
       else if (terr_kp1 >= terr_k)           {action = MAINTAIN; goto takeaction;}
       else                                   {action = RAISE;    goto takeaction;}
     }
@@ -2804,13 +2812,13 @@ static void IDACompleteStep(IDAMem IDA_mem, realtype err_k, realtype err_km1)
        If hh is reduced, hnew/hh is restricted to be between .5 and .9. */
     
     hnew = hh;
-    rr = RPowerR( (TWO * err_knew + PT0001) , (-ONE/(kk+1) ) );
+    rr = SUNRpowerR( (TWO * err_knew + PT0001) , (-ONE/(kk+1) ) );
     
     if (rr >= TWO) {
       hnew = TWO * hh;
-      if( (tmp = ABS(hnew)*hmax_inv) > ONE ) hnew /= tmp;
+      if( (tmp = SUNRabs(hnew)*hmax_inv) > ONE ) hnew /= tmp;
     } else if (rr <= ONE ) { 
-      rr = MAX(HALF, MIN(PT9,rr));
+      rr = SUNMAX(HALF, SUNMIN(PT9,rr));
       hnew = hh * rr;
     }
     
@@ -2867,7 +2875,7 @@ int IDAGetSolution(void *ida_mem, realtype t, N_Vector yret, N_Vector ypret)
 
   /* Check t for legality.  Here tn - hused is t_{n-1}. */
  
-  tfuzz = HUNDRED * uround * (ABS(tn) + ABS(hh));
+  tfuzz = HUNDRED * uround * (SUNRabs(tn) + SUNRabs(hh));
   if (hh < ZERO) tfuzz = - tfuzz;
   tp = tn - hused - tfuzz;
   if ((t - tp)*hh < ZERO) {
@@ -2941,8 +2949,8 @@ realtype IDAWrmsNorm(IDAMem IDA_mem, N_Vector x, N_Vector w,
  * the initial point of the IVP.
  *
  * This routine returns an int equal to:
- *  IDA_RTFUNC_FAIL < 0  if the g function failed, or
- *  IDA_SUCCESS     = 0  otherwise.
+ *  IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *  IDA_SUCCESS     = 0 otherwise.
  */
 
 static int IDARcheck1(IDAMem IDA_mem)
@@ -2953,7 +2961,7 @@ static int IDARcheck1(IDAMem IDA_mem)
 
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   tlo = tn;
-  ttol = (ABS(tn) + ABS(hh))*uround*HUNDRED;
+  ttol = (SUNRabs(tn) + SUNRabs(hh))*uround*HUNDRED;
 
   /* Evaluate g at initial t and check for zero values. */
   retval = gfun (tlo, phi[0], phi[1], glo, user_data);
@@ -2962,7 +2970,7 @@ static int IDARcheck1(IDAMem IDA_mem)
 
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       gactive[i] = FALSE;
     }
@@ -2970,7 +2978,7 @@ static int IDARcheck1(IDAMem IDA_mem)
   if (!zroot) return(IDA_SUCCESS);
 
   /* Some g_i is zero at t0; look at g at t0+(small increment). */
-  hratio = MAX(ttol/ABS(hh), PT1);
+  hratio = SUNMAX(ttol/SUNRabs(hh), PT1);
   smallh = hratio*hh;
   tplus = tlo + smallh;
   N_VLinearSum(ONE, phi[0], smallh, phi[1], yy);
@@ -2981,12 +2989,11 @@ static int IDARcheck1(IDAMem IDA_mem)
   /* We check now only the components of g which were exactly 0.0 at t0
    * to see if we can 'activate' them. */
   for (i = 0; i < nrtfn; i++) {
-    if (!gactive[i] && ABS(ghi[i]) != ZERO) {
+    if (!gactive[i] && SUNRabs(ghi[i]) != ZERO) {
       gactive[i] = TRUE;
       glo[i] = ghi[i];
     }
   }
-
   return(IDA_SUCCESS);
 }
 
@@ -3005,10 +3012,10 @@ static int IDARcheck1(IDAMem IDA_mem)
  * or the last root location.
  *
  * This routine returns an int equal to:
- *     IDA_RTFUNC_FAIL (<0) if the g function failed, or
- *     CLOSERT     (>0) if a close pair of zeros was found, or
- *     RTFOUND     (>0) if a new zero of g was found near tlo, or
- *     IDA_SUCCESS (=0) otherwise.
+ *     IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *     CLOSERT         = 3 if a close pair of zeros was found, or
+ *     RTFOUND         = 1 if a new zero of g was found near tlo, or
+ *     IDA_SUCCESS     = 0 otherwise.
  */
 
 static int IDARcheck2(IDAMem IDA_mem)
@@ -3028,7 +3035,7 @@ static int IDARcheck2(IDAMem IDA_mem)
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   for (i = 0; i < nrtfn; i++) {
     if (!gactive[i]) continue;
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       iroots[i] = 1;
     }
@@ -3036,7 +3043,7 @@ static int IDARcheck2(IDAMem IDA_mem)
   if (!zroot) return(IDA_SUCCESS);
 
   /* One or more g_i has a zero at tlo.  Check g at tlo+smallh. */
-  ttol = (ABS(tn) + ABS(hh))*uround*HUNDRED;
+  ttol = (SUNRabs(tn) + SUNRabs(hh))*uround*HUNDRED;
   smallh = (hh > ZERO) ? ttol : -ttol;
   tplus = tlo + smallh;
   if ( (tplus - tn)*hh >= ZERO) {
@@ -3054,7 +3061,7 @@ static int IDARcheck2(IDAMem IDA_mem)
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
     if (!gactive[i]) continue;
-    if (ABS(ghi[i]) == ZERO) {
+    if (SUNRabs(ghi[i]) == ZERO) {
       if (iroots[i] == 1) return(CLOSERT);
       zroot = TRUE;
       iroots[i] = 1;
@@ -3074,9 +3081,9 @@ static int IDARcheck2(IDAMem IDA_mem)
  * Only roots beyond tlo in the direction of integration are sought.
  *
  * This routine returns an int equal to:
- *     IDA_RTFUNC_FAIL (<0) if the g function failed, or
- *     RTFOUND     (>0) if a root of g was found, or
- *     IDA_SUCCESS (=0) otherwise.
+ *     IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *     RTFOUND         = 1 if a root of g was found, or
+ *     IDA_SUCCESS     = 0 otherwise.
  */
 
 static int IDARcheck3(IDAMem IDA_mem)
@@ -3098,7 +3105,7 @@ static int IDARcheck3(IDAMem IDA_mem)
   nge++;
   if (retval != 0) return(IDA_RTFUNC_FAIL);
 
-  ttol = (ABS(tn) + ABS(hh))*uround*HUNDRED;
+  ttol = (SUNRabs(tn) + SUNRabs(hh))*uround*HUNDRED;
   ier = IDARootfind(IDA_mem);
   if (ier == IDA_RTFUNC_FAIL) return(IDA_RTFUNC_FAIL);
   for(i=0; i<nrtfn; i++) {
@@ -3113,7 +3120,6 @@ static int IDARcheck3(IDAMem IDA_mem)
   /* If a root was found, interpolate to get y(trout) and return.  */
   (void) IDAGetSolution(IDA_mem, trout, yy, yp);
   return(RTFOUND);
-
 }
 
 /*
@@ -3125,7 +3131,7 @@ static int IDARcheck3(IDAMem IDA_mem)
  * Here the sign of tlo - thi is arbitrary, but if multiple roots
  * are found, the one closest to tlo is returned.
  *
- *  The method used is the Illinois algorithm, a modified secant method.
+ * The method used is the Illinois algorithm, a modified secant method.
  * Reference: Kathie L. Hiebert and Lawrence F. Shampine, Implicitly
  * Defined Output Points for Solutions of ODEs, Sandia National
  * Laboratory Report SAND80-0180, February 1980.
@@ -3136,7 +3142,7 @@ static int IDARcheck3(IDAMem IDA_mem)
  *            the vector-valued function g(t).  Input only.
  *
  * gfun     = user-defined function for g(t).  Its form is
- *           (void) gfun(t, y, yp, gt, user_data)
+ *            (void) gfun(t, y, yp, gt, user_data)
  *
  * rootdir  = in array specifying the direction of zero-crossings.
  *            If rootdir[i] > 0, search for roots of g_i only if
@@ -3158,11 +3164,11 @@ static int IDARcheck3(IDAMem IDA_mem)
  *            When a root at trout is found, it is located only to
  *            within a tolerance of ttol.  Typically, ttol should
  *            be set to a value on the order of
- *              100 * UROUND * max (ABS(tlo), ABS(thi))
+ *               100 * UROUND * max (SUNRabs(tlo), SUNRabs(thi))
  *            where UROUND is the unit roundoff of the machine.
  *
  * tlo, thi = endpoints of the interval in which roots are sought.
- *            On input, and must be distinct, but tlo - thi may
+ *            On input, these must be distinct, but tlo - thi may
  *            be of either sign.  The direction of integration is
  *            assumed to be from tlo to thi.  On return, tlo and thi
  *            are the endpoints of the final relevant interval.
@@ -3188,9 +3194,9 @@ static int IDARcheck3(IDAMem IDA_mem)
  *            to that indicated by rootdir[i].
  *
  * This routine returns an int equal to:
- *      IDA_RTFUNC_FAIL (<0) if the g function failed, or
- *      RTFOUND = 1 if a root of g was found, or
- *      IDA_SUCCESS = 0 otherwise.
+ *      IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *      RTFOUND         = 1 if a root of g was found, or
+ *      IDA_SUCCESS     = 0 otherwise.
  *
  */
 
@@ -3208,13 +3214,13 @@ static int IDARootfind(IDAMem IDA_mem)
   sgnchg = FALSE;
   for (i = 0;  i < nrtfn; i++) {
     if(!gactive[i]) continue;
-    if (ABS(ghi[i]) == ZERO) {
+    if (SUNRabs(ghi[i]) == ZERO) {
       if(rootdir[i]*glo[i] <= ZERO) {
         zroot = TRUE;
       }
     } else {
       if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-        gfrac = ABS(ghi[i]/(ghi[i] - glo[i]));
+        gfrac = SUNRabs(ghi[i]/(ghi[i] - glo[i]));
         if (gfrac > maxfrac) {
           sgnchg = TRUE;
           maxfrac = gfrac;
@@ -3233,7 +3239,8 @@ static int IDARootfind(IDAMem IDA_mem)
     for (i = 0; i < nrtfn; i++) {
       iroots[i] = 0;
       if(!gactive[i]) continue;
-      if (ABS(ghi[i]) == ZERO) iroots[i] = glo[i] > 0 ? -1:1;
+      if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
+        iroots[i] = glo[i] > 0 ? -1:1;
     }
     return(RTFOUND);
   }
@@ -3246,6 +3253,9 @@ static int IDARootfind(IDAMem IDA_mem)
   side = 0;  sideprev = -1;
   loop {                                    /* Looping point */
 
+    /* If interval size is already less than tolerance ttol, break. */
+      if (SUNRabs(thi - tlo) <= ttol) break;
+
     /* Set weight alph.
        On the first two passes, set alph = 1.  Thereafter, reset alph
        according to the side (low vs high) of the subinterval in which
@@ -3266,13 +3276,13 @@ static int IDARootfind(IDAMem IDA_mem)
        If tmid is too close to tlo or thi, adjust it inward,
        by a fractional distance that is between 0.1 and 0.5.  */
     tmid = thi - (thi - tlo)*ghi[imax]/(ghi[imax] - alph*glo[imax]);
-    if (ABS(tmid - tlo) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
+    if (SUNRabs(tmid - tlo) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
       fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = tlo + fracsub*(thi - tlo);
     }
-    if (ABS(thi - tmid) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
+    if (SUNRabs(thi - tmid) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
       fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = thi - fracsub*(thi - tlo);
     }
@@ -3290,13 +3300,11 @@ static int IDARootfind(IDAMem IDA_mem)
     sideprev = side;
     for (i = 0;  i < nrtfn; i++) {
       if(!gactive[i]) continue;
-      if (ABS(grout[i]) == ZERO) {
-        if(rootdir[i]*glo[i] <= ZERO) {
-          zroot = TRUE;
-        }
+      if (SUNRabs(grout[i]) == ZERO) {
+        if(rootdir[i]*glo[i] <= ZERO) zroot = TRUE;
       } else {
         if ( (glo[i]*grout[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-          gfrac = ABS(grout[i]/(grout[i] - glo[i]));
+          gfrac = SUNRabs(grout[i]/(grout[i] - glo[i]));
           if (gfrac > maxfrac) {
             sgnchg = TRUE;
             maxfrac = gfrac;
@@ -3311,8 +3319,8 @@ static int IDARootfind(IDAMem IDA_mem)
       for (i = 0; i < nrtfn; i++) ghi[i] = grout[i];
       side = 1;
       /* Stop at root thi if converged; otherwise loop. */
-      if (ABS(thi - tlo) <= ttol) break;
-    continue;  /* Return to looping point. */
+      if (SUNRabs(thi - tlo) <= ttol) break;
+      continue;  /* Return to looping point. */
     }
 
     if (zroot) {
@@ -3328,7 +3336,7 @@ static int IDARootfind(IDAMem IDA_mem)
     for (i = 0; i < nrtfn; i++) glo[i] = grout[i];
     side = 2;
     /* Stop at root thi if converged; otherwise loop back. */
-    if (ABS(thi - tlo) <= ttol) break;
+    if (SUNRabs(thi - tlo) <= ttol) break;
 
   } /* End of root-search loop */
 
@@ -3338,7 +3346,7 @@ static int IDARootfind(IDAMem IDA_mem)
     grout[i] = ghi[i];
     iroots[i] = 0;
     if(!gactive[i]) continue;
-    if ( (ABS(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
+    if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
       iroots[i] = glo[i] > 0 ? -1:1;
     if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
       iroots[i] = glo[i] > 0 ? -1:1;
@@ -3352,11 +3360,11 @@ static int IDARootfind(IDAMem IDA_mem)
  * =================================================================
  */
 
-/* 
- * IDAProcessError is a high level error handling function
- * - if ida_mem==NULL it prints the error message to stderr
- * - otherwise, it sets-up and calls the error hadling function 
- *   pointed to by ida_ehfun
+/*
+ * IDAProcessError is a high level error handling function.
+ * - If ida_mem==NULL it prints the error message to stderr.
+ * - Otherwise, it sets up and calls the error handling function 
+ *   pointed to by ida_ehfun.
  */
 
 #define ehfun   (IDA_mem->ida_ehfun)
@@ -3374,32 +3382,24 @@ void IDAProcessError(IDAMem IDA_mem,
 
   va_start(ap, msgfmt);
 
-  if (IDA_mem == NULL) {    /* We write to stderr */
+  /* Compose the message */
 
+  vsprintf(msg, msgfmt, ap);
+
+  if (IDA_mem == NULL) {    /* We write to stderr */
 #ifndef NO_FPRINTF_OUTPUT
     fprintf(stderr, "\n[%s ERROR]  %s\n  ", module, fname);
-    fprintf(stderr, msgfmt);
-    fprintf(stderr, "\n\n");
+    fprintf(stderr, "%s\n\n", msg);
 #endif
 
   } else {                 /* We can call ehfun */
-
-    /* Compose the message */
-
-    vsprintf(msg, msgfmt, ap);
-
-    /* Call ehfun */
-
     ehfun(error_code, module, fname, msg, eh_data);
-
   }
 
   /* Finalize argument processing */
-  
   va_end(ap);
 
   return;
-
 }
 
 /* IDAErrHandler is the default error handling function.
diff --git a/src/ida/ida_band.c b/src/ida/ida_band.c
index c7b84a0..11992fa 100644
--- a/src/ida/ida_band.c
+++ b/src/ida/ida_band.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2011/03/23 20:44:01 $
+ * $Revision: 4951 $
+ * $Date: 2016-09-22 10:21:00 -0700 (Thu, 22 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDA banded linear
  * solver module, IDABAND. This module uses standard banded
@@ -111,7 +116,6 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
 {
   IDAMem IDA_mem;
   IDADlsMem idadls_mem;
-  int flag;
 
   /* Return immediately if ida_mem is NULL. */
   if (ida_mem == NULL) {
@@ -132,7 +136,7 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
     return(IDADLS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem. */
   linit  = IDABandInit;
@@ -159,6 +163,8 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
 
   last_flag = IDADLS_SUCCESS;
 
+  idaDlsInitializeCounters(idadls_mem);
+
   setupNonNull = TRUE;
 
   /* Store problem size */
@@ -168,7 +174,7 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
   idadls_mem->d_mu = mupper;
     
   /* Set extended upper half-bandwidth for JJ (required for pivoting). */
-  smu = MIN(Neq-1, mupper + mlower);
+  smu = SUNMIN(Neq-1, mupper + mlower);
 
   /* Allocate memory for JJ and pivot array. */
   JJ = NULL;
@@ -211,9 +217,12 @@ static int IDABandInit(IDAMem IDA_mem)
 
   idadls_mem = (IDADlsMem) lmem;
 
-  /* Initialize nje and nreB */
-  nje   = 0;
-  nreDQ = 0;
+  idaDlsInitializeCounters(idadls_mem);
+
+/*
+    nje   = 0;
+    nreDQ = 0;
+*/
 
   if (jacDQ) {
     bjac = idaDlsBandDQJac;
diff --git a/src/ida/ida_bbdpre.c b/src/ida/ida_bbdpre.c
index 977a516..dcf3d00 100644
--- a/src/ida/ida_bbdpre.c
+++ b/src/ida/ida_bbdpre.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2011/03/23 20:44:01 $
+ * $Revision: 4920 $
+ * $Date: 2016-09-19 14:34:35 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file contains implementations of routines for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -53,7 +58,7 @@ static int IDABBDPrecSolve(realtype tt,
 
 /* Prototype for IDABBDPrecFree */
 
-static void IDABBDPrecFree(IDAMem ida_mem);
+static int IDABBDPrecFree(IDAMem ida_mem);
 
 /* Prototype for difference quotient Jacobian calculation routine */
 
@@ -122,15 +127,15 @@ int IDABBDPrecInit(void *ida_mem, long int Nlocal,
   pdata->ida_mem = IDA_mem;
   pdata->glocal = Gres;
   pdata->gcomm = Gcomm;
-  pdata->mudq = MIN(Nlocal-1, MAX(0, mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0, mldq));
-  muk = MIN(Nlocal-1, MAX(0, mukeep));
-  mlk = MIN(Nlocal-1, MAX(0, mlkeep));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
+  muk = SUNMIN(Nlocal-1, SUNMAX(0, mukeep));
+  mlk = SUNMIN(Nlocal-1, SUNMAX(0, mlkeep));
   pdata->mukeep = muk;
   pdata->mlkeep = mlk;
 
   /* Set extended upper half-bandwidth for PP (required for pivoting). */
-  storage_mu = MIN(Nlocal-1, muk+mlk);
+  storage_mu = SUNMIN(Nlocal-1, muk+mlk);
 
   /* Allocate memory for preconditioner matrix. */
   pdata->PP = NULL;
@@ -164,7 +169,7 @@ int IDABBDPrecInit(void *ida_mem, long int Nlocal,
   pdata->tempv4 = tempv4;
   
   /* Set rel_yy based on input value dq_rel_yy (0 implies default). */
-  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : RSqrt(uround); 
+  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : SUNRsqrt(uround); 
 
   /* Store Nlocal to be used in IDABBDPrecSetup */
   pdata->n_local = Nlocal;
@@ -174,7 +179,12 @@ int IDABBDPrecInit(void *ida_mem, long int Nlocal,
   pdata->ipwsize = Nlocal;
   pdata->nge = 0;
 
-  /* Overwrite the pdata field in the SPILS memory */
+  /* make sure s_pdata is free from any previous allocations */
+  if (idaspils_mem->s_pfree != NULL) {
+    idaspils_mem->s_pfree(IDA_mem);
+  }
+
+  /* Point to the new pdata field in the SPILS memory */
   idaspils_mem->s_pdata = pdata;
 
   /* Attach the pfree function */
@@ -218,11 +228,11 @@ int IDABBDPrecReInit(void *ida_mem,
 
   /* Load half-bandwidths. */
   Nlocal = pdata->n_local;
-  pdata->mudq = MIN(Nlocal-1, MAX(0, mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0, mldq));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
 
   /* Set rel_yy based on input value dq_rel_yy (0 implies default). */
-  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : RSqrt(uround); 
+  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : SUNRsqrt(uround); 
 
   /* Re-initialize nge */
   pdata->nge = 0;
@@ -424,15 +434,15 @@ static int IDABBDPrecSolve(realtype tt,
 
 
 
-static void IDABBDPrecFree(IDAMem IDA_mem)
+static int IDABBDPrecFree(IDAMem IDA_mem)
 {
   IDASpilsMem idaspils_mem;
   IBBDPrecData pdata;
   
-  if (IDA_mem->ida_lmem == NULL) return;
+  if (IDA_mem->ida_lmem == NULL) return(0);
   idaspils_mem = (IDASpilsMem) IDA_mem->ida_lmem;
   
-  if (idaspils_mem->s_pdata == NULL) return;
+  if (idaspils_mem->s_pdata == NULL) return(0);
   pdata = (IBBDPrecData) idaspils_mem->s_pdata;
 
   DestroyMat(PP);
@@ -441,6 +451,8 @@ static void IDABBDPrecFree(IDAMem IDA_mem)
 
   free(pdata);
   pdata = NULL;
+
+  return(0);
 }
 
 
@@ -516,7 +528,7 @@ static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
   /* Set bandwidth and number of column groups for band differencing. */
 
   width = mldq + mudq + 1;
-  ngroups = MIN(width, Nlocal);
+  ngroups = SUNMIN(width, Nlocal);
 
   /* Loop over groups. */
   for(group = 1; group <= ngroups; group++) {
@@ -530,15 +542,15 @@ static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
       /* Set increment inc to yj based on rel_yy*abs(yj), with
          adjustments using ypj and ewtj if this is small, and a further
          adjustment to give it the same sign as hh*ypj. */
-      inc = rel_yy*MAX(ABS(yj), MAX( ABS(hh*ypj), ONE/ewtj));
+      inc = rel_yy*SUNMAX(SUNRabs(yj), SUNMAX( SUNRabs(hh*ypj), ONE/ewtj));
       if (hh*ypj < ZERO) inc = -inc;
       inc = (yj + inc) - yj;
       
       /* Adjust sign(inc) again if yj has an inequality constraint. */
       if (constraints != NULL) {
         conj = cnsdata[j];
-        if (ABS(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
-        else if (ABS(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
+        if (SUNRabs(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
+        else if (SUNRabs(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
       }
 
       /* Increment yj and ypj. */
@@ -560,20 +572,20 @@ static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
       ewtj = ewtdata[j];
 
       /* Set increment inc as before .*/
-      inc = rel_yy*MAX(ABS(yj), MAX( ABS(hh*ypj), ONE/ewtj));
+      inc = rel_yy*SUNMAX(SUNRabs(yj), SUNMAX( SUNRabs(hh*ypj), ONE/ewtj));
       if (hh*ypj < ZERO) inc = -inc;
       inc = (yj + inc) - yj;
       if (constraints != NULL) {
         conj = cnsdata[j];
-        if (ABS(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
-        else if (ABS(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
+        if (SUNRabs(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
+        else if (SUNRabs(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
       }
 
       /* Form difference quotients and load into PP. */
       inc_inv = ONE/inc;
       col_j = BAND_COL(PP,j);
-      i1 = MAX(0, j-mukeep);
-      i2 = MIN(j+mlkeep, Nlocal-1);
+      i1 = SUNMAX(0, j-mukeep);
+      i2 = SUNMIN(j+mlkeep, Nlocal-1);
       for(i = i1; i <= i2; i++) BAND_COL_ELEM(col_j,i,j) =
                                   inc_inv * (gtempdata[i] - grefdata[i]);
     }
diff --git a/src/ida/ida_bbdpre_impl.h b/src/ida/ida_bbdpre_impl.h
index 3affc14..a9ef672 100644
--- a/src/ida/ida_bbdpre_impl.h
+++ b/src/ida/ida_bbdpre_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:35:26 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file (private version) for the IDABBDPRE
  * module, for a band-block-diagonal preconditioner, i.e. a
@@ -20,13 +25,13 @@
 #ifndef _IDABBDPRE_IMPL_H
 #define _IDABBDPRE_IMPL_H
 
+#include <ida/ida_bbdpre.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_bbdpre.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Definition of IBBDPrecData
diff --git a/src/ida/ida_dense.c b/src/ida/ida_dense.c
index a0e241e..f98b168 100644
--- a/src/ida/ida_dense.c
+++ b/src/ida/ida_dense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2011/03/23 20:44:01 $
+ * $Revision: 4951 $
+ * $Date: 2016-09-22 10:21:00 -0700 (Thu, 22 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDADENSE linear solver.
  * -----------------------------------------------------------------
@@ -104,7 +109,6 @@ int IDADense(void *ida_mem, long int Neq)
 {
   IDAMem IDA_mem;
   IDADlsMem idadls_mem;
-  int flag;
 
   /* Return immediately if ida_mem is NULL. */
   if (ida_mem == NULL) {
@@ -120,7 +124,7 @@ int IDADense(void *ida_mem, long int Neq)
     return(IDADLS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree(IDA_mem);
+  if (lfree != NULL) lfree(IDA_mem);
 
   /* Set five main function fields in IDA_mem. */
   linit  = IDADenseInit;
@@ -147,6 +151,8 @@ int IDADense(void *ida_mem, long int Neq)
 
   last_flag = IDADLS_SUCCESS;
 
+  idaDlsInitializeCounters(idadls_mem);
+
   setupNonNull = TRUE;
 
   /* Store problem size */
@@ -193,9 +199,11 @@ static int IDADenseInit(IDAMem IDA_mem)
   
   idadls_mem = (IDADlsMem) lmem;
 
-   
-  nje   = 0;
-  nreDQ = 0;
+  idaDlsInitializeCounters(idadls_mem);
+  /*
+   nje   = 0;
+   nreDQ = 0;
+  */
 
   if (jacDQ) {
     djac = idaDlsDenseDQJac;
diff --git a/src/ida/ida_direct.c b/src/ida/ida_direct.c
index b53ca80..9f7d403 100644
--- a/src/ida/ida_direct.c
+++ b/src/ida/ida_direct.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:35:26 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for an IDADLS linear solver.
  * -----------------------------------------------------------------
@@ -347,7 +352,7 @@ int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
   yp_data  = N_VGetArrayPointer(yp);
   if(constraints!=NULL) cns_data = N_VGetArrayPointer(constraints);
 
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
 
   for (j=0; j < N; j++) {
 
@@ -362,7 +367,7 @@ int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
     adjustments using yp_j and ewt_j if this is small, and a further
     adjustment to give it the same sign as hh*yp_j. */
 
-    inc = MAX( srur * MAX( ABS(yj), ABS(hh*ypj) ) , ONE/ewt_data[j] );
+    inc = SUNMAX( srur * SUNMAX( SUNRabs(yj), SUNRabs(hh*ypj) ) , ONE/ewt_data[j] );
 
     if (hh*ypj < ZERO) inc = -inc;
     inc = (yj + inc) - yj;
@@ -370,8 +375,8 @@ int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
     /* Adjust sign(inc) again if y_j has an inequality constraint. */
     if (constraints != NULL) {
       conj = cns_data[j];
-      if (ABS(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
-      else if (ABS(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
+      if (SUNRabs(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
+      else if (SUNRabs(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
     }
 
     /* Increment y_j and yp_j, call res, and break on error return. */
@@ -462,9 +467,9 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
 
   /* Compute miscellaneous values for the Jacobian computation. */
 
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   width = mlower + mupper + 1;
-  ngroups = MIN(width, N);
+  ngroups = SUNMIN(width, N);
 
   /* Loop over column groups. */
   for (group=1; group <= ngroups; group++) {
@@ -480,7 +485,7 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
         adjustments using ypj and ewtj if this is small, and a further
         adjustment to give it the same sign as hh*ypj. */
 
-        inc = MAX( srur * MAX( ABS(yj), ABS(hh*ypj) ) , ONE/ewtj );
+        inc = SUNMAX( srur * SUNMAX( SUNRabs(yj), SUNRabs(hh*ypj) ) , ONE/ewtj );
 
         if (hh*ypj < ZERO) inc = -inc;
         inc = (yj + inc) - yj;
@@ -489,8 +494,8 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
 
         if (constraints != NULL) {
           conj = cns_data[j];
-          if (ABS(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
-          else if (ABS(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
+          if (SUNRabs(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
+          else if (SUNRabs(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
         }
 
         /* Increment yj and ypj. */
@@ -518,20 +523,20 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
       
       /* Set increment inc exactly as above. */
 
-      inc = MAX( srur * MAX( ABS(yj), ABS(hh*ypj) ) , ONE/ewtj );
+      inc = SUNMAX( srur * SUNMAX( SUNRabs(yj), SUNRabs(hh*ypj) ) , ONE/ewtj );
       if (hh*ypj < ZERO) inc = -inc;
       inc = (yj + inc) - yj;
       if (constraints != NULL) {
         conj = cns_data[j];
-        if (ABS(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
-        else if (ABS(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
+        if (SUNRabs(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
+        else if (SUNRabs(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
       }
       
       /* Load the difference quotient Jacobian elements for column j. */
 
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mupper);
-      i2 = MIN(j+mlower,N-1);
+      i1 = SUNMAX(0, j-mupper);
+      i2 = SUNMIN(j+mlower,N-1);
       
       for (i=i1; i<=i2; i++) 
             BAND_COL_ELEM(col_j,i,j) = inc_inv*(rtemp_data[i]-r_data[i]);
@@ -542,3 +547,10 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
   return(retval);
   
 }
+
+int idaDlsInitializeCounters(IDADlsMem idadls_mem)
+{
+  idadls_mem->d_nje   = 0;
+  idadls_mem->d_nreDQ = 0;
+  return(0);
+}
diff --git a/src/ida/ida_direct_impl.h b/src/ida/ida_direct_impl.h
index c887899..8361d19 100644
--- a/src/ida/ida_direct_impl.h
+++ b/src/ida/ida_direct_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:35:26 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the IDADLS linear solvers.
  * -----------------------------------------------------------------
@@ -17,12 +22,12 @@
 #ifndef _IDADLS_IMPL_H
 #define _IDADLS_IMPL_H
 
+#include <ida/ida_direct.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_direct.h>
-
 /*
  * =================================================================
  * I D A D I R E C T    I N T E R N A L    C O N S T A N T S
@@ -72,15 +77,20 @@ typedef struct IDADlsMemRec {
  */
   
 int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
-		     N_Vector yy, N_Vector yp, N_Vector rr, 
-		     DlsMat Jac, void *data,
-		     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                     N_Vector yy, N_Vector yp, N_Vector rr, 
+                     DlsMat Jac, void *data,
+                     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
   
 int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
-		    realtype tt, realtype c_j, 
-		    N_Vector yy, N_Vector yp, N_Vector rr,
-		    DlsMat Jac, void *data,
-		    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                    realtype tt, realtype c_j, 
+                    N_Vector yy, N_Vector yp, N_Vector rr,
+                    DlsMat Jac, void *data,
+                    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Auxilliary functions */
+
+int idaDlsInitializeCounters(IDADlsMem idadls_mem);
+
 
 /*
  * =================================================================
diff --git a/src/ida/ida_ic.c b/src/ida/ida_ic.c
index 43bafc2..2da1bca 100644
--- a/src/ida/ida_ic.c
+++ b/src/ida/ida_ic.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:29:00 $
+ * $Revision: 4536 $
+ * $Date: 2015-09-16 14:14:12 -0700 (Wed, 16 Sep 2015) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh, and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IC calculation for IDA.
  * It is independent of the linear solver in use.                  
@@ -97,6 +102,7 @@ static int IDAICFailFlag(IDAMem IDA_mem, int retval);
 #define cj             (IDA_mem->ida_cj)
 #define cjratio        (IDA_mem->ida_cjratio)
 #define nbacktr        (IDA_mem->ida_nbacktr)
+#define maxbacks       (IDA_mem->ida_maxbacks)
 #define nre            (IDA_mem->ida_nre)
 #define ncfn           (IDA_mem->ida_ncfn)
 #define nni            (IDA_mem->ida_nni)
@@ -147,7 +153,8 @@ static int IDAICFailFlag(IDAMem IDA_mem, int retval);
  *   IDA_NO_RECOVERY     res, lsetup, or lsolve had a recoverable
  *                       error, but IDACalcIC could not recover
  *   IDA_CONSTR_FAIL     the inequality constraints could not be met
- *   IDA_LINESEARCH_FAIL the linesearch failed (on steptol test)
+ *   IDA_LINESEARCH_FAIL the linesearch failed (either on steptol test
+ *                       or on the maxbacks test)
  *   IDA_CONV_FAIL       the Newton iterations failed to converge
  * -----------------------------------------------------------------
  */
@@ -193,8 +200,8 @@ int IDACalcIC(void *ida_mem, int icopt, realtype tout1)
     return(IDA_ILL_INPUT);
   }
 
-  tdist = ABS(tout1 - tn);
-  troundoff = TWO*uround*(ABS(tn) + ABS(tout1));    
+  tdist = SUNRabs(tout1 - tn);
+  troundoff = TWO*uround*(SUNRabs(tn) + SUNRabs(tout1));
   if(tdist < troundoff) {
     IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDACalcIC", MSG_IC_TOO_CLOSE);
     return(IDA_ILL_INPUT);
@@ -332,7 +339,8 @@ int IDACalcIC(void *ida_mem, int icopt, realtype tout1)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res, lsetup, or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  *  IC_CONV_FAIL       if the Newton iterations failed to converge
  *  IC_SLOW_CONVRG     if the iterations are converging slowly
  *                     (failed the convergence test, but showed
@@ -404,7 +412,8 @@ static int IDAnlsIC (IDAMem IDA_mem)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  *  IC_CONV_FAIL       if the Newton iterations failed to converge
  *  IC_SLOW_CONVRG     if the iterations appear to be converging slowly.
  *                     They failed the convergence test, but showed 
@@ -431,7 +440,7 @@ static int IDANewtonIC(IDAMem IDA_mem)
 
   /* Compute the norm of the step; return now if this is small. */
   fnorm = IDAWrmsNorm(IDA_mem, delta, ewt, FALSE);
-  if(sysindex == 0) fnorm *= tscale*ABS(cj);
+  if(sysindex == 0) fnorm *= tscale*SUNRabs(cj);
   if(fnorm <= epsNewt) return(IDA_SUCCESS);
   fnorm0 = fnorm;
 
@@ -486,7 +495,8 @@ static int IDANewtonIC(IDAMem IDA_mem)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  * The error return values (negative) considered non-recoverable are:
  *  IDA_RES_FAIL   if res had a non-recoverable error
  *  IDA_LSOLVE_FAIL      if lsolve had a non-recoverable error
@@ -496,7 +506,7 @@ static int IDANewtonIC(IDAMem IDA_mem)
 static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
 {
   booleantype conOK;
-  int retval;
+  int retval, nbacks;
   realtype f1norm, fnormp, f1normp, ratio, lambda, minlam, slpi;
   N_Vector mc;
 
@@ -530,6 +540,7 @@ static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
   slpi = -TWO*f1norm*ratio;
   minlam = steptol/(*delnorm);
   lambda = ONE;
+  nbacks = 0;
 
   /* In IDA_Y_INIT case, set ypnew = yp0 (fixed) for linesearch. */
   if(icopt == IDA_Y_INIT) N_VScale(ONE, yp0, ypnew);
@@ -538,6 +549,7 @@ static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
 
   loop {
 
+    if (nbacks == maxbacks) return(IC_LINESRCH_FAILED);
     /* Get new (y,y') = (ynew,ypnew) and norm of new function value. */
     IDANewyyp(IDA_mem, lambda);
     retval = IDAfnorm(IDA_mem, &fnormp);
@@ -551,7 +563,7 @@ static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
     if(f1normp <= f1norm + ALPHALS*slpi*lambda) break;
     if(lambda < minlam) return(IC_LINESRCH_FAILED);
     lambda /= TWO;
-    nbacktr++;
+    nbacktr++; nbacks++;
 
   }  /* End of breakout linesearch loop */
 
@@ -601,7 +613,7 @@ static int IDAfnorm(IDAMem IDA_mem, realtype *fnorm)
 
   /* Compute the WRMS-norm; rescale if index = 0. */
   *fnorm = IDAWrmsNorm(IDA_mem, delnew, ewt, FALSE);
-  if(sysindex == 0) (*fnorm) *= tscale*ABS(cj);
+  if(sysindex == 0) (*fnorm) *= tscale*SUNRabs(cj);
 
   return(IDA_SUCCESS);
 
diff --git a/src/ida/ida_impl.h b/src/ida/ida_impl.h
index 331ac1f..1ea32af 100644
--- a/src/ida/ida_impl.h
+++ b/src/ida/ida_impl.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.15 $
- * $Date: 2009/09/09 22:25:05 $
+ * $Revision: 4920 $
+ * $Date: 2016-09-19 14:34:35 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Allan G. Taylor, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file (private version) for the main IDA solver.
  * -----------------------------------------------------------------
@@ -18,14 +23,14 @@
 #ifndef _IDA_IMPL_H
 #define _IDA_IMPL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <stdarg.h>
 
 #include <ida/ida.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* 
  * =================================================================
  *   M A I N    I N T E G R A T O R    M E M O R Y    B L O C K
@@ -69,9 +74,9 @@ typedef struct IDAMemRec {
 
   booleantype    ida_setupNonNull;   /* Does setup do something?              */
   booleantype    ida_constraintsSet; /* constraints vector present: 
-					do constraints calc                   */
+                                        do constraints calc                   */
   booleantype    ida_suppressalg;    /* true means suppress algebraic vars
-					in local error tests                  */
+                                        in local error tests                  */
 
   /* Divided differences array and associated minor arrays */
 
@@ -93,8 +98,8 @@ typedef struct IDAMemRec {
   N_Vector ida_constraints; /* vector of inequality constraint options        */
   N_Vector ida_savres;      /* saved residual vector (= tempv1)               */
   N_Vector ida_ee;          /* accumulated corrections to y vector, but
-			       set equal to estimated local errors upon
-			       successful return                              */
+                               set equal to estimated local errors upon
+                               successful return                              */
   N_Vector ida_mm;          /* mask vector in constraints tests (= tempv2)    */
   N_Vector ida_tempv1;      /* work space vector                              */
   N_Vector ida_tempv2;      /* work space vector                              */
@@ -116,6 +121,7 @@ typedef struct IDAMemRec {
   int ida_maxnit;           /* max. number of Netwon iterations in IC calc.   */
   int ida_nbacktr;          /* number of IC linesearch backtrack operations   */
   int ida_sysindex;         /* computed system index (0 or 1)                 */
+  int ida_maxbacks;         /* max backtracks per Newton step                 */
   realtype ida_epiccon;     /* IC nonlinear convergence test constant         */
   realtype ida_steptol;     /* minimum Newton step size in IC calculation     */
   realtype ida_tscale;      /* time scale factor = abs(tout1 - t0)            */
@@ -204,11 +210,11 @@ typedef struct IDAMemRec {
   int (*ida_linit)(struct IDAMemRec *idamem);
 
   int (*ida_lsetup)(struct IDAMemRec *idamem, N_Vector yyp, 
-		    N_Vector ypp, N_Vector resp, 
-		    N_Vector tempv1, N_Vector tempv2, N_Vector tempv3); 
+                    N_Vector ypp, N_Vector resp, 
+                    N_Vector tempv1, N_Vector tempv2, N_Vector tempv3); 
 
   int (*ida_lsolve)(struct IDAMemRec *idamem, N_Vector b, N_Vector weight,
-		    N_Vector ycur, N_Vector ypcur, N_Vector rescur);
+                    N_Vector ycur, N_Vector ypcur, N_Vector rescur);
 
   int (*ida_lperf)(struct IDAMemRec *idamem, int perftask);
 
@@ -332,7 +338,8 @@ typedef struct IDAMemRec {
  * -----------------------------------------------------------------
  * ida_lfree should free up any memory allocated by the linear     
  * solver. This routine is called once a problem has been          
- * completed and the linear solver is no longer needed.            
+ * completed and the linear solver is no longer needed.  It should 
+ * return 0 upon success, nonzero on failure.
  * -----------------------------------------------------------------
  */                                                                 
 
@@ -349,13 +356,13 @@ int IDAEwtSet(N_Vector ycur, N_Vector weight, void *data);
 /* High level error handler */
 
 void IDAProcessError(IDAMem IDA_mem, 
-		     int error_code, const char *module, const char *fname, 
-		     const char *msgfmt, ...);
+                     int error_code, const char *module, const char *fname, 
+                     const char *msgfmt, ...);
 
 /* Prototype of internal errHandler function */
 
 void IDAErrHandler(int error_code, const char *module, const char *function, 
-		   char *msg, void *data);
+                   char *msg, void *data);
 
 /*
  * =================================================================
@@ -418,6 +425,7 @@ void IDAErrHandler(int error_code, const char *module, const char *function,
 /* IDACalcIC error messages */
 
 #define MSG_IC_BAD_ICOPT   "icopt has an illegal value."
+#define MSG_IC_BAD_MAXBACKS "maxbacks <= 0 illegal."
 #define MSG_IC_MISSING_ID  "id = NULL conflicts with icopt."
 #define MSG_IC_TOO_CLOSE   "tout1 too close to t0 to attempt initial condition calculation."
 #define MSG_IC_BAD_ID      "id has illegal values."
@@ -428,7 +436,7 @@ void IDAErrHandler(int error_code, const char *module, const char *function,
 #define MSG_IC_SOLVE_FAIL  "The linear solver solve failed unrecoverably."
 #define MSG_IC_NO_RECOVERY "The residual routine or the linear setup or solve routine had a recoverable error, but IDACalcIC was unable to recover."
 #define MSG_IC_FAIL_CONSTR "Unable to satisfy the inequality constraints."
-#define MSG_IC_FAILED_LINS "The linesearch algorithm failed with too small a step."
+#define MSG_IC_FAILED_LINS "The linesearch algorithm failed: step too small or too many backtracks."
 #define MSG_IC_CONV_FAILED "Newton/Linesearch algorithm failed to converge."
 
 /* IDASolve error messages */
diff --git a/src/ida/ida_io.c b/src/ida/ida_io.c
index d180dd5..ade32f5 100644
--- a/src/ida/ida_io.c
+++ b/src/ida/ida_io.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.15 $
- * $Date: 2010/12/01 22:35:26 $
+ * $Revision: 4529 $
+ * $Date: 2015-09-02 15:41:00 -0700 (Wed, 02 Sep 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan Hindmarsh, Radu Serban and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the optional inputs and     
  * outputs for the IDA solver.                                    
@@ -123,7 +128,7 @@ int IDASetMaxOrd(void *ida_mem, int maxord)
     return(IDA_ILL_INPUT);
   }  
 
-  IDA_mem->ida_maxord = MIN(maxord,MAXORD_DEFAULT);
+  IDA_mem->ida_maxord = SUNMIN(maxord,MAXORD_DEFAULT);
 
   return(IDA_SUCCESS);
 }
@@ -218,7 +223,7 @@ int IDASetStopTime(void *ida_mem, realtype tstop)
   if (IDA_mem->ida_nst > 0) {
 
     if ( (tstop - IDA_mem->ida_tn) * IDA_mem->ida_hh < ZERO ) {
-      IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASetStopTime", MSG_BAD_TSTOP, IDA_mem->ida_tn);
+      IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASetStopTime", MSG_BAD_TSTOP, tstop, IDA_mem->ida_tn);
       return(IDA_ILL_INPUT);
     }
 
@@ -574,6 +579,29 @@ int IDASetMaxNumItersIC(void *ida_mem, int maxnit)
 
 /*-----------------------------------------------------------------*/
 
+int IDASetMaxBacksIC(void *ida_mem, int maxbacks)
+{
+  IDAMem IDA_mem;
+
+  if (ida_mem==NULL) {
+    IDAProcessError(NULL, IDA_MEM_NULL, "IDA", "IDASetMaxBacksIC", MSG_NO_MEM);
+    return(IDA_MEM_NULL);
+  }
+
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (maxbacks <= 0) {
+    IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASetMaxBacksIC", MSG_IC_BAD_MAXBACKS);
+    return(IDA_ILL_INPUT);
+  }
+
+  IDA_mem->ida_maxbacks = maxbacks;
+
+  return(IDA_SUCCESS);
+}
+
+/*-----------------------------------------------------------------*/
+
 int IDASetLineSearchOffIC(void *ida_mem, booleantype lsoff)
 {
   IDAMem IDA_mem;
diff --git a/src/ida/ida_klu.c b/src/ida/ida_klu.c
new file mode 100644
index 0000000..78d9f1b
--- /dev/null
+++ b/src/ida/ida_klu.c
@@ -0,0 +1,564 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4874 $
+ * $Date: 2016-08-31 10:22:40 -0700 (Wed, 31 Aug 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the IDAKLU linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "ida/ida_klu.h"
+#include "ida_impl.h"
+#include "ida_sparse_impl.h"
+#include "sundials/sundials_klu_impl.h"
+#include "sundials/sundials_math.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+#define TWOTHIRDS    RCONST(0.6666666666666667)
+
+/* IDAKLU linit, lsetup, lsolve, and lfree routines */
+ 
+static int IDAKLUInit(IDAMem IDA_mem);
+
+static int IDAKLUSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+		       N_Vector rrp, N_Vector tmp1,
+		       N_Vector tmp2, N_Vector tmp3);
+
+static int IDAKLUSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+			     N_Vector ycur, N_Vector ypcur, N_Vector rrcur);
+
+static int IDAKLUFree(IDAMem IDA_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLU
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the IDA / KLU linear solver module.  
+ * IDAKLU first calls the existing lfree routine if this is not NULL.
+ * Then it sets the ida_linit, ida_lsetup, ida_lsolve, ida_lperf, and
+ * ida_lfree fields in (*IDA_mem) to be IDAKLUInit, IDAKLUSetup,
+ * IDAKLUSolve, NULL, and IDAKLUFree, respectively.
+ * It allocates memory for a structure of type IDAkluMemRec and sets
+ * the ida_lmem field in (*IDA_mem) to the address of this structure.
+ * It sets setupNonNull in (*IDA_mem) to TRUE.
+ * Finally, it allocates memory for KLU.
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_LMEM_FAIL = -1,
+ * or IDASLS_ILL_INPUT = -2.
+ *
+ * NOTE: The KLU linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, IDAKLU will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int IDAKLU(void *ida_mem, int n, int nnz, int sparsetype)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+  int flag;
+
+  /* Return immediately if ida_mem is NULL. */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDAKLU", 
+                    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (IDA_mem->ida_tempv1->ops->nvgetarraypointer == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASLS", "IDAKLU", 
+                    MSGSP_BAD_NVECTOR);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  if (IDA_mem->ida_lfree != NULL) flag = IDA_mem->ida_lfree(IDA_mem);
+
+  /* Set five main function fields in IDA_mem. */
+  IDA_mem->ida_linit  = IDAKLUInit;
+  IDA_mem->ida_lsetup = IDAKLUSetup;
+  IDA_mem->ida_lsolve = IDAKLUSolve;
+  IDA_mem->ida_lperf  = NULL;
+  IDA_mem->ida_lfree  = IDAKLUFree;
+
+  /* Get memory for IDASlsMemRec. */
+  idasls_mem = (IDASlsMem) malloc(sizeof(struct IDASlsMemRec));
+  if (idasls_mem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDAKLU", 
+                    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* Get memory for KLUData. */
+  klu_data = (KLUData)malloc(sizeof(struct KLUDataRec));
+  if (klu_data == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDAKLU", 
+                    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  IDA_mem->ida_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  idasls_mem->s_jaceval = NULL;
+  idasls_mem->s_jacdata = NULL;
+  idasls_mem->sparsetype = sparsetype;
+
+  /* Allocate memory for the sparse Jacobian */
+  idasls_mem->s_JacMat = SparseNewMat(n, n, nnz, sparsetype);
+  if (idasls_mem->s_JacMat == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDAKLU", 
+                    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* KInitialize KLU structures */
+  switch (sparsetype) {
+    case CSC_MAT:
+      klu_data->sun_klu_solve = &klu_solve;
+      break;
+    case CSR_MAT:
+      klu_data->sun_klu_solve = &klu_tsolve;
+      break;
+    default:
+      SparseDestroyMat(idasls_mem->s_JacMat);
+      free(klu_data);
+      free(idasls_mem);
+      return(IDASLS_ILL_INPUT);
+  }
+  klu_data->s_Symbolic = NULL;
+  klu_data->s_Numeric = NULL;
+
+  /* Set default parameters for KLU */
+  flag = klu_defaults(&klu_data->s_Common);
+  if (flag == 0) {
+    IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "IDAKLU", 
+                    MSGSP_PACKAGE_FAIL);
+    return(IDASLS_PACKAGE_FAIL);
+  }
+
+  /* Set ordering to COLAMD as the idas default use.
+     Users can set a different value with IDAKLUSetOrdering,
+     and the user-set value is loaded before any call to klu_analyze in
+     IDAKLUSetup.  */
+  klu_data->s_ordering = 1;
+  klu_data->s_Common.ordering = klu_data->s_ordering;
+
+  /* Attach linear solver memory to the integrator memory */
+  idasls_mem->s_solver_data = (void *) klu_data;
+  IDA_mem->ida_lmem = idasls_mem;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to IDAKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_MEM_NULL = -1, 
+ * IDASLS_LMEM_NULL = -2, IDASLS_ILL_INPUT = -3, or IDASLS_MEM_FAIL = -4.
+ * -----------------------------------------------------------------
+ */
+
+int IDAKLUReInit(void *ida_mem_v, int n, int nnz, int reinit_type)
+{
+  IDAMem ida_mem;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if ida_mem is NULL. */
+  if (ida_mem_v == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDAKLUReInit", 
+                    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  ida_mem = (IDAMem) ida_mem_v;
+
+  /* Return immediately if ark_lmem is NULL. */
+  if (ida_mem->ida_lmem == NULL) {
+    IDAProcessError(NULL, IDASLS_LMEM_NULL, "IDASLS", "IDAKLUReInit", 
+                    MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+
+  idasls_mem = (IDASlsMem) (ida_mem->ida_lmem);
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  /* Return if reinit_type is not valid */
+  if ((reinit_type != 1) && (reinit_type != 2)) {
+    IDAProcessError(NULL, IDASLS_ILL_INPUT, "IDASLS", "IDAKLUReInit", 
+                    MSGSP_ILL_INPUT);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  if (reinit_type == 1) {
+
+    /* Destroy previous Jacobian information */
+    if (idasls_mem->s_JacMat) {
+      SparseDestroyMat(idasls_mem->s_JacMat);
+    }
+
+    /* Allocate memory for the sparse Jacobian */
+    idasls_mem->s_JacMat = SparseNewMat(n, n, nnz, idasls_mem->sparsetype);
+    if (idasls_mem->s_JacMat == NULL) {
+      IDAProcessError(ida_mem, IDASLS_MEM_FAIL, "IDASLS", "IDAKLU", 
+                      MSGSP_MEM_FAIL);
+      return(IDASLS_MEM_FAIL);
+    }
+  }
+
+  /* Free the prior factorazation and reset for first factorization */
+  if( klu_data->s_Symbolic != NULL)
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  if( klu_data->s_Numeric != NULL)
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  idasls_mem->s_first_factorize = 1;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLU interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the IDAKLU
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int IDAKLUInit(IDAMem IDA_mem)
+{
+  IDASlsMem idasls_mem;
+
+  idasls_mem = (IDASlsMem)IDA_mem->ida_lmem;
+
+  idasls_mem->s_jacdata = IDA_mem->ida_user_data;
+
+  idasls_mem->s_nje = 0;
+  /* This forces a factorize every call to IDA */
+  idasls_mem->s_first_factorize = 1;
+
+  idasls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the IDAKLU linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     IDASLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int IDAKLUSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+		       N_Vector rrp, N_Vector tmp1, N_Vector tmp2,
+		       N_Vector tmp3)
+{
+  int retval;
+  realtype tn, cj;
+  IDASlsMem idasls_mem;
+  IDASlsSparseJacFn jaceval;
+  KLUData klu_data;
+  SlsMat JacMat;
+  void *jacdata;
+  
+  realtype uround_twothirds;
+
+  uround_twothirds = SUNRpowerR(IDA_mem->ida_uround,TWOTHIRDS);
+
+  idasls_mem = (IDASlsMem) (IDA_mem->ida_lmem);
+  tn = IDA_mem->ida_tn; 
+  cj = IDA_mem->ida_cj;
+
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  jaceval = idasls_mem->s_jaceval;
+  jacdata = idasls_mem->s_jacdata;
+  JacMat = idasls_mem->s_JacMat;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_JAC_NOSET, "IDASLS", "IDAKLUSetup", 
+		    MSGSP_JAC_NOSET);
+    free(idasls_mem); idasls_mem = NULL;
+    return(IDASLS_JAC_NOSET);
+  }
+
+  /* Increment nje counter and call Jacobian eval routine. */
+  idasls_mem->s_nje++;
+  retval = jaceval(tn, cj, yyp, ypp, rrp, JacMat, jacdata, 
+		   tmp1, tmp2, tmp3);
+
+  if (retval < 0) {
+    IDAProcessError(IDA_mem, IDASLS_JACFUNC_UNRECVR, "IDASLS", 
+		    "IDAKLUSetup", MSGSP_JACFUNC_FAILED);
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_UNRECVR;
+    return(IDASLS_JACFUNC_UNRECVR);
+  }
+  if (retval > 0) {
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_RECVR;
+    return(+1);
+  }
+
+  if (idasls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get the symbolic factorization
+       ------------------------------------------------------------*/ 
+    /* Update the ordering option with any user-updated values from 
+       calls to IDAKLUSetOrdering */
+    klu_data->s_Common.ordering = klu_data->s_ordering;
+
+     if (klu_data->s_Symbolic != NULL) {
+       klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    }
+     klu_data->s_Symbolic = klu_analyze(JacMat->NP, JacMat->indexptrs, 
+				       JacMat->indexvals, &(klu_data->s_Common));
+     if (klu_data->s_Symbolic == NULL) {
+      IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "IDAKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(IDASLS_PACKAGE_FAIL);
+     }
+
+     /* ------------------------------------------------------------
+	Compute the LU factorization of  the Jacobian.
+       ------------------------------------------------------------*/
+     if( klu_data->s_Numeric != NULL) {
+       klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+     }
+     klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, JacMat->data, 
+				      klu_data->s_Symbolic, &(klu_data->s_Common));
+
+     if (klu_data->s_Numeric == NULL) {
+       IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "IDAKLUSetup", 
+		       MSGSP_PACKAGE_FAIL);
+       return(IDASLS_PACKAGE_FAIL);
+     }
+
+     idasls_mem->s_first_factorize = 0;
+  }
+  else {
+
+    retval = klu_refactor(JacMat->indexptrs, JacMat->indexvals, JacMat->data, 
+			  klu_data->s_Symbolic, klu_data->s_Numeric,
+			  &(klu_data->s_Common));
+    if (retval == 0) {
+      IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "idaKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(IDASLS_PACKAGE_FAIL);
+    }
+    
+    /*-----------------------------------------------------------
+      Check if a cheap estimate of the reciprocal of the condition 
+      number is getting too small.  If so, delete
+      the prior numeric factorization and recompute it.
+      -----------------------------------------------------------*/
+    
+    retval = klu_rcond(klu_data->s_Symbolic, klu_data->s_Numeric,
+		       &(klu_data->s_Common));
+    if (retval == 0) {
+      IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "idaKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(IDASLS_PACKAGE_FAIL);
+    }
+
+    if ( (klu_data->s_Common.rcond)  < uround_twothirds ) {
+      
+      /* Condition number may be getting large.  
+	 Compute more accurate estimate */
+      retval = klu_condest(JacMat->indexptrs, JacMat->data, 
+			   klu_data->s_Symbolic, klu_data->s_Numeric,
+			   &(klu_data->s_Common));
+      if (retval == 0) {
+	IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "idaKLUSetup", 
+			MSGSP_PACKAGE_FAIL);
+	return(IDASLS_PACKAGE_FAIL);
+      }
+      
+      if ( (klu_data->s_Common.condest) > 
+	   (1.0/uround_twothirds) ) {
+
+	/* More accurate estimate also says condition number is 
+	   large, so recompute the numeric factorization */
+
+	klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+	
+	klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+					 JacMat->data, klu_data->s_Symbolic, 
+					 &(klu_data->s_Common));
+
+	if (klu_data->s_Numeric == NULL) {
+	  IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", 
+			  "IDAKLUSetup", MSGSP_PACKAGE_FAIL);
+	  return(IDASLS_PACKAGE_FAIL);
+	}
+      }
+    }
+  }
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the IDAKLU linear
+  solver module.  It calls the KLU solve routine, scales the
+  solution vector according to cjratio, then returns IDASLS_SUCCESS = 0.
+*/
+
+static int IDAKLUSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+		       N_Vector ycur, N_Vector ypcur, N_Vector rrcur)
+{
+  int flag;
+  realtype cjratio;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+  SlsMat JacMat;
+  realtype *bd;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+  JacMat = idasls_mem->s_JacMat;
+  cjratio = IDA_mem->ida_cjratio;
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+  bd = N_VGetArrayPointer(b);
+
+  /* Call KLU to solve the linear system */
+  flag = klu_data->sun_klu_solve(klu_data->s_Symbolic, klu_data->s_Numeric, JacMat->NP, 1, bd, 
+                                 &(klu_data->s_Common));
+  if (flag == 0) {
+    IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "IDAKLUSolve", 
+		    MSGSP_PACKAGE_FAIL);
+    return(IDASLS_PACKAGE_FAIL);
+  }
+
+  /* Scale the correction to account for change in cj. */
+  if (cjratio != ONE) N_VScale(TWO/(ONE + cjratio), b, b);
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+  return(IDASLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the IDAKLU linear solver.
+*/
+
+static int IDAKLUFree(IDAMem IDA_mem)
+{
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  if( klu_data->s_Numeric != NULL)
+  {
+     klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  }
+  if( klu_data->s_Symbolic != NULL)
+  {
+     klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  }
+
+  if (idasls_mem->s_JacMat) {
+    SparseDestroyMat(idasls_mem->s_JacMat);
+    idasls_mem->s_JacMat = NULL;
+  }
+
+  free(klu_data); 
+  free(IDA_mem->ida_lmem); 
+
+  return(IDASLS_SUCCESS);
+}
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDAKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in IDA is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int IDAKLUSetOrdering(void *ida_mem_v, int ordering_choice)
+{
+  IDAMem ida_mem;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+
+ /* Return immediately if ida_mem is NULL */
+  if (ida_mem_v == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDAKLUSetOrdering",
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  ida_mem = (IDAMem) ida_mem_v;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) ) {
+    IDAProcessError(NULL, IDASLS_ILL_INPUT, "IDASLS", "IDAKLUSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  idasls_mem = (IDASlsMem) ida_mem->ida_lmem;
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  klu_data->s_ordering = ordering_choice;
+
+  return(IDASLS_SUCCESS);
+}
diff --git a/src/ida/ida_lapack.c b/src/ida/ida_lapack.c
index 86530ea..bbe524f 100644
--- a/src/ida/ida_lapack.c
+++ b/src/ida/ida_lapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2011/03/23 23:16:14 $
+ * $Revision: 4951 $
+ * $Date: 2016-09-22 10:21:00 -0700 (Thu, 22 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a IDA dense linear solver
  * using BLAS and LAPACK functions.
@@ -276,6 +281,9 @@ int IDALapackBand(void *ida_mem, int N, int mupper, int mlower)
   J_data = NULL;
 
   last_flag = IDADLS_SUCCESS;
+
+  idaDlsInitializeCounters(idadls_mem);
+
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -293,7 +301,7 @@ int IDALapackBand(void *ida_mem, int N, int mupper, int mlower)
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(n-1, mu + ml);
+  smu = mu + ml;
 
   /* Allocate memory for JJ and pivot arrays */
   JJ = NULL;
@@ -335,9 +343,13 @@ static int idaLapackDenseInit(IDAMem IDA_mem)
 
   idadls_mem = (IDADlsMem) lmem;
   
-  nje   = 0;
-  nreDQ = 0;
+  idaDlsInitializeCounters(idadls_mem);
   
+  /*
+     nje   = 0;
+     nreDQ = 0;
+  */
+
   if (jacDQ) {
     djac = idaDlsDenseDQJac;
     J_data = IDA_mem;
diff --git a/src/ida/ida_sparse.c b/src/ida/ida_sparse.c
new file mode 100644
index 0000000..c683f78
--- /dev/null
+++ b/src/ida/ida_sparse.c
@@ -0,0 +1,175 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for an IDASLS linear solver.
+ * -----------------------------------------------------------------
+ */
+
+/* 
+ * =================================================================
+ * IMPORTED HEADER FILES
+ * =================================================================
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "ida_impl.h"
+#include "ida_sparse_impl.h"
+#include <sundials/sundials_math.h>
+
+/* 
+ * =================================================================
+ * FUNCTION SPECIFIC CONSTANTS
+ * =================================================================
+ */
+
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* 
+ * =================================================================
+ * EXPORTED FUNCTIONS FOR IMPLICIT INTEGRATION
+ * =================================================================
+ */
+              
+/*
+ * IDASlsSetSparseJacFn specifies the sparse Jacobian function.
+ */
+int IDASlsSetSparseJacFn(void *ida_mem, IDASlsSparseJacFn jac)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+
+  /* Return immediately if ida_mem is NULL */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDASlsSetSparseJacFn", 
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (IDA_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_LMEM_NULL, "IDASLS", 
+		    "IDASlsSetSparseJacFn", MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  idasls_mem->s_jaceval = jac;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * IDASlsGetNumJacEvals returns the number of Jacobian evaluations.
+ */
+int IDASlsGetNumJacEvals(void *ida_mem, long int *njevals)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+
+  /* Return immediately if ida_mem is NULL */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDASlsGetNumJacEvals", MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (IDA_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_LMEM_NULL, "IDASLS", 
+		    "IDASlsGetNumJacEvals", MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  *njevals = idasls_mem->s_nje;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * IDASlsGetReturnFlagName returns the name associated with a IDASLS
+ * return value.
+ */
+char *IDASlsGetReturnFlagName(long int flag)
+{
+  char *name;
+
+  name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case IDASLS_SUCCESS:
+    sprintf(name,"IDASLS_SUCCESS");
+    break;   
+  case IDASLS_MEM_NULL:
+    sprintf(name,"IDASLS_MEM_NULL");
+    break;
+  case IDASLS_LMEM_NULL:
+    sprintf(name,"IDASLS_LMEM_NULL");
+    break;
+  case IDASLS_ILL_INPUT:
+    sprintf(name,"IDASLS_ILL_INPUT");
+    break;
+  case IDASLS_MEM_FAIL:
+    sprintf(name,"IDASLS_MEM_FAIL");
+    break;
+  case IDASLS_JAC_NOSET:
+    sprintf(name,"IDASLS_JAC_NOSET");
+    break;
+  case IDASLS_JACFUNC_UNRECVR:
+    sprintf(name,"IDASLS_JACFUNC_UNRECVR");
+    break;
+  case IDASLS_JACFUNC_RECVR:
+    sprintf(name,"IDASLS_JACFUNC_RECVR");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+/*
+ * IDASlsGetLastFlag returns the last flag set in a IDASLS function.
+ */
+int IDASlsGetLastFlag(void *ida_mem, long int *flag)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+
+  /* Return immediately if ida_mem is NULL */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDASlsGetLastFlag", 
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (IDA_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_LMEM_NULL, "IDASLS", 
+		    "IDASlsGetLastFlag", MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  *flag = idasls_mem->s_last_flag;
+
+  return(IDASLS_SUCCESS);
+}
+
diff --git a/src/ida/ida_sparse_impl.h b/src/ida/ida_sparse_impl.h
new file mode 100644
index 0000000..65d34b0
--- /dev/null
+++ b/src/ida/ida_sparse_impl.h
@@ -0,0 +1,127 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the IDASLS linear solvers.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDASPARSE_IMPL_H
+#define _IDASPARSE_IMPL_H
+
+#include "ida/ida_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * I D A S S P A R S E    I N T E R N A L    C O N S T A N T S
+ * =================================================================
+ */
+
+/*
+ * =================================================================
+ * PART I:  F O R W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : IDASlsMemRec, IDASlsMem                             
+ * -----------------------------------------------------------------
+ * IDASlsMem is pointer to a IDASlsMemRec structure.
+ * -----------------------------------------------------------------
+ */
+
+typedef struct IDASlsMemRec {
+
+  IDASlsSparseJacFn s_jaceval; /* user Jacobian evaluation routine 
+                                  to be called */
+  void *s_jacdata;           /* J_data is passed to djac or bjac */
+
+  long int s_nje;           /* nje = no. of calls to jac */
+
+  long int s_last_flag;     /* last error return flag */
+
+  int s_first_factorize;    /* flag telling whether the first 
+                               factorization needs to happen */
+  SlsMat s_JacMat;          /* J = dF/dy + cj*dF/dy' */
+  
+  int sparsetype;           /* matrix type: compressed sparse column or row */
+
+  void *s_solver_data;      /* structure for solver-specific data */
+  
+
+} *IDASlsMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Prototypes of internal functions
+ * -----------------------------------------------------------------
+ */
+  
+
+/*
+ * =================================================================
+ * PART II:  B A C K W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : IDASlsMemRecB, IDASlsMemB       
+ * -----------------------------------------------------------------
+ * An IDASLS linear solver's specification function attaches such
+ * a structure to the lmemB filed of IDABMem
+ * -----------------------------------------------------------------
+ */
+
+typedef struct IDASlsMemRecB {
+
+  IDASlsSparseJacFnB s_djacB;
+  IDASlsSparseJacFnBS s_djacBS;
+
+} *IDASlsMemB;
+
+
+/*
+ * =================================================================
+ * E R R O R   M E S S A G E S
+ * =================================================================
+ */
+
+#define MSGSP_IDAMEM_NULL "Integrator memory is NULL."
+#define MSGSP_BAD_NVECTOR "A required vector operation is not implemented."
+#define MSGSP_MEM_FAIL "A memory request failed."
+#define MSGSP_LMEM_NULL "Linear solver memory is NULL."
+#define MSGSP_ILL_INPUT "Invalid input detected."
+#define MSGSP_JAC_NOSET "Jacobian evaluation function has not been set."
+#define MSGSP_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
+#define MSGSP_PACKAGE_FAIL "A call to an external package failed."
+
+#define MSGSP_CAMEM_NULL "idaadj_mem = NULL illegal."
+#define MSGSP_LMEMB_NULL "Linear solver memory is NULL for the backward integration."
+#define MSGSP_BAD_T "Bad t for interpolation."
+#define MSGSP_BAD_WHICH "Illegal value for which."
+#define MSGSP_NO_ADJ "Illegal attempt to call before calling IDAAdjInit."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/ida/ida_spbcgs.c b/src/ida/ida_spbcgs.c
index c1e27ea..a795f89 100644
--- a/src/ida/ida_spbcgs.c
+++ b/src/ida/ida_spbcgs.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2011/05/25 20:20:25 $
+ * $Revision: 4829 $
+ * $Date: 2016-07-27 16:01:15 -0700 (Wed, 27 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDA scaled preconditioned
  * Bi-CGSTAB linear solver module, IDASPBCG.
@@ -129,7 +134,7 @@ int IDASpbcg(void *ida_mem, int maxl)
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   SpbcgMem spbcg_mem;
-  int flag, maxl1;
+  int maxl1;
 
   /* Return immediately if ida_mem is NULL */
   if (ida_mem == NULL) {
@@ -144,7 +149,7 @@ int IDASpbcg(void *ida_mem, int maxl)
     return(IDASPILS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem */
   linit  = IDASpbcgInit;
@@ -185,6 +190,8 @@ int IDASpbcg(void *ida_mem, int maxl)
 
   idaspils_mem->s_last_flag = IDASPILS_SUCCESS;
 
+  idaSpilsInitializeCounters(idaspils_mem);
+
   /* Set setupNonNull to FALSE */
   setupNonNull = FALSE;
 
@@ -216,7 +223,7 @@ int IDASpbcg(void *ida_mem, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SpbcgMalloc to allocate workspace for Spbcg */
   spbcg_mem = NULL;
@@ -261,9 +268,7 @@ static int IDASpbcgInit(IDAMem IDA_mem)
   idaspils_mem = (IDASpilsMem) lmem;
   spbcg_mem = (SpbcgMem) spils_mem;
 
-  /* Initialize counters */
-  npe = nli = nps = ncfl = 0;
-  njtimes = nres = 0;
+  idaSpilsInitializeCounters(idaspils_mem);
 
   /* Set setupNonNull to TRUE iff there is preconditioning with setup */
   setupNonNull = (psolve != NULL) && (pset != NULL);
diff --git a/src/ida/ida_spgmr.c b/src/ida/ida_spgmr.c
index 2fd21e9..e380ddf 100644
--- a/src/ida/ida_spgmr.c
+++ b/src/ida/ida_spgmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2011/05/25 20:20:25 $
+ * $Revision: 4829 $
+ * $Date: 2016-07-27 16:01:15 -0700 (Wed, 27 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh, and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDA Scaled              
  * Preconditioned GMRES linear solver module, IDASPGMR.            
@@ -129,7 +134,7 @@ int IDASpgmr(void *ida_mem, int maxl)
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   SpgmrMem spgmr_mem;
-  int flag, maxl1;
+  int maxl1;
 
   /* Return immediately if ida_mem is NULL */
   if (ida_mem == NULL) {
@@ -144,7 +149,7 @@ int IDASpgmr(void *ida_mem, int maxl)
     return(IDASPILS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem */
   linit  = IDASpgmrInit;
@@ -186,6 +191,9 @@ int IDASpgmr(void *ida_mem, int maxl)
   idaspils_mem->s_dqincfac = ONE;
 
   idaspils_mem->s_last_flag  = IDASPILS_SUCCESS;
+  
+  /* initialize solver performance counters */
+  idaSpilsInitializeCounters(idaspils_mem);
 
   /* Set setupNonNull to FALSE */
   setupNonNull = FALSE;
@@ -218,7 +226,7 @@ int IDASpgmr(void *ida_mem, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt( N_VDotProd(ytemp, ytemp) );
+  sqrtN = SUNRsqrt( N_VDotProd(ytemp, ytemp) );
 
   /* Call SpgmrMalloc to allocate workspace for Spgmr */
   spgmr_mem = NULL;
@@ -264,8 +272,7 @@ static int IDASpgmrInit(IDAMem IDA_mem)
   idaspils_mem = (IDASpilsMem) lmem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = 0;
-  njtimes = nres = 0;
+  idaSpilsInitializeCounters(idaspils_mem);
 
   /* Set setupNonNull to TRUE iff there is preconditioning with setup */
   setupNonNull = (psolve != NULL) && (pset != NULL);
@@ -473,4 +480,3 @@ static int IDASpgmrFree(IDAMem IDA_mem)
 
   return(0);
 }
-
diff --git a/src/ida/ida_spils.c b/src/ida/ida_spils.c
index 813c10a..b784f46 100644
--- a/src/ida/ida_spils.c
+++ b/src/ida/ida_spils.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:35:26 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common implementation file for the IDA Scaled              
  * Preconditioned Linear Solver modules.
@@ -588,7 +593,7 @@ int IDASpilsDQJtimes(realtype tt,
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   N_Vector y_tmp, yp_tmp;
-  realtype sig, siginv;
+  realtype sig=ZERO, siginv;
   int iter, retval;
 
   /* data is ida_mem */
@@ -635,3 +640,15 @@ int IDASpilsDQJtimes(realtype tt,
   return(0);
 
 }
+
+int idaSpilsInitializeCounters(IDASpilsMem idaspils_mem)
+{
+  idaspils_mem->s_npe     = 0;
+  idaspils_mem->s_nli     = 0;
+  idaspils_mem->s_nps     = 0;
+  idaspils_mem->s_ncfl    = 0;
+  idaspils_mem->s_njtimes = 0;
+  idaspils_mem->s_nres    = 0;
+
+  return(0);
+}
diff --git a/src/ida/ida_spils_impl.h b/src/ida/ida_spils_impl.h
index 457b8c7..4836d98 100644
--- a/src/ida/ida_spils_impl.h
+++ b/src/ida/ida_spils_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:35:26 $
+ * $Revision: 4920 $
+ * $Date: 2016-09-19 14:34:35 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common header file (private version) for the Scaled
  * Preconditioned Iterative Linear Solver modules.
@@ -18,13 +23,13 @@
 #ifndef _IDASPILS_IMPL_H
 #define _IDASPILS_IMPL_H
 
+#include <ida/ida_spils.h>
+#include "ida_impl.h"
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <ida/ida_spils.h>
-#include "ida_impl.h"
-
 /* Types of iterative linear solvers */
 
 #define SPILS_SPGMR   1
@@ -90,7 +95,7 @@ typedef struct IDASpilsMemRec {
 
   IDASpilsPrecSetupFn s_pset;
   IDASpilsPrecSolveFn s_psolve;
-  void (*s_pfree)(IDAMem IDA_mem);
+  int (*s_pfree)(IDAMem IDA_mem);
   void *s_pdata;
   
   /* Jacobian times vector compuation
@@ -129,6 +134,9 @@ int IDASpilsDQJtimes(realtype tt,
                      realtype c_j, void *data, 
                      N_Vector work1, N_Vector work2);
 
+/* Auxilliary functions */
+
+int idaSpilsInitializeCounters(IDASpilsMem idaspils_mem);
 
 
 /*
diff --git a/src/ida/ida_sptfqmr.c b/src/ida/ida_sptfqmr.c
index 65bd102..284bbbf 100644
--- a/src/ida/ida_sptfqmr.c
+++ b/src/ida/ida_sptfqmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2007/11/26 16:20:00 $
+ * $Revision: 4829 $
+ * $Date: 2016-07-27 16:01:15 -0700 (Wed, 27 Jul 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDA scaled preconditioned
  * TFQMR linear solver module, IDASPTFQMR.
@@ -128,7 +133,7 @@ int IDASptfqmr(void *ida_mem, int maxl)
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   SptfqmrMem sptfqmr_mem;
-  int flag, maxl1;
+  int maxl1;
 
   /* Return immediately if ida_mem is NULL */
   if (ida_mem == NULL) {
@@ -143,7 +148,7 @@ int IDASptfqmr(void *ida_mem, int maxl)
     return(IDASPILS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem */
   linit  = IDASptfqmrInit;
@@ -184,6 +189,8 @@ int IDASptfqmr(void *ida_mem, int maxl)
 
   idaspils_mem->s_last_flag = IDASPILS_SUCCESS;
 
+  idaSpilsInitializeCounters(idaspils_mem);
+
   /* Set setupNonNull to FALSE */
   setupNonNull = FALSE;
 
@@ -215,7 +222,7 @@ int IDASptfqmr(void *ida_mem, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SptfqmrMalloc to allocate workspace for Sptfqmr */
   sptfqmr_mem = NULL;
@@ -260,9 +267,7 @@ static int IDASptfqmrInit(IDAMem IDA_mem)
   idaspils_mem = (IDASpilsMem) lmem;
   sptfqmr_mem = (SptfqmrMem) spils_mem;
 
-  /* Initialize counters */
-  npe = nli = nps = ncfl = 0;
-  njtimes = nres = 0;
+  idaSpilsInitializeCounters(idaspils_mem);
 
   /* Set setupNonNull to TRUE iff there is preconditioning with setup */
   setupNonNull = (psolve != NULL) && (pset != NULL);
diff --git a/src/ida/ida_superlumt.c b/src/ida/ida_superlumt.c
new file mode 100644
index 0000000..eda8449
--- /dev/null
+++ b/src/ida/ida_superlumt.c
@@ -0,0 +1,522 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4938 $
+ * $Date: 2016-09-21 14:33:08 -0700 (Wed, 21 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the IDASUPERLUMT linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sundials/sundials_math.h"
+#include "sundials/sundials_superlumt_impl.h"
+
+#include "ida_impl.h"
+#include "ida_sparse_impl.h"
+#include "ida/ida_superlumt.h"
+
+/* Constants */
+
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* IDASUPERLUMT linit, lsetup, lsolve, and lfree routines */
+ 
+static int IDASuperLUMTInit(IDAMem IDA_mem);
+
+static int IDASuperLUMTSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+			     N_Vector rrp, N_Vector tmp1,
+			     N_Vector tmp2, N_Vector tmp3);
+
+static int IDASuperLUMTSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+			     N_Vector ycur, N_Vector ypcur, N_Vector rrcur);
+
+static int IDASuperLUMTFree(IDAMem IDA_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * IDASuperLUMT
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the IDA / SuperLUMT linear solver module.  
+ * IDASuperLUMT first calls the existing lfree routine if this is not NULL.
+ * Then it sets the ida_linit, ida_lsetup, ida_lsolve, ida_lperf, and
+ * ida_lfree fields in (*IDA_mem) to be IDASuperLUMTInit, IDASuperLUMTSetup,
+ * IDASuperLUMTSolve, NULL, and IDASuperLUMTFree, respectively.
+ * It allocates memory for a structure of type IDAsluMemRec and sets
+ * the ida_lmem field in (*IDA_mem) to the address of this structure.
+ * It sets setupNonNull in (*IDA_mem) to TRUE, sets the d_jdata field
+ * in the IDAsluMemRec structure to be the input parameter jdata,
+ * and sets the d_jac field to be:
+ *   (1) the input parameter djac, if djac != NULL, or                
+ *   (2) throws an error, if djac == NULL.                             
+ * Finally, it allocates memory for SuperLUMT.
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_LMEM_FAIL = -1,
+ * or IDASLS_ILL_INPUT = -2.
+ *
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, IDASuperLUMT will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int IDASuperLUMT(void *ida_mem, int num_threads, int n, int nnz)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+  int *perm_c, *perm_r;
+  int nrhs, panel_size, relax;
+  double *bd;
+  SuperMatrix *B;
+
+  /* Return immediately if ida_mem is NULL. */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDASuperLUMT", 
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (IDA_mem->ida_tempv1->ops->nvgetarraypointer == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASLS", "IDASuperLUMT", 
+		    MSGSP_BAD_NVECTOR);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  if (IDA_mem->ida_lfree != NULL) IDA_mem->ida_lfree(IDA_mem);
+
+  /* Set five main function fields in IDA_mem. */
+  IDA_mem->ida_linit  = IDASuperLUMTInit;
+  IDA_mem->ida_lsetup = IDASuperLUMTSetup;
+  IDA_mem->ida_lsolve = IDASuperLUMTSolve;
+  IDA_mem->ida_lperf  = NULL;
+  IDA_mem->ida_lfree  = IDASuperLUMTFree;
+
+  /* Get memory for IDASlsMemRec. */
+  idasls_mem = NULL;
+  idasls_mem = (IDASlsMem) malloc(sizeof(struct IDASlsMemRec));
+  if (idasls_mem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* Get memory for SLUMT_data. */
+  slumt_data = NULL;
+  slumt_data = (SLUMTData)malloc(sizeof(struct SLUMTDataRec));
+  if (slumt_data == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  IDA_mem->ida_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  idasls_mem->s_jaceval = NULL;
+  idasls_mem->s_jacdata = IDA_mem->ida_user_data;
+
+  /* Allocate memory for the sparse Jacobian */
+  idasls_mem->s_JacMat = NULL;
+  idasls_mem->s_JacMat = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (idasls_mem->s_JacMat == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* Set up memory for the permutations */
+  perm_r = (int *)malloc(n*sizeof(int));
+  if (perm_r == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+  perm_c = (int *)malloc(n*sizeof(int));
+  if (perm_c == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    free(perm_r);
+    return(IDASLS_MEM_FAIL);
+  }
+  slumt_data->perm_r = perm_r;
+  slumt_data->perm_c = perm_c;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  /* Set default parameters for SuperLU */
+  slumt_data->num_threads = num_threads;
+  slumt_data->diag_pivot_thresh = 1.0;
+
+  /* Allocate structures for SuperLU */
+  slumt_data->Gstat = (Gstat_t *)malloc(sizeof(Gstat_t));
+  slumt_data->s_A = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_AC = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_L = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_U = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_A->Store  = NULL;
+  slumt_data->s_AC->Store = NULL;
+  slumt_data->s_L->Store  = NULL;
+  slumt_data->s_U->Store  = NULL;
+  slumt_data->superlumt_options = (superlumt_options_t *)malloc(sizeof(superlumt_options_t));
+
+  dCreate_CompCol_Matrix(slumt_data->s_A, idasls_mem->s_JacMat->M, 
+			 idasls_mem->s_JacMat->N, 
+			 idasls_mem->s_JacMat->NNZ, idasls_mem->s_JacMat->data, 
+			 idasls_mem->s_JacMat->indexvals, 
+			 idasls_mem->s_JacMat->indexptrs, 
+			 SLU_NC, SLU_D, SLU_GE);
+
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  StatAlloc(idasls_mem->s_JacMat->N, num_threads, panel_size, relax, 
+	    slumt_data->Gstat);
+  
+  /* Create RHS matrix */
+  nrhs = 1;
+  bd = NULL;
+  B = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  B->Store = NULL;
+  dCreate_Dense_Matrix(B, n, nrhs, bd, n, 
+		       SLU_DN, SLU_D, SLU_GE);
+  slumt_data->s_B = B;
+
+  /* Set ordering to COLAMD as the ida default use.
+     Users can set a different value with IDASuperLUMTSetOrdering,
+     and the user-set value is loaded before any call to factorize the
+     matrix in IDASuperLUMTSetup.  */
+  slumt_data->s_ordering = 3;
+
+  /* Attach linear solver memory to the integrator memory */
+  idasls_mem->s_solver_data = (void *) slumt_data;
+  IDA_mem->ida_lmem = idasls_mem;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * IDASuperLUMT interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the IDASuperLUMT
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int IDASuperLUMTInit(IDAMem IDA_mem)
+{
+  int num_threads, n;
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+
+  idasls_mem = (IDASlsMem)IDA_mem->ida_lmem;
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  idasls_mem->s_nje = 0;
+  idasls_mem->s_first_factorize = 1;
+
+  /* ------------------------------------------------------------
+     Allocate storage and initialize statistics variables. 
+     ------------------------------------------------------------*/
+  n = idasls_mem->s_JacMat->N;
+  num_threads = slumt_data->num_threads;
+
+  StatInit(n, num_threads, slumt_data->Gstat);
+
+  idasls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the IDASuperLUMT linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     IDASLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int IDASuperLUMTSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+			     N_Vector rrp, N_Vector tmp1, N_Vector tmp2,
+			     N_Vector tmp3)
+{
+  int retval, info;
+  int nprocs, panel_size, relax, permc_spec, lwork;
+  int *perm_r, *perm_c;
+  realtype tn, cj;
+  double diag_pivot_thresh, drop_tol;
+  fact_t fact;
+  trans_t trans;
+  yes_no_t refact, usepr;
+  IDASlsMem idasls_mem;
+  IDASlsSparseJacFn jaceval;
+  SuperMatrix *A, *AC, *L, *U;
+  Gstat_t *Gstat;
+  superlumt_options_t *superlumt_options;
+  SLUMTData slumt_data;
+  SlsMat JacMat;
+  void *jacdata;
+  void *work;
+  
+  idasls_mem = (IDASlsMem) (IDA_mem->ida_lmem);
+  tn = IDA_mem->ida_tn; 
+  cj = IDA_mem->ida_cj;
+
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  jaceval = idasls_mem->s_jaceval;
+  jacdata = idasls_mem->s_jacdata;
+  JacMat = idasls_mem->s_JacMat;
+
+  superlumt_options = slumt_data->superlumt_options;
+  A = slumt_data->s_A;
+  AC = slumt_data->s_AC;
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  Gstat = slumt_data->Gstat;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  nprocs = slumt_data->num_threads;
+  diag_pivot_thresh = slumt_data->diag_pivot_thresh;
+
+  /* Set option values for SuperLU_MT */
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  fact = EQUILIBRATE;
+  trans = NOTRANS;
+  usepr = NO;
+  drop_tol = 0.0;
+  lwork = 0;
+  work = NULL;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_JAC_NOSET, "IDASLS", "IDASuperLUMTSetup", 
+		    MSGSP_JAC_NOSET);
+    free(idasls_mem); idasls_mem = NULL;
+    return(IDASLS_JAC_NOSET);
+  }
+
+  /* Increment nje counter and call Jacobian eval routine. */
+  idasls_mem->s_nje++;
+  retval = jaceval(tn, cj, yyp, ypp, rrp, JacMat, jacdata, 
+		   tmp1, tmp2, tmp3);
+
+  if (retval < 0) {
+    IDAProcessError(IDA_mem, IDASLS_JACFUNC_UNRECVR, "IDASLS", 
+		    "IDASuperLUMTSetup", MSGSP_JACFUNC_FAILED);
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_UNRECVR;
+    return(IDASLS_JACFUNC_UNRECVR);
+  }
+  if (retval > 0) {
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_RECVR;
+    return(+1);
+  }
+
+  if (idasls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get column permutation vector perm_c[], according to permc_spec:
+       permc_spec = 3: approximate minimum degree for unsymmetric matrices
+       ------------------------------------------------------------*/ 
+    permc_spec = slumt_data->s_ordering;
+    get_perm_c(permc_spec, A, perm_c);
+ 
+    refact= NO;
+    idasls_mem->s_first_factorize = 0;
+  }
+  else {
+    /* ------------------------------------------------------------
+       Re-initialize statistics variables 
+       ------------------------------------------------------------*/
+    StatInit(JacMat->N, nprocs, Gstat);
+    Destroy_CompCol_Permuted(AC);
+    refact= YES;
+  }
+
+  /* ------------------------------------------------------------
+     Initialize the option structure superlumt_options using the
+     user-input parameters;  Subsequent calls will re-initialize
+     options.
+     Apply perm_c to the columns of original A to form AC.
+     ------------------------------------------------------------*/
+  pdgstrf_init(nprocs, fact, trans, refact, panel_size, relax,
+	       diag_pivot_thresh, usepr, drop_tol, perm_c, perm_r,
+	       work, lwork, A, AC, superlumt_options, Gstat);
+  /* ------------------------------------------------------------
+     Compute the LU factorization of A.
+     The following routine will create nprocs threads.
+     ------------------------------------------------------------*/
+  pdgstrf(superlumt_options, AC, perm_r, L, U, Gstat, &info);
+    
+  if (info != 0) {
+    idasls_mem->s_last_flag = info;
+    return(+1);
+  }
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the IDASuperLUMT linear
+  solver module.  It calls the SuperLUMT solve routine, scales the
+  solution vector according to cjratio, then returns IDASLU_SUCCESS = 0.
+*/
+
+static int IDASuperLUMTSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+			     N_Vector ycur, N_Vector ypcur, N_Vector rrcur)
+{
+  int info, trans;
+  int *perm_r, *perm_c;
+  double cjratio;
+  IDASlsMem idasls_mem;
+  SuperMatrix *L, *U, *B;
+  Gstat_t *Gstat;
+  DNformat *Bstore;
+  SLUMTData slumt_data;
+  realtype *bd;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+  cjratio = IDA_mem->ida_cjratio;
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  Gstat = slumt_data->Gstat;
+  B = slumt_data->s_B;
+   
+  bd = N_VGetArrayPointer(b);
+  Bstore = (DNformat *) (B->Store);
+  Bstore->nzval = bd;
+
+  /* Call SuperLUMT to solve the linear system using L and U */
+  trans = NOTRANS;
+  dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, &info);
+
+  /* Scale the correction to account for change in cj. */
+  if (cjratio != ONE) N_VScale(TWO/(ONE + cjratio), b, b);
+
+  Bstore->nzval = NULL;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+  return(IDASLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the IDASuperLUMT linear solver.
+*/
+
+static int IDASuperLUMTFree(IDAMem IDA_mem)
+{
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  pxgstrf_finalize(slumt_data->superlumt_options, slumt_data->s_AC);
+
+  free(slumt_data->perm_r);
+  free(slumt_data->perm_c);
+  free(slumt_data->superlumt_options);
+  Destroy_SuperNode_SCP( (slumt_data->s_L) );
+  Destroy_CompCol_NCP( (slumt_data->s_U) );
+  StatFree( (slumt_data->Gstat) );
+  free(slumt_data->Gstat);
+  
+  Destroy_SuperMatrix_Store(slumt_data->s_B);
+  SUPERLU_FREE(slumt_data->s_A->Store);
+  if (idasls_mem->s_JacMat) {
+    SparseDestroyMat(idasls_mem->s_JacMat);
+    idasls_mem->s_JacMat = NULL;
+  }
+
+  free(slumt_data->s_B);
+  free(slumt_data->s_A);
+  free(slumt_data->s_AC);
+  free(slumt_data->s_L);
+  free(slumt_data->s_U);
+
+  free(slumt_data); 
+  slumt_data = NULL;
+ 
+  free(IDA_mem->ida_lmem); 
+  IDA_mem->ida_lmem = NULL;
+
+  return(IDASLS_SUCCESS);
+}
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDASuperLUMTSetOrdering sets the ordering used by SuperLUMT for reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int IDASuperLUMTSetOrdering(void *ida_mem_v, int ordering_choice)
+{
+  IDAMem ida_mem;
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+
+ /* Return immediately if ida_mem is NULL */
+  if (ida_mem_v == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDASuperLUMTSetOrdering",
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  ida_mem = (IDAMem) ida_mem_v;
+  idasls_mem = (IDASlsMem) ida_mem->ida_lmem;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) && (ordering_choice != 3) ) {
+    IDAProcessError(NULL, IDASLS_ILL_INPUT, "IDASLS", "IDASuperLUMTSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  slumt_data->s_ordering = ordering_choice;
+
+  return(IDASLS_SUCCESS);
+}
+
+
+
+
diff --git a/src/idas/CMakeLists.txt b/src/idas/CMakeLists.txt
index e87faff..400a228 100644
--- a/src/idas/CMakeLists.txt
+++ b/src/idas/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:48 $
+# $Revision: 4759 $
+# $Date: 2016-05-18 16:25:17 -0700 (Wed, 18 May 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the IDAS library
 
@@ -23,6 +28,7 @@ SET(idas_SOURCES
   idas_direct.c
   idas_band.c
   idas_dense.c
+  idas_sparse.c
   idas_spils.c
   idas_spbcgs.c
   idas_spgmr.c
@@ -30,6 +36,14 @@ SET(idas_SOURCES
   idas_bbdpre.c
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND idas_SOURCES idas_klu.c)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND idas_SOURCES idas_superlumt.c)
+ENDIF()
+
 # Add variable shared_SOURCES with the common SUNDIALS sources which will
 # also be included in the IDAS library
 SET(shared_SOURCES
@@ -39,6 +53,7 @@ SET(shared_SOURCES
   sundials_band.c
   sundials_dense.c
   sundials_iterative.c
+  sundials_sparse.c
   sundials_spbcgs.c
   sundials_spgmr.c
   sundials_sptfqmr.c
@@ -54,12 +69,21 @@ SET(idas_HEADERS
   idas_dense.h
   idas_direct.h
   idas.h
+  idas_sparse.h
   idas_spbcgs.h
   idas_spgmr.h
   idas_spils.h
   idas_sptfqmr.h
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND idas_HEADERS idas_klu.h)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND idas_HEADERS idas_superlumt.h)
+ENDIF()
+
 # Add prefix with complete path to the IDAS header files
 ADD_PREFIX(${sundials_SOURCE_DIR}/include/idas/ idas_HEADERS)
 
@@ -73,6 +97,15 @@ ELSE(LAPACK_FOUND)
   SET(idas_BL_HEADERS "")
 ENDIF(LAPACK_FOUND)
 
+IF(SUPERLUMT_FOUND)
+  SET(idas_SLU_SOURCES idas_superlumt.c)
+  SET(idas_SLU_HEADERS idas_superlumt.h)
+  ADD_PREFIX(${sundials_SOURCE_DIR}/include/idas/ idas_SLU_HEADERS)
+ELSE(SUPERLUMT_FOUND)
+  SET(idas_SLU_SOURCES "")
+  SET(idas_SLU_HEADERS "")
+ENDIF(SUPERLUMT_FOUND)
+
 # Add source directories to include directories for access to
 # implementation only header files.
 INCLUDE_DIRECTORIES(.)
@@ -86,7 +119,7 @@ IF(BUILD_STATIC_LIBS)
 
   # Add the build target for the static IDAS library
   ADD_LIBRARY(sundials_idas_static STATIC 
-    ${idas_SOURCES} ${idas_BL_SOURCES}  ${shared_SOURCES})
+    ${idas_SOURCES} ${idas_BL_SOURCES} ${idas_SLU_SOURCES}  ${shared_SOURCES})
 
   # Set the library name and make sure it is not deleted
   SET_TARGET_PROPERTIES(sundials_idas_static
@@ -102,7 +135,7 @@ IF(BUILD_SHARED_LIBS)
 
   # Add the build target for the IDAS library
   ADD_LIBRARY(sundials_idas_shared SHARED 
-    ${idas_SOURCES}  ${idas_BL_SOURCES}  ${shared_SOURCES})
+    ${idas_SOURCES}  ${idas_BL_SOURCES} ${idas_SLU_SOURCES} ${shared_SOURCES})
 
   # Set the library name and make sure it is not deleted
   SET_TARGET_PROPERTIES(sundials_idas_shared
@@ -118,7 +151,7 @@ IF(BUILD_SHARED_LIBS)
 ENDIF(BUILD_SHARED_LIBS)
 
 # Install the IDAS header files
-INSTALL(FILES ${idas_HEADERS} ${idas_BL_HEADERS} DESTINATION include/idas)
+INSTALL(FILES ${idas_HEADERS} ${idas_BL_HEADERS} ${idas_SLU_HEADERS} DESTINATION include/idas)
 
 # Install the IDAS implementation header file
 INSTALL(FILES idas_impl.h DESTINATION include/idas)
diff --git a/src/idas/LICENSE b/src/idas/LICENSE
index 3232487..27cf43f 100644
--- a/src/idas/LICENSE
+++ b/src/idas/LICENSE
@@ -1,7 +1,7 @@
-Copyright (c) 2006, The Regents of the University of California. 
+Copyright (c) 2002-2015, Lawrence Livermore National Security. 
 Produced at the Lawrence Livermore National Laboratory.
 Written by Radu Serban.
-UCRL-CODE-000000
+UCRL-CODE-237203
 All rights reserved. 
 
 This file is part of IDAS.
diff --git a/src/idas/Makefile.in b/src/idas/Makefile.in
deleted file mode 100644
index 1bd573e..0000000
--- a/src/idas/Makefile.in
+++ /dev/null
@@ -1,173 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for IDA module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-LIB_REVISION = 0:0:0
-
-IDAS_LIB = libsundials_idas.la
-
-IDAS_SRC_FILES = idas.c idaa.c idas_ic.c idas_io.c idaa_io.c idas_direct.c idas_dense.c idas_band.c idas_spils.c idas_spbcgs.c idas_spgmr.c idas_sptfqmr.c idas_bbdpre.c
-IDAS_BL_SRC_FILES = idas_lapack.c
-
-IDAS_OBJ_FILES = $(IDAS_SRC_FILES:.c=.o)
-IDAS_BL_OBJ_FILES = $(IDAS_BL_SRC_FILES:.c=.o)
-
-IDAS_LIB_FILES = $(IDAS_SRC_FILES:.c=.lo)
-IDAS_BL_LIB_FILES = $(IDAS_BL_SRC_FILES:.c=.lo)
-
-SHARED_LIB_FILES = $(top_builddir)/src/sundials/sundials_band.lo \
-                   $(top_builddir)/src/sundials/sundials_dense.lo \
-                   $(top_builddir)/src/sundials/sundials_direct.lo \
-                   $(top_builddir)/src/sundials/sundials_iterative.lo \
-                   $(top_builddir)/src/sundials/sundials_spgmr.lo \
-                   $(top_builddir)/src/sundials/sundials_spbcgs.lo \
-                   $(top_builddir)/src/sundials/sundials_sptfqmr.lo \
-                   $(top_builddir)/src/sundials/sundials_math.lo \
-                   $(top_builddir)/src/sundials/sundials_nvector.lo
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(IDAS_LIB)
-
-$(IDAS_LIB): shared $(IDAS_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: shared $(IDAS_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(IDAS_LIB) $(IDAS_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-lib_with_bl: shared $(IDAS_LIB_FILES) $(IDAS_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(IDAS_LIB) $(IDAS_LIB_FILES) $(IDAS_BL_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-install: $(IDAS_LIB)
-	$(mkinstalldirs) $(includedir)/idas
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(IDAS_LIB) $(libdir)
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas.h         $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_direct.h  $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_dense.h   $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_band.h    $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_spbcgs.h  $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_spgmr.h   $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_sptfqmr.h $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_bbdpre.h  $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_spils.h   $(includedir)/idas/
-	$(INSTALL_HEADER) $(top_srcdir)/src/idas/idas_impl.h        $(includedir)/idas/
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  $(INSTALL_HEADER) $(top_srcdir)/include/idas/idas_lapack.h  $(includedir)/idas/ ; \
-	fi
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(IDAS_LIB)
-	rm -f $(includedir)/idas/idas.h
-	rm -f $(includedir)/idas/idas_direct.h
-	rm -f $(includedir)/idas/idas_dense.h
-	rm -f $(includedir)/idas/idas_band.h
-	rm -f $(includedir)/idas/idas_lapack.h
-	rm -f $(includedir)/idas/idas_spbcgs.h
-	rm -f $(includedir)/idas/idas_spgmr.h
-	rm -f $(includedir)/idas/idas_sptfqmr.h
-	rm -f $(includedir)/idas/idas_bbdpre.h
-	rm -f $(includedir)/idas/idas_spils.h
-	rm -f $(includedir)/idas/idas_impl.h
-	$(rminstalldirs) ${includedir}/idas
-
-shared:
-	@cd ${top_builddir}/src/sundials ; \
-	 ${MAKE} ;                         \
-	 cd ${abs_builddir}
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(IDAS_LIB)
-	rm -f $(IDAS_LIB_FILES)
-	rm -f $(IDAS_BL_LIB_FILES)
-	rm -f $(IDAS_OBJ_FILES)
-	rm -f $(IDAS_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-idas.lo: $(srcdir)/idas.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas.c
-idaa.lo: $(srcdir)/idaa.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idaa.c
-idas_ic.lo: $(srcdir)/idas_ic.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_ic.c
-idas_io.lo: $(srcdir)/idas_io.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_io.c
-idaa_io.lo: $(srcdir)/idaa_io.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idaa_io.c
-idas_direct.lo: $(srcdir)/idas_direct.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_direct.c
-idas_dense.lo: $(srcdir)/idas_dense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_dense.c
-idas_band.lo: $(srcdir)/idas_band.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_band.c
-idas_lapack.lo: $(srcdir)/idas_lapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_lapack.c
-idas_spils.lo: $(srcdir)/idas_spils.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_spils.c
-idas_spbcgs.lo: $(srcdir)/idas_spbcgs.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_spbcgs.c
-idas_spgmr.lo: $(srcdir)/idas_spgmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_spgmr.c
-idas_sptfqmr.lo: $(srcdir)/idas_sptfqmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_sptfqmr.c
-idas_bbdpre.lo: $(srcdir)/idas_bbdpre.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/idas_bbdpre.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/idas/README b/src/idas/README
index 9f92eac..cc7c3e7 100644
--- a/src/idas/README
+++ b/src/idas/README
@@ -1,5 +1,5 @@
                                IDAS
-                    Release 1.1.0, March 2012
+                    Release 1.3.0, September 2016
                            Radu Serban 
               Center for Applied Scientific Computing, LLNL
 
@@ -8,12 +8,12 @@ IDAS is a package for the solution of differential-algebraic equation (DAE)
 systems with sensitivity analysis capabilities (both forward and adjoint modes). 
 It is written in ANSI standard C.
 
-IDAS can be used both on serial and parallel (MPI) computers.  The main
+IDAS can be used both on serial and parallel computers.  The main
 difference is in the NVECTOR module of vector kernels.  The desired
 version is obtained when compiling the example files by linking the
-appropriate library of NVECTOR kernels.  In the parallel version,
-communication between processors is done with the MPI (Message Passage
-Interface) system.
+appropriate library of NVECTOR kernels.  In the parallel versions,
+communication between processors is done with MPI, with OpenMP, 
+or with Pthreads.
 
 When used with the serial NVECTOR module, IDAS provides both direct 
 (dense and band) linear solvers and preconditioned Krylov (iterative) 
@@ -27,8 +27,8 @@ preconditioner.
 
 IDAS is part of a software family called SUNDIALS: SUite of Nonlinear and 
 DIfferential/ALgebraic equation Solvers [3].  This suite consists of CVODE, 
-CVODES, IDA, IDAS, and KINSOL.  The directory structure of the package supplied 
-reflects this family relationship.
+CVODES, ARkode, IDA, IDAS, and KINSOL.  The directory structure of the 
+package supplied reflects this family relationship.
 
 Several examples problem programs are included, covering both serial
 and parallel cases, both small and large problem sizes, and both
@@ -49,19 +49,19 @@ and the IDAS Examples [2] (idas_examples.pdf) documents.
 B. Installation
 ---------------
 
-For basic installation instructions see the file /sundials/INSTALL_NOTES. 
-For complete installation instructions see the "IDAS Installation Procedure"
+For basic installation instructions see the file /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see the "Installation Procedure"
 chapter in the IDAS User Guide.
 
 
 C. References
 -------------
 
-[1] R. Serban and C. Petra,  "User Documentation for IDAS v1.1.0," 
-    LLNL technical report UCRL-SM-234051, December 2011.
+[1] R. Serban, C. Petra,and A. C. Hindmarsh,  "User Documentation for IDAS v1.3.0," 
+    LLNL technical report UCRL-SM-234051, March 2016.
 
-[2] R. Serban, "Example Programs for IDAS v1.1.0," 
-    LLNL technical report LLNL-TR-437091, December 2011.
+[2] R. Serban and A.C. Hindmarsh, "Example Programs for IDAS v1.3.0," 
+    LLNL technical report LLNL-TR-437091, March 2016.
 
 [3] A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, 
     D. E. Shumaker, and C. S. Woodward, "SUNDIALS, Suite of Nonlinear and 
@@ -72,41 +72,9 @@ C. References
 D. Releases
 -----------
 
+v. 1.3.0   - Sep. 2016
+v. 1.2.2   - Aug. 2015
+v. 1.2.1   - Mar. 2015
+v. 1.2.0   - Mar. 2015
 v. 1.1.0   - Mar. 2012
 v. 1.0.0   - May  2009
-
-
-E. Revision History
--------------------
-
-v. 1.6.0 (May 2009) ---> v. 1.1.0 (Mar. 2012)
----------------------------------------------
-
-- Bug fixes
-   - errors in the logic for the integration of backward problems were
-     identified and fixed.
-   - a missing vector pointer setting was added in IDASensLineSrch.
-   - in IDACompleteStep, conditionals around lines loading a new column of three
-     auxiliary divided difference arrays, for a possible order increase, were fixed.
-   - after the solver memory is created, it is set to zero before being filled.
-   - in each linear solver interface function, the linear solver memory is
-     freed on an error return, and the **Free function now includes a
-     line setting to NULL the main memory pointer to the linear solver memory.
-   - a memory leak was fixed in two of the IDASp***Free functions.
-   - in rootfinding functions IDARcheck1/IDARcheck2, when an exact zero is found,
-     the array glo at the left endpoint is adjusted instead of shifting tlo.
-
-- Changes to user interface
-   - One significant design change was made with this release: The problem
-     size and its relatives, bandwidth parameters, related internal indices,
-     pivot arrays, and the optional output lsflag, have all been
-     changed from type int to type long int, except for the
-     problem size and bandwidths in user calls to routines specifying
-     BLAS/LAPACK routines for the dense/band linear solvers.  The function
-     NewIntArray is replaced by a pair NewIntArray/NewLintArray,
-     for int and long int arrays, respectively.
-   - in a minor change to the user interface, the type of the index
-     which in IDAS was changed from long int to int.
-   - in the installation files, we modified the treatment of the macro
-     SUNDIALS_USE_GENERIC_MATH, so that the parameter GENERIC_MATH_LIB
-     is either defined (with no value) or not defined.
diff --git a/src/idas/idaa.c b/src/idas/idaa.c
index 1377edd..3ee80d1 100644
--- a/src/idas/idaa.c
+++ b/src/idas/idaa.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.15 $
- * $Date: 2011/12/07 23:28:51 $
+ * $Revision: 4847 $
+ * $Date: 2016-08-03 15:50:53 -0700 (Wed, 03 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDAA adjoint integrator.
  * -----------------------------------------------------------------
@@ -305,7 +310,7 @@ int IDAAdjInit(void *ida_mem, long int steps, int interp)
 
   /* By default we will store but not interpolate sensitivities
    *  - storeSensi will be set in IDASolveF to FALSE if FSA is not enabled
-   *    or if the user forced this through IDASetAdjNoSensi 
+   *    or if the user forced this through IDAAdjSetNoSensi 
    *  - interpSensi will be set in IDASolveB to TRUE if storeSensi is TRUE 
    *    and if at least one backward problem requires sensitivities 
    *  - noInterp will be set in IDACalcICB to TRUE before the call to
@@ -474,7 +479,7 @@ int IDASolveF(void *ida_mem, realtype tout, realtype *tret,
   CkpntMem tmp;
   DtpntMem *dt_mem;
   int flag, i;
-  booleantype iret, allocOK;
+  booleantype /* iret, */ allocOK;
 
   /* Is the mem OK? */
   if (ida_mem == NULL) {
@@ -525,8 +530,9 @@ int IDASolveF(void *ida_mem, realtype tout, realtype *tret,
   
   /* We will call IDASolve in IDA_ONE_STEP mode, regardless
      of what itask is, so flag if we need to return */
-  if (itask == IDA_ONE_STEP) iret = TRUE;
-  else                       iret = FALSE;
+/*   if (itask == IDA_ONE_STEP) iret = TRUE;
+ *   else                       iret = FALSE;
+ */
 
   /* On the first step:
    *   - set tinitial
@@ -1205,7 +1211,6 @@ int IDAQuadReInitB(void *ida_mem, int which, N_Vector yQB0)
   IDAMem IDA_mem;
   IDAadjMem IDAADJ_mem;
   IDABMem IDAB_mem;
-  void *ida_memB;
   
   /* Is ida_mem valid? */
   if (ida_mem == NULL) {
@@ -1234,7 +1239,6 @@ int IDAQuadReInitB(void *ida_mem, int which, N_Vector yQB0)
     /* advance */
     IDAB_mem = IDAB_mem->ida_next;
   }
-  ida_memB = (void *) IDAB_mem->IDA_mem;
 
   return IDAQuadReInit(ida_mem, yQB0);
 }
@@ -1429,7 +1433,7 @@ int IDASolveB(void *ida_mem, realtype tBout, int itaskB)
   IDAadjMem IDAADJ_mem;
   CkpntMem ck_mem;
   IDABMem IDAB_mem, tmp_IDAB_mem;
-  int flag, sign;
+  int flag=0, sign;
   realtype tfuzz, tBret, tBn;
   booleantype gotCkpnt, reachedTBout, isActive;
 
@@ -1509,8 +1513,8 @@ int IDASolveB(void *ida_mem, realtype tBout, int itaskB)
 
   /* Check if tBout is legal */
   if ( (sign*(tBout-tinitial) < ZERO) || (sign*(tfinal-tBout) < ZERO) ) {
-    tfuzz = HUNDRED*uround*(ABS(tinitial) + ABS(tfinal));
-    if ( (sign*(tBout-tinitial) < ZERO) && (ABS(tBout-tinitial) < tfuzz) ) {
+    tfuzz = HUNDRED*uround*(SUNRabs(tinitial) + SUNRabs(tfinal));
+    if ( (sign*(tBout-tinitial) < ZERO) && (SUNRabs(tBout-tinitial) < tfuzz) ) {
       tBout = tinitial;
     } else {
       IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAA", "IDASolveB", MSGAM_BAD_TBOUT);
@@ -1919,7 +1923,7 @@ static booleantype IDAAckpntAllocVectors(IDAMem IDA_mem, CkpntMem ck_mem)
   for (j=0; j<phi_alloc_; j++) {
     phi_[j] = N_VClone(tempv);
     if(phi_[j] == NULL) {    
-      for(jj=0; jj<j; j++) N_VDestroy(phi_[jj]);
+      for(jj=0; jj<j; jj++) N_VDestroy(phi_[jj]);
       return(FALSE);
     }
   }
@@ -1929,9 +1933,9 @@ static booleantype IDAAckpntAllocVectors(IDAMem IDA_mem, CkpntMem ck_mem)
     for (j=0; j<phi_alloc_; j++) {
       phiQ_[j] = N_VClone(tempvQ);
       if(phiQ_[j] == NULL)  {        
-        for (jj=0; jj<j; j++) N_VDestroy(phiQ_[jj]);
+        for (jj=0; jj<j; jj++) N_VDestroy(phiQ_[jj]);
 
-        for(jj=0; jj<phi_alloc_; j++) N_VDestroy(phi_[jj]);
+        for(jj=0; jj<phi_alloc_; jj++) N_VDestroy(phi_[jj]);
 
         return(FALSE);
       }
@@ -2484,7 +2488,7 @@ static int IDAAhermiteGetY(IDAMem IDA_mem, realtype t,
   realtype factor1, factor2, factor3;
 
   N_Vector y0, yd0, y1, yd1;
-  N_Vector *yS0, *ySd0, *yS1, *ySd1;
+  N_Vector *yS0=NULL, *ySd0=NULL, *yS1, *ySd1;
 
   int flag, is, NS;
   long int indx;
@@ -2495,7 +2499,7 @@ static int IDAAhermiteGetY(IDAMem IDA_mem, realtype t,
   dt_mem = IDAADJ_mem->dt_mem;
  
   /* Local value of Ns */
-  NS = interpSensi ? Ns : 0;
+  NS = (interpSensi && (yyS != NULL)) ? Ns : 0;
 
   /* Get the index in dt_mem */
   flag = IDAAfindIndex(IDA_mem, t, &indx, &newpoint);
@@ -2865,11 +2869,9 @@ static int IDAApolynomialGetY(IDAMem IDA_mem, realtype t,
   dt_mem = IDAADJ_mem->dt_mem;
  
   /* Local value of Ns */
- 
-  NS = interpSensi ? Ns : 0;
+  NS = (interpSensi && (yyS != NULL)) ? Ns : 0;
 
   /* Get the index in dt_mem */
-
   flag = IDAAfindIndex(IDA_mem, t, &indx, &newpoint);
   if (flag != IDA_SUCCESS) return(flag);
 
@@ -2891,7 +2893,7 @@ static int IDAApolynomialGetY(IDAMem IDA_mem, realtype t,
   }
 
   /* Scaling factor */
-  delt = ABS(dt_mem[indx]->t - dt_mem[indx-1]->t);
+  delt = SUNRabs(dt_mem[indx]->t - dt_mem[indx-1]->t);
 
   /* Find the direction of the forward integration */
   dir = (tfinal - tinitial > ZERO) ? 1 : -1;
@@ -3152,7 +3154,7 @@ static int IDAAfindIndex(IDAMem ida_mem, realtype t,
 
     if ( *indx == 0 ) {
       /* t is beyond leftmost limit. Is it too far? */  
-      if ( ABS(t - dt_mem[0]->t) > FUZZ_FACTOR * uround ) {
+      if ( SUNRabs(t - dt_mem[0]->t) > FUZZ_FACTOR * uround ) {
         return(IDA_GETY_BADT);
       }
     }
diff --git a/src/idas/idaa_io.c b/src/idas/idaa_io.c
index 6952073..dae7618 100644
--- a/src/idas/idaa_io.c
+++ b/src/idas/idaa_io.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2010/12/01 22:41:48 $
+ * $Revision: 4538 $
+ * $Date: 2015-09-16 15:18:28 -0700 (Wed, 16 Sep 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the optional input and output
  * functions for the adjoint module in the IDAS solver.
@@ -674,7 +679,7 @@ SUNDIALS_EXPORT int IDAGetAdjCurrentCheckPoint(void *ida_mem, void **addr)
 }
 
 
-/* IDAGetConsistenICB
+/* IDAGetConsistentICB
  *
  * Returns the consistent initial conditions computed by IDACalcICB or
  * IDACalcICBS
@@ -693,21 +698,21 @@ int IDAGetConsistentICB(void *ida_mem, int which, N_Vector yyB0_mod, N_Vector yp
   
   /* Is ida_mem valid? */
   if (ida_mem == NULL) {
-    IDAProcessError(NULL, IDA_MEM_NULL, "IDAA", "IDAGetConsistenICB", MSGAM_NULL_IDAMEM);
+    IDAProcessError(NULL, IDA_MEM_NULL, "IDAA", "IDAGetConsistentICB", MSGAM_NULL_IDAMEM);
     return IDA_MEM_NULL;
   }
   IDA_mem = (IDAMem) ida_mem;
 
   /* Is ASA initialized? */
   if (IDA_mem->ida_adjMallocDone == FALSE) {
-    IDAProcessError(IDA_mem, IDA_NO_ADJ, "IDAA", "IDAGetConsistenICB",  MSGAM_NO_ADJ);
+    IDAProcessError(IDA_mem, IDA_NO_ADJ, "IDAA", "IDAGetConsistentICB",  MSGAM_NO_ADJ);
     return(IDA_NO_ADJ);
   }
   IDAADJ_mem = IDA_mem->ida_adj_mem;
 
   /* Check the value of which */
   if ( which >= nbckpbs ) {
-    IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAA", "IDAGetConsistenICB", MSGAM_BAD_WHICH);
+    IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAA", "IDAGetConsistentICB", MSGAM_BAD_WHICH);
     return(IDA_ILL_INPUT);
   }
   
diff --git a/src/idas/idas.c b/src/idas/idas.c
index dab8af2..04465c7 100644
--- a/src/idas/idas.c
+++ b/src/idas/idas.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.39 $
- * $Date: 2012/03/06 21:58:55 $
+ * $Revision: 4845 $
+ * $Date: 2016-08-03 15:45:09 -0700 (Wed, 03 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the main IDAS solver.
  * It is independent of the linear solver in use.
@@ -255,6 +260,8 @@
 #define MAXNJ            4  /* max. number of J tries in IC calc. */
 #define MAXNI           10  /* max. Newton iterations in IC calc. */
 #define EPCON RCONST(0.33)  /* Newton convergence test constant */
+#define MAXBACKS       100  /* max backtracks per Newton step in IDACalcIC */
+
 
 /* IDANewtonIter constants */
 
@@ -481,8 +488,9 @@ void *IDACreate(void)
   IDA_mem->ida_maxnh   = MAXNH;
   IDA_mem->ida_maxnj   = MAXNJ;
   IDA_mem->ida_maxnit  = MAXNI;
+  IDA_mem->ida_maxbacks  = MAXBACKS;
   IDA_mem->ida_lsoff   = FALSE;
-  IDA_mem->ida_steptol = RPowerR(IDA_mem->ida_uround, TWOTHIRDS);
+  IDA_mem->ida_steptol = SUNRpowerR(IDA_mem->ida_uround, TWOTHIRDS);
 
   /* Set default values for quad. optional inputs */
   IDA_mem->ida_quadr      = FALSE;
@@ -2244,12 +2252,12 @@ int IDASolve(void *ida_mem, realtype tout, realtype *tret,
        check for approach to tstop, and scale phi[1], phiQ[1], and phiS[1] by hh.
        Also check for zeros of root function g at and near t0.    */
 
-    tdist = ABS(tout - tn);
+    tdist = SUNRabs(tout - tn);
     if (tdist == ZERO) {
       IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAS", "IDASolve", MSG_TOO_CLOSE);
       return(IDA_ILL_INPUT);
     }
-    troundoff = TWO*uround*(ABS(tn) + ABS(tout));    
+    troundoff = TWO*uround*(SUNRabs(tn) + SUNRabs(tout));
     if (tdist < troundoff) {
       IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAS", "IDASolve", MSG_TOO_CLOSE);
       return(IDA_ILL_INPUT);
@@ -2275,11 +2283,11 @@ int IDASolve(void *ida_mem, realtype tout, realtype *tret,
       if (tout < tn) hh = -hh;
     }
 
-    rh = ABS(hh)*hmax_inv;
+    rh = SUNRabs(hh)*hmax_inv;
     if (rh > ONE) hh /= rh;
 
     if (tstopset) {
-      if ( (tstop - tn)*hh < ZERO) {
+      if ( (tstop - tn)*hh <= ZERO) {
         IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAS", "IDASolve", MSG_BAD_TSTOP, tstop, tn);
         return(IDA_ILL_INPUT);
       }
@@ -2351,8 +2359,8 @@ int IDASolve(void *ida_mem, realtype tout, realtype *tret,
 
       /* If tn is distinct from tretlast (within roundoff),
          check remaining interval for roots */
-      troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-      if ( ABS(tn - tretlast) > troundoff ) {
+      troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+      if ( SUNRabs(tn - tretlast) > troundoff ) {
         ier = IDARcheck3(IDA_mem);
         if (ier == IDA_SUCCESS) {     /* no root found */
           irfnd = 0;
@@ -2483,8 +2491,8 @@ int IDASolve(void *ida_mem, realtype tout, realtype *tret,
 
     /* If tstop is set and was reached, reset tn = tstop */
     if (tstopset) {
-      troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-      if (ABS(tn - tstop) <= troundoff) tn = tstop;
+      troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+      if (SUNRabs(tn - tstop) <= troundoff) tn = tstop;
     }
 
     /* After successful step, check for stop conditions; continue or break. */
@@ -2587,7 +2595,7 @@ int IDAGetDky(void *ida_mem, realtype t, int k, N_Vector dky)
 
   /* Check t for legality.  Here tn - hused is t_{n-1}. */
 
-  tfuzz = HUNDRED * uround * (ABS(tn) + ABS(hh));
+  tfuzz = HUNDRED * uround * (SUNRabs(tn) + SUNRabs(hh));
   if (hh < ZERO) tfuzz = - tfuzz;
   tp = tn - hused - tfuzz;
   if ((t - tp)*hh < ZERO) {
@@ -2778,7 +2786,7 @@ int IDAGetQuadDky(void *ida_mem, realtype t, int k, N_Vector dkyQ)
 int IDAGetSens(void *ida_mem, realtype *ptret, N_Vector *yySout)
 {
   IDAMem IDA_mem;
-  int is, ierr;
+  int is, ierr=0;
 
   /* Check ida_mem */
   if (ida_mem == NULL) {
@@ -2817,7 +2825,7 @@ int IDAGetSens(void *ida_mem, realtype *ptret, N_Vector *yySout)
  */
 int IDAGetSensDky(void *ida_mem, realtype t, int k, N_Vector *dkySout)
 {
-  int is, ier;
+  int is, ier=0;
   IDAMem IDA_mem;
 
   /* Check all inputs for legality */
@@ -2926,7 +2934,7 @@ int IDAGetSensDky1(void *ida_mem, realtype t, int k, int is, N_Vector dkyS)
 
   /* Check t for legality.  Here tn - hused is t_{n-1}. */
  
-  tfuzz = HUNDRED * uround * (ABS(tn) + ABS(hh));
+  tfuzz = HUNDRED * uround * (SUNRabs(tn) + SUNRabs(hh));
   if (hh < ZERO) tfuzz = - tfuzz;
   tp = tn - hused - tfuzz;
   if ((t - tp)*hh < ZERO) {
@@ -2984,7 +2992,7 @@ int IDAGetSensDky1(void *ida_mem, realtype t, int k, int is, N_Vector dkyS)
 int IDAGetQuadSens(void *ida_mem, realtype *ptret, N_Vector *yyQSout)
 {
   IDAMem IDA_mem;
-  int is, ierr;
+  int is, ierr=0;
 
   /* Check ida_mem */
   if (ida_mem == NULL) {
@@ -3023,7 +3031,7 @@ int IDAGetQuadSens(void *ida_mem, realtype *ptret, N_Vector *yyQSout)
  */
 int IDAGetQuadSensDky(void *ida_mem, realtype t, int k, N_Vector *dkyQSout)
 {
-  int is, ier;
+  int is, ier=0;
   IDAMem IDA_mem;
 
   /* Check all inputs for legality */
@@ -3158,7 +3166,7 @@ int IDAGetQuadSensDky1(void *ida_mem, realtype t, int k, int is, N_Vector dkyQS)
 
   /* Check t for legality.  Here tn - hused is t_{n-1}. */
  
-  tfuzz = HUNDRED * uround * (ABS(tn) + ABS(hh));
+  tfuzz = HUNDRED * uround * (SUNRabs(tn) + SUNRabs(hh));
   if (hh < ZERO) tfuzz = - tfuzz;
   tp = tn - hused - tfuzz;
   if ((t - tp)*hh < ZERO) {
@@ -3411,7 +3419,7 @@ static booleantype IDAAllocVectors(IDAMem IDA_mem, N_Vector tmpl)
   /* Allocate phi[0] ... phi[maxord].  Make sure phi[2] and phi[3] are
   allocated (for use as temporary vectors), regardless of maxord.       */
 
-  maxcol = MAX(maxord,3);
+  maxcol = SUNMAX(maxord,3);
   for (j=0; j <= maxcol; j++) {
     phi[j] = N_VClone(tmpl);
     if (phi[j] == NULL) {
@@ -3450,7 +3458,7 @@ static void IDAFreeVectors(IDAMem IDA_mem)
   N_VDestroy(delta);   delta = NULL;
   N_VDestroy(tempv1); tempv1 = NULL;
   N_VDestroy(tempv2); tempv2 = NULL;
-  maxcol = MAX(IDA_mem->ida_maxord_alloc,3);
+  maxcol = SUNMAX(IDA_mem->ida_maxord_alloc,3);
   for(j=0; j <= maxcol; j++) { N_VDestroy(phi[j]); phi[j] = NULL;}
 
   lrw -= (maxcol + 6)*lrw1;
@@ -3637,7 +3645,7 @@ static booleantype IDASensAllocVectors(IDAMem IDA_mem, N_Vector tmpl)
   /*  Make sure phiS[2], phiS[3] and phiS[4] are
       allocated (for use as temporary vectors), regardless of maxord.*/
 
-  maxcol = MAX(maxord,4);
+  maxcol = SUNMAX(maxord,4);
   for (j=0; j <= maxcol; j++) {
     phiS[j] = N_VCloneVectorArray(Ns, tmpl);
     if (phiS[j] == NULL) {
@@ -3707,7 +3715,7 @@ static void IDASensFreeVectors(IDAMem IDA_mem)
   N_VDestroyVectorArray(ewtS, Ns);
   N_VDestroy(tmpS3);
 
-  maxcol = MAX(IDA_mem->ida_maxord_alloc, 4);
+  maxcol = SUNMAX(IDA_mem->ida_maxord_alloc, 4);
   for (j=0; j<=maxcol; j++) 
     N_VDestroyVectorArray(phiS[j], Ns);
 
@@ -3780,7 +3788,7 @@ static booleantype IDAQuadSensAllocVectors(IDAMem IDA_mem, N_Vector tmpl)
     N_VDestroyVectorArray(eeQS, Ns);
   }
 
-  maxcol = MAX(maxord,4);
+  maxcol = SUNMAX(maxord,4);
   /* Allocate phiQS */
   for (j=0; j<=maxcol; j++) {
     phiQS[j] = N_VCloneVectorArray(Ns, tmpl);
@@ -3813,7 +3821,7 @@ static void IDAQuadSensFreeVectors(IDAMem IDA_mem)
 {
   int j, maxcol;
 
-  maxcol = MAX(maxord, 4);
+  maxcol = SUNMAX(maxord, 4);
 
   N_VDestroyVectorArray(yyQS, Ns);
   N_VDestroyVectorArray(ewtQS, Ns);
@@ -3865,7 +3873,7 @@ int IDAInitialSetup(IDAMem IDA_mem)
 
   /* Test for more vector operations, depending on options */
   if (suppressalg)
-    if (id->ops->nvwrmsnormmask == NULL) {
+    if (phi[0]->ops->nvwrmsnormmask == NULL) {
       IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAS", "IDAInitialSetup", MSG_BAD_NVECTOR);
       return(IDA_ILL_INPUT);
   }
@@ -4038,9 +4046,9 @@ int IDAInitialSetup(IDAMem IDA_mem)
  *
  * This routine is responsible for loading the error weight vector
  * ewt, according to itol, as follows:
- * (1) ewt[i] = 1 / (rtol * ABS(ycur[i]) + atol), i=0,...,Neq-1
+ * (1) ewt[i] = 1 / (rtol * SUNRabs(ycur[i]) + atol), i=0,...,Neq-1
  *     if itol = IDA_SS
- * (2) ewt[i] = 1 / (rtol * ABS(ycur[i]) + atol[i]), i=0,...,Neq-1
+ * (2) ewt[i] = 1 / (rtol * SUNRabs(ycur[i]) + atol[i]), i=0,...,Neq-1
  *     if itol = IDA_SV
  *
  *  IDAEwtSet returns 0 if ewt is successfully set as above to a
@@ -4416,8 +4424,8 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
     }
 
     if (tstopset) {
-      troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-      if (ABS(tn - tstop) <= troundoff) {
+      troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+      if (SUNRabs(tn - tstop) <= troundoff) {
         ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
         if (ier != IDA_SUCCESS) {
           IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASolve", MSG_BAD_TSTOP, tstop, tn);
@@ -4451,8 +4459,8 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
     }
 
     if (tstopset) {
-      troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-      if (ABS(tn - tstop) <= troundoff) {
+      troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+      if (SUNRabs(tn - tstop) <= troundoff) {
         ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
         if (ier != IDA_SUCCESS) {
           IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASolve", MSG_BAD_TSTOP, tstop, tn);
@@ -4469,7 +4477,7 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
     return(CONTINUE_STEPS);
         
   }
-  return(-99);
+  return(IDA_ILL_INPUT);
 }
 
 /*
@@ -4496,7 +4504,7 @@ static int IDAStopTest1(IDAMem IDA_mem, realtype tout, realtype *tret,
 static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret, 
                         N_Vector yret, N_Vector ypret, int itask)
 {
-  int ier;
+  /* int ier; */
   realtype troundoff;
 
   switch (itask) {
@@ -4505,16 +4513,16 @@ static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret,
 
       /* Test for tn past tout. */
       if ((tn - tout)*hh >= ZERO) {
-        ier = IDAGetSolution(IDA_mem, tout, yret, ypret);
+        /* ier = */ IDAGetSolution(IDA_mem, tout, yret, ypret);
         *tret = tretlast = tout;
         return(IDA_SUCCESS);
       }
 
       if (tstopset) {
         /* Test for tn at tstop and for tn near tstop */
-        troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-        if (ABS(tn - tstop) <= troundoff) {
-          ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
+        troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+        if (SUNRabs(tn - tstop) <= troundoff) {
+          /* ier = */ IDAGetSolution(IDA_mem, tstop, yret, ypret);
           *tret = tretlast = tstop;
           tstopset = FALSE;
           return(IDA_TSTOP_RETURN);
@@ -4529,9 +4537,9 @@ static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret,
 
       if (tstopset) {
         /* Test for tn at tstop and for tn near tstop */
-        troundoff = HUNDRED*uround*(ABS(tn) + ABS(hh));
-        if (ABS(tn - tstop) <= troundoff) {
-          ier = IDAGetSolution(IDA_mem, tstop, yret, ypret);
+        troundoff = HUNDRED*uround*(SUNRabs(tn) + SUNRabs(hh));
+        if (SUNRabs(tn - tstop) <= troundoff) {
+          /* ier = */ IDAGetSolution(IDA_mem, tstop, yret, ypret);
           *tret = tretlast = tstop;
           tstopset = FALSE;
           return(IDA_TSTOP_RETURN);
@@ -4544,7 +4552,7 @@ static int IDAStopTest2(IDAMem IDA_mem, realtype tout, realtype *tret,
       return(IDA_SUCCESS);
 
   }
-  return -99;
+  return IDA_ILL_INPUT;
 }
 
 /* 
@@ -4596,7 +4604,7 @@ static int IDAHandleFailure(IDAMem IDA_mem, int sflag)
 
   }
 
-  return -99;
+  return (IDA_UNRECONGISED_ERROR);
 }
 
 /* 
@@ -4885,7 +4893,7 @@ int IDAGetSolution(void *ida_mem, realtype t, N_Vector yret, N_Vector ypret)
 
   /* Check t for legality.  Here tn - hused is t_{n-1}. */
  
-  tfuzz = HUNDRED * uround * (ABS(tn) + ABS(hh));
+  tfuzz = HUNDRED * uround * (SUNRabs(tn) + SUNRabs(hh));
   if (hh < ZERO) tfuzz = - tfuzz;
   tp = tn - hused - tfuzz;
   if ((t - tp)*hh < ZERO) {
@@ -4935,7 +4943,7 @@ static void IDASetCoeffs(IDAMem IDA_mem, realtype *ck)
   /* Set coefficients for the current stepsize h */
 
   if (hh != hused || kk != kused) ns = 0;
-  ns = MIN(ns+1,kused+2);
+  ns = SUNMIN(ns+1,kused+2);
   if (kk+1 >= ns) {
     beta[0] = ONE;
     alpha[0] = ONE;
@@ -4967,8 +4975,8 @@ static void IDASetCoeffs(IDAMem IDA_mem, realtype *ck)
   
   /* compute variable stepsize error coefficient ck */
 
-  *ck = ABS(alpha[kk] + alphas - alpha0);
-  *ck = MAX(*ck, alpha[kk]);
+  *ck = SUNRabs(alpha[kk] + alphas - alpha0);
+  *ck = SUNMAX(*ck, alpha[kk]);
 
  /* change phi to phi-star  */
 
@@ -5128,7 +5136,7 @@ static int IDANls(IDAMem IDA_mem)
         N_VLinearSum(ONE, phi[0], -ONE, yy, tempv1);
         N_VProd(mm, tempv1, tempv1);
         rr = PT9*N_VMinQuotient(phi[0], tempv1);
-        rr = MAX(rr,PT1);
+        rr = SUNMAX(rr,PT1);
         return(IDA_CONSTR_RECVR);
       }
     }
@@ -5240,7 +5248,7 @@ static int IDANewtonIter(IDAMem IDA_mem)
        if (delnrm <= toldel) return(IDA_SUCCESS);
     }
     else {
-      rate = RPowerR( delnrm/oldnrm, ONE/mnewt );
+      rate = SUNRpowerR( delnrm/oldnrm, ONE/mnewt );
       if (rate > RATEMAX) return(IDA_NCONV_RECVR); 
       ss = rate/(ONE - rate);
     }
@@ -5466,7 +5474,7 @@ static int IDASensNewtonIter(IDAMem IDA_mem)
       if (delSnrm <= toldel) return(IDA_SUCCESS);
       delSnrm1 = delSnrm;
     } else {
-      rateS = RPowerR(delSnrm/delSnrm1, ONE/mnewt);
+      rateS = SUNRpowerR(delSnrm/delSnrm1, ONE/mnewt);
       if (rateS > RATEMAX) return(IDA_NCONV_RECVR);
       ssS = rateS/(ONE - rateS);
     }
@@ -5603,7 +5611,7 @@ static int IDATestError(IDAMem IDA_mem, realtype ck,
 
       /* Reduce order if errors are reduced */
 
-      if (MAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1; 
+      if (SUNMAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1;
 
     } else {
 
@@ -5630,7 +5638,7 @@ static int IDATestError(IDAMem IDA_mem, realtype ck,
  * and performs the local error test. 
  *
  * IDAQuadTestError returns the updated local error estimate at orders k, 
- * k-1, and k-2. These are norms of type MAX(|err|,|errQ|).
+ * k-1, and k-2. These are norms of type SUNMAX(|err|,|errQ|).
  *
  * The return flag can be either IDA_SUCCESS or ERROR_TEST_FAIL.
  */
@@ -5683,7 +5691,7 @@ static int IDAQuadTestError(IDAMem IDA_mem, realtype ck,
         terr_km2 = (kk-1) * (*err_km2);
 
         /* Decrease order if errors are reduced */
-        if (MAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1; 
+        if (SUNMAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1;
       
       } else {
         
@@ -5710,7 +5718,7 @@ static int IDAQuadTestError(IDAMem IDA_mem, realtype ck,
  * and performs the local error test. (Used only in staggered approach).
  *
  * IDASensTestError returns the updated local error estimate at orders k, 
- * k-1, and k-2. These are norms of type MAX(|err|,|errQ|,|errS|).
+ * k-1, and k-2. These are norms of type SUNMAX(|err|,|errQ|,|errS|).
  *
  * The return flag can be either IDA_SUCCESS or ERROR_TEST_FAIL.
  */
@@ -5766,7 +5774,7 @@ static int IDASensTestError(IDAMem IDA_mem, realtype ck,
         terr_km2 = (kk-1) * (*err_km2);
 
         /* Decrease order if errors are reduced */
-        if (MAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1; 
+        if (SUNMAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1;
       
       } else {
         
@@ -5795,7 +5803,7 @@ static int IDASensTestError(IDAMem IDA_mem, realtype ck,
  *
  * IDAQuadSensTestError returns the updated local error estimate at 
  * orders k, k-1, and k-2. These are norms of type 
- * MAX(|err|,|errQ|,|errS|,|errQS|).
+ * SUNMAX(|err|,|errQ|,|errS|,|errQS|).
  *
  * The return flag can be either IDA_SUCCESS or ERROR_TEST_FAIL.
  */
@@ -5852,7 +5860,7 @@ static int IDAQuadSensTestError(IDAMem IDA_mem, realtype ck,
         terr_km2 = (kk-1) * (*err_km2);
 
         /* Decrease order if errors are reduced */
-        if (MAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1;
+        if (SUNMAX(terr_km1, terr_km2) <= terr_k)  knew = kk - 1;
 
       } else {
         /* Decrease order to 1 if errors are reduced by at least 1/2 */
@@ -6003,8 +6011,8 @@ static int IDAHandleNFlag(IDAMem IDA_mem, int nflag, realtype err_k, realtype er
       err_knew = (kk==knew)? err_k : err_km1;
 
       kk = knew;      
-      rr = PT9 * RPowerR( TWO * err_knew + PT0001,(-ONE/(kk+1)) );
-      rr = MAX(QUARTER, MIN(PT9,rr));
+      rr = PT9 * SUNRpowerR( TWO * err_knew + PT0001,(-ONE/(kk+1)) );
+      rr = SUNMAX(QUARTER, SUNMIN(PT9,rr));
       hh *=rr;
       return(PREDICT_AGAIN);
       
@@ -6108,7 +6116,7 @@ static void IDACompleteStep(IDAMem IDA_mem, realtype err_k, realtype err_km1)
     if(nst > 1) {
       kk++;
       hnew = TWO * hh;
-      if( (tmp = ABS(hnew)*hmax_inv) > ONE ) hnew /= tmp;
+      if( (tmp = SUNRabs(hnew)*hmax_inv) > ONE ) hnew /= tmp;
       hh = hnew;
     }
 
@@ -6159,7 +6167,7 @@ static void IDACompleteStep(IDAMem IDA_mem, realtype err_k, realtype err_km1)
       else                                   {action = RAISE;    goto takeaction;}
     } else {
       terr_km1 = kk * err_km1;
-      if (terr_km1 <= MIN(terr_k, terr_kp1)) {action = LOWER;    goto takeaction;}
+      if (terr_km1 <= SUNMIN(terr_k, terr_kp1)) {action = LOWER;    goto takeaction;}
       else if (terr_kp1  >= terr_k)          {action = MAINTAIN; goto takeaction;}
       else                                   {action = RAISE;    goto takeaction;}
     }
@@ -6176,13 +6184,13 @@ static void IDACompleteStep(IDAMem IDA_mem, realtype err_k, realtype err_km1)
        If hh is reduced, hnew/hh is restricted to be between .5 and .9. */
     
     hnew = hh;
-    rr = RPowerR( (TWO * err_knew + PT0001) , (-ONE/(kk+1) ) );
+    rr = SUNRpowerR( (TWO * err_knew + PT0001) , (-ONE/(kk+1) ) );
     
     if (rr >= TWO) {
       hnew = TWO * hh;
-      if( (tmp = ABS(hnew)*hmax_inv) > ONE ) hnew /= tmp;
+      if( (tmp = SUNRabs(hnew)*hmax_inv) > ONE ) hnew /= tmp;
     } else if (rr <= ONE ) { 
-      rr = MAX(HALF, MIN(PT9,rr));
+      rr = SUNMAX(HALF, SUNMIN(PT9,rr));
       hnew = hh * rr;
     }
     
@@ -6384,8 +6392,8 @@ static realtype IDAQuadSensWrmsNormUpdate(IDAMem IDA_mem, realtype old_nrm,
  * the initial point of the IVP.
  *
  * This routine returns an int equal to:
- *  IDA_RTFUNC_FAIL < 0  if the g function failed, or
- *  IDA_SUCCESS     = 0  otherwise.
+ *  IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *  IDA_SUCCESS     = 0 otherwise.
  */
 
 static int IDARcheck1(IDAMem IDA_mem)
@@ -6396,7 +6404,7 @@ static int IDARcheck1(IDAMem IDA_mem)
 
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   tlo = tn;
-  ttol = (ABS(tn) + ABS(hh))*uround*HUNDRED;
+  ttol = (SUNRabs(tn) + SUNRabs(hh))*uround*HUNDRED;
 
   /* Evaluate g at initial t and check for zero values. */
   retval = gfun (tlo, phi[0], phi[1], glo, user_data);
@@ -6405,7 +6413,7 @@ static int IDARcheck1(IDAMem IDA_mem)
 
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       gactive[i] = FALSE;
     }
@@ -6413,7 +6421,7 @@ static int IDARcheck1(IDAMem IDA_mem)
   if (!zroot) return(IDA_SUCCESS);
 
   /* Some g_i is zero at t0; look at g at t0+(small increment). */
-  hratio = MAX(ttol/ABS(hh), PT1);
+  hratio = SUNMAX(ttol/SUNRabs(hh), PT1);
   smallh = hratio*hh;
   tplus = tlo + smallh;
   N_VLinearSum(ONE, phi[0], smallh, phi[1], yy);
@@ -6424,7 +6432,7 @@ static int IDARcheck1(IDAMem IDA_mem)
   /* We check now only the components of g which were exactly 0.0 at t0
    * to see if we can 'activate' them. */
   for (i = 0; i < nrtfn; i++) {
-    if (!gactive[i] && ABS(ghi[i]) != ZERO) {
+    if (!gactive[i] && SUNRabs(ghi[i]) != ZERO) {
       gactive[i] = TRUE;
       glo[i] = ghi[i];
     }
@@ -6447,10 +6455,10 @@ static int IDARcheck1(IDAMem IDA_mem)
  * or the last root location.
  *
  * This routine returns an int equal to:
- *     IDA_RTFUNC_FAIL (<0) if the g function failed, or
- *     CLOSERT     (>0) if a close pair of zeros was found, or
- *     RTFOUND     (>0) if a new zero of g was found near tlo, or
- *     IDA_SUCCESS (=0) otherwise.
+ *     IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *     CLOSERT         = 3 if a close pair of zeros was found, or
+ *     RTFOUND         = 1 if a new zero of g was found near tlo, or
+ *     IDA_SUCCESS     = 0 otherwise.
  */
 
 static int IDARcheck2(IDAMem IDA_mem)
@@ -6470,7 +6478,7 @@ static int IDARcheck2(IDAMem IDA_mem)
   for (i = 0; i < nrtfn; i++) iroots[i] = 0;
   for (i = 0; i < nrtfn; i++) {
     if (!gactive[i]) continue;
-    if (ABS(glo[i]) == ZERO) {
+    if (SUNRabs(glo[i]) == ZERO) {
       zroot = TRUE;
       iroots[i] = 1;
     }
@@ -6478,7 +6486,7 @@ static int IDARcheck2(IDAMem IDA_mem)
   if (!zroot) return(IDA_SUCCESS);
 
   /* One or more g_i has a zero at tlo.  Check g at tlo+smallh. */
-  ttol = (ABS(tn) + ABS(hh))*uround*HUNDRED;
+  ttol = (SUNRabs(tn) + SUNRabs(hh))*uround*HUNDRED;
   smallh = (hh > ZERO) ? ttol : -ttol;
   tplus = tlo + smallh;
   if ( (tplus - tn)*hh >= ZERO) {
@@ -6496,7 +6504,7 @@ static int IDARcheck2(IDAMem IDA_mem)
   zroot = FALSE;
   for (i = 0; i < nrtfn; i++) {
     if (!gactive[i]) continue;
-    if (ABS(ghi[i]) == ZERO) {
+    if (SUNRabs(ghi[i]) == ZERO) {
       if (iroots[i] == 1) return(CLOSERT);
       zroot = TRUE;
       iroots[i] = 1;
@@ -6516,9 +6524,9 @@ static int IDARcheck2(IDAMem IDA_mem)
  * Only roots beyond tlo in the direction of integration are sought.
  *
  * This routine returns an int equal to:
- *     IDA_RTFUNC_FAIL (<0) if the g function failed, or
- *     RTFOUND     (>0) if a root of g was found, or
- *     IDA_SUCCESS (=0) otherwise.
+ *     IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *     RTFOUND         = 1 if a root of g was found, or
+ *     IDA_SUCCESS     = 0 otherwise.
  */
 
 static int IDARcheck3(IDAMem IDA_mem)
@@ -6540,7 +6548,7 @@ static int IDARcheck3(IDAMem IDA_mem)
   nge++;
   if (retval != 0) return(IDA_RTFUNC_FAIL);
 
-  ttol = (ABS(tn) + ABS(hh))*uround*HUNDRED;
+  ttol = (SUNRabs(tn) + SUNRabs(hh))*uround*HUNDRED;
   ier = IDARootfind(IDA_mem);
   if (ier == IDA_RTFUNC_FAIL) return(IDA_RTFUNC_FAIL);
   for(i=0; i<nrtfn; i++) {
@@ -6555,7 +6563,6 @@ static int IDARcheck3(IDAMem IDA_mem)
   /* If a root was found, interpolate to get y(trout) and return.  */
   (void) IDAGetSolution(IDA_mem, trout, yy, yp);
   return(RTFOUND);
-
 }
 
 /*
@@ -6567,7 +6574,7 @@ static int IDARcheck3(IDAMem IDA_mem)
  * Here the sign of tlo - thi is arbitrary, but if multiple roots
  * are found, the one closest to tlo is returned.
  *
- *  The method used is the Illinois algorithm, a modified secant method.
+ * The method used is the Illinois algorithm, a modified secant method.
  * Reference: Kathie L. Hiebert and Lawrence F. Shampine, Implicitly
  * Defined Output Points for Solutions of ODEs, Sandia National
  * Laboratory Report SAND80-0180, February 1980.
@@ -6578,7 +6585,7 @@ static int IDARcheck3(IDAMem IDA_mem)
  *            the vector-valued function g(t).  Input only.
  *
  * gfun     = user-defined function for g(t).  Its form is
- *           (void) gfun(t, y, yp, gt, user_data)
+ *            (void) gfun(t, y, yp, gt, user_data)
  *
  * rootdir  = in array specifying the direction of zero-crossings.
  *            If rootdir[i] > 0, search for roots of g_i only if
@@ -6600,11 +6607,11 @@ static int IDARcheck3(IDAMem IDA_mem)
  *            When a root at trout is found, it is located only to
  *            within a tolerance of ttol.  Typically, ttol should
  *            be set to a value on the order of
- *              100 * UROUND * max (ABS(tlo), ABS(thi))
+ *               100 * UROUND * max (SUNRabs(tlo), SUNRabs(thi))
  *            where UROUND is the unit roundoff of the machine.
  *
  * tlo, thi = endpoints of the interval in which roots are sought.
- *            On input, and must be distinct, but tlo - thi may
+ *            On input, these must be distinct, but tlo - thi may
  *            be of either sign.  The direction of integration is
  *            assumed to be from tlo to thi.  On return, tlo and thi
  *            are the endpoints of the final relevant interval.
@@ -6630,9 +6637,9 @@ static int IDARcheck3(IDAMem IDA_mem)
  *            to that indicated by rootdir[i].
  *
  * This routine returns an int equal to:
- *      IDA_RTFUNC_FAIL (<0) if the g function failed, or
- *      RTFOUND = 1 if a root of g was found, or
- *      IDA_SUCCESS = 0 otherwise.
+ *      IDA_RTFUNC_FAIL < 0 if the g function failed, or
+ *      RTFOUND         = 1 if a root of g was found, or
+ *      IDA_SUCCESS     = 0 otherwise.
  *
  */
 
@@ -6650,13 +6657,13 @@ static int IDARootfind(IDAMem IDA_mem)
   sgnchg = FALSE;
   for (i = 0;  i < nrtfn; i++) {
     if(!gactive[i]) continue;
-    if (ABS(ghi[i]) == ZERO) {
+    if (SUNRabs(ghi[i]) == ZERO) {
       if(rootdir[i]*glo[i] <= ZERO) {
         zroot = TRUE;
       }
     } else {
       if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-        gfrac = ABS(ghi[i]/(ghi[i] - glo[i]));
+        gfrac = SUNRabs(ghi[i]/(ghi[i] - glo[i]));
         if (gfrac > maxfrac) {
           sgnchg = TRUE;
           maxfrac = gfrac;
@@ -6675,7 +6682,8 @@ static int IDARootfind(IDAMem IDA_mem)
     for (i = 0; i < nrtfn; i++) {
       iroots[i] = 0;
       if(!gactive[i]) continue;
-      if (ABS(ghi[i]) == ZERO) iroots[i] = glo[i] > 0 ? -1:1;
+      if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
+        iroots[i] = glo[i] > 0 ? -1:1;
     }
     return(RTFOUND);
   }
@@ -6688,6 +6696,9 @@ static int IDARootfind(IDAMem IDA_mem)
   side = 0;  sideprev = -1;
   loop {                                    /* Looping point */
 
+    /* If interval size is already less than tolerance ttol, break. */
+      if (SUNRabs(thi - tlo) <= ttol) break;
+
     /* Set weight alph.
        On the first two passes, set alph = 1.  Thereafter, reset alph
        according to the side (low vs high) of the subinterval in which
@@ -6708,13 +6719,13 @@ static int IDARootfind(IDAMem IDA_mem)
        If tmid is too close to tlo or thi, adjust it inward,
        by a fractional distance that is between 0.1 and 0.5.  */
     tmid = thi - (thi - tlo)*ghi[imax]/(ghi[imax] - alph*glo[imax]);
-    if (ABS(tmid - tlo) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
+    if (SUNRabs(tmid - tlo) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
       fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = tlo + fracsub*(thi - tlo);
     }
-    if (ABS(thi - tmid) < HALF*ttol) {
-      fracint = ABS(thi - tlo)/ttol;
+    if (SUNRabs(thi - tmid) < HALF*ttol) {
+      fracint = SUNRabs(thi - tlo)/ttol;
       fracsub = (fracint > FIVE) ? PT1 : HALF/fracint;
       tmid = thi - fracsub*(thi - tlo);
     }
@@ -6732,13 +6743,11 @@ static int IDARootfind(IDAMem IDA_mem)
     sideprev = side;
     for (i = 0;  i < nrtfn; i++) {
       if(!gactive[i]) continue;
-      if (ABS(grout[i]) == ZERO) {
-        if(rootdir[i]*glo[i] <= ZERO) {
-          zroot = TRUE;
-        }
+      if (SUNRabs(grout[i]) == ZERO) {
+        if(rootdir[i]*glo[i] <= ZERO) zroot = TRUE;
       } else {
         if ( (glo[i]*grout[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) {
-          gfrac = ABS(grout[i]/(grout[i] - glo[i]));
+          gfrac = SUNRabs(grout[i]/(grout[i] - glo[i]));
           if (gfrac > maxfrac) {
             sgnchg = TRUE;
             maxfrac = gfrac;
@@ -6753,8 +6762,8 @@ static int IDARootfind(IDAMem IDA_mem)
       for (i = 0; i < nrtfn; i++) ghi[i] = grout[i];
       side = 1;
       /* Stop at root thi if converged; otherwise loop. */
-      if (ABS(thi - tlo) <= ttol) break;
-    continue;  /* Return to looping point. */
+      if (SUNRabs(thi - tlo) <= ttol) break;
+      continue;  /* Return to looping point. */
     }
 
     if (zroot) {
@@ -6770,7 +6779,7 @@ static int IDARootfind(IDAMem IDA_mem)
     for (i = 0; i < nrtfn; i++) glo[i] = grout[i];
     side = 2;
     /* Stop at root thi if converged; otherwise loop back. */
-    if (ABS(thi - tlo) <= ttol) break;
+    if (SUNRabs(thi - tlo) <= ttol) break;
 
   } /* End of root-search loop */
 
@@ -6780,7 +6789,7 @@ static int IDARootfind(IDAMem IDA_mem)
     grout[i] = ghi[i];
     iroots[i] = 0;
     if(!gactive[i]) continue;
-    if ( (ABS(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
+    if ( (SUNRabs(ghi[i]) == ZERO) && (rootdir[i]*glo[i] <= ZERO) )
       iroots[i] = glo[i] > 0 ? -1:1;
     if ( (glo[i]*ghi[i] < ZERO) && (rootdir[i]*glo[i] <= ZERO) ) 
       iroots[i] = glo[i] > 0 ? -1:1;
@@ -6861,7 +6870,7 @@ static int IDASensRes1DQ(int Ns, realtype t,
   IDA_mem = (IDAMem) user_dataS;
 
   /* Set base perturbation del */
-  del  = RSqrt(MAX(rtol, uround));
+  del  = SUNRsqrt(SUNMAX(rtol, uround));
   rdel = ONE/del;
 
   pbari = pbar[is];
@@ -6873,7 +6882,7 @@ static int IDASensRes1DQ(int Ns, realtype t,
   Delp  = pbari * del;
   rDelp = ONE/Delp;
   norms = N_VWrmsNorm(yyS, ewt) * pbari;
-  rDely = MAX(norms, rdel) / pbari;
+  rDely = SUNMAX(norms, rdel) / pbari;
   Dely  = ONE/rDely;
 
   if (DQrhomax == ZERO) {
@@ -6882,7 +6891,7 @@ static int IDASensRes1DQ(int Ns, realtype t,
   } else {
     /* switch between simultaneous/separate DQ */
     ratio = Dely * rDelp;
-    if ( MAX(ONE/ratio, ratio) <= DQrhomax ) 
+    if ( SUNMAX(ONE/ratio, ratio) <= DQrhomax )
       method = (DQtype==IDA_CENTERED) ? CENTERED1 : FORWARD1;
     else
       method = (DQtype==IDA_CENTERED) ? CENTERED2 : FORWARD2;
@@ -6892,7 +6901,7 @@ static int IDASensRes1DQ(int Ns, realtype t,
 
   case CENTERED1:
 
-    Del = MIN(Dely, Delp);
+    Del = SUNMIN(Dely, Delp);
     r2Del = HALF/Del;
 
     /* Forward perturb y, y' and parameter */
@@ -6972,7 +6981,7 @@ static int IDASensRes1DQ(int Ns, realtype t,
 
   case FORWARD1:
 
-    Del = MIN(Dely, Delp);
+    Del = SUNMIN(Dely, Delp);
     rDel = ONE/Del;
 
     /* Forward perturb y, y' and parameter */
@@ -7071,12 +7080,12 @@ static int IDAQuadSensRhs1InternalDQ(IDAMem IDA_mem, int is, realtype t,
   int nfel = 0, which;
   realtype psave, pbari;
   realtype del , rdel;
-  realtype Delp, rDelp;
+  realtype Delp;
   realtype Dely, rDely;
   realtype Del , r2Del ;
   realtype norms;
 
-  del = RSqrt(MAX(rtol, uround));
+  del = SUNRsqrt(SUNMAX(rtol, uround));
   rdel = ONE/del;
   
   pbari = pbar[is];
@@ -7086,9 +7095,8 @@ static int IDAQuadSensRhs1InternalDQ(IDAMem IDA_mem, int is, realtype t,
   psave = p[which];
   
   Delp  = pbari * del;
-  rDelp = ONE/Delp;
   norms   = N_VWrmsNorm(yyS, ewt) * pbari;
-  rDely = MAX(norms, rdel) / pbari;
+  rDely = SUNMAX(norms, rdel) / pbari;
   Dely  = ONE/rDely;
   
   method = (DQtype==IDA_CENTERED) ? CENTERED1 : FORWARD1;
@@ -7097,7 +7105,7 @@ static int IDAQuadSensRhs1InternalDQ(IDAMem IDA_mem, int is, realtype t,
 
   case CENTERED1:
     
-    Del = MIN(Dely, Delp);
+    Del = SUNMIN(Dely, Delp);
     r2Del = HALF/Del;
     
     N_VLinearSum(ONE, yy, Del, yyS, yytmp);
@@ -7123,7 +7131,7 @@ static int IDAQuadSensRhs1InternalDQ(IDAMem IDA_mem, int is, realtype t,
 
   case FORWARD1:
     
-    Del = MIN(Dely, Delp);
+    Del = SUNMIN(Dely, Delp);
     rdel = ONE/Del;
     
     N_VLinearSum(ONE, yy, Del, yyS, yytmp);
@@ -7153,11 +7161,11 @@ static int IDAQuadSensRhs1InternalDQ(IDAMem IDA_mem, int is, realtype t,
  * =================================================================
  */
 
-/* 
- * IDAProcessError is a high level error handling function
- * - if ida_mem==NULL it prints the error message to stderr
- * - otherwise, it sets-up and calls the error hadling function 
- *   pointed to by ida_ehfun
+/*
+ * IDAProcessError is a high level error handling function.
+ * - If ida_mem==NULL it prints the error message to stderr.
+ * - Otherwise, it sets up and calls the error handling function 
+ *   pointed to by ida_ehfun.
  */
 
 #define ehfun   (IDA_mem->ida_ehfun)
@@ -7175,21 +7183,17 @@ void IDAProcessError(IDAMem IDA_mem,
 
   va_start(ap, msgfmt);
 
-  if (IDA_mem == NULL) {    /* We write to stderr */
+  /* Compose the message */
 
+  vsprintf(msg, msgfmt, ap);
+
+  if (IDA_mem == NULL) {    /* We write to stderr */
 #ifndef NO_FPRINTF_OUTPUT
     fprintf(stderr, "\n[%s ERROR]  %s\n  ", module, fname);
-    fprintf(stderr, msgfmt);
-    fprintf(stderr, "\n\n");
+    fprintf(stderr, "%s\n\n", msg);
 #endif
 
-  } else {                 
-    /* We can call ehfun */
-
-    /* Compose the message */
-    vsprintf(msg, msgfmt, ap);
-
-    /* Call ehfun */
+  } else {                 /* We can call ehfun */
     ehfun(error_code, module, fname, msg, eh_data);
   }
 
@@ -7197,7 +7201,6 @@ void IDAProcessError(IDAMem IDA_mem,
   va_end(ap);
 
   return;
-
 }
 
 /* IDAErrHandler is the default error handling function.
diff --git a/src/idas/idas_band.c b/src/idas/idas_band.c
index 5589249..f0c2935 100644
--- a/src/idas/idas_band.c
+++ b/src/idas/idas_band.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.14 $
- * $Date: 2011/03/23 21:12:45 $
+ * $Revision: 4909 $
+ * $Date: 2016-09-14 16:51:27 -0700 (Wed, 14 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDAS banded linear
  * solver module, IDABAND. This module uses standard banded
@@ -49,7 +54,7 @@ static int IDABandFree(IDAMem IDA_mem);
 
 /* IDABAND lfreeB function */
 
-static void IDABandFreeB(IDABMem IDAB_mem);
+static int IDABandFreeB(IDABMem IDAB_mem);
 
 /* 
  * ================================================================
@@ -123,7 +128,6 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
 {
   IDAMem IDA_mem;
   IDADlsMem idadls_mem;
-  int flag;
 
   /* Return immediately if ida_mem is NULL. */
   if (ida_mem == NULL) {
@@ -144,7 +148,7 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
     return(IDADLS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem. */
   linit  = IDABandInit;
@@ -170,6 +174,8 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
   jacdata = NULL;
   last_flag = IDADLS_SUCCESS;
 
+  idaDlsInitializeCounters(idadls_mem); 
+
   setupNonNull = TRUE;
 
   /* Store problem size */
@@ -179,7 +185,7 @@ int IDABand(void *ida_mem, long int Neq, long int mupper, long int mlower)
   idadls_mem->d_mu = mupper;
     
   /* Set extended upper half-bandwidth for JJ (required for pivoting). */
-  smu = MIN(Neq-1, mupper + mlower);
+  smu = SUNMIN(Neq-1, mupper + mlower);
 
   /* Allocate memory for JJ and pivot array. */
   JJ = NULL;
@@ -223,8 +229,7 @@ static int IDABandInit(IDAMem IDA_mem)
   idadls_mem = (IDADlsMem) lmem;
 
   /* Initialize nje and nreB */
-  nje   = 0;
-  nreDQ = 0;
+  idaDlsInitializeCounters(idadls_mem); 
 
   if (jacDQ) {
     bjac = idaDlsBandDQJac;
@@ -397,7 +402,7 @@ int IDABandB(void *ida_mem, int which,
   IDAB_mem->ida_lmem  = idadlsB_mem;
   IDAB_mem->ida_lfree = IDABandFreeB;
 
-  /* Call IDABand for the IDAS data of the backward problem. */
+  /* Call IDABand to attach the IDABAND linear solver. */
   ida_memB = (void *)IDAB_mem->IDA_mem;
   flag = IDABand(ida_memB, NeqB, mupperB, mlowerB);
 
@@ -413,12 +418,14 @@ int IDABandB(void *ida_mem, int which,
  * IDABandFreeB 
  */
 
-static void IDABandFreeB(IDABMem IDAB_mem)
+static int IDABandFreeB(IDABMem IDAB_mem)
 {
   IDADlsMemB idadlsB_mem;
 
   idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
 
   free(idadlsB_mem);
+
+  return(0);
 }
 
diff --git a/src/idas/idas_bbdpre.c b/src/idas/idas_bbdpre.c
index 774cb9f..2b93fba 100644
--- a/src/idas/idas_bbdpre.c
+++ b/src/idas/idas_bbdpre.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2011/03/23 21:12:45 $
+ * $Revision: 4921 $
+ * $Date: 2016-09-19 14:35:11 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file contains implementations of routines for a
  * band-block-diagonal preconditioner, i.e. a block-diagonal
@@ -53,7 +58,7 @@ static int IDABBDPrecSolve(realtype tt,
 
 /* Prototype for IDABBDPrecFree */
 
-static void IDABBDPrecFree(IDAMem ida_mem);
+static int IDABBDPrecFree(IDAMem ida_mem);
 
 /* Prototype for difference quotient Jacobian calculation routine */
 
@@ -73,7 +78,7 @@ static int IDAAgcomm(long int NlocalB, realtype tt,
 
 /* Prototype for the pfree routine for backward problems. */
 
-static void IDABBDPrecFreeB(IDABMem IDAB_mem);
+static int IDABBDPrecFreeB(IDABMem IDAB_mem);
 
 /* 
  * ================================================================
@@ -138,15 +143,15 @@ int IDABBDPrecInit(void *ida_mem, long int Nlocal,
   pdata->ida_mem = IDA_mem;
   pdata->glocal = Gres;
   pdata->gcomm = Gcomm;
-  pdata->mudq = MIN(Nlocal-1, MAX(0, mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0, mldq));
-  muk = MIN(Nlocal-1, MAX(0, mukeep));
-  mlk = MIN(Nlocal-1, MAX(0, mlkeep));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
+  muk = SUNMIN(Nlocal-1, SUNMAX(0, mukeep));
+  mlk = SUNMIN(Nlocal-1, SUNMAX(0, mlkeep));
   pdata->mukeep = muk;
   pdata->mlkeep = mlk;
 
   /* Set extended upper half-bandwidth for PP (required for pivoting). */
-  storage_mu = MIN(Nlocal-1, muk+mlk);
+  storage_mu = SUNMIN(Nlocal-1, muk+mlk);
 
   /* Allocate memory for preconditioner matrix. */
   pdata->PP = NULL;
@@ -180,7 +185,7 @@ int IDABBDPrecInit(void *ida_mem, long int Nlocal,
   pdata->tempv4 = tempv4;
   
   /* Set rel_yy based on input value dq_rel_yy (0 implies default). */
-  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : RSqrt(uround); 
+  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : SUNRsqrt(uround); 
 
   /* Store Nlocal to be used in IDABBDPrecSetup */
   pdata->n_local = Nlocal;
@@ -190,7 +195,12 @@ int IDABBDPrecInit(void *ida_mem, long int Nlocal,
   pdata->ipwsize = Nlocal;
   pdata->nge = 0;
 
-  /* Overwrite the pdata field in the SPILS memory */
+  /* make sure s_P_data is free from any previous allocations */
+  if (idaspils_mem->s_pfree != NULL) {
+    idaspils_mem->s_pfree(IDA_mem);
+  }
+
+  /* Point to the new pdata field in the SPILS memory */
   idaspils_mem->s_pdata = pdata;
 
   /* Attach the pfree function */
@@ -233,11 +243,11 @@ int IDABBDPrecReInit(void *ida_mem,
 
   /* Load half-bandwidths. */
   Nlocal = pdata->n_local;
-  pdata->mudq = MIN(Nlocal-1, MAX(0, mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0, mldq));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
 
   /* Set rel_yy based on input value dq_rel_yy (0 implies default). */
-  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : RSqrt(uround); 
+  pdata->rel_yy = (dq_rel_yy > ZERO) ? dq_rel_yy : SUNRsqrt(uround); 
 
   /* Re-initialize nge */
   pdata->nge = 0;
@@ -438,15 +448,15 @@ static int IDABBDPrecSolve(realtype tt,
 }
 
 
-static void IDABBDPrecFree(IDAMem IDA_mem)
+static int IDABBDPrecFree(IDAMem IDA_mem)
 {
   IDASpilsMem idaspils_mem;
   IBBDPrecData pdata;
   
-  if (IDA_mem->ida_lmem == NULL) return;
+  if (IDA_mem->ida_lmem == NULL) return(0);
   idaspils_mem = (IDASpilsMem) IDA_mem->ida_lmem;
   
-  if (idaspils_mem->s_pdata == NULL) return;
+  if (idaspils_mem->s_pdata == NULL) return(0);
   pdata = (IBBDPrecData) idaspils_mem->s_pdata;
 
   DestroyMat(PP);
@@ -455,6 +465,8 @@ static void IDABBDPrecFree(IDAMem IDA_mem)
 
   free(pdata);
   pdata = NULL;
+
+  return(0);
 }
 
 
@@ -530,7 +542,7 @@ static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
   /* Set bandwidth and number of column groups for band differencing. */
 
   width = mldq + mudq + 1;
-  ngroups = MIN(width, Nlocal);
+  ngroups = SUNMIN(width, Nlocal);
 
   /* Loop over groups. */
   for(group = 1; group <= ngroups; group++) {
@@ -544,15 +556,15 @@ static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
       /* Set increment inc to yj based on rel_yy*abs(yj), with
          adjustments using ypj and ewtj if this is small, and a further
          adjustment to give it the same sign as hh*ypj. */
-      inc = rel_yy*MAX(ABS(yj), MAX( ABS(hh*ypj), ONE/ewtj));
+      inc = rel_yy*SUNMAX(SUNRabs(yj), SUNMAX( SUNRabs(hh*ypj), ONE/ewtj));
       if (hh*ypj < ZERO) inc = -inc;
       inc = (yj + inc) - yj;
       
       /* Adjust sign(inc) again if yj has an inequality constraint. */
       if (constraints != NULL) {
         conj = cnsdata[j];
-        if (ABS(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
-        else if (ABS(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
+        if (SUNRabs(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
+        else if (SUNRabs(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
       }
 
       /* Increment yj and ypj. */
@@ -574,20 +586,20 @@ static int IBBDDQJac(IBBDPrecData pdata, realtype tt, realtype cj,
       ewtj = ewtdata[j];
 
       /* Set increment inc as before .*/
-      inc = rel_yy*MAX(ABS(yj), MAX( ABS(hh*ypj), ONE/ewtj));
+      inc = rel_yy*SUNMAX(SUNRabs(yj), SUNMAX( SUNRabs(hh*ypj), ONE/ewtj));
       if (hh*ypj < ZERO) inc = -inc;
       inc = (yj + inc) - yj;
       if (constraints != NULL) {
         conj = cnsdata[j];
-        if (ABS(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
-        else if (ABS(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
+        if (SUNRabs(conj) == ONE)      {if ((yj+inc)*conj <  ZERO) inc = -inc;}
+        else if (SUNRabs(conj) == TWO) {if ((yj+inc)*conj <= ZERO) inc = -inc;}
       }
 
       /* Form difference quotients and load into PP. */
       inc_inv = ONE/inc;
       col_j = BAND_COL(PP,j);
-      i1 = MAX(0, j-mukeep);
-      i2 = MIN(j+mlkeep, Nlocal-1);
+      i1 = SUNMAX(0, j-mukeep);
+      i2 = SUNMIN(j+mlkeep, Nlocal-1);
       for(i = i1; i <= i2; i++) BAND_COL_ELEM(col_j,i,j) =
                                   inc_inv * (gtempdata[i] - grefdata[i]);
     }
@@ -732,10 +744,11 @@ int IDABBDPrecReInitB(void *ida_mem, int which,
   return(flag);
 }
 
-static void IDABBDPrecFreeB(IDABMem IDAB_mem)
+static int IDABBDPrecFreeB(IDABMem IDAB_mem)
 {
   free(IDAB_mem->ida_pmem);
   IDAB_mem->ida_pmem = NULL;
+  return(0);
 }
 
 /* 
diff --git a/src/idas/idas_bbdpre_impl.h b/src/idas/idas_bbdpre_impl.h
index 2794ad2..9c05f4c 100644
--- a/src/idas/idas_bbdpre_impl.h
+++ b/src/idas/idas_bbdpre_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:39:18 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file (private version) for the IDABBDPRE
  * module, for a band-block-diagonal preconditioner, i.e. a
@@ -20,13 +25,13 @@
 #ifndef _IDASBBDPRE_IMPL_H
 #define _IDASBBDPRE_IMPL_H
 
+#include <idas/idas_bbdpre.h>
+#include <sundials/sundials_band.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_bbdpre.h>
-#include <sundials/sundials_band.h>
-
 /*
  * -----------------------------------------------------------------
  * Definition of IBBDPrecData
diff --git a/src/idas/idas_dense.c b/src/idas/idas_dense.c
index f7415ed..ed02e2b 100644
--- a/src/idas/idas_dense.c
+++ b/src/idas/idas_dense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.14 $
- * $Date: 2011/03/23 21:12:45 $
+ * $Revision: 4909 $
+ * $Date: 2016-09-14 16:51:27 -0700 (Wed, 14 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDASDENSE linear solver.
  * -----------------------------------------------------------------
@@ -44,7 +49,7 @@ static int IDADenseFree(IDAMem IDA_mem);
 
 /* IDADENSE lfreeB function */
 
-static void IDADenseFreeB(IDABMem IDAB_mem);
+static int IDADenseFreeB(IDABMem IDAB_mem);
 
 /* 
  * ================================================================
@@ -116,7 +121,6 @@ int IDADense(void *ida_mem, long int Neq)
 {
   IDAMem IDA_mem;
   IDADlsMem idadls_mem;
-  int flag;
 
   /* Return immediately if ida_mem is NULL. */
   if (ida_mem == NULL) {
@@ -132,7 +136,7 @@ int IDADense(void *ida_mem, long int Neq)
     return(IDADLS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree(IDA_mem);
+  if (lfree != NULL) lfree(IDA_mem);
 
   /* Set five main function fields in IDA_mem. */
   linit  = IDADenseInit;
@@ -159,6 +163,8 @@ int IDADense(void *ida_mem, long int Neq)
 
   last_flag = IDADLS_SUCCESS;
 
+  idaDlsInitializeCounters(idadls_mem); 
+
   setupNonNull = TRUE;
 
   /* Store problem size */
@@ -205,9 +211,7 @@ static int IDADenseInit(IDAMem IDA_mem)
   
   idadls_mem = (IDADlsMem) lmem;
 
-   
-  nje   = 0;
-  nreDQ = 0;
+  idaDlsInitializeCounters(idadls_mem); 
 
   if (jacDQ) {
     djac = idaDlsDenseDQJac;
@@ -368,7 +372,7 @@ int IDADenseB(void *ida_mem, int which, long int NeqB)
   
   }
 
-  /* set matrix type and initialize Jacob function. */
+  /* Set matrix type and initialize Jac function. */
   idadlsB_mem->d_typeB = SUNDIALS_DENSE;
   idadlsB_mem->d_bjacB = NULL;
 
@@ -376,7 +380,7 @@ int IDADenseB(void *ida_mem, int which, long int NeqB)
   IDAB_mem->ida_lmem  = idadlsB_mem;
   IDAB_mem->ida_lfree = IDADenseFreeB;
 
-  /* Call IDADense to the IDAS data of the backward problem. */
+  /* Call IDADense to attach the IDADENSE linear solver. */
   ida_memB = (void *)IDAB_mem->IDA_mem;
   flag = IDADense(ida_memB, NeqB);
 
@@ -393,12 +397,14 @@ int IDADenseB(void *ida_mem, int which, long int NeqB)
  * as argument. 
  */
 
-static void IDADenseFreeB(IDABMem IDAB_mem)
+static int IDADenseFreeB(IDABMem IDAB_mem)
 {
   IDADlsMemB idadlsB_mem;
 
   idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
 
   free(idadlsB_mem);
+
+  return(0);
 }
 
diff --git a/src/idas/idas_direct.c b/src/idas/idas_direct.c
index 80f309f..033d6b3 100644
--- a/src/idas/idas_direct.c
+++ b/src/idas/idas_direct.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:39:19 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for an IDASDLS linear solver.
  * -----------------------------------------------------------------
@@ -48,6 +53,10 @@ static int idaDlsDenseJacBWrapper(long int NeqB, realtype tt, realtype c_jB,
                                   DlsMat JacB, void *ida_mem,
                                   N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
 
+static int idaDlsDenseJacBSWrapper(long int NeqB, realtype tt, realtype c_jB,
+                                   N_Vector yyB, N_Vector ypB, N_Vector rBr, 
+                                   DlsMat JacB, void *ida_mem,
+                                   N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
 
 static int idaDlsBandJacBWrapper(long int NeqB, long int mupperB, long int mlowerB,
                                  realtype tt, realtype c_jB, 
@@ -55,6 +64,12 @@ static int idaDlsBandJacBWrapper(long int NeqB, long int mupperB, long int mlowe
                                  DlsMat JacB, void *ida_mem,
                                  N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
 
+static int idaDlsBandJacBSWrapper(long int NeqB, long int mupperB, long int mlowerB,
+                                  realtype tt, realtype c_jB, 
+                                  N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                  DlsMat JacB, void *ida_mem,
+                                  N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
 /*
  * =================================================================
  * READIBILITY REPLACEMENTS
@@ -365,7 +380,7 @@ int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
   yp_data  = N_VGetArrayPointer(yp);
   if(constraints!=NULL) cns_data = N_VGetArrayPointer(constraints);
 
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
 
   for (j=0; j < N; j++) {
 
@@ -380,7 +395,7 @@ int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
     adjustments using yp_j and ewt_j if this is small, and a further
     adjustment to give it the same sign as hh*yp_j. */
 
-    inc = MAX( srur * MAX( ABS(yj), ABS(hh*ypj) ) , ONE/ewt_data[j] );
+    inc = SUNMAX( srur * SUNMAX( SUNRabs(yj), SUNRabs(hh*ypj) ) , ONE/ewt_data[j] );
 
     if (hh*ypj < ZERO) inc = -inc;
     inc = (yj + inc) - yj;
@@ -388,8 +403,8 @@ int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
     /* Adjust sign(inc) again if y_j has an inequality constraint. */
     if (constraints != NULL) {
       conj = cns_data[j];
-      if (ABS(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
-      else if (ABS(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
+      if (SUNRabs(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
+      else if (SUNRabs(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
     }
 
     /* Increment y_j and yp_j, call res, and break on error return. */
@@ -482,9 +497,9 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
 
   /* Compute miscellaneous values for the Jacobian computation. */
 
-  srur = RSqrt(uround);
+  srur = SUNRsqrt(uround);
   width = mlower + mupper + 1;
-  ngroups = MIN(width, N);
+  ngroups = SUNMIN(width, N);
 
   /* Loop over column groups. */
   for (group=1; group <= ngroups; group++) {
@@ -500,7 +515,7 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
         adjustments using ypj and ewtj if this is small, and a further
         adjustment to give it the same sign as hh*ypj. */
 
-        inc = MAX( srur * MAX( ABS(yj), ABS(hh*ypj) ) , ONE/ewtj );
+        inc = SUNMAX( srur * SUNMAX( SUNRabs(yj), SUNRabs(hh*ypj) ) , ONE/ewtj );
 
         if (hh*ypj < ZERO) inc = -inc;
         inc = (yj + inc) - yj;
@@ -509,8 +524,8 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
 
         if (constraints != NULL) {
           conj = cns_data[j];
-          if (ABS(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
-          else if (ABS(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
+          if (SUNRabs(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
+          else if (SUNRabs(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
         }
 
         /* Increment yj and ypj. */
@@ -538,20 +553,20 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
       
       /* Set increment inc exactly as above. */
 
-      inc = MAX( srur * MAX( ABS(yj), ABS(hh*ypj) ) , ONE/ewtj );
+      inc = SUNMAX( srur * SUNMAX( SUNRabs(yj), SUNRabs(hh*ypj) ) , ONE/ewtj );
       if (hh*ypj < ZERO) inc = -inc;
       inc = (yj + inc) - yj;
       if (constraints != NULL) {
         conj = cns_data[j];
-        if (ABS(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
-        else if (ABS(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
+        if (SUNRabs(conj) == ONE)      {if((yj+inc)*conj <  ZERO) inc = -inc;}
+        else if (SUNRabs(conj) == TWO) {if((yj+inc)*conj <= ZERO) inc = -inc;}
       }
       
       /* Load the difference quotient Jacobian elements for column j. */
 
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mupper);
-      i2 = MIN(j+mlower,N-1);
+      i1 = SUNMAX(0, j-mupper);
+      i2 = SUNMIN(j+mlower,N-1);
       
       for (i=i1; i<=i2; i++) 
             BAND_COL_ELEM(col_j,i,j) = inc_inv*(rtemp_data[i]-r_data[i]);
@@ -564,6 +579,14 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
 }
 
 
+int idaDlsInitializeCounters(IDADlsMem idadls_mem)
+{
+  idadls_mem->d_nje   = 0;
+  idadls_mem->d_nreDQ = 0;
+  
+  return(0);
+}
+
 /* 
  * =================================================================
  * BACKWARD INTEGRATION SUPPORT
@@ -573,7 +596,10 @@ int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
 /* Additional readability replacements */
 #define yyTmp       (IDAADJ_mem->ia_yyTmp)
 #define ypTmp       (IDAADJ_mem->ia_ypTmp)
+#define yySTmp      (IDAADJ_mem->ia_yySTmp)
+#define ypSTmp      (IDAADJ_mem->ia_ypSTmp)
 #define noInterp    (IDAADJ_mem->ia_noInterp)
+#define interpSensi (IDAADJ_mem->ia_interpSensi)
 
 /*
  * -----------------------------------------------------------------
@@ -639,6 +665,64 @@ int IDADlsSetDenseJacFnB(void *ida_mem, int which, IDADlsDenseJacFnB jacB)
   return(flag);
 }
 
+int IDADlsSetDenseJacFnBS(void *ida_mem, int which, IDADlsDenseJacFnBS jacBS)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDADlsMemB idadlsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDADLS_MEM_NULL, "IDASDLS", "IDADlsSetDenseJacFnBS", MSGD_CAMEM_NULL);
+    return(IDADLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDADLS_NO_ADJ, "IDASDLS", "IDADlsSetDenseJacFnBS",  MSGD_NO_ADJ);
+    return(IDADLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDADLS_ILL_INPUT, "IDASDLS", "IDADlsSetDenseJacFnBS", MSGD_BAD_WHICH);
+    return(IDADLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Get the IDAMem corresponding to this backward problem. */
+  ida_memB = (void*) IDAB_mem->IDA_mem;
+
+  if (IDAB_mem->ida_lmem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDADLS_LMEMB_NULL, 
+                    "IDASDLS", "IDADlsSetDenseJacFnBS", MSGD_LMEMB_NULL);
+    return(IDADLS_LMEMB_NULL);
+  }
+  idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
+
+  idadlsB_mem->d_djacBS = jacBS;
+
+  if (jacBS != NULL) {
+    flag = IDADlsSetDenseJacFn(ida_memB, idaDlsDenseJacBSWrapper);
+  } else {
+    flag = IDADlsSetDenseJacFn(ida_memB, NULL);
+  }
+
+  return(flag);
+}
+
 int IDADlsSetBandJacFnB(void *ida_mem, int which, IDADlsBandJacFnB jacB)
 {
   IDAMem IDA_mem;
@@ -697,6 +781,65 @@ int IDADlsSetBandJacFnB(void *ida_mem, int which, IDADlsBandJacFnB jacB)
   return(flag);
 }
 
+int IDADlsSetBandJacFnBS(void *ida_mem, int which, IDADlsBandJacFnBS jacBS)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDADlsMemB idadlsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDADLS_MEM_NULL, "IDASDLS", "IDADlsSetBandJacFnBS", MSGD_CAMEM_NULL);
+    return(IDADLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDADLS_NO_ADJ, "IDASDLS", "IDADlsSetBandJacFnBS",  MSGD_NO_ADJ);
+    return(IDADLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDADLS_ILL_INPUT, "IDASDLS", "IDADlsSetBandJacFnBS", MSGD_BAD_WHICH);
+    return(IDADLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Get the IDAMem corresponding to this backward problem. */
+  ida_memB = (void*) IDAB_mem->IDA_mem;
+
+  if (IDAB_mem->ida_lmem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDADLS_LMEMB_NULL, 
+                    "IDASDLS", "IDADlsSetBandJacFnBS", MSGD_LMEMB_NULL);
+    return(IDADLS_LMEMB_NULL);
+  }
+  idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
+
+  idadlsB_mem->d_bjacBS = jacBS;
+
+  if (jacBS != NULL) {
+    flag = IDADlsSetBandJacFn(ida_memB, idaDlsBandJacBSWrapper);
+  } else {
+    flag = IDADlsSetBandJacFn(ida_memB, NULL);
+  }
+
+  return(flag);
+}
+
+
 /*
  * -----------------------------------------------------------------
  * PRIVATE INTERFACE FUNCTIONS
@@ -735,7 +878,7 @@ static int idaDlsDenseJacBWrapper(long int NeqB, realtype tt, realtype c_jB,
   if (noInterp == FALSE) {
     flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
     if (flag != IDA_SUCCESS) {
-      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASDLS", "idaDlsDenseJacWrapper", MSGD_BAD_T);
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASDLS", "idaDlsDenseJacBWrapper", MSGD_BAD_T);
       return(-1);
     }
   }
@@ -750,6 +893,56 @@ static int idaDlsDenseJacBWrapper(long int NeqB, realtype tt, realtype c_jB,
 }
 
 /*
+ * idaDlsDenseJacBSWrapper
+ *
+ * This routine interfaces to the IDADenseJacFnBS routine provided 
+ * by the user. idaDlsDenseJacBSWrapper is of type IDADlsDenseJacFn.
+ * NOTE: data actually contains ida_mem
+ */
+
+static int idaDlsDenseJacBSWrapper(long int NeqB, realtype tt, realtype c_jB,
+                                  N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                  DlsMat JacB, void *ida_mem, 
+                                  N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  IDAadjMem IDAADJ_mem;
+  IDAMem IDA_mem;
+  IDABMem IDAB_mem;
+  IDADlsMemB idadlsB_mem;
+  int flag;
+
+  IDA_mem = (IDAMem) ida_mem;
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Get current backward problem. */
+  IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
+  
+  /* Get linear solver's data for this backward problem. */
+  idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
+
+  /* Get forward solution from interpolation. */
+  if( noInterp == FALSE) {
+    if (interpSensi)
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, yySTmp, ypSTmp);
+    else
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
+  
+    if (flag != IDA_SUCCESS) {
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASDLS", "idaDlsDenseJacBSWrapper", MSGD_BAD_T);
+      return(-1);
+    }
+  }
+
+  /* Call user's adjoint dense djacBS routine */
+  flag = idadlsB_mem->d_djacBS(NeqB, tt, c_jB, 
+                              yyTmp, ypTmp, yySTmp, ypSTmp, 
+                              yyB, ypB, rrB, 
+                              JacB, IDAB_mem->ida_user_data, 
+                              tmp1B, tmp2B, tmp3B);
+  return(flag);
+}
+
+/*
  * idaDlsBandJacBWrapper
  *
  * This routine interfaces to the IDABandJacFnB routine provided 
@@ -782,7 +975,7 @@ static int idaDlsBandJacBWrapper(long int NeqB, long int mupperB, long int mlowe
   if (noInterp == FALSE) {
     flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
     if (flag != IDA_SUCCESS) {
-      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASDLS", "idaDlsBandJacWrapper", MSGD_BAD_T);
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASDLS", "idaDlsBandJacBWrapper", MSGD_BAD_T);
       return(-1);
     }
   }
@@ -797,3 +990,55 @@ static int idaDlsBandJacBWrapper(long int NeqB, long int mupperB, long int mlowe
   return(flag);
 }
 
+/*
+ * idaDlsBandJacBSWrapper
+ *
+ * This routine interfaces to the IDABandJacFnBS routine provided 
+ * by the user. idaDlsBandJacBSWrapper is of type IDADlsBandJacFn.
+ * NOTE: data actually contains ida_mem
+ */
+
+static int idaDlsBandJacBSWrapper(long int NeqB, long int mupperB, long int mlowerB, 
+                                 realtype tt, realtype c_jB, 
+                                 N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                                 DlsMat JacB, void *ida_mem, 
+                                 N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  IDAadjMem IDAADJ_mem;
+  IDAMem IDA_mem;
+  IDABMem IDAB_mem;
+  IDADlsMemB idadlsB_mem;
+  int flag;
+
+  IDA_mem = (IDAMem) ida_mem;
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Get current backward problem. */
+  IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
+  
+  /* Get linear solver's data for this backward problem. */
+  idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
+
+  /* Get forward solution from interpolation. */
+  if( noInterp == FALSE) {
+    if (interpSensi)
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, yySTmp, ypSTmp);
+    else
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
+  
+    if (flag != IDA_SUCCESS) {
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASDLS", "idaDlsBandJacBSWrapper", MSGD_BAD_T);
+      return(-1);
+    }
+  }
+
+  /* Call user's adjoint band bjacBS routine */
+  flag = idadlsB_mem->d_bjacBS(NeqB, mupperB, mlowerB, 
+                              tt, c_jB,
+                              yyTmp, ypTmp, yySTmp, ypSTmp, 
+                              yyB, ypB, rrB,
+                              JacB, IDAB_mem->ida_user_data, 
+                              tmp1B, tmp2B, tmp3B);
+  return(flag);
+}
+
diff --git a/src/idas/idas_direct_impl.h b/src/idas/idas_direct_impl.h
index 34c482b..8898560 100644
--- a/src/idas/idas_direct_impl.h
+++ b/src/idas/idas_direct_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:39:18 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Implementation header file for the IDADLS linear solvers.
  * -----------------------------------------------------------------
@@ -17,12 +22,12 @@
 #ifndef _IDASDLS_IMPL_H
 #define _IDASDLS_IMPL_H
 
+#include <idas/idas_direct.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_direct.h>
-
 /*
  * =================================================================
  * I D A S D I R E C T    I N T E R N A L    C O N S T A N T S
@@ -78,15 +83,20 @@ typedef struct IDADlsMemRec {
  */
   
 int idaDlsDenseDQJac(long int N, realtype tt, realtype c_j,
-		     N_Vector yy, N_Vector yp, N_Vector rr, 
-		     DlsMat Jac, void *data,
-		     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                     N_Vector yy, N_Vector yp, N_Vector rr, 
+                     DlsMat Jac, void *data,
+                     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
   
 int idaDlsBandDQJac(long int N, long int mupper, long int mlower,
-		    realtype tt, realtype c_j, 
-		    N_Vector yy, N_Vector yp, N_Vector rr,
-		    DlsMat Jac, void *data,
-		    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                    realtype tt, realtype c_j, 
+                    N_Vector yy, N_Vector yp, N_Vector rr,
+                    DlsMat Jac, void *data,
+                    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+
+/* Auxilliary functions */
+
+int idaDlsInitializeCounters(IDADlsMem idadls_mem);
+
 
 /*
  * =================================================================
@@ -108,7 +118,9 @@ typedef struct IDADlsMemRecB {
   int d_typeB;
 
   IDADlsDenseJacFnB d_djacB;
-  IDADlsBandJacFnB  d_bjacB;
+  IDADlsDenseJacFnBS d_djacBS;
+  IDADlsBandJacFnB d_bjacB;
+  IDADlsBandJacFnBS d_bjacBS;
 
 } *IDADlsMemB;
 
diff --git a/src/idas/idas_ic.c b/src/idas/idas_ic.c
index d9c1aa5..f854b65 100644
--- a/src/idas/idas_ic.c
+++ b/src/idas/idas_ic.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2011/04/26 22:51:51 $
+ * $Revision: 4539 $
+ * $Date: 2015-09-16 15:39:33 -0700 (Wed, 16 Sep 2015) $
  * ----------------------------------------------------------------- 
  * Programmers: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IC calculation for IDAS.
  * It is independent of the linear solver in use.                  
@@ -112,6 +117,7 @@ static int IDAICFailFlag(IDAMem IDA_mem, int retval);
 #define cj             (IDA_mem->ida_cj)
 #define cjratio        (IDA_mem->ida_cjratio)
 #define nbacktr        (IDA_mem->ida_nbacktr)
+#define maxbacks       (IDA_mem->ida_maxbacks)
 #define nre            (IDA_mem->ida_nre)
 #define ncfn           (IDA_mem->ida_ncfn)
 #define nni            (IDA_mem->ida_nni)
@@ -179,7 +185,8 @@ static int IDAICFailFlag(IDAMem IDA_mem, int retval);
  *   IDA_NO_RECOVERY     res, lsetup, or lsolve had a recoverable
  *                       error, but IDACalcIC could not recover
  *   IDA_CONSTR_FAIL     the inequality constraints could not be met
- *   IDA_LINESEARCH_FAIL the linesearch failed (on steptol test)
+ *   IDA_LINESEARCH_FAIL if the linesearch failed (either on steptol test
+ *                       or on the maxbacks test)
  *   IDA_CONV_FAIL       the Newton iterations failed to converge
  * -----------------------------------------------------------------
  */
@@ -227,8 +234,8 @@ int IDACalcIC(void *ida_mem, int icopt, realtype tout1)
     return(IDA_ILL_INPUT);
   }
 
-  tdist = ABS(tout1 - tn);
-  troundoff = TWO*uround*(ABS(tn) + ABS(tout1));    
+  tdist = SUNRabs(tout1 - tn);
+  troundoff = TWO*uround*(SUNRabs(tn) + SUNRabs(tout1));
   if(tdist < troundoff) {
     IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAS", "IDACalcIC", MSG_IC_TOO_CLOSE);
     return(IDA_ILL_INPUT);
@@ -533,7 +540,8 @@ int IDACalcIC(void *ida_mem, int icopt, realtype tout1)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res, lsetup, or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  *  IC_CONV_FAIL       if the Newton iterations failed to converge
  *  IC_SLOW_CONVRG     if the iterations are converging slowly
  *                     (failed the convergence test, but showed
@@ -630,7 +638,8 @@ static int IDANlsIC(IDAMem IDA_mem)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  *  IC_CONV_FAIL       if the Newton iterations failed to converge
  *  IC_SLOW_CONVRG     if the iterations appear to be converging slowly.
  *                     They failed the convergence test, but showed 
@@ -674,7 +683,7 @@ static int IDANewtonIC(IDAMem IDA_mem)
   }
 
   /* Test for convergence. Return now if the norm is small. */
-  if(sysindex == 0) fnorm *= tscale*ABS(cj);
+  if(sysindex == 0) fnorm *= tscale*SUNRabs(cj);
   if(fnorm <= epsNewt) return(IDA_SUCCESS);
   fnorm0 = fnorm;
 
@@ -733,7 +742,8 @@ static int IDANewtonIC(IDAMem IDA_mem)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  * The error return values (negative) considered non-recoverable are:
  *  IDA_RES_FAIL   if res had a non-recoverable error
  *  IDA_LSOLVE_FAIL      if lsolve had a non-recoverable error
@@ -743,7 +753,7 @@ static int IDANewtonIC(IDAMem IDA_mem)
 static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
 {
   booleantype conOK;
-  int retval, is;
+  int retval, is, nbacks;
   realtype f1norm, fnormp, f1normp, ratio, lambda, minlam, slpi;
   N_Vector mc;
   booleantype sensi_sim;
@@ -778,6 +788,7 @@ static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
   slpi = -TWO*f1norm*ratio;
   minlam = steptol/(*delnorm);
   lambda = ONE;
+  nbacks = 0;
 
   /* Are we computing sensitivities with the IDA_SIMULTANEOUS approach? */
   sensi_sim = (sensi && (ism==IDA_SIMULTANEOUS));
@@ -797,6 +808,7 @@ static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
 
   loop {
 
+    if (nbacks == maxbacks) return(IC_LINESRCH_FAILED);
     /* Get new (y,y') = (ynew,ypnew) and norm of new function value. */
     IDANewyyp(IDA_mem, lambda);
     retval = IDAfnorm(IDA_mem, &fnormp);
@@ -810,7 +822,7 @@ static int IDALineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
     if(f1normp <= f1norm + ALPHALS*slpi*lambda) break;
     if(lambda < minlam) return(IC_LINESRCH_FAILED);
     lambda /= TWO;
-    nbacktr++;
+    nbacktr++; nbacks++;
 
   }  /* End of breakout linesearch loop */
 
@@ -906,7 +918,7 @@ static int IDAfnorm(IDAMem IDA_mem, realtype *fnorm)
   }
 
   /* Rescale norm if index = 0. */
-  if(sysindex == 0) (*fnorm) *= tscale*ABS(cj);
+  if(sysindex == 0) (*fnorm) *= tscale*SUNRabs(cj);
 
   return(IDA_SUCCESS);
 
@@ -990,14 +1002,15 @@ static int IDANewy(IDAMem IDA_mem)
  * -----------------------------------------------------------------
  * IDASensNlsIC
  * -----------------------------------------------------------------
- * IDASensNlsIC solves nonlinear systems forsensitivities consistent 
+ * IDASensNlsIC solves nonlinear systems for sensitivities consistent 
  * initial conditions.  It mainly relies on IDASensNewtonIC.
  *
  * The return value is IDA_SUCCESS = 0 if no error occurred.
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res, lsetup, or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  *  IC_CONV_FAIL       if the Newton iterations failed to converge
  *  IC_SLOW_CONVRG     if the iterations are converging slowly
  *                     (failed the convergence test, but showed
@@ -1067,7 +1080,8 @@ static int IDASensNlsIC(IDAMem IDA_mem)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  *  IC_CONV_FAIL       if the Newton iterations failed to converge
  *  IC_SLOW_CONVRG     if the iterations appear to be converging slowly.
  *                     They failed the convergence test, but showed 
@@ -1093,7 +1107,7 @@ static int IDASensNewtonIC(IDAMem IDA_mem)
   }
     /* Compute the norm of the step and return if it is small enough */
   fnorm = IDASensWrmsNorm(IDA_mem, deltaS, ewtS, FALSE);
-  if(sysindex == 0) fnorm *= tscale*ABS(cj);
+  if(sysindex == 0) fnorm *= tscale*SUNRabs(cj);
   if(fnorm <= epsNewt) return(IDA_SUCCESS);
   fnorm0 = fnorm;
 
@@ -1145,7 +1159,8 @@ static int IDASensNewtonIC(IDAMem IDA_mem)
  * The error return values (positive) considered recoverable are:
  *  IC_FAIL_RECOV      if res or lsolve failed recoverably
  *  IC_CONSTR_FAILED   if the constraints could not be met
- *  IC_LINESRCH_FAILED if the linesearch failed (on steptol test)
+ *  IC_LINESRCH_FAILED if the linesearch failed (either on steptol test
+ *                     or on maxbacks test)
  * The error return values (negative) considered non-recoverable are:
  *  IDA_RES_FAIL   if res had a non-recoverable error
  *  IDA_LSOLVE_FAIL      if lsolve had a non-recoverable error
@@ -1154,7 +1169,7 @@ static int IDASensNewtonIC(IDAMem IDA_mem)
 
 static int IDASensLineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
 {
-  int is, retval;
+  int is, retval, nbacks;
   realtype f1norm, fnormp, f1normp, slpi, minlam;
   realtype lambda, ratio;
   
@@ -1168,8 +1183,11 @@ static int IDASensLineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
   slpi = -TWO*f1norm*ratio;
   minlam = steptol/(*delnorm);
   lambda = ONE;
+  nbacks = 0;
 
   loop {
+
+    if (nbacks == maxbacks) return(IC_LINESRCH_FAILED);
     /* Get new iteration in (ySnew, ypSnew). */
     IDASensNewyyp(IDA_mem, lambda);
 
@@ -1185,7 +1203,7 @@ static int IDASensLineSrch(IDAMem IDA_mem, realtype *delnorm, realtype *fnorm)
     if(f1normp <= f1norm + ALPHALS*slpi*lambda) break;
     if(lambda < minlam) return(IC_LINESRCH_FAILED);
     lambda /= TWO;
-    nbacktr++;
+    nbacktr++; nbacks++;
   }
   
   /* Update yyS0, ypS0 and fnorm and return. */
@@ -1244,7 +1262,7 @@ static int IDASensfnorm(IDAMem IDA_mem, realtype *fnorm)
 
   /* Compute the WRMS-norm; rescale if index = 0. */
   *fnorm = IDASensWrmsNorm(IDA_mem, delnewS, ewtS, FALSE);
-  if(sysindex == 0) (*fnorm) *= tscale*ABS(cj);  
+  if(sysindex == 0) (*fnorm) *= tscale*SUNRabs(cj);
 
   return(IDA_SUCCESS);
 }
diff --git a/src/idas/idas_impl.h b/src/idas/idas_impl.h
index 72b3bf7..3deb98c 100644
--- a/src/idas/idas_impl.h
+++ b/src/idas/idas_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.23 $
- * $Date: 2011/04/27 20:39:34 $
+ * $Revision: 4921 $
+ * $Date: 2016-09-19 14:35:11 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file (private version) for the main IDAS solver.
  * -----------------------------------------------------------------
@@ -17,16 +22,16 @@
 #ifndef _IDAS_IMPL_H
 #define _IDAS_IMPL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <stdarg.h>
 
 #include <idas/idas.h>
 #include <sundials/sundials_nvector.h>
 #include <sundials/sundials_types.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /* 
  * =================================================================
  *   M A I N    I N T E G R A T O R    M E M O R Y    B L O C K
@@ -233,6 +238,7 @@ typedef struct IDAMemRec {
   int ida_maxnit;           /* max. number of Netwon iterations in IC calc.   */
   int ida_nbacktr;          /* number of IC linesearch backtrack operations   */
   int ida_sysindex;         /* computed system index (0 or 1)                 */
+  int ida_maxbacks;         /* max backtracks per Newton step                 */
   realtype ida_epiccon;     /* IC nonlinear convergence test constant         */
   realtype ida_steptol;     /* minimum Newton step size in IC calculation     */
   realtype ida_tscale;      /* time scale factor = abs(tout1 - t0)            */
@@ -621,13 +627,13 @@ struct IDABMemRec {
   void *ida_lmem;
 
   /* Function to free any memory allocated by the linear solver */
-  void (*ida_lfree)(IDABMem IDAB_mem);
+  int (*ida_lfree)(IDABMem IDAB_mem);
 
   /* Memory block for a preconditioner's module interface to IDAA */ 
   void *ida_pmem;
 
   /* Function to free any memory allocated by the preconditioner module */
-  void (*ida_pfree)(IDABMem IDAB_mem);
+  int (*ida_pfree)(IDABMem IDAB_mem);
 
   /* Time at which to extract solution / quadratures */
   realtype ida_tout;
@@ -945,6 +951,7 @@ int IDASensResDQ(int Ns, realtype t,
 /* IDACalcIC error messages */
 
 #define MSG_IC_BAD_ICOPT   "icopt has an illegal value."
+#define MSG_IC_BAD_MAXBACKS "maxbacks <= 0 illegal."
 #define MSG_IC_MISSING_ID  "id = NULL conflicts with icopt."
 #define MSG_IC_TOO_CLOSE   "tout1 too close to t0 to attempt initial condition calculation."
 #define MSG_IC_BAD_ID      "id has illegal values."
@@ -955,7 +962,7 @@ int IDASensResDQ(int Ns, realtype t,
 #define MSG_IC_SOLVE_FAIL  "The linear solver solve failed unrecoverably."
 #define MSG_IC_NO_RECOVERY "The residual routine or the linear setup or solve routine had a recoverable error, but IDACalcIC was unable to recover."
 #define MSG_IC_FAIL_CONSTR "Unable to satisfy the inequality constraints."
-#define MSG_IC_FAILED_LINS "The linesearch algorithm failed with too small a step."
+#define MSG_IC_FAILED_LINS "The linesearch algorithm failed: step too small or too many backtracks."
 #define MSG_IC_CONV_FAILED "Newton/Linesearch algorithm failed to converge."
 
 /* IDASolve error messages */
diff --git a/src/idas/idas_io.c b/src/idas/idas_io.c
index 557efeb..cbd8722 100644
--- a/src/idas/idas_io.c
+++ b/src/idas/idas_io.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.26 $
- * $Date: 2010/12/01 22:39:19 $
+ * $Revision: 4539 $
+ * $Date: 2015-09-16 15:39:33 -0700 (Wed, 16 Sep 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Cosmin Petra @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the optional inputs and     
  * outputs for the IDAS solver.                                    
@@ -122,7 +127,7 @@ int IDASetMaxOrd(void *ida_mem, int maxord)
     return(IDA_ILL_INPUT);
   }  
 
-  IDA_mem->ida_maxord = MIN(maxord,MAXORD_DEFAULT);
+  IDA_mem->ida_maxord = SUNMIN(maxord,MAXORD_DEFAULT);
 
   return(IDA_SUCCESS);
 }
@@ -217,7 +222,7 @@ int IDASetStopTime(void *ida_mem, realtype tstop)
   if (IDA_mem->ida_nst > 0) {
 
     if ( (tstop - IDA_mem->ida_tn) * IDA_mem->ida_hh < ZERO ) {
-      IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASetStopTime", MSG_BAD_TSTOP, IDA_mem->ida_tn);
+      IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASetStopTime", MSG_BAD_TSTOP, tstop, IDA_mem->ida_tn);
       return(IDA_ILL_INPUT);
     }
 
@@ -573,6 +578,29 @@ int IDASetMaxNumItersIC(void *ida_mem, int maxnit)
 
 /*-----------------------------------------------------------------*/
 
+int IDASetMaxBacksIC(void *ida_mem, int maxbacks)
+{
+  IDAMem IDA_mem;
+
+  if (ida_mem==NULL) {
+    IDAProcessError(NULL, IDA_MEM_NULL, "IDA", "IDASetMaxBacksIC", MSG_NO_MEM);
+    return(IDA_MEM_NULL);
+  }
+
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (maxbacks <= 0) {
+    IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDA", "IDASetMaxBacksIC", MSG_IC_BAD_MAXBACKS);
+    return(IDA_ILL_INPUT);
+  }
+
+  IDA_mem->ida_maxbacks = maxbacks;
+
+  return(IDA_SUCCESS);
+}
+
+/*-----------------------------------------------------------------*/
+
 int IDASetLineSearchOffIC(void *ida_mem, booleantype lsoff)
 {
   IDAMem IDA_mem;
@@ -750,7 +778,7 @@ int IDASetSensParams(void *ida_mem, realtype *p, realtype *pbar, int *plist)
         IDAProcessError(IDA_mem, IDA_ILL_INPUT, "IDAS", "IDASetSensParams", MSG_BAD_PBAR);
         return(IDA_ILL_INPUT);
       }
-      IDA_mem->ida_pbar[is] = ABS(pbar[is]);
+      IDA_mem->ida_pbar[is] = SUNRabs(pbar[is]);
     }
   else
     for (is=0; is<Ns; is++)
@@ -1863,6 +1891,7 @@ char *IDAGetReturnFlagName(long int flag)
     break;
   case IDA_QSRHS_FAIL:
     sprintf(name, "IDA_QSRHS_FAIL");
+    break;
 
     /* IDAA flags follow below. */
   case IDA_NO_ADJ:
diff --git a/src/idas/idas_klu.c b/src/idas/idas_klu.c
new file mode 100644
index 0000000..80efb38
--- /dev/null
+++ b/src/idas/idas_klu.c
@@ -0,0 +1,780 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4951 $
+ * $Date: 2016-09-22 10:21:00 -0700 (Thu, 22 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the IDASKLU linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "idas/idas_klu.h"
+#include "idas_impl.h"
+#include "idas_sparse_impl.h"
+#include "sundials/sundials_klu_impl.h"
+#include "sundials/sundials_math.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+#define TWOTHIRDS    RCONST(0.6666666666666667)
+
+/* IDASKLU linit, lsetup, lsolve, and lfree routines */
+ 
+static int IDAKLUInit(IDAMem IDA_mem);
+
+static int IDAKLUSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+		       N_Vector rrp, N_Vector tmp1,
+		       N_Vector tmp2, N_Vector tmp3);
+
+static int IDAKLUSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+			     N_Vector ycur, N_Vector ypcur, N_Vector rrcur);
+
+static int IDAKLUFree(IDAMem IDA_mem);
+
+/* IDAKLU lfreeB function */
+
+static int IDAKLUFreeB(IDABMem IDAB_mem);
+
+
+/* 
+ * ================================================================
+ *
+ *                   PART I - forward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLU
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the IDA / KLU linear solver module.  
+ * IDAKLU first calls the existing lfree routine if this is not NULL.
+ * Then it sets the ida_linit, ida_lsetup, ida_lsolve, ida_lperf, and
+ * ida_lfree fields in (*IDA_mem) to be IDAKLUInit, IDAKLUSetup,
+ * IDAKLUSolve, NULL, and IDAKLUFree, respectively.
+ * It allocates memory for a structure of type IDAkluMemRec and sets
+ * the ida_lmem field in (*IDA_mem) to the address of this structure.
+ * It sets setupNonNull in (*IDA_mem) to TRUE.
+ * Finally, it allocates memory for KLU.
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_LMEM_FAIL = -1,
+ * or IDASLS_ILL_INPUT = -2.
+ *
+ * NOTE: The KLU linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, IDAKLU will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int IDAKLU(void *ida_mem, int n, int nnz, int sparsetype)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+  int flag;
+
+  /* Return immediately if ida_mem is NULL. */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDAKLU", 
+                    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (IDA_mem->ida_tempv1->ops->nvgetarraypointer == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDAKLU", 
+                    MSGSP_BAD_NVECTOR);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  if (IDA_mem->ida_lfree != NULL) flag = IDA_mem->ida_lfree(IDA_mem);
+
+  /* Set five main function fields in IDA_mem. */
+  IDA_mem->ida_linit  = IDAKLUInit;
+  IDA_mem->ida_lsetup = IDAKLUSetup;
+  IDA_mem->ida_lsolve = IDAKLUSolve;
+  IDA_mem->ida_lperf  = NULL;
+  IDA_mem->ida_lfree  = IDAKLUFree;
+
+  /* Get memory for IDASlsMemRec. */
+  idasls_mem = (IDASlsMem) malloc(sizeof(struct IDASlsMemRec));
+  if (idasls_mem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDAKLU", 
+                    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* Get memory for KLUData. */
+  klu_data = (KLUData)malloc(sizeof(struct KLUDataRec));
+  if (klu_data == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDAKLU", 
+                    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  IDA_mem->ida_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  idasls_mem->s_jaceval = NULL;
+  idasls_mem->s_jacdata = NULL;
+  idasls_mem->sparsetype = sparsetype;
+
+  /* Allocate memory for the sparse Jacobian */
+  idasls_mem->s_JacMat = SparseNewMat(n, n, nnz, sparsetype);
+  if (idasls_mem->s_JacMat == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDAKLU", 
+                    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* Initialize KLU structures */
+  switch (sparsetype) {
+    case CSC_MAT:
+      klu_data->sun_klu_solve = &klu_solve;
+      break;
+    case CSR_MAT:
+      klu_data->sun_klu_solve = &klu_tsolve;
+      break;
+    default:
+      SparseDestroyMat(idasls_mem->s_JacMat);
+      free(klu_data);
+      free(idasls_mem);
+      return(IDASLS_ILL_INPUT);
+  }
+  klu_data->s_Symbolic = NULL;
+  klu_data->s_Numeric = NULL;
+
+  /* Set default parameters for KLU */
+  flag = klu_defaults(&klu_data->s_Common);
+  if (flag == 0) {
+    IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASSLS", "IDAKLU", 
+                    MSGSP_PACKAGE_FAIL);
+    return(IDASLS_PACKAGE_FAIL);
+  }
+
+  /* Set ordering to COLAMD as the idas default use.
+     Users can set a different value with IDAKLUSetOrdering,
+     and the user-set value is loaded before any call to klu_analyze in
+     IDAKLUSetup.  */
+  klu_data->s_ordering = 1;
+  klu_data->s_Common.ordering = klu_data->s_ordering;
+
+  /* Attach linear solver memory to the integrator memory */
+  idasls_mem->s_solver_data = (void *) klu_data;
+  IDA_mem->ida_lmem = idasls_mem;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to IDAKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_MEM_NULL = -1, 
+ * IDASLS_LMEM_NULL = -2, IDASLS_ILL_INPUT = -3, or IDASLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+int IDAKLUReInit(void *ida_mem_v, int n, int nnz, int reinit_type)
+{
+  IDAMem ida_mem;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if ida_mem is NULL. */
+  if (ida_mem_v == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDAKLUReInit", 
+                    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  ida_mem = (IDAMem) ida_mem_v;
+
+  /* Return immediately if ida_lmem is NULL. */
+  if (ida_mem->ida_lmem == NULL) {
+    IDAProcessError(NULL, IDASLS_LMEM_NULL, "IDASLS", "IDAKLUReInit", 
+                    MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+
+  idasls_mem = (IDASlsMem) (ida_mem->ida_lmem);
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  /* Return if reinit_type is not valid */
+  if ((reinit_type != 1) && (reinit_type != 2)) {
+    IDAProcessError(NULL, IDASLS_ILL_INPUT, "IDASLS", "IDAKLUReInit", 
+                    MSGSP_ILL_INPUT);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  if (reinit_type == 1) {
+
+    /* Destroy previous Jacobian information */
+    if (idasls_mem->s_JacMat) {
+      SparseDestroyMat(idasls_mem->s_JacMat);
+    }
+
+    /* Allocate memory for the sparse Jacobian */
+    idasls_mem->s_JacMat = SparseNewMat(n, n, nnz, idasls_mem->sparsetype);
+    if (idasls_mem->s_JacMat == NULL) {
+      IDAProcessError(ida_mem, IDASLS_MEM_FAIL, "IDASLS", "IDAKLU", 
+                      MSGSP_MEM_FAIL);
+      return(IDASLS_MEM_FAIL);
+    }
+  }
+
+  /* Free the prior factorazation and reset for first factorization */
+  if( klu_data->s_Symbolic != NULL)
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  if( klu_data->s_Numeric != NULL)
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  idasls_mem->s_first_factorize = 1;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * IDAKLU interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the IDAKLU
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int IDAKLUInit(IDAMem IDA_mem)
+{
+  IDASlsMem idasls_mem;
+
+  idasls_mem = (IDASlsMem)IDA_mem->ida_lmem;
+
+  idasls_mem->s_jacdata = IDA_mem->ida_user_data;
+
+  idasls_mem->s_nje = 0;
+  /* Force factorization every call to IDAS */
+  idasls_mem->s_first_factorize = 1;
+
+  idasls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the IDAKLU linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     IDASLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int IDAKLUSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+		       N_Vector rrp, N_Vector tmp1, N_Vector tmp2,
+		       N_Vector tmp3)
+{
+  int retval;
+  realtype tn, cj;
+  IDASlsMem idasls_mem;
+  IDASlsSparseJacFn jaceval;
+  KLUData klu_data;
+  SlsMat JacMat;
+  void *jacdata;
+  
+  realtype uround_twothirds;
+
+  uround_twothirds = SUNRpowerR(IDA_mem->ida_uround,TWOTHIRDS);
+
+  idasls_mem = (IDASlsMem) (IDA_mem->ida_lmem);
+  tn = IDA_mem->ida_tn; 
+  cj = IDA_mem->ida_cj;
+
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  jaceval = idasls_mem->s_jaceval;
+  jacdata = idasls_mem->s_jacdata;
+  JacMat = idasls_mem->s_JacMat;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_JAC_NOSET, "IDASSLS", "IDAKLUSetup", 
+		    MSGSP_JAC_NOSET);
+    free(idasls_mem); idasls_mem = NULL;
+    return(IDASLS_JAC_NOSET);
+  }
+
+  /* Increment nje counter and call Jacobian eval routine. */
+  idasls_mem->s_nje++;
+  retval = jaceval(tn, cj, yyp, ypp, rrp, JacMat, jacdata, 
+		   tmp1, tmp2, tmp3);
+
+  if (retval < 0) {
+    IDAProcessError(IDA_mem, IDASLS_JACFUNC_UNRECVR, "IDASSLS", 
+		    "IDAKLUSetup", MSGSP_JACFUNC_FAILED);
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_UNRECVR;
+    return(IDASLS_JACFUNC_UNRECVR);
+  }
+  if (retval > 0) {
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_RECVR;
+    return(+1);
+  }
+
+  if (idasls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get the symbolic factorization
+       ------------------------------------------------------------*/ 
+    /* Update the ordering option with any user-updated values from 
+       calls to IDAKLUSetOrdering */
+    klu_data->s_Common.ordering = klu_data->s_ordering;
+
+    if (klu_data->s_Symbolic != NULL) {
+       klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    }
+    klu_data->s_Symbolic = klu_analyze(JacMat->NP, JacMat->indexptrs, 
+				       JacMat->indexvals, &(klu_data->s_Common));
+    if (klu_data->s_Symbolic == NULL) {
+      IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASSLS", "IDAKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(IDASLS_PACKAGE_FAIL);
+    }
+
+    /* ------------------------------------------------------------
+       Compute the LU factorization of  the Jacobian.
+       ------------------------------------------------------------*/
+    if( klu_data->s_Numeric != NULL) {
+       klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    }
+    klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, JacMat->data, 
+				     klu_data->s_Symbolic, &(klu_data->s_Common));
+
+    if (klu_data->s_Numeric == NULL) {
+      IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "IDAKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(IDASLS_PACKAGE_FAIL);
+    }
+
+    idasls_mem->s_first_factorize = 0;
+  }
+  else {
+
+    retval = klu_refactor(JacMat->indexptrs, JacMat->indexvals, JacMat->data, 
+			  klu_data->s_Symbolic, klu_data->s_Numeric,
+			  &(klu_data->s_Common));
+    if (retval == 0) {
+      IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "idaKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(IDASLS_PACKAGE_FAIL);
+    }
+    
+    /*-----------------------------------------------------------
+      Check if a cheap estimate of the reciprocal of the condition 
+      number is getting too small.  If so, delete
+      the prior numeric factorization and recompute it.
+      -----------------------------------------------------------*/
+    
+    retval = klu_rcond(klu_data->s_Symbolic, klu_data->s_Numeric,
+		       &(klu_data->s_Common));
+    if (retval == 0) {
+      IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "idaKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(IDASLS_PACKAGE_FAIL);
+    }
+
+    if ( (klu_data->s_Common.rcond)  < uround_twothirds ) {
+      
+      /* Condition number may be getting large.  
+	 Compute more accurate estimate */
+      retval = klu_condest(JacMat->indexptrs, JacMat->data, 
+			   klu_data->s_Symbolic, klu_data->s_Numeric,
+			   &(klu_data->s_Common));
+      if (retval == 0) {
+	IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", "idaKLUSetup", 
+			MSGSP_PACKAGE_FAIL);
+	return(IDASLS_PACKAGE_FAIL);
+      }
+      
+      if ( (klu_data->s_Common.condest) > 
+	   (1.0/uround_twothirds) ) {
+
+	/* More accurate estimate also says condition number is 
+	   large, so recompute the numeric factorization */
+
+	klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+	
+	klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+					 JacMat->data, klu_data->s_Symbolic, 
+					 &(klu_data->s_Common));
+
+	if (klu_data->s_Numeric == NULL) {
+	  IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASLS", 
+			  "IDAKLUSetup", MSGSP_PACKAGE_FAIL);
+	  return(IDASLS_PACKAGE_FAIL);
+	}
+      }
+    }
+  }
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the IDAKLU linear
+  solver module.  It calls the KLU solve routine, scales the
+  solution vector according to cjratio, then returns IDASLS_SUCCESS = 0.
+*/
+
+static int IDAKLUSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+		       N_Vector ycur, N_Vector ypcur, N_Vector rrcur)
+{
+  int flag;
+  realtype cjratio;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+  SlsMat JacMat;
+  realtype *bd;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+  JacMat = idasls_mem->s_JacMat;
+  cjratio = IDA_mem->ida_cjratio;
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+  bd = N_VGetArrayPointer(b);
+
+  /* Call KLU to solve the linear system */
+  flag = klu_data->sun_klu_solve(klu_data->s_Symbolic, klu_data->s_Numeric, JacMat->NP, 1, bd, 
+                                 &(klu_data->s_Common));
+  if (flag == 0) {
+    IDAProcessError(IDA_mem, IDASLS_PACKAGE_FAIL, "IDASSLS", "IDAKLUSolve", 
+		    MSGSP_PACKAGE_FAIL);
+    return(IDASLS_PACKAGE_FAIL);
+  }
+
+  /* Scale the correction to account for change in cj. */
+  if (cjratio != ONE) N_VScale(TWO/(ONE + cjratio), b, b);
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+  return(IDASLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the IDAKLU linear solver.
+*/
+
+static int IDAKLUFree(IDAMem IDA_mem)
+{
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  if( klu_data->s_Numeric != NULL)
+  {
+     klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  }
+  if( klu_data->s_Symbolic != NULL)
+  {
+     klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  }
+
+  if (idasls_mem->s_JacMat) {
+    SparseDestroyMat(idasls_mem->s_JacMat);
+    idasls_mem->s_JacMat = NULL;
+  }
+
+  free(klu_data); 
+  free(IDA_mem->ida_lmem); 
+
+  return(IDASLS_SUCCESS);
+}
+
+/* 
+ * ================================================================
+ *
+ *                   PART II - backward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * IDAKLUB is a wrapper around IDAKLU.
+ */
+
+int IDAKLUB(void *ida_mem, int which, int n, int nnz, int sparsetype)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDASlsMemB idaslsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDAKLUB", 
+		    MSGSP_CAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASLS_NO_ADJ, "IDASSLS", "IDAKLUB",  
+		    MSGSP_NO_ADJ);
+    return(IDASLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDAKLUB", 
+		    MSGSP_BAD_WHICH);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Alloc memory for IDASlsMemRecB */
+  idaslsB_mem = (IDASlsMemB) malloc(sizeof(struct IDASlsMemRecB));
+  if (idaslsB_mem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", 
+		    "IDAKLUB", MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  
+  }
+
+  /* set matrix type and initialize Jacob function. */
+  idaslsB_mem->s_djacB = NULL;
+
+  /* Attach lmemB data and lfreeB function. */
+  IDAB_mem->ida_lmem  = idaslsB_mem;
+  IDAB_mem->ida_lfree = IDAKLUFreeB;
+
+  /* Call IDAKLU to the IDAS data of the backward problem. */
+  ida_memB = (void *)IDAB_mem->IDA_mem;
+  flag = IDAKLU(ida_memB, n, nnz, sparsetype);
+
+  if (flag != IDASLS_SUCCESS) {
+    free(idaslsB_mem);
+    idaslsB_mem = NULL;
+  }
+
+  return(flag);
+}
+
+
+/*
+ * IDAKLUReInitB is a wrapper around IDAKLUReInit.
+ */
+
+int IDAKLUReInitB(void *ida_mem, int which, int n, int nnz, int reinit_type)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  /* IDASlsMemB idaslsB_mem; */
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDAKLUReInitB", 
+		    MSGSP_CAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASLS_NO_ADJ, "IDASSLS", "IDAKLUReInitB",  
+		    MSGSP_NO_ADJ);
+    return(IDASLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDAKLUReInitB", 
+		    MSGSP_BAD_WHICH);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  ida_memB = (void *)(IDAB_mem->IDA_mem);
+  
+  flag = IDAKLUReInit(ida_memB, n, nnz, reinit_type);
+
+  return(flag);
+}
+
+
+/*
+ * IDAKLUSetOrderingB is a wrapper around IDAKLUSetOrdering.
+ */
+
+int IDAKLUSetOrderingB(void *ida_mem, int which, int ordering_choiceB)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  /* IDASlsMemB idaslsB_mem; */
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDAKLUSetOrderingB", 
+		    MSGSP_CAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASLS_NO_ADJ, "IDASSLS", "IDAKLUSetOrderingB",  
+		    MSGSP_NO_ADJ);
+    return(IDASLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDAKLUSetOrderingB", 
+		    MSGSP_BAD_WHICH);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  ida_memB = (void *)(IDAB_mem->IDA_mem);
+  
+  flag = IDAKLUSetOrdering(ida_memB, ordering_choiceB);
+
+  return(flag);
+}
+
+
+/*
+ * IDAKLUFreeB frees the linear solver's memory for that backward problem passed 
+ * as argument. 
+ */
+
+static int IDAKLUFreeB(IDABMem IDAB_mem)
+{
+  IDASlsMemB idaslsB_mem;
+
+  idaslsB_mem = (IDASlsMemB) IDAB_mem->ida_lmem;
+
+  free(idaslsB_mem);
+
+  return(0);
+}
+
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDAKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in IDA is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int IDAKLUSetOrdering(void *ida_mem_v, int ordering_choice)
+{
+  IDAMem ida_mem;
+  IDASlsMem idasls_mem;
+  KLUData klu_data;
+
+ /* Return immediately if ida_mem_v is NULL */
+  if (ida_mem_v == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDAKLUSetOrdering",
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  ida_mem = (IDAMem) ida_mem_v;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) ) {
+    IDAProcessError(NULL, IDASLS_ILL_INPUT, "IDASLS", "IDAKLUSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  idasls_mem = (IDASlsMem) ida_mem->ida_lmem;
+  klu_data = (KLUData) idasls_mem->s_solver_data;
+
+  klu_data->s_ordering = ordering_choice;
+
+  return(IDASLS_SUCCESS);
+}
diff --git a/src/idas/idas_lapack.c b/src/idas/idas_lapack.c
index 20d7640..460067f 100644
--- a/src/idas/idas_lapack.c
+++ b/src/idas/idas_lapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2011/03/23 23:25:35 $
+ * $Revision: 4909 $
+ * $Date: 2016-09-14 16:51:27 -0700 (Wed, 14 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a IDAS dense linear solver
  * using BLAS and LAPACK functions.
@@ -64,6 +69,17 @@ static int idaLapackBandSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
                               N_Vector yC, N_Vector ypC, N_Vector fctC);
 static int idaLapackBandFree(IDAMem IDA_mem);
 
+static int IDALapackDenseFreeB(IDABMem IDAB_mem);
+static int IDALapackBandFreeB(IDABMem IDAB_mem);
+
+/* 
+ * ================================================================
+ *
+ *                   PART I - forward problems
+ *
+ * ================================================================
+ */
+
 /*
  * =================================================================
  * READIBILITY REPLACEMENTS
@@ -178,6 +194,7 @@ int IDALapackDense(void *ida_mem, int N)
   J_data = NULL;
 
   last_flag = IDADLS_SUCCESS;
+  idaDlsInitializeCounters(idadls_mem); 
   setupNonNull = TRUE;
 
   /* Set problem dimension */
@@ -276,6 +293,7 @@ int IDALapackBand(void *ida_mem, int N, int mupper, int mlower)
   J_data = NULL;
 
   last_flag = IDADLS_SUCCESS;
+  idaDlsInitializeCounters(idadls_mem); 
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -293,7 +311,7 @@ int IDALapackBand(void *ida_mem, int N, int mupper, int mlower)
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(n-1, mu + ml);
+  smu = mu + ml;
 
   /* Allocate memory for JJ and pivot arrays */
   JJ = NULL;
@@ -335,8 +353,7 @@ static int idaLapackDenseInit(IDAMem IDA_mem)
 
   idadls_mem = (IDADlsMem) lmem;
   
-  nje   = 0;
-  nreDQ = 0;
+  idaDlsInitializeCounters(idadls_mem); 
   
   if (jacDQ) {
     djac = idaDlsDenseDQJac;
@@ -452,8 +469,7 @@ static int idaLapackBandInit(IDAMem IDA_mem)
 
   idadls_mem = (IDADlsMem) lmem;
 
-  nje   = 0;
-  nreDQ = 0;
+  idaDlsInitializeCounters(idadls_mem); 
 
   if (jacDQ) {
     bjac = idaDlsBandDQJac;
@@ -560,3 +576,183 @@ static int idaLapackBandFree(IDAMem IDA_mem)
   return(0);
 }
 
+/* 
+ * ================================================================
+ *
+ *                   PART II - backward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * IDALapackDenseB is a wrapper around IDALapackDense.
+ */
+
+int IDALapackDenseB(void *ida_mem, int which, int NeqB)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDADlsMemB idadlsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDADLS_MEM_NULL, "IDASLAPACK", "IDALapackDenseB", MSGD_CAMEM_NULL);
+    return(IDADLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDADLS_NO_ADJ, "IDASLAPACK", "IDALapackDenseB",  MSGD_NO_ADJ);
+    return(IDADLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDADLS_ILL_INPUT, "IDASLAPACK", "IDALapackDenseB", MSGD_BAD_WHICH);
+    return(IDADLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Alloc memory for IDADlsMemRecB */
+  idadlsB_mem = (IDADlsMemB) malloc(sizeof(struct IDADlsMemRecB));
+  if (idadlsB_mem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDADLS_MEM_FAIL, "IDASLAPACK", "IDALapackDenseB", MSGD_MEM_FAIL);
+    return(IDADLS_MEM_FAIL);
+  
+  }
+
+  /* Set matrix type and initialize Jac function. */
+  idadlsB_mem->d_typeB = SUNDIALS_DENSE;
+  idadlsB_mem->d_bjacB = NULL;
+
+  /* Attach lmemB data and lfreeB function. */
+  IDAB_mem->ida_lmem  = idadlsB_mem;
+  IDAB_mem->ida_lfree = IDALapackDenseFreeB;
+
+  /* Call IDALapackDense to attach the IDALAPACKDENSE linear solver. */
+  ida_memB = (void *)IDAB_mem->IDA_mem;
+  flag = IDALapackDense(ida_memB, NeqB);
+
+  if (flag != IDADLS_SUCCESS) {
+    free(idadlsB_mem);
+    idadlsB_mem = NULL;
+  }
+
+  return(flag);
+}
+
+/*
+ * IDALapackDenseFreeB frees the linear solver's memory for that backward problem passed 
+ * as argument. 
+ */
+
+static int IDALapackDenseFreeB(IDABMem IDAB_mem)
+{
+  IDADlsMemB idadlsB_mem;
+
+  idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
+
+  free(idadlsB_mem);
+
+  return(0);
+}
+
+/*
+ * IDALapackBandB is a wrapper around IDALapackBand. It attaches the IDASLAPACKBAND linear solver
+ * to the backward problem memory block.
+ */
+
+int IDALapackBandB(void *ida_mem, int which,
+             int NeqB, int mupperB, int mlowerB)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDADlsMemB idadlsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDADLS_MEM_NULL, "IDASLAPACKBAND", "IDALapackBandB", MSGD_CAMEM_NULL);
+    return(IDADLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDADLS_NO_ADJ, "IDASLAPACKBAND", "IDALapackBandB",  MSGD_NO_ADJ);
+    return(IDADLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDADLS_ILL_INPUT, "IDASLAPACKBAND", "IDALapackBandB", MSGD_BAD_WHICH);
+    return(IDADLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Get memory for IDADlsMemRecB */
+  idadlsB_mem = (IDADlsMemB) malloc(sizeof(struct IDADlsMemRecB));
+  if (idadlsB_mem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDADLS_MEM_FAIL, "IDASLAPACKBAND", "IDALapackBandB", MSGD_MEM_FAIL);
+    return(IDADLS_MEM_FAIL);
+  
+  }
+
+  /* set matrix type and initialize Jacob function. */
+  idadlsB_mem->d_typeB = SUNDIALS_BAND;
+  idadlsB_mem->d_bjacB = NULL;
+
+
+  /* Attach lmemB data and lfreeB function. */
+  IDAB_mem->ida_lmem  = idadlsB_mem;
+  IDAB_mem->ida_lfree = IDALapackBandFreeB;
+
+  /* Call IDALapackBand to attach the IDALAPACKBAND linear solver. */
+  ida_memB = (void *)IDAB_mem->IDA_mem;
+  flag = IDALapackBand(ida_memB, NeqB, mupperB, mlowerB);
+
+  if (flag != IDADLS_SUCCESS) {
+    free(idadlsB_mem);
+    idadlsB_mem = NULL;
+  }
+
+  return(flag);
+}
+
+/*
+ * IDALapackBandFreeB 
+ */
+
+static int IDALapackBandFreeB(IDABMem IDAB_mem)
+{
+  IDADlsMemB idadlsB_mem;
+
+  idadlsB_mem = (IDADlsMemB) IDAB_mem->ida_lmem;
+
+  free(idadlsB_mem);
+
+  return(0);
+}
+
diff --git a/src/idas/idas_sparse.c b/src/idas/idas_sparse.c
new file mode 100644
index 0000000..9009457
--- /dev/null
+++ b/src/idas/idas_sparse.c
@@ -0,0 +1,429 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for an IDASSLS linear solver.
+ * -----------------------------------------------------------------
+ */
+
+/* 
+ * =================================================================
+ * IMPORTED HEADER FILES
+ * =================================================================
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "idas_impl.h"
+#include "idas_sparse_impl.h"
+#include <sundials/sundials_math.h>
+
+/* 
+ * =================================================================
+ * FUNCTION SPECIFIC CONSTANTS
+ * =================================================================
+ */
+
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* 
+ * =================================================================
+ * PROTOTYPES FOR PRIVATE FUNCTIONS
+ * =================================================================
+ */
+
+static int idaSlsSparseJacBWrapper(realtype tt, realtype c_jB,
+		            N_Vector yyB, N_Vector ypB, N_Vector rBr, 
+		            SlsMat JacMat, void *ida_mem,
+			    N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+static int idaSlsSparseJacBSWrapper(realtype tt, realtype c_jB,
+			      N_Vector yyB, N_Vector ypB, N_Vector rBr, 
+			      SlsMat JacMat, void *ida_mem,
+			      N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+/* 
+ * =================================================================
+ * EXPORTED FUNCTIONS FOR IMPLICIT INTEGRATION
+ * =================================================================
+ */
+              
+/*
+ * IDASlsSetSparseJacFn specifies the sparse Jacobian function.
+ */
+int IDASlsSetSparseJacFn(void *ida_mem, IDASlsSparseJacFn jac)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+
+  /* Return immediately if ida_mem is NULL */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDASlsSetSparseJacFn", 
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (IDA_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_LMEM_NULL, "IDASSLS", 
+		    "IDASlsSetSparseJacFn", MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  idasls_mem->s_jaceval = jac;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * IDASlsGetNumJacEvals returns the number of Jacobian evaluations.
+ */
+int IDASlsGetNumJacEvals(void *ida_mem, long int *njevals)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+
+  /* Return immediately if ida_mem is NULL */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDASlsGetNumJacEvals", MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (IDA_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_LMEM_NULL, "IDASSLS", 
+		    "IDASlsGetNumJacEvals", MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  *njevals = idasls_mem->s_nje;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * IDASlsGetReturnFlagName returns the name associated with a IDASLS
+ * return value.
+ */
+char *IDASlsGetReturnFlagName(long int flag)
+{
+  char *name;
+
+  name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case IDASLS_SUCCESS:
+    sprintf(name,"IDASLS_SUCCESS");
+    break;   
+  case IDASLS_MEM_NULL:
+    sprintf(name,"IDASLS_MEM_NULL");
+    break;
+  case IDASLS_LMEM_NULL:
+    sprintf(name,"IDASLS_LMEM_NULL");
+    break;
+  case IDASLS_ILL_INPUT:
+    sprintf(name,"IDASLS_ILL_INPUT");
+    break;
+  case IDASLS_MEM_FAIL:
+    sprintf(name,"IDASLS_MEM_FAIL");
+    break;
+  case IDASLS_JAC_NOSET:
+    sprintf(name,"IDASLS_JAC_NOSET");
+    break;
+  case IDASLS_JACFUNC_UNRECVR:
+    sprintf(name,"IDASLS_JACFUNC_UNRECVR");
+    break;
+  case IDASLS_JACFUNC_RECVR:
+    sprintf(name,"IDASLS_JACFUNC_RECVR");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+/*
+ * IDASlsGetLastFlag returns the last flag set in a IDASLS function.
+ */
+int IDASlsGetLastFlag(void *ida_mem, long int *flag)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+
+  /* Return immediately if ida_mem is NULL */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDASlsGetLastFlag", 
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  if (IDA_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_LMEM_NULL, "IDASSLS", 
+		    "IDASlsGetLastFlag", MSGSP_LMEM_NULL);
+    return(IDASLS_LMEM_NULL);
+  }
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  *flag = idasls_mem->s_last_flag;
+
+  return(IDASLS_SUCCESS);
+}
+
+/* 
+ * =================================================================
+ * BACKWARD INTEGRATION SUPPORT
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * EXPORTED FUNCTIONS
+ * -----------------------------------------------------------------
+ */
+
+int IDASlsSetSparseJacFnB(void *ida_mem, int which, IDASlsSparseJacFnB jacB)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDASlsMemB idaslsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDASlsSetSparseJacFnB", 
+		    MSGSP_CAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASLS_NO_ADJ, "IDASSLS", "IDASlsSetSparseJacFnB", 
+		    MSGSP_NO_ADJ);
+    return(IDASLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", 
+		    "IDASlsSetSparseJacFnB", MSGSP_BAD_WHICH);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Get the IDAMem corresponding to this backward problem. */
+  ida_memB = (void*) IDAB_mem->IDA_mem;
+
+  if (IDAB_mem->ida_lmem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDASLS_LMEMB_NULL, 
+                    "IDASSLS", "IDASlsSetSparseJacFnB", MSGSP_LMEMB_NULL);
+    return(IDASLS_LMEMB_NULL);
+  }
+  idaslsB_mem = (IDASlsMemB) IDAB_mem->ida_lmem;
+
+  idaslsB_mem->s_djacB = jacB;
+
+  if (jacB != NULL) {
+    flag = IDASlsSetSparseJacFn(ida_memB, idaSlsSparseJacBWrapper);
+  } else {
+    flag = IDASlsSetSparseJacFn(ida_memB, NULL);
+  }
+
+  return(flag);
+}
+
+int IDASlsSetSparseJacFnBS(void *ida_mem, int which, IDASlsSparseJacFnBS jacBS)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDASlsMemB idaslsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASDLS", "IDASlsSetSparseJacFnBS", MSGSP_CAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASLS_NO_ADJ, "IDASSLS", "IDASlsSetSparseJacFnBS",  MSGSP_NO_ADJ);
+    return(IDASLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDASlsSetSparseJacFnBS", MSGSP_BAD_WHICH);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Get the IDAMem corresponding to this backward problem. */
+  ida_memB = (void*) IDAB_mem->IDA_mem;
+
+  if (IDAB_mem->ida_lmem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDASLS_LMEMB_NULL, 
+                    "IDASSLS", "IDASlsSetSparseJacFnBS", MSGSP_LMEMB_NULL);
+    return(IDASLS_LMEMB_NULL);
+  }
+  idaslsB_mem = (IDASlsMemB) IDAB_mem->ida_lmem;
+
+  idaslsB_mem->s_djacBS = jacBS;
+
+  if (jacBS != NULL) {
+    flag = IDASlsSetSparseJacFn(ida_memB, idaSlsSparseJacBSWrapper);
+  } else {
+    flag = IDASlsSetSparseJacFn(ida_memB, NULL);
+  }
+
+  return(flag);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * PRIVATE INTERFACE FUNCTIONS
+ * -----------------------------------------------------------------
+ */
+
+/*
+ * idaSlsSparseJacBWrapper
+ *
+ * This routine interfaces to the IDASlsSparseJacFnB routine provided 
+ * by the user. idaSlsSparseJacBWrapper is of type IDASlsSparseJacFn.
+ * NOTE: data actually contains ida_mem
+ */
+
+static int idaSlsSparseJacBWrapper(realtype tt, realtype c_jB,
+                       N_Vector yyB, N_Vector ypB, N_Vector rrB,
+  		       SlsMat JacMat, void *ida_mem, 
+                       N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  IDAadjMem IDAADJ_mem;
+  IDAMem IDA_mem;
+  IDABMem IDAB_mem;
+  IDASlsMemB idaslsB_mem;
+  int flag;
+
+  IDA_mem = (IDAMem) ida_mem;
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Get current backward problem. */
+  IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
+  
+  /* Get linear solver's data for this backward problem. */
+  idaslsB_mem = (IDASlsMemB) IDAB_mem->ida_lmem;
+
+  /* Forward solution from interpolation */
+  if (IDAADJ_mem->ia_noInterp == FALSE) {
+    flag = IDAADJ_mem->ia_getY(IDA_mem, tt, IDAADJ_mem->ia_yyTmp, 
+			       IDAADJ_mem->ia_ypTmp, NULL, NULL);
+    if (flag != IDA_SUCCESS) {
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSLS",
+		      "idaSlsSparseJacBWrapper", MSGSP_BAD_T);
+      return(-1);
+    }
+  }
+
+  /* Call user's adjoint sparse djacB routine */
+  flag = idaslsB_mem->s_djacB(tt, c_jB, 
+                              IDAADJ_mem->ia_yyTmp, IDAADJ_mem->ia_ypTmp, 
+                              yyB, ypB, rrB, 
+                              JacMat, IDAB_mem->ida_user_data,
+                              tmp1B, tmp2B, tmp3B);
+  return(flag);
+}
+
+/*
+ * idaSlsSparseJacBSWrapper
+ *
+ * This routine interfaces to the IDASlsSparseJacFnBS routine provided 
+ * by the user. idaSlsSparseJacBSWrapper is of type IDASlsSparseJacFn.
+ * NOTE: data actually contains ida_mem
+ */
+
+static int idaSlsSparseJacBSWrapper(realtype tt, realtype c_jB,
+                       N_Vector yyB, N_Vector ypB, N_Vector rrB,
+  		       SlsMat JacMat, void *ida_mem, 
+                       N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  IDAadjMem IDAADJ_mem;
+  IDAMem IDA_mem;
+  IDABMem IDAB_mem;
+  IDASlsMemB idaslsB_mem;
+  int flag;
+
+  IDA_mem = (IDAMem) ida_mem;
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Get current backward problem. */
+  IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
+  
+  /* Get linear solver's data for this backward problem. */
+  idaslsB_mem = (IDASlsMemB) IDAB_mem->ida_lmem;
+
+  /* Forward solution from interpolation */
+  if (IDAADJ_mem->ia_noInterp == FALSE) {
+    if (IDAADJ_mem->ia_interpSensi)
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, IDAADJ_mem->ia_yyTmp, 
+				 IDAADJ_mem->ia_ypTmp,
+				 IDAADJ_mem->ia_yySTmp,IDAADJ_mem->ia_yySTmp);
+    else
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, IDAADJ_mem->ia_yyTmp, 
+			       IDAADJ_mem->ia_ypTmp, NULL, NULL);
+    if (flag != IDA_SUCCESS) {
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSLS",
+		      "idaSlsSparseJacBSWrapper", MSGSP_BAD_T);
+      return(-1);
+    }
+  }
+
+  /* Call user's adjoint sparse djacB routine */
+  flag = idaslsB_mem->s_djacBS(tt, c_jB, 
+                              IDAADJ_mem->ia_yyTmp, IDAADJ_mem->ia_ypTmp, 
+			      IDAADJ_mem->ia_yySTmp, IDAADJ_mem->ia_ypSTmp,
+			      yyB, ypB, rrB, 
+                              JacMat, IDAB_mem->ida_user_data,
+                              tmp1B, tmp2B, tmp3B);
+  return(flag);
+}
diff --git a/src/idas/idas_sparse_impl.h b/src/idas/idas_sparse_impl.h
new file mode 100644
index 0000000..b9cedd5
--- /dev/null
+++ b/src/idas/idas_sparse_impl.h
@@ -0,0 +1,127 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the IDASLS linear solvers.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _IDASSPARSE_IMPL_H
+#define _IDASSPARSE_IMPL_H
+
+#include "idas/idas_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * I D A S S P A R S E    I N T E R N A L    C O N S T A N T S
+ * =================================================================
+ */
+
+/*
+ * =================================================================
+ * PART I:  F O R W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : IDASlsMemRec, IDASlsMem                             
+ * -----------------------------------------------------------------
+ * IDASlsMem is pointer to a IDASlsMemRec structure.
+ * -----------------------------------------------------------------
+ */
+
+typedef struct IDASlsMemRec {
+
+  IDASlsSparseJacFn s_jaceval; /* user Jacobian evaluation routine 
+				  to be called */
+  void *s_jacdata;           /* J_data is passed to djac or bjac */
+
+  long int s_nje;           /* nje = no. of calls to jac */
+
+  long int s_last_flag;     /* last error return flag */
+
+  int s_first_factorize;    /* flag telling whether the first 
+			       factorization needs to happen */
+  SlsMat s_JacMat;          /* J = dF/dy + cj*dF/dy' */
+  
+  int sparsetype;           /* matrix type: compressed sparse column or row */
+
+  void *s_solver_data;      /* structure for solver-specific data */
+  
+
+} *IDASlsMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Prototypes of internal functions
+ * -----------------------------------------------------------------
+ */
+  
+
+/*
+ * =================================================================
+ * PART II:  B A C K W A R D    P R O B L E M S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : IDASlsMemRecB, IDASlsMemB       
+ * -----------------------------------------------------------------
+ * An IDASLS linear solver's specification function attaches such
+ * a structure to the lmemB filed of IDABMem
+ * -----------------------------------------------------------------
+ */
+
+typedef struct IDASlsMemRecB {
+
+  IDASlsSparseJacFnB s_djacB;
+  IDASlsSparseJacFnBS s_djacBS;
+
+} *IDASlsMemB;
+
+
+/*
+ * =================================================================
+ * E R R O R   M E S S A G E S
+ * =================================================================
+ */
+
+#define MSGSP_IDAMEM_NULL "Integrator memory is NULL."
+#define MSGSP_BAD_NVECTOR "A required vector operation is not implemented."
+#define MSGSP_MEM_FAIL "A memory request failed."
+#define MSGSP_LMEM_NULL "Linear solver memory is NULL."
+#define MSGSP_ILL_INPUT "Invalid input detected."
+#define MSGSP_JAC_NOSET "Jacobian evaluation function has not been set."
+#define MSGSP_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
+#define MSGSP_PACKAGE_FAIL "A call to an external package failed."
+
+#define MSGSP_CAMEM_NULL "idaadj_mem = NULL illegal."
+#define MSGSP_LMEMB_NULL "Linear solver memory is NULL for the backward integration."
+#define MSGSP_BAD_T "Bad t for interpolation."
+#define MSGSP_BAD_WHICH "Illegal value for which."
+#define MSGSP_NO_ADJ "Illegal attempt to call before calling IDAAdjInit."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/idas/idas_spbcgs.c b/src/idas/idas_spbcgs.c
index a69f843..6bf329d 100644
--- a/src/idas/idas_spbcgs.c
+++ b/src/idas/idas_spbcgs.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2011/05/25 20:46:33 $
+ * $Revision: 4909 $
+ * $Date: 2016-09-14 16:51:27 -0700 (Wed, 14 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDAS scaled preconditioned
  * Bi-CGSTAB linear solver module, IDASPBCG.
@@ -49,7 +54,7 @@ static int IDASpbcgFree(IDAMem IDA_mem);
 
 /* IDASPBCG lfreeB function */
 
-static void IDASpbcgFreeB(IDABMem IDAB_mem);
+static int IDASpbcgFreeB(IDABMem IDAB_mem);
 
 /* 
  * ================================================================
@@ -140,7 +145,7 @@ int IDASpbcg(void *ida_mem, int maxl)
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   SpbcgMem spbcg_mem;
-  int flag, maxl1;
+  int maxl1;
 
   /* Return immediately if ida_mem is NULL */
   if (ida_mem == NULL) {
@@ -155,7 +160,7 @@ int IDASpbcg(void *ida_mem, int maxl)
     return(IDASPILS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem */
   linit  = IDASpbcgInit;
@@ -196,6 +201,8 @@ int IDASpbcg(void *ida_mem, int maxl)
 
   idaspils_mem->s_last_flag = IDASPILS_SUCCESS;
 
+  idaSpilsInitializeCounters(idaspils_mem);
+
   /* Set setupNonNull to FALSE */
   setupNonNull = FALSE;
 
@@ -227,7 +234,7 @@ int IDASpbcg(void *ida_mem, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SpbcgMalloc to allocate workspace for Spbcg */
   spbcg_mem = NULL;
@@ -273,8 +280,7 @@ static int IDASpbcgInit(IDAMem IDA_mem)
   spbcg_mem = (SpbcgMem) spils_mem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = 0;
-  njtimes = nres = 0;
+  idaSpilsInitializeCounters(idaspils_mem);
 
   /* Set setupNonNull to TRUE iff there is preconditioning with setup */
   setupNonNull = (psolve != NULL) && (pset != NULL);
@@ -513,7 +519,6 @@ int IDASpbcgB(void *ida_mem, int which, int maxlB)
   IDAadjMem IDAADJ_mem;
   IDABMem IDAB_mem;
   IDASpilsMemB idaspilsB_mem;
-  void *ida_memB;
   int flag;
   
   /* Check if ida_mem is allright. */
@@ -543,8 +548,6 @@ int IDASpbcgB(void *ida_mem, int which, int maxlB)
     /* advance */
     IDAB_mem = IDAB_mem->ida_next;
   }
-  /* ida_mem corresponding to 'which' problem. */
-  ida_memB = (void *) IDAB_mem->IDA_mem;
 
   
   /* Get memory for IDASpilsMemRecB */
@@ -580,11 +583,13 @@ int IDASpbcgB(void *ida_mem, int which, int maxlB)
  * IDASpbcgFreeB 
  */
 
-static void IDASpbcgFreeB(IDABMem IDAB_mem)
+static int IDASpbcgFreeB(IDABMem IDAB_mem)
 {
   IDASpilsMemB idaspilsB_mem;
 
   idaspilsB_mem = (IDASpilsMemB) IDAB_mem->ida_lmem;
 
   free(idaspilsB_mem);
+
+  return(0);
 }
diff --git a/src/idas/idas_spgmr.c b/src/idas/idas_spgmr.c
index 7242be4..60953be 100644
--- a/src/idas/idas_spgmr.c
+++ b/src/idas/idas_spgmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2011/05/25 20:46:33 $
+ * $Revision: 4909 $
+ * $Date: 2016-09-14 16:51:27 -0700 (Wed, 14 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh, and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDAS Scaled              
  * Preconditioned GMRES linear solver module, IDASPGMR.            
@@ -48,7 +53,7 @@ static int IDASpgmrPerf(IDAMem IDA_mem, int perftask);
 static int IDASpgmrFree(IDAMem IDA_mem);
 
 /* IDASPGMR lfreeB function */
-static void IDASpgmrFreeB(IDABMem IDAB_mem);
+static int IDASpgmrFreeB(IDABMem IDAB_mem);
 
 /* 
  * ================================================================
@@ -139,7 +144,7 @@ int IDASpgmr(void *ida_mem, int maxl)
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   SpgmrMem spgmr_mem;
-  int flag, maxl1;
+  int maxl1;
 
   /* Return immediately if ida_mem is NULL */
   if (ida_mem == NULL) {
@@ -154,7 +159,7 @@ int IDASpgmr(void *ida_mem, int maxl)
     return(IDASPILS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem */
   linit  = IDASpgmrInit;
@@ -197,6 +202,8 @@ int IDASpgmr(void *ida_mem, int maxl)
 
   idaspils_mem->s_last_flag  = IDASPILS_SUCCESS;
 
+  idaSpilsInitializeCounters(idaspils_mem);
+
   /* Set setupNonNull to FALSE */
   setupNonNull = FALSE;
 
@@ -228,7 +235,7 @@ int IDASpgmr(void *ida_mem, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt( N_VDotProd(ytemp, ytemp) );
+  sqrtN = SUNRsqrt( N_VDotProd(ytemp, ytemp) );
 
   /* Call SpgmrMalloc to allocate workspace for Spgmr */
   spgmr_mem = NULL;
@@ -274,8 +281,7 @@ static int IDASpgmrInit(IDAMem IDA_mem)
   idaspils_mem = (IDASpilsMem) lmem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = 0;
-  njtimes = nres = 0;
+  idaSpilsInitializeCounters(idaspils_mem);
 
   /* Set setupNonNull to TRUE iff there is preconditioning with setup */
   setupNonNull = (psolve != NULL) && (pset != NULL);
@@ -505,7 +511,6 @@ int IDASpgmrB(void *ida_mem, int which, int maxlB)
   IDAadjMem IDAADJ_mem;
   IDABMem IDAB_mem;
   IDASpilsMemB idaspilsB_mem;
-  void *ida_memB;
   int flag;
   
   /* Check if ida_mem is allright. */
@@ -535,8 +540,6 @@ int IDASpgmrB(void *ida_mem, int which, int maxlB)
     /* advance */
     IDAB_mem = IDAB_mem->ida_next;
   }
-  /* ida_mem corresponding to 'which' problem. */
-  ida_memB = (void *) IDAB_mem->IDA_mem;
 
   
   /* Get memory for IDASpilsMemRecB */
@@ -572,11 +575,13 @@ int IDASpgmrB(void *ida_mem, int which, int maxlB)
  * IDASpgmrFreeB 
  */
 
-static void IDASpgmrFreeB(IDABMem IDAB_mem)
+static int IDASpgmrFreeB(IDABMem IDAB_mem)
 {
   IDASpilsMemB idaspilsB_mem;
 
   idaspilsB_mem = (IDASpilsMemB) IDAB_mem->ida_lmem;
 
   free(idaspilsB_mem);
+
+  return(0);
 }
diff --git a/src/idas/idas_spils.c b/src/idas/idas_spils.c
index 74f7d3f..7de6bf8 100644
--- a/src/idas/idas_spils.c
+++ b/src/idas/idas_spils.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:39:19 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California  
- * Produced at the Lawrence Livermore National Laboratory
- * All rights reserved
- * For details, see the LICENSE file
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common implementation file for the IDAS Scaled              
  * Preconditioned Linear Solver modules.
@@ -38,24 +43,39 @@
  * =================================================================
  */
 
-static int IDAAspilsPrecSetup(realtype tt, 
-                              N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                              realtype c_jB, void *idaadj_mem,
-                              N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
-
-static int IDAAspilsPrecSolve(realtype tt, 
-                              N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                              N_Vector rvecB, N_Vector zvecB,
-                              realtype c_jB, realtype deltaB,
-                              void *idaadj_mem, N_Vector tmpB);
-
-static int IDAAspilsJacTimesVec(realtype tt,
-                                N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                                N_Vector vB, N_Vector JvB, 
-                                realtype c_jB, void *idaadj_mem, 
-                                N_Vector tmp1B, N_Vector tmp2B);
-
-
+static int IDAAspilsPrecSetupB(realtype tt, 
+                               N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                               realtype c_jB, void *idaadj_mem,
+                               N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+static int IDAAspilsPrecSetupBS(realtype tt, 
+                                N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                                realtype c_jB, void *idaadj_mem,
+                                N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
+
+static int IDAAspilsPrecSolveB(realtype tt, 
+                               N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                               N_Vector rvecB, N_Vector zvecB,
+                               realtype c_jB, realtype deltaB,
+                               void *idaadj_mem, N_Vector tmpB);
+
+static int IDAAspilsPrecSolveBS(realtype tt, 
+                                N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                                N_Vector rvecB, N_Vector zvecB,
+                                realtype c_jB, realtype deltaB,
+                                void *idaadj_mem, N_Vector tmpB);
+
+static int IDAAspilsJacTimesVecB(realtype tt,
+                                 N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                 N_Vector vB, N_Vector JvB, 
+                                 realtype c_jB, void *idaadj_mem, 
+                                 N_Vector tmp1B, N_Vector tmp2B);
+
+static int IDAAspilsJacTimesVecBS(realtype tt,
+                                  N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                  N_Vector vB, N_Vector JvB, 
+                                  realtype c_jB, void *idaadj_mem, 
+                                  N_Vector tmp1B, N_Vector tmp2B);
 
 /* 
  * ================================================================
@@ -621,7 +641,7 @@ int IDASpilsDQJtimes(realtype tt,
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   N_Vector y_tmp, yp_tmp;
-  realtype sig, siginv;
+  realtype sig=ZERO, siginv;
   int iter, retval;
 
   /* data is ida_mem */
@@ -670,6 +690,19 @@ int IDASpilsDQJtimes(realtype tt,
 }
 
 
+int idaSpilsInitializeCounters(IDASpilsMem idaspils_mem)
+{
+  idaspils_mem->s_npe     = 0;
+  idaspils_mem->s_nli     = 0;
+  idaspils_mem->s_nps     = 0;
+  idaspils_mem->s_ncfl    = 0;
+  idaspils_mem->s_njtimes = 0;
+  idaspils_mem->s_nres    = 0;
+
+  return(0);
+}
+
+
 /* 
  * ================================================================
  *
@@ -683,6 +716,9 @@ int IDASpilsDQJtimes(realtype tt,
 #define yyTmp        (IDAADJ_mem->ia_yyTmp)
 #define ypTmp        (IDAADJ_mem->ia_ypTmp)
 #define noInterp     (IDAADJ_mem->ia_noInterp)
+#define interpSensi  (IDAADJ_mem->ia_interpSensi)
+#define yySTmp      (IDAADJ_mem->ia_yySTmp)
+#define ypSTmp      (IDAADJ_mem->ia_ypSTmp)
 
 /*
  * -----------------------------------------------------------------
@@ -953,9 +989,77 @@ int IDASpilsSetPreconditionerB(void *ida_mem, int which,
   idaspilsB_mem->s_psetB   = psetB;
   idaspilsB_mem->s_psolveB = psolveB;
 
-  return IDASpilsSetPreconditioner(ida_memB, IDAAspilsPrecSetup, IDAAspilsPrecSolve);
+  if (psetB == NULL) {
+    return IDASpilsSetPreconditioner(ida_memB, NULL, IDAAspilsPrecSolveB);
+  } else {
+    return IDASpilsSetPreconditioner(ida_memB, IDAAspilsPrecSetupB, IDAAspilsPrecSolveB);
+  }
+}
+
+int IDASpilsSetPreconditionerBS(void *ida_mem, int which, 
+                                IDASpilsPrecSetupFnBS psetBS,
+                                IDASpilsPrecSolveFnBS psolveBS)
+{
+  IDAadjMem IDAADJ_mem;
+  IDAMem IDA_mem;
+  IDABMem IDAB_mem;
+  void *ida_memB;
+  IDASpilsMemB idaspilsB_mem;
+  
+  /* Check if ida_mem is allright. */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASPILS_MEM_NULL, "IDASSPILS", 
+                    "IDASpilsSetPreconditionerBS", MSGS_IDAMEM_NULL);
+    return(IDASPILS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASPILS_NO_ADJ, "IDASSPILS", 
+                    "IDASpilsSetPreconditionerBS",  MSGS_NO_ADJ);
+    return(IDASPILS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASPILS_ILL_INPUT, "IDASSPILS", 
+                    "IDASpilsSetPreconditionerBS", MSGS_BAD_WHICH);
+    return(IDASPILS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+  /* ida_mem corresponding to 'which' problem. */
+  ida_memB = (void *) IDAB_mem->IDA_mem;
+
+  if ( IDAB_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASPILS_LMEMB_NULL, "IDASSPILS", 
+                    "IDASpilsSetPreconditionerBS", MSGS_LMEMB_NULL);
+    return(IDASPILS_ILL_INPUT);
+  }
+
+  /* Get the IDASpilsMemB data. */
+  idaspilsB_mem = (IDASpilsMemB) IDAB_mem->ida_lmem;
+
+  /* Set preconditioners for the backward problem. */
+  idaspilsB_mem->s_psetBS   = psetBS;
+  idaspilsB_mem->s_psolveBS = psolveBS;
+
+  if (psetBS == NULL) {
+    return IDASpilsSetPreconditioner(ida_memB, NULL, IDAAspilsPrecSolveBS);
+  } else {
+    return IDASpilsSetPreconditioner(ida_memB, IDAAspilsPrecSetupBS, IDAAspilsPrecSolveBS);
+  }
 }
 
+
 int IDASpilsSetJacTimesVecFnB(void *ida_mem, int which, IDASpilsJacTimesVecFnB jtvB)
 {
   IDAadjMem IDAADJ_mem;
@@ -1011,24 +1115,87 @@ int IDASpilsSetJacTimesVecFnB(void *ida_mem, int which, IDASpilsJacTimesVecFnB j
   idaspilsB_mem->s_jtimesB   = jtvB;
 
   if (jtvB != NULL) {
-    flag = IDASpilsSetJacTimesVecFn(IDAB_mem, IDAAspilsJacTimesVec);
+    flag = IDASpilsSetJacTimesVecFn(ida_memB, IDAAspilsJacTimesVecB);
+  } else {
+    flag = IDASpilsSetJacTimesVecFn(ida_memB, NULL);
+  }
+  return(flag);
+}
+
+int IDASpilsSetJacTimesVecFnBS(void *ida_mem, int which, IDASpilsJacTimesVecFnBS jtvBS)
+{
+  IDAadjMem IDAADJ_mem;
+  IDAMem IDA_mem;
+  IDABMem IDAB_mem;
+  IDASpilsMemB idaspilsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Check if ida_mem is allright. */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASPILS_MEM_NULL, "IDASSPILS", 
+                    "IDASpilsSetJacTimesVecFnBS", MSGS_IDAMEM_NULL);
+    return(IDASPILS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASPILS_NO_ADJ, "IDASSPILS", 
+                    "IDASpilsSetJacTimesVecFnBS",  MSGS_NO_ADJ);
+    return(IDASPILS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASPILS_ILL_INPUT, "IDASSPILS", 
+                    "IDASpilsSetJacTimesVecFnBS", MSGS_BAD_WHICH);
+    return(IDASPILS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+  /* ida_mem corresponding to 'which' problem. */
+  ida_memB = (void *) IDAB_mem->IDA_mem;
+
+  if ( IDAB_mem->ida_lmem == NULL) {
+    IDAProcessError(IDA_mem, IDASPILS_LMEMB_NULL, "IDASSPILS", 
+                    "IDASpilsSetJacTimesVecFnBS", MSGS_LMEMB_NULL);
+    return(IDASPILS_ILL_INPUT);
+  }
+
+  idaspilsB_mem = (IDASpilsMemB) IDAB_mem->ida_lmem;
+
+  /* Call the corresponding Set* function for the backward problem. */
+
+  idaspilsB_mem->s_jtimesBS = jtvBS;
+
+  if (jtvBS != NULL) {
+    flag = IDASpilsSetJacTimesVecFn(ida_memB, IDAAspilsJacTimesVecBS);
   } else {
-    flag = IDASpilsSetJacTimesVecFn(IDAB_mem, NULL);
+    flag = IDASpilsSetJacTimesVecFn(ida_memB, NULL);
   }
   return(flag);
 }
 
+
 /*
  * -----------------------------------------------------------------
  * IDASSPILS private functions
  *
- * Those routines are interfaces the routines provided by user for
- * backward problems.
+ * These routines are interfaces to the routines provided by the
+ * user for backward problems.
  *
  * -----------------------------------------------------------------
  */
 
-static int IDAAspilsPrecSetup(realtype tt, 
+static int IDAAspilsPrecSetupB(realtype tt, 
                               N_Vector yyB, N_Vector ypB, N_Vector rrB, 
                               realtype c_jB, void *ida_mem,
                               N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
@@ -1044,27 +1211,64 @@ static int IDAAspilsPrecSetup(realtype tt,
   IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
   idaspilsB_mem = (IDASpilsMemB)IDAB_mem->ida_lmem;
   
-  /* Get FORWARD solution from interpolation. */
+  /* Get forward solution from interpolation. */
   if (noInterp==FALSE) {
     flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
     if (flag != IDA_SUCCESS) {
-      IDAProcessError(IDA_mem, -1, "IDASSPILS", "IDAAspilsPrecSetup", MSGS_BAD_T);
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSPILS", "IDAAspilsPrecSetupB", MSGS_BAD_T);
       return(-1);
     }
   }
 
   /* Call user's adjoint precondB routine */
   flag = idaspilsB_mem->s_psetB(tt, yyTmp, ypTmp, yyB, ypB, rrB, 
-                               c_jB, IDAB_mem->ida_user_data,
-                               tmp1B, tmp2B, tmp3B);
+                                c_jB, IDAB_mem->ida_user_data,
+                                tmp1B, tmp2B, tmp3B);
   return(flag);
 }
 
-static int IDAAspilsPrecSolve(realtype tt, 
-                              N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                              N_Vector rvecB, N_Vector zvecB,
-                              realtype c_jB, realtype deltaB,
-                              void *ida_mem, N_Vector tmpB)
+static int IDAAspilsPrecSetupBS(realtype tt, 
+                               N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                               realtype c_jB, void *ida_mem,
+                               N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDASpilsMemB idaspilsB_mem;
+  IDABMem IDAB_mem;
+  int flag;
+
+  IDA_mem = (IDAMem) ida_mem;
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+  IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
+  idaspilsB_mem = (IDASpilsMemB)IDAB_mem->ida_lmem;
+  
+  /* Get forward solution from interpolation. */
+  if( noInterp == FALSE) {
+    if (interpSensi)
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, yySTmp, ypSTmp);
+    else
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
+    if (flag != IDA_SUCCESS) {
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSPILS", "IDAAspilsPrecSetupBS", MSGS_BAD_T);
+      return(-1);
+    }
+  }
+
+  /* Call user's adjoint precondBS routine */
+  flag = idaspilsB_mem->s_psetBS(tt, yyTmp, ypTmp, yySTmp, ypSTmp,
+                                 yyB, ypB, rrB,
+                                 c_jB, IDAB_mem->ida_user_data,
+                                 tmp1B, tmp2B, tmp3B);
+  return(flag);
+}
+
+
+static int IDAAspilsPrecSolveB(realtype tt, 
+                               N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                               N_Vector rvecB, N_Vector zvecB,
+                               realtype c_jB, realtype deltaB,
+                               void *ida_mem, N_Vector tmpB)
 {
   IDAMem IDA_mem;
   IDAadjMem IDAADJ_mem;
@@ -1077,11 +1281,11 @@ static int IDAAspilsPrecSolve(realtype tt,
   IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
   idaspilsB_mem = (IDASpilsMemB)IDAB_mem->ida_lmem;
   
-  /* Get FORWARD solution from interpolation. */
+  /* Get forward solution from interpolation. */
   if (noInterp==FALSE) {
     flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
     if (flag != IDA_SUCCESS) {
-      IDAProcessError(IDA_mem, -1, "IDASSPILS", "IDAAspilsPrecSolve", MSGS_BAD_T);
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSPILS", "IDAAspilsPrecSolveB", MSGS_BAD_T);
       return(-1);
     }
   }
@@ -1094,11 +1298,50 @@ static int IDAAspilsPrecSolve(realtype tt,
   return(flag);
 }
 
-static int IDAAspilsJacTimesVec(realtype tt,
-                                N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                                N_Vector vB, N_Vector JvB, 
-                                realtype c_jB, void *ida_mem, 
-                                N_Vector tmp1B, N_Vector tmp2B)
+static int IDAAspilsPrecSolveBS(realtype tt, 
+                                N_Vector yyB, N_Vector ypB, N_Vector rrB, 
+                                N_Vector rvecB, N_Vector zvecB,
+                                realtype c_jB, realtype deltaB,
+                                void *ida_mem, N_Vector tmpB)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDASpilsMemB idaspilsB_mem;
+  IDABMem IDAB_mem;
+  int flag;
+
+  IDA_mem = (IDAMem) ida_mem;
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+  IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
+  idaspilsB_mem = (IDASpilsMemB)IDAB_mem->ida_lmem;
+  
+  /* Get forward solution from interpolation. */
+  if( noInterp == FALSE) {
+    if (interpSensi)
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, yySTmp, ypSTmp);
+    else
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
+    if (flag != IDA_SUCCESS) {
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSPILS", "IDAAspilsPrecSolveBS", MSGS_BAD_T);
+      return(-1);
+    }
+  }
+
+  /* Call user's adjoint psolveBS routine */
+  flag = idaspilsB_mem->s_psolveBS(tt, yyTmp, ypTmp, yySTmp, ypSTmp,
+                                   yyB, ypB, rrB,
+                                   rvecB, zvecB,
+                                   c_jB, deltaB,
+                                   IDAB_mem->ida_user_data, tmpB);
+  return(flag);
+}
+
+
+static int IDAAspilsJacTimesVecB(realtype tt,
+                                 N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                 N_Vector vB, N_Vector JvB, 
+                                 realtype c_jB, void *ida_mem, 
+                                 N_Vector tmp1B, N_Vector tmp2B)
 {
   IDAMem IDA_mem;
   IDAadjMem IDAADJ_mem;
@@ -1111,15 +1354,15 @@ static int IDAAspilsJacTimesVec(realtype tt,
   IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
   idaspilsB_mem = (IDASpilsMemB)IDAB_mem->ida_lmem;
   
-  /* Get FORWARD solution from interpolation. */
+  /* Get forward solution from interpolation. */
   if (noInterp==FALSE) {
     flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
     if (flag != IDA_SUCCESS) {
-      IDAProcessError(IDA_mem, -1, "IDASSPILS", "IDAAspilsJacTimesVec", MSGS_BAD_T);
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSPILS", "IDAAspilsJacTimesVecB", MSGS_BAD_T);
       return(-1);
     }
   }
-  /* Call user's adjoint psolveB routine */
+  /* Call user's adjoint jtimesB routine */
   flag = idaspilsB_mem->s_jtimesB(tt, yyTmp, ypTmp, 
                                   yyB, ypB, rrB, 
                                   vB, JvB, 
@@ -1127,3 +1370,41 @@ static int IDAAspilsJacTimesVec(realtype tt,
                                   tmp1B, tmp2B);
   return(flag);
 }
+
+static int IDAAspilsJacTimesVecBS(realtype tt,
+                                  N_Vector yyB, N_Vector ypB, N_Vector rrB,
+                                  N_Vector vB, N_Vector JvB, 
+                                  realtype c_jB, void *ida_mem, 
+                                  N_Vector tmp1B, N_Vector tmp2B)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDASpilsMemB idaspilsB_mem;
+  IDABMem IDAB_mem;
+  int flag;
+
+  IDA_mem = (IDAMem) ida_mem;
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+  IDAB_mem = IDAADJ_mem->ia_bckpbCrt;
+  idaspilsB_mem = (IDASpilsMemB)IDAB_mem->ida_lmem;
+  
+  /* Get forward solution from interpolation. */
+  if( noInterp == FALSE) {
+    if (interpSensi)
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, yySTmp, ypSTmp);
+    else
+      flag = IDAADJ_mem->ia_getY(IDA_mem, tt, yyTmp, ypTmp, NULL, NULL);
+    if (flag != IDA_SUCCESS) {
+      IDAProcessError(IDAB_mem->IDA_mem, -1, "IDASSPILS", "IDAAspilsJacTimesVecBS", MSGS_BAD_T);
+      return(-1);
+    }
+  }
+
+  /* Call user's adjoint jtimesBS routine */
+  flag = idaspilsB_mem->s_jtimesBS(tt, yyTmp, ypTmp, yySTmp, ypSTmp,
+                                   yyB, ypB, rrB,
+                                   vB, JvB,
+                                   c_jB, IDAB_mem->ida_user_data,
+                                   tmp1B, tmp2B);
+  return(flag);
+}
diff --git a/src/idas/idas_spils_impl.h b/src/idas/idas_spils_impl.h
index 0944d54..6cbaac6 100644
--- a/src/idas/idas_spils_impl.h
+++ b/src/idas/idas_spils_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.9 $
- * $Date: 2010/12/01 22:39:18 $
+ * $Revision: 4921 $
+ * $Date: 2016-09-19 14:35:11 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmers: Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the common header file (private version) for the Scaled
  * Preconditioned Iterative Linear Solver modules.
@@ -18,13 +23,13 @@
 #ifndef _IDASSPILS_IMPL_H
 #define _IDASSPILS_IMPL_H
 
+#include <idas/idas_spils.h>
+#include "idas_impl.h"
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <idas/idas_spils.h>
-#include "idas_impl.h"
-
 /* Types of iterative linear solvers */
 
 #define SPILS_SPGMR   1
@@ -90,7 +95,7 @@ typedef struct IDASpilsMemRec {
 
   IDASpilsPrecSetupFn s_pset;
   IDASpilsPrecSolveFn s_psolve;
-  void (*s_pfree)(IDAMem IDA_mem);
+  int (*s_pfree)(IDAMem IDA_mem);
   void *s_pdata;
   
   /* Jacobian times vector compuation
@@ -129,7 +134,9 @@ int IDASpilsDQJtimes(realtype tt,
                      realtype c_j, void *data, 
                      N_Vector work1, N_Vector work2);
 
+/* Auxilliary functions */
 
+int idaSpilsInitializeCounters(IDASpilsMem idaspils_mem);
 
 /*
  * -----------------------------------------------------------------
@@ -197,8 +204,11 @@ int IDASpilsDQJtimes(realtype tt,
 typedef struct IDASpilsMemRecB {
 
   IDASpilsJacTimesVecFnB s_jtimesB;
+  IDASpilsJacTimesVecFnBS s_jtimesBS;
   IDASpilsPrecSetupFnB s_psetB;
+  IDASpilsPrecSetupFnBS s_psetBS;
   IDASpilsPrecSolveFnB s_psolveB;
+  IDASpilsPrecSolveFnBS s_psolveBS;
   void *s_P_dataB;
 
 } *IDASpilsMemB;
diff --git a/src/idas/idas_sptfqmr.c b/src/idas/idas_sptfqmr.c
index a4f1186..3920213 100644
--- a/src/idas/idas_sptfqmr.c
+++ b/src/idas/idas_sptfqmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2007/11/26 16:20:01 $
+ * $Revision: 4909 $
+ * $Date: 2016-09-14 16:51:27 -0700 (Wed, 14 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the IDAS scaled preconditioned
  * TFQMR linear solver module, IDASPTFQMR.
@@ -37,18 +42,18 @@
 static int IDASptfqmrInit(IDAMem IDA_mem);
 
 static int IDASptfqmrSetup(IDAMem IDA_mem, 
-			   N_Vector yy_p, N_Vector yp_p, N_Vector rr_p, 
-			   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
+                           N_Vector yy_p, N_Vector yp_p, N_Vector rr_p, 
+                           N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
 
 static int IDASptfqmrSolve(IDAMem IDA_mem, N_Vector bb, N_Vector weight,
-			   N_Vector yy_now, N_Vector yp_now, N_Vector rr_now);
+                           N_Vector yy_now, N_Vector yp_now, N_Vector rr_now);
 
 static int IDASptfqmrPerf(IDAMem IDA_mem, int perftask);
 
 static int IDASptfqmrFree(IDAMem IDA_mem);
 
 /* IDASPTFQMR lfree function for backward problem. */
-static void IDASptfqmrFreeB(IDABMem IDAB_mem);
+static int IDASptfqmrFreeB(IDABMem IDAB_mem);
 
 /* 
  * ================================================================
@@ -139,7 +144,7 @@ int IDASptfqmr(void *ida_mem, int maxl)
   IDAMem IDA_mem;
   IDASpilsMem idaspils_mem;
   SptfqmrMem sptfqmr_mem;
-  int flag, maxl1;
+  int maxl1;
 
   /* Return immediately if ida_mem is NULL */
   if (ida_mem == NULL) {
@@ -154,7 +159,7 @@ int IDASptfqmr(void *ida_mem, int maxl)
     return(IDASPILS_ILL_INPUT);
   }
 
-  if (lfree != NULL) flag = lfree((IDAMem) ida_mem);
+  if (lfree != NULL) lfree((IDAMem) ida_mem);
 
   /* Set five main function fields in ida_mem */
   linit  = IDASptfqmrInit;
@@ -195,6 +200,8 @@ int IDASptfqmr(void *ida_mem, int maxl)
 
   idaspils_mem->s_last_flag = IDASPILS_SUCCESS;
 
+  idaSpilsInitializeCounters(idaspils_mem);
+
   /* Set setupNonNull to FALSE */
   setupNonNull = FALSE;
 
@@ -226,7 +233,7 @@ int IDASptfqmr(void *ida_mem, int maxl)
 
   /* Compute sqrtN from a dot product */
   N_VConst(ONE, ytemp);
-  sqrtN = RSqrt(N_VDotProd(ytemp, ytemp));
+  sqrtN = SUNRsqrt(N_VDotProd(ytemp, ytemp));
 
   /* Call SptfqmrMalloc to allocate workspace for Sptfqmr */
   sptfqmr_mem = NULL;
@@ -272,8 +279,7 @@ static int IDASptfqmrInit(IDAMem IDA_mem)
   sptfqmr_mem = (SptfqmrMem) spils_mem;
 
   /* Initialize counters */
-  npe = nli = nps = ncfl = 0;
-  njtimes = nres = 0;
+  idaSpilsInitializeCounters(idaspils_mem);
 
   /* Set setupNonNull to TRUE iff there is preconditioning with setup */
   setupNonNull = (psolve != NULL) && (pset != NULL);
@@ -506,7 +512,6 @@ int IDASptfqmrB(void *ida_mem, int which, int maxlB)
   IDAadjMem IDAADJ_mem;
   IDABMem IDAB_mem;
   IDASpilsMemB idaspilsB_mem;
-  void *ida_memB;
   int flag;
   
   /* Check if ida_mem is allright. */
@@ -536,8 +541,6 @@ int IDASptfqmrB(void *ida_mem, int which, int maxlB)
     /* advance */
     IDAB_mem = IDAB_mem->ida_next;
   }
-  /* ida_mem corresponding to 'which' problem. */
-  ida_memB = (void *) IDAB_mem->IDA_mem;
 
   
   /* Get memory for IDASpilsMemRecB */
@@ -573,11 +576,13 @@ int IDASptfqmrB(void *ida_mem, int which, int maxlB)
  * IDASptfqmrFreeB 
  */
 
-static void IDASptfqmrFreeB(IDABMem IDAB_mem)
+static int IDASptfqmrFreeB(IDABMem IDAB_mem)
 {
   IDASpilsMemB idaspilsB_mem;
 
   idaspilsB_mem = (IDASpilsMemB) IDAB_mem->ida_lmem;
 
   free(idaspilsB_mem);
+
+  return(0);
 }
diff --git a/src/idas/idas_superlumt.c b/src/idas/idas_superlumt.c
new file mode 100644
index 0000000..4bab266
--- /dev/null
+++ b/src/idas/idas_superlumt.c
@@ -0,0 +1,679 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4938 $
+ * $Date: 2016-09-21 14:33:08 -0700 (Wed, 21 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the IDASSUPERLUMT linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sundials/sundials_math.h"
+#include "sundials/sundials_superlumt_impl.h"
+
+#include "idas_impl.h"
+#include "idas_sparse_impl.h"
+#include "idas/idas_superlumt.h"
+
+/* Constants */
+
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* IDASSSUPERLUMT linit, lsetup, lsolve, and lfree routines */
+ 
+static int IDASuperLUMTInit(IDAMem IDA_mem);
+
+static int IDASuperLUMTSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+			     N_Vector rrp, N_Vector tmp1,
+			     N_Vector tmp2, N_Vector tmp3);
+
+static int IDASuperLUMTSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+			     N_Vector ycur, N_Vector ypcur, N_Vector rrcur);
+
+static int IDASuperLUMTFree(IDAMem IDA_mem);
+
+/* IDASUPERLUMT lfreeB function */
+
+static int IDASuperLUMTFreeB(IDABMem IDAB_mem);
+
+
+/* 
+ * ================================================================
+ *
+ *                   PART I - forward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * IDASuperLUMT
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the IDA / SuperLUMT linear solver module.  
+ * IDASuperLUMT first calls the existing lfree routine if this is not NULL.
+ * Then it sets the ida_linit, ida_lsetup, ida_lsolve, ida_lperf, and
+ * ida_lfree fields in (*IDA_mem) to be IDASuperLUMTInit, IDASuperLUMTSetup,
+ * IDASuperLUMTSolve, NULL, and IDASuperLUMTFree, respectively.
+ * It allocates memory for a structure of type IDAsluMemRec and sets
+ * the ida_lmem field in (*IDA_mem) to the address of this structure.
+ * It sets setupNonNull in (*IDA_mem) to TRUE, sets the d_jdata field
+ * in the IDAsluMemRec structure to be the input parameter jdata,
+ * and sets the d_jac field to be:
+ *   (1) the input parameter djac, if djac != NULL, or                
+ *   (2) throws an error, if djac == NULL.                             
+ * Finally, it allocates memory for SuperLUMT.
+ * The return value is IDASLS_SUCCESS = 0, IDASLS_LMEM_FAIL = -1,
+ * or IDASLS_ILL_INPUT = -2.
+ *
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, IDASuperLUMT will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int IDASuperLUMT(void *ida_mem, int num_threads, int n, int nnz)
+{
+  IDAMem IDA_mem;
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+  int *perm_c, *perm_r;
+  int nrhs, panel_size, relax;
+  double *bd;
+  SuperMatrix *B;
+
+  /* Return immediately if ida_mem is NULL. */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDASuperLUMT", 
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (IDA_mem->ida_tempv1->ops->nvgetarraypointer == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDASuperLUMT", 
+		    MSGSP_BAD_NVECTOR);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  if (IDA_mem->ida_lfree != NULL) IDA_mem->ida_lfree(IDA_mem);
+
+  /* Set five main function fields in IDA_mem. */
+  IDA_mem->ida_linit  = IDASuperLUMTInit;
+  IDA_mem->ida_lsetup = IDASuperLUMTSetup;
+  IDA_mem->ida_lsolve = IDASuperLUMTSolve;
+  IDA_mem->ida_lperf  = NULL;
+  IDA_mem->ida_lfree  = IDASuperLUMTFree;
+
+  /* Get memory for IDASlsMemRec. */
+  idasls_mem = NULL;
+  idasls_mem = (IDASlsMem) malloc(sizeof(struct IDASlsMemRec));
+  if (idasls_mem == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* Get memory for SLUMT_data. */
+  slumt_data = NULL;
+  slumt_data = (SLUMTData)malloc(sizeof(struct SLUMTDataRec));
+  if (slumt_data == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  IDA_mem->ida_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  idasls_mem->s_jaceval = NULL;
+  idasls_mem->s_jacdata = IDA_mem->ida_user_data;
+
+  /* Allocate memory for the sparse Jacobian */
+  idasls_mem->s_JacMat = NULL;
+  idasls_mem->s_JacMat = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (idasls_mem->s_JacMat == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+
+  /* Set up memory for the permutations */
+  perm_r = (int *)malloc(n*sizeof(int));
+  if (perm_r == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  }
+  perm_c = (int *)malloc(n*sizeof(int));
+  if (perm_c == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", "IDASuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    free(perm_r);
+    return(IDASLS_MEM_FAIL);
+  }
+  slumt_data->perm_r = perm_r;
+  slumt_data->perm_c = perm_c;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  /* Set default parameters for SuperLU */
+  slumt_data->num_threads = num_threads;
+  slumt_data->diag_pivot_thresh = 1.0;
+
+  /* Allocate structures for SuperLU */
+  slumt_data->Gstat = (Gstat_t *)malloc(sizeof(Gstat_t));
+  slumt_data->s_A = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_AC = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_L = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_U = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_A->Store  = NULL;
+  slumt_data->s_AC->Store = NULL;
+  slumt_data->s_L->Store  = NULL;
+  slumt_data->s_U->Store  = NULL;
+  slumt_data->superlumt_options = (superlumt_options_t *)malloc(sizeof(superlumt_options_t));
+
+  dCreate_CompCol_Matrix(slumt_data->s_A, idasls_mem->s_JacMat->M, idasls_mem->s_JacMat->N, 
+			 idasls_mem->s_JacMat->NNZ, idasls_mem->s_JacMat->data, 
+			 idasls_mem->s_JacMat->indexvals, idasls_mem->s_JacMat->indexptrs, 
+			 SLU_NC, SLU_D, SLU_GE);
+
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  StatAlloc(idasls_mem->s_JacMat->N, num_threads, panel_size, relax, slumt_data->Gstat);
+  
+  /* Create RHS matrix */
+  nrhs = 1;
+  bd = NULL;
+  B = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  B->Store = NULL;
+  dCreate_Dense_Matrix(B, n, nrhs, bd, n, 
+		       SLU_DN, SLU_D, SLU_GE);
+  slumt_data->s_B = B;
+
+  /* Set ordering to COLAMD as the idas default use.
+     Users can set a different value with IDASuperLUMTSetOrdering,
+     and the user-set value is loaded before any call to factorize the
+     matrix in IDASuperLUMTSetup.  */
+  slumt_data->s_ordering = 3;
+
+  /* Attach linear solver memory to the integrator memory */
+  idasls_mem->s_solver_data = (void *) slumt_data;
+  IDA_mem->ida_lmem = idasls_mem;
+
+  return(IDASLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * IDASuperLUMT interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the IDASuperLUMT
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int IDASuperLUMTInit(IDAMem IDA_mem)
+{
+  int num_threads, n;
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+
+  idasls_mem = (IDASlsMem)IDA_mem->ida_lmem;
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  idasls_mem->s_nje = 0;
+  idasls_mem->s_first_factorize = 1;
+
+  /* ------------------------------------------------------------
+     Allocate storage and initialize statistics variables. 
+     ------------------------------------------------------------*/
+  n = idasls_mem->s_JacMat->N;
+  num_threads = slumt_data->num_threads;
+
+  StatInit(n, num_threads, slumt_data->Gstat);
+
+  idasls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the IDASuperLUMT linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     IDASLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int IDASuperLUMTSetup(IDAMem IDA_mem, N_Vector yyp, N_Vector ypp,
+			     N_Vector rrp, N_Vector tmp1, N_Vector tmp2,
+			     N_Vector tmp3)
+{
+  int retval, info;
+  int nprocs, panel_size, relax, permc_spec, lwork;
+  int *perm_r, *perm_c;
+  realtype tn, cj;
+  double diag_pivot_thresh, drop_tol;
+  fact_t fact;
+  trans_t trans;
+  yes_no_t refact, usepr;
+  IDASlsMem idasls_mem;
+  IDASlsSparseJacFn jaceval;
+  SuperMatrix *A, *AC, *L, *U;
+  Gstat_t *Gstat;
+  superlumt_options_t *superlumt_options;
+  SLUMTData slumt_data;
+  SlsMat JacMat;
+  void *jacdata;
+  void *work;
+  
+  idasls_mem = (IDASlsMem) (IDA_mem->ida_lmem);
+  tn = IDA_mem->ida_tn; 
+  cj = IDA_mem->ida_cj;
+
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+  jaceval = idasls_mem->s_jaceval;
+  jacdata = idasls_mem->s_jacdata;
+  JacMat = idasls_mem->s_JacMat;
+
+  superlumt_options = slumt_data->superlumt_options;
+  A = slumt_data->s_A;
+  AC = slumt_data->s_AC;
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  Gstat = slumt_data->Gstat;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  nprocs = slumt_data->num_threads;
+  diag_pivot_thresh = slumt_data->diag_pivot_thresh;
+
+  /* Set option values for SuperLU_MT */
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  fact = EQUILIBRATE;
+  trans = NOTRANS;
+  usepr = NO;
+  drop_tol = 0.0;
+  lwork = 0;
+  work = NULL;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    IDAProcessError(IDA_mem, IDASLS_JAC_NOSET, "IDASSLS", "IDASuperLUMTSetup", 
+		    MSGSP_JAC_NOSET);
+    free(idasls_mem); idasls_mem = NULL;
+    return(IDASLS_JAC_NOSET);
+  }
+
+  /* Increment nje counter and call Jacobian eval routine. */
+  idasls_mem->s_nje++;
+  retval = jaceval(tn, cj, yyp, ypp, rrp, JacMat, jacdata, 
+		   tmp1, tmp2, tmp3);
+
+  if (retval < 0) {
+    IDAProcessError(IDA_mem, IDASLS_JACFUNC_UNRECVR, "IDASSLS", 
+		    "IDASuperLUMTSetup", MSGSP_JACFUNC_FAILED);
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_UNRECVR;
+    return(IDASLS_JACFUNC_UNRECVR);
+  }
+  if (retval > 0) {
+    idasls_mem->s_last_flag = IDASLS_JACFUNC_RECVR;
+    return(+1);
+  }
+
+  if (idasls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get column permutation vector perm_c[], according to permc_spec:
+       permc_spec = 3: approximate minimum degree for unsymmetric matrices
+       ------------------------------------------------------------*/ 
+    permc_spec = 3;
+    get_perm_c(permc_spec, A, perm_c);
+ 
+    refact= NO;
+    idasls_mem->s_first_factorize = 0;
+  }
+  else {
+    /* ------------------------------------------------------------
+       Re-initialize statistics variables 
+       ------------------------------------------------------------*/
+    StatInit(JacMat->N, nprocs, Gstat);
+    Destroy_CompCol_Permuted(AC);
+    refact= YES;
+  }
+
+  /* ------------------------------------------------------------
+     Initialize the option structure superlumt_options using the
+     user-input parameters;  Subsequent calls will re-initialize
+     options.
+     Apply perm_c to the columns of original A to form AC.
+     ------------------------------------------------------------*/
+  pdgstrf_init(nprocs, fact, trans, refact, panel_size, relax,
+	       diag_pivot_thresh, usepr, drop_tol, perm_c, perm_r,
+	       work, lwork, A, AC, superlumt_options, Gstat);
+  /* ------------------------------------------------------------
+     Compute the LU factorization of A.
+     The following routine will create nprocs threads.
+     ------------------------------------------------------------*/
+  pdgstrf(superlumt_options, AC, perm_r, L, U, Gstat, &info);
+    
+  if (info != 0) {
+    idasls_mem->s_last_flag = info;
+    return(+1);
+  }
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the IDASuperLUMT linear
+  solver module.  It calls the SuperLUMT solve routine, scales the
+  solution vector according to cjratio, then returns IDASLU_SUCCESS = 0.
+*/
+
+static int IDASuperLUMTSolve(IDAMem IDA_mem, N_Vector b, N_Vector weight,
+			     N_Vector ycur, N_Vector ypcur, N_Vector rrcur)
+{
+  int info, trans;
+  int *perm_r, *perm_c;
+  double cjratio;
+  IDASlsMem idasls_mem;
+  SuperMatrix *L, *U, *B;
+  Gstat_t *Gstat;
+  DNformat *Bstore;
+  SLUMTData slumt_data;
+  realtype *bd;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+  cjratio = IDA_mem->ida_cjratio;
+
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  Gstat = slumt_data->Gstat;
+  B = slumt_data->s_B;
+   
+  bd = N_VGetArrayPointer(b);
+  Bstore = (DNformat *) (B->Store);
+  Bstore->nzval = bd;
+
+  /* Call SuperLUMT to solve the linear system using L and U */
+  trans = NOTRANS;
+  dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, &info);
+
+  /* Scale the correction to account for change in cj. */
+  if (cjratio != ONE) N_VScale(TWO/(ONE + cjratio), b, b);
+
+  Bstore->nzval = NULL;
+
+  idasls_mem->s_last_flag = IDASLS_SUCCESS;
+  return(IDASLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the IDASuperLUMT linear solver.
+*/
+
+static int IDASuperLUMTFree(IDAMem IDA_mem)
+{
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+  
+  idasls_mem = (IDASlsMem) IDA_mem->ida_lmem;
+
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  pxgstrf_finalize(slumt_data->superlumt_options, slumt_data->s_AC);
+
+  free(slumt_data->perm_r);
+  free(slumt_data->perm_c);
+  free(slumt_data->superlumt_options);
+  Destroy_SuperNode_SCP( (slumt_data->s_L) );
+  Destroy_CompCol_NCP( (slumt_data->s_U) );
+  StatFree( (slumt_data->Gstat) );
+  free(slumt_data->Gstat);
+  
+  Destroy_SuperMatrix_Store(slumt_data->s_B);
+  SUPERLU_FREE(slumt_data->s_A->Store);
+  if (idasls_mem->s_JacMat) {
+    SparseDestroyMat(idasls_mem->s_JacMat);
+    idasls_mem->s_JacMat = NULL;
+  }
+
+  free(slumt_data->s_B);
+  free(slumt_data->s_A);
+  free(slumt_data->s_AC);
+  free(slumt_data->s_L);
+  free(slumt_data->s_U);
+
+  free(slumt_data); 
+  slumt_data = NULL;
+ 
+  free(IDA_mem->ida_lmem); 
+  IDA_mem->ida_lmem = NULL;
+
+  return(IDASLS_SUCCESS);
+}
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * IDASuperLUMTSetOrdering sets the ordering used by SuperLUMT for reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int IDASuperLUMTSetOrdering(void *ida_mem_v, int ordering_choice)
+{
+  IDAMem ida_mem;
+  IDASlsMem idasls_mem;
+  SLUMTData slumt_data;
+
+ /* Return immediately if ida_mem is NULL */
+  if (ida_mem_v == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASLS", "IDASuperLUMTSetOrdering",
+		    MSGSP_IDAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  ida_mem = (IDAMem) ida_mem_v;
+  idasls_mem = (IDASlsMem) ida_mem->ida_lmem;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) && (ordering_choice != 3) ) {
+    IDAProcessError(NULL, IDASLS_ILL_INPUT, "IDASLS", "IDASuperLUMTSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  slumt_data = (SLUMTData) idasls_mem->s_solver_data;
+
+  slumt_data->s_ordering = ordering_choice;
+
+  return(IDASLS_SUCCESS);
+}
+
+
+
+/* 
+ * ================================================================
+ *
+ *                   PART II - backward problems
+ *
+ * ================================================================
+ */
+
+/*
+ * IDASuperLUMTB is a wrapper around IDASuperLUMT.
+ */
+
+int IDASuperLUMTB(void *ida_mem, int which, int num_threads, int n, int nnz)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  IDASlsMemB idaslsB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDASuperLUMTB", 
+		    MSGSP_CAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASLS_NO_ADJ, "IDASSLS", "IDASuperLUMTB",  
+		    MSGSP_NO_ADJ);
+    return(IDASLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDASuperLUMTB", 
+		    MSGSP_BAD_WHICH);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  /* Alloc memory for IDASlsMemRecB */
+  idaslsB_mem = (IDASlsMemB) malloc(sizeof(struct IDASlsMemRecB));
+  if (idaslsB_mem == NULL) {
+    IDAProcessError(IDAB_mem->IDA_mem, IDASLS_MEM_FAIL, "IDASSLS", 
+		    "IDASuperLUMTB", MSGSP_MEM_FAIL);
+    return(IDASLS_MEM_FAIL);
+  
+  }
+
+  /* set matrix type and initialize Jacob function. */
+  idaslsB_mem->s_djacB = NULL;
+
+  /* Attach lmemB data and lfreeB function. */
+  IDAB_mem->ida_lmem  = idaslsB_mem;
+  IDAB_mem->ida_lfree = IDASuperLUMTFreeB;
+
+  /* Call IDASuperLUMT to the IDAS data of the backward problem. */
+  ida_memB = (void *)IDAB_mem->IDA_mem;
+  flag = IDASuperLUMT(ida_memB, num_threads, n, nnz);
+
+  if (flag != IDASLS_SUCCESS) {
+    free(idaslsB_mem);
+    idaslsB_mem = NULL;
+  }
+
+  return(flag);
+}
+
+
+/*
+ * IDASuperLUMTSetOrderingB is a wrapper around IDASuperLUMTSetOrdering.
+ */
+int IDASuperLUMTSetOrderingB(void *ida_mem, int which, int ordering_choiceB)
+{
+  IDAMem IDA_mem;
+  IDAadjMem IDAADJ_mem;
+  IDABMem IDAB_mem;
+  void *ida_memB;
+  int flag;
+  
+  /* Is ida_mem allright? */
+  if (ida_mem == NULL) {
+    IDAProcessError(NULL, IDASLS_MEM_NULL, "IDASSLS", "IDASuperLUMTB", 
+		    MSGSP_CAMEM_NULL);
+    return(IDASLS_MEM_NULL);
+  }
+  IDA_mem = (IDAMem) ida_mem;
+
+  /* Is ASA initialized? */
+  if (IDA_mem->ida_adjMallocDone == FALSE) {
+    IDAProcessError(IDA_mem, IDASLS_NO_ADJ, "IDASSLS", "IDASuperLUMTB",  
+		    MSGSP_NO_ADJ);
+    return(IDASLS_NO_ADJ);
+  }
+  IDAADJ_mem = IDA_mem->ida_adj_mem;
+
+  /* Check the value of which */
+  if ( which >= IDAADJ_mem->ia_nbckpbs ) {
+    IDAProcessError(IDA_mem, IDASLS_ILL_INPUT, "IDASSLS", "IDASuperLUMTB", 
+		    MSGSP_BAD_WHICH);
+    return(IDASLS_ILL_INPUT);
+  }
+
+  /* Find the IDABMem entry in the linked list corresponding to 'which'. */
+  IDAB_mem = IDAADJ_mem->IDAB_mem;
+  while (IDAB_mem != NULL) {
+    if( which == IDAB_mem->ida_index ) break;
+    /* advance */
+    IDAB_mem = IDAB_mem->ida_next;
+  }
+
+  ida_memB = (void *)(IDAB_mem->IDA_mem);
+  
+  flag = IDASuperLUMTSetOrdering(ida_memB, ordering_choiceB);
+
+  return(flag);
+}
+
+
+
+
+/*
+ * IDASuperLUMTFreeB frees the linear solver's memory for that backward problem passed 
+ * as argument. 
+ */
+
+static int IDASuperLUMTFreeB(IDABMem IDAB_mem)
+{
+  IDASlsMemB idaslsB_mem;
+
+  idaslsB_mem = (IDASlsMemB) IDAB_mem->ida_lmem;
+
+  free(idaslsB_mem);
+
+  return(0);
+}
+
diff --git a/src/kinsol/CMakeLists.txt b/src/kinsol/CMakeLists.txt
index 5a209fe..d22ed62 100644
--- a/src/kinsol/CMakeLists.txt
+++ b/src/kinsol/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:58:48 $
+# $Revision: 4917 $
+# $Date: 2016-09-18 23:24:29 -0700 (Sun, 18 Sep 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the KINSOL library
 
@@ -20,13 +25,23 @@ SET(kinsol_SOURCES
   kinsol_direct.c
   kinsol_band.c
   kinsol_dense.c
+  kinsol_sparse.c
   kinsol_spils.c
   kinsol_spbcgs.c
+  kinsol_spfgmr.c
   kinsol_spgmr.c
   kinsol_sptfqmr.c
   kinsol_bbdpre.c
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND kinsol_SOURCES kinsol_klu.c)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND kinsol_SOURCES kinsol_superlumt.c)
+ENDIF()
+
 # Add variable shared_SOURCES with the common SUNDIALS sources which will
 # also be included in the KINSOL library
 SET(shared_SOURCES
@@ -36,7 +51,9 @@ SET(shared_SOURCES
   sundials_band.c
   sundials_dense.c
   sundials_iterative.c
+  sundials_sparse.c
   sundials_spbcgs.c
+  sundials_spfgmr.c
   sundials_spgmr.c
   sundials_sptfqmr.c
   )
@@ -52,11 +69,20 @@ SET(kinsol_HEADERS
   kinsol_direct.h
   kinsol.h
   kinsol_spbcgs.h
+  kinsol_spfgmr.h
   kinsol_spgmr.h
   kinsol_spils.h
   kinsol_sptfqmr.h
   )
 
+IF(KLU_FOUND)
+    LIST(APPEND kinsol_HEADERS kinsol_klu.h kinsol_sparse.h)
+ENDIF()
+
+IF(SUPERLUMT_FOUND)
+    LIST(APPEND kinsol_HEADERS kinsol_superlumt.h kinsol_sparse.h)
+ENDIF()
+
 # Add prefix with complete path to the KINSOL header files
 ADD_PREFIX(${sundials_SOURCE_DIR}/include/kinsol/ kinsol_HEADERS)
 
@@ -70,6 +96,24 @@ ELSE(LAPACK_FOUND)
   SET(kinsol_BL_HEADERS "")
 ENDIF(LAPACK_FOUND)
 
+IF(SUPERLUMT_FOUND)
+  SET(kinsol_SLU_SOURCES kinsol_superlumt.c)
+  SET(kinsol_SLU_HEADERS kinsol_superlumt.h)
+  ADD_PREFIX(${sundials_SOURCE_DIR}/include/kinsol/ kinsol_SLU_HEADERS)
+ELSE(SUPERLUMT_FOUND)
+  SET(kinsol_SLU_SOURCES "")
+  SET(kinsol_SLU_HEADERS "")
+ENDIF(SUPERLUMT_FOUND)
+
+IF(KLU_FOUND)
+  SET(kinsol_KLU_SOURCES kinsol_klu.c)
+  SET(kinsol_KLU_HEADERS kinsol_klu.h)
+  ADD_PREFIX(${sundials_SOURCE_DIR}/include/kinsol/ kinsol_KLU_HEADERS)
+ELSE(KLU_FOUND)
+  SET(kinsol_KLU_SOURCES "")
+  SET(kinsol_KLU_HEADERS "")
+ENDIF(KLU_FOUND)
+
 # Add source directories to include directories for access to
 # implementation only header files.
 INCLUDE_DIRECTORIES(.)
@@ -83,7 +127,7 @@ IF(BUILD_STATIC_LIBS)
 
   # Add the build target for the static KINSOL library
   ADD_LIBRARY(sundials_kinsol_static STATIC
-    ${kinsol_SOURCES} ${kinsol_BL_SOURCES} ${shared_SOURCES})
+    ${kinsol_SOURCES} ${kinsol_BL_SOURCES} ${kinsol_SLU_SOURCES} ${kinsol_KLU_SOURCES} ${shared_SOURCES})
 
   # Set the library name and make sure it is not deleted
   SET_TARGET_PROPERTIES(sundials_kinsol_static
@@ -99,7 +143,7 @@ IF(BUILD_SHARED_LIBS)
 
   # Add the build target for the KINSOL library
   ADD_LIBRARY(sundials_kinsol_shared SHARED
-    ${kinsol_SOURCES} ${kinsol_BL_SOURCES} ${shared_SOURCES})
+    ${kinsol_SOURCES} ${kinsol_BL_SOURCES} ${kinsol_SLU_SOURCES} ${kinsol_KLU_SOURCES} ${shared_SOURCES})
 
   # Set the library name and make sure it is not deleted
   SET_TARGET_PROPERTIES(sundials_kinsol_shared
@@ -115,7 +159,7 @@ IF(BUILD_SHARED_LIBS)
 ENDIF(BUILD_SHARED_LIBS)
 
 # Install the KINSOL header files
-INSTALL(FILES ${kinsol_HEADERS} ${kinsol_BL_HEADERS} DESTINATION include/kinsol)
+INSTALL(FILES ${kinsol_HEADERS} ${kinsol_BL_HEADERS} ${kinsol_SLU_HEADERS} ${kinsol_KLU_HEADERS} DESTINATION include/kinsol)
 
 # Install the KINSOL implementation header file
 INSTALL(FILES kinsol_impl.h DESTINATION include/kinsol)
diff --git a/src/kinsol/LICENSE b/src/kinsol/LICENSE
index b42049f..f2e95bc 100644
--- a/src/kinsol/LICENSE
+++ b/src/kinsol/LICENSE
@@ -1,7 +1,7 @@
-Copyright (c) 2002, The Regents of the University of California. 
+Copyright (c) 2002-2015, Lawrence Livermore National Security. 
 Produced at the Lawrence Livermore National Laboratory. 
 Written by Alan Hindmarsh, Allan Taylor, Radu Serban.
-UCRL-CODE-155953
+LLNL-CODE-665877
 All rights reserved. 
 
 This file is part of KINSOL.
diff --git a/src/kinsol/Makefile.in b/src/kinsol/Makefile.in
deleted file mode 100644
index 6bd0992..0000000
--- a/src/kinsol/Makefile.in
+++ /dev/null
@@ -1,167 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for KINSOL module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-LIB_REVISION = 1:0:0
-
-KINSOL_LIB = libsundials_kinsol.la
-
-KINSOL_SRC_FILES = kinsol.c kinsol_io.c kinsol_direct.c kinsol_dense.c kinsol_band.c kinsol_spils.c kinsol_spgmr.c kinsol_spbcgs.c kinsol_sptfqmr.c kinsol_bbdpre.c
-KINSOL_BL_SRC_FILES = kinsol_lapack.c
-
-KINSOL_OBJ_FILES = $(KINSOL_SRC_FILES:.c=.o)
-KINSOL_BL_OBJ_FILES = $(KINSOL_BL_SRC_FILES:.c=.o)
-
-KINSOL_LIB_FILES = $(KINSOL_SRC_FILES:.c=.lo)
-KINSOL_BL_LIB_FILES = $(KINSOL_BL_SRC_FILES:.c=.lo)
-
-SHARED_LIB_FILES = $(top_builddir)/src/sundials/sundials_band.lo \
-                   $(top_builddir)/src/sundials/sundials_dense.lo \
-                   $(top_builddir)/src/sundials/sundials_direct.lo \
-                   $(top_builddir)/src/sundials/sundials_iterative.lo \
-                   $(top_builddir)/src/sundials/sundials_spgmr.lo \
-                   $(top_builddir)/src/sundials/sundials_spbcgs.lo \
-                   $(top_builddir)/src/sundials/sundials_sptfqmr.lo \
-                   $(top_builddir)/src/sundials/sundials_math.lo \
-                   $(top_builddir)/src/sundials/sundials_nvector.lo
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(KINSOL_LIB)
-
-$(KINSOL_LIB): shared $(KINSOL_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: shared $(KINSOL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(KINSOL_LIB) $(KINSOL_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-lib_with_bl: shared $(KINSOL_LIB_FILES) $(KINSOL_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(KINSOL_LIB) $(KINSOL_LIB_FILES) $(KINSOL_BL_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-install: $(KINSOL_LIB)
-	$(mkinstalldirs) $(includedir)/kinsol
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(KINSOL_LIB) $(libdir)
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol.h         $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_direct.h  $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_dense.h   $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_band.h    $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_spgmr.h   $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_spbcgs.h  $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_sptfqmr.h $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_bbdpre.h  $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_spils.h   $(includedir)/kinsol/
-	$(INSTALL_HEADER) $(top_srcdir)/src/kinsol/kinsol_impl.h        $(includedir)/kinsol/
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  $(INSTALL_HEADER) $(top_srcdir)/include/kinsol/kinsol_lapack.h  $(includedir)/kinsol/ ; \
-	fi
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(KINSOL_LIB)
-	rm -f $(includedir)/kinsol/kinsol.h
-	rm -f $(includedir)/kinsol/kinsol_direct.h
-	rm -f $(includedir)/kinsol/kinsol_dense.h
-	rm -f $(includedir)/kinsol/kinsol_band.h
-	rm -f $(includedir)/kinsol/kinsol_lapack.h
-	rm -f $(includedir)/kinsol/kinsol_spgmr.h
-	rm -f $(includedir)/kinsol/kinsol_spbcgs.h
-	rm -f $(includedir)/kinsol/kinsol_sptfqmr.h
-	rm -f $(includedir)/kinsol/kinsol_bbdpre.h
-	rm -f $(includedir)/kinsol/kinsol_spils.h
-	rm -f $(includedir)/kinsol/kinsol_impl.h
-	$(rminstalldirs) ${includedir}/kinsol
-
-shared:
-	@cd ${top_builddir}/src/sundials ; \
-	 ${MAKE} ;                         \
-	 cd ${abs_builddir}
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(KINSOL_LIB)
-	rm -f $(KINSOL_LIB_FILES)
-	rm -f $(KINSOL_BL_LIB_FILES)
-	rm -f $(KINSOL_OBJ_FILES)
-	rm -f $(KINSOL_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-kinsol.lo: $(srcdir)/kinsol.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol.c
-kinsol_io.lo: $(srcdir)/kinsol_io.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_io.c
-kinsol_direct.lo: $(srcdir)/kinsol_direct.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_direct.c
-kinsol_dense.lo: $(srcdir)/kinsol_dense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_dense.c
-kinsol_band.lo: $(srcdir)/kinsol_band.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_band.c
-kinsol_lapack.lo: $(srcdir)/kinsol_lapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_lapack.c
-kinsol_spils.lo: $(srcdir)/kinsol_spils.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_spils.c
-kinsol_spgmr.lo: $(srcdir)/kinsol_spgmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_spgmr.c
-kinsol_spbcgs.lo: $(srcdir)/kinsol_spbcgs.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_spbcgs.c
-kinsol_sptfqmr.lo: $(srcdir)/kinsol_sptfqmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_sptfqmr.c
-kinsol_bbdpre.lo: $(srcdir)/kinsol_bbdpre.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/kinsol_bbdpre.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/kinsol/README b/src/kinsol/README
index ba660e5..f087a61 100644
--- a/src/kinsol/README
+++ b/src/kinsol/README
@@ -1,24 +1,27 @@
                              KINSOL
-                   Release 2.7.0, March 2012
-           Aaron Collier, Alan C. Hindmarsh, and Radu Serban
+                   Release 2.9.0, September 2016
+     Aaron Collier, Alan C. Hindmarsh, Radu Serban, and Carol S. Woodward
              Center for Applied Scientific Computing, LLNL
 
 KINSOL is a solver for nonlinear algebraic systems which can be
-described as F(u) = 0.  It is newly rewritten in the C language and based
+described as F(u) = 0.  It is written in the C language and based
 on the previous Fortran package NKSOL [4], written by Peter Brown and
-Youcef Saad.
+Youcef Saad.  Nonlinear solver methods available include Newton-Krylov,
+Picard, and fixed point.  Both Picard and fixed point can be accelerated
+with Anderson acceleration.
 
-KINSOL can be used both on serial and parallel (MPI) computers.
+KINSOL can be used both on serial and parallel computers.
 The difference is only in the NVECTOR module of vector functions.
 The desired version is obtained when compiling the example files
 by linking with the appropriate library of NVECTOR functions.  In the
-parallel version, communication between processes is done via the MPI 
-(Message Passage Interface) system.
+parallel versions, communication between processes is done  
+with MPI, with OpenMP, or with Pthreads.
 
 When used with the serial NVECTOR module, KINSOL provides both direct (dense 
-and band) and preconditioned Krylov (iterative) linear solvers. Three different
+and band) and preconditioned Krylov (iterative) linear solvers. Four different
 iterative solvers are available: scaled preconditioned GMRES (SPGMR), scaled 
-preconditioned BiCGStab (SPBCG), and scaled preconditioned TFQMR (SPTFQMR). 
+preconditioned BiCGStab (SPBCG), scaled preconditioned TFQMR (SPTFQMR), and
+scaled preconditioned Flexible GMRES (SPFGMR). 
 When used with the parallel NVECTOR module, KINSOL provides a
 preconditioner module called KINBBDPRE, which provides a
 band-block-diagonal preconditioner for use with the Krylov linear
@@ -28,7 +31,7 @@ acceleration of the Krylov solvers.
 
 KINSOL is part of a software family called SUNDIALS: SUite of Nonlinear
 and DIfferential/ALgebraic equation Solvers.  This suite consists of
-CVODE, KINSOL, and IDA, and variants of these.  The directory
+CVODE, CVODES, ARKode, KINSOL, IDA, and IDAS.  The directory
 structure of the package supplied reflects this family relationship.
 
 For use with Fortran applications, a set of Fortran/C interface routines,
@@ -50,8 +53,8 @@ and the KINSOL Examples [2] (kin_examples.pdf) documents.
 B. Installation
 ---------------
 
-For basic installation instructions see the file /sundials/INSTALL_NOTES. 
-For complete installation instructions see the "KINSOL Installation Procedure"
+For basic installation instructions see the file /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see the "Installation Procedure"
 chapter in the KINSOL User Guide [1].
 
 
@@ -59,11 +62,11 @@ C. References
 -------------
 
 [1] A. M. Collier, A. C. Hindmarsh, R. Serban, and C. S. Woodward,
-    "User Documentation for KINSOL v2.7.0," LLNL technical report
-    UCRL-SM-208116, December 2011. 
+    "User Documentation for KINSOL v2.9.0," LLNL technical report
+    UCRL-SM-208116, March 2016.
 
-[2] A. M. Collier and R. Serban, "Example Programs for KINSOL v2.7.0,"
-    LLNL technical report UCRL-SM-208114, December 2011.
+[2] A. M. Collier and R. Serban, "Example Programs for KINSOL v2.9.0,"
+    LLNL technical report UCRL-SM-208114, March 2016.
 
 [3] A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, 
     D. E. Shumaker, and C. S. Woodward, "SUNDIALS, Suite of Nonlinear and 
@@ -82,6 +85,10 @@ C. References
 D. Releases
 -----------
 
+v. 2.9.0   - Sep. 2016
+v. 2.8.2   - Aug. 2015
+v. 2.8.1   - Mar. 2015
+v. 2.8.0   - Mar. 2015
 v. 2.7.0   - Mar. 2012
 v. 2.6.0   - May  2009
 v. 2.5.0   - Nov. 2006
@@ -93,305 +100,3 @@ v. 2.2.0   - Dec. 2004
 v. 2.0     - Jul. 2002 (first SUNDIALS release)
 v. 1.0     - Aug. 1998 (date written)
 
-
-E. Revision History
--------------------
-
-v. 2.6.0 (May 2009) ---> v. 2.7.0 (Mar. 2012)
----------------------------------------------
-
-- Bug fixes
-   - Three major logic bugs were fixed -- involving updating the solution
-     vector, updating the linesearch parameter, and a missing error return.
-   - Three minor errors were fixed -- involving setting etachoice in the
-     Matlab/KINSOL interface, a missing error case in KINPrintInfo,
-     and avoiding an exponential overflow in the evaluation of omega.
-   - In each linear solver interface function, the linear solver memory is
-     freed on an error return, and the **Free function now includes a
-     line setting to NULL the main memory pointer to the linear solver memory.
-
-- Changes to user interface
-   - One significant design change was made with this release: The problem
-     size and its relatives, bandwidth parameters, related internal indices,
-     pivot arrays, and the optional output lsflag, have all been
-     changed from type int to type long int, except for the
-     problem size and bandwidths in user calls to routines specifying
-     BLAS/LAPACK routines for the dense/band linear solvers.  The function
-     NewIntArray is replaced by a pair NewIntArray/NewLintArray,
-     for int and long int arrays, respectively.
-   - in the installation files, we modified the treatment of the macro
-     SUNDIALS_USE_GENERIC_MATH, so that the parameter GENERIC_MATH_LIB
-     is either defined (with no value) or not defined.
-
-
-v. 2.5.0 (Nov. 2006) ---> v. 2.6.0 (May 2009)
----------------------------------------------
-
-- New features
-   - added a new linear solver module based on Blas + Lapack for
-     both dense and banded matrices.
-
-- Bug fixes
-   - added logic to ensure omega is updated every iteration.
-   - fixed difference-quotient Jacobian memory reset bug.
-
-- Changes to user interface
-   - renamed all **Malloc functions to **Init
-   - all user-supplied functions now receive the same pointer to user data
-     (instead of having different ones for the system evaluation, Jacobian
-     information functions, etc.
-   - common functionality for all direct linear solvers (dense, band, and
-     the new Lapack solver) has been collected into the DLS (Direct Linear
-     Solver) module, similar to the SPILS module for the iterative linear 
-     solvers. All optional input and output functions for these linear 
-     solver now have the prefix 'KINDls'. In addition, in order to include
-     the new Lapack-based linear solver, all dimensions for these linear
-     solvers (problem sizes, bandwidths, etc) are now of type 'int' 
-     (instead of 'long int').
-   - the initialization function for the preconditioner module KINBBDPRE
-     was renamed KINBBDInit (from KINBBDAlloc) and it does not return
-     a pointer to preconditioner memory anymore. Instead, all preconditioner
-     module-related functions are now called with the main solver memory 
-     pointer as their first argument. When using the KINBBDPRE module,
-     there is no need to use special functions to attach one of the SPILS
-     linear solvers (instead use one of KINSpgmr, KINSpbcg, or KINSptfqmr).
-     Moreover, there is no need to call a memory deallocation function for
-     the preconditioner module.
-   - changes corresponding to the above were made to the FCMIX interface.
-
-v. 2.4.0 (Mar. 2006) ---> v. 2.5.0 (Oct. 2006)
-----------------------------------------------
-
-- Changes related to the build system
-   - reorganized source tree: header files in ${srcdir}/include/kinsol,
-     source files in ${srcdir}/src/kinsol, fcmix source files in
-     ${srcdir}/src/kinsol/fcmix, examples in ${srcdir}/examples/kinsol
-   - exported header files are installed unde ${includedir}/kinsol
-
-- Changes to user interface
-   - all included header files use relative paths from ${includedir}
-
-v. 2.3.0 (Apr. 2005) ---> v. 2.4.0 (Mar. 2006)
-----------------------------------------------
-
-- New features
-   - added direct linear solvers (dense and band, provided
-     through the KINDENSE and KINBAND modules, respectively) thus adding
-     modified (and exact) Newton methods to KINSOL.
-   - added KINSPBCG interface module to allow KINSOL to interface with the
-     shared SPBCG (scaled preconditioned Bi-CGSTAB) linear solver module.
-   - added KINSPTFQMR interface module to allow KINSOL to interface with
-     the shared SPTFQMR (scaled preconditioned TFQMR) linear solver module
-   - added support for SPBCG and SPTFQMR to the KINBBDPRE preconditioner module.
-   - added option to KINBBDPRE preconditioner module to allow specification
-     of different half-bandwidths for difference quotient approximation and
-     retained matrix.
-   - added support for interpreting failures in user-supplied functions.
-
-- Bug fixes
-   - corrected a bug in the preconditioner logic that caused the initial call
-     to the preconditioner setup routine (controlled by KINSetNoInitSetup) to
-     be skipped during subsequent calls to KINSol
-
-- Changes to underlying algorithms
-   - modified the KINBBDPRE preconditioner module to allow the use of
-     different half-bandwidths for the difference quotient approximation
-     and the retained matrix.
-   - added nonlinear residual monitoring scheme to control Jacobian updating
-     when a direct linear solver is used (modified Newton iteration)
-
-- Changes to user interface
-   - changed argument of KINFree and KINBBDPrecFree to be the address of 
-     the respective memory block pointer, so that its NULL value is 
-     propagated back to the calling function.
-   - modified the argument list of KINBBDPrecAlloc to allow specification
-     of the upper and lower half-bandwidths to be used in the computation
-     of the local Jacobian blocks (mudq, mldq), and the half-bandwidths
-     of the retained banded approximation to the local Jacobian block
-     (mukeep, mlkeep).
-   - added KINSPBCG module which defines appropriate KINSpbcg* functions to
-     allow KINSOL to interface with the shared SPBCG linear solver module.
-   - added KINBBDSpbcg function to KINBBDPRE module to support SPBCG linear
-     solver module.
-   - changed function type names (not the actual definitions) to accomodate
-     all the Scaled Preconditioned Iterative Linear Solvers now available:
-       KINSpgmrJactimesVecFn -> KINSpilsJacTimesVecFn
-       KINSpgmrPrecSetupFn   -> KINSpilsPrecSetupFn
-       KINSpgmrPrecSolveFn   -> KINSpilsPrecSolveFn 
-   - changed function types so that all user-supplied functions return
-     an integer flag (not all of them currently used).
-   - changed some names for KINBBDPRE function outputs
-   - added option for user-supplied error handler function.
-   - added option for user-supplied info handler function.
-   - renamed all exported header files (except for kinsol.h, all header files
-     have the prefix 'kinsol_')
-   - changed naming scheme for KINSOL examples
-
-- Changes to the FKINSOL module
-   - modified argument list of FKINBBDINIT to accomadate changes made
-     to KINBBDPRE module, so now user must specify the upper and lower
-     half-bandwidths for the difference quotient approximation (mudq, mldq)
-     and the retained matrix (mukeep, mlkeep).
-   - added support for KINSPBCG/SPBCG (added FKIN*SPBCG* functions).
-   - added support for KINSPTFQMR/SPTFQMR (added FKIN*SPTFQMR* functions).
-   - added support for KINDENSE/DENSE (added FKIN*DENSE* functions).
-   - added support for KINBAND/BAND (added FKIN*DENSE* functions).
-   - Optional inputs are now set using routines FKINSETIIN (integer inputs),
-     FKINSETRIN (real inputs), and FKINSETVIN (vector inputs) through pairs 
-     key-value. Optional outputs are still obtained from two arrays (IOUT and 
-     ROUT), owned by the user and passed as arguments to FKINMALLOC.
-
-- Changes related to the build system
-   - updated configure script and Makefiles for Fortran examples to avoid C++
-     compiler errors (now use CC and MPICC to link only if necessary)
-   - the main KINSOL header file (kinsol.h) is still exported to the install include
-     directory. However, all other KINSOL header files are exported into an 'kinsol'
-     subdirectory of the install include directory.
-   - the KINSOL library now contains all shared object files (there is no separate
-     libsundials_shared library anymore)
-
-v. 2.2.2 (Mar. 2005) ---> v. 2.3.0 (Apr. 2005)
-----------------------------------------------
-
-- Changes to user interface
-   - KINSOL now stores an actual copy of the constraints vector rather than
-     just a pointer in order to resolve potential scoping issues
-   - several optional input functions were combined into a single function:
-       - KINSpgmrSetPrecSetupFn, KINSpgmrSetPrecSolveFn and KINSpgmrSetPrecData
-         were combined into KINSpgmrSetPreconditioner
-       - KINSpgmrSetJacTimesVecFn and KINSpgmrSetJacData were combined into
-         KINSpgmrSetJacTimesVecFn
-
-- Changes to FKINSOL module:
-   - FKINSPGMRSETPSET and FKINSPGMRSETPSOL were combined into FKINSPGMRSETPREC
-   - due to changes to the main solver, if FKPSOL is provided, then FKPSET
-     must also be defined, even if it is empty
-
-v. 2.2.1 (Jan. 2005) ---> v. 2.2.2 (Mar. 2005)
-----------------------------------------------
-
-- Bug fixes
-   - fixed bug in computation of the scaled step length
-   - fixed bug in logic for disabling the call to the preconditioner setup function 
-     at the first iteration
-   - modified FCMIX files to avoid C++ compiler errors
-   - changed implicit type conversion to explicit in check_flag() routine in
-     examples to avoid C++ compiler errors
-
-- Changes to documentation
-   - added section with numerical values of all input and output solver constants
-   - added description of --with-mpi-flags option
-
-- Changes related to the build system
-   - fixed autoconf-related bug to allow configuration with the PGI Fortran compiler
-   - modified to use customized detection of the Fortran name mangling scheme 
-     (autoconf's AC_F77_WRAPPERS routine is problematic on some platforms)
-   - added --with-mpi-flags as a configure option to allow user to specify
-     MPI-specific flags
-   - updated Makefiles for Fortran examples to avoid C++ compiler errors (now use
-     CC and MPICC to link)
-
-v. 2.2.0 (Dec. 2004) ---> v. 2.2.1 (Jan. 2005)
-----------------------------------------------
-
-- Changes related to the build system
-   - changed order of compiler directives in header files to avoid compilation
-     errors when using a C++ compiler.
-
-v. 2.0 (Jul. 2002) ---> v. 2.2.0 (Dec. 2004)
---------------------------------------------
-
-- New feature
-   - added option to disable all error messages.
-
-- Bug fixes
-   - fixed constraints-related bug.
-   - fixed bug in implementation of line-search method related to
-     beta-condition.
-   - corrected value of ealpha variable (related to forcing term).
-
-- Changes related to NVECTOR module
-  (see also the file sundials/shared/README)
-   - removed machEnv, redefined table of vector operations (now contained
-     in the N_Vector structure itself).
-   - all KINSOL functions create new N_Vector variables through cloning,
-     using an N_Vector passed by the user as a template.
-
-- Changes to type names and KINSOL constants
-   - removed type 'integertype'; instead use 'int' or 'long int', as
-     appropriate.
-   - restructured the list of return values from the various KINSOL
-     functions.
-   - changed all KINSOL constants (inputs and return values) to have
-     the prefix 'KIN_' (e.g. KIN_SUCCESS).
-   - renamed function type 'SysFn' to 'KINSysFn'.
-
-- Changes to underlying algorithms
-   - modified line-search backtracking scheme to use cubic interpolation
-     after the first backtrack, if possible.
-   - changed implementation of constraints:
-       if constraints[i] =
-         0  u[i] NOT constrained
-        +1  u[i] >= 0
-        -1  u[i] <= 0
-        +2  u[i] >  0
-        -2  u[i] <  0
-       where u is the solution vector (see the KINSOL User Guide [1] for
-       additional details).
-
-- Changes to optional input/output
-   - added KINSet* and KINGet* functions for optional inputs/outputs,
-     replacing the arrays iopt and ropt.
-   - added new optional inputs (e.g. maximum number of nonlinear iterations
-     between calls to preconditioner setup routine, etc.).
-   - the value of the last return flag from any function within the SPGMR
-     linear solver module can be obtained as an optional output using
-     KINSpgmrGetLastFlag.
-
-- Changes to user-callable functions
-   - added new function KINCreate which initializes the KINSOL solver object
-     and returns a pointer to the KINSOL memory block.
-   - removed N (problem size) from all functions.
-   - shortened argument lists of most KINSOL functions (the arguments that
-     were dropped can now be specified through KINSet* functions).
-   - removed reinitialization functions for SPGMR linear solver (same
-     functionality can be obtained using KINSpgmrSet* functions).
-
-- Changes to user-supplied functions
-   - removed N (problem dimension) from argument lists.
-   - in KINSPGMR, shortened argument lists for user preconditioner functions.
-
-- Changes to the FKINSOL module
-   - revised to use underscore and precision flags at compile time (from
-     configure); example sources are preprocessed accordingly.
-   - use KIN*Set* and KIN*Get* functions from KINSOL (although the optional
-     I/O is still communicated to the user of FKINSOL through arrays IOPT
-     and ROPT).
-   - added new optional inputs and outputs (e.g. last return flag from the
-     linear solver, etc.).
-
-v. 1.0 (Aug. 1998) ---> v. 2.0 (Jul. 2002)
-------------------------------------------
-
-YYYYMMDD
-
-19980802   DATE WRITTEN - KINSOL released.
-19981203   Implemented serial Fortran/C interface (fkinsols.c).
-19990301   Fixed bug in nbktrk.
-19990325   Removed machEnv as an argument to KINSol.
-19991229   Fixed preconditioner evaluation logic;
-           revised SPGMR module to treat scalings correctly.
-20000324   Upgraded serial and parallel versions of NVECTOR module.
-20000706   Fixed bug in use of vtemp1 in KINSpgmrSolve call to KINAtimes etc.
-20000808   Fixed bug in N_VMin routine.
-20010118   Minor corrections, notably:
-           In fkinsol.h, KINUAtimes prototype fixed.  In fkinsols.c and
-           fkinsolp.c, N_Vector's disposed with N_VDISPOSE after KINSol call. 
-           In all fkin*.c, #include lines for header files corrected.
-20011212   Corrected 4 N_VDISPOSE arguments in FKINSOL.
-20011212   Added missing error flag print in KINSol, and changed 5 return
-           values in KINStop to enum-defined expressions.
-20011220   Default type 'integer' changed to 'long int' in llnltyps.h.
-20011221   In FKINSOL, corrected type (integer) for Neq in KINPreco, KINPSol.
-20020313   Modified to work with new NVECTOR abstraction.
-20020627   Modified to reflect type name changes.
diff --git a/src/kinsol/fcmix/CMakeLists.txt b/src/kinsol/fcmix/CMakeLists.txt
index bbfe4c4..16377cf 100644
--- a/src/kinsol/fcmix/CMakeLists.txt
+++ b/src/kinsol/fcmix/CMakeLists.txt
@@ -16,6 +16,24 @@ ELSE(LAPACK_FOUND)
   SET(fkinsol_BL_SOURCES "")
 ENDIF(LAPACK_FOUND)
 
+IF(KLU_FOUND OR SUPERLUMT_FOUND)
+  SET(fkinsol_SPARSE_SOURCES fkinsparse.c)
+ELSE(SPARSE_FOUND)
+  SET(fkinsol_SPARSE_SOURCES "")
+ENDIF(KLU_FOUND OR SUPERLUMT_FOUND)
+ 
+IF(KLU_FOUND)
+  SET(fkinsol_KLU_SOURCES fkinklu.c)
+ELSE(KLU_FOUND)
+  SET(fkinsol_KLU_SOURCES "")
+ENDIF(KLU_FOUND)
+ 
+IF(SUPERLUMT_FOUND)
+  SET(fkinsol_SUPERLUMT_SOURCES fkinsuperlumt.c)
+ELSE(SUPERLUMT_FOUND)
+  SET(fkinsol_SUPERLUMT_SOURCES "")
+ENDIF(SUPERLUMT_FOUND)
+
 # Add source directories to include directories for access to
 # implementation only header files (both for fkinsol and kinsol)
 INCLUDE_DIRECTORIES(.)
@@ -29,7 +47,7 @@ ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
 # coming from inexistent user-provided functions)
 
 # Add the build target for the FKINSOL library
-ADD_LIBRARY(sundials_fkinsol_static STATIC ${fkinsol_SOURCES} ${fkinsol_BL_SOURCES})
+ADD_LIBRARY(sundials_fkinsol_static STATIC ${fkinsol_SOURCES} ${fkinsol_BL_SOURCES} ${fkinsol_SPARSE_SOURCES} ${fkinsol_KLU_SOURCES} ${fkinsol_SUPERLUMT_SOURCES})
 
 # Set the library name and make sure it is not deleted
 SET_TARGET_PROPERTIES(sundials_fkinsol_static
diff --git a/src/kinsol/fcmix/Makefile.in b/src/kinsol/fcmix/Makefile.in
deleted file mode 100644
index 6330fc8..0000000
--- a/src/kinsol/fcmix/Makefile.in
+++ /dev/null
@@ -1,119 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.9 $
-# $Date: 2009/03/25 23:10:50 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for FKINSOL module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/kinsol -I$(top_builddir)/include
-
-LIB_REVISION = 0:1:0
-
-FKINSOL_LIB = libsundials_fkinsol.la
-
-FKINSOL_SRC_FILES = fkinsol.c fkindense.c fkinband.c fkinpreco.c fkinjtimes.c fkinbbd.c
-FKINSOL_BL_SRC_FILES = fkinlapack.c fkinlapdense.c fkinlapband.c 
-
-FKINSOL_OBJ_FILES = $(FKINSOL_SRC_FILES:.c=.o)
-FKINSOL_BL_OBJ_FILES = $(FKINSOL_BL_SRC_FILES:.c=.o)
-
-FKINSOL_LIB_FILES = $(FKINSOL_SRC_FILES:.c=.lo)
-FKINSOL_BL_LIB_FILES = $(FKINSOL_BL_SRC_FILES:.c=.lo)
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-all: $(FKINSOL_LIB)
-
-$(FKINSOL_LIB): $(FKINSOL_LIB_FILES)
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: $(FKINSOL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(FKINSOL_LIB) $(FKINSOL_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -static -version-info $(LIB_REVISION)
-
-lib_with_bl: $(FKINSOL_LIB_FILES) $(FKINSOL_BL_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(FKINSOL_LIB) $(FKINSOL_LIB_FILES) $(FKINSOL_BL_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -static -version-info $(LIB_REVISION)
-
-install: $(FKINSOL_LIB)
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(FKINSOL_LIB) $(libdir)
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(FKINSOL_LIB)
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(FKINSOL_LIB)
-	rm -f $(FKINSOL_LIB_FILES)
-	rm -f $(FKINSOL_BL_LIB_FILES)
-	rm -f $(FKINSOL_OBJ_FILES)
-	rm -f $(FKINSOL_BL_OBJ_FILES)
-
-distclean: clean
-	rm -f Makefile
-
-fkinsol.lo: $(srcdir)/fkinsol.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinsol.c
-fkinpreco.lo: $(srcdir)/fkinpreco.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinpreco.c
-fkinjtimes.lo: $(srcdir)/fkinjtimes.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinjtimes.c
-fkinbbd.lo: $(srcdir)/fkinbbd.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinbbd.c
-fkindense.lo: $(srcdir)/fkindense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkindense.c
-fkinband.lo: $(srcdir)/fkinband.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinband.c
-fkinlapack.lo: $(srcdir)/fkinlapack.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinlapack.c
-fkinlapdense.lo: $(srcdir)/fkinlapdense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinlapdense.c
-fkinlapband.lo: $(srcdir)/fkinlapband.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/fkinlapband.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/kinsol/fcmix/fkinband.c b/src/kinsol/fcmix/fkinband.c
index b87ee37..fb949e6 100644
--- a/src/kinsol/fcmix/fkinband.c
+++ b/src/kinsol/fcmix/fkinband.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:45:33 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for KINSOL/KINBAND, for the case
  * of a user-supplied Jacobian approximation routine.
diff --git a/src/kinsol/fcmix/fkinbbd.c b/src/kinsol/fcmix/fkinbbd.c
index a220d0a..dfb6cad 100644
--- a/src/kinsol/fcmix/fkinbbd.c
+++ b/src/kinsol/fcmix/fkinbbd.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:45:33 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This module contains the routines necessary to interface with
  * the KINBBDPRE module and user-supplied Fortran routines. Generic
diff --git a/src/kinsol/fcmix/fkinbbd.h b/src/kinsol/fcmix/fkinbbd.h
index a55f871..a045ac1 100644
--- a/src/kinsol/fcmix/fkinbbd.h
+++ b/src/kinsol/fcmix/fkinbbd.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4398 $
+ * $Date: 2015-02-28 14:29:35 -0800 (Sat, 28 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the Fortran interface include file for the BBD
  * preconditioner module KINBBDPRE.
@@ -24,7 +29,8 @@
  use of the KINSOL solver with the KINBBDPRE preconditioner module, for the
  solution of nonlinear systems in a mixed Fortran/C setting. The combination
  of KINSOL and KINBBDPRE solves systems f(u) = 0 with the SPGMR (scaled
- preconditioned GMRES), SPBCG (scaled preconditioned Bi-CGSTAB), or SPTFQMR
+ preconditioned GMRES), SPFGMR (scaled preconditioned flexible GMRES), 
+ SPBCG (scaled preconditioned Bi-CGSTAB), or SPTFQMR
  (scaled preconditioned TFQMR) method for the linear systems that arise, and
  with a preconditioner that is block-diagonal with banded blocks. While KINSOL
  and KINBBDPRE are written in C, it is assumed here that the user's calling
@@ -37,6 +43,7 @@
    FKINBBDSPTFQMR: interfaces with KINSptfqmr
    FKINBBDSPBCG : interfaces with KINSpbcg
    FKINBBDSPGMR : interfaces with KINSpgmr
+   FKINBBDSPFGMR : interfaces with KINSpfgmr
    FKINBBDOPT : accesses optional outputs
    FKINBBDFREE : interfaces to KINBBDPrecFree
 
@@ -179,9 +186,10 @@
 
        Note: See printed message for details in case of failure.
 
- (4.3) Attach one of the 3 SPILS linear solvers. Make one of the 
+ (4.3) Attach one of the SPILS linear solvers. Make one of the 
        following calls (see fkinsol.h) for more details.
           CALL FKINSPGMR (MAXL, MAXLRST, IER)
+          CALL FKINSPFGMR (MAXL, MAXLRST, IER)
           CALL FKINSPBCG (MAXL, IER)
           CALL FKINSPTFQMR (MAXL, IER)
 
@@ -242,19 +250,18 @@
 #ifndef _FKINBBD_H
 #define _FKINBBD_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 /*
  * -----------------------------------------------------------------
  * header files
  * -----------------------------------------------------------------
  */
-
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector */
 #include <sundials/sundials_types.h>   /* definition of type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /*
  * -----------------------------------------------------------------
  * generic names are translated through the define statements below
diff --git a/src/kinsol/fcmix/fkindense.c b/src/kinsol/fcmix/fkindense.c
index 408f00a..77551a5 100644
--- a/src/kinsol/fcmix/fkindense.c
+++ b/src/kinsol/fcmix/fkindense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:45:33 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for KINSOL/KINDENSE, for the case
  * of a user-supplied Jacobian approximation routine.
diff --git a/src/kinsol/fcmix/fkinjtimes.c b/src/kinsol/fcmix/fkinjtimes.c
index 6cdb992..c85fe68 100644
--- a/src/kinsol/fcmix/fkinjtimes.c
+++ b/src/kinsol/fcmix/fkinjtimes.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:29:01 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Routines used to interface between KINSOL and a Fortran
  * user-supplied routine FKJTIMES (Jacobian J times vector v).
diff --git a/src/kinsol/fcmix/fkinklu.c b/src/kinsol/fcmix/fkinklu.c
new file mode 100644
index 0000000..867d871
--- /dev/null
+++ b/src/kinsol/fcmix/fkinklu.c
@@ -0,0 +1,52 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4654 $
+ * $Date: 2016-02-17 20:12:58 -0800 (Wed, 17 Feb 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the Fortran interface to
+ * the KINKLU solver. See fkinsol.h for usage.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fkinsol.h"
+#include "kinsol_impl.h"
+#include <kinsol/kinsol_klu.h>
+ 
+/*
+ * ----------------------------------------------------------------
+ * Function : FKIN_KLU
+ * ----------------------------------------------------------------
+ */
+
+void FKIN_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier)
+{
+  *ier = KINKLU(KIN_kinmem, *neq, *nnz, *sparsetype);
+  KINKLUSetOrdering(KIN_kinmem, *ordering);
+  KIN_ls = KIN_LS_KLU;
+}
+
+/*
+ * ----------------------------------------------------------------
+ * Function : FKIN_KLUReinit
+ * ----------------------------------------------------------------
+ */
+
+void FKIN_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier)
+{
+  *ier = KINKLUReInit(KIN_kinmem, *neq, *nnz, *reinit_type);
+}
+
diff --git a/src/kinsol/fcmix/fkinlapack.c b/src/kinsol/fcmix/fkinlapack.c
index 7c24f14..e117b69 100644
--- a/src/kinsol/fcmix/fkinlapack.c
+++ b/src/kinsol/fcmix/fkinlapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/11/22 00:12:51 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for KINSOL/KINLAPACK
  * -----------------------------------------------------------------
diff --git a/src/kinsol/fcmix/fkinlapband.c b/src/kinsol/fcmix/fkinlapband.c
index 2948627..97d5288 100644
--- a/src/kinsol/fcmix/fkinlapband.c
+++ b/src/kinsol/fcmix/fkinlapband.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:45:33 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for KINSOL/KINBAND, for the case
  * of a user-supplied Jacobian approximation routine.
diff --git a/src/kinsol/fcmix/fkinlapdense.c b/src/kinsol/fcmix/fkinlapdense.c
index 37ce649..03f04f4 100644
--- a/src/kinsol/fcmix/fkinlapdense.c
+++ b/src/kinsol/fcmix/fkinlapdense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:45:33 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Fortran/C interface routines for KINSOL/KINLAPACKDENSE, for the
  * case of a user-supplied Jacobian approximation routine.
diff --git a/src/kinsol/fcmix/fkinpreco.c b/src/kinsol/fcmix/fkinpreco.c
index abc6184..d1882f9 100644
--- a/src/kinsol/fcmix/fkinpreco.c
+++ b/src/kinsol/fcmix/fkinpreco.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/30 19:29:01 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file contains the interfaces between KINSOL and the
  * user-supplied Fortran routines FK_PSET and FK_PSOL.
diff --git a/src/kinsol/fcmix/fkinsol.c b/src/kinsol/fcmix/fkinsol.c
index 933fa08..f8d5e41 100644
--- a/src/kinsol/fcmix/fkinsol.c
+++ b/src/kinsol/fcmix/fkinsol.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:45:33 $
+ * $Revision: 4906 $
+ * $Date: 2016-09-14 16:05:17 -0700 (Wed, 14 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the Fortran interface to
  * the KINSOL package. See fkinsol.h for usage.
@@ -29,9 +34,12 @@
 
 #include <kinsol/kinsol_band.h>    /* prototypes of KINBAND interface routines    */
 #include <kinsol/kinsol_dense.h>   /* prototypes of KINDENSE interface routines   */
+#include <kinsol/kinsol_klu.h>     /* prototypes of KINKLU interface routines     */
+#include <kinsol/kinsol_superlumt.h> /* prototypes of KINSUPERLU interface routines */
 #include <kinsol/kinsol_sptfqmr.h> /* prototypes of KINSPTFQMR interface routines */
 #include <kinsol/kinsol_spbcgs.h>  /* prototypes of KINSPBCG interface routines   */
 #include <kinsol/kinsol_spgmr.h>   /* prototypes of KINSPGMR interface routines   */
+#include <kinsol/kinsol_spfgmr.h>  /* prototypes of KINSPFGMR interface routines  */
 
 /*
  * ----------------------------------------------------------------
@@ -70,6 +78,61 @@ extern void FK_FUN(realtype*, realtype*, int*);
 
 /*
  * ----------------------------------------------------------------
+ * Function : FKIN_CREATE
+ * ----------------------------------------------------------------
+ */
+
+void FKIN_CREATE(int *ier)
+{
+  
+  *ier = 0;
+  /* check for required vector operations */
+  if ((F2C_KINSOL_vec->ops->nvgetarraypointer == NULL) ||
+      (F2C_KINSOL_vec->ops->nvsetarraypointer == NULL)) {
+    *ier = -1;
+    printf("FKINCREATE: A required vector operation is not implemented.\n\n");
+    return;
+  }
+
+  /* Initialize pointers to NULL */
+  KIN_kinmem = NULL;
+
+  /* Create KINSOL object */
+  KIN_kinmem = KINCreate();
+  if (KIN_kinmem == NULL) {
+    *ier = -1;
+    return;
+  }
+}
+
+/*
+ * ----------------------------------------------------------------
+ * Function : FKIN_INIT
+ * ----------------------------------------------------------------
+ */
+
+void FKIN_INIT(long int *iout, realtype *rout, int *ier)
+{
+  
+  /* Call KINInit */
+  *ier = 0;
+  *ier = KINInit(KIN_kinmem, FKINfunc, F2C_KINSOL_vec);
+
+  /* On failure, exit */
+  if (*ier != KIN_SUCCESS) {
+    *ier = -1;
+    return;
+  }
+
+  /* Grab optional output arrays and store them in global variables */
+  KIN_iout = iout;
+  KIN_rout = rout;
+
+  return;
+}
+
+/*
+ * ----------------------------------------------------------------
  * Function : FKIN_MALLOC
  * ----------------------------------------------------------------
  */
@@ -118,23 +181,25 @@ void FKIN_MALLOC(long int *iout, realtype *rout, int *ier)
  * ----------------------------------------------------------------
  */
 
-void FKIN_SETIIN(char key_name[], long int *ival, int *ier, int key_len)
+void FKIN_SETIIN(char key_name[], long int *ival, int *ier)
 {
-  if (!strncmp(key_name,"PRNT_LEVEL", (size_t)key_len)) 
+  if (!strncmp(key_name,"PRNT_LEVEL",10))
     *ier = KINSetPrintLevel(KIN_kinmem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_NITERS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_NITERS",10))
     *ier = KINSetNumMaxIters(KIN_kinmem, (int) *ival);
-  else if (!strncmp(key_name,"ETA_FORM", (size_t)key_len)) 
+  else if (!strncmp(key_name,"ETA_FORM",8))
     *ier = KINSetEtaForm(KIN_kinmem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_SETUPS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAA",3))
+    *ier = KINSetMAA(KIN_kinmem, (int) *ival);
+  else if (!strncmp(key_name,"MAX_SETUPS",10))
     *ier = KINSetMaxSetupCalls(KIN_kinmem, (int) *ival);
-  else if (!strncmp(key_name,"MAX_SP_SETUPS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_SP_SETUPS",13))
     *ier = KINSetMaxSubSetupCalls(KIN_kinmem, (int) *ival);
-  else if (!strncmp(key_name,"NO_INIT_SETUP", (size_t)key_len)) 
+  else if (!strncmp(key_name,"NO_INIT_SETUP",13))
     *ier = KINSetNoInitSetup(KIN_kinmem, (int) *ival);
-  else if (!strncmp(key_name,"NO_MIN_EPS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"NO_MIN_EPS",10))
     *ier = KINSetNoMinEps(KIN_kinmem, (int) *ival);
-  else if (!strncmp(key_name,"NO_RES_MON", (size_t)key_len)) 
+  else if (!strncmp(key_name,"NO_RES_MON",10))
     *ier = KINSetNoResMon(KIN_kinmem, (int) *ival);
   else {
     *ier = -99;
@@ -149,24 +214,24 @@ void FKIN_SETIIN(char key_name[], long int *ival, int *ier, int key_len)
  * ----------------------------------------------------------------
  */
 
-void FKIN_SETRIN(char key_name[], realtype *rval, int *ier, int key_len)
+void FKIN_SETRIN(char key_name[], realtype *rval, int *ier)
 {
 
-  if (!strncmp(key_name,"FNORM_TOL", (size_t)key_len)) 
+  if (!strncmp(key_name,"FNORM_TOL",9))
     *ier = KINSetFuncNormTol(KIN_kinmem, *rval);
-  else if (!strncmp(key_name,"SSTEP_TOL", (size_t)key_len)) 
+  else if (!strncmp(key_name,"SSTEP_TOL",9))
     *ier = KINSetScaledStepTol(KIN_kinmem, *rval);
-  else if (!strncmp(key_name,"MAX_STEP", (size_t)key_len)) 
+  else if (!strncmp(key_name,"MAX_STEP",8))
     *ier = KINSetMaxNewtonStep(KIN_kinmem, *rval);
-  else if (!strncmp(key_name,"RERR_FUNC", (size_t)key_len)) 
+  else if (!strncmp(key_name,"RERR_FUNC",9))
     *ier = KINSetRelErrFunc(KIN_kinmem, *rval);
-  else if (!strncmp(key_name,"ETA_CONST", (size_t)key_len)) 
+  else if (!strncmp(key_name,"ETA_CONST",9))
     *ier = KINSetEtaConstValue(KIN_kinmem, *rval);
-  else if (!strncmp(key_name,"ETA_PARAMS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"ETA_PARAMS",10))
     *ier = KINSetEtaParams(KIN_kinmem, rval[0], rval[1]);
-  else if (!strncmp(key_name,"RMON_CONST", (size_t)key_len)) 
+  else if (!strncmp(key_name,"RMON_CONST",10))
     *ier = KINSetResMonConstValue(KIN_kinmem, *rval);
-  else if (!strncmp(key_name,"RMON_PARAMS", (size_t)key_len)) 
+  else if (!strncmp(key_name,"RMON_PARAMS",11))
     *ier = KINSetResMonParams(KIN_kinmem, rval[0], rval[1]);
   else {
     *ier = -99;
@@ -181,17 +246,18 @@ void FKIN_SETRIN(char key_name[], realtype *rval, int *ier, int key_len)
  * ----------------------------------------------------------------
  */
 
-void FKIN_SETVIN(char key_name[], realtype *vval, int *ier, int key_len)
+void FKIN_SETVIN(char key_name[], realtype *vval, int *ier)
 {
   N_Vector Vec;
 
-  if (!strncmp(key_name,"CONSTR_VEC", (size_t)key_len)) {
+  if (!strncmp(key_name,"CONSTR_VEC",10)) {
     Vec = NULL;
     Vec = N_VCloneEmpty(F2C_KINSOL_vec);
     if (Vec == NULL) {
       *ier = -1;
       return;
     }
+    *ier = 0;
     N_VSetArrayPointer(vval, Vec);
     KINSetConstraints(KIN_kinmem, Vec);
     N_VDestroy(Vec);
@@ -265,6 +331,19 @@ void FKIN_SPGMR(int *maxl, int *maxlrst, int *ier)
 
 /*
  * ----------------------------------------------------------------
+ * Function : FKIN_SPFGMR
+ * ----------------------------------------------------------------
+ */
+
+void FKIN_SPFGMR(int *maxl, int *maxlrst, int *ier)
+{
+  *ier = KINSpfgmr(KIN_kinmem, *maxl);
+  KINSpilsSetMaxRestarts(KIN_kinmem, *maxlrst);
+  KIN_ls = KIN_LS_SPFGMR;
+}
+
+/*
+ * ----------------------------------------------------------------
  * Function : FKIN_SOL
  * ----------------------------------------------------------------
  */
@@ -273,7 +352,6 @@ void FKIN_SOL(realtype *uu, int *globalstrategy,
               realtype *uscale , realtype *fscale, int *ier)
 
 {
-  int lsflag;
   N_Vector uuvec, uscalevec, fscalevec;
 
   *ier = 0;
@@ -330,8 +408,14 @@ void FKIN_SOL(realtype *uu, int *globalstrategy,
     KINDlsGetLastFlag(KIN_kinmem, &KIN_iout[8]);                /* LSTF */
     KINDlsGetNumFuncEvals(KIN_kinmem, &KIN_iout[9]);            /* NFE */
     KINDlsGetNumJacEvals(KIN_kinmem, &KIN_iout[10]);            /* NJE */    
+  case KIN_LS_KLU:
+  case KIN_LS_SUPERLUMT:
+    KINSlsGetLastFlag(KIN_kinmem, &KIN_iout[8]);                /* LSTF  */
+    KINSlsGetNumJacEvals(KIN_kinmem, &KIN_iout[10]);            /* NJE   */
+    break;
   case KIN_LS_SPTFQMR:
   case KIN_LS_SPBCG:
+  case KIN_LS_SPFGMR:
   case KIN_LS_SPGMR:
     KINSpilsGetWorkSpace(KIN_kinmem, &KIN_iout[6], &KIN_iout[7]); /* LRW & LIW */
     KINSpilsGetLastFlag(KIN_kinmem, &KIN_iout[8]);                /* LSTF */
@@ -391,5 +475,5 @@ int FKINfunc(N_Vector uu, N_Vector fval, void *user_data)
 
   FK_FUN(udata, fdata, &ier);
 
-  return(0);
+  return(ier);
 }
diff --git a/src/kinsol/fcmix/fkinsol.h b/src/kinsol/fcmix/fkinsol.h
index 609acf9..f253221 100644
--- a/src/kinsol/fcmix/fkinsol.h
+++ b/src/kinsol/fcmix/fkinsol.h
@@ -1,15 +1,21 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:45:33 $
+ * $Revision: 4905 $
+ * $Date: 2016-09-14 16:04:36 -0700 (Wed, 14 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
+ *                Daniel R. Reynolds @ SMU
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the header file for the FKINSOL Interface Package.
  * See below for usage details.
@@ -25,19 +31,26 @@
  in a mixed Fortran/C setting. While KINSOL is written in C, it is assumed 
  here that the user's calling program and user-supplied problem-defining 
  routines are written in Fortran. This package provides the necessary
- interface to KINSOL for both the serial and the parallel NVECTOR
+ interface to KINSOL for the serial and parallel NVECTOR
  implementations.
 
  The user-callable functions, with the corresponding KINSOL functions,
  are as follows:
 
-   FNVINITS and FNVINITP initialize serial and parallel vector
-                         computations, respectively
+   FNVINITS, FNVINITP, FNVINITOMP, FNVINITPTS
+          initialize serial, distributed memory parallel, or threaded 
+          vector computations
    FKINMALLOC interfaces to KINInit
+   FKINCREATE interfaces to KINCreate
+   FKININIT interfaces to KINInit
    FKINSETIIN, FKINSETRIN, FKINSETVIN interface to KINSet* functions
    FKINDENSE interfaces to KINDense
+   FKINKLU interfaces to KINKLU
+   FKINSUPERLUMT interfaces to KINSUPERLUMT
+   FKINSPARSESETJAC interfaces to KINSlsSetSparseJacFn
    FKINSPTFQMR interfaces to KINSptfqmr
    FKINSPGMR interfaces to KINSpgmr
+   FKINSPFGMR interfaces to KINSpfgmr
    FKINSPBCG interfaces to KINSpbcg
    FKINSOL interfaces to KINSol and KINGet* functions
    FKINFREE interfaces to KINFree
@@ -50,6 +63,8 @@
               KINDenseJacFn
    FKBJAC   : called by the interface function FKINBandJac of type
               KINBandJacFn
+   FKINSPJAC: called by the interface function FKINSparseJac of type 
+              KINSlsSparseJacFn
    FKJTIMES : called by the interface function FKINJtimes of type
               KINSpilsJacTimesVecFn
    FKPSOL   : called by the interface function FKINPSol of type
@@ -89,7 +104,10 @@
      It must set the FVAL array to f(u), the system function, as a
      function of the array UU = u. Here UU and FVAL are arrays representing
      vectors, which are distributed vectors in the parallel case.
-     IER is a return flag (currently not used).
+     IER is a return flag, which should be 0 if FKFUN was successful.
+     Return IER > 0 if a recoverable error occurred (and KINSOL is to try
+     to recover).  Return IER < 0 if an unrecoverable error occurred.
+     
 
  (2s) Optional user-supplied dense Jacobian approximation routine: FKDJAC
   
@@ -133,7 +151,44 @@
      distributed vectors in the parallel case. FKJTIMES should return IER = 0 
      if successful, or a nonzero IER otherwise.
 
- (5) Initialization:  FNVINITS/FNVINITP and FKINMALLOC
+  (4.1s) User-supplied sparse Jacobian approximation routine: FKINSPJAC
+
+     Required when using the KINKLU or KINSuperLUMT linear solvers, the 
+     user must supply a routine that computes a compressed-sparse-column 
+     [or compressed-sparse-row] approximation of the system Jacobian 
+     J = dF(y)/dy.  If supplied, it must have the following form:
+
+       SUBROUTINE FKINSPJAC(Y, FY, N, NNZ, JDATA, JRVALS, 
+      &                     JCPTRS, WK1, WK2, IER)
+
+     Typically this routine will use only N, NNZ, JDATA, JRVALS and 
+     JCPTRS. It must load the N by N compressed sparse column [or compressed 
+     sparse row] matrix with storage for NNZ nonzeros, stored in the arrays 
+     JDATA (nonzero values), JRVALS (row [or column] indices for each nonzero), 
+     JCOLPTRS (indices for start of each column [or row]), with the Jacobian 
+     matrix at the current (y) in CSC [or CSR] form (see sundials_sparse.h for 
+     more information).
+
+     The arguments are:
+         Y    -- array containing state variables [realtype, input]
+         FY   -- array containing residual values [realtype, input]
+         N    -- number of matrix rows/columns in Jacobian [int, input]
+         NNZ  -- allocated length of nonzero storage [int, input]
+        JDATA -- nonzero values in Jacobian
+                 [realtype of length NNZ, output]
+       JRVALS -- row [or column] indices for each nonzero in Jacobian
+                  [int of length NNZ, output]
+       JCPTRS -- pointers to each Jacobian column [or row] in preceding arrays
+                 [int of length N+1, output]
+         WK*  -- array containing temporary workspace of same size as Y 
+                 [realtype, input]
+         IER  -- return flag [int, output]:
+                    0 if successful, 
+                   >0 if a recoverable error occurred,
+                   <0 if an unrecoverable error ocurred.
+
+ (5) Initialization:  FNVINITS/FNVINITP/FNVINITOMP/FNVINITPTS and 
+                      FKINCREATE and FKININIT 
 
  (5.1s) To initialize the serial machine environment, the user must make
         the following call:
@@ -144,8 +199,8 @@
           NEQ = size of vectors
           IER = return completion flag. Values are 0 = success, -1 = failure.
 
- (5.1p) To initialize the parallel machine environment, the user must make 
-        the following call:
+ (5.1p) To initialize the distributed memory parallel machine environment, 
+        the user must make the following call:
 
           CALL FNVINITP (3, NLOCAL, NGLOBAL, IER)
 
@@ -156,15 +211,31 @@
           IER     = return completion flag. Values are 0 = success,
                     -1 = failure.
 
- (5.2) To allocate internal memory, make the following call:
+ (5.1omp) To initialize the openMP threaded vector kernel, 
+          the user must make the following call:
+
+          CALL FNVINITOMP (3, NEQ, NUM_THREADS, IER)
+
+        The arguments are:
+          NEQ = size of vectors
+          NUM_THREADS = number of threads
+          IER = return completion flag. Values are 0 = success, -1 = failure.
+
+ (5.1pts) To initialize the Pthreads threaded vector kernel, 
+          the user must make the following call:
+
+          CALL FNVINITOMP (3, NEQ, NUM_THREADS, IER)
+
+        The arguments are:
+          NEQ = size of vectors
+          NUM_THREADS = number of threads
+          IER = return completion flag. Values are 0 = success, -1 = failure.
+
+ (5.2) To create the internal memory structure, make the following call:
 
-         CALL FKINMALLOC(IOUT, ROUT, IER)
+         CALL FKINCREATE(IER)
 
        The arguments are:
-         IOUT        = array of length at least 15 for integer optional outputs
-                       (declare as INTEGER*4 or INTEGER*8 according to
-                       C type long int)
-         ROUT        = array of length at least 2 for real optional outputs
          IER         = return completion flag. Values are 0 = success, and
                        -1 = failure.
 
@@ -176,8 +247,8 @@
 
        to set the optional input specified by the character key KEY to the 
        integer value VALUE.
-       KEY is one of the following: PRNT_LEVEL, MAX_NITERS, ETA_FORM, 
-       MAX_SETUPS, MAX_SP_SETUPS, NO_INIT_SETUP, NO_MIN_EPS, NO_RES_MON.
+       KEY is one of the following: 'PRNT_LEVEL', 'MAX_NITERS', 'ETA_FORM', 'MAA',
+       'MAX_SETUPS', 'MAX_SP_SETUPS', 'NO_INIT_SETUP', 'NO_MIN_EPS', 'NO_RES_MON'.
 
        To set various real optional inputs, make the folowing call:
 
@@ -185,9 +256,9 @@
 
       to set the optional input specified by the character key KEY to the
       real value VALUE.
-      KEY is one of the following: FNORM_TOL, SSTEP_TOL, MAX_STEP, RERR_FUNC,
-      ETA_CONST, ETA_PARAMS, RMON_CONST, RMON_PARAMS.
-      Note that if KEY is ETA_PARAMS or RMON_PARAMS, then VALUE must be an
+      KEY is one of the following: 'FNORM_TOL', 'SSTEP_TOL', 'MAX_STEP',
+      'RERR_FUNC', 'ETA_CONST', 'ETA_PARAMS', 'RMON_CONST', 'RMON_PARAMS'.
+      Note that if KEY is 'ETA_PARAMS' or 'RMON_PARAMS', then VALUE must be an
       array of dimension 2.
 
       To set the vector of constraints on the solution, make the following call:
@@ -199,6 +270,21 @@
       FKINSETIIN, FKINSETRIN, and FKINSETVIN return IER=0 if successful and 
       IER<0 if an error occured.
 
+ (5.4) To allocate and initialize the internal memory structure, 
+       make the following call:
+
+         CALL FKININIT(IOUT, ROUT, IER)
+
+       The arguments are:
+         IOUT        = array of length at least 15 for integer optional outputs
+                       (declare as INTEGER*4 or INTEGER*8 according to
+                       C type long int)
+         ROUT        = array of length at least 2 for real optional outputs
+         IER         = return completion flag. Values are 0 = success, and
+                       -1 = failure.
+
+       Note: See printed message for details in case of failure.
+
  (6) Specification of linear system solution method:
 
      The solution method in KINSOL involves the solution of linear systems 
@@ -244,7 +330,96 @@
        with FLAG = 1 to specify that FKBJAC is provided.  (FLAG = 0 specifies
        using the internal finite difference approximation to the Jacobian.)
 
- (6.3) SPTFQMR treatment of the linear systems:
+
+ (6.3s) SPARSE treatment of the linear system using the KLU solver.
+
+     The user must make the call
+
+       CALL FKINKLU(NEQ, NNZ, SPARSETYPE, ORDERING, IER)
+
+     The arguments are:
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	SPARSETYPE = choice between CSC and CSR format
+           (0 = CSC, 1 = CSR) [int; input]
+	ORDERING = the matrix ordering desired, possible values
+	   come from the KLU package (0 = AMD, 1 = COLAMD) [int; input]
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     When using the KLU solver the user must provide the FKINSPJAC routine for the 
+     evalution of the sparse approximation to the Jacobian. To indicate that this
+     routine has been provided, after the call to FKINKLU, the following call must 
+     be made    
+
+       CALL FKINSPARSESETJAC(IER) 
+
+     The int return flag IER=0 if successful, and nonzero otherwise.
+
+
+     The KINSOL KLU solver will reuse much of the factorization information from one
+     nonlinear iteration to the next.  If at any time the user wants to force a full
+     refactorization or if the number of nonzeros in the Jacobian matrix changes, the
+     user should make the call
+
+       CALL FKINKLUREINIT(NEQ, NNZ, REINIT_TYPE)
+
+     The arguments are:
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	REINIT_TYPE = 1 or 2.  For a value of 1, the matrix will be destroyed and 
+          a new one will be allocated with NNZ nonzeros.  For a value of 2, 
+	  only symbolic and numeric factorizations will be completed. 
+ 
+     When using FKINKLU, the user is required to supply the FKINSPJAC 
+     routine for the evaluation of the sparse approximation to the 
+     Jacobian, as discussed above with the other user-supplied routines.
+ 
+     Optional outputs specific to the KLU case are:
+        LSTF    = IOUT(8)  from KINSlsGetLastFlag
+        NJES    = IOUT(10) from KINSlsGetNumJacEvals
+     See the KINSOL manual for descriptions.
+ 
+ (6.4s) SPARSE treatment of the linear system using the SuperLUMT solver.
+
+     The user must make the call
+
+       CALL FKINSUPERLUMT(NTHREADS, NEQ, NNZ, ORDERING, IER)
+
+     The arguments are:
+        NTHREADS = desired number of threads to use [int; input]
+        NEQ = the problem size [int; input]
+        NNZ = the maximum number of nonzeros [int; input]
+	ORDERING = the matrix ordering desired, possible values
+	   come from the SuperLU_MT package [int; input]
+           0 = Natural
+           1 = Minimum degree on A^T A
+           2 = Minimum degree on A^T + A
+           3 = COLAMD
+	IER = error return flag [int, output]: 
+	         0 = success, 
+		 negative = error.
+ 
+     At this time, there is no reinitialization capability for the SUNDIALS 
+     interfaces to the SuperLUMT solver.
+
+     When using FKINSUPERLUMT, the user is required to supply the FKINSPJAC 
+     routine for the evaluation of the CSC approximation to the 
+     Jacobian (note: the current SuperLU_MT interface in SUNDIALS does not 
+     support CSR matrices). To indicate that this routine has been provided, 
+     after the call to FKINSUPERLUMT, the following call must be made    
+
+         CALL FKINSPARSESETJAC(IER) 
+
+     The int return flag IER=0 if successful, and nonzero otherwise.
+ 
+     Optional outputs specific to the SUPERLUMT case are:
+        LSTF    = IOUT(8)  from KINSlsGetLastFlag
+        NJES    = IOUT(10) from KINSlsGetNumJacEvals
+     See the KINSOL manual for descriptions.
+  
+ (6.5) SPTFQMR treatment of the linear systems:
 
        For the Scaled Preconditioned TFQMR solution of the linear systems,
        the user must make the call:
@@ -258,7 +433,7 @@
 
        Note: See printed message for details in case of failure.
 
- (6.4) SPBCG treatment of the linear systems:
+ (6.6) SPBCG treatment of the linear systems:
 
        For the Scaled Preconditioned Bi-CGSTAB solution of the linear systems,
        the user must make the call:
@@ -272,23 +447,24 @@
 
        Note: See printed message for details in case of failure.
 
- (6.5) SPGMR treatment of the linear systems:
+ (6.7) SPGMR and SPFGMR treatment of the linear systems:
 
-       For the Scaled Preconditioned GMRES solution of the linear systems,
-       the user must make the call:
+       For the Scaled Preconditioned GMRES or Scaled Preconditioned Flexible 
+       GMRES solution of the linear systems, the user must make one of the calls:
 
          CALL FKINSPGMR(MAXL, MAXLRST, IER)
+         CALL FKINSPFGMR(MAXL, MAXLRST, IER)
 
        In the above routine, the arguments are as follows:
          MAXL     = maximum Krylov subspace dimension; 0 indicates default.
          MAXLRST  = maximum number of linear system restarts; 0 indicates
-                    default (SPGMR only).
+                    default (SPGMR and SPFGMR only).
          IER      = return completion flag.  Values are 0 = succes, and
                     -1 = failure.
 
        Note: See printed message for details in case of failure.
 
- (6.6) Specifying user-provided functions for the iterative linear solvers
+ (6.8) Specifying user-provided functions for the iterative linear solvers
 
        If the user program includes the FKJTIMES routine for the evaluation
        of the Jacobian-vector product, the following call must be made:
@@ -344,7 +520,8 @@
        UU          = array containing the initial guess on input, and the
                      solution on return
        GLOBALSTRAT = (INTEGER) a number defining the global strategy choice:
-                     0 = No globalization, 1 = LineSearch
+                     0 = No globalization, 1 = LineSearch, 2 = Picard, 
+                     3 = Fixed Point 
        USCALE      = array of scaling factors for the UU vector
        FSCALE      = array of scaling factors for the FVAL (function) vector
        IER         = INTEGER error flag as returned by KINSOL:
@@ -357,8 +534,8 @@
 
  (8) Memory freeing: FKINFREE
 
-     To the free the internal memory created by the calls to FKINMALLOC
-     and either FNVINITS or FNVINITP, make the following call:
+     To the free the internal memory created by the calls to FKINCREATE and 
+     FKININIT and any FNVINIT**, make the following call:
 
        CALL FKINFREE
 
@@ -378,7 +555,7 @@
        FNORM  = ROUT(1) = final scaled norm of f(u)
        STEPL  = ROUT(2) = scaled last step length
 
-     The following optional outputs are specific to the SPGMR/SPBCG/SPTFQMR
+     The following optional outputs are specific to the SPGMR/SPFGMR/SPBCG/SPTFQMR
      module:
 
        LRW    = IOUT( 7) = real workspace size for the linear solver module
@@ -404,21 +581,21 @@
 #ifndef _FKINSOL_H
 #define _FKINSOL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 /*
  * -----------------------------------------------------------------
  * header files
  * -----------------------------------------------------------------
  */
-
 #include <kinsol/kinsol.h>
 #include <sundials/sundials_direct.h>  /* definition of type DlsMat   */
+#include <sundials/sundials_sparse.h>  /* definition of type SlsMat   */
 #include <sundials/sundials_nvector.h> /* definition of type N_Vector */
 #include <sundials/sundials_types.h>   /* definition of type realtype */
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /*
  * -----------------------------------------------------------------
  * generic names are translated through the define statements below
@@ -428,6 +605,8 @@ extern "C" {
 #if defined(SUNDIALS_F77_FUNC)
 
 #define FKIN_MALLOC         SUNDIALS_F77_FUNC(fkinmalloc, FKINMALLOC)
+#define FKIN_CREATE         SUNDIALS_F77_FUNC(fkincreate, FKINCREATE)
+#define FKIN_INIT           SUNDIALS_F77_FUNC(fkininit,   FKININIT)
 #define FKIN_SETIIN         SUNDIALS_F77_FUNC(fkinsetiin, FKINSETIIN)
 #define FKIN_SETRIN         SUNDIALS_F77_FUNC(fkinsetrin, FKINSETRIN)
 #define FKIN_SETVIN         SUNDIALS_F77_FUNC(fkinsetvin, FKINSETVIN)
@@ -439,9 +618,14 @@ extern "C" {
 #define FKIN_LAPACKDENSESETJAC SUNDIALS_F77_FUNC(fkinlapackdensesetjac, FKINLAPACKDENSESETJAC)
 #define FKIN_LAPACKBAND        SUNDIALS_F77_FUNC(fkinlapackband, FKINLAPACKBAND)
 #define FKIN_LAPACKBANDSETJAC  SUNDIALS_F77_FUNC(fkinlapackbandsetjac, FKINLAPACKBANDSETJAC)
+#define FKIN_KLU            SUNDIALS_F77_FUNC(fkinklu, FKLUKLU)
+#define FKIN_KLUREINIT      SUNDIALS_F77_FUNC(fkinklureinit, FKLUKLUREINIT)
+#define FKIN_SUPERLUMT      SUNDIALS_F77_FUNC(fkinsuperlumt, FKLUSUPERLUMT)
+#define FKIN_SPARSESETJAC   SUNDIALS_F77_FUNC(fkinsparsesetjac, FKINSPARSESETJAC)  
 #define FKIN_SPTFQMR        SUNDIALS_F77_FUNC(fkinsptfqmr, FKINSPTFQMR)
 #define FKIN_SPBCG          SUNDIALS_F77_FUNC(fkinspbcg, FKINSPBCG)
 #define FKIN_SPGMR          SUNDIALS_F77_FUNC(fkinspgmr, FKINSPGMR)
+#define FKIN_SPFGMR         SUNDIALS_F77_FUNC(fkinspfgmr, FKINSPFGMR)
 #define FKIN_SPILSSETJAC    SUNDIALS_F77_FUNC(fkinspilssetjac, FKINSPILSSETJAC)
 #define FKIN_SPILSSETPREC   SUNDIALS_F77_FUNC(fkinspilssetprec, FKINSPILSSETPREC)
 #define FKIN_SOL            SUNDIALS_F77_FUNC(fkinsol, FKINSOL)
@@ -456,6 +640,8 @@ extern "C" {
 #else
 
 #define FKIN_MALLOC         fkinmalloc_
+#define FKIN_CREATE         fkincreate_
+#define FKIN_INIT           fkininit_
 #define FKIN_SETIIN         fkinsetiin_
 #define FKIN_SETRIN         fkinsetrin_
 #define FKIN_SETVIN         fkinsetvin_
@@ -467,9 +653,14 @@ extern "C" {
 #define FKIN_LAPACKDENSESETJAC fkinlapackdensesetjac_
 #define FKIN_LAPACKBAND        fkinlapackband_
 #define FKIN_LAPACKBANDSETJAC  fkinlapackbandsetjac_
+#define FKIN_KLU            fkinklu_
+#define FKIN_KLUREINIT      fkinklureinit_
+#define FKIN_SUPERLUMT      fkinsuperlumt_
+#define FKIN_SPARSESETJAC   fkinsparsesetjac_
 #define FKIN_SPTFQMR        fkinsptfqmr_
 #define FKIN_SPBCG          fkinspbcg_
 #define FKIN_SPGMR          fkinspgmr_
+#define FKIN_SPFGMR         fkinspgmr_
 #define FKIN_SPILSSETJAC    fkinspilssetjac_
 #define FKIN_SPILSSETPREC   fkinspilssetprec_
 #define FKIN_SOL            fkinsol_
@@ -490,10 +681,12 @@ extern "C" {
  */
 
 void FKIN_MALLOC(long int *iout, realtype *rout, int *ier);
+void FKIN_CREATE(int *ier);
+void FKIN_INIT(long int *iout, realtype *rout, int *ier);
 
-void FKIN_SETIIN(char key_name[], long int *ival, int *ier, int key_len);
-void FKIN_SETRIN(char key_name[], realtype *rval, int *ier, int key_len);
-void FKIN_SETVIN(char key_name[], realtype *vval, int *ier, int key_len);
+void FKIN_SETIIN(char key_name[], long int *ival, int *ier);
+void FKIN_SETRIN(char key_name[], realtype *rval, int *ier);
+void FKIN_SETVIN(char key_name[], realtype *vval, int *ier);
 
 void FKIN_DENSE(long int *neq, int *ier);
 void FKIN_DENSESETJAC(int *flag, int *ier);
@@ -506,9 +699,15 @@ void FKIN_LAPACKDENSESETJAC(int *flag, int *ier);
 void FKIN_LAPACKBAND(int *neq, int *mupper, int *mlower, int *ier);
 void FKIN_LAPACKBANDSETJAC(int *flag, int *ier);
 
+void FKIN_KLU(int *neq, int *nnz, int *sparsetype, int *ordering, int *ier);
+void FKIN_KLUREINIT(int *neq, int *nnz, int *reinit_type, int *ier);
+void FKIN_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier);
+void FKIN_SPARSESETJAC(int *ier);
+
 void FKIN_SPTFQMR(int *maxl, int *ier);
 void FKIN_SPBCG(int *maxl, int *ier);
 void FKIN_SPGMR(int *maxl, int *maxlrst, int *ier);
+void FKIN_SPFGMR(int *maxl, int *maxlrst, int *ier);
 
 void FKIN_SPILSSETJAC(int *flag, int *ier);
 void FKIN_SPILSSETPREC(int *flag, int *ier);
@@ -546,6 +745,9 @@ int FKINLapackBandJac(long int N, long int mupper, long int mlower,
                       DlsMat J, void *user_data,
                       N_Vector vtemp1, N_Vector vtemp2);
 
+int FKINSparseJac(N_Vector y, N_Vector fval, SlsMat J,
+		  void *user_data, N_Vector vtemp1, N_Vector vtemp2);
+
 int FKINPSet(N_Vector uu, N_Vector uscale,
              N_Vector fval, N_Vector fscale,
              void *user_data,
@@ -575,9 +777,10 @@ extern int KIN_ls;
 
 /* Linear solver IDs */
 
-enum { KIN_LS_SPGMR = 1, KIN_LS_SPBCG = 2, KIN_LS_SPTFQMR = 3, 
-       KIN_LS_DENSE = 4, KIN_LS_BAND  = 5,
-       KIN_LS_LAPACKDENSE = 6, KIN_LS_LAPACKBAND = 7 };
+  enum { KIN_LS_SPGMR = 1, KIN_LS_SPFGMR = 2, KIN_LS_SPBCG = 3, KIN_LS_SPTFQMR = 4, 
+	 KIN_LS_DENSE = 5, KIN_LS_BAND  = 6,
+	 KIN_LS_LAPACKDENSE = 7, KIN_LS_LAPACKBAND = 8,
+         KIN_LS_KLU = 9, KIN_LS_SUPERLUMT = 10 };
 
 #ifdef __cplusplus
 }
diff --git a/src/kinsol/fcmix/fkinsparse.c b/src/kinsol/fcmix/fkinsparse.c
new file mode 100644
index 0000000..c123b07
--- /dev/null
+++ b/src/kinsol/fcmix/fkinsparse.c
@@ -0,0 +1,71 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4815 $
+ * $Date: 2016-07-20 16:51:55 -0700 (Wed, 20 Jul 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ *                Daniel R. Reynolds @ SMU
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fkinsol.h"
+#include "kinsol_impl.h"
+#include <kinsol/kinsol_sparse.h>
+
+/* Prototype of the Fortran routine */
+ 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+ 
+extern void FKIN_SPJAC(realtype *Y, realtype *FY, int *N, int *NNZ, 
+                       realtype *JDATA, int *JRVALS, int *JCPTRS, 
+                       realtype *V1, realtype *V2, int *ier);
+ 
+#ifdef __cplusplus
+}
+#endif
+ 
+/*=============================================================*/
+
+/* Fortran interface to C routine KINSlsSetSparseJacFn; see
+   fkinsol.h for further information */
+void FKIN_SPARSESETJAC(int *ier)
+{
+  *ier = KINSlsSetSparseJacFn(KIN_kinmem, FKINSparseJac);
+}
+
+/*=============================================================*/
+ 
+/* C interface to user-supplied Fortran routine FKINSPJAC; see 
+   fkinsol.h for additional information  */
+int FKINSparseJac(N_Vector y, N_Vector fy, 
+                  SlsMat J, void *user_data, N_Vector vtemp1, 
+                  N_Vector vtemp2)
+{
+  int ier;
+  realtype *ydata, *fydata, *v1data, *v2data;
+ 
+  ydata   = N_VGetArrayPointer(y);
+  fydata  = N_VGetArrayPointer(fy);
+  v1data  = N_VGetArrayPointer(vtemp1);
+  v2data  = N_VGetArrayPointer(vtemp2);
+ 
+  FKIN_SPJAC(ydata, fydata, &(J->NP), &(J->NNZ),
+             J->data, J->indexvals, J->indexptrs,  
+             v1data, v2data, &ier); 
+  return(ier);
+}
+
diff --git a/src/kinsol/fcmix/fkinsuperlumt.c b/src/kinsol/fcmix/fkinsuperlumt.c
new file mode 100644
index 0000000..61874dc
--- /dev/null
+++ b/src/kinsol/fcmix/fkinsuperlumt.c
@@ -0,0 +1,42 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4402 $
+ * $Date: 2015-02-28 19:35:39 -0800 (Sat, 28 Feb 2015) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2015, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the Fortran interface to
+ * the KINSuperLUMT solver. See fkinsol.h for usage.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "fkinsol.h"
+#include "kinsol_impl.h"
+#include <kinsol/kinsol_superlumt.h>
+ 
+/*
+ * ----------------------------------------------------------------
+ * Function : FKIN_SUPERLUMT
+ * ----------------------------------------------------------------
+ */
+
+void FKIN_SUPERLUMT(int *nthreads, int *neq, int *nnz, int *ordering, int *ier)
+{
+  *ier = KINSuperLUMT(KIN_kinmem, *nthreads, *neq, *nnz);
+  KINSuperLUMTSetOrdering(KIN_kinmem, *ordering);
+  KIN_ls = KIN_LS_SUPERLUMT;
+}
+
+
diff --git a/src/kinsol/kinsol.c b/src/kinsol/kinsol.c
index c4bd15d..72903fc 100644
--- a/src/kinsol/kinsol.c
+++ b/src/kinsol/kinsol.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2011/07/13 22:29:01 $
+ * $Revision: 4888 $
+ * $Date: 2016-09-02 13:34:35 -0700 (Fri, 02 Sep 2016) $
  * -----------------------------------------------------------------
- * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
- *                Aaron Collier @ LLNL
+ * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, Carol Woodward,
+ *                John Loffeld, and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the main KINSol solver.
  * It is independent of the KINSol linear solver in use.
@@ -38,6 +43,8 @@
  *     KINFullNewton
  *     KINLineSearch
  *     KINConstraint
+ *     KINFP
+ *     KINPicardAA
  *   Stopping tests
  *     KINStop
  *     KINForcingTerm
@@ -67,6 +74,7 @@
 #include <math.h>
 
 #include "kinsol_impl.h"
+#include "kinsol_spils_impl.h"
 #include <sundials/sundials_math.h>
 
 /* 
@@ -115,7 +123,7 @@
  *    RETRY_ITERATION
  *    CONTINUE_ITERATIONS
  *
- * KINFullNewton and KINLineSearch return values:
+ * KINFullNewton, KINLineSearch, KINFP, and KINPicardAA return values:
  *    KIN_SUCCESS
  *    KIN_SYSFUNC_FAIL
  *    STEP_TOO_SMALL
@@ -165,7 +173,7 @@
 
 static booleantype KINCheckNvector(N_Vector tmpl);
 static booleantype KINAllocVectors(KINMem kin_mem, N_Vector tmpl);
-static int KINSolInit(KINMem kin_mem, int strategy);
+static int KINSolInit(KINMem kin_mem);
 static int KINConstraint(KINMem kin_mem );
 static void KINForcingTerm(KINMem kin_mem, realtype fnormp);
 static void KINFreeVectors(KINMem kin_mem);
@@ -174,11 +182,20 @@ static int  KINFullNewton(KINMem kin_mem, realtype *fnormp,
                           realtype *f1normp, booleantype *maxStepTaken);
 static int  KINLineSearch(KINMem kin_mem, realtype *fnormp, 
                           realtype *f1normp, booleantype *maxStepTaken);
+static int  KINPicardAA(KINMem kin_mem, long int *iter, realtype *R, 
+			realtype *gamma, realtype *fmax);
+static int  KINFP(KINMem kin_mem, long int *iter, realtype *R, 
+		  realtype *gamma, realtype *fmax);
 
 static int  KINLinSolDrv(KINMem kinmem);
+static int  KINPicardFcnEval(KINMem kin_mem, N_Vector gval, N_Vector uval, 
+			     N_Vector fval1);
 static realtype KINScFNorm(KINMem kin_mem, N_Vector v, N_Vector scale);
 static realtype KINScSNorm(KINMem kin_mem, N_Vector v, N_Vector u);
-static int KINStop(KINMem kin_mem, int strategy, booleantype maxStepTaken, int sflag);
+static int KINStop(KINMem kin_mem, booleantype maxStepTaken, 
+		   int sflag);
+static int AndersonAcc(KINMem kin_mem, N_Vector gval, N_Vector fv, N_Vector x, 
+		       N_Vector x_old, int iter, realtype *R, realtype *gamma);
 
 /* 
  * =================================================================
@@ -206,7 +223,7 @@ void *KINCreate(void)
 {
   KINMem kin_mem;
   realtype uround;
-
+ 
   kin_mem = NULL;
   kin_mem = (KINMem) malloc(sizeof(struct KINMemRec));
   if (kin_mem == NULL) {
@@ -228,6 +245,16 @@ void *KINCreate(void)
   kin_mem->kin_constraints      = NULL;
   kin_mem->kin_uscale           = NULL;
   kin_mem->kin_fscale           = NULL;
+  kin_mem->kin_fold_aa          = NULL;
+  kin_mem->kin_gold_aa          = NULL;
+  kin_mem->kin_df_aa            = NULL;
+  kin_mem->kin_dg_aa            = NULL;
+  kin_mem->kin_q_aa             = NULL;
+  kin_mem->kin_gamma_aa         = NULL;
+  kin_mem->kin_R_aa             = NULL;
+  kin_mem->kin_m_aa             = ZERO;
+  kin_mem->kin_aamem_aa         = 0;
+  kin_mem->kin_setstop_aa       = 0;
   kin_mem->kin_constraintsSet   = FALSE;
   kin_mem->kin_ehfun            = KINErrHandler;
   kin_mem->kin_eh_data          = kin_mem;
@@ -245,10 +272,10 @@ void *KINCreate(void)
   kin_mem->kin_mxnbcf           = MXNBCF_DEFAULT;
   kin_mem->kin_sthrsh           = TWO;
   kin_mem->kin_noMinEps         = FALSE;
-  kin_mem->kin_mxnewtstep       = ZERO;
-  kin_mem->kin_sqrt_relfunc     = RSqrt(uround);
-  kin_mem->kin_scsteptol        = RPowerR(uround,TWOTHIRDS);
-  kin_mem->kin_fnormtol         = RPowerR(uround,ONETHIRD);
+  kin_mem->kin_mxnstepin        = ZERO;
+  kin_mem->kin_sqrt_relfunc     = SUNRsqrt(uround);
+  kin_mem->kin_scsteptol        = SUNRpowerR(uround,TWOTHIRDS);
+  kin_mem->kin_fnormtol         = SUNRpowerR(uround,ONETHIRD);
   kin_mem->kin_etaflag          = KIN_ETACHOICE1;
   kin_mem->kin_eta              = POINT1;     /* default for KIN_ETACONSTANT */
   kin_mem->kin_eta_alpha        = TWO;        /* default for KIN_ETACHOICE2  */
@@ -372,6 +399,7 @@ int KINInit(void *kinmem, KINSysFn func, N_Vector tmpl)
 #define egamma           (kin_mem->kin_eta_gamma)
 #define noMinEps         (kin_mem->kin_noMinEps)
 #define mxnewtstep       (kin_mem->kin_mxnewtstep)
+#define mxnstepin        (kin_mem->kin_mxnstepin)
 #define mxnbcf           (kin_mem->kin_mxnbcf)
 #define relfunc          (kin_mem->kin_sqrt_relfunc)
 #define fnormtol         (kin_mem->kin_fnormtol)
@@ -406,13 +434,12 @@ int KINInit(void *kinmem, KINSysFn func, N_Vector tmpl)
 #define uscale           (kin_mem->kin_uscale)
 #define fscale           (kin_mem->kin_fscale)
 #define sJpnorm          (kin_mem->kin_sJpnorm)
-#define sfdotJp          (kin_mem->kin_sfdotJp)
+#define sFdotJp          (kin_mem->kin_sFdotJp)
 #define unew             (kin_mem->kin_unew)
 #define pp               (kin_mem->kin_pp)
 #define vtemp1           (kin_mem->kin_vtemp1)
 #define vtemp2           (kin_mem->kin_vtemp2)
 #define eps              (kin_mem->kin_eps)
-#define res_norm         (kin_mem->kin_res_norm)
 #define liw1             (kin_mem->kin_liw1)
 #define lrw1             (kin_mem->kin_lrw1)
 
@@ -426,6 +453,16 @@ int KINInit(void *kinmem, KINSysFn func, N_Vector tmpl)
 #define omega_min        (kin_mem->kin_omega_min)
 #define omega_max        (kin_mem->kin_omega_max)
 
+#define fold             (kin_mem->kin_fold_aa)
+#define gold             (kin_mem->kin_gold_aa)
+#define df               (kin_mem->kin_df_aa)
+#define dg               (kin_mem->kin_dg_aa)
+#define Q                (kin_mem->kin_q_aa)
+#define maa              (kin_mem->kin_m_aa)
+#define aamem            (kin_mem->kin_aamem_aa)
+#define setstop          (kin_mem->kin_setstop_aa)
+#define strategy         (kin_mem->kin_globalstrategy)
+
 /* 
  * -----------------------------------------------------------------
  * Main solver function
@@ -454,10 +491,10 @@ int KINInit(void *kinmem, KINSysFn func, N_Vector tmpl)
  *  KINStop  determines if an approximate solution has been found
  */
 
-int KINSol(void *kinmem, N_Vector u, int strategy,  
+int KINSol(void *kinmem, N_Vector u, int strategy_in,  
            N_Vector u_scale, N_Vector f_scale)
 {
-  realtype fnormp, f1normp, epsmin;
+  realtype fnormp, f1normp, epsmin, fmax=ZERO;
   KINMem kin_mem;
   int ret, sflag;
   booleantype maxStepTaken;
@@ -489,12 +526,44 @@ int KINSol(void *kinmem, N_Vector u, int strategy,
   uu = u;
   uscale = u_scale;
   fscale = f_scale;
+  strategy = strategy_in;
+
+  /* CSW:  
+     Call fixed point solver if requested.  Note that this should probably
+     be forked off to a FPSOL solver instead of kinsol in the future. */
+  if ( strategy == KIN_FP ) {
+    if (uu == NULL) {
+      KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSol", MSG_UU_NULL);
+      return(KIN_ILL_INPUT);
+    }
 
-  /* initialize solver */
+    if (kin_mem->kin_constraintsSet != FALSE) {
+      KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSol", MSG_CONSTRAINTS_NOTOK);
+      return(KIN_ILL_INPUT);
+    }
 
-  ret = KINSolInit(kin_mem, strategy);
+    if (printfl > 0)
+      KINPrintInfo(kin_mem, PRNT_TOL, "KINSOL", "KINSol", INFO_TOL, scsteptol, fnormtol);
+
+    nfe = nnilset = nnilset_sub = nni = nbcf = nbktrk = 0;
+    ret = KINFP(kin_mem, &nni, kin_mem->kin_R_aa, kin_mem->kin_gamma_aa, &fmax);
+
+    switch(ret) {
+    case KIN_SYSFUNC_FAIL:
+      KINProcessError(kin_mem, KIN_SYSFUNC_FAIL, "KINSOL", "KINSol", MSG_SYSFUNC_FAILED);
+      break;
+    case KIN_MAXITER_REACHED:
+      KINProcessError(kin_mem, KIN_MAXITER_REACHED, "KINSOL", "KINSol", MSG_MAXITER_REACHED);
+      break;
+    }
+
+    return(ret);
+  }
+
+  /* initialize solver */
+  ret = KINSolInit(kin_mem);
   if (ret != KIN_SUCCESS) return(ret);
-  
+
   ncscmx = 0;
 
   /* Note: The following logic allows the choice of whether or not
@@ -515,6 +584,21 @@ int KINSol(void *kinmem, N_Vector u, int strategy,
   if (omega == ZERO) eval_omega = TRUE;
   else               eval_omega = FALSE;
  
+
+  /* CSW:  
+     Call fixed point solver for Picard method if requested.  
+     Note that this should probably be forked off to a part of an 
+     FPSOL solver instead of kinsol in the future. */
+  if ( strategy == KIN_PICARD ) {
+
+    kin_mem->kin_gval = N_VClone(unew);
+    lrw += lrw1;
+    ret = KINPicardAA(kin_mem, &nni, kin_mem->kin_R_aa, kin_mem->kin_gamma_aa, &fmax);
+
+    return(ret);
+  }
+
+
   loop{
 
     retry_nni = FALSE;
@@ -526,16 +610,11 @@ int KINSol(void *kinmem, N_Vector u, int strategy,
 
     if (inexact_ls) {
       eps = (eta + uround) * fnorm;
-      if(!noMinEps) eps = MAX(epsmin, eps);
+      if(!noMinEps) eps = SUNMAX(epsmin, eps);
     }
 
     repeat_nni:
 
-    /* call KINLinSolDrv to calculate the (approximate) Newton step, pp */ 
-
-    ret = KINLinSolDrv(kin_mem);
-    if (ret != KIN_SUCCESS) break;
-
     /* call the appropriate routine to calculate an acceptable step pp */
 
     sflag = 0;
@@ -543,6 +622,11 @@ int KINSol(void *kinmem, N_Vector u, int strategy,
     if (strategy == KIN_NONE) {
 
       /* Full Newton Step*/
+
+      /* call KINLinSolDrv to calculate the (approximate) Newton step, pp */ 
+      ret = KINLinSolDrv(kin_mem);
+      if (ret != KIN_SUCCESS) break;
+
       sflag = KINFullNewton(kin_mem, &fnormp, &f1normp, &maxStepTaken);
 
       /* if sysfunc failed unrecoverably, stop */
@@ -554,6 +638,11 @@ int KINSol(void *kinmem, N_Vector u, int strategy,
     } else if (strategy == KIN_LINESEARCH) {
 
       /* Line Search */
+
+      /* call KINLinSolDrv to calculate the (approximate) Newton step, pp */ 
+      ret = KINLinSolDrv(kin_mem);
+      if (ret != KIN_SUCCESS) break;
+
       sflag = KINLineSearch(kin_mem, &fnormp, &f1normp, &maxStepTaken);
 
       /* if sysfunc failed unrecoverably, stop */
@@ -570,23 +659,23 @@ int KINSol(void *kinmem, N_Vector u, int strategy,
 
     }
 
-    /* evaluate eta by calling the forcing term routine */
-
-    if (callForcingTerm) KINForcingTerm(kin_mem, fnormp);
+    if ( (strategy != KIN_PICARD) && (strategy != KIN_FP) ) {
+      
+      /* evaluate eta by calling the forcing term routine */
+      if (callForcingTerm) KINForcingTerm(kin_mem, fnormp);
 
-    fnorm = fnormp;
+      fnorm = fnormp;
 
-    /* call KINStop to check if tolerances where met by this iteration */
+      /* call KINStop to check if tolerances where met by this iteration */
+      ret = KINStop(kin_mem, maxStepTaken, sflag); 
 
-    ret = KINStop(kin_mem, strategy, maxStepTaken, sflag); 
-
-    if (ret == RETRY_ITERATION) {
-      retry_nni = TRUE;
-      goto repeat_nni;
+      if (ret == RETRY_ITERATION) {
+	retry_nni = TRUE;
+	goto repeat_nni;
+      }
     }
 
     /* update uu after the iteration */
-
     N_VScale(ONE, unew, uu);
 
     f1norm = f1normp;
@@ -602,6 +691,8 @@ int KINSol(void *kinmem, N_Vector u, int strategy,
     
   }  /* end of loop; return */
 
+
+
   if (printfl > 0)
     KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", "KINSol", INFO_RETVAL, ret);
 
@@ -718,8 +809,9 @@ static booleantype KINCheckNvector(N_Vector tmpl)
 
 static booleantype KINAllocVectors(KINMem kin_mem, N_Vector tmpl)
 {
-  /* allocate unew, fval, pp, vtemp1 and vtemp2 */
-  
+  /* allocate unew, fval, pp, vtemp1 and vtemp2. */  
+  /* allocate df, dg, q, for Anderson Acceleration, Broyden and EN */
+ 
   unew = N_VClone(tmpl);
   if (unew == NULL) return(FALSE);
 
@@ -758,6 +850,121 @@ static booleantype KINAllocVectors(KINMem kin_mem, N_Vector tmpl)
   liw += 5*liw1;
   lrw += 5*lrw1;
 
+  if (maa) {
+    kin_mem->kin_R_aa = (realtype *) malloc((maa*maa) * sizeof(realtype));
+    if (kin_mem->kin_R_aa == NULL) {
+      KINProcessError(kin_mem, 0, "KINSOL", "KINAllocVectors", MSG_MEM_FAIL);
+      N_VDestroy(unew);
+      N_VDestroy(fval);
+      N_VDestroy(pp);
+      N_VDestroy(vtemp1);
+      N_VDestroy(vtemp2);
+      return(KIN_MEM_FAIL);
+    }
+    kin_mem->kin_gamma_aa = (realtype *)malloc(maa * sizeof(realtype));
+    if (kin_mem->kin_gamma_aa == NULL) {
+      KINProcessError(kin_mem, 0, "KINSOL", "KINAllocVectors", MSG_MEM_FAIL);
+      N_VDestroy(unew);
+      N_VDestroy(fval);
+      N_VDestroy(pp);
+      N_VDestroy(vtemp1);
+      N_VDestroy(vtemp2);
+      free(kin_mem->kin_R_aa);
+      return(KIN_MEM_FAIL);
+    }
+    kin_mem->kin_ipt_map = (int *)malloc(maa * sizeof(int));
+    if (kin_mem->kin_ipt_map == NULL) {
+      KINProcessError(kin_mem, 0, "KINSOL", "KINAllocVectors", MSG_MEM_FAIL);
+      N_VDestroy(unew);
+      N_VDestroy(fval);
+      N_VDestroy(pp);
+      N_VDestroy(vtemp1);
+      N_VDestroy(vtemp2);
+      free(kin_mem->kin_R_aa);
+      free(kin_mem->kin_gamma_aa);
+      return(KIN_MEM_FAIL);
+    }
+  } 
+
+  if (maa) {
+    fold = N_VClone(tmpl);
+    if (fold == NULL) {
+      N_VDestroy(unew);
+      N_VDestroy(fval);
+      N_VDestroy(pp);
+      N_VDestroy(vtemp1);
+      N_VDestroy(vtemp2);
+      free(kin_mem->kin_R_aa);
+      free(kin_mem->kin_gamma_aa);
+      free(kin_mem->kin_ipt_map);
+      return(FALSE);
+    }
+    gold = N_VClone(tmpl);
+    if (gold == NULL) {
+      N_VDestroy(unew);
+      N_VDestroy(fval);
+      N_VDestroy(pp);
+      N_VDestroy(vtemp1);
+      N_VDestroy(vtemp2);
+      N_VDestroy(fold);
+      return(FALSE);
+    }
+    df = N_VCloneVectorArray(maa,tmpl);
+    if (df == NULL) {
+      N_VDestroy(unew);
+      N_VDestroy(fval);
+      N_VDestroy(pp);
+      N_VDestroy(vtemp1);
+      N_VDestroy(vtemp2);
+      free(kin_mem->kin_R_aa);
+      free(kin_mem->kin_gamma_aa);
+      free(kin_mem->kin_ipt_map);
+      N_VDestroy(fold);
+      N_VDestroy(gold);
+      return(FALSE);
+    }
+    dg = N_VCloneVectorArray(maa,tmpl);
+    if (dg == NULL) {
+      N_VDestroy(unew);
+      N_VDestroy(fval);
+      N_VDestroy(pp);
+      N_VDestroy(vtemp1);
+      N_VDestroy(vtemp2);
+      free(kin_mem->kin_R_aa);
+      free(kin_mem->kin_gamma_aa);
+      free(kin_mem->kin_ipt_map);
+      N_VDestroy(fold);
+      N_VDestroy(gold);
+      N_VDestroyVectorArray(df, maa);
+      return(FALSE);
+    }
+
+    /* update solver workspace lengths */
+
+    liw += 2*maa*liw1+2;
+    lrw += 2*maa*lrw1+2;
+
+    if (aamem) {
+      Q = N_VCloneVectorArray(maa,tmpl);
+      if (Q == NULL) {
+	N_VDestroy(unew);
+	N_VDestroy(fval);
+	N_VDestroy(pp);
+	N_VDestroy(vtemp1);
+	N_VDestroy(vtemp2);
+	free(kin_mem->kin_R_aa);
+	free(kin_mem->kin_gamma_aa);
+	free(kin_mem->kin_ipt_map);
+	N_VDestroy(fold);
+	N_VDestroy(gold);
+	N_VDestroyVectorArray(df, maa);
+	N_VDestroyVectorArray(dg, maa);
+	return(FALSE);
+      }
+      liw += maa*liw1;
+      lrw += maa*lrw1;
+    }
+  }
   return(TRUE);
 }
 
@@ -776,6 +983,31 @@ static void KINFreeVectors(KINMem kin_mem)
   if (vtemp1 != NULL) N_VDestroy(vtemp1);
   if (vtemp2 != NULL) N_VDestroy(vtemp2);
 
+  if ( (kin_mem->kin_globalstrategy == KIN_PICARD) && (kin_mem->kin_gval != NULL) ) 
+    N_VDestroy(kin_mem->kin_gval);
+
+  if ( ((strategy == KIN_PICARD) || (strategy == KIN_FP)) && (maa > 0) ) {
+    free(kin_mem->kin_R_aa);
+    free(kin_mem->kin_gamma_aa);
+    free(kin_mem->kin_ipt_map);
+  }
+
+  if (maa)
+  {
+     if (fold != NULL) N_VDestroy(fold);
+     if (gold != NULL) N_VDestroy(gold);
+     N_VDestroyVectorArray(df,maa);
+     N_VDestroyVectorArray(dg,maa);
+     lrw -= (2*maa*lrw1+2);
+     liw -= (2*maa*liw1+2);
+     if (aamem)
+     {
+        N_VDestroyVectorArray(Q,maa);
+        lrw -= maa*lrw1;
+        liw -= maa*liw1;
+     }
+  }
+
   lrw -= 5*lrw1;
   liw -= 5*liw1;
 
@@ -806,14 +1038,14 @@ static void KINFreeVectors(KINMem kin_mem)
  * The possible return values for KINSolInit are:
  *   KIN_SUCCESS : indicates a normal initialization
  *
- *   KINS_ILL_INPUT : indicates that an input error has been found
+ *   KIN_ILL_INPUT : indicates that an input error has been found
  *
  *   KIN_INITIAL_GUESS_OK : indicates that the guess uu
  *                          satisfied the system func(uu) = 0
  *                          within the tolerances specified
  */
 
-static int KINSolInit(KINMem kin_mem, int strategy)
+static int KINSolInit(KINMem kin_mem)
 {
   int retval;
   realtype fmax;
@@ -825,7 +1057,8 @@ static int KINSolInit(KINMem kin_mem, int strategy)
     return(KIN_ILL_INPUT);
   }
 
-  if ((strategy != KIN_NONE) && (strategy != KIN_LINESEARCH)) {
+  if ( (strategy != KIN_NONE) && (strategy != KIN_LINESEARCH) && 
+       (strategy != KIN_PICARD) && (strategy != KIN_FP) ) {
     KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSolInit", MSG_BAD_GLSTRAT);
     return(KIN_ILL_INPUT);
   }
@@ -850,6 +1083,12 @@ static int KINSolInit(KINMem kin_mem, int strategy)
     return(KIN_ILL_INPUT);
   }
 
+  if ( (constraints != NULL) && ( (strategy == KIN_PICARD) || (strategy == KIN_FP) ) ) {
+    KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSolInit", MSG_CONSTRAINTS_NOTOK);
+    return(KIN_ILL_INPUT);
+  }
+    
+
   /* set the constraints flag */
 
   if (constraints == NULL) 
@@ -879,8 +1118,8 @@ static int KINSolInit(KINMem kin_mem, int strategy)
 
   /* calculate the default value for mxnewtstep (maximum Newton step) */
 
-  if (mxnewtstep == ZERO)
-    mxnewtstep = THOUSAND * N_VWL2Norm(uu, uscale);
+  if (mxnstepin == ZERO) mxnewtstep = THOUSAND * N_VWL2Norm(uu, uscale);
+  else                   mxnewtstep = mxnstepin;
   if (mxnewtstep < ONE) mxnewtstep = ONE;
 
 
@@ -894,9 +1133,10 @@ static int KINSolInit(KINMem kin_mem, int strategy)
 
     /* this value is always used for choice #1 */
 
-    if (etaflag == KIN_ETACHOICE1) ealpha = (ONE + RSqrt(FIVE)) * HALF;
+    if (etaflag == KIN_ETACHOICE1) ealpha = (ONE + SUNRsqrt(FIVE)) * HALF;
 
-    /* initial value for eta set to 0.5 for other than the KIN_ETACONSTANT option */
+    /* initial value for eta set to 0.5 for other than the 
+       KIN_ETACONSTANT option */
 
     if (etaflag != KIN_ETACONSTANT) eta = HALF;
 
@@ -914,24 +1154,28 @@ static int KINSolInit(KINMem kin_mem, int strategy)
 
   nfe = nnilset = nnilset_sub = nni = nbcf = nbktrk = 0;
 
-  /* see if the system func(uu) = 0 is satisfied by the initial guess uu */
-
+  /* see if the initial guess uu satisfies the nonlinear system */
   retval = func(uu, fval, user_data); nfe++;
+
   if (retval < 0) {
-    KINProcessError(kin_mem, KIN_SYSFUNC_FAIL, "KINSOL", "KINSolInit", MSG_SYSFUNC_FAILED);
+    KINProcessError(kin_mem, KIN_SYSFUNC_FAIL, "KINSOL", "KINSolInit", 
+		    MSG_SYSFUNC_FAILED);
     return(KIN_SYSFUNC_FAIL);
   } else if (retval > 0) {
-    KINProcessError(kin_mem, KIN_FIRST_SYSFUNC_ERR, "KINSOL", "KINSolInit", MSG_SYSFUNC_FIRST);
+    KINProcessError(kin_mem, KIN_FIRST_SYSFUNC_ERR, "KINSOL", "KINSolInit", 
+		    MSG_SYSFUNC_FIRST);
     return(KIN_FIRST_SYSFUNC_ERR);
   }
 
   fmax = KINScFNorm(kin_mem, fval, fscale);
+  if (fmax <= (POINT01 * fnormtol)) {
+    kin_mem->kin_fnorm = N_VWL2Norm(fval, fscale);
+    return(KIN_INITIAL_GUESS_OK);
+  }
 
   if (printfl > 1)
     KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", "KINSolInit", INFO_FMAX, fmax);
-
-  if (fmax <= (POINT01 * fnormtol)) return(KIN_INITIAL_GUESS_OK);
-
+  
   /* initialize the linear solver if linit != NULL */
 
   if (linit != NULL) {
@@ -946,11 +1190,11 @@ static int KINSolInit(KINMem kin_mem, int strategy)
 
   fnorm = N_VWL2Norm(fval, fscale);
   f1norm = HALF * fnorm * fnorm;
-
   fnorm_sub = fnorm;
 
   if (printfl > 0)
-    KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINSolInit", INFO_NNI, nni, nfe, fnorm);
+    KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINSolInit", 
+		 INFO_NNI, nni, nfe, fnorm);
 
   /* problem has now been successfully initialized */
 
@@ -1005,14 +1249,14 @@ static int KINLinSolDrv(KINMem kin_mem)
 
     /* call the generic 'lsolve' routine to solve the system Jx = b */
 
-    retval = lsolve(kin_mem, x, b, &res_norm);
+    retval = lsolve(kin_mem, x, b, &sJpnorm, &sFdotJp);
 
     if (retval == 0)                          return(KIN_SUCCESS);
     else if (retval < 0)                      return(KIN_LSOLVE_FAIL);
     else if ((!setupNonNull) || (jacCurrent)) return(KIN_LINSOLV_NO_RECOVERY);
 
-    /* loop back only if the linear solver setup is in use and Jacobian information
-       is not current */
+    /* loop back only if the linear solver setup is in use 
+       and Jacobian information is not current */
 
     sthrsh = TWO;
 
@@ -1102,9 +1346,9 @@ static int KINFullNewton(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
   *fnormp = N_VWL2Norm(fval,fscale);
   *f1normp = HALF * (*fnormp) * (*fnormp);
 
-  /* scale sfdotJp and sJpnorm by ratio for later use in KINForcingTerm */
+  /* scale sFdotJp and sJpnorm by ratio for later use in KINForcingTerm */
 
-  sfdotJp *= ratio;
+  sFdotJp *= ratio;
   sJpnorm *= ratio;
  
   if (printfl > 1) 
@@ -1143,7 +1387,7 @@ static int KINFullNewton(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
  *  rlmin = --------------------------
  *          ||           pp         ||
  *          || -------------------- ||_L-infinity
- *          || (1/uscale + ABS(uu)) ||
+ *          || (1/uscale + SUNRabs(uu)) ||
  *
  *
  * If the system function fails unrecoverably at any time, KINLineSearch 
@@ -1158,7 +1402,7 @@ static int KINFullNewton(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
  * If the step size is limited due to constraint violations and/or 
  * recoverable system function failures, we set rlmax=1 to ensure
  * that the update remains feasible during the attempts to enforce 
- * the beta-condition (this is not an isse while enforcing the alpha
+ * the beta-condition (this is not an issue while enforcing the alpha
  * condition, as rl can only decrease from 1 at that stage)
  */
 
@@ -1257,7 +1501,7 @@ static int KINLineSearch(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
 
   /* Estimate the line search value rl (lambda) to satisfy both ALPHA and BETA conditions */
 
-  slpi = sfdotJp * ratio;
+  slpi = sFdotJp * ratio;
   rlength = KINScSNorm(kin_mem, pp, uu);
   rlmin = scsteptol / rlength;
   rl = ONE;
@@ -1299,10 +1543,10 @@ static int KINLineSearch(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
       rl_b *= tmp1;
       disc = (rl_b * rl_b) - (THREE * rl_a * slpi);
 
-      if (ABS(rl_a) < uround) {        /* cubic is actually just a quadratic (rl_a ~ 0) */
+      if (SUNRabs(rl_a) < uround) {        /* cubic is actually just a quadratic (rl_a ~ 0) */
         rltmp = -slpi / (TWO * rl_b);
       } else {                         /* real cubic */
-        rltmp = (-rl_b + RSqrt(disc)) / (THREE * rl_a);
+        rltmp = (-rl_b + SUNRsqrt(disc)) / (THREE * rl_a);
       }
     }
       if (rltmp > (HALF * rl)) rltmp = HALF * rl;
@@ -1312,7 +1556,7 @@ static int KINLineSearch(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
     rlprev = rl;
     f1nprv = (*f1normp);
     pt1trl = POINT1 * rl;
-    rl = MAX(pt1trl, rltmp);
+    rl = SUNMAX(pt1trl, rltmp);
     nbktrk_l++;
 
     /* Update unew and re-evaluate function */
@@ -1352,7 +1596,7 @@ static int KINLineSearch(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
 
         rlprev = rl;
         f1nprv = *f1normp;
-        rl = MIN((TWO * rl), rlmax);
+        rl = SUNMIN((TWO * rl), rlmax);
         nbktrk_l++;
 
         N_VLinearSum(ONE, uu, rl, pp, unew);
@@ -1371,12 +1615,12 @@ static int KINLineSearch(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
       } while (((*f1normp) <= alpha_cond) && 
 	       ((*f1normp) < beta_cond) && (rl < rlmax));
 
-    } /* enf if (rl == ONE) block */
+    } /* end if (rl == ONE) block */
 
     if ((rl < ONE) || ((rl > ONE) && (*f1normp > alpha_cond))) {
 
-      rllo = MIN(rl, rlprev);
-      rldiff = ABS(rlprev - rl);
+      rllo = SUNMIN(rl, rlprev);
+      rldiff = SUNRabs(rlprev - rl);
 
       do {
 
@@ -1406,9 +1650,10 @@ static int KINLineSearch(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
       } while ((*f1normp > alpha_cond) ||
 	       ((*f1normp < beta_cond) && (rldiff >= rlmin)));
 
-      if ((*f1normp) < beta_cond) {
+      if ( (*f1normp < beta_cond) || ((rldiff < rlmin) && (*f1normp > alpha_cond)) ) {
 
-	/* beta condition could not be satisfied so set unew to last u value
+	/* beta condition could not be satisfied or rldiff too small 
+	   and alpha_cond not satisfied, so set unew to last u value
 	   that satisfied the alpha condition and continue */
 
         N_VLinearSum(ONE, uu, rllo, pp, unew);
@@ -1434,9 +1679,9 @@ static int KINLineSearch(KINMem kin_mem, realtype *fnormp, realtype *f1normp,
   if (printfl > 1)
     KINPrintInfo(kin_mem, PRNT_ADJ, "KINSOL", "KINLineSearch", INFO_ADJ, nbktrk_l);
 
-  /* scale sfdotJp and sJpnorm by rl * ratio for later use in KINForcingTerm */
+  /* scale sFdotJp and sJpnorm by rl * ratio for later use in KINForcingTerm */
 
-  sfdotJp = sfdotJp * rl * ratio;
+  sFdotJp = sFdotJp * rl * ratio;
   sJpnorm = sJpnorm * rl * ratio;
 
   if ((rl * pnorm) > (POINT99 * mxnewtstep)) *maxStepTaken = TRUE;
@@ -1465,7 +1710,7 @@ static int KINConstraint(KINMem kin_mem)
 
   if(N_VConstrMask(constraints, vtemp1, vtemp2)) return(KIN_SUCCESS);
 
-  /* vtemp1[i] = ABS(pp[i]) */
+  /* vtemp1[i] = SUNRabs(pp[i]) */
 
   N_VAbs(pp, vtemp1);
 
@@ -1495,7 +1740,7 @@ static int KINConstraint(KINMem kin_mem)
  * sflag    is one of KIN_SUCCESS, STEP_TOO_SMALL
  */
 
-static int KINStop(KINMem kin_mem, int strategy, booleantype maxStepTaken, int sflag)
+static int KINStop(KINMem kin_mem, booleantype maxStepTaken, int sflag)
 {
   realtype fmax, rlength, omexp;
   N_Vector delta;
@@ -1507,7 +1752,7 @@ static int KINStop(KINMem kin_mem, int strategy, booleantype maxStepTaken, int s
     if (setupNonNull && !jacCurrent) {
       /* If the Jacobian is out of date, update it and retry */
       sthrsh = TWO;
-      return(CONTINUE_ITERATIONS);
+      return(RETRY_ITERATION);
     } else {
       /* Give up */
       if (strategy == KIN_NONE)  return(KIN_STEP_LT_STPTOL);
@@ -1579,17 +1824,17 @@ static int KINStop(KINMem kin_mem, int strategy, booleantype maxStepTaken, int s
 
       /* If indicated, estimate new OMEGA value */
       if (eval_omega) {
-        omexp = MAX(ZERO,(fnorm/fnormtol)-ONE);
-        omega = (omexp > TWELVE)? omega_max : MIN(omega_min*EXP(omexp), omega_max);
+        omexp = SUNMAX(ZERO,(fnorm/fnormtol)-ONE);
+        omega = (omexp > TWELVE)? omega_max : SUNMIN(omega_min*SUNRexp(omexp), omega_max);
       }   
       /* Check if making satisfactory progress */
 
       if (fnorm > omega*fnorm_sub) {
-        /* Insuficient progress */
+        /* Insufficient progress */
 	if (setupNonNull && !jacCurrent) {
           /* If the Jacobian is out of date, update it and retry */
 	  sthrsh = TWO;
-	  return(RETRY_ITERATION);
+          return(CONTINUE_ITERATIONS);
 	} else {
           /* Otherwise, we cannot do anything, so just return. */
         }
@@ -1650,27 +1895,27 @@ static void KINForcingTerm(KINMem kin_mem, realtype fnormp)
 
     /* compute the norm of f + Jp , scaled L2 norm */
 
-    linmodel_norm = RSqrt((fnorm * fnorm) + (TWO * sfdotJp) + (sJpnorm * sJpnorm));
+    linmodel_norm = SUNRsqrt((fnorm * fnorm) + (TWO * sFdotJp) + (sJpnorm * sJpnorm));
 
     /* form the safeguarded for choice #1 */ 
 
-    eta_safe = RPowerR(eta, ealpha); 
-    eta = ABS(fnormp - linmodel_norm) / fnorm; 
+    eta_safe = SUNRpowerR(eta, ealpha); 
+    eta = SUNRabs(fnormp - linmodel_norm) / fnorm;
   }
 
   /* choice #2 forcing term */
 
   if (etaflag == KIN_ETACHOICE2) {
-    eta_safe = egamma * RPowerR(eta, ealpha); 
-    eta = egamma * RPowerR((fnormp / fnorm), ealpha); 
+    eta_safe = egamma * SUNRpowerR(eta, ealpha); 
+    eta = egamma * SUNRpowerR((fnormp / fnorm), ealpha); 
   }
 
   /* apply safeguards */
  
   if(eta_safe < POINT1) eta_safe = ZERO;
-  eta = MAX(eta, eta_safe); 
-  eta = MAX(eta, eta_min); 
-  eta = MIN(eta, eta_max); 
+  eta = SUNMAX(eta, eta_safe);
+  eta = SUNMAX(eta, eta_min);
+  eta = SUNMIN(eta, eta_max);
 
   return; 
 }
@@ -1848,13 +2093,13 @@ void KINInfoHandler(const char *module, const char *function,
  * =================================================================
  */
 
-/* 
+/*
  * KINProcessError 
  *
- * Thi is a high level error handling function
- * - if cv_mem==NULL it prints the error message to stderr
- * - otherwise, it sets-up and calls the error hadling function 
- *   pointed to by cv_ehfun
+ * KINProcessError is a high level error handling function.
+ * - If cv_mem==NULL it prints the error message to stderr.
+ * - Otherwise, it sets up and calls the error handling function 
+ *   pointed to by cv_ehfun.
  */
 
 #define ehfun    (kin_mem->kin_ehfun)
@@ -1872,32 +2117,24 @@ void KINProcessError(KINMem kin_mem,
 
   va_start(ap, msgfmt);
 
-  if (kin_mem == NULL) {    /* We write to stderr */
+  /* Compose the message */
 
+  vsprintf(msg, msgfmt, ap);
+
+  if (kin_mem == NULL) {    /* We write to stderr */
 #ifndef NO_FPRINTF_OUTPUT
     fprintf(stderr, "\n[%s ERROR]  %s\n  ", module, fname);
-    fprintf(stderr, msgfmt);
-    fprintf(stderr, "\n\n");
+    fprintf(stderr, "%s\n\n", msg);
 #endif
 
   } else {                 /* We can call ehfun */
-
-    /* Compose the message */
-
-    vsprintf(msg, msgfmt, ap);
-
-    /* Call ehfun */
-
     ehfun(error_code, module, fname, msg, eh_data);
-
   }
 
   /* Finalize argument processing */
-  
   va_end(ap);
 
   return;
-
 }
 
 /* 
@@ -1934,3 +2171,374 @@ void KINErrHandler(int error_code, const char *module,
   return;
 }
 
+
+/*
+ * =======================================================================
+ * Picard and fixed point solvers
+ * =======================================================================
+ */
+
+/*
+ * KINPicardAA
+ *
+ * This routine is the main driver for the Picard iteration with 
+ * acclerated fixed point. 
+ */
+
+static int KINPicardAA(KINMem kin_mem, long int *iterp, realtype *R, 
+                       realtype *gamma, realtype *fmaxptr)
+{
+  int retval, ret; 
+  long int iter;
+  realtype fmax, epsmin, fnormp;
+  N_Vector delta, gval;
+  
+  delta = kin_mem->kin_vtemp1;
+  gval = kin_mem->kin_gval;
+  ret = CONTINUE_ITERATIONS;
+  fmax = fnormtol + ONE;
+  iter = 0;
+  epsmin = ZERO;
+  fnormp = -ONE;
+
+  N_VConst(ZERO, gval);
+
+  /* if eps is to be bounded from below, set the bound */
+  if (inexact_ls && !noMinEps) epsmin = POINT01 * fnormtol;
+
+  while (ret == CONTINUE_ITERATIONS) {
+
+    iter++;
+
+    /* Update the forcing term for the inexact linear solves */
+    if (inexact_ls) {
+      eps = (eta + uround) * fnorm;
+      if(!noMinEps) eps = SUNMAX(epsmin, eps);
+    }
+
+    /* evaluate g = uu - L^{-1}func(uu) and return if failed.  
+       For Picard, assume that the fval vector has been filled 
+       with an eval of the nonlinear residual prior to this call. */
+    retval = KINPicardFcnEval(kin_mem, gval, uu, fval);
+
+    if (retval < 0) {
+      ret = KIN_SYSFUNC_FAIL;
+      break;
+    }
+
+    if (maa == 0) { 
+      N_VScale(ONE, gval, unew);
+    }
+    else {  /* use Anderson, if desired */
+      N_VScale(ONE, uu, unew);
+      AndersonAcc(kin_mem, gval, delta, unew, uu, (int)(iter-1), R, gamma);
+    }
+
+    /* Fill the Newton residual based on the new solution iterate */
+    retval = func(unew, fval, user_data); nfe++;
+    
+    if (retval < 0) {
+      ret = KIN_SYSFUNC_FAIL;
+      break;
+    }
+
+    /* Evaluate function norms */
+    fnormp = N_VWL2Norm(fval,fscale);
+    fmax = KINScFNorm(kin_mem, fval, fscale); /* measure  || F(x) ||_max */
+    fnorm = fmax;
+    *fmaxptr = fmax;
+    
+    if (printfl > 1) 
+      KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", "KINPicardAA", INFO_FMAX, fmax);
+
+    /* print the current iter, fnorm, and nfe values if printfl > 0 */
+    if (printfl>0)
+      KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINPicardAA", INFO_NNI, iter, nfe, fnorm);
+
+    /* Check if the maximum number of iterations is reached */
+    if (iter >= mxiter) {
+      ret = KIN_MAXITER_REACHED;
+    }
+    if (fmax <= fnormtol) { 
+      ret = KIN_SUCCESS;
+    }
+
+    /* Update with new iterate. */
+    N_VScale(ONE, unew, uu);
+
+    if (ret == CONTINUE_ITERATIONS) { 
+      /* evaluate eta by calling the forcing term routine */
+      if (callForcingTerm) KINForcingTerm(kin_mem, fnormp);
+    }
+
+    fflush(errfp);
+    
+  }  /* end of loop; return */
+
+  *iterp = iter;
+
+  if (printfl > 0)
+    KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", "KINPicardAA", INFO_RETVAL, ret);
+
+  return(ret); 
+}
+
+/*
+ * KINPicardFcnEval
+ *
+ * This routine evaluates the Picard fixed point function
+ * using the linear solver, gval = u - L^{-1}F(u).
+ * The function assumes the user has defined L either through
+ * a user-supplied matvec if using a SPILS solver or through
+ * a supplied matrix if using a dense solver.  This assumption is
+ * tested by a check on the strategy and the requisite functionality
+ * within the linear solve routines.
+ *
+ * This routine fills gval = uu - L^{-1}F(uu) given uu and fval = F(uu).
+ */ 
+
+static int KINPicardFcnEval(KINMem kin_mem, N_Vector gval, N_Vector uval, N_Vector fval1)
+{
+  int retval;
+
+  if ((nni - nnilset) >= msbset) {
+    sthrsh = TWO;
+    update_fnorm_sub = TRUE;
+  }
+
+  loop{
+
+    jacCurrent = FALSE;
+
+    if ((sthrsh > ONEPT5) && setupNonNull) {
+      retval = lsetup(kin_mem);
+      jacCurrent = TRUE;
+      nnilset = nni;
+      nnilset_sub = nni;
+      if (retval != 0) return(KIN_LSETUP_FAIL);
+    }
+
+    /* call the generic 'lsolve' routine to solve the system Lx = -fval
+       Note that we are using gval to hold x. */
+    N_VScale(-ONE, fval1, fval1);
+    retval = lsolve(kin_mem, gval, fval1, &sJpnorm, &sFdotJp);
+
+    if (retval == 0) {
+      /* Update gval = uval + gval since gval = -L^{-1}F(uu)  */
+      N_VLinearSum(ONE, uval, ONE, gval, gval);
+      return(KIN_SUCCESS);
+    }
+    else if (retval < 0)                      return(KIN_LSOLVE_FAIL);
+    else if ((!setupNonNull) || (jacCurrent)) return(KIN_LINSOLV_NO_RECOVERY);
+
+    /* loop back only if the linear solver setup is in use
+       and matrix information is not current */
+
+    sthrsh = TWO;
+  }
+
+}
+
+
+/*
+ * KINFP
+ *
+ * This routine is the main driver for the fixed point iteration with
+ * Anderson Acceleration.
+ */
+
+static int KINFP(KINMem kin_mem, long int *iterp, 
+		 realtype *R, realtype *gamma, 
+		 realtype *fmaxptr)
+{
+  int retval, ret; 
+  long int iter;
+  realtype fmax;
+  N_Vector delta;
+  
+  delta = kin_mem->kin_vtemp1;
+  ret = CONTINUE_ITERATIONS;
+  fmax = fnormtol + ONE;
+  iter = 0;
+
+  while (ret == CONTINUE_ITERATIONS) {
+
+    iter++;
+
+    /* evaluate func(uu) and return if failed */
+    retval = func(uu, fval, user_data); nfe++;
+
+    if (retval < 0) {
+      ret = KIN_SYSFUNC_FAIL;
+      break;
+    }
+
+    if (maa == 0) { 
+      N_VScale(ONE, fval, unew);
+    }
+    else {  /* use Anderson, if desired */
+      AndersonAcc(kin_mem, fval, delta, unew, uu, (int)(iter-1), R, gamma);
+    }
+
+    N_VLinearSum(ONE, unew, -ONE, uu, delta);
+    fmax = KINScFNorm(kin_mem, delta, fscale); /* measure  || g(x)-x || */
+    
+    if (printfl > 1) 
+      KINPrintInfo(kin_mem, PRNT_FMAX, "KINSOL", "KINFP", INFO_FMAX, fmax);
+    
+    fnorm = fmax;
+    *fmaxptr = fmax;
+
+    /* print the current iter, fnorm, and nfe values if printfl > 0 */
+    if (printfl>0)
+      KINPrintInfo(kin_mem, PRNT_NNI, "KINSOL", "KINFP", INFO_NNI, iter, nfe, fnorm);
+
+    /* Check if the maximum number of iterations is reached */
+    if (iter >= mxiter) {
+      ret = KIN_MAXITER_REACHED;
+    }
+    if (fmax <= fnormtol) { 
+      ret = KIN_SUCCESS;
+    }
+    
+    if (ret == CONTINUE_ITERATIONS) { 
+      /* Only update solution if taking a next iteration.  */
+      /* CSW  Should put in a conditional to send back the newest iterate or
+	 the one consistent with the fval */
+      N_VScale(ONE, unew, uu);
+    }
+
+    fflush(errfp);
+    
+  }  /* end of loop; return */
+
+  *iterp = iter;
+
+  if (printfl > 0)
+    KINPrintInfo(kin_mem, PRNT_RETVAL, "KINSOL", "KINFP", INFO_RETVAL, ret);
+
+  return(ret); 
+} 
+
+
+ /* -----------------------------------------------------------------
+ * Stopping tests
+ * -----------------------------------------------------------------
+ */
+
+
+/*
+ * ========================================================================
+ * Anderson Acceleration
+ * ========================================================================
+ */
+
+static int AndersonAcc(KINMem kin_mem, N_Vector gval, N_Vector fv, 
+		       N_Vector x, N_Vector xold, 
+		       int iter, realtype *R, realtype *gamma)
+{
+  int i_pt, i, j, lAA;
+  int *ipt_map;
+  realtype alfa;
+  realtype a, b, temp, c, s;
+
+  ipt_map = kin_mem->kin_ipt_map;
+  i_pt = iter-1 - ((iter-1)/maa)*maa;
+  N_VLinearSum(ONE, gval, -1.0, xold, fv);
+  if (iter > 0) {
+    /* compute dg_new = gval -gval_old*/
+    N_VLinearSum(ONE, gval, -1.0, gold, dg[i_pt]);
+    /* compute df_new = fval - fval_old */
+    N_VLinearSum(ONE, fv, -1.0, fold, df[i_pt]);
+  }
+
+  N_VScale(ONE, gval, gold);
+  N_VScale(ONE, fv, fold);
+
+  if (iter == 0) {
+    N_VScale(ONE, gval, x);
+  }
+  else {
+    if (iter == 1) {
+      R[0] = sqrt(N_VDotProd(df[i_pt],df[i_pt]));
+      alfa = 1/R[0];
+      N_VScale(alfa,df[i_pt],Q[i_pt]);
+      ipt_map[0] = 0;
+    }
+    else if (iter <= maa) {
+      N_VScale(ONE,df[i_pt],vtemp2);
+      for (j=0; j < (iter-1); j++) {
+        ipt_map[j] = j;
+        R[(iter-1)*maa+j] = N_VDotProd(Q[j],vtemp2);
+        N_VLinearSum(ONE,vtemp2,-R[(iter-1)*maa+j],Q[j],vtemp2);
+      }
+      R[(iter-1)*maa+iter-1] = sqrt(N_VDotProd(vtemp2,vtemp2));
+      N_VScale((1/R[(iter-1)*maa+iter-1]),vtemp2,Q[i_pt]);
+      ipt_map[iter-1] = iter-1;
+    }
+    else {
+      /* Delete left-most column vector from QR factorization */
+      for (i=0; i < maa-1; i++) {
+        a = R[(i+1)*maa + i];
+        b = R[(i+1)*maa + i+1];
+        temp = sqrt(a*a + b*b);
+        c = a / temp;
+        s = b / temp;
+        R[(i+1)*maa + i] = temp;
+        R[(i+1)*maa + i+1] = 0.0;
+	/* OK to re-use temp */
+        if (i < maa-1) {
+          for (j = i+2; j < maa; j++) {
+            a = R[j*maa + i];
+            b = R[j*maa + i+1];
+            temp = c * a + s * b;
+            R[j*maa + i+1] = -s*a + c*b;
+            R[j*maa + i] = temp;
+	  }
+	}
+        N_VLinearSum(c, Q[i], s, Q[i+1], vtemp2);
+        N_VLinearSum(-s, Q[i], c, Q[i+1], Q[i+1]);
+        N_VScale(ONE, vtemp2, Q[i]);
+      }
+
+      /* Shift R to the left by one. */
+      for (i = 1; i < maa; i++) {
+        for (j = 0; j < maa-1; j++) {
+          R[(i-1)*maa + j] = R[i*maa + j];
+        }
+      }
+
+      /* Add the new df vector */
+      N_VScale(ONE,df[i_pt],vtemp2);
+      for (j=0; j < (maa-1); j++) {
+        R[(maa-1)*maa+j] = N_VDotProd(Q[j],vtemp2);
+        N_VLinearSum(ONE,vtemp2,-R[(maa-1)*maa+j],Q[j],vtemp2);
+      }
+      R[(maa-1)*maa+maa-1] = sqrt(N_VDotProd(vtemp2,vtemp2));
+      N_VScale((1/R[(maa-1)*maa+maa-1]),vtemp2,Q[maa-1]);
+
+      /* Update the iteration map */
+      j = 0;
+      for (i=i_pt+1; i < maa; i++)
+        ipt_map[j++] = i;
+      for (i=0; i < (i_pt+1); i++)
+        ipt_map[j++] = i;
+    }
+
+    /* Solve least squares problem and update solution */
+    lAA = iter;
+    if (maa < iter) lAA = maa;
+    N_VScale(ONE, gval, x);
+    for (i=0; i < lAA; i++)
+      gamma[i] = N_VDotProd(fv,Q[i]);
+    for (i=lAA-1; i > -1; i--) {
+      for (j=i+1; j < lAA; j++) {
+        gamma[i] = gamma[i]-R[j*maa+i]*gamma[j]; 
+      }
+      gamma[i] = gamma[i]/R[i*maa+i];
+      N_VLinearSum(ONE,x,-gamma[i],dg[ipt_map[i]],x);
+    }
+  }
+
+  return 0;
+}
diff --git a/src/kinsol/kinsol_band.c b/src/kinsol/kinsol_band.c
index f975a5e..79b7109 100644
--- a/src/kinsol/kinsol_band.c
+++ b/src/kinsol/kinsol_band.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2011/03/23 23:37:59 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the KINBAND linear solver.
  * -----------------------------------------------------------------
@@ -39,8 +44,8 @@
 static int kinBandInit(KINMem kin_mem);
 static int kinBandSetup(KINMem kin_mem);
 static int kinBandsolve(KINMem kin_mem, N_Vector x, N_Vector b,
-                        realtype *res_norm);
-static void kinBandFree(KINMem kin_mem);
+                        realtype *sJpnorm, realtype *sFdotJp);
+static int kinBandFree(KINMem kin_mem);
 
 /*
  * =================================================================
@@ -63,14 +68,13 @@ static void kinBandFree(KINMem kin_mem);
 #define uscale         (kin_mem->kin_uscale)
 #define fscale         (kin_mem->kin_fscale)
 #define sqrt_relfunc   (kin_mem->kin_sqrt_relfunc)
-#define sJpnorm        (kin_mem->kin_sJpnorm)
-#define sfdotJp        (kin_mem->kin_sfdotJp)
 #define errfp          (kin_mem->kin_errfp)
 #define infofp         (kin_mem->kin_infofp)
 #define setupNonNull   (kin_mem->kin_setupNonNull)
 #define vtemp1         (kin_mem->kin_vtemp1)
 #define vec_tmpl       (kin_mem->kin_vtemp1)
 #define vtemp2         (kin_mem->kin_vtemp2)
+#define strategy       (kin_mem->kin_globalstrategy)
 
 #define mtype          (kindls_mem->d_type)
 #define n              (kindls_mem->d_n)
@@ -159,6 +163,8 @@ int KINBand(void *kinmem, long int N, long int mupper, long int mlower)
   J_data = NULL;
   last_flag = KINDLS_SUCCESS;
 
+  kinDlsInitializeCounters(kindls_mem);
+
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -176,7 +182,7 @@ int KINBand(void *kinmem, long int N, long int mupper, long int mlower)
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(N-1, mu + ml);
+  smu = SUNMIN(N-1, mu + ml);
 
   /* Allocate memory for J and pivot array */
   J = NULL;
@@ -226,8 +232,7 @@ static int kinBandInit(KINMem kin_mem)
 
   kindls_mem = (KINDlsMem) lmem;
 
-  nje   = 0;
-  nfeDQ = 0;
+  kinDlsInitializeCounters(kindls_mem);
 
   if (jacDQ) {
     bjac = kinDlsBandDQJac;
@@ -236,6 +241,14 @@ static int kinBandInit(KINMem kin_mem)
     J_data = kin_mem->kin_user_data;
   }
 
+  /* Stop Picard solve if user fails to provide Jacobian */
+  if ( (strategy == KIN_PICARD) && jacDQ )
+    {
+      KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "kinBandInit", 
+		      MSG_NOL_FAIL);
+      return(KIN_ILL_INPUT);
+    }
+
   last_flag = KINDLS_SUCCESS;
   return(0);
 }
@@ -247,9 +260,8 @@ static int kinBandInit(KINMem kin_mem)
  * This routine does the setup operations for the band linear solver.
  * It makes a decision whether or not to call the Jacobian evaluation
  * routine based on various state variables, and if not it uses the 
- * saved copy.  In any case, it constructs the Newton matrix 
- * M = I - gamma*J, updates counters, and calls the band LU 
- * factorization routine.
+ * saved copy.  In any case, it constructs the Newton matrix J,
+ * updates counters, and calls the band LU factorization routine.
  * -----------------------------------------------------------------
  */
 
@@ -285,10 +297,12 @@ static int kinBandSetup(KINMem kin_mem)
  * -----------------------------------------------------------------
  * This routine handles the solve operation for the band linear solver
  * by calling the band backsolve routine.  The return value is 0.
+ * The argument *sJpnorm is ignored.
  * -----------------------------------------------------------------
  */
 
-static int kinBandsolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_norm)
+static int kinBandsolve(KINMem kin_mem, N_Vector x, N_Vector b,
+                        realtype *sJpnorm, realtype *sFdotJp)
 {
   KINDlsMem kindls_mem;
   realtype *xd;
@@ -305,23 +319,18 @@ static int kinBandsolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_no
 
   BandGBTRS(J, lpivots, xd);
 
-  /* Compute the terms Jpnorm and sfdotJp for use in the global strategy
-     routines and in KINForcingTerm. Both of these terms are subsequently
-     corrected if the step is reduced by constraints or the line search.
-     
-     sJpnorm is the norm of the scaled product (scaled by fscale) of
-     the current Jacobian matrix J and the step vector p.
+  /* Compute the term sFdotJp for use in the linesearch routine.
+     This term is subsequently corrected if the step is reduced by
+     constraints or the linesearch.
 
-     sfdotJp is the dot product of the scaled f vector and the scaled
-     vector J*p, where the scaling uses fscale. */
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
 
-  sJpnorm = N_VWL2Norm(b,fscale);
   N_VProd(b, fscale, b);
   N_VProd(b, fscale, b);
-  sfdotJp = N_VDotProd(fval, b);
+  *sFdotJp = N_VDotProd(fval, b);
 
   last_flag = KINDLS_SUCCESS;
-
   return(0);
 }
 
@@ -333,7 +342,7 @@ static int kinBandsolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_no
  * -----------------------------------------------------------------
  */
 
-static void kinBandFree(KINMem kin_mem)
+static int kinBandFree(KINMem kin_mem)
 {
   KINDlsMem kindls_mem;
 
@@ -342,5 +351,7 @@ static void kinBandFree(KINMem kin_mem)
   DestroyMat(J);
   DestroyArray(lpivots);
   free(kindls_mem); kindls_mem = NULL;
+
+  return(0);
 }
 
diff --git a/src/kinsol/kinsol_bbdpre.c b/src/kinsol/kinsol_bbdpre.c
index 54fa840..05e880a 100644
--- a/src/kinsol/kinsol_bbdpre.c
+++ b/src/kinsol/kinsol_bbdpre.c
@@ -1,7 +1,7 @@
 /*
  *-----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:43:33 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  *-----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
@@ -58,7 +58,7 @@ static int KINBBDPrecSolve(N_Vector uu, N_Vector uscale,
 
 /* Prototype for KINBBDPrecFree */
 
-static void KINBBDPrecFree(KINMem kin_mem);
+static int KINBBDPrecFree(KINMem kin_mem);
 
 /* Prototype for difference quotient jacobian calculation routine */
 
@@ -136,16 +136,16 @@ int KINBBDPrecInit(void *kinmem, long int Nlocal,
   pdata->kin_mem = kinmem;
   pdata->gloc = gloc;
   pdata->gcomm = gcomm;
-  pdata->mudq = MIN(Nlocal-1, MAX(0, mudq));
-  pdata->mldq = MIN(Nlocal-1, MAX(0, mldq));
-  muk = MIN(Nlocal-1, MAX(0,mukeep));
-  mlk = MIN(Nlocal-1, MAX(0,mlkeep));
+  pdata->mudq = SUNMIN(Nlocal-1, SUNMAX(0, mudq));
+  pdata->mldq = SUNMIN(Nlocal-1, SUNMAX(0, mldq));
+  muk = SUNMIN(Nlocal-1, SUNMAX(0,mukeep));
+  mlk = SUNMIN(Nlocal-1, SUNMAX(0,mlkeep));
   pdata->mukeep = muk;
   pdata->mlkeep = mlk;
 
   /* allocate memory for preconditioner matrix */
 
-  storage_mu = MIN(Nlocal-1, muk+mlk);
+  storage_mu = SUNMIN(Nlocal-1, muk+mlk);
   pdata->PP = NULL;
   pdata->PP = NewBandMat(Nlocal, muk, mlk, storage_mu);
   if (pdata->PP == NULL) {
@@ -181,7 +181,7 @@ int KINBBDPrecInit(void *kinmem, long int Nlocal,
   /* set rel_uu based on input value dq_rel_uu */
 
   if (dq_rel_uu > ZERO) pdata->rel_uu = dq_rel_uu;
-  else pdata->rel_uu = RSqrt(uround);  /* using dq_rel_uu = 0.0 means use default */
+  else pdata->rel_uu = SUNRsqrt(uround);  /* using dq_rel_uu = 0.0 means use default */
 
   /* store Nlocal to be used by the preconditioner routines */
 
@@ -193,7 +193,12 @@ int KINBBDPrecInit(void *kinmem, long int Nlocal,
   pdata->ipwsize = Nlocal + 1;
   pdata->nge = 0;
 
-  /* Overwrite the P_data field in the SPILS memory */
+  /* make sure s_P_data is free from any previous allocations */
+  if (kinspils_mem->s_pfree != NULL) {
+    kinspils_mem->s_pfree(kin_mem);
+  }
+
+  /* Point to the new P_data field in the SPILS memory */
   kinspils_mem->s_P_data = pdata;
 
   /* Attach the pfree function */
@@ -362,7 +367,7 @@ static int KINBBDPrecSetup(N_Vector uu, N_Vector uscale,
     return(-1);
   }
 
-  nge += (1 + MIN(mldq+mudq+1, Nlocal));
+  nge += (1 + SUNMIN(mldq+mudq+1, Nlocal));
 
   /* do LU factorization of P in place (in PP) */
 
@@ -426,15 +431,15 @@ static int KINBBDPrecSolve(N_Vector uu, N_Vector uscale,
 }
 
 
-static void KINBBDPrecFree(KINMem kin_mem)
+static int KINBBDPrecFree(KINMem kin_mem)
 {
   KINSpilsMem kinspils_mem;
   KBBDPrecData pdata;
 
-  if (kin_mem->kin_lmem == NULL) return;
+  if (kin_mem->kin_lmem == NULL) return(0);
   kinspils_mem = (KINSpilsMem) kin_mem->kin_lmem;
   
-  if (kinspils_mem->s_P_data == NULL) return;
+  if (kinspils_mem->s_P_data == NULL) return(0);
   pdata = (KBBDPrecData) kinspils_mem->s_P_data;
 
   N_VDestroy(vtemp3);
@@ -443,6 +448,8 @@ static void KINBBDPrecFree(KINMem kin_mem)
 
   free(pdata);
   pdata = NULL;
+
+  return(0);
 }
 
 
@@ -502,7 +509,7 @@ static int KBBDDQJac(KBBDPrecData pdata,
   /* set bandwidth and number of column groups for band differencing */
 
   width = mldq + mudq + 1;
-  ngroups = MIN(width, Nlocal);
+  ngroups = SUNMIN(width, Nlocal);
 
   /* loop over groups */
   
@@ -511,7 +518,7 @@ static int KBBDDQJac(KBBDPrecData pdata,
     /* increment all u_j in group */
 
     for(j = group - 1; j < Nlocal; j += width) {
-      inc = rel_uu * MAX(ABS(udata[j]), (ONE / uscdata[j]));
+      inc = rel_uu * SUNMAX(SUNRabs(udata[j]), (ONE / uscdata[j]));
       utempdata[j] += inc;
     }
   
@@ -525,10 +532,10 @@ static int KBBDDQJac(KBBDPrecData pdata,
     for (j = group - 1; j < Nlocal; j += width) {
       utempdata[j] = udata[j];
       col_j = BAND_COL(PP,j);
-      inc = rel_uu * MAX(ABS(udata[j]) , (ONE / uscdata[j]));
+      inc = rel_uu * SUNMAX(SUNRabs(udata[j]) , (ONE / uscdata[j]));
       inc_inv = ONE / inc;
-      i1 = MAX(0, (j - mukeep));
-      i2 = MIN((j + mlkeep), (Nlocal - 1));
+      i1 = SUNMAX(0, (j - mukeep));
+      i2 = SUNMIN((j + mlkeep), (Nlocal - 1));
       for (i = i1; i <= i2; i++)
 	BAND_COL_ELEM(col_j, i, j) = inc_inv * (gtempdata[i] - gudata[i]);
     }
diff --git a/src/kinsol/kinsol_bbdpre_impl.h b/src/kinsol/kinsol_bbdpre_impl.h
index 5775bce..1ff6de0 100644
--- a/src/kinsol/kinsol_bbdpre_impl.h
+++ b/src/kinsol/kinsol_bbdpre_impl.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 22:43:33 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  *  -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * KINBBDPRE module header file (private version)
  * -----------------------------------------------------------------
@@ -18,14 +23,14 @@
 #ifndef _KINBBDPRE_IMPL_H
 #define _KINBBDPRE_IMPL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <kinsol/kinsol_bbdpre.h>
 #include <sundials/sundials_band.h>
 #include "kinsol_impl.h"
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /*
  * -----------------------------------------------------------------
  * Definition of KBBDData
diff --git a/src/kinsol/kinsol_dense.c b/src/kinsol/kinsol_dense.c
index 70f0e03..c55e317 100644
--- a/src/kinsol/kinsol_dense.c
+++ b/src/kinsol/kinsol_dense.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2010/12/01 22:43:33 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the KINDENSE linear solver.
  * -----------------------------------------------------------------
@@ -39,8 +44,8 @@
 static int kinDenseInit(KINMem kin_mem);
 static int kinDenseSetup(KINMem kin_mem);
 static int kinDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b,
-                         realtype *res_norm);
-static void kinDenseFree(KINMem kin_mem);
+                         realtype *sJpnorm, realtype *sFdotJp);
+static int kinDenseFree(KINMem kin_mem);
 
 /*
  * =================================================================
@@ -63,14 +68,13 @@ static void kinDenseFree(KINMem kin_mem);
 #define uscale         (kin_mem->kin_uscale)
 #define fscale         (kin_mem->kin_fscale)
 #define sqrt_relfunc   (kin_mem->kin_sqrt_relfunc)
-#define sJpnorm        (kin_mem->kin_sJpnorm)
-#define sfdotJp        (kin_mem->kin_sfdotJp)
 #define errfp          (kin_mem->kin_errfp)
 #define infofp         (kin_mem->kin_infofp)
 #define setupNonNull   (kin_mem->kin_setupNonNull)
 #define vtemp1         (kin_mem->kin_vtemp1)
 #define vec_tmpl       (kin_mem->kin_vtemp1)
 #define vtemp2         (kin_mem->kin_vtemp2)
+#define strategy       (kin_mem->kin_globalstrategy)
 
 #define mtype          (kindls_mem->d_type)
 #define n              (kindls_mem->d_n)
@@ -159,6 +163,8 @@ int KINDense(void *kinmem, long int N)
   J_data = NULL;
   last_flag = KINDLS_SUCCESS;
 
+  kinDlsInitializeCounters(kindls_mem);
+
   setupNonNull = TRUE;
 
   /* Set problem dimension */
@@ -213,8 +219,7 @@ static int kinDenseInit(KINMem kin_mem)
 
   kindls_mem = (KINDlsMem) lmem;
   
-  nje   = 0;
-  nfeDQ = 0;
+  kinDlsInitializeCounters(kindls_mem);
   
   if (jacDQ) {
     djac = kinDlsDenseDQJac;
@@ -222,6 +227,12 @@ static int kinDenseInit(KINMem kin_mem)
   } else {
     J_data = kin_mem->kin_user_data;
   }
+  
+  if ( (strategy == KIN_PICARD) && jacDQ ) {
+    KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINDenseInit", 
+		    MSG_NOL_FAIL);
+    return(KIN_ILL_INPUT);
+  }
 
   last_flag = KINDLS_SUCCESS;
   return(0);
@@ -268,10 +279,12 @@ static int kinDenseSetup(KINMem kin_mem)
  * -----------------------------------------------------------------
  * This routine handles the solve operation for the dense linear solver
  * by calling the dense backsolve routine.  The returned value is 0.
+ * The argument *sJpnorm is ignored.
  * -----------------------------------------------------------------
  */
 
-static int kinDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_norm)
+static int kinDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+                         realtype *sJpnorm, realtype *sFdotJp)
 {
   KINDlsMem kindls_mem;
   realtype *xd;
@@ -288,23 +301,18 @@ static int kinDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_n
   
   DenseGETRS(J, lpivots, xd);
 
-  /* Compute the terms Jpnorm and sfdotJp for use in the global strategy
-     routines and in KINForcingTerm. Both of these terms are subsequently
-     corrected if the step is reduced by constraints or the line search.
+  /* Compute the term sFdotJp for use in the linesearch routine.
+     This term is subsequently corrected if the step is reduced by
+     constraints or the linesearch.
 
-     sJpnorm is the norm of the scaled product (scaled by fscale) of
-     the current Jacobian matrix J and the step vector p.
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
 
-     sfdotJp is the dot product of the scaled f vector and the scaled
-     vector J*p, where the scaling uses fscale. */
-
-  sJpnorm = N_VWL2Norm(b,fscale);
   N_VProd(b, fscale, b);
   N_VProd(b, fscale, b);
-  sfdotJp = N_VDotProd(fval, b);
+  *sFdotJp = N_VDotProd(fval, b);
 
   last_flag = KINDLS_SUCCESS;
-
   return(0);
 }
 
@@ -316,7 +324,7 @@ static int kinDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_n
  * -----------------------------------------------------------------
  */
 
-static void kinDenseFree(KINMem kin_mem)
+static int kinDenseFree(KINMem kin_mem)
 {
   KINDlsMem  kindls_mem;
 
@@ -325,5 +333,7 @@ static void kinDenseFree(KINMem kin_mem)
   DestroyMat(J);
   DestroyArray(lpivots);
   free(kindls_mem); kindls_mem = NULL;
+
+  return(0);
 }
 
diff --git a/src/kinsol/kinsol_direct.c b/src/kinsol/kinsol_direct.c
index 8365aaf..3ef5d65 100644
--- a/src/kinsol/kinsol_direct.c
+++ b/src/kinsol/kinsol_direct.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:43:33 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the KINDLS linear solvers
  * -----------------------------------------------------------------
@@ -386,7 +391,7 @@ int kinDlsDenseDQJac(long int N,
     ujsaved = u_data[j];
     ujscale = ONE/uscale_data[j];
     sign = (ujsaved >= ZERO) ? ONE : -ONE;
-    inc = sqrt_relfunc*MAX(ABS(ujsaved), ujscale)*sign;
+    inc = sqrt_relfunc*SUNMAX(SUNRabs(ujsaved), ujscale)*sign;
     u_data[j] += inc;
 
     retval = func(u, ftemp, user_data);
@@ -457,13 +462,13 @@ int kinDlsBandDQJac(long int N, long int mupper, long int mlower,
 
   /* Set bandwidth and number of column groups for band differencing */
   width = mlower + mupper + 1;
-  ngroups = MIN(width, N);
+  ngroups = SUNMIN(width, N);
   
   for (group=1; group <= ngroups; group++) {
     
     /* Increment all utemp components in group */
     for(j=group-1; j < N; j+=width) {
-      inc = sqrt_relfunc*MAX(ABS(u_data[j]), ABS(uscale_data[j]));
+      inc = sqrt_relfunc*SUNMAX(SUNRabs(u_data[j]), ONE/SUNRabs(uscale_data[j]));
       utemp_data[j] += inc;
     }
 
@@ -475,10 +480,10 @@ int kinDlsBandDQJac(long int N, long int mupper, long int mlower,
     for (j=group-1; j < N; j+=width) {
       utemp_data[j] = u_data[j];
       col_j = BAND_COL(Jac,j);
-      inc = sqrt_relfunc*MAX(ABS(u_data[j]), ABS(uscale_data[j]));
+      inc = sqrt_relfunc*SUNMAX(SUNRabs(u_data[j]), ONE/SUNRabs(uscale_data[j]));
       inc_inv = ONE/inc;
-      i1 = MAX(0, j-mupper);
-      i2 = MIN(j+mlower, N-1);
+      i1 = SUNMAX(0, j-mupper);
+      i2 = SUNMIN(j+mlower, N-1);
       for (i=i1; i <= i2; i++)
         BAND_COL_ELEM(col_j,i,j) = inc_inv * (futemp_data[i] - fu_data[i]);
     }
@@ -489,3 +494,12 @@ int kinDlsBandDQJac(long int N, long int mupper, long int mlower,
 
   return(0);
 }
+
+
+int kinDlsInitializeCounters(KINDlsMem kindls_mem)
+{
+  kindls_mem->d_nje   = 0;
+  kindls_mem->d_nfeDQ = 0;
+  
+  return(0);
+}
diff --git a/src/kinsol/kinsol_direct_impl.h b/src/kinsol/kinsol_direct_impl.h
index c46a500..db1e2f0 100644
--- a/src/kinsol/kinsol_direct_impl.h
+++ b/src/kinsol/kinsol_direct_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2010/12/01 22:43:33 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common implementation header file for the KINDLS linear solvers.
  * -----------------------------------------------------------------
@@ -17,12 +22,12 @@
 #ifndef _KINDLS_IMPL_H
 #define _KINDLS_IMPL_H
 
+#include <kinsol/kinsol_direct.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <kinsol/kinsol_direct.h>
-
 
 /*
  * -----------------------------------------------------------------
@@ -69,14 +74,17 @@ typedef struct KINDlsMemRec {
  */
 
 int kinDlsDenseDQJac(long int N,
-		     N_Vector u, N_Vector fu,
-		     DlsMat Jac, void *data,
-		     N_Vector tmp1, N_Vector tmp2);
+                     N_Vector u, N_Vector fu,
+                     DlsMat Jac, void *data,
+                     N_Vector tmp1, N_Vector tmp2);
 
 int kinDlsBandDQJac(long int N, long int mupper, long int mlower,
-		    N_Vector u, N_Vector fu,
-		    DlsMat Jac, void *data,
-		    N_Vector tmp1, N_Vector tmp2);
+                    N_Vector u, N_Vector fu,
+                    DlsMat Jac, void *data,
+                    N_Vector tmp1, N_Vector tmp2);
+
+/* Auxilliary functions */
+int kinDlsInitializeCounters(KINDlsMem kindls_mem);
 
 /*
  * -----------------------------------------------------------------
diff --git a/src/kinsol/kinsol_impl.h b/src/kinsol/kinsol_impl.h
index 9943c00..7994b5d 100644
--- a/src/kinsol/kinsol_impl.h
+++ b/src/kinsol/kinsol_impl.h
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2009/03/29 23:28:01 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * KINSOL solver module header file (private version)
  * -----------------------------------------------------------------
@@ -18,14 +23,14 @@
 #ifndef _KINSOL_IMPL_H
 #define _KINSOL_IMPL_H
 
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
 #include <stdarg.h>
 
 #include <kinsol/kinsol.h>
 
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
 /*
  * =================================================================
  *   M A I N    S O L V E R    M E M O R Y    B L O C K
@@ -66,7 +71,8 @@ typedef struct KINMemRec {
   realtype kin_fnormtol;       /* stopping tolerance on L2-norm of function
 				  value                                        */
   realtype kin_scsteptol;      /* scaled step length tolerance                 */
-  int kin_globalstrategy;      /* choices are KIN_NONE and KIN_LINESEARCH      */
+  int kin_globalstrategy;      /* choices are KIN_NONE, KIN_LINESEARCH
+				  KIN_PICARD and KIN_FP                        */
   int kin_printfl;             /* level of verbosity of output                 */
   long int kin_mxiter;         /* maximum number of nonlinear iterations       */
   long int kin_msbset;         /* maximum number of nonlinear iterations that
@@ -98,6 +104,7 @@ typedef struct KINMemRec {
 				       algorithm)                              */
 
   realtype kin_mxnewtstep;     /* maximum allowable scaled step length         */
+  realtype kin_mxnstepin;      /* input (or preset) value for mxnewtstep       */
   realtype kin_sqrt_relfunc;   /* relative error bound for func(u)             */
   realtype kin_stepl;          /* scaled length of current step                */
   realtype kin_stepmul;        /* step scaling factor                          */
@@ -137,6 +144,10 @@ typedef struct KINMemRec {
   N_Vector kin_fval;        /* vector containing result of nonlinear system
 			       function evaluated at a given iterate
 			       (fval = func(uu))                               */
+  N_Vector kin_gval;        /* vector containing result of the fixed point 
+			       function evaluated at a given iterate; 
+			       used in KIN_PICARD strategy only.
+			       (gval = uu - L^{-1}fval(uu))                    */
   N_Vector kin_uscale;      /* iterate scaling vector                          */
   N_Vector kin_fscale;      /* fval scaling vector                             */
   N_Vector kin_pp;          /* incremental change vector (pp = unew-uu)        */
@@ -144,6 +155,19 @@ typedef struct KINMemRec {
   N_Vector kin_vtemp1;      /* scratch vector #1                               */
   N_Vector kin_vtemp2;      /* scratch vector #2                               */
 
+  /* space requirements for AA, Broyden and NLEN */ 
+  N_Vector kin_fold_aa;	    /* vector needed for AA, Broyden, and NLEN */
+  N_Vector kin_gold_aa;	    /* vector needed for AA, Broyden, and NLEN */
+  N_Vector *kin_df_aa;	    /* vector array needed for AA, Broyden, and NLEN */
+  N_Vector *kin_dg_aa;	    /* vector array needed for AA, Broyden and NLEN */
+  N_Vector *kin_q_aa;	    /* vector array needed for AA */
+  realtype *kin_gamma_aa;   /* array of size maa used in AA */
+  realtype *kin_R_aa;       /* array of size maa*maa used in AA */
+  int      *kin_ipt_map;    /* array of size maa used in AA */
+  long int kin_m_aa;	    /* parameter for AA, Broyden or NLEN */
+  booleantype kin_aamem_aa; /* sets additional memory needed for Anderson Acc */
+  booleantype kin_setstop_aa; /* determines whether user will set stopping criterion */
+
   /* space requirements for vector storage */ 
 
   long int kin_lrw1;        /* number of realtype-sized memory blocks needed
@@ -164,9 +188,9 @@ typedef struct KINMemRec {
   int (*kin_lsetup)(struct KINMemRec *kin_mem);
 
   int (*kin_lsolve)(struct KINMemRec *kin_mem, N_Vector xx, N_Vector bb, 
-		    realtype *res_norm );
+		    realtype *sJpnorm, realtype *sFdotJp);
 
-  void (*kin_lfree)(struct KINMemRec *kin_mem);
+  int (*kin_lfree)(struct KINMemRec *kin_mem);
 
   booleantype kin_inexact_ls; /* flag set by the linear solver module
 				 (in linit) indicating whether this is an
@@ -177,11 +201,10 @@ typedef struct KINMemRec {
 
   realtype kin_fnorm;     /* value of L2-norm of fscale*fval                   */
   realtype kin_f1norm;    /* f1norm = 0.5*(fnorm)^2                            */
-  realtype kin_res_norm;  /* value of L2-norm of residual (set by the linear
-			     solver)                                           */
-  realtype kin_sfdotJp;   /* value of scaled func(u) vector (fscale*fval)
-			     dotted with scaled J(u)*pp vector                 */
-  realtype kin_sJpnorm;   /* value of L2-norm of fscale*(J(u)*pp)              */
+  realtype kin_sFdotJp;   /* value of scaled F(u) vector (fscale*fval)
+                             dotted with scaled J(u)*pp vector (set by lsolve) */
+  realtype kin_sJpnorm;   /* value of L2-norm of fscale*(J(u)*pp)
+                             (set by lsolve)                                   */
 
   realtype kin_fnorm_sub; /* value of L2-norm of fscale*fval (subinterval)     */
   booleantype kin_eval_omega; /* flag indicating that omega must be evaluated. */
@@ -196,7 +219,7 @@ typedef struct KINMemRec {
   /*
    * -----------------------------------------------------------------
    * Note: The KINLineSearch subroutine scales the values of the
-   * variables sfdotJp and sJpnorm by a factor rl (lambda) that is
+   * variables sFdotJp and sJpnorm by a factor rl (lambda) that is
    * chosen by the line search algorithm such that the sclaed Newton
    * step satisfies the following conditions:
    *
@@ -278,7 +301,7 @@ typedef struct KINMemRec {
 /*
  * -----------------------------------------------------------------
  * Function : int (*kin_lsolve)(KINMem kin_mem, N_Vector xx,
- *                              N_Vector bb, realtype *res_norm)
+ *                N_Vector bb, realtype *sJpnorm, realtype *sFdotJp)
  * -----------------------------------------------------------------
  * kin_lsolve interfaces with the subroutine implementing the
  * numerical method to be used to solve the linear system J*xx = bb,
@@ -299,8 +322,11 @@ typedef struct KINMemRec {
  *      value of the system function evaluated at the current
  *      iterate) by KINLinSolDrv before kin_lsolve is called
  *
- *  res_norm  holds the value of the L2-norm (Euclidean norm) of
- *            the residual vector upon return
+ *  sJpnorm  holds the value of the L2-norm (Euclidean norm) of
+ *           fscale*(J(u)*pp) upon return
+ *
+ *  sFdotJp  holds the value of the scaled F(u) (fscale*F) dotted
+ *           with the scaled J(u)*pp vector upon return
  *
  * If successful, the kin_lsolve routine should return 0 (zero).
  * Otherwise it should return a positive value if a re-evaluation
@@ -311,11 +337,12 @@ typedef struct KINMemRec {
 
 /*
  * -----------------------------------------------------------------
- * Function : void (*kin_lfree)(KINMem kin_mem)
+ * Function : int (*kin_lfree)(KINMem kin_mem)
  * -----------------------------------------------------------------
  * kin_lfree is called by KINFree and should free (deallocate) all
  * system memory resources allocated for the linear solver module
- * (see KINSpgmrFree/KINSpbcgFree).
+ * (see KINSpgmrFree/KINSpbcgFree).  It should return 0 upon 
+ * success, nonzero on failure.
  *
  *  kinmem  pointer to an internal memory block allocated during
  *          prior calls to KINCreate and KINMalloc
@@ -379,6 +406,8 @@ void KINInfoHandler(const char *module, const char *function,
 #define MSG_BAD_MXNBCF         "mxbcf < 0 illegal."
 #define MSG_BAD_CONSTRAINTS    "Illegal values in constraints vector."
 #define MSG_BAD_OMEGA          "scalars < 0 illegal."
+#define MSG_BAD_MAA            "maa < 0 illegal."
+#define MSG_ZERO_MAA           "maa = 0 illegal."
 
 #define MSG_LSOLV_NO_MEM       "The linear solver memory pointer is NULL."
 #define MSG_UU_NULL            "uu = NULL illegal."
@@ -387,6 +416,7 @@ void KINInfoHandler(const char *module, const char *function,
 #define MSG_USCALE_NONPOSITIVE "uscale has nonpositive elements."
 #define MSG_BAD_FSCALE         "fscale = NULL illegal."
 #define MSG_FSCALE_NONPOSITIVE "fscale has nonpositive elements."
+#define MSG_CONSTRAINTS_NOTOK  "Constraints not allowed with fixed point or Picard iterations"
 #define MSG_INITIAL_CNSTRNT    "Initial guess does NOT meet constraints."
 #define MSG_LINIT_FAIL         "The linear solver's init routine failed."
 
@@ -400,6 +430,7 @@ void KINInfoHandler(const char *module, const char *function,
 #define MSG_MAXITER_REACHED     "The maximum number of iterations was reached before convergence."
 #define MSG_MXNEWT_5X_EXCEEDED  "Five consecutive steps have been taken that satisfy a scaled step length test."
 #define MSG_SYSFUNC_REPTD       "Unable to correct repeated recoverable system function errors."
+#define MSG_NOL_FAIL            "Unable to find user's Linear Jacobian, which is required for the KIN_PICARD Strategy"
 
 /*
  * =================================================================
diff --git a/src/kinsol/kinsol_io.c b/src/kinsol/kinsol_io.c
index ec3a933..08d67b3 100644
--- a/src/kinsol/kinsol_io.c
+++ b/src/kinsol/kinsol_io.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2010/12/01 22:43:33 $
+ * $Revision: 4368 $
+ * $Date: 2015-02-12 12:25:15 -0800 (Thu, 12 Feb 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Allan Taylor, Alan Hindmarsh, Radu Serban, and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the optional input and output
  * functions for the KINSOL solver.
@@ -185,6 +190,61 @@ int KINSetUserData(void *kinmem, void *user_data)
 
 /*
  * -----------------------------------------------------------------
+ * Function : KINSetMAA
+ * -----------------------------------------------------------------
+ */
+
+int KINSetMAA(void *kinmem, long int maa)
+{
+  KINMem kin_mem;
+
+  if (kinmem == NULL) {
+    KINProcessError(NULL, KIN_MEM_NULL, "KINSOL", "KINSetMAA", MSG_NO_MEM);
+    return(KIN_MEM_NULL);
+  }
+
+  kin_mem = (KINMem) kinmem;
+
+  if (maa < 0) {
+    KINProcessError(NULL, KIN_ILL_INPUT, "KINSOL", "KINSetMAA", MSG_BAD_MAA);
+    return(KIN_ILL_INPUT);
+  }
+
+  if (maa > kin_mem->kin_mxiter) maa = kin_mem->kin_mxiter;
+
+  kin_mem = (KINMem) kinmem;
+  kin_mem->kin_m_aa = maa;
+  kin_mem->kin_aamem_aa = (maa == 0) ? FALSE : TRUE;
+
+  return(KIN_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSetAAStopCrit
+ * -----------------------------------------------------------------
+ */
+
+/*  CSW: This function is currently not supported.
+
+int KINSetAAStopCrit(void *kinmem, booleantype setstop)
+{
+  KINMem kin_mem;
+
+  if (kinmem == NULL) {
+    KINProcessError(NULL, KIN_MEM_NULL, "KINSOL", "KINSetAAStopCrit", MSG_NO_MEM);
+    return(KIN_MEM_NULL);
+  }
+
+  kin_mem = (KINMem) kinmem;
+  kin_mem->kin_setstop_aa = setstop;
+
+  return(KIN_SUCCESS);
+}
+*/
+
+/*
+ * -----------------------------------------------------------------
  * Function : KINSetNumMaxIters
  * -----------------------------------------------------------------
  */
@@ -547,9 +607,9 @@ int KINSetMaxNewtonStep(void *kinmem, realtype mxnewtstep)
   }
 
   /* Note: passing a value of 0.0 will use the default
-     value (computed in KINSolinit) */
+     value (computed in KINSolInit) */
 
-  kin_mem->kin_mxnewtstep = mxnewtstep;
+  kin_mem->kin_mxnstepin = mxnewtstep;
 
   return(KIN_SUCCESS);
 }
@@ -610,9 +670,9 @@ int KINSetRelErrFunc(void *kinmem, realtype relfunc)
 
   if (relfunc == ZERO) {
     uround = kin_mem->kin_uround;
-    kin_mem->kin_sqrt_relfunc = RSqrt(uround);
+    kin_mem->kin_sqrt_relfunc = SUNRsqrt(uround);
   } else {
-    kin_mem->kin_sqrt_relfunc = RSqrt(relfunc);
+    kin_mem->kin_sqrt_relfunc = SUNRsqrt(relfunc);
   }
 
   return(KIN_SUCCESS);
@@ -643,7 +703,7 @@ int KINSetFuncNormTol(void *kinmem, realtype fnormtol)
 
   if (fnormtol == ZERO) {
     uround = kin_mem->kin_uround;
-    kin_mem->kin_fnormtol = RPowerR(uround,ONETHIRD);
+    kin_mem->kin_fnormtol = SUNRpowerR(uround,ONETHIRD);
   } else {
     kin_mem->kin_fnormtol = fnormtol;
   }
@@ -676,7 +736,7 @@ int KINSetScaledStepTol(void *kinmem, realtype scsteptol)
 
   if (scsteptol == ZERO) {
     uround = kin_mem->kin_uround;
-    kin_mem->kin_scsteptol = RPowerR(uround,TWOTHIRDS);
+    kin_mem->kin_scsteptol = SUNRpowerR(uround,TWOTHIRDS);
   } else {
     kin_mem->kin_scsteptol = scsteptol;
   }
@@ -905,7 +965,7 @@ int KINGetFuncNorm(void *kinmem, realtype *funcnorm)
   }
 
   kin_mem = (KINMem) kinmem;
-  *funcnorm = fnorm;
+  *funcnorm = kin_mem->kin_fnorm;
 
   return(KIN_SUCCESS);
 }
diff --git a/src/kinsol/kinsol_klu.c b/src/kinsol/kinsol_klu.c
new file mode 100644
index 0000000..646684e
--- /dev/null
+++ b/src/kinsol/kinsol_klu.c
@@ -0,0 +1,575 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the KINKLU linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sundials/sundials_math.h>
+
+#include "kinsol/kinsol_klu.h"
+#include "kinsol_impl.h"
+#include "kinsol_sparse_impl.h"
+#include "sundials/sundials_klu_impl.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+#define TWOTHIRDS    RCONST(0.6666666666666667)
+
+/* KINKLU linit, lsetup, lsolve, and lfree routines */
+ 
+static int kinKLUInit(KINMem kin_mem);
+static int kinKLUSetup(KINMem kin_mem);
+static int kinKLUSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+		       realtype *sJpnorm, realtype *sFdotJp);		       
+static int kinKLUFree(KINMem kin_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * KINKLU
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the KINSOL / KLU linear solver module.  
+ * KINKLU first calls the existing lfree routine if this is not NULL.
+ * Then it sets the kin_linit, kin_lsetup, kin_lsolve, kin_lperf, and
+ * kin_lfree fields in (*kin_mem) to be kinKLUInit, kinKLUSetup,
+ * kinKLUSolve, NULL, and kinKLUFree, respectively.
+ * It allocates memory for a structure of type kinkluMemRec and sets
+ * the kin_lmem field in (*kin_mem) to the address of this structure.
+ * It sets setupNonNull in (*kin_mem) to TRUE.
+ * Finally, it allocates memory for KLU.
+ * The return value is KINSLS_SUCCESS = 0, KINSLS_LMEM_FAIL = -1,
+ * or KINSLS_ILL_INPUT = -2.
+ *
+ * NOTE: The KLU linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, KINKLU will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int KINKLU(void *kin_mem_v, int n, int nnz, int sparsetype)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+  KLUData klu_data;
+  int flag;
+
+  /* Return immediately if kin_mem is NULL. */
+  if (kin_mem_v == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINKLU", 
+                    MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+  kin_mem = (KINMem) kin_mem_v;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (kin_mem->kin_vtemp1->ops->nvgetarraypointer == NULL) {
+    KINProcessError(kin_mem, KINSLS_ILL_INPUT, "KINSLS", "KINKLU", 
+                    MSGSP_BAD_NVECTOR);
+    return(KINSLS_ILL_INPUT);
+  }
+
+  if (kin_mem->kin_lfree != NULL) kin_mem->kin_lfree(kin_mem);
+
+  /* Set five main function fields in kin_mem. */
+  kin_mem->kin_linit  = kinKLUInit;
+  kin_mem->kin_lsetup = kinKLUSetup;
+  kin_mem->kin_lsolve = kinKLUSolve;
+  kin_mem->kin_lfree  = kinKLUFree;
+
+  /* Get memory for kinSlsMemRec. */
+  kinsls_mem = (KINSlsMem) malloc(sizeof(struct KINSlsMemRec));
+  if (kinsls_mem == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "KINKLU", 
+                    MSGSP_MEM_FAIL);
+    return(KINSLS_MEM_FAIL);
+  }
+
+  /* Get memory for KLUData. */
+  klu_data = (KLUData)malloc(sizeof(struct KLUDataRec));
+  if (klu_data == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "KINKLU", 
+                    MSGSP_MEM_FAIL);
+    return(KINSLS_MEM_FAIL);
+  }
+
+  kin_mem->kin_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  kinsls_mem->s_jaceval = NULL;
+  kinsls_mem->s_jacdata = NULL;
+
+  /* Allocate memory for the sparse Jacobian */
+  kinsls_mem->s_JacMat = SparseNewMat(n, n, nnz, sparsetype);
+  if (kinsls_mem->s_JacMat == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "KINKLU", 
+                    MSGSP_MEM_FAIL);
+    return(KINSLS_MEM_FAIL);
+  }
+
+  /* Initialize KLU structures */
+  switch (sparsetype) {
+    case CSC_MAT:
+      klu_data->sun_klu_solve = &klu_solve;
+      break;
+    case CSR_MAT:
+      klu_data->sun_klu_solve = &klu_tsolve;
+      break;
+    default:
+      SparseDestroyMat(kinsls_mem->s_JacMat);
+      free(klu_data);
+      free(kinsls_mem);
+      return(KINSLS_ILL_INPUT);
+  }
+  klu_data->s_Symbolic = NULL;
+  klu_data->s_Numeric = NULL;
+
+  /* Set default parameters for KLU */
+  flag = klu_defaults(&klu_data->s_Common);
+  if (flag == 0) {
+    KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", "KINKLU", 
+                    MSGSP_PACKAGE_FAIL);
+    return(KINSLS_PACKAGE_FAIL);
+  }
+  /* Set ordering to COLAMD as the kinsol default use.
+     Users can set a different value with KINKLUSetOrdering,
+     and the user-set value is loaded before any call to klu_analyze in
+     kinKLUSetup.  */
+  klu_data->s_ordering = 1;
+  klu_data->s_Common.ordering = klu_data->s_ordering;
+
+  /* This is a direct linear solver */
+  kin_mem->kin_inexact_ls = FALSE;
+
+  /* Attach linear solver memory to the nonlinear solver memory */
+  kinsls_mem->s_solver_data = (void *) klu_data;
+  kin_mem->kin_lmem = kinsls_mem;
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+
+  return(KINSLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * KINKLUReInit
+ * -----------------------------------------------------------------
+ * This routine reinitializes memory and flags for a new factorization 
+ * (symbolic and numeric) to be conducted at the next solver setup
+ * call.  This routine is useful in the cases where the number of nonzeroes 
+ * has changed or if the structure of the linear system has changed
+ * which would require a new symbolic (and numeric factorization).
+ *
+ * The reinit_type argumenmt governs the level of reinitialization:
+ *
+ * reinit_type = 1: The Jacobian matrix will be destroyed and 
+ *                  a new one will be allocated based on the nnz
+ *                  value passed to this call. New symbolic and
+ *                  numeric factorizations will be completed at the next
+ *                  solver setup.
+ *
+ * reinit_type = 2: Only symbolic and numeric factorizations will be 
+ *                  completed.  It is assumed that the Jacobian size
+ *                  has not exceeded the size of nnz given in the prior
+ *                  call to KINKLU.
+ *
+ * This routine assumes no other changes to solver use are necessary.
+ *
+ * The return value is KINSLS_SUCCESS = 0, KINSLS_MEM_NULL = -1, 
+ * KINSLS_LMEM_NULL = -2, KINSLS_ILL_INPUT = -3, or KINSLS_MEM_FAIL = -4.
+ *
+ * -----------------------------------------------------------------
+ */
+
+int KINKLUReInit(void *kin_mem_v, int n, int nnz, int reinit_type)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+  KLUData klu_data;
+
+  /* Return immediately if kin_mem is NULL. */
+  if (kin_mem_v == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINKLUReInit", 
+                    MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+  kin_mem = (KINMem) kin_mem_v;
+
+  /* Return immediately if kin_lmem is NULL. */
+  if (kin_mem->kin_lmem == NULL) {
+    KINProcessError(NULL, KINSLS_LMEM_NULL, "KINSLS", "KINKLUReInit", 
+                    MSGSP_LMEM_NULL);
+    return(KINSLS_LMEM_NULL);
+  }
+  kinsls_mem = (KINSlsMem) (kin_mem->kin_lmem);
+  klu_data = (KLUData) kinsls_mem->s_solver_data;
+
+  /* Return if reinit_type is not valid */
+  if ((reinit_type != 1) && (reinit_type != 2)) {
+    KINProcessError(NULL, KINSLS_ILL_INPUT, "KINSLS", "KINKLUReInit", 
+                    MSGSP_ILL_INPUT);
+    return(KINSLS_ILL_INPUT);
+  }
+
+  if (reinit_type == 1) {
+
+    /* Destroy previous Jacobian information */
+    if (kinsls_mem->s_JacMat) {
+      SparseDestroyMat(kinsls_mem->s_JacMat);
+    }
+
+    /* Allocate memory for the sparse Jacobian */
+    kinsls_mem->s_JacMat = SparseNewMat(n, n, nnz, kinsls_mem->sparsetype);
+    if (kinsls_mem->s_JacMat == NULL) {
+      KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "KINKLU", 
+                      MSGSP_MEM_FAIL);
+      return(KINSLS_MEM_FAIL);
+    }
+  }
+
+  /* Free the prior factorazation and reset for first factorization */
+  if( klu_data->s_Symbolic != NULL)
+    klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  if( klu_data->s_Numeric != NULL)
+    klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  kinsls_mem->s_first_factorize = 1;
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * KINKLU interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the KINKLU
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int kinKLUInit(KINMem kin_mem)
+{
+  KINSlsMem kinsls_mem;
+
+  kinsls_mem = (KINSlsMem)kin_mem->kin_lmem;
+
+  kinsls_mem->s_jacdata = kin_mem->kin_user_data;
+
+  kinsls_mem->s_nje = 0;
+  /* This forces factorization for every call to KINSol */
+  kinsls_mem->s_first_factorize = 1;
+
+  kinsls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the KINKLU linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     KINSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int kinKLUSetup(KINMem kin_mem)
+{
+  int retval;
+  KINSlsMem kinsls_mem;
+  KINSlsSparseJacFn jaceval;
+  KLUData klu_data;
+  SlsMat JacMat;
+  void *jacdata;
+  realtype uround_twothirds;
+
+  uround_twothirds = SUNRpowerR(kin_mem->kin_uround,TWOTHIRDS);
+
+  kinsls_mem = (KINSlsMem) (kin_mem->kin_lmem);
+
+  klu_data = (KLUData) kinsls_mem->s_solver_data;
+
+  jaceval = kinsls_mem->s_jaceval;
+  jacdata = kinsls_mem->s_jacdata;
+  JacMat = kinsls_mem->s_JacMat;
+
+  /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    KINProcessError(kin_mem, KINSLS_JAC_NOSET, "KINSLS", "kinKLUSetup", 
+		    MSGSP_JAC_NOSET);
+    free(kinsls_mem); kinsls_mem = NULL;
+    return(KINSLS_JAC_NOSET);
+  }
+
+  /* Increment nje counter and call Jacobian eval routine. */
+  kinsls_mem->s_nje++;
+  retval = jaceval(kin_mem->kin_uu, kin_mem->kin_fval, JacMat, jacdata, 
+		   kin_mem->kin_vtemp1, kin_mem->kin_vtemp2);
+
+  if (retval < 0) {
+    KINProcessError(kin_mem, KINSLS_JACFUNC_UNRECVR, "KINSLS", 
+		    "kinKLUSetup", MSGSP_JACFUNC_FAILED);
+    kinsls_mem->s_last_flag = KINSLS_JACFUNC_UNRECVR;
+    return(KINSLS_JACFUNC_UNRECVR);
+  }
+  if (retval == 1) {
+    kinsls_mem->s_first_factorize = 1;
+  }
+  if (retval > 1) {
+    kinsls_mem->s_last_flag = KINSLS_JACFUNC_RECVR;
+    return(+1);
+  }
+
+  if (kinsls_mem->s_first_factorize) {
+    /* ------------------------------------------------------------
+       Get the symbolic factorization
+       ------------------------------------------------------------*/ 
+    /* Update the ordering option with any user-updated values from 
+       calls to KINKLUSetOrdering */
+    klu_data->s_Common.ordering = klu_data->s_ordering;
+
+    if (klu_data->s_Symbolic != NULL) {
+       klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+    }
+    klu_data->s_Symbolic = klu_analyze(JacMat->NP, JacMat->indexptrs, 
+				       JacMat->indexvals, &(klu_data->s_Common));
+    if (klu_data->s_Symbolic == NULL) {
+      KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", "kinKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(KINSLS_PACKAGE_FAIL);
+    }
+
+    /* ------------------------------------------------------------
+       Compute the LU factorization of the Jacobian.
+       ------------------------------------------------------------*/
+    /* If klu_factor previously called, free data */
+    if( klu_data->s_Numeric != NULL) {
+       klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+    }
+    klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+				     JacMat->data, klu_data->s_Symbolic, 
+				     &(klu_data->s_Common));
+
+    if (klu_data->s_Numeric == NULL) {
+      KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", "kinKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(KINSLS_PACKAGE_FAIL);
+    }
+
+    kinsls_mem->s_first_factorize = 0;
+
+  }
+  else {
+    
+    retval = klu_refactor(JacMat->indexptrs, JacMat->indexvals, JacMat->data, 
+			klu_data->s_Symbolic, klu_data->s_Numeric,
+			&(klu_data->s_Common));
+    if (retval == 0) {
+      KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", "kinKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(KINSLS_PACKAGE_FAIL);
+    }
+
+    /*-----------------------------------------------------------
+      Check if a cheap estimate of the reciprocal of the condition 
+      number is getting too small.  If so, delete
+      the prior numeric factorization and recompute it.
+      -----------------------------------------------------------*/
+    
+    retval = klu_rcond(klu_data->s_Symbolic, klu_data->s_Numeric,
+		       &(klu_data->s_Common));
+    if (retval == 0) {
+      KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", "kinKLUSetup", 
+		      MSGSP_PACKAGE_FAIL);
+      return(KINSLS_PACKAGE_FAIL);
+    }
+
+# if 1
+    if ( (klu_data->s_Common.rcond)  < uround_twothirds ) {
+      
+      /* Condition number may be getting large.  
+	 Compute more accurate estimate */
+      retval = klu_condest(JacMat->indexptrs, JacMat->data, 
+			   klu_data->s_Symbolic, klu_data->s_Numeric,
+			   &(klu_data->s_Common));
+      if (retval == 0) {
+	KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", "kinKLUSetup", 
+			MSGSP_PACKAGE_FAIL);
+	return(KINSLS_PACKAGE_FAIL);
+      }
+      
+      if ( (klu_data->s_Common.condest) > 
+	   (1.0/uround_twothirds) ) {
+
+	/* More accurate estimate also says condition number is 
+	   large, so recompute the numeric factorization */
+
+	klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+	
+	klu_data->s_Numeric = klu_factor(JacMat->indexptrs, JacMat->indexvals, 
+					 JacMat->data, klu_data->s_Symbolic, 
+					 &(klu_data->s_Common));
+
+	if (klu_data->s_Numeric == NULL) {
+	  KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", 
+			  "kinKLUSetup", MSGSP_PACKAGE_FAIL);
+	  return(KINSLS_PACKAGE_FAIL);
+	}
+      }
+    }
+#endif 
+
+  }
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the KINKLU linear
+  solver module.  It calls the KLU solve routine, 
+  then returns KINSLS_SUCCESS = 0.
+*/
+
+static int kinKLUSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+		       realtype *sJpnorm, realtype *sFdotJp)		       
+{
+  int flag;
+  KINSlsMem kinsls_mem;
+  KLUData klu_data;
+  SlsMat JacMat;
+  realtype *xd;
+  
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+  JacMat = kinsls_mem->s_JacMat;
+
+  klu_data = (KLUData) kinsls_mem->s_solver_data;
+
+  /* Copy the right-hand side into x */
+  N_VScale(ONE, b, x);
+  xd = N_VGetArrayPointer(x);
+
+  /* Call KLU to solve the linear system */
+  flag = klu_data->sun_klu_solve(klu_data->s_Symbolic, klu_data->s_Numeric, JacMat->NP, 1, xd, 
+                                 &(klu_data->s_Common));
+  if (flag == 0) {
+    KINProcessError(kin_mem, KINSLS_PACKAGE_FAIL, "KINSLS", "kinKLUSolve", 
+		    MSGSP_PACKAGE_FAIL);
+    return(KINSLS_PACKAGE_FAIL);
+  }
+
+  /* Compute the term sFdotJp for use in the linesearch routine.
+     This term is subsequently corrected if the step is reduced by
+     constraints or the linesearch.
+
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
+
+  N_VProd(b, kin_mem->kin_fscale, b);
+  N_VProd(b, kin_mem->kin_fscale, b);
+  *sFdotJp = N_VDotProd(kin_mem->kin_fval, b);
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+  return(KINSLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the KINKLU linear solver.
+*/
+
+static int kinKLUFree(KINMem kin_mem)
+{
+  KINSlsMem kinsls_mem;
+  KLUData klu_data;
+  
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+  klu_data = (KLUData) kinsls_mem->s_solver_data;
+
+  if( klu_data->s_Numeric != NULL)
+  {
+     klu_free_numeric(&(klu_data->s_Numeric), &(klu_data->s_Common));
+  }
+  if( klu_data->s_Symbolic != NULL)
+  {
+     klu_free_symbolic(&(klu_data->s_Symbolic), &(klu_data->s_Common));
+  }
+
+  if (kinsls_mem->s_JacMat) {
+    SparseDestroyMat(kinsls_mem->s_JacMat);
+    kinsls_mem->s_JacMat = NULL;
+  }
+
+  free(klu_data); 
+  free(kin_mem->kin_lmem); 
+
+  return(0);
+}
+
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * KINKLUSetOrdering sets the ordering used by KLU for reducing fill.
+ * Options are: 0 for AMD, 1 for COLAMD, and 2 for the natural ordering.
+ * The default used in KINSOL is 1 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int KINKLUSetOrdering(void *kin_mem_v, int ordering_choice)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+  KLUData klu_data;
+
+ /* Return immediately if kin_mem is NULL */
+  if (kin_mem_v == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINKLUSetOrdering",
+		    MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+  kin_mem = (KINMem) kin_mem_v;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) ) {
+    KINProcessError(NULL, KINSLS_ILL_INPUT, "KINSLS", "KINKLUSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(KINSLS_ILL_INPUT);
+  }
+
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+  klu_data = (KLUData) kinsls_mem->s_solver_data;
+
+  klu_data->s_ordering = ordering_choice;
+
+  return(KINSLS_SUCCESS);
+}
+
diff --git a/src/kinsol/kinsol_lapack.c b/src/kinsol/kinsol_lapack.c
index 08fa4b3..ceb6026 100644
--- a/src/kinsol/kinsol_lapack.c
+++ b/src/kinsol/kinsol_lapack.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2011/02/16 22:43:28 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * ----------------------------------------------------------------- 
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2006, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a KINSOL dense linear solver
  * using BLAS and LAPACK functions.
@@ -44,14 +49,16 @@
 /* KINLAPACK DENSE linit, lsetup, lsolve, and lfree routines */ 
 static int kinLapackDenseInit(KINMem kin_mem);
 static int kinLapackDenseSetup(KINMem kin_mem);
-static int kinLapackDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_norm);
-static void kinLapackDenseFree(KINMem kin_mem);
+static int kinLapackDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+                               realtype *sJpnorm, realtype *sFdotJp);
+static int kinLapackDenseFree(KINMem kin_mem);
 
 /* KINLAPACK BAND linit, lsetup, lsolve, and lfree routines */ 
 static int kinLapackBandInit(KINMem kin_mem);
 static int kinLapackBandSetup(KINMem kin_mem);
-static int kinLapackBandSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_norm);
-static void kinLapackBandFree(KINMem kin_mem);
+static int kinLapackBandSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+                              realtype *sJpnorm, realtype *sFdotJp);
+static int kinLapackBandFree(KINMem kin_mem);
 
 /*
  * =================================================================
@@ -74,8 +81,6 @@ static void kinLapackBandFree(KINMem kin_mem);
 #define uscale         (kin_mem->kin_uscale)
 #define fscale         (kin_mem->kin_fscale)
 #define sqrt_relfunc   (kin_mem->kin_sqrt_relfunc)
-#define sJpnorm        (kin_mem->kin_sJpnorm)
-#define sfdotJp        (kin_mem->kin_sfdotJp)
 #define errfp          (kin_mem->kin_errfp)
 #define infofp         (kin_mem->kin_infofp)
 #define setupNonNull   (kin_mem->kin_setupNonNull)
@@ -172,6 +177,8 @@ int KINLapackDense(void *kinmem, int N)
 
   last_flag = KINDLS_SUCCESS;
 
+  kinDlsInitializeCounters(kindls_mem);
+
   setupNonNull = TRUE;
 
   /* Set problem dimension */
@@ -274,6 +281,8 @@ int KINLapackBand(void *kinmem, int N, int mupper, int mlower)
 
   last_flag = KINDLS_SUCCESS;
 
+  kinDlsInitializeCounters(kindls_mem);
+
   setupNonNull = TRUE;
   
   /* Load problem dimension */
@@ -291,7 +300,7 @@ int KINLapackBand(void *kinmem, int N, int mupper, int mlower)
   }
 
   /* Set extended upper half-bandwith for M (required for pivoting) */
-  smu = MIN(n-1, mu + ml);
+  smu = mu + ml;
 
   /* Allocate memory for J and pivot array */
   J = NULL;
@@ -342,8 +351,7 @@ static int kinLapackDenseInit(KINMem kin_mem)
 
   kindls_mem = (KINDlsMem) lmem;
   
-  nje   = 0;
-  nfeDQ = 0;
+  kinDlsInitializeCounters(kindls_mem);
   
   if (jacDQ) {
     djac = kinDlsDenseDQJac;
@@ -399,10 +407,12 @@ static int kinLapackDenseSetup(KINMem kin_mem)
  * -----------------------------------------------------------------
  * This routine handles the solve operation for the dense linear solver
  * by calling the dense backsolve routine.  The returned value is 0.
+ * The argument *sJpnorm is ignored.
  * -----------------------------------------------------------------
  */
 
-static int kinLapackDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_norm)
+static int kinLapackDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+                               realtype *sJpnorm, realtype *sFdotJp)
 {
   KINDlsMem kindls_mem;
   realtype *xd;
@@ -421,23 +431,18 @@ static int kinLapackDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype
   dgetrs_f77("N", &intn, &one, J->data, &intn, pivots, xd, &intn, &ier, 1); 
   if (ier > 0) return(-1);
 
-  /* Compute the terms Jpnorm and sfdotJp for use in the global strategy
-   * routines and in KINForcingTerm. Both of these terms are subsequently
-   * corrected if the step is reduced by constraints or the line search.
-   *
-   * sJpnorm is the norm of the scaled product (scaled by fscale) of
-   * the current Jacobian matrix J and the step vector p.
-   *
-   * sfdotJp is the dot product of the scaled f vector and the scaled
-   * vector J*p, where the scaling uses fscale. 
-   */
-  sJpnorm = N_VWL2Norm(b,fscale);
+  /* Compute the term sFdotJp for use in the linesearch routine.
+     This term is subsequently corrected if the step is reduced by
+     constraints or the linesearch.
+
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
+
   N_VProd(b, fscale, b);
   N_VProd(b, fscale, b);
-  sfdotJp = N_VDotProd(fval, b);
+  *sFdotJp = N_VDotProd(fval, b);
 
   last_flag = KINDLS_SUCCESS;
-
   return(0);
 }
 
@@ -449,7 +454,7 @@ static int kinLapackDenseSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype
  * -----------------------------------------------------------------
  */
 
-static void kinLapackDenseFree(KINMem kin_mem)
+static int kinLapackDenseFree(KINMem kin_mem)
 {
   KINDlsMem  kindls_mem;
 
@@ -458,6 +463,8 @@ static void kinLapackDenseFree(KINMem kin_mem)
   DestroyMat(J);
   DestroyArray(pivots);
   free(kindls_mem); kindls_mem = NULL;
+
+  return(0);
 }
 
 
@@ -482,8 +489,7 @@ static int kinLapackBandInit(KINMem kin_mem)
 
   kindls_mem = (KINDlsMem) lmem;
 
-  nje   = 0;
-  nfeDQ = 0;
+  kinDlsInitializeCounters(kindls_mem);
 
   if (jacDQ) {
     bjac = kinDlsBandDQJac;
@@ -546,10 +552,12 @@ static int kinLapackBandSetup(KINMem kin_mem)
  * -----------------------------------------------------------------
  * This routine handles the solve operation for the band linear solver
  * by calling the band backsolve routine.  The return value is 0.
+ * The argument *sJpnorm is ignored.
  * -----------------------------------------------------------------
  */
 
-static int kinLapackBandSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *res_norm)
+static int kinLapackBandSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+                              realtype *sJpnorm, realtype *sFdotJp)
 {
   KINDlsMem kindls_mem;
   realtype *xd;
@@ -571,23 +579,18 @@ static int kinLapackBandSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *
   dgbtrs_f77("N", &intn, &iml, &imu, &one, J->data, &ldmat, pivots, xd, &intn, &ier, 1);
   if (ier > 0) return(-1);
 
-  /* Compute the terms Jpnorm and sfdotJp for use in the global strategy
-   * routines and in KINForcingTerm. Both of these terms are subsequently
-   * corrected if the step is reduced by constraints or the line search.
-   * 
-   * sJpnorm is the norm of the scaled product (scaled by fscale) of
-   * the current Jacobian matrix J and the step vector p.
-   *
-   * sfdotJp is the dot product of the scaled f vector and the scaled
-   * vector J*p, where the scaling uses fscale. 
-   */
-  sJpnorm = N_VWL2Norm(b,fscale);
+  /* Compute the term sFdotJp for use in the linesearch routine.
+     This term is subsequently corrected if the step is reduced by
+     constraints or the linesearch.
+
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
+
   N_VProd(b, fscale, b);
   N_VProd(b, fscale, b);
-  sfdotJp = N_VDotProd(fval, b);
+  *sFdotJp = N_VDotProd(fval, b);
 
   last_flag = KINDLS_SUCCESS;
-
   return(0);
 }
 
@@ -599,7 +602,7 @@ static int kinLapackBandSolve(KINMem kin_mem, N_Vector x, N_Vector b, realtype *
  * -----------------------------------------------------------------
  */
 
-static void kinLapackBandFree(KINMem kin_mem)
+static int kinLapackBandFree(KINMem kin_mem)
 {
   KINDlsMem kindls_mem;
 
@@ -608,4 +611,6 @@ static void kinLapackBandFree(KINMem kin_mem)
   DestroyMat(J);
   DestroyArray(pivots);
   free(kindls_mem); kindls_mem = NULL;
+
+  return(0);
 }
diff --git a/src/kinsol/kinsol_sparse.c b/src/kinsol/kinsol_sparse.c
new file mode 100644
index 0000000..17b05ec
--- /dev/null
+++ b/src/kinsol/kinsol_sparse.c
@@ -0,0 +1,178 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for an KINSLS linear solver.
+ * -----------------------------------------------------------------
+ */
+
+/* 
+ * =================================================================
+ * IMPORTED HEADER FILES
+ * =================================================================
+ */
+
+#include "kinsol_impl.h"
+#include "kinsol_sparse_impl.h"
+#include "sundials/sundials_math.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* 
+ * =================================================================
+ * FUNCTION SPECIFIC CONSTANTS
+ * =================================================================
+ */
+
+#define ZERO         RCONST(0.0)
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* 
+ * =================================================================
+ * EXPORTED FUNCTIONS 
+ * =================================================================
+ */
+              
+/*
+ * KINSlsSetSparseJacFn specifies the sparse Jacobian function.
+ */
+int KINSlsSetSparseJacFn(void *kin_mem_v, KINSlsSparseJacFn jac)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+
+  kin_mem = (KINMem) kin_mem_v;
+
+  /* Return immediately if kin_mem is NULL */
+  if (kin_mem == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINSlsSetSparseJacFn", 
+		    MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+
+  if (kin_mem->kin_lmem == NULL) {
+    KINProcessError(kin_mem, KINSLS_LMEM_NULL, "KINSLS", 
+		    "KINSlsSetSparseJacFn", MSGSP_LMEM_NULL);
+    return(KINSLS_LMEM_NULL);
+  }
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+
+  kinsls_mem->s_jaceval = jac;
+
+  return(KINSLS_SUCCESS);
+}
+
+/*
+ * KINSlsGetNumJacEvals returns the number of Jacobian evaluations.
+ */
+int KINSlsGetNumJacEvals(void *kin_mem_v, long int *njevals)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+
+  kin_mem = (KINMem) kin_mem_v;
+
+  /* Return immediately if kin_mem is NULL */
+  if (kin_mem == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINSlsGetNumJacEvals", MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+
+  if (kin_mem->kin_lmem == NULL) {
+    KINProcessError(kin_mem, KINSLS_LMEM_NULL, "KINSLS", 
+		    "KINSlsGetNumJacEvals", MSGSP_LMEM_NULL);
+    return(KINSLS_LMEM_NULL);
+  }
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+
+  *njevals = kinsls_mem->s_nje;
+
+  return(KINSLS_SUCCESS);
+}
+
+/*
+ * KINSlsGetReturnFlagName returns the name associated with a KINSLS
+ * return value.
+ */
+char *KINSlsGetReturnFlagName(long int flag)
+{
+  char *name;
+
+  name = (char *)malloc(30*sizeof(char));
+
+  switch(flag) {
+  case KINSLS_SUCCESS:
+    sprintf(name,"KINSLS_SUCCESS");
+    break;   
+  case KINSLS_MEM_NULL:
+    sprintf(name,"KINSLS_MEM_NULL");
+    break;
+  case KINSLS_LMEM_NULL:
+    sprintf(name,"KINSLS_LMEM_NULL");
+    break;
+  case KINSLS_ILL_INPUT:
+    sprintf(name,"KINSLS_ILL_INPUT");
+    break;
+  case KINSLS_MEM_FAIL:
+    sprintf(name,"KINSLS_MEM_FAIL");
+    break;
+  case KINSLS_JAC_NOSET:
+    sprintf(name,"KINSLS_JAC_NOSET");
+    break;
+  case KINSLS_JACFUNC_UNRECVR:
+    sprintf(name,"KINSLS_JACFUNC_UNRECVR");
+    break;
+  case KINSLS_JACFUNC_RECVR:
+    sprintf(name,"KINSLS_JACFUNC_RECVR");
+    break;
+  default:
+    sprintf(name,"NONE");
+  }
+
+  return(name);
+}
+
+/*
+ * KINSlsGetLastFlag returns the last flag set in a KINSLS function.
+ */
+int KINSlsGetLastFlag(void *kin_mem_v, long int *flag)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+
+  kin_mem= (KINMem) kin_mem_v;
+
+  /* Return immediately if kin_mem is NULL */
+  if (kin_mem == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINSlsGetLastFlag", 
+		    MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+
+  if (kin_mem->kin_lmem == NULL) {
+    KINProcessError(kin_mem, KINSLS_LMEM_NULL, "KINSLS", 
+		    "KINSlsGetLastFlag", MSGSP_LMEM_NULL);
+    return(KINSLS_LMEM_NULL);
+  }
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+
+  *flag = kinsls_mem->s_last_flag;
+
+  return(KINSLS_SUCCESS);
+}
+
diff --git a/src/kinsol/kinsol_sparse_impl.h b/src/kinsol/kinsol_sparse_impl.h
new file mode 100644
index 0000000..ed98bd9
--- /dev/null
+++ b/src/kinsol/kinsol_sparse_impl.h
@@ -0,0 +1,92 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4558 $
+ * $Date: 2015-10-05 09:04:16 -0700 (Mon, 05 Oct 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * Implementation header file for the KINSLS linear solvers.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _KINSPARSE_IMPL_H
+#define _KINSPARSE_IMPL_H
+
+#include "kinsol/kinsol_sparse.h"
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+/*
+ * =================================================================
+ * K I N S P A R S E    I N T E R N A L    C O N S T A N T S
+ * =================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Types : KINSlsMemRec, KINSlsMem                             
+ * -----------------------------------------------------------------
+ * KINSlsMem is pointer to a KINSlsMemRec structure.
+ * -----------------------------------------------------------------
+ */
+
+typedef struct KINSlsMemRec {
+
+  KINSlsSparseJacFn s_jaceval; /* user Jacobian evaluation routine 
+				  to be called */
+  void *s_jacdata;           /* J_data is passed to eval. routine */
+
+  long int s_nje;           /* nje = no. of calls to jac */
+
+  long int s_last_flag;     /* last error return flag */
+
+  int s_first_factorize;    /* flag telling whether the first 
+			       factorization needs to happen */
+  SlsMat s_JacMat;          /* J = dF/du */
+
+  int sparsetype;           /* matrix type: compressed sparse column or row */
+
+  void *s_solver_data;      /* structure for solver-specific data */
+  
+
+} *KINSlsMem;
+
+/*
+ * -----------------------------------------------------------------
+ * Prototypes of internal functions
+ * -----------------------------------------------------------------
+ */
+  
+
+/*
+ * =================================================================
+ * E R R O R   M E S S A G E S
+ * =================================================================
+ */
+
+#define MSGSP_KINMEM_NULL "Solver memory is NULL."
+#define MSGSP_BAD_NVECTOR "A required vector operation is not implemented."
+#define MSGSP_MEM_FAIL "A memory request failed."
+#define MSGSP_LMEM_NULL "Linear solver memory is NULL."
+#define MSGSP_JAC_NOSET "Jacobian evaluation function has not been set."
+#define MSGSP_ILL_INPUT "Invalid input detected."
+#define MSGSP_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
+#define MSGSP_PACKAGE_FAIL "A call to an external package failed."
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/kinsol/kinsol_spbcgs.c b/src/kinsol/kinsol_spbcgs.c
index 70a4a7e..979fa2c 100644
--- a/src/kinsol/kinsol_spbcgs.c
+++ b/src/kinsol/kinsol_spbcgs.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2007/11/26 16:20:01 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the KINSOL interface to the
  * scaled, preconditioned Bi-CGSTAB (SPBCG) iterative linear solver.
@@ -45,8 +50,8 @@
 static int KINSpbcgInit(KINMem kin_mem);
 static int KINSpbcgSetup(KINMem kin_mem);
 static int KINSpbcgSolve(KINMem kin_mem, N_Vector xx,
-			 N_Vector bb, realtype *res_norm);
-static void KINSpbcgFree(KINMem kin_mem);
+			 N_Vector bb, realtype *sJpnorm, realtype *sFdotJp);
+static int KINSpbcgFree(KINMem kin_mem);
 
 /*
  * -----------------------------------------------------------------
@@ -71,14 +76,13 @@ static void KINSpbcgFree(KINMem kin_mem);
 #define fscale       (kin_mem->kin_fscale)
 #define sqrt_relfunc (kin_mem->kin_sqrt_relfunc)
 #define eps          (kin_mem->kin_eps)
-#define sJpnorm      (kin_mem->kin_sJpnorm)
-#define sfdotJp      (kin_mem->kin_sfdotJp)
 #define errfp        (kin_mem->kin_errfp)
 #define infofp       (kin_mem->kin_infofp)
 #define setupNonNull (kin_mem->kin_setupNonNull)
 #define vtemp1       (kin_mem->kin_vtemp1)
 #define vec_tmpl     (kin_mem->kin_vtemp1)
 #define vtemp2       (kin_mem->kin_vtemp2)
+#define strategy     (kin_mem->kin_globalstrategy)
 
 #define pretype   (kinspils_mem->s_pretype)
 #define nli       (kinspils_mem->s_nli)
@@ -183,6 +187,8 @@ int KINSpbcg(void *kinmem, int maxl)
   kinspils_mem->s_pretype   = PREC_NONE;
   kinspils_mem->s_last_flag = KINSPILS_SUCCESS;
 
+  kinSpilsInitializeCounters(kinspils_mem);
+
   /* Call SpbcgMalloc to allocate workspace for SPBCG */
 
   /* vec_tmpl passed as template vector */
@@ -238,9 +244,7 @@ static int KINSpbcgInit(KINMem kin_mem)
   spbcg_mem = (SpbcgMem) spils_mem;
 
   /* initialize counters */
-
-  npe = nli = nps = ncfl = 0;
-  njtimes = nfes = 0;
+  kinSpilsInitializeCounters(kinspils_mem);
 
   /* set preconditioner type */
 
@@ -263,7 +267,13 @@ static int KINSpbcgInit(KINMem kin_mem)
     J_data = user_data;
   }
 
-  /*  Set maxl in the SPBCG memory in case it was changed by the user */
+  if ( (strategy == KIN_PICARD) && jtimesDQ ) {
+    KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSpbcgInit", 
+		    MSG_NOL_FAIL);
+    return(KIN_ILL_INPUT);
+  }
+
+ /*  Set maxl in the SPBCG memory in case it was changed by the user */
   spbcg_mem->l_max  = maxl;
 
   last_flag = KINSPILS_SUCCESS;
@@ -319,11 +329,12 @@ static int KINSpbcgSetup(KINMem kin_mem)
  */
 
 static int KINSpbcgSolve(KINMem kin_mem, N_Vector xx, N_Vector bb, 
-                         realtype *res_norm)
+                         realtype *sJpnorm, realtype *sFdotJp)
 {
   KINSpilsMem kinspils_mem;
   SpbcgMem spbcg_mem;
   int ret, nli_inc, nps_inc;
+  realtype res_norm;
   
   kinspils_mem = (KINSpilsMem) lmem;
   spbcg_mem = (SpbcgMem) spils_mem;
@@ -340,7 +351,7 @@ static int KINSpbcgSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
 
   ret = SpbcgSolve(spbcg_mem, kin_mem, xx, bb, pretype, eps,
                    kin_mem, fscale, fscale, KINSpilsAtimes,
-                   KINSpilsPSolve, res_norm, &nli_inc, &nps_inc);
+                   KINSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
 
   /* increment counters nli, nps, and ncfl 
      (nni is updated in the KINSol main iteration loop) */
@@ -352,54 +363,57 @@ static int KINSpbcgSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
     KINPrintInfo(kin_mem, PRNT_NLI, "KINSPBCG", "KINSpbcgSolve", INFO_NLI, nli_inc);
 
   if (ret != 0) ncfl++;
+  last_flag = ret;
 
-  /* Compute the terms sJpnorm and sfdotJp for use in the global strategy
-     routines and in KINForcingTerm. Both of these terms are subsequently
-     corrected if the step is reduced by constraints or the line search.
-
-     sJpnorm is the norm of the scaled product (scaled by fscale) of
-     the current Jacobian matrix J and the step vector p.
-
-     sfdotJp is the dot product of the scaled f vector and the scaled
-     vector J*p, where the scaling uses fscale. */
-
-  ret = KINSpilsAtimes(kin_mem, xx, bb);
-  if (ret == 0)     ret = SPBCG_SUCCESS;
-  else if (ret > 0) ret = SPBCG_ATIMES_FAIL_REC;
-  else if (ret < 0) ret = SPBCG_ATIMES_FAIL_UNREC;
-
-  sJpnorm = N_VWL2Norm(bb,fscale);
-  N_VProd(bb, fscale, bb);
-  N_VProd(bb, fscale, bb);
-  sfdotJp = N_VDotProd(fval, bb);
+  if ( (ret != 0) && (ret != SPBCG_RES_REDUCED) ) {
+
+    /* Handle all failure returns from SpbcgSolve */
+
+    switch(ret) {
+    case SPBCG_PSOLVE_FAIL_REC:
+    case SPBCG_ATIMES_FAIL_REC:
+      return(1);
+      break;
+    case SPBCG_CONV_FAIL:
+    case SPBCG_MEM_NULL:
+    case SPBCG_ATIMES_FAIL_UNREC:
+    case SPBCG_PSOLVE_FAIL_UNREC:
+      return(-1);
+      break;
+    }
+  }
 
-  if (printfl > 2) 
-    KINPrintInfo(kin_mem, PRNT_EPS, "KINSPBCG", "KINSpbcgSolve", INFO_EPS, *res_norm, eps);
+  /*  SpbcgSolve returned either SPBCG_SUCCESS or SPBCG_RES_REDUCED.
 
-  /* Interpret return value from SpbcgSolve */
+     Compute the terms sJpnorm and sFdotJp for use in the linesearch
+     routine and in KINForcingTerm.  Both of these terms are subsequently
+     corrected if the step is reduced by constraints or the linesearch.
 
-  last_flag = ret;
+     sJpnorm is the norm of the scaled product (scaled by fscale) of the
+     current Jacobian matrix J and the step vector p (= solution vector xx).
 
-  switch(ret) {
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
 
-  case SPBCG_SUCCESS:
-  case SPBCG_RES_REDUCED:
-    return(0);
-    break;
-  case SPBCG_PSOLVE_FAIL_REC:
-  case SPBCG_ATIMES_FAIL_REC:
+  ret = KINSpilsAtimes(kin_mem, xx, bb);
+  if (ret > 0) {
+    last_flag = SPBCG_ATIMES_FAIL_REC;
     return(1);
-    break;
-  case SPBCG_CONV_FAIL:
-  case SPBCG_MEM_NULL:
-  case SPBCG_ATIMES_FAIL_UNREC:
-  case SPBCG_PSOLVE_FAIL_UNREC:
+  }      
+  else if (ret < 0) {
+    last_flag = SPBCG_ATIMES_FAIL_UNREC;
     return(-1);
-    break;
   }
 
-  return(0);
+  *sJpnorm = N_VWL2Norm(bb, fscale);
+  N_VProd(bb, fscale, bb);
+  N_VProd(bb, fscale, bb);
+  *sFdotJp = N_VDotProd(fval, bb);
+
+  if (printfl > 2) KINPrintInfo(kin_mem, PRNT_EPS, "KINSPBCG",
+                     "KINSpbcgSolve", INFO_EPS, res_norm, eps);
 
+  return(0);
 }
 
 /*
@@ -410,7 +424,7 @@ static int KINSpbcgSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
  * -----------------------------------------------------------------
  */
 
-static void KINSpbcgFree(KINMem kin_mem)
+static int KINSpbcgFree(KINMem kin_mem)
 {
   KINSpilsMem kinspils_mem;
   SpbcgMem spbcg_mem;
@@ -423,4 +437,6 @@ static void KINSpbcgFree(KINMem kin_mem)
   if (kinspils_mem->s_pfree != NULL) (kinspils_mem->s_pfree)(kin_mem);
 
   free(kinspils_mem); kinspils_mem = NULL;
+
+  return(0);
 }
diff --git a/src/kinsol/kinsol_spfgmr.c b/src/kinsol/kinsol_spfgmr.c
new file mode 100644
index 0000000..9186c28
--- /dev/null
+++ b/src/kinsol/kinsol_spfgmr.c
@@ -0,0 +1,451 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Carol S. Woodward @ LLNL
+ *    Based on kinsol_spgmr.c
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the KINSOL scaled,
+ * preconditioned Flexible GMRES linear solver, KINSpfgmr.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "kinsol_impl.h"
+#include <kinsol/kinsol_spfgmr.h>
+#include "kinsol_spils_impl.h"
+
+#include <sundials/sundials_spfgmr.h>
+#include <sundials/sundials_math.h>
+
+/*
+ * -----------------------------------------------------------------
+ * private constants
+ * -----------------------------------------------------------------
+ */
+
+#define ZERO RCONST(0.0)
+
+/*
+ * -----------------------------------------------------------------
+ * function prototypes
+ * -----------------------------------------------------------------
+ */
+
+/* KINSpfgmr linit, lsetup, lsolve, and lfree routines */
+
+static int KINSpfgmrInit(KINMem kin_mem);
+static int KINSpfgmrSetup(KINMem kin_mem);
+static int KINSpfgmrSolve(KINMem kin_mem, N_Vector xx, 
+                          N_Vector bb, realtype *sJpnorm, realtype *sFdotJp);
+static int KINSpfgmrFree(KINMem kin_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * readability replacements
+ * -----------------------------------------------------------------
+ */
+/*
+#define nni            (kin_mem->kin_nni)
+#define nnilset        (kin_mem->kin_nnilset)
+#define func           (kin_mem->kin_func)
+#define user_data      (kin_mem->kin_user_data)
+#define printfl        (kin_mem->kin_printfl)
+#define linit          (kin_mem->kin_linit)
+#define lsetup         (kin_mem->kin_lsetup)
+#define lsolve         (kin_mem->kin_lsolve)
+#define lfree          (kin_mem->kin_lfree)
+#define lmem           (kin_mem->kin_lmem)
+#define inexact_ls     (kin_mem->kin_inexact_ls)
+#define uu             (kin_mem->kin_uu)
+#define fval           (kin_mem->kin_fval)
+#define uscale         (kin_mem->kin_uscale)
+#define fscale         (kin_mem->kin_fscale)
+#define sqrt_relfunc   (kin_mem->kin_sqrt_relfunc)
+#define jacCurrent     (kin_mem->kin_jacCurrent)
+#define eps            (kin_mem->kin_eps)
+#define errfp          (kin_mem->kin_errfp)
+#define infofp         (kin_mem->kin_infofp)
+#define setupNonNull   (kin_mem->kin_setupNonNull)
+#define vtemp1         (kin_mem->kin_vtemp1)
+#define vec_tmpl       (kin_mem->kin_vtemp1)
+#define vtemp2         (kin_mem->kin_vtemp2)
+#define strategy       (kin_mem->kin_globalstrategy)
+
+#define pretype   (kinspils_mem->s_pretype)
+#define gstype    (kinspils_mem->s_gstype)
+#define nli       (kinspils_mem->s_nli)
+#define npe       (kinspils_mem->s_npe)
+#define nps       (kinspils_mem->s_nps)
+#define ncfl      (kinspils_mem->s_ncfl)
+#define njtimes   (kinspils_mem->s_njtimes)
+#define nfes      (kinspils_mem->s_nfes)
+#define new_uu    (kinspils_mem->s_new_uu)
+#define spils_mem (kinspils_mem->s_spils_mem)
+
+#define jtimesDQ  (kinspils_mem->s_jtimesDQ)
+#define jtimes    (kinspils_mem->s_jtimes)
+#define J_data    (kinspils_mem->s_J_data)
+
+#define last_flag (kinspils_mem->s_last_flag)
+*/
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSpfgmr
+ * -----------------------------------------------------------------
+ * This routine allocates and initializes the memory record and
+ * sets function fields specific to the SPFGMR linear solver module.
+ * KINSpfgmr sets the kin_linit, kin_lsetup, kin_lsolve, and
+ * kin_lfree fields in *kinmem to be KINSpfgmrInit, KINSpfgmrSetup,
+ * KINSpfgmrSolve, and KINSpfgmrFree, respectively. It allocates
+ * memory for a structure of type KINSpilsMemRec and sets the
+ * kin_lmem field in *kinmem to the address of this structure. It
+ * also calls SpfgmrMalloc to allocate memory for the module
+ * SPFGMR. In summary, KINSpfgmr sets various fields in the
+ * KINSpilsMemRec structure.
+ * -----------------------------------------------------------------
+ */
+
+int KINSpfgmr(void *kinmem, int maxl)
+{
+  KINMem kin_mem;
+  KINSpilsMem kinspils_mem;
+  SpfgmrMem spfgmr_mem;
+  int maxl1;
+
+  if (kinmem == NULL){
+    KINProcessError(NULL, KINSPILS_MEM_NULL, "KINSPILS", "KINSpfgmr", MSGS_KINMEM_NULL);
+    return(KINSPILS_MEM_NULL);  
+  }
+  kin_mem = (KINMem) kinmem;
+
+  /* check for required vector operations */
+
+  /* Note: do NOT need to check for N_VLinearSum, N_VProd, N_VScale, N_VDiv, 
+     or N_VWL2Norm because they are required by KINSOL */
+
+  if ((kin_mem->kin_vtemp1->ops->nvconst == NULL) ||
+      (kin_mem->kin_vtemp1->ops->nvdotprod == NULL) ||
+      (kin_mem->kin_vtemp1->ops->nvl1norm == NULL)) {
+    KINProcessError(NULL, KINSPILS_ILL_INPUT, "KINSPILS", "KINSpfgmr", MSGS_BAD_NVECTOR);
+    return(KINSPILS_ILL_INPUT);
+  }
+
+  if (kin_mem->kin_lfree != NULL) kin_mem->kin_lfree(kin_mem);
+
+  /* set four main function fields in kin_mem */
+
+  kin_mem->kin_linit  = KINSpfgmrInit; 
+  kin_mem->kin_lsetup = KINSpfgmrSetup;
+  kin_mem->kin_lsolve = KINSpfgmrSolve;
+  kin_mem->kin_lfree  = KINSpfgmrFree;
+
+  /* get memory for KINSpilsMemRec */
+  kinspils_mem = NULL;
+  kinspils_mem = (KINSpilsMem) malloc(sizeof(struct KINSpilsMemRec));
+  if (kinspils_mem == NULL){
+    KINProcessError(NULL, KINSPILS_MEM_FAIL, "KINSPILS", "KINSpfgmr", MSGS_MEM_FAIL);
+    return(KINSPILS_MEM_FAIL);  
+  }
+
+  /* Set ILS type */
+  kinspils_mem->s_type = SPILS_SPFGMR;
+
+  /* set SPFGMR parameters that were passed in call sequence */
+
+  maxl1 = (maxl <= 0) ? KINSPILS_MAXL : maxl;
+  kinspils_mem->s_maxl = maxl1;  
+
+  /* Set defaults for Jacobian-related fields */
+
+  kinspils_mem->s_jtimesDQ = TRUE;
+  kinspils_mem->s_jtimes   = NULL;
+  kinspils_mem->s_J_data   = NULL;
+
+  /* Set defaults for preconditioner-related fields */
+
+  kinspils_mem->s_pset   = NULL;
+  kinspils_mem->s_psolve = NULL;
+  kinspils_mem->s_pfree  = NULL;
+  kinspils_mem->s_P_data = kin_mem->kin_user_data;
+
+  /* Set default values for the rest of the SPFGMR parameters */
+
+  kinspils_mem->s_pretype   = PREC_NONE;
+  kinspils_mem->s_gstype    = MODIFIED_GS;
+  kinspils_mem->s_maxlrst   = 0;
+  kinspils_mem->s_last_flag = KINSPILS_SUCCESS;
+
+  kinSpilsInitializeCounters(kinspils_mem);
+
+  /* Call SpfgmrMalloc to allocate workspace for SPFGMR */
+
+  /* vtemp1 passed as template vector */
+  spfgmr_mem = NULL;
+  spfgmr_mem = SpfgmrMalloc(maxl1, kin_mem->kin_vtemp1);
+  if (spfgmr_mem == NULL) {
+    KINProcessError(NULL, KINSPILS_MEM_FAIL, "KINSPILS", "KINSpfgmr", MSGS_MEM_FAIL);
+    free(kinspils_mem); kinspils_mem = NULL;
+    return(KINSPILS_MEM_FAIL);
+  }
+
+  /* This is an iterative linear solver */
+
+  kin_mem->kin_inexact_ls = TRUE;
+
+  /* Attach SPFGMR memory to spils memory structure */
+  kinspils_mem->s_spils_mem = (void *) spfgmr_mem;
+
+  /* attach linear solver memory to KINSOL memory */
+  kin_mem->kin_lmem = kinspils_mem;
+
+  return(KINSPILS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * additional readability replacements
+ * -----------------------------------------------------------------
+ */
+
+/*
+#define maxl    (kinspils_mem->s_maxl)
+#define maxlrst (kinspils_mem->s_maxlrst)
+#define pset    (kinspils_mem->s_pset)
+#define psolve  (kinspils_mem->s_psolve)
+#define P_data  (kinspils_mem->s_P_data)
+*/
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSpfgmrInit
+ * -----------------------------------------------------------------
+ * This routine initializes variables associated with the FGMRES
+ * linear solver. Memory allocation was done previously in
+ * KINSpfgmr.
+ * -----------------------------------------------------------------
+ */
+
+static int KINSpfgmrInit(KINMem kin_mem)
+{
+  KINSpilsMem kinspils_mem;
+
+  kinspils_mem = (KINSpilsMem) kin_mem->kin_lmem;
+
+  /* initialize counters */
+  kinSpilsInitializeCounters(kinspils_mem);
+
+  /* set preconditioner type */
+
+  if (kinspils_mem->s_psolve != NULL) {
+    kinspils_mem->s_pretype = PREC_RIGHT;
+  } else {
+    kinspils_mem->s_pretype = PREC_NONE;
+  }
+  
+  /* set setupNonNull to TRUE iff there is preconditioning with setup */
+
+  kin_mem->kin_setupNonNull = 
+    (kinspils_mem->s_psolve != NULL) && (kinspils_mem->s_pset != NULL);
+
+  /* Set Jacobian-related fields, based on jtimesDQ */
+  if (kinspils_mem->s_jtimesDQ) {
+    kinspils_mem->s_jtimes = KINSpilsDQJtimes;
+    kinspils_mem->s_J_data = kin_mem;
+  } else {
+    kinspils_mem->s_J_data = kin_mem->kin_user_data;
+  }
+
+  if ( (kin_mem->kin_globalstrategy == KIN_PICARD) 
+       && (kinspils_mem->s_jtimesDQ) ) {
+    KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSpfgmrInit", 
+		    MSG_NOL_FAIL);
+    return(KIN_ILL_INPUT);
+  }
+
+  kinspils_mem->s_last_flag = KINSPILS_SUCCESS;
+  return(0);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSpfgmrSetup
+ * -----------------------------------------------------------------
+ * This routine does the setup operations for the SPFGMR linear
+ * solver, that is, it is an interface to the user-supplied
+ * routine pset.
+ * -----------------------------------------------------------------
+ */
+
+static int KINSpfgmrSetup(KINMem kin_mem)
+{
+  KINSpilsMem kinspils_mem;
+  int ret;
+
+  kinspils_mem = (KINSpilsMem) kin_mem->kin_lmem;
+
+  /* call pset routine */
+
+  ret = kinspils_mem->s_pset(kin_mem->kin_uu, kin_mem->kin_uscale, 
+                             kin_mem->kin_fval, kin_mem->kin_fscale, 
+                             kinspils_mem->s_P_data, 
+                             kin_mem->kin_vtemp1, kin_mem->kin_vtemp2); 
+
+  kinspils_mem->s_last_flag = ret;
+
+  (kinspils_mem->s_npe)++;
+  kin_mem->kin_nnilset = kin_mem->kin_nni; 
+
+  /* return the same value ret that pset returned */
+  return(ret);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSpfgmrSolve
+ * -----------------------------------------------------------------
+ * This routine handles the call to the generic SPFGMR solver
+ * SpfgmrSolve for the solution of the linear system Ax = b.
+ *
+ * Appropriate variables are passed to SpfgmrSolve and the counters
+ * nli, nps, and ncfl are incremented, and the return value is set
+ * according to the success of SpfgmrSolve. The success flag is
+ * returned if SpfgmrSolve converged, or if the residual was reduced.
+ * Of the other error conditions, only preconditioner solver
+ * failure is specifically returned. Otherwise a generic flag is
+ * returned to denote failure of this routine.
+ * -----------------------------------------------------------------
+ */
+
+static int KINSpfgmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb, 
+                         realtype *sJpnorm, realtype *sFdotJp)
+{
+  KINSpilsMem kinspils_mem;
+  SpfgmrMem spfgmr_mem;
+  int ret, nli_inc, nps_inc;
+  realtype res_norm;
+  
+  kinspils_mem = (KINSpilsMem) kin_mem->kin_lmem;
+
+  spfgmr_mem = (SpfgmrMem) kinspils_mem->s_spils_mem;
+
+  /* Set initial guess to xx = 0. bb is set, by the routine
+     calling KINSpfgmrSolve, to the RHS vector for the system
+     to be solved. */ 
+  N_VConst(ZERO, xx);
+
+  kinspils_mem->s_new_uu = TRUE; /* set flag required for user Jacobian routine */
+
+  /* call SpfgmrSolve */
+  ret = SpfgmrSolve(spfgmr_mem, kin_mem, xx, bb, kinspils_mem->s_pretype, 
+		    kinspils_mem->s_gstype, kin_mem->kin_eps, 
+		    kinspils_mem->s_maxlrst, kinspils_mem->s_maxl, 
+		    kin_mem, kin_mem->kin_fscale, kin_mem->kin_fscale, 
+		    KINSpilsAtimes, KINSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
+
+  /* increment counters nli, nps, and ncfl 
+     (nni is updated in the KINSol main iteration loop) */
+
+  kinspils_mem->s_nli = kinspils_mem->s_nli + (long int) nli_inc;
+  kinspils_mem->s_nps = kinspils_mem->s_nps + (long int) nps_inc;
+
+  if (kin_mem->kin_printfl > 2) 
+    KINPrintInfo(kin_mem, PRNT_NLI, "KINSPFGMR", "KINSpfgmrSolve", INFO_NLI, nli_inc);
+
+  if (ret != 0) (kinspils_mem->s_ncfl)++;
+  kinspils_mem->s_last_flag = ret;
+
+  if ( (ret != 0) && (ret != SPFGMR_RES_REDUCED) ) {
+
+    /* Handle all failure returns from SpfgmrSolve */
+
+    switch(ret) {
+    case SPFGMR_PSOLVE_FAIL_REC:
+    case SPFGMR_ATIMES_FAIL_REC:
+      return(1);
+      break;
+    case SPFGMR_CONV_FAIL:
+    case SPFGMR_QRFACT_FAIL:
+    case SPFGMR_MEM_NULL:
+    case SPFGMR_GS_FAIL:
+    case SPFGMR_QRSOL_FAIL:
+    case SPFGMR_ATIMES_FAIL_UNREC:
+    case SPFGMR_PSOLVE_FAIL_UNREC:
+      return(-1);
+      break;
+    }
+  }
+
+  /*  SpfgmrSolve returned either SPFGMR_SUCCESS or SPFGMR_RES_REDUCED.
+
+     Compute the terms sJpnorm and sFdotJp for use in the linesearch
+     routine and in KINForcingTerm.  Both of these terms are subsequently
+     corrected if the step is reduced by constraints or the linesearch.
+
+     sJpnorm is the norm of the scaled product (scaled by fscale) of the
+     current Jacobian matrix J and the step vector p (= solution vector xx).
+
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
+
+  ret = KINSpilsAtimes(kin_mem, xx, bb);
+  if (ret > 0) {
+    kinspils_mem->s_last_flag = SPFGMR_ATIMES_FAIL_REC;
+    return(1);
+  }      
+  else if (ret < 0) {
+    kinspils_mem->s_last_flag = SPFGMR_ATIMES_FAIL_UNREC;
+    return(-1);
+  }
+
+  *sJpnorm = N_VWL2Norm(bb, kin_mem->kin_fscale);
+  N_VProd(bb, kin_mem->kin_fscale, bb);
+  N_VProd(bb, kin_mem->kin_fscale, bb);
+  *sFdotJp = N_VDotProd(kin_mem->kin_fval, bb);
+
+  if (kin_mem->kin_printfl > 2) KINPrintInfo(kin_mem, PRNT_EPS, "KINSPFGMR",
+					     "KINSpfgmrSolve", INFO_EPS, 
+					     res_norm, kin_mem->kin_eps);
+
+  return(0);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * Function : KINSpfgmrFree
+ * -----------------------------------------------------------------
+ * This routine frees memory specific to the SPFGMR linear solver.
+ * -----------------------------------------------------------------
+ */
+
+static int KINSpfgmrFree(KINMem kin_mem)
+{
+  KINSpilsMem kinspils_mem;
+  SpfgmrMem spfgmr_mem;
+
+  kinspils_mem = (KINSpilsMem) kin_mem->kin_lmem;
+
+  spfgmr_mem = (SpfgmrMem) kinspils_mem->s_spils_mem;
+  SpfgmrFree(spfgmr_mem);
+
+  if (kinspils_mem->s_pfree != NULL) (kinspils_mem->s_pfree)(kin_mem);
+
+  free(kinspils_mem); kinspils_mem = NULL;
+
+  return(0);
+}
diff --git a/src/kinsol/kinsol_spgmr.c b/src/kinsol/kinsol_spgmr.c
index 7f34d37..1341ca9 100644
--- a/src/kinsol/kinsol_spgmr.c
+++ b/src/kinsol/kinsol_spgmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2007/11/26 16:20:01 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the KINSOL scaled,
  * preconditioned GMRES linear solver, KINSpgmr.
@@ -45,8 +50,8 @@
 static int KINSpgmrInit(KINMem kin_mem);
 static int KINSpgmrSetup(KINMem kin_mem);
 static int KINSpgmrSolve(KINMem kin_mem, N_Vector xx, 
-                         N_Vector bb, realtype *res_norm);
-static void KINSpgmrFree(KINMem kin_mem);
+                         N_Vector bb, realtype *sJpnorm, realtype *sFdotJp);
+static int KINSpgmrFree(KINMem kin_mem);
 
 /*
  * -----------------------------------------------------------------
@@ -72,14 +77,13 @@ static void KINSpgmrFree(KINMem kin_mem);
 #define sqrt_relfunc   (kin_mem->kin_sqrt_relfunc)
 #define jacCurrent     (kin_mem->kin_jacCurrent)
 #define eps            (kin_mem->kin_eps)
-#define sJpnorm        (kin_mem->kin_sJpnorm)
-#define sfdotJp        (kin_mem->kin_sfdotJp)
 #define errfp          (kin_mem->kin_errfp)
 #define infofp         (kin_mem->kin_infofp)
 #define setupNonNull   (kin_mem->kin_setupNonNull)
 #define vtemp1         (kin_mem->kin_vtemp1)
 #define vec_tmpl       (kin_mem->kin_vtemp1)
 #define vtemp2         (kin_mem->kin_vtemp2)
+#define strategy       (kin_mem->kin_globalstrategy)
 
 #define pretype   (kinspils_mem->s_pretype)
 #define gstype    (kinspils_mem->s_gstype)
@@ -185,6 +189,8 @@ int KINSpgmr(void *kinmem, int maxl)
   kinspils_mem->s_maxlrst   = 0;
   kinspils_mem->s_last_flag = KINSPILS_SUCCESS;
 
+  kinSpilsInitializeCounters(kinspils_mem);
+
   /* Call SpgmrMalloc to allocate workspace for SPGMR */
 
   /* vec_tmpl passed as template vector */
@@ -238,9 +244,7 @@ static int KINSpgmrInit(KINMem kin_mem)
   kinspils_mem = (KINSpilsMem) lmem;
 
   /* initialize counters */
-
-  npe = nli = nps = ncfl = 0;
-  njtimes = nfes = 0;
+  kinSpilsInitializeCounters(kinspils_mem);
 
   /* set preconditioner type */
 
@@ -263,6 +267,12 @@ static int KINSpgmrInit(KINMem kin_mem)
     J_data = user_data;
   }
 
+  if ( (strategy == KIN_PICARD) && jtimesDQ ) {
+    KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSpgmrInit", 
+		    MSG_NOL_FAIL);
+    return(KIN_ILL_INPUT);
+  }
+
   last_flag = KINSPILS_SUCCESS;
   return(0);
 }
@@ -316,11 +326,12 @@ static int KINSpgmrSetup(KINMem kin_mem)
  */
 
 static int KINSpgmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb, 
-                         realtype *res_norm)
+                         realtype *sJpnorm, realtype *sFdotJp)
 {
   KINSpilsMem kinspils_mem;
   SpgmrMem spgmr_mem;
   int ret, nli_inc, nps_inc;
+  realtype res_norm;
   
   kinspils_mem = (KINSpilsMem) lmem;
 
@@ -338,7 +349,7 @@ static int KINSpgmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
 
   ret = SpgmrSolve(spgmr_mem, kin_mem, xx, bb, pretype, gstype, eps, 
                    maxlrst, kin_mem, fscale, fscale, KINSpilsAtimes,
-                   KINSpilsPSolve, res_norm, &nli_inc, &nps_inc);
+                   KINSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
 
   /* increment counters nli, nps, and ncfl 
      (nni is updated in the KINSol main iteration loop) */
@@ -350,57 +361,60 @@ static int KINSpgmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
     KINPrintInfo(kin_mem, PRNT_NLI, "KINSPGMR", "KINSpgmrSolve", INFO_NLI, nli_inc);
 
   if (ret != 0) ncfl++;
+  last_flag = ret;
 
-  /* Compute the terms sJpnorm and sfdotJp for use in the global strategy
-     routines and in KINForcingTerm. Both of these terms are subsequently
-     corrected if the step is reduced by constraints or the line search.
-
-     sJpnorm is the norm of the scaled product (scaled by fscale) of
-     the current Jacobian matrix J and the step vector p.
-
-     sfdotJp is the dot product of the scaled f vector and the scaled
-     vector J*p, where the scaling uses fscale. */
-
-  ret = KINSpilsAtimes(kin_mem, xx, bb);
-  if (ret == 0)     ret = SPGMR_SUCCESS;
-  else if (ret > 0) ret = SPGMR_ATIMES_FAIL_REC;
-  else if (ret < 0) ret = SPGMR_ATIMES_FAIL_UNREC;
-
-  sJpnorm = N_VWL2Norm(bb,fscale);
-  N_VProd(bb, fscale, bb);
-  N_VProd(bb, fscale, bb);
-  sfdotJp = N_VDotProd(fval, bb);
+  if ( (ret != 0) && (ret != SPGMR_RES_REDUCED) ) {
+
+    /* Handle all failure returns from SpgmrSolve */
+
+    switch(ret) {
+    case SPGMR_PSOLVE_FAIL_REC:
+    case SPGMR_ATIMES_FAIL_REC:
+      return(1);
+      break;
+    case SPGMR_CONV_FAIL:
+    case SPGMR_QRFACT_FAIL:
+    case SPGMR_MEM_NULL:
+    case SPGMR_GS_FAIL:
+    case SPGMR_QRSOL_FAIL:
+    case SPGMR_ATIMES_FAIL_UNREC:
+    case SPGMR_PSOLVE_FAIL_UNREC:
+      return(-1);
+      break;
+    }
+  }
 
-  if (printfl > 2)
-    KINPrintInfo(kin_mem, PRNT_EPS, "KINSPGMR", "KINSpgmrSolve", INFO_EPS, *res_norm, eps);
+  /*  SpgmrSolve returned either SPGMR_SUCCESS or SPGMR_RES_REDUCED.
 
-  /* Interpret return value from SpgmrSolve */
+     Compute the terms sJpnorm and sFdotJp for use in the linesearch
+     routine and in KINForcingTerm.  Both of these terms are subsequently
+     corrected if the step is reduced by constraints or the linesearch.
 
-  last_flag = ret;
+     sJpnorm is the norm of the scaled product (scaled by fscale) of the
+     current Jacobian matrix J and the step vector p (= solution vector xx).
 
-  switch(ret) {
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
 
-  case SPGMR_SUCCESS:
-  case SPGMR_RES_REDUCED:
-    return(0);
-    break;
-  case SPGMR_PSOLVE_FAIL_REC:
-  case SPGMR_ATIMES_FAIL_REC:
+  ret = KINSpilsAtimes(kin_mem, xx, bb);
+  if (ret > 0) {
+    last_flag = SPGMR_ATIMES_FAIL_REC;
     return(1);
-    break;
-  case SPGMR_CONV_FAIL:
-  case SPGMR_QRFACT_FAIL:
-  case SPGMR_MEM_NULL:
-  case SPGMR_GS_FAIL:
-  case SPGMR_QRSOL_FAIL:
-  case SPGMR_ATIMES_FAIL_UNREC:
-  case SPGMR_PSOLVE_FAIL_UNREC:
+  }      
+  else if (ret < 0) {
+    last_flag = SPGMR_ATIMES_FAIL_UNREC;
     return(-1);
-    break;
   }
 
-  return(0);
+  *sJpnorm = N_VWL2Norm(bb, fscale);
+  N_VProd(bb, fscale, bb);
+  N_VProd(bb, fscale, bb);
+  *sFdotJp = N_VDotProd(fval, bb);
+
+  if (printfl > 2) KINPrintInfo(kin_mem, PRNT_EPS, "KINSPGMR",
+                     "KINSpgmrSolve", INFO_EPS, res_norm, eps);
 
+  return(0);
 }
 
 /*
@@ -411,7 +425,7 @@ static int KINSpgmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
  * -----------------------------------------------------------------
  */
 
-static void KINSpgmrFree(KINMem kin_mem)
+static int KINSpgmrFree(KINMem kin_mem)
 {
   KINSpilsMem kinspils_mem;
   SpgmrMem spgmr_mem;
@@ -424,4 +438,6 @@ static void KINSpgmrFree(KINMem kin_mem)
   if (kinspils_mem->s_pfree != NULL) (kinspils_mem->s_pfree)(kin_mem);
 
   free(kinspils_mem); kinspils_mem = NULL;
+
+  return(0);
 }
diff --git a/src/kinsol/kinsol_spils.c b/src/kinsol/kinsol_spils.c
index 4191730..262c738 100644
--- a/src/kinsol/kinsol_spils.c
+++ b/src/kinsol/kinsol_spils.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2011/06/23 00:36:18 $
+ * $Revision: 4749 $
+ * $Date: 2016-04-23 18:42:38 -0700 (Sat, 23 Apr 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the KINSPILS linear solvers.
  * -----------------------------------------------------------------
@@ -600,7 +605,7 @@ int KINSpilsDQJtimes(N_Vector v, N_Vector Jv,
  
   /*  this expression for sigma is from p. 469, Brown and Saad paper */
 
-  sigma = sign*sqrt_relfunc*MAX(ABS(sutsv),sq1norm)/vtv; 
+  sigma = sign*sqrt_relfunc*SUNMAX(SUNRabs(sutsv),sq1norm)/vtv;
 
   sigma_inv = ONE/sigma;
 
@@ -621,3 +626,14 @@ int KINSpilsDQJtimes(N_Vector v, N_Vector Jv,
   return(0);
 }
 
+int kinSpilsInitializeCounters(KINSpilsMem kinspils_mem)
+{
+  kinspils_mem->s_npe     = 0;
+  kinspils_mem->s_nli     = 0;
+  kinspils_mem->s_nps     = 0;
+  kinspils_mem->s_ncfl    = 0;
+  kinspils_mem->s_njtimes = 0;
+  kinspils_mem->s_nfes    = 0;
+  
+  return(0);
+}
diff --git a/src/kinsol/kinsol_spils_impl.h b/src/kinsol/kinsol_spils_impl.h
index 6950bc0..e7b5b3a 100644
--- a/src/kinsol/kinsol_spils_impl.h
+++ b/src/kinsol/kinsol_spils_impl.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2010/12/01 22:43:33 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * Common implementation header file for the scaled, preconditioned
  * linear solver modules.
@@ -18,18 +23,19 @@
 #ifndef _KINSPILS_IMPL_H
 #define _KINSPILS_IMPL_H
 
+#include <kinsol/kinsol_spils.h>
+#include "kinsol_impl.h"
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <kinsol/kinsol_spils.h>
-#include "kinsol_impl.h"
-
 /* Types of iterative linear solvers */
 
 #define SPILS_SPGMR   1
 #define SPILS_SPBCG   2
 #define SPILS_SPTFQMR 3
+#define SPILS_SPFGMR  5
 
 /*
  * -----------------------------------------------------------------
@@ -59,16 +65,16 @@ typedef struct KINSpilsMemRec {
 
   int  s_maxl;          /* maximum allowable dimension of Krylov subspace      */     
   int  s_pretype;       /* preconditioning type: PREC_NONE, PREC_RIGHT,
-			   PREC_LEFT or PREC_BOTH (used by SPGMR module and
-			   defined in sundials_iterative.h)                    */
+                           PREC_LEFT or PREC_BOTH (used by SPGMR module and
+                           defined in sundials_iterative.h)                    */
   int  s_gstype;        /* Gram-Schmidt orthogonalization procedure:
-			   CLASSICAL_GS or MODIFIED_GS (used by SPGMR module
-			   and defined in sundials_iterative.h)                */
+                           CLASSICAL_GS or MODIFIED_GS (used by SPGMR module
+                           and defined in sundials_iterative.h)                */
   booleantype s_new_uu; /* flag indicating if the iterate has been updated -
-			   Jacobian must be updated/reevaluated (meant to be
-			   used by user-supplied jtimes function)              */
+                           Jacobian must be updated/reevaluated (meant to be
+                           used by user-supplied jtimes function)              */
   int s_maxlrst;        /* maximum number of times the SPGMR linear solver
-			   can be restarted                                    */
+                           can be restarted                                    */
 
   /* counters */
 
@@ -77,10 +83,10 @@ typedef struct KINSpilsMemRec {
   long int s_nps;     /* number of calls to preconditioner solve fun.          */
   long int s_ncfl;    /* number of linear convergence failures                 */
   long int s_nfes;    /* number of evaluations of the system function F(u) or
-			 number of calls made to func routine                  */    
+                         number of calls made to func routine                  */    
   long int s_njtimes; /* number of times the matrix-vector product J(u)*v
-			 was computed or number of calls made to jtimes
-			 routine                                               */
+                         was computed or number of calls made to jtimes
+                         routine                                               */
 
   /* miscellaneous */
 
@@ -89,7 +95,7 @@ typedef struct KINSpilsMemRec {
   long int s_last_flag; /* last flag returned                                  */
 
 
-   /* Preconditioner computation
+  /* Preconditioner computation
    * (a) user-provided:
    *     - P_data == user_data
    *     - pfree == NULL (the user dealocates memory for user_data)
@@ -100,7 +106,7 @@ typedef struct KINSpilsMemRec {
  
   KINSpilsPrecSetupFn s_pset;     
   KINSpilsPrecSolveFn s_psolve; 
-  void (*s_pfree)(KINMem kin_mem);
+  int (*s_pfree)(KINMem kin_mem);
   void *s_P_data;
 
   /* Jacobian times vector compuation
@@ -125,7 +131,7 @@ typedef struct KINSpilsMemRec {
  * -----------------------------------------------------------------
  */
 
-/* KINSpgmr Atimes and PSolve routines called by generic SPGMR solver */
+/* KINSpgmr Atimes and PSolve routines called by generic solver */
 
 int KINSpilsAtimes(void *kinsol_mem, N_Vector v, N_Vector z);
 int KINSpilsPSolve(void *kinsol_mem, N_Vector r, N_Vector z, int lr);
@@ -136,6 +142,11 @@ int KINSpilsDQJtimes(N_Vector v, N_Vector Jv,
                      N_Vector u, booleantype *new_u, 
                      void *data);
 
+/* Auxilliary functions */
+
+int kinSpilsInitializeCounters(KINSpilsMem kinspils_mem);
+
+
 /*
  * -----------------------------------------------------------------
  * KINSPILS error messages
diff --git a/src/kinsol/kinsol_sptfqmr.c b/src/kinsol/kinsol_sptfqmr.c
index 3ab6228..57ec6a1 100644
--- a/src/kinsol/kinsol_sptfqmr.c
+++ b/src/kinsol/kinsol_sptfqmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2007/11/26 16:20:01 $
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Aaron Collier and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the KINSOL interface to the
  * scaled, preconditioned TFQMR (SPTFQMR) iterative linear solver.
@@ -45,8 +50,8 @@
 static int KINSptfqmrInit(KINMem kin_mem);
 static int KINSptfqmrSetup(KINMem kin_mem);
 static int KINSptfqmrSolve(KINMem kin_mem, N_Vector xx,
-			   N_Vector bb, realtype *res_norm);
-static void KINSptfqmrFree(KINMem kin_mem);
+			   N_Vector bb, realtype *sJpnorm, realtype *sFdotJp);
+static int KINSptfqmrFree(KINMem kin_mem);
 
 /*
  * -----------------------------------------------------------------
@@ -71,14 +76,13 @@ static void KINSptfqmrFree(KINMem kin_mem);
 #define fscale       (kin_mem->kin_fscale)
 #define sqrt_relfunc (kin_mem->kin_sqrt_relfunc)
 #define eps          (kin_mem->kin_eps)
-#define sJpnorm      (kin_mem->kin_sJpnorm)
-#define sfdotJp      (kin_mem->kin_sfdotJp)
 #define errfp        (kin_mem->kin_errfp)
 #define infofp       (kin_mem->kin_infofp)
 #define setupNonNull (kin_mem->kin_setupNonNull)
 #define vtemp1       (kin_mem->kin_vtemp1)
 #define vec_tmpl     (kin_mem->kin_vtemp1)
 #define vtemp2       (kin_mem->kin_vtemp2)
+#define strategy     (kin_mem->kin_globalstrategy)
 
 #define pretype     (kinspils_mem->s_pretype)
 #define nli         (kinspils_mem->s_nli)
@@ -183,6 +187,8 @@ int KINSptfqmr(void *kinmem, int maxl)
   kinspils_mem->s_pretype   = PREC_NONE;
   kinspils_mem->s_last_flag = KINSPILS_SUCCESS;
 
+  kinSpilsInitializeCounters(kinspils_mem);
+
   /* Call SptfqmrMalloc to allocate workspace for SPTFQMR */
 
   /* vec_tmpl passed as template vector */
@@ -232,15 +238,10 @@ int KINSptfqmr(void *kinmem, int maxl)
 static int KINSptfqmrInit(KINMem kin_mem)
 {
   KINSpilsMem kinspils_mem;
-  SptfqmrMem sptfqmr_mem;
-
   kinspils_mem = (KINSpilsMem) lmem;
-  sptfqmr_mem = (SptfqmrMem) spils_mem;
 
   /* initialize counters */
-
-  npe = nli = nps = ncfl = 0;
-  njtimes = nfes = 0;
+  kinSpilsInitializeCounters(kinspils_mem);
 
   /* set preconditioner type */
 
@@ -263,8 +264,11 @@ static int KINSptfqmrInit(KINMem kin_mem)
     J_data = user_data;
   }
 
-  /*  Set maxl in the SPTFQMR memory in case it was changed by the user */
-  sptfqmr_mem->l_max  = maxl;
+  if ( (strategy == KIN_PICARD) && jtimesDQ ) {
+    KINProcessError(kin_mem, KIN_ILL_INPUT, "KINSOL", "KINSptfqmrInit", 
+		    MSG_NOL_FAIL);
+    return(KIN_ILL_INPUT);
+  }
 
   last_flag = KINSPILS_SUCCESS;
   return(0);
@@ -319,11 +323,12 @@ static int KINSptfqmrSetup(KINMem kin_mem)
  */
 
 static int KINSptfqmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb, 
-			   realtype *res_norm)
+			   realtype *sJpnorm, realtype *sFdotJp)
 {
   KINSpilsMem kinspils_mem;
   SptfqmrMem sptfqmr_mem;
   int ret, nli_inc, nps_inc;
+  realtype res_norm;
   
   kinspils_mem = (KINSpilsMem) lmem;
   sptfqmr_mem = (SptfqmrMem) spils_mem;
@@ -340,7 +345,7 @@ static int KINSptfqmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
 
   ret = SptfqmrSolve(sptfqmr_mem, kin_mem, xx, bb, pretype, eps,
 		     kin_mem, fscale, fscale, KINSpilsAtimes,
-		     KINSpilsPSolve, res_norm, &nli_inc, &nps_inc);
+		     KINSpilsPSolve, &res_norm, &nli_inc, &nps_inc);
 
   /* increment counters nli, nps, and ncfl 
      (nni is updated in the KINSol main iteration loop) */
@@ -352,56 +357,57 @@ static int KINSptfqmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
     KINPrintInfo(kin_mem, PRNT_NLI, "KINSPTFQMR", "KINSptfqmrSolve", INFO_NLI, nli_inc);
 
   if (ret != 0) ncfl++;
+  last_flag = ret;
 
-  /* Compute the terms sJpnorm and sfdotJp for use in the global strategy
-     routines and in KINForcingTerm. Both of these terms are subsequently
-     corrected if the step is reduced by constraints or the line search.
-
-     sJpnorm is the norm of the scaled product (scaled by fscale) of
-     the current Jacobian matrix J and the step vector p.
-
-     sfdotJp is the dot product of the scaled f vector and the scaled
-     vector J*p, where the scaling uses fscale. */
-
-  ret = KINSpilsAtimes(kin_mem, xx, bb);
-  if (ret == 0)     ret = SPTFQMR_SUCCESS;
-  else if (ret > 0) ret = SPTFQMR_ATIMES_FAIL_REC;
-  else if (ret < 0) ret = SPTFQMR_ATIMES_FAIL_UNREC;
-
-  sJpnorm = N_VWL2Norm(bb,fscale);
-  N_VProd(bb, fscale, bb);
-  N_VProd(bb, fscale, bb);
-  sfdotJp = N_VDotProd(fval, bb);
+  if ( (ret != 0) && (ret != SPTFQMR_RES_REDUCED) ) {
+
+    /* Handle all failure returns from SptfqmrSolve */
+
+    switch(ret) {
+    case SPTFQMR_PSOLVE_FAIL_REC:
+    case SPTFQMR_ATIMES_FAIL_REC:
+      return(1);
+      break;
+    case SPTFQMR_CONV_FAIL:
+    case SPTFQMR_MEM_NULL:
+    case SPTFQMR_ATIMES_FAIL_UNREC:
+    case SPTFQMR_PSOLVE_FAIL_UNREC:
+      return(-1);
+      break;
+    }
+  }
 
-  if (printfl > 2) 
-    KINPrintInfo(kin_mem, PRNT_EPS, "KINSPTFQMR", "KINSptfqmrSolve", INFO_EPS, *res_norm, eps);
+  /*  SptfqmrSolve returned either SPTFQMR_SUCCESS or SPTFQMR_RES_REDUCED.
 
-  /* Interpret return value from SptfqmrSolve */
+     Compute the terms sJpnorm and sFdotJp for use in the linesearch
+     routine and in KINForcingTerm.  Both of these terms are subsequently
+     corrected if the step is reduced by constraints or the linesearch.
 
-  last_flag = ret;
+     sJpnorm is the norm of the scaled product (scaled by fscale) of the
+     current Jacobian matrix J and the step vector p (= solution vector xx).
 
-  switch(ret) {
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
 
-  case SPTFQMR_SUCCESS:
-  case SPTFQMR_RES_REDUCED:
-    return(0);
-    break;
-  case SPTFQMR_PSOLVE_FAIL_REC:
-    return(1);
-    break;
-  case SPTFQMR_ATIMES_FAIL_REC:
+  ret = KINSpilsAtimes(kin_mem, xx, bb);
+  if (ret > 0) {
+    last_flag = SPTFQMR_ATIMES_FAIL_REC;
     return(1);
-    break;
-  case SPTFQMR_CONV_FAIL:
-  case SPTFQMR_MEM_NULL:
-  case SPTFQMR_ATIMES_FAIL_UNREC:
-  case SPTFQMR_PSOLVE_FAIL_UNREC:
+  }      
+  else if (ret < 0) {
+    last_flag = SPTFQMR_ATIMES_FAIL_UNREC;
     return(-1);
-    break;
   }
 
-  return(0);
+  *sJpnorm = N_VWL2Norm(bb, fscale);
+  N_VProd(bb, fscale, bb);
+  N_VProd(bb, fscale, bb);
+  *sFdotJp = N_VDotProd(fval, bb);
+
+  if (printfl > 2) KINPrintInfo(kin_mem, PRNT_EPS, "KINSPTFQMR",
+                     "KINSptfqmrSolve", INFO_EPS, res_norm, eps);
 
+  return(0);
 }
 
 /*
@@ -412,7 +418,7 @@ static int KINSptfqmrSolve(KINMem kin_mem, N_Vector xx, N_Vector bb,
  * -----------------------------------------------------------------
  */
 
-static void KINSptfqmrFree(KINMem kin_mem)
+static int KINSptfqmrFree(KINMem kin_mem)
 {
   KINSpilsMem kinspils_mem;
   SptfqmrMem sptfqmr_mem;
@@ -425,4 +431,6 @@ static void KINSptfqmrFree(KINMem kin_mem)
   if (kinspils_mem->s_pfree != NULL) (kinspils_mem->s_pfree)(kin_mem);
 
   free(kinspils_mem); kinspils_mem = NULL;
+
+  return(0);
 }
diff --git a/src/kinsol/kinsol_superlumt.c b/src/kinsol/kinsol_superlumt.c
new file mode 100644
index 0000000..851ad1c
--- /dev/null
+++ b/src/kinsol/kinsol_superlumt.c
@@ -0,0 +1,506 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4924 $
+ * $Date: 2016-09-19 14:36:05 -0700 (Mon, 19 Sep 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for the KINSuperLUMT linear solver.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sundials/sundials_math.h"
+#include "sundials/sundials_superlumt_impl.h"
+
+#include "kinsol/kinsol_superlumt.h"
+#include "kinsol_impl.h"
+#include "kinsol_sparse_impl.h"
+
+/* Constants */
+
+#define ONE          RCONST(1.0)
+#define TWO          RCONST(2.0)
+
+/* KINSuperLUMT linit, lsetup, lsolve, and lfree routines */
+ 
+static int kinSuperLUMTInit(KINMem kin_mem);
+static int kinSuperLUMTSetup(KINMem kin_mem);
+static int kinSuperLUMTSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+		       realtype *sJpnorm, realtype *sFdotJp);		       
+static int kinSuperLUMTFree(KINMem kin_mem);
+
+/*
+ * -----------------------------------------------------------------
+ * KINSuperLUMT
+ * -----------------------------------------------------------------
+ * This routine initializes the memory record and sets various function
+ * fields specific to the KINSOL / SuperLUMT linear solver module.  
+ * KINSuperLUMT first calls the existing lfree routine if this is not NULL.
+ * Then it sets the kin_linit, kin_lsetup, kin_lsolve, and
+ * kin_lfree fields in (*kin_mem) to be kinSuperLUMTInit, kinSuperLUMTSetup,
+ * kinSuperLUMTSolve, NULL, and kinSuperLUMTFree, respectively.
+ * It allocates memory for a structure of type kinsluMemRec and sets
+ * the kin_lmem field in (*kin_mem) to the address of this structure.
+ * It sets setupNonNull in (*kin_mem) to TRUE.
+ * Finally, it allocates memory for SuperLUMT.
+ * The return value is KINSLS_SUCCESS = 0, KINSLS_LMEM_FAIL = -1,
+ * or KINSLS_ILL_INPUT = -2.
+ *
+ * NOTE: The SuperLUMT linear solver assumes a serial implementation
+ *       of the NVECTOR package. Therefore, KINSuperLUMT will first 
+ *       test for a compatible N_Vector internal representation
+ *       by checking that the function N_VGetArrayPointer exists.
+ * -----------------------------------------------------------------
+ */
+
+int KINSuperLUMT(void *kin_mem_v, int num_threads, int n, int nnz)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+  SLUMTData slumt_data;
+  int *perm_c, *perm_r;
+  int nrhs, panel_size, relax;
+  double *bd;
+  SuperMatrix *B;
+
+  /* Return immediately if kin_mem is NULL. */
+  if (kin_mem_v == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINSuperLUMT", 
+		    MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+  kin_mem = (KINMem) kin_mem_v;
+
+  /* Test if the NVECTOR package is compatible with the Direct solver */
+  if (kin_mem->kin_vtemp1->ops->nvgetarraypointer == NULL) {
+    KINProcessError(kin_mem, KINSLS_ILL_INPUT, "KINSLS", "KINSuperLUMT", 
+		    MSGSP_BAD_NVECTOR);
+    return(KINSLS_ILL_INPUT);
+  }
+
+  if (kin_mem->kin_lfree != NULL) kin_mem->kin_lfree(kin_mem);
+
+  /* Set five main function fields in kin_mem. */
+  kin_mem->kin_linit  = kinSuperLUMTInit;
+  kin_mem->kin_lsetup = kinSuperLUMTSetup;
+  kin_mem->kin_lsolve = kinSuperLUMTSolve;
+  kin_mem->kin_lfree  = kinSuperLUMTFree;
+
+  /* Get memory for kinSlsMemRec. */
+  kinsls_mem = (KINSlsMem) malloc(sizeof(struct KINSlsMemRec));
+  if (kinsls_mem == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "KINSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(KINSLS_MEM_FAIL);
+  }
+
+  /* Get memory for SLUMTData. */
+  slumt_data = (SLUMTData)malloc(sizeof(struct SLUMTDataRec));
+  if (slumt_data == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "KINSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(KINSLS_MEM_FAIL);
+  }
+
+  kin_mem->kin_setupNonNull = TRUE;
+
+  /* Set default Jacobian routine and Jacobian data */
+  kinsls_mem->s_jaceval = NULL;
+  kinsls_mem->s_jacdata = kin_mem->kin_user_data;
+
+  /* Allocate memory for the sparse Jacobian */
+  kinsls_mem->s_JacMat = SparseNewMat(n, n, nnz, CSC_MAT);
+  if (kinsls_mem->s_JacMat == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "KINSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(KINSLS_MEM_FAIL);
+  }
+
+   /* Set up memory for the permutations */
+  perm_r = (int *)malloc(n*sizeof(int));
+  if (perm_r == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "kinSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    return(KINSLS_MEM_FAIL);
+  }
+  perm_c = (int *)malloc(n*sizeof(int));
+  if (perm_c == NULL) {
+    KINProcessError(kin_mem, KINSLS_MEM_FAIL, "KINSLS", "kinSuperLUMT", 
+		    MSGSP_MEM_FAIL);
+    free(perm_r);
+    return(KINSLS_MEM_FAIL);
+  }
+  slumt_data->perm_r = perm_r;
+  slumt_data->perm_c = perm_c;
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+
+  /* Set default parameters for SuperLU */
+  slumt_data->num_threads = num_threads;
+  slumt_data->diag_pivot_thresh = 1.0;
+
+  /* Allocate structures for SuperLU */
+  slumt_data->Gstat = (Gstat_t *)malloc(sizeof(Gstat_t));
+  slumt_data->s_A = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_AC = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_L = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_U = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  slumt_data->s_A->Store  = NULL;
+  slumt_data->s_AC->Store = NULL;
+  slumt_data->s_L->Store  = NULL;
+  slumt_data->s_U->Store  = NULL;
+  slumt_data->superlumt_options = (superlumt_options_t *)malloc(sizeof(superlumt_options_t));
+
+  dCreate_CompCol_Matrix(slumt_data->s_A, kinsls_mem->s_JacMat->M, kinsls_mem->s_JacMat->N, 
+			 kinsls_mem->s_JacMat->NNZ, kinsls_mem->s_JacMat->data, 
+			 kinsls_mem->s_JacMat->indexvals, kinsls_mem->s_JacMat->indexptrs, 
+			 SLU_NC, SLU_D, SLU_GE);
+
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  StatAlloc(kinsls_mem->s_JacMat->N, num_threads, panel_size, relax, slumt_data->Gstat);
+  
+  /* Create RHS matrix */
+  nrhs = 1;
+  bd = NULL;
+  B = (SuperMatrix *)malloc(sizeof(SuperMatrix));
+  B->Store = NULL;
+  dCreate_Dense_Matrix(B, n, nrhs, bd, n, 
+		       SLU_DN, SLU_D, SLU_GE);
+  slumt_data->s_B = B;
+
+  /* Set ordering to COLAMD as the kinsol default use.
+     Users can set a different value with KINSuperLUMTSetOrdering,
+     and the user-set value is loaded before any call to factorize the
+     matrix in kinSuperLUMTSetup.  */
+  slumt_data->s_ordering = 3;
+
+  /* This is a direct linear solver */
+  kin_mem->kin_inexact_ls = FALSE;
+
+  /* Attach linear solver memory to the nonlinear solver memory */
+  kinsls_mem->s_solver_data = (void *) slumt_data;
+  kin_mem->kin_lmem = kinsls_mem;
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+
+  return(KINSLS_SUCCESS);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * KINSuperLUMT interface functions
+ * -----------------------------------------------------------------
+ */
+
+/*
+  This routine does remaining initializations specific to the KINSuperLUMT
+  linear solver module.  
+  It returns 0 if successful.
+*/
+
+static int kinSuperLUMTInit(KINMem kin_mem)
+{
+  int num_threads, n;
+  KINSlsMem kinsls_mem;
+  SLUMTData slumt_data;
+
+  kinsls_mem = (KINSlsMem)kin_mem->kin_lmem;
+  slumt_data = (SLUMTData) kinsls_mem->s_solver_data;
+
+  kinsls_mem->s_nje = 0;
+  kinsls_mem->s_first_factorize = 1;
+
+  /* ------------------------------------------------------------
+     Allocate storage and initialize statistics variables. 
+     ------------------------------------------------------------*/
+  n = kinsls_mem->s_JacMat->N;
+  num_threads = slumt_data->num_threads;
+
+  StatInit(n, num_threads, slumt_data->Gstat);
+
+  kinsls_mem->s_last_flag = 0;
+  return(0);
+}
+
+/*
+  This routine does the setup operations for the KINSuperLUMT linear 
+  solver module.  It calls the Jacobian evaluation routine,
+  updates counters, and calls the LU factorization routine.
+  The return value is either
+     KINSLS_SUCCESS = 0  if successful,
+     +1  if the jac routine failed recoverably or the
+         LU factorization failed, or
+     -1  if the jac routine failed unrecoverably.
+*/
+
+static int kinSuperLUMTSetup(KINMem kin_mem)
+{
+  int retval, info;
+  int nprocs, panel_size, relax, permc_spec, lwork;
+  int *perm_r, *perm_c;
+  double diag_pivot_thresh, drop_tol;
+  fact_t fact;
+  trans_t trans;
+  yes_no_t refact, usepr;
+  KINSlsMem kinsls_mem;
+  KINSlsSparseJacFn jaceval;
+  SuperMatrix *A, *AC, *L, *U;
+  Gstat_t *Gstat;
+  superlumt_options_t *superlumt_options;
+  SLUMTData slumt_data;
+  SlsMat JacMat;
+  void *jacdata;
+  void *work;
+
+  kinsls_mem = (KINSlsMem) (kin_mem->kin_lmem);
+
+  slumt_data = (SLUMTData) kinsls_mem->s_solver_data;
+
+  jaceval = kinsls_mem->s_jaceval;
+  jacdata = kinsls_mem->s_jacdata;
+  JacMat = kinsls_mem->s_JacMat;
+
+  superlumt_options = slumt_data->superlumt_options;
+  A = slumt_data->s_A;
+  AC = slumt_data->s_AC;
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  Gstat = slumt_data->Gstat;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  nprocs = slumt_data->num_threads;
+  diag_pivot_thresh = slumt_data->diag_pivot_thresh;
+
+  /* Set option values for SuperL_MT */
+  panel_size = sp_ienv(1);
+  relax = sp_ienv(2);
+  fact = EQUILIBRATE;
+  trans = NOTRANS;
+  usepr = NO;
+  drop_tol = 0.0;
+  lwork = 0;
+  work = NULL;
+
+ /* Check that Jacobian eval routine is set */
+  if (jaceval == NULL) {
+    KINProcessError(kin_mem, KINSLS_JAC_NOSET, "KINSLS", "kinSuperLUMTSetup", 
+		    MSGSP_JAC_NOSET);
+    free(kinsls_mem); kinsls_mem = NULL;
+    return(KINSLS_JAC_NOSET);
+  }
+
+  /* Increment nje counter and call Jacobian eval routine. */
+  kinsls_mem->s_nje++;
+  retval = jaceval(kin_mem->kin_uu, kin_mem->kin_fval, JacMat, jacdata, 
+		   kin_mem->kin_vtemp1, kin_mem->kin_vtemp2);
+
+  if (retval < 0) {
+    KINProcessError(kin_mem, KINSLS_JACFUNC_UNRECVR, "KINSLS", 
+		    "kinSuperLUMTSetup", MSGSP_JACFUNC_FAILED);
+    kinsls_mem->s_last_flag = KINSLS_JACFUNC_UNRECVR;
+    return(KINSLS_JACFUNC_UNRECVR);
+  }
+  if (retval > 0) {
+    kinsls_mem->s_last_flag = KINSLS_JACFUNC_RECVR;
+    return(+1);
+  }
+
+  if (kinsls_mem->s_first_factorize) {
+    /* Update the ordering option with any user-updated values from 
+       calls to KINSuperLUMTSetOrdering */
+    permc_spec = slumt_data->s_ordering;
+    get_perm_c(permc_spec, A, perm_c);
+ 
+    refact= NO;
+    kinsls_mem->s_first_factorize = 0;
+  }
+  else {
+    /* ------------------------------------------------------------
+       Re-initialize statistics variables 
+       ------------------------------------------------------------*/
+    StatInit(JacMat->N, nprocs, Gstat);
+    Destroy_CompCol_Permuted(AC);
+    refact= YES;
+  }
+
+  /* ------------------------------------------------------------
+     Initialize the option structure superlumt_options using the
+     user-input parameters;  Subsequent calls will re-initialize
+     options.
+     Apply perm_c to the columns of original A to form AC.
+     ------------------------------------------------------------*/
+  pdgstrf_init(nprocs, fact, trans, refact, panel_size, relax,
+	       diag_pivot_thresh, usepr, drop_tol, perm_c, perm_r,
+	       work, lwork, A, AC, superlumt_options, Gstat);
+  /* ------------------------------------------------------------
+     Compute the LU factorization of A.
+     The following routine will create nprocs threads.
+     ------------------------------------------------------------*/
+  pdgstrf(superlumt_options, AC, perm_r, L, U, Gstat, &info);
+    
+  if (info != 0) {
+    kinsls_mem->s_last_flag = info;
+    return(+1);
+  }
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+
+  return(0);
+}
+
+/*
+  This routine handles the solve operation for the KINSuperLUMT linear
+  solver module.  It calls the SuperLUMT solve routine, 
+  then returns KINSLS_SUCCESS = 0.
+*/
+
+static int kinSuperLUMTSolve(KINMem kin_mem, N_Vector x, N_Vector b,
+			     realtype *sJpnorm, realtype *sFdotJp)		       
+{
+  int info, trans;
+  int *perm_r, *perm_c;
+  KINSlsMem kinsls_mem;
+  SuperMatrix *L, *U, *B;
+  Gstat_t *Gstat;
+  DNformat *Bstore;
+  SLUMTData slumt_data;
+  realtype *xd;
+  
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+  slumt_data = (SLUMTData) kinsls_mem->s_solver_data;
+
+  L = slumt_data->s_L;
+  U = slumt_data->s_U;
+  perm_r = slumt_data->perm_r;
+  perm_c = slumt_data->perm_c;
+  Gstat = slumt_data->Gstat;
+  B = slumt_data->s_B;
+   
+  /* Copy the right-hand side into x */
+  N_VScale(ONE, b, x);
+  xd = N_VGetArrayPointer(x);
+  Bstore = (DNformat *) (B->Store);
+  Bstore->nzval = xd;
+
+  /* Call SuperLUMT to solve the linear system using L and U */
+  trans = NOTRANS;
+  dgstrs(trans, L, U, perm_r, perm_c, B, Gstat, &info);
+
+  Bstore->nzval = NULL;
+
+  /* Compute the term sFdotJp for use in the linesearch routine.
+     This term is subsequently corrected if the step is reduced by
+     constraints or the linesearch.
+
+     sFdotJp is the dot product of the scaled f vector and the scaled
+     vector J*p, where the scaling uses fscale.                            */
+
+  N_VProd(b, kin_mem->kin_fscale, b);
+  N_VProd(b, kin_mem->kin_fscale, b);
+  *sFdotJp = N_VDotProd(kin_mem->kin_fval, b);
+
+  kinsls_mem->s_last_flag = KINSLS_SUCCESS;
+  return(KINSLS_SUCCESS);
+}
+
+/*
+  This routine frees memory specific to the KINSuperLUMT linear solver.
+*/
+
+static int kinSuperLUMTFree(KINMem kin_mem)
+{
+  KINSlsMem kinsls_mem;
+  SLUMTData slumt_data;
+  
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+  slumt_data = (SLUMTData) kinsls_mem->s_solver_data;
+
+  pxgstrf_finalize(slumt_data->superlumt_options, slumt_data->s_AC);
+
+  free(slumt_data->perm_r);
+  free(slumt_data->perm_c);
+  free(slumt_data->superlumt_options);
+  Destroy_SuperNode_SCP( (slumt_data->s_L) );
+  Destroy_CompCol_NCP( (slumt_data->s_U) );
+  StatFree( (slumt_data->Gstat) );
+  free(slumt_data->Gstat);
+  
+  Destroy_SuperMatrix_Store(slumt_data->s_B);
+  SUPERLU_FREE(slumt_data->s_A->Store);
+  if (kinsls_mem->s_JacMat) {
+    SparseDestroyMat(kinsls_mem->s_JacMat);
+    kinsls_mem->s_JacMat = NULL;
+  }
+
+  free(slumt_data->s_B);
+  free(slumt_data->s_A);
+  free(slumt_data->s_AC);
+  free(slumt_data->s_L);
+  free(slumt_data->s_U);
+
+  free(slumt_data); 
+  free(kin_mem->kin_lmem); 
+
+  return(0);
+}
+
+
+/* 
+ * -----------------------------------------------------------------
+ * Optional Input Specification Functions
+ * -----------------------------------------------------------------
+ *
+ * KINSuperLUMTSetOrdering sets the ordering used by SuperLUMT for reducing fill.
+ * Options are: 
+ * 0 for natural ordering
+ * 1 for minimal degree ordering on A'*A
+ * 2 for minimal degree ordering on A'+A
+ * 3 for approximate minimal degree ordering for unsymmetric matrices
+ * The default used in SUNDIALS is 3 for COLAMD.
+ * -----------------------------------------------------------------
+ */
+
+int KINSuperLUMTSetOrdering(void *kin_mem_v, int ordering_choice)
+{
+  KINMem kin_mem;
+  KINSlsMem kinsls_mem;
+  SLUMTData slumt_data;
+
+ /* Return immediately if kin_mem is NULL */
+  if (kin_mem_v == NULL) {
+    KINProcessError(NULL, KINSLS_MEM_NULL, "KINSLS", "KINSuperLUMTSetOrdering",
+		    MSGSP_KINMEM_NULL);
+    return(KINSLS_MEM_NULL);
+  }
+  kin_mem = (KINMem) kin_mem_v;
+  kinsls_mem = (KINSlsMem) kin_mem->kin_lmem;
+
+ /* Return if ordering choice argument is not valid */
+  if ( (ordering_choice != 0) && (ordering_choice != 1) && 
+       (ordering_choice != 2) && (ordering_choice != 3) ) {
+    KINProcessError(NULL, KINSLS_ILL_INPUT, "KINSLS", "KINSuperLUMTSetOrdering",
+		    MSGSP_ILL_INPUT);
+    return(KINSLS_ILL_INPUT);
+  }
+
+  slumt_data = (SLUMTData) kinsls_mem->s_solver_data;
+
+  slumt_data->s_ordering = ordering_choice;
+
+  return(KINSLS_SUCCESS);
+}
+
diff --git a/src/nvec_openmp/CMakeLists.txt b/src/nvec_openmp/CMakeLists.txt
new file mode 100644
index 0000000..eab8451
--- /dev/null
+++ b/src/nvec_openmp/CMakeLists.txt
@@ -0,0 +1,94 @@
+# ---------------------------------------------------------------
+# $Revision: 4075 $
+# $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+# ---------------------------------------------------------------
+# Programmer:  Steve Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the openmp NVECTOR library
+
+INSTALL(CODE "MESSAGE(\"\nInstall NVECTOR_OPENMP\n\")")
+
+# Add variable nvecopenmp_SOURCES with the sources for the NVECOPENMP lib
+SET(nvecopenmp_SOURCES nvector_openmp.c)
+
+# Add variable shared_SOURCES with the common SUNDIALS sources which will
+# also be included in the NVECOPENMP library
+SET(shared_SOURCES sundials_math.c)
+ADD_PREFIX(${sundials_SOURCE_DIR}/src/sundials/ shared_SOURCES)
+
+# Add variable nvecopenmp_HEADERS with the exported NVECOPENMP header files
+SET(nvecopenmp_HEADERS nvector_openmp.h)
+ADD_PREFIX(${sundials_SOURCE_DIR}/include/nvector/ nvecopenmp_HEADERS)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(.)
+
+# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY 
+ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+
+IF(OPENMP_FOUND)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+  # Use C flags for linker as well.
+  SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}")
+ENDIF(OPENMP_FOUND)
+
+# Rules for building and installing the static library:
+#  - Add the build target for the NVECOPENMP library
+#  - Set the library name and make sure it is not deleted
+#  - Install the NVECOPENMP library
+IF(BUILD_STATIC_LIBS)
+  ADD_LIBRARY(sundials_nvecopenmp_static STATIC ${nvecopenmp_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecopenmp_static
+    PROPERTIES OUTPUT_NAME sundials_nvecopenmp CLEAN_DIRECT_OUTPUT 1)
+  INSTALL(TARGETS sundials_nvecopenmp_static DESTINATION lib)
+ENDIF(BUILD_STATIC_LIBS)
+
+# Rules for building and installing the shared library:
+#  - Add the build target for the NVECOPENMP library
+#  - Set the library name and make sure it is not deleted
+#  - Set VERSION and SOVERSION for shared libraries
+#  - Install the NVECOPENMP library
+IF(BUILD_SHARED_LIBS)
+  ADD_LIBRARY(sundials_nvecopenmp_shared SHARED ${nvecopenmp_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecopenmp_shared
+    PROPERTIES OUTPUT_NAME sundials_nvecopenmp CLEAN_DIRECT_OUTPUT 1)
+  SET_TARGET_PROPERTIES(sundials_nvecopenmp_shared
+    PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION})
+  INSTALL(TARGETS sundials_nvecopenmp_shared DESTINATION lib)
+ENDIF(BUILD_SHARED_LIBS)
+
+# Install the NVECOPENMP header files
+INSTALL(FILES ${nvecopenmp_HEADERS} DESTINATION include/nvector)
+
+# If FCMIX is enabled, build and install the FNVECOPENMP library
+IF(FCMIX_ENABLE AND F77_FOUND)
+  SET(fnvecopenmp_SOURCES fnvector_openmp.c)
+  IF(BUILD_STATIC_LIBS)
+    ADD_LIBRARY(sundials_fnvecopenmp_static STATIC ${fnvecopenmp_SOURCES})
+    SET_TARGET_PROPERTIES(sundials_fnvecopenmp_static
+      PROPERTIES OUTPUT_NAME sundials_fnvecopenmp CLEAN_DIRECT_OUTPUT 1)
+    INSTALL(TARGETS sundials_fnvecopenmp_static DESTINATION lib)
+  ENDIF(BUILD_STATIC_LIBS)
+  IF(BUILD_SHARED_LIBS)
+    ADD_LIBRARY(sundials_fnvecopenmp_shared ${fnvecopenmp_SOURCES})
+    SET_TARGET_PROPERTIES(sundials_fnvecopenmp_shared
+      PROPERTIES OUTPUT_NAME sundials_fnvecopenmp CLEAN_DIRECT_OUTPUT 1)
+    SET_TARGET_PROPERTIES(sundials_fnvecopenmp_shared 
+      PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION})
+    INSTALL(TARGETS sundials_fnvecopenmp_shared DESTINATION lib)
+  ENDIF(BUILD_SHARED_LIBS)
+ENDIF(FCMIX_ENABLE AND F77_FOUND)
+
+#
+MESSAGE(STATUS "Added NVECTOR_OPENMP module")
diff --git a/src/nvec_openmp/README b/src/nvec_openmp/README
new file mode 100644
index 0000000..d7faa43
--- /dev/null
+++ b/src/nvec_openmp/README
@@ -0,0 +1,46 @@
+                     NVECTOR_OPENMP
+                 released as part of SUNDIALS
+    SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
+                   Release 2.7.0, September 2016
+
+
+OpenMP implementation of the NVECTOR module for SUNDIALS. 
+
+NVECTOR_OPENMP defines the content field of N_Vector to be a structure 
+containing the length of the vector, a pointer to the beginning of a 
+contiguous data array, and a boolean flag indicating ownership of the 
+data array.
+
+NVECTOR_OPENMP defines five macros to provide access to the content of 
+a openmp N_Vector, several constructors for variables of type N_Vector,
+a constructor for an array of variables of type N_Vector, and destructors
+for N_Vector and N_Vector array.
+
+NVECTOR_OPENMP provides implementations for all vector operations defined
+by the generic NVECTOR module in the table of operations.
+
+
+A. Documentation
+----------------
+
+The openmp NVECTOR implementation follows the serial implemenation
+fully described in the user documentation for any of the SUNDIALS
+solvers. A PDF file for the user guide for a particular solver
+is available in the solver's subdirectory under doc/.
+
+
+B. Installation
+---------------
+
+For basic installation instructions see /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see any of the user guides.
+
+
+C. Releases
+-----------
+
+v. 2.7.0 - Sep. 2015
+v. 2.6.2 - Aug. 2015
+v. 2.6.1 - Mar. 2015
+v. 2.6.0 - Mar. 2015
+
diff --git a/src/nvec_openmp/fnvector_openmp.c b/src/nvec_openmp/fnvector_openmp.c
new file mode 100644
index 0000000..6108cf7
--- /dev/null
+++ b/src/nvec_openmp/fnvector_openmp.c
@@ -0,0 +1,159 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4388 $
+ * $Date: 2015-02-25 15:50:00 -0800 (Wed, 25 Feb 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Steven Smith @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This file (companion of nvector_openmp.h) contains the
+ * implementation needed for the Fortran initialization of openmp
+ * vector operations.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "fnvector_openmp.h"
+
+/* Define global vector variables */
+
+N_Vector F2C_CVODE_vec;
+N_Vector F2C_CVODE_vecQ;
+N_Vector *F2C_CVODE_vecS;
+N_Vector F2C_CVODE_vecB;
+N_Vector F2C_CVODE_vecQB;
+
+N_Vector F2C_IDA_vec;
+N_Vector F2C_IDA_vecQ;
+N_Vector *F2C_IDA_vecS;
+N_Vector F2C_IDA_vecB;
+N_Vector F2C_IDA_vecQB;
+
+N_Vector F2C_KINSOL_vec;
+
+N_Vector F2C_ARKODE_vec;
+
+/* Fortran callable interfaces */
+
+void FNV_INITOMP(int *code, long int *N, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vec = NULL;
+    F2C_CVODE_vec = N_VNewEmpty_OpenMP(*N, *num_threads);
+    if (F2C_CVODE_vec == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vec = NULL;
+    F2C_IDA_vec = N_VNewEmpty_OpenMP(*N, *num_threads);
+    if (F2C_IDA_vec == NULL) *ier = -1;
+    break;
+  case FCMIX_KINSOL:
+    F2C_KINSOL_vec = NULL;
+    F2C_KINSOL_vec = N_VNewEmpty_OpenMP(*N, *num_threads);
+    if (F2C_KINSOL_vec == NULL) *ier = -1;
+    break;
+  case FCMIX_ARKODE:
+    F2C_ARKODE_vec = NULL;
+    F2C_ARKODE_vec = N_VNewEmpty_OpenMP(*N, *num_threads);
+    if (F2C_ARKODE_vec == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITOMP_Q(int *code, long int *Nq, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecQ = NULL;
+    F2C_CVODE_vecQ = N_VNewEmpty_OpenMP(*Nq, *num_threads);
+    if (F2C_CVODE_vecQ == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecQ = NULL;
+    F2C_IDA_vecQ = N_VNewEmpty_OpenMP(*Nq, *num_threads);
+    if (F2C_IDA_vecQ == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITOMP_B(int *code, long int *NB, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecB = NULL;
+    F2C_CVODE_vecB = N_VNewEmpty_OpenMP(*NB, *num_threads);
+    if (F2C_CVODE_vecB == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecB = NULL;
+    F2C_IDA_vecB = N_VNewEmpty_OpenMP(*NB, *num_threads);
+    if (F2C_IDA_vecB == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITOMP_QB(int *code, long int *NqB, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecQB = NULL;
+    F2C_CVODE_vecQB = N_VNewEmpty_OpenMP(*NqB, *num_threads);
+    if (F2C_CVODE_vecQB == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecQB = NULL;
+    F2C_IDA_vecQB = N_VNewEmpty_OpenMP(*NqB, *num_threads);
+    if (F2C_IDA_vecQB == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITOMP_S(int *code, int *Ns, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecS = NULL;
+    F2C_CVODE_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_OpenMP(*Ns, F2C_CVODE_vec);
+    if (F2C_CVODE_vecS == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecS = NULL;
+    F2C_IDA_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_OpenMP(*Ns, F2C_IDA_vec);
+    if (F2C_IDA_vecS == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+
diff --git a/src/nvec_openmp/fnvector_openmp.h b/src/nvec_openmp/fnvector_openmp.h
new file mode 100644
index 0000000..4451b4b
--- /dev/null
+++ b/src/nvec_openmp/fnvector_openmp.h
@@ -0,0 +1,95 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4388 $
+ * $Date: 2015-02-25 15:50:00 -0800 (Wed, 25 Feb 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Steven Smith @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This file (companion of nvector_openmp.h) contains the
+ * definitions needed for the initialization of openmp
+ * vector operations in Fortran.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _FNVECTOR_OPENMP_H
+#define _FNVECTOR_OPENMP_H
+
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_fnvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+#if defined(SUNDIALS_F77_FUNC)
+#define FNV_INITOMP    SUNDIALS_F77_FUNC(fnvinitomp, FNVINITOMP)
+#else
+#define FNV_INITOMP    fnvinitomp_
+#endif
+
+#if defined(SUNDIALS_F77_FUNC_)
+
+#define FNV_INITOMP_Q  SUNDIALS_F77_FUNC_(fnvinitomp_q, FNVINITOMP_Q)
+#define FNV_INITOMP_S  SUNDIALS_F77_FUNC_(fnvinitomp_s, FNVINITOMP_S)
+#define FNV_INITOMP_B  SUNDIALS_F77_FUNC_(fnvinitomp_b, FNVINITOMP_B)
+#define FNV_INITOMP_QB SUNDIALS_F77_FUNC_(fnvinitomp_qb, FNVINITOMP_QB)
+
+#else
+
+#define FNV_INITOMP_Q  fnvinitomp_q_
+#define FNV_INITOMP_S  fnvinitomp_s_
+#define FNV_INITOMP_B  fnvinitomp_b_
+#define FNV_INITOMP_QB fnvinitomp_qb_
+
+#endif
+
+/* Declarations of global variables */
+
+extern N_Vector F2C_CVODE_vec;
+extern N_Vector F2C_CVODE_vecQ;
+extern N_Vector *F2C_CVODE_vecS;
+extern N_Vector F2C_CVODE_vecB;
+extern N_Vector F2C_CVODE_vecQB;
+
+extern N_Vector F2C_IDA_vec;
+extern N_Vector F2C_IDA_vecQ;
+extern N_Vector *F2C_IDA_vecS;
+extern N_Vector F2C_IDA_vecB;
+extern N_Vector F2C_IDA_vecQB;
+
+extern N_Vector F2C_KINSOL_vec;
+
+extern N_Vector F2C_ARKODE_vec;
+
+/* 
+ * Prototypes of exported functions 
+ *
+ * FNV_INITOMP    - initializes openmp vector operations for main problem
+ * FNV_INITOMP_Q  - initializes openmp vector operations for quadratures
+ * FNV_INITOMP_S  - initializes openmp vector operations for sensitivities
+ * FNV_INITOMP_B  - initializes openmp vector operations for adjoint problem
+ * FNV_INITOMP_QB - initializes openmp vector operations for adjoint quadratures
+ *
+ */
+
+void FNV_INITOMP(int *code, long int *neq, int *num_threads, int *ier);
+void FNV_INITOMP_Q(int *code, long int *Nq, int *num_threads, int *ier);
+void FNV_INITOMP_S(int *code, int *Ns, int *ier);
+void FNV_INITOMP_B(int *code, long int *NB, int *num_threads, int *ier);
+void FNV_INITOMP_QB(int *code, long int *NqB, int *num_threads, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/nvec_openmp/nvector_openmp.c b/src/nvec_openmp/nvector_openmp.c
new file mode 100644
index 0000000..aa23004
--- /dev/null
+++ b/src/nvec_openmp/nvector_openmp.c
@@ -0,0 +1,1332 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4869 $
+ * $Date: 2016-08-19 10:34:20 -0700 (Fri, 19 Aug 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner and Carol S. Woodward @ LLNL
+ * -----------------------------------------------------------------
+ * Acknowledgements: This NVECTOR module is based on the NVECTOR 
+ *                   Serial module by Scott D. Cohen, Alan C. 
+ *                   Hindmarsh, Radu Serban, and Aaron Collier 
+ *                   @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for an OpenMP implementation
+ * of the NVECTOR module.
+ * -----------------------------------------------------------------
+ */
+
+#include <omp.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <nvector/nvector_openmp.h>
+#include <sundials/sundials_math.h>
+
+#define ZERO   RCONST(0.0)
+#define HALF   RCONST(0.5)
+#define ONE    RCONST(1.0)
+#define ONEPT5 RCONST(1.5)
+
+/* Private function prototypes */
+/* z=x */
+static void VCopy_OpenMP(N_Vector x, N_Vector z);
+/* z=x+y */
+static void VSum_OpenMP(N_Vector x, N_Vector y, N_Vector z);
+/* z=x-y */
+static void VDiff_OpenMP(N_Vector x, N_Vector y, N_Vector z);
+/* z=-x */
+static void VNeg_OpenMP(N_Vector x, N_Vector z);
+/* z=c(x+y) */
+static void VScaleSum_OpenMP(realtype c, N_Vector x, N_Vector y, N_Vector z);
+/* z=c(x-y) */
+static void VScaleDiff_OpenMP(realtype c, N_Vector x, N_Vector y, N_Vector z); 
+/* z=ax+y */
+static void VLin1_OpenMP(realtype a, N_Vector x, N_Vector y, N_Vector z);
+/* z=ax-y */
+static void VLin2_OpenMP(realtype a, N_Vector x, N_Vector y, N_Vector z);
+/* y <- ax+y */
+static void Vaxpy_OpenMP(realtype a, N_Vector x, N_Vector y);
+/* x <- ax */
+static void VScaleBy_OpenMP(realtype a, N_Vector x);
+
+/*
+ * -----------------------------------------------------------------
+ * exported functions
+ * -----------------------------------------------------------------
+ */
+
+/* ----------------------------------------------------------------
+ * Returns vector type ID. Used to identify vector implementation 
+ * from abstract N_Vector interface.
+ */
+N_Vector_ID N_VGetVectorID_OpenMP(N_Vector v)
+{
+  return SUNDIALS_NVEC_OPENMP;
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create a new empty vector 
+ */
+
+N_Vector N_VNewEmpty_OpenMP(long int length, int num_threads)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_OpenMP content;
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+  
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { free(v); return(NULL); }
+
+  ops->nvgetvectorid     = N_VGetVectorID_OpenMP;
+  ops->nvclone           = N_VClone_OpenMP;
+  ops->nvcloneempty      = N_VCloneEmpty_OpenMP;
+  ops->nvdestroy         = N_VDestroy_OpenMP;
+  ops->nvspace           = N_VSpace_OpenMP;
+  ops->nvgetarraypointer = N_VGetArrayPointer_OpenMP;
+  ops->nvsetarraypointer = N_VSetArrayPointer_OpenMP;
+  ops->nvlinearsum       = N_VLinearSum_OpenMP;
+  ops->nvconst           = N_VConst_OpenMP;
+  ops->nvprod            = N_VProd_OpenMP;
+  ops->nvdiv             = N_VDiv_OpenMP;
+  ops->nvscale           = N_VScale_OpenMP;
+  ops->nvabs             = N_VAbs_OpenMP;
+  ops->nvinv             = N_VInv_OpenMP;
+  ops->nvaddconst        = N_VAddConst_OpenMP;
+  ops->nvdotprod         = N_VDotProd_OpenMP;
+  ops->nvmaxnorm         = N_VMaxNorm_OpenMP;
+  ops->nvwrmsnormmask    = N_VWrmsNormMask_OpenMP;
+  ops->nvwrmsnorm        = N_VWrmsNorm_OpenMP;
+  ops->nvmin             = N_VMin_OpenMP;
+  ops->nvwl2norm         = N_VWL2Norm_OpenMP;
+  ops->nvl1norm          = N_VL1Norm_OpenMP;
+  ops->nvcompare         = N_VCompare_OpenMP;
+  ops->nvinvtest         = N_VInvTest_OpenMP;
+  ops->nvconstrmask      = N_VConstrMask_OpenMP;
+  ops->nvminquotient     = N_VMinQuotient_OpenMP;
+
+  /* Create content */
+  content = NULL;
+  content = (N_VectorContent_OpenMP) malloc(sizeof(struct _N_VectorContent_OpenMP));
+  if (content == NULL) { free(ops); free(v); return(NULL); }
+
+  content->length   = length;
+  content->num_threads = num_threads;
+  content->own_data = FALSE;
+  content->data     = NULL;
+
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create a new vector 
+ */
+
+N_Vector N_VNew_OpenMP(long int length, int num_threads)
+{
+  N_Vector v;
+  realtype *data;
+
+  v = NULL;
+  v = N_VNewEmpty_OpenMP(length, num_threads);
+  if (v == NULL) return(NULL);
+
+  /* Create data */
+  if (length > 0) {
+
+    /* Allocate memory */
+    data = NULL;
+    data = (realtype *) malloc(length * sizeof(realtype));
+    if(data == NULL) { N_VDestroy_OpenMP(v); return(NULL); }
+
+    /* Attach data */
+    NV_OWN_DATA_OMP(v) = TRUE;
+    NV_DATA_OMP(v)     = data;
+
+  }
+
+  return(v);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create a vector with user data component 
+ */
+
+N_Vector N_VMake_OpenMP(long int length, realtype *v_data, int num_threads)
+{
+  N_Vector v;
+
+  v = NULL;
+  v = N_VNewEmpty_OpenMP(length, num_threads);
+  if (v == NULL) return(NULL);
+
+  if (length > 0) {
+    /* Attach data */
+    NV_OWN_DATA_OMP(v) = FALSE;
+    NV_DATA_OMP(v)     = v_data;
+  }
+
+  return(v);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create an array of new vectors. 
+ */
+
+N_Vector *N_VCloneVectorArray_OpenMP(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VClone_OpenMP(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_OpenMP(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create an array of new vectors with NULL data array. 
+ */
+
+N_Vector *N_VCloneVectorArrayEmpty_OpenMP(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VCloneEmpty_OpenMP(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_OpenMP(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to free an array created with N_VCloneVectorArray_OpenMP
+ */
+
+void N_VDestroyVectorArray_OpenMP(N_Vector *vs, int count)
+{
+  int j;
+
+  for (j = 0; j < count; j++) N_VDestroy_OpenMP(vs[j]);
+
+  free(vs); vs = NULL;
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to return number of vector elements
+ */
+long int N_VGetLength_OpenMP(N_Vector v)
+{
+  return NV_LENGTH_OMP(v);
+}
+
+ 
+/* ----------------------------------------------------------------------------
+ * Function to print a vector 
+ */
+ 
+void N_VPrint_OpenMP(N_Vector x)
+{
+  long int i, N;
+  realtype *xd;
+
+  xd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+
+  for (i = 0; i < N; i++) {
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf("%11.8Lg\n", xd[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf("%11.8g\n", xd[i]);
+#else
+    printf("%11.8g\n", xd[i]);
+#endif
+  }
+  printf("\n");
+
+  return;
+}
+
+/*
+ * -----------------------------------------------------------------
+ * implementation of vector operations
+ * -----------------------------------------------------------------
+ */
+
+/* ----------------------------------------------------------------------------
+ * Create new vector from existing vector without attaching data
+ */
+
+N_Vector N_VCloneEmpty_OpenMP(N_Vector w)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_OpenMP content;
+
+  if (w == NULL) return(NULL);
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { free(v); return(NULL); }
+  
+  ops->nvgetvectorid     = w->ops->nvgetvectorid;
+  ops->nvclone           = w->ops->nvclone;
+  ops->nvcloneempty      = w->ops->nvcloneempty;
+  ops->nvdestroy         = w->ops->nvdestroy;
+  ops->nvspace           = w->ops->nvspace;
+  ops->nvgetarraypointer = w->ops->nvgetarraypointer;
+  ops->nvsetarraypointer = w->ops->nvsetarraypointer;
+  ops->nvlinearsum       = w->ops->nvlinearsum;
+  ops->nvconst           = w->ops->nvconst;  
+  ops->nvprod            = w->ops->nvprod;   
+  ops->nvdiv             = w->ops->nvdiv;
+  ops->nvscale           = w->ops->nvscale; 
+  ops->nvabs             = w->ops->nvabs;
+  ops->nvinv             = w->ops->nvinv;
+  ops->nvaddconst        = w->ops->nvaddconst;
+  ops->nvdotprod         = w->ops->nvdotprod;
+  ops->nvmaxnorm         = w->ops->nvmaxnorm;
+  ops->nvwrmsnormmask    = w->ops->nvwrmsnormmask;
+  ops->nvwrmsnorm        = w->ops->nvwrmsnorm;
+  ops->nvmin             = w->ops->nvmin;
+  ops->nvwl2norm         = w->ops->nvwl2norm;
+  ops->nvl1norm          = w->ops->nvl1norm;
+  ops->nvcompare         = w->ops->nvcompare;    
+  ops->nvinvtest         = w->ops->nvinvtest;
+  ops->nvconstrmask      = w->ops->nvconstrmask;
+  ops->nvminquotient     = w->ops->nvminquotient;
+
+  /* Create content */
+  content = NULL;
+  content = (N_VectorContent_OpenMP) malloc(sizeof(struct _N_VectorContent_OpenMP));
+  if (content == NULL) { free(ops); free(v); return(NULL); }
+
+  content->length   = NV_LENGTH_OMP(w);
+  content->num_threads   = NV_NUM_THREADS_OMP(w);
+  content->own_data = FALSE;
+  content->data     = NULL;
+
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Create new vector from existing vector and attach data
+ */
+
+N_Vector N_VClone_OpenMP(N_Vector w)
+{
+  N_Vector v;
+  realtype *data;
+  long int length;
+
+  v = NULL;
+  v = N_VCloneEmpty_OpenMP(w);
+  if (v == NULL) return(NULL);
+
+  length = NV_LENGTH_OMP(w);
+
+  /* Create data */
+  if (length > 0) {
+
+    /* Allocate memory */
+    data = NULL;
+    data = (realtype *) malloc(length * sizeof(realtype));
+    if(data == NULL) { N_VDestroy_OpenMP(v); return(NULL); }
+
+    /* Attach data */
+    NV_OWN_DATA_OMP(v) = TRUE;
+    NV_DATA_OMP(v)     = data;
+
+  }
+
+  return(v);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Destroy vector and free vector memory
+ */
+
+void N_VDestroy_OpenMP(N_Vector v)
+{
+  if (NV_OWN_DATA_OMP(v) == TRUE) {
+    free(NV_DATA_OMP(v));
+    NV_DATA_OMP(v) = NULL;
+  }
+  free(v->content); v->content = NULL;
+  free(v->ops); v->ops = NULL;
+  free(v); v = NULL;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Get storage requirement for N_Vector
+ */
+
+void N_VSpace_OpenMP(N_Vector v, long int *lrw, long int *liw)
+{
+  *lrw = NV_LENGTH_OMP(v);
+  *liw = 1;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Get vector data pointer
+ */
+
+realtype *N_VGetArrayPointer_OpenMP(N_Vector v)
+{
+  return((realtype *) NV_DATA_OMP(v));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Set vector data pointer
+ */
+
+void N_VSetArrayPointer_OpenMP(realtype *v_data, N_Vector v)
+{
+  if (NV_LENGTH_OMP(v) > 0) NV_DATA_OMP(v) = v_data;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute linear combination z[i] = a*x[i]+b*y[i]
+ */
+
+void N_VLinearSum_OpenMP(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype c, *xd, *yd, *zd;
+  N_Vector v1, v2;
+  booleantype test;
+
+  xd = yd = zd = NULL;
+
+  if ((b == ONE) && (z == y)) {    /* BLAS usage: axpy y <- ax+y */
+    Vaxpy_OpenMP(a,x,y);
+    return;
+  }
+
+  if ((a == ONE) && (z == x)) {    /* BLAS usage: axpy x <- by+x */
+    Vaxpy_OpenMP(b,y,x);
+    return;
+  }
+
+  /* Case: a == b == 1.0 */
+
+  if ((a == ONE) && (b == ONE)) {
+    VSum_OpenMP(x, y, z);
+    return;
+  }
+
+  /* Cases: (1) a == 1.0, b = -1.0, (2) a == -1.0, b == 1.0 */
+
+  if ((test = ((a == ONE) && (b == -ONE))) || ((a == -ONE) && (b == ONE))) {
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VDiff_OpenMP(v2, v1, z);
+    return;
+  }
+
+  /* Cases: (1) a == 1.0, b == other or 0.0, (2) a == other or 0.0, b == 1.0 */
+  /* if a or b is 0.0, then user should have called N_VScale */
+
+  if ((test = (a == ONE)) || (b == ONE)) {
+    c  = test ? b : a;
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VLin1_OpenMP(c, v1, v2, z);
+    return;
+  }
+
+  /* Cases: (1) a == -1.0, b != 1.0, (2) a != 1.0, b == -1.0 */
+
+  if ((test = (a == -ONE)) || (b == -ONE)) {
+    c = test ? b : a;
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VLin2_OpenMP(c, v1, v2, z);
+    return;
+  }
+
+  /* Case: a == b */
+  /* catches case both a and b are 0.0 - user should have called N_VConst */
+
+  if (a == b) {
+    VScaleSum_OpenMP(a, x, y, z);
+    return;
+  }
+
+  /* Case: a == -b */
+
+  if (a == -b) {
+    VScaleDiff_OpenMP(a, x, y, z);
+    return;
+  }
+
+  /* Do all cases not handled above:
+     (1) a == other, b == 0.0 - user should have called N_VScale
+     (2) a == 0.0, b == other - user should have called N_VScale
+     (3) a,b == other, a !=b, a != -b */
+  
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,a,b,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = (a*xd[i])+(b*yd[i]);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Assigns constant value to all vector elements, z[i] = c
+ */
+
+void N_VConst_OpenMP(realtype c, N_Vector z)
+{
+  long int i, N;
+  realtype *zd;
+
+  zd = NULL;
+
+  N  = NV_LENGTH_OMP(z);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,c,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(z))
+  for (i = 0; i < N; i++) zd[i] = c;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise product z[i] = x[i]*y[i]
+ */
+
+void N_VProd_OpenMP(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]*yd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise division z[i] = x[i]/y[i]
+ */
+
+void N_VDiv_OpenMP(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]/yd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaler multiplication z[i] = c*x[i]
+ */
+
+void N_VScale_OpenMP(realtype c, N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  if (z == x) {  /* BLAS usage: scale x <- cx */
+    VScaleBy_OpenMP(c, x);
+    return;
+  }
+
+  if (c == ONE) {
+    VCopy_OpenMP(x, z);
+  } else if (c == -ONE) {
+    VNeg_OpenMP(x, z);
+  } else {
+    N  = NV_LENGTH_OMP(x);
+    xd = NV_DATA_OMP(x);
+    zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,c,xd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+    for (i = 0; i < N; i++) 
+      zd[i] = c*xd[i];
+  }
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute absolute value of vector components z[i] = SUNRabs(x[i])
+ */
+
+void N_VAbs_OpenMP(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for schedule(static) num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = SUNRabs(xd[i]);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise inverse z[i] = 1 / x[i]
+ */
+
+void N_VInv_OpenMP(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = ONE/xd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise addition of a scaler to a vector z[i] = x[i] + b
+ */
+
+void N_VAddConst_OpenMP(N_Vector x, realtype b, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,b,xd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) 
+    zd[i] = xd[i]+b;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes the dot product of two vectors, a = sum(x[i]*y[i])
+ */
+
+realtype N_VDotProd_OpenMP(N_Vector x, N_Vector y)
+{
+  long int i, N;
+  realtype sum, *xd, *yd;
+
+  sum = ZERO;
+  xd = yd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,yd) \
+  reduction(+:sum) schedule(static) num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) {
+    sum += xd[i]*yd[i];
+  }
+  
+  return(sum);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes max norm of a vector 
+ */
+
+realtype N_VMaxNorm_OpenMP(N_Vector x)
+{
+  long int i, N;
+  realtype tmax, max, *xd;
+
+  max = ZERO;
+  xd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+
+#pragma omp parallel default(none) private(i,tmax) shared(N,max,xd) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  {
+    tmax = ZERO;
+#pragma omp for schedule(static)
+    for (i = 0; i < N; i++) {
+      if (SUNRabs(xd[i]) > tmax) tmax = SUNRabs(xd[i]);
+    }
+#pragma omp critical 
+    {
+      if (tmax > max)
+	max = tmax;
+    }
+  }
+  return(max);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes weighted root mean square norm of a vector 
+ */
+
+realtype N_VWrmsNorm_OpenMP(N_Vector x, N_Vector w)
+{
+  long int i, N;
+  realtype sum, *xd, *wd;
+
+  sum = ZERO;
+  xd = wd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  wd = NV_DATA_OMP(w);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,wd) \
+  reduction(+:sum) schedule(static) num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) {
+    sum += SUNSQR(xd[i]*wd[i]);
+  }
+
+  return(SUNRsqrt(sum/N));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes weighted root mean square norm of a masked vector 
+ */
+
+realtype N_VWrmsNormMask_OpenMP(N_Vector x, N_Vector w, N_Vector id)
+{
+  long int i, N;
+  realtype sum, *xd, *wd, *idd;
+
+  sum = ZERO;
+  xd = wd = idd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd  = NV_DATA_OMP(x);
+  wd  = NV_DATA_OMP(w);
+  idd = NV_DATA_OMP(id);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,wd,idd) \
+  reduction(+:sum) schedule(static) num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) {
+    if (idd[i] > ZERO) {
+      sum += SUNSQR(xd[i]*wd[i]);
+    }
+  }
+
+  return(SUNRsqrt(sum / N));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Finds the minimun component of a vector 
+ */
+
+realtype N_VMin_OpenMP(N_Vector x)
+{
+  long int i, N;
+  realtype min, *xd;
+  realtype tmin;
+
+  xd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+
+  min = xd[0];
+
+#pragma omp parallel default(none) private(i,tmin) shared(N,min,xd) \
+            num_threads(NV_NUM_THREADS_OMP(x))
+  {
+    tmin = xd[0];
+#pragma omp for schedule(static)
+    for (i = 1; i < N; i++) {
+      if (xd[i] < tmin) tmin = xd[i];
+    }
+    if (tmin < min) {
+#pragma omp critical
+      {
+	if (tmin < min) min = tmin;
+      }
+    }
+  }
+
+  return(min);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes weighted L2 norm of a vector
+ */
+
+realtype N_VWL2Norm_OpenMP(N_Vector x, N_Vector w)
+{
+  long int i, N;
+  realtype sum, *xd, *wd;
+
+  sum = ZERO;
+  xd = wd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  wd = NV_DATA_OMP(w);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,wd) \
+  reduction(+:sum) schedule(static) num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) {
+    sum += SUNSQR(xd[i]*wd[i]);
+  }
+
+  return(SUNRsqrt(sum));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes L1 norm of a vector
+ */
+
+realtype N_VL1Norm_OpenMP(N_Vector x)
+{
+  long int i, N;
+  realtype sum, *xd;
+
+  sum = ZERO;
+  xd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd) \
+  reduction(+:sum) schedule(static) num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i<N; i++)  
+    sum += SUNRabs(xd[i]);
+
+  return(sum);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compare vector component values to a scaler   
+ */
+
+void N_VCompare_OpenMP(realtype c, N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,c,xd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) {
+    zd[i] = (SUNRabs(xd[i]) >= c) ? ONE : ZERO;
+  }
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise inverse z[i] = ONE/x[i] and checks if x[i] == ZERO
+ */
+
+booleantype N_VInvTest_OpenMP(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd, val;
+
+  xd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  zd = NV_DATA_OMP(z);
+
+  val = ZERO;
+
+#pragma omp parallel for default(none) private(i) shared(N,val,xd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) {
+    if (xd[i] == ZERO) 
+      val = ONE;
+    else
+      zd[i] = ONE/xd[i];
+  }
+
+  if (val > ZERO)
+    return (FALSE);
+  else
+    return (TRUE);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute constraint mask of a vector 
+ */
+
+booleantype N_VConstrMask_OpenMP(N_Vector c, N_Vector x, N_Vector m)
+{
+  long int i, N;
+  realtype temp;
+  realtype *cd, *xd, *md;
+
+  cd = xd = md = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  cd = NV_DATA_OMP(c);
+  md = NV_DATA_OMP(m);
+
+  temp = ONE;
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,cd,md,temp) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++) {
+    md[i] = ZERO;
+    if (cd[i] == ZERO) continue;
+    if (cd[i] > ONEPT5 || cd[i] < -ONEPT5) {
+      if ( xd[i]*cd[i] <= ZERO) { temp = ZERO; md[i] = ONE; }
+      continue;
+    }
+    if ( cd[i] > HALF || cd[i] < -HALF) {
+      if (xd[i]*cd[i] < ZERO ) { temp = ZERO; md[i] = ONE; }
+    }
+  }
+
+  if (temp == ONE) return (TRUE);
+  else return(FALSE);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute minimum componentwise quotient 
+ */
+
+realtype N_VMinQuotient_OpenMP(N_Vector num, N_Vector denom)
+{
+  long int i, N;
+  realtype *nd, *dd, min, tmin, val;
+
+  nd = dd = NULL;
+
+  N  = NV_LENGTH_OMP(num);
+  nd = NV_DATA_OMP(num);
+  dd = NV_DATA_OMP(denom);
+
+  min = BIG_REAL;
+
+#pragma omp parallel default(none) private(i,tmin,val) shared(N,min,nd,dd) \
+   num_threads(NV_NUM_THREADS_OMP(num))
+  {
+    tmin = BIG_REAL;
+#pragma omp for schedule(static)
+    for (i = 0; i < N; i++) {
+      if (dd[i] != ZERO) {
+	val = nd[i]/dd[i];
+	if (val < tmin) tmin = val;
+      }
+    }
+    if (tmin < min) {
+#pragma omp critical
+      {
+	if (tmin < min) min = tmin;
+      }
+    }
+  }
+
+  return(min);
+}
+
+/*
+ * -----------------------------------------------------------------
+ * private functions
+ * -----------------------------------------------------------------
+ */
+
+
+/* ----------------------------------------------------------------------------
+ * Copy vector components into a second vector   
+ */
+
+static void VCopy_OpenMP(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]; 
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector sum    
+ */
+
+static void VSum_OpenMP(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,yd,zd) schedule(static) \
+ num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]+yd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector difference   
+ */
+
+static void VDiff_OpenMP(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]-yd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute the negative of a vector   
+ */
+
+static void VNeg_OpenMP(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  zd = NV_DATA_OMP(z);
+  
+#pragma omp parallel for default(none) private(i) shared(N,xd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = -xd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaled vector sum    
+ */
+
+static void VScaleSum_OpenMP(realtype c, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,c,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = c*(xd[i]+yd[i]);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaled vector difference
+ */
+
+static void VScaleDiff_OpenMP(realtype c, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,c,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = c*(xd[i]-yd[i]);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector sum z[i] = a*x[i]+y[i]    
+ */
+
+static void VLin1_OpenMP(realtype a, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,a,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = (a*xd[i])+yd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector difference z[i] = a*x[i]-y[i]    
+ */
+
+static void VLin2_OpenMP(realtype a, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+  zd = NV_DATA_OMP(z);
+
+#pragma omp parallel for default(none) private(i) shared(N,a,xd,yd,zd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    zd[i] = (a*xd[i])-yd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute special cases of linear sum
+ */
+
+static void Vaxpy_OpenMP(realtype a, N_Vector x, N_Vector y)
+{
+  long int i, N;
+  realtype *xd, *yd;
+
+  xd = yd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+  yd = NV_DATA_OMP(y);
+
+  if (a == ONE) {
+#pragma omp parallel for default(none) private(i) shared(N,xd,yd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+    for (i = 0; i < N; i++)
+      yd[i] += xd[i];
+    return;
+  }
+
+  if (a == -ONE) {
+#pragma omp parallel for default(none) private(i) shared(N,xd,yd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+    for (i = 0; i < N; i++)
+      yd[i] -= xd[i];
+    return;
+  }    
+
+#pragma omp parallel for default(none) private(i) shared(N,a,xd,yd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    yd[i] += a*xd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaled vector x[i] = a*x[i]    
+ */
+
+static void VScaleBy_OpenMP(realtype a, N_Vector x)
+{
+  long int i, N;
+  realtype *xd;
+
+  xd = NULL;
+
+  N  = NV_LENGTH_OMP(x);
+  xd = NV_DATA_OMP(x);
+
+#pragma omp parallel for default(none) private(i) shared(N,a,xd) schedule(static) \
+   num_threads(NV_NUM_THREADS_OMP(x))
+  for (i = 0; i < N; i++)
+    xd[i] *= a;
+
+  return;
+}
diff --git a/src/nvec_par/CMakeLists.txt b/src/nvec_par/CMakeLists.txt
index f5e359f..8477fb4 100644
--- a/src/nvec_par/CMakeLists.txt
+++ b/src/nvec_par/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.3 $
-# $Date: 2009/02/17 02:58:48 $
+# $Revision: 4625 $
+# $Date: 2016-01-13 16:05:42 -0800 (Wed, 13 Jan 2016) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the parallel NVECTOR library
 
@@ -42,7 +47,7 @@ ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
 # Rules for building and installing the static library:
 #  - Add the build target for the NVECPARALLEL library
 #  - Set the library name and make sure it is not deleted
-#  - Install the NVECSERIAL library
+#  - Install the NVECPARALLEL library
 IF(BUILD_STATIC_LIBS)
   ADD_LIBRARY(sundials_nvecparallel_static STATIC ${nvecparallel_SOURCES} ${shared_SOURCES})
   SET_TARGET_PROPERTIES(sundials_nvecparallel_static
@@ -54,7 +59,7 @@ ENDIF(BUILD_STATIC_LIBS)
 #  - Add the build target for the NVECPARALLEL library
 #  - Set the library name and make sure it is not deleted
 #  - Set VERSION and SOVERSION for shared libraries
-#  - Install the NVECSERIAL library
+#  - Install the NVECPARALLEL library
 IF(BUILD_SHARED_LIBS)
   ADD_LIBRARY(sundials_nvecparallel_shared SHARED ${nvecparallel_SOURCES} ${shared_SOURCES})
   SET_TARGET_PROPERTIES(sundials_nvecparallel_shared
diff --git a/src/nvec_par/Makefile.in b/src/nvec_par/Makefile.in
deleted file mode 100644
index bd7ea4f..0000000
--- a/src/nvec_par/Makefile.in
+++ /dev/null
@@ -1,128 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.8 $
-# $Date: 2007/01/29 17:36:28 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for parallel NVECTOR module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-MPICC       = @MPICC@
-MPI_INC_DIR = @MPI_INC_DIR@
-MPI_LIB_DIR = @MPI_LIB_DIR@
-MPI_LIBS    = @MPI_LIBS@
-MPI_FLAGS   = @MPI_FLAGS@
-CPPFLAGS    = @CPPFLAGS@
-CFLAGS      = @CFLAGS@
-LDFLAGS     = @LDFLAGS@
-LIBS        = @LIBS@
-
-FCMIX_ENABLED = @FCMIX_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(MPI_INC_DIR)
-
-LIB_REVISION = 0:2:0
-
-NVECPAR_LIB       = libsundials_nvecparallel.la
-NVECPAR_LIB_FILES = nvector_parallel.lo
-
-FNVECPAR_LIB       = libsundials_fnvecparallel.la
-FNVECPAR_LIB_FILES = fnvector_parallel.lo
-
-SHARED_LIB_FILES = $(top_builddir)/src/sundials/sundials_math.lo
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-all: $(NVECPAR_LIB) $(FNVECPAR_LIB)
-
-$(NVECPAR_LIB): shared $(NVECPAR_LIB_FILES)
-	$(LIBTOOL) --mode=link $(MPICC) $(CFLAGS) $(MPI_FLAGS) -o $(NVECPAR_LIB) $(NVECPAR_LIB_FILES) $(SHARED_LIB_FILES) $(LDFLAGS) -L$(MPI_LIB_DIR) $(MPI_LIBS) $(LIBS) -rpath $(libdir) -version-info $(LIB_REVISION)
-
-$(FNVECPAR_LIB): $(FNVECPAR_LIB_FILES)
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                                                                                                                                                                                    \
-	   echo "${LIBTOOL} --mode=link ${MPICC} ${CFLAGS} ${MPI_FLAGS} -o ${FNVECPAR_LIB} ${FNVECPAR_LIB_FILES} ${SHARED_LIB_FILES} ${LDFLAGS} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBS} -rpath ${libdir} -version-info ${LIB_REVISION}" ; \
-	   ${LIBTOOL} --mode=link ${MPICC} ${CFLAGS} ${MPI_FLAGS} -o ${FNVECPAR_LIB} ${FNVECPAR_LIB_FILES} ${SHARED_LIB_FILES} ${LDFLAGS} -L${MPI_LIB_DIR} ${MPI_LIBS} ${LIBS} -rpath ${libdir} -version-info ${LIB_REVISION} ;        \
-	 fi
-
-install: $(NVECPAR_LIB) $(FNVECPAR_LIB)
-	$(mkinstalldirs) $(includedir)/nvector
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(NVECPAR_LIB) $(libdir)
-	$(INSTALL_HEADER) $(top_srcdir)/include/nvector/nvector_parallel.h $(includedir)/nvector/
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                                    \
-	   echo "${LIBTOOL} --mode=install ${INSTALL_LIB} ${FNVECPAR_LIB} ${libdir}" ; \
-	   ${LIBTOOL} --mode=install ${INSTALL_LIB} ${FNVECPAR_LIB} ${libdir} ;        \
-	 fi
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(NVECPAR_LIB)
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                             \
-	   echo "${LIBTOOL} --mode=uninstall rm -f ${libdir}/${FNVECPAR_LIB}" ; \
-	   ${LIBTOOL} --mode=uninstall rm -f ${libdir}/${FNVECPAR_LIB} ;        \
-	 fi
-	rm -f $(includedir)/nvector/nvector_parallel.h
-	$(rminstalldirs) ${includedir}/nvector
-
-shared:
-	@cd ${top_builddir}/src/sundials ; \
-	 ${MAKE} ;                         \
-	 cd ${abs_builddir}
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(NVECPAR_LIB)
-	rm -f $(NVECPAR_LIB_FILES)
-	rm -f nvector_parallel.o
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then               \
-	   echo "${LIBTOOL} --mode=clean rm -f ${FNVECPAR_LIB}" ; \
-	   ${LIBTOOL} --mode=clean rm -f ${FNVECPAR_LIB} ;        \
-	   echo "rm -f ${FNVECPAR_LIB_FILES}" ;                   \
-	   rm -f ${FNVECPAR_LIB_FILES} ;                          \
-	   echo "rm -f fnvector_parallel.o" ;                     \
-	   rm -f fnvector_parallel.o ;                            \
-	 fi
-
-distclean: clean
-	rm -f Makefile
-
-nvector_parallel.lo: $(srcdir)/nvector_parallel.c
-	$(LIBTOOL) --mode=compile $(MPICC) $(CPPFLAGS) $(MPI_FLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/nvector_parallel.c
-fnvector_parallel.lo: $(srcdir)/fnvector_parallel.c
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                                                                                    \
-	   echo "${LIBTOOL} --mode=compile ${MPICC} ${CPPFLAGS} ${MPI_FLAGS} $(INCLUDES) ${CFLAGS} -c ${srcdir}/fnvector_parallel.c" ; \
-	   ${LIBTOOL} --mode=compile ${MPICC} ${CPPFLAGS} ${MPI_FLAGS} $(INCLUDES) ${CFLAGS} -c ${srcdir}/fnvector_parallel.c ;        \
-	 fi
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/nvec_par/README b/src/nvec_par/README
index b9bb47e..246c346 100644
--- a/src/nvec_par/README
+++ b/src/nvec_par/README
@@ -1,5 +1,7 @@
                      NVECTOR_PARALLEL
-                Release 2.5.0, March 2012
+                 released as part of SUNDIALS
+    SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
+                   Release 2.7.0, September 2016
 
 
 MPI parallel implementation of the NVECTOR module for SUNDIALS. 
@@ -22,40 +24,25 @@ A. Documentation
 ----------------
 
 The MPI parallel NVECTOR implementation is fully described in the user documentation
-for any of the SUNDIALS solvers [1-5]. A PDF file for the user guide for a particular
+for any of the SUNDIALS solvers. A PDF file for the user guide for a particular
 solver is available in the solver's subdirectory under doc/.
 
 
 B. Installation
 ---------------
 
-For basic installation instructions see /sundials/INSTALL_NOTES. 
+For basic installation instructions see /sundials/INSTALL_GUIDE.pdf. 
 For complete installation instructions see any of the user guides.
 
 
-C. References
--------------
 
-[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODE v2.7.0," 
-    LLNL technical report UCRL-MA-208108, December 2011.
-
-[2] A. C. Hindmarsh and R. Serban, "User Documentation for CVODES v2.7.0," 
-    LLNL technical report UCRL-MA-208111, December 2011.
-
-[3] A. C. Hindmarsh and R. Serban, "User Documentation for IDA v2.7.0," 
-    LLNL technical report UCRL-MA-208112, December 2011.
-
-[4] R. Serban and C. Petra,  "User Documentation for IDAS v1.1.0," 
-    LLNL technical report UCRL-SM-234051, December 2011.
-
-[5] A. M. Collier, A. C. Hindmarsh, R. Serban,and C. S. Woodward, "User 
-    Documentation for KINSOL v2.7.0," LLNL technical report UCRL-MA-208116, 
-    December 2011.
-
-
-D. Releases
+C. Releases
 -----------
 
+v. 2.7.0 - Sep. 2016
+v. 2.6.2 - Aug. 2015
+v. 2.6.1 - Mar. 2015
+v. 2.6.0 - Mar. 2015
 v. 2.5.0 - Mar. 2012
 v. 2.4.0 - May  2009
 v. 2.3.0 - Nov. 2006
@@ -68,76 +55,3 @@ v. 2.0   - Dec. 2004
 v. 1.0   - Jul. 2002 (first SUNDIALS release)
 
 
-E. Revision History
--------------------
-
-v. 2.4.0 (May 2009) ---> v. 2.5.0 (Mar. 2012)
----------------------------------------------
-
-- Bug fix:
-   - consistently updated to using SUNDIALS_F77_FUNC in fcmix header files.
-
-v. 2.3.0 (Nov. 2006) ---> v. 2.4.0 (May 2009)
----------------------------------------------
-
-- none
-
-v. 2.2.0 (Mar. 2006) ---> v. 2.3.0 (Nov. 2006)
-----------------------------------------------
-
-- Changes related to the build system
-   - reorganized source tree. Header files in ${srcdir}/include/nvector; 
-     sources in ${srcdir}/src/nvec_par
-   - exported header files in ${includedir}/sundials
-
-v. 2.1.1 (May 2005) ---> v. 2.2.0 (Mar. 2006)
----------------------------------------------
-
-- none
-
-v. 2.1.0 (Apr. 2005) ---> v. 2.1.1 (May 2005)
----------------------------------------------
-
-- Changes to user interface
-   - added argument to initialization routines to allow user to specify a
-     different MPI communicator
-
-- Changes to data structures
-   - added N_VCloneEmpty to global vector operations table
-
-v. 2.0.2 (Mar. 2005) ---> v. 2.1.0 (Apr. 2005)
-----------------------------------------------
-
-- none
-
-v. 2.0.1 (Jan. 2005) ---> v. 2.0.2 (Mar. 2005)
-----------------------------------------------
-
-- Changes related to the build system
-   - fixed autoconf-related bug to allow configuration with the PGI Fortran compiler
-   - modified to use customized detection of the Fortran name mangling scheme 
-     (autoconf's AC_F77_WRAPPERS routine is problematic on some platforms)
-   - added --with-mpi-flags as a configure option to allow user to specify
-     MPI-specific flags
-   - updated Makefiles for Fortran examples to avoid C++ compiler errors (now use
-     CC and MPICC to link)
-
-v. 2.0 (Dec. 2004) ---> v. 2.0.1 (Jan. 2005)
---------------------------------------------
-
-- Changes related to the build system
-   - changed order of compiler directives in header files to avoid compilation
-     errors when using a C++ compiler.
-
-v. 1.0 (Jul. 2002) ---> v. 2.0 (Dec. 2004)
-------------------------------------------
-
-- Revised to correspond to new generic NVECTOR module
-  (see sundials/shared/README).
-- Extended the list of user-callable functions provided by NVECTOR_PARALLEL
-  outside the table of vector operations.
-- Revised parallel N_VMin and N_VMinQuotient to use BIG_REAL if
-  local N is 0 or no quotients found.
-- Revised the F/C interface to use underscore flags for name mapping
-  and to use precision flag from configure.
-- Revised F/C routine NVECTOR names for uniformity.
diff --git a/src/nvec_par/fnvector_parallel.c b/src/nvec_par/fnvector_parallel.c
index 6ece6b9..42492a7 100644
--- a/src/nvec_par/fnvector_parallel.c
+++ b/src/nvec_par/fnvector_parallel.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/07/05 15:32:37 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file (companion of nvector_parallel.h) contains the 
  * implementation needed for the Fortran initialization of parallel 
@@ -37,6 +42,8 @@ N_Vector F2C_IDA_vecQB;
 
 N_Vector F2C_KINSOL_vec;
 
+N_Vector F2C_ARKODE_vec;
+
 #ifndef SUNDIALS_MPI_COMM_F2C
 #define MPI_Fint int
 #endif
@@ -71,6 +78,11 @@ void FNV_INITP(MPI_Fint *comm, int *code, long int *L, long int *N, int *ier)
     F2C_KINSOL_vec = N_VNewEmpty_Parallel(F2C_comm, *L, *N);
     if (F2C_KINSOL_vec == NULL) *ier = -1;
     break;
+  case FCMIX_ARKODE:
+    F2C_ARKODE_vec = NULL;
+    F2C_ARKODE_vec = N_VNewEmpty_Parallel(F2C_comm, *L, *N);
+    if (F2C_ARKODE_vec == NULL) *ier = -1;
+    break;
   default:
     *ier = -1;
   }
diff --git a/src/nvec_par/fnvector_parallel.h b/src/nvec_par/fnvector_parallel.h
index 9d5b06f..c9fcbac 100644
--- a/src/nvec_par/fnvector_parallel.h
+++ b/src/nvec_par/fnvector_parallel.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file (companion of nvector_parallel.c) contains the
  * definitions needed for the initialization of parallel
@@ -19,13 +24,13 @@
 #ifndef _FNVECTOR_PARALLEL_H
 #define _FNVECTOR_PARALLEL_H
 
+#include <nvector/nvector_parallel.h>
+#include <sundials/sundials_fnvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <nvector/nvector_parallel.h>  
-#include <sundials/sundials_fnvector.h>
-
 #if defined(SUNDIALS_F77_FUNC)
 #define FNV_INITP    SUNDIALS_F77_FUNC(fnvinitp, FNVINITP)
 #else
@@ -64,6 +69,8 @@ extern N_Vector F2C_IDA_vecQB;
 
 extern N_Vector F2C_KINSOL_vec;
 
+extern N_Vector F2C_ARKODE_vec;
+
 /* 
  * Prototypes of exported functions 
  *
diff --git a/src/nvec_par/nvector_parallel.c b/src/nvec_par/nvector_parallel.c
index 8a53fab..f9797c8 100644
--- a/src/nvec_par/nvector_parallel.c
+++ b/src/nvec_par/nvector_parallel.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/07/05 15:32:37 $
+ * $Revision: 4867 $
+ * $Date: 2016-08-19 10:05:14 -0700 (Fri, 19 Aug 2016) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a parallel MPI implementation
  * of the NVECTOR package.
@@ -65,6 +70,16 @@ static void VScaleBy_Parallel(realtype a, N_Vector x);
  */
 
 /* ----------------------------------------------------------------
+ * Returns vector type ID. Used to identify vector implementation 
+ * from abstract N_Vector interface.
+ */
+
+N_Vector_ID N_VGetVectorID_Parallel(N_Vector v)
+{
+  return SUNDIALS_NVEC_PARALLEL;
+}
+
+/* ----------------------------------------------------------------
  * Function to create a new parallel vector with empty data array
  */
 
@@ -95,6 +110,7 @@ N_Vector N_VNewEmpty_Parallel(MPI_Comm comm,
   ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
   if (ops == NULL) { free(v); return(NULL); }
 
+  ops->nvgetvectorid     = N_VGetVectorID_Parallel;
   ops->nvclone           = N_VClone_Parallel;
   ops->nvcloneempty      = N_VCloneEmpty_Parallel;
   ops->nvdestroy         = N_VDestroy_Parallel;
@@ -267,6 +283,24 @@ void N_VDestroyVectorArray_Parallel(N_Vector *vs, int count)
 }
 
 /* ---------------------------------------------------------------- 
+ * Function to return global vector length 
+ */
+
+long int N_VGetLength_Parallel(N_Vector v)
+{
+  return NV_GLOBLENGTH_P(v);
+}
+
+/* ---------------------------------------------------------------- 
+ * Function to return local vector length 
+ */
+
+long int N_VGetLocalLength_Parallel(N_Vector v)
+{
+  return NV_LOCLENGTH_P(v);
+}
+
+/* ---------------------------------------------------------------- 
  * Function to print a parallel vector 
  */
 
@@ -284,7 +318,7 @@ void N_VPrint_Parallel(N_Vector x)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
     printf("%Lg\n", xd[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%lg\n", xd[i]);
+    printf("%g\n", xd[i]);
 #else
     printf("%g\n", xd[i]);
 #endif
@@ -318,6 +352,7 @@ N_Vector N_VCloneEmpty_Parallel(N_Vector w)
   ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
   if (ops == NULL) { free(v); return(NULL); }
   
+  ops->nvgetvectorid     = w->ops->nvgetvectorid;
   ops->nvclone           = w->ops->nvclone;
   ops->nvcloneempty      = w->ops->nvcloneempty;
   ops->nvdestroy         = w->ops->nvdestroy;
@@ -607,7 +642,7 @@ void N_VAbs_Parallel(N_Vector x, N_Vector z)
   zd = NV_DATA_P(z);
 
   for (i = 0; i < N; i++)
-    zd[i] = ABS(xd[i]);
+    zd[i] = SUNRabs(xd[i]);
 
   return;
 }
@@ -681,7 +716,7 @@ realtype N_VMaxNorm_Parallel(N_Vector x)
   max = ZERO;
 
   for (i = 0; i < N; i++) {
-    if (ABS(xd[i]) > max) max = ABS(xd[i]);
+    if (SUNRabs(xd[i]) > max) max = SUNRabs(xd[i]);
   }
    
   gmax = VAllReduce_Parallel(max, 2, comm);
@@ -706,12 +741,12 @@ realtype N_VWrmsNorm_Parallel(N_Vector x, N_Vector w)
 
   for (i = 0; i < N; i++) {
     prodi = xd[i]*wd[i];
-    sum += SQR(prodi);
+    sum += SUNSQR(prodi);
   }
 
   gsum = VAllReduce_Parallel(sum, 1, comm);
 
-  return(RSqrt(gsum/N_global));
+  return(SUNRsqrt(gsum/N_global));
 }
 
 realtype N_VWrmsNormMask_Parallel(N_Vector x, N_Vector w, N_Vector id)
@@ -733,13 +768,13 @@ realtype N_VWrmsNormMask_Parallel(N_Vector x, N_Vector w, N_Vector id)
   for (i = 0; i < N; i++) {
     if (idd[i] > ZERO) {
       prodi = xd[i]*wd[i];
-      sum += SQR(prodi);
+      sum += SUNSQR(prodi);
     }
   }
 
   gsum = VAllReduce_Parallel(sum, 1, comm);
 
-  return(RSqrt(gsum/N_global));
+  return(SUNRsqrt(gsum/N_global));
 }
 
 realtype N_VMin_Parallel(N_Vector x)
@@ -788,12 +823,12 @@ realtype N_VWL2Norm_Parallel(N_Vector x, N_Vector w)
 
   for (i = 0; i < N; i++) {
     prodi = xd[i]*wd[i];
-    sum += SQR(prodi);
+    sum += SUNSQR(prodi);
   }
 
   gsum = VAllReduce_Parallel(sum, 1, comm);
 
-  return(RSqrt(gsum));
+  return(SUNRsqrt(gsum));
 }
 
 realtype N_VL1Norm_Parallel(N_Vector x)
@@ -810,7 +845,7 @@ realtype N_VL1Norm_Parallel(N_Vector x)
   comm = NV_COMM_P(x);
 
   for (i = 0; i<N; i++) 
-    sum += ABS(xd[i]);
+    sum += SUNRabs(xd[i]);
 
   gsum = VAllReduce_Parallel(sum, 1, comm);
 
@@ -829,7 +864,7 @@ void N_VCompare_Parallel(realtype c, N_Vector x, N_Vector z)
   zd = NV_DATA_P(z);
 
   for (i = 0; i < N; i++) {
-    zd[i] = (ABS(xd[i]) >= c) ? ONE : ZERO;
+    zd[i] = (SUNRabs(xd[i]) >= c) ? ONE : ZERO;
   }
 
   return;
@@ -919,7 +954,7 @@ realtype N_VMinQuotient_Parallel(N_Vector num, N_Vector denom)
   for (i = 0; i < N; i++) {
     if (dd[i] == ZERO) continue;
     else {
-      if (!notEvenOnce) min = MIN(min, nd[i]/dd[i]);
+      if (!notEvenOnce) min = SUNMIN(min, nd[i]/dd[i]);
       else {
         min = nd[i]/dd[i];
         notEvenOnce = FALSE;
diff --git a/src/nvec_parhyp/CMakeLists.txt b/src/nvec_parhyp/CMakeLists.txt
new file mode 100644
index 0000000..9255489
--- /dev/null
+++ b/src/nvec_parhyp/CMakeLists.txt
@@ -0,0 +1,77 @@
+# ---------------------------------------------------------------
+# $Revision: 4075 $
+# $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+# ---------------------------------------------------------------
+# Programmer:  Radu Serban @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the parhyp NVECTOR library
+
+INSTALL(CODE "MESSAGE(\"\nInstall NVECTOR_PARHYP\n\")")
+
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICC)
+
+# Add variable nvecparhyp_SOURCES with the sources for the NVECPARHYP lib
+SET(nvecparhyp_SOURCES nvector_parhyp.c)
+
+# Add variable shared_SOURCES with the common SUNDIALS sources which will
+# also be included in the NVECPARHYP library
+SET(shared_SOURCES sundials_math.c)
+ADD_PREFIX(${sundials_SOURCE_DIR}/src/sundials/ shared_SOURCES)
+
+# Add variable nvecparhyp_HEADERS with the exported NVECPARHYP header files
+SET(nvecparhyp_HEADERS nvector_parhyp.h)
+ADD_PREFIX(${sundials_SOURCE_DIR}/include/nvector/ nvecparhyp_HEADERS)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(.)
+INCLUDE_DIRECTORIES(${HYPRE_INCLUDE_DIR})
+
+# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY 
+ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+
+# Rules for building and installing the static library:
+#  - Add the build target for the NVECPARHYP library
+#  - Set the library name and make sure it is not deleted
+#  - Install the NVECPARHYP library
+IF(BUILD_STATIC_LIBS)
+  ADD_LIBRARY(sundials_nvecparhyp_static STATIC ${nvecparhyp_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecparhyp_static
+    PROPERTIES OUTPUT_NAME sundials_nvecparhyp CLEAN_DIRECT_OUTPUT 1)
+  INSTALL(TARGETS sundials_nvecparhyp_static DESTINATION lib)
+ENDIF(BUILD_STATIC_LIBS)
+
+# Rules for building and installing the shared library:
+#  - Add the build target for the NVECPARHYP library
+#  - Set the library name and make sure it is not deleted
+#  - Set VERSION and SOVERSION for shared libraries
+#  - Install the NVECPARHYP library
+IF(BUILD_SHARED_LIBS)
+  ADD_LIBRARY(sundials_nvecparhyp_shared SHARED ${nvecparhyp_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecparhyp_shared
+    PROPERTIES OUTPUT_NAME sundials_nvecparhyp CLEAN_DIRECT_OUTPUT 1)
+  SET_TARGET_PROPERTIES(sundials_nvecparhyp_shared 
+    PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION})
+  INSTALL(TARGETS sundials_nvecparhyp_shared DESTINATION lib)
+ENDIF(BUILD_SHARED_LIBS)
+
+# Install the NVECPARHYP header files
+INSTALL(FILES ${nvecparhyp_HEADERS} DESTINATION include/nvector)
+
+#
+MESSAGE(STATUS "Added NVECTOR_PARHYP module")
diff --git a/src/nvec_parhyp/README b/src/nvec_parhyp/README
new file mode 100644
index 0000000..4469e2f
--- /dev/null
+++ b/src/nvec_parhyp/README
@@ -0,0 +1,46 @@
+                     NVECTOR_PARHYPE
+                 released as part of SUNDIALS
+    SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
+                   Release 2.7.0, September 2016
+
+
+The NVECTOR_PARHYP implementation of the nvector module provided with
+SUNDIALS is a wrapper around hypre's ParVector class. 
+Most of the vector kernels simply call hypre vector operations. 
+
+NVECTOR_PARHYP defines the content field of N_Vector to 
+be a structure containing the global and local lengths of the vector, a 
+pointer to an object of type hypre_ParVector, an MPI communicator, 
+and a boolean flag indicating ownership of the data array.
+
+NVECTOR_PARHYP defines implementations of all vector operations defined
+by the generic NVECTOR module in the table of operations, except for 
+N_VSetArrayPointer and N_VGetArrayPointer, because accessing raw vector data should 
+be handled by hypre functions.  As such, this vector is not available for use with 
+SUNDIALS Fortran interfaces. When access to raw vector data is needed, one 
+should extract the hypre vector first, and then use hypre methods to access the data. 
+Usage examples of NVECTOR_PARHYP are provided in cvAdvDiff_non_ph.c example program 
+for CVODE and the ark_diurnal_kry_ph.c example program for ARKODE.
+
+A. Documentation
+----------------
+
+The NVECTOR_PARHYP implementation is fully described in the user documentation
+for any of the SUNDIALS solvers. A PDF file for the user guide for a particular
+solver is available in the solver's subdirectory under doc/.
+
+
+B. Installation
+---------------
+
+For basic installation instructions see /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see any of the user guides.
+
+
+
+C. Releases
+-----------
+
+v. 2.7.0 - Sep. 2016
+
+
diff --git a/src/nvec_parhyp/nvector_parhyp.c b/src/nvec_parhyp/nvector_parhyp.c
new file mode 100644
index 0000000..fc56996
--- /dev/null
+++ b/src/nvec_parhyp/nvector_parhyp.c
@@ -0,0 +1,1160 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4396 $
+ * $Date: 2015-02-26 16:59:39 -0800 (Thu, 26 Feb 2015) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Jean M. Sexton @ SMU
+ *                Slaven Peles @ LLNL
+ * -----------------------------------------------------------------
+ * Based on work by Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
+ *                  and Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for a parhyp MPI implementation
+ * of the NVECTOR package.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <nvector/nvector_parhyp.h>
+#include <sundials/sundials_math.h>
+
+#define ZERO   RCONST(0.0)
+#define HALF   RCONST(0.5)
+#define ONE    RCONST(1.0)
+#define ONEPT5 RCONST(1.5)
+
+/* Error Message */
+
+#define BAD_N1 "N_VNew_ParHyp -- Sum of local vector lengths differs from "
+#define BAD_N2 "input global length. \n\n"
+#define BAD_N   BAD_N1 BAD_N2
+
+/*
+ * -----------------------------------------------------------------
+ * Simplifying macros NV_CONTENT_PH, NV_DATA_PH, NV_LOCLENGTH_PH, 
+ *                    NV_GLOBLENGTH_PH, and NV_COMM_PH
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * N_Vector v;
+ * long int v_len, s_len, i;
+ *
+ * (1) NV_CONTENT_PH
+ *
+ *     This routines gives access to the contents of the HYPRE
+ *     vector wrapper (the N_Vector).
+ *
+ *     The assignment v_cont = NV_CONTENT_PH(v) sets v_cont to be
+ *     a pointer to the N_Vector content structure.
+ *
+ * (2) NV_DATA_PH, NV_LOCLENGTH_PH, NV_GLOBLENGTH_PH, and NV_COMM_PH
+ *
+ *     These routines give access to the individual parts of
+ *     the content structure of a parhyp N_Vector.
+ *
+ *     The assignment v_llen = NV_LOCLENGTH_PH(v) sets v_llen to
+ *     be the length of the local part of the vector v. The call
+ *     NV_LOCLENGTH_PH(v) = llen_v generally should NOT be used! It 
+ *     will change locally stored value with the HYPRE local vector 
+ *     length, but it will NOT change the length of the actual HYPRE
+ *     local vector.
+ *
+ *     The assignment v_glen = NV_GLOBLENGTH_PH(v) sets v_glen to
+ *     be the global length of the vector v. The call
+ *     NV_GLOBLENGTH_PH(v) = glen_v generally should NOT be used! It 
+ *     will change locally stored value with the HYPRE parallel vector 
+ *     length, but it will NOT change the length of the actual HYPRE
+ *     parallel vector.
+ *
+ *     The assignment v_comm = NV_COMM_PH(v) sets v_comm to be the
+ *     MPI communicator of the vector v. The assignment
+ *     NV_COMM_C(v) = comm_v sets the MPI communicator of v to be
+ *     NV_COMM_PH(v) = comm_v generally should NOT be used! It 
+ *     will change locally stored value with the HYPRE parallel vector 
+ *     communicator, but it will NOT change the communicator of the 
+ *     actual HYPRE parallel vector.
+ * 
+ * (3) NV_DATA_PH, NV_HYPRE_PARVEC_PH
+ *     
+ *     The assignment v_data = NV_DATA_PH(v) sets v_data to be
+ *     a pointer to the first component of the data inside the 
+ *     local vector of the HYPRE_parhyp vector for the vector v. 
+ *     The assignment NV_DATA_PH(v) = data_v should NOT be used. 
+ *     Instead, use NV_HYPRE_PARVEC_PH to obtain pointer to HYPRE 
+ *     vector and then use HYPRE functions to manipulate vector data.
+ *
+ *     The assignment v_parhyp = NV_HYPRE_PARVEC_PH(v) sets v_parhyp
+ *     to be a pointer to hypre_ParVector of vector v. The assignment
+ *     NV_HYPRE_PARVEC_PH(v) = parhyp_v sets pointer to 
+ *     hypre_ParVector of vector v to be parhyp_v.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#define NV_CONTENT_PH(v)    ( (N_VectorContent_ParHyp)(v->content) )
+
+#define NV_LOCLENGTH_PH(v)  ( NV_CONTENT_PH(v)->local_length )
+
+#define NV_GLOBLENGTH_PH(v) ( NV_CONTENT_PH(v)->global_length )
+
+#define NV_OWN_PARVEC_PH(v) ( NV_CONTENT_PH(v)->own_parvector )
+
+#define NV_HYPRE_PARVEC_PH(v) ( NV_CONTENT_PH(v)->x )
+
+#define NV_DATA_PH(v)       ( NV_HYPRE_PARVEC_PH(v) == NULL ? NULL : hypre_VectorData(hypre_ParVectorLocalVector(NV_HYPRE_PARVEC_PH(v))) )
+
+#define NV_COMM_PH(v)       ( NV_CONTENT_PH(v)->comm )
+
+
+/* Private function prototypes */
+
+/* Reduction operations add/max/min over the processor group */
+static realtype VAllReduce_ParHyp(realtype d, int op, MPI_Comm comm);
+/* z=x */
+/* static void VCopy_ParHyp(N_Vector x, N_Vector z); */
+/* z=x+y */
+static void VSum_ParHyp(N_Vector x, N_Vector y, N_Vector z);
+/* z=x-y */
+static void VDiff_ParHyp(N_Vector x, N_Vector y, N_Vector z);
+/* z=-x */
+/* static void VNeg_ParHyp(N_Vector x, N_Vector z); */
+/* z=c(x+y) */
+static void VScaleSum_ParHyp(realtype c, N_Vector x, N_Vector y, N_Vector z);
+/* z=c(x-y) */
+static void VScaleDiff_ParHyp(realtype c, N_Vector x, N_Vector y, N_Vector z); 
+/* z=ax+y */
+static void VLin1_ParHyp(realtype a, N_Vector x, N_Vector y, N_Vector z);
+/* z=ax-y */
+static void VLin2_ParHyp(realtype a, N_Vector x, N_Vector y, N_Vector z);
+/* y <- ax+y */
+/* static void Vaxpy_ParHyp(realtype a, N_Vector x, N_Vector y); */
+/* x <- ax */
+/* static void VScaleBy_ParHyp(realtype a, N_Vector x); */
+
+/*
+ * -----------------------------------------------------------------
+ * exported functions
+ * -----------------------------------------------------------------
+ */
+
+/* ----------------------------------------------------------------
+ * Returns vector type ID. Used to identify vector implementation 
+ * from abstract N_Vector interface.
+ */
+N_Vector_ID N_VGetVectorID_ParHyp(N_Vector v)
+{
+  return SUNDIALS_NVEC_PARHYP;
+}
+
+
+/* ----------------------------------------------------------------
+ * Function to create a new parhyp vector without underlying
+ * HYPRE vector.
+ */
+N_Vector N_VNewEmpty_ParHyp(MPI_Comm comm, 
+                            long int local_length,
+                            long int global_length)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_ParHyp content;
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+  
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { free(v); return(NULL); }
+
+  ops->nvgetvectorid     = N_VGetVectorID_ParHyp;
+  ops->nvclone           = N_VClone_ParHyp;
+  ops->nvcloneempty      = N_VCloneEmpty_ParHyp;
+  ops->nvdestroy         = N_VDestroy_ParHyp;
+  ops->nvspace           = N_VSpace_ParHyp;
+  ops->nvgetarraypointer = N_VGetArrayPointer_ParHyp;
+  ops->nvsetarraypointer = N_VSetArrayPointer_ParHyp;
+  ops->nvlinearsum       = N_VLinearSum_ParHyp;
+  ops->nvconst           = N_VConst_ParHyp;
+  ops->nvprod            = N_VProd_ParHyp;
+  ops->nvdiv             = N_VDiv_ParHyp;
+  ops->nvscale           = N_VScale_ParHyp;
+  ops->nvabs             = N_VAbs_ParHyp;
+  ops->nvinv             = N_VInv_ParHyp;
+  ops->nvaddconst        = N_VAddConst_ParHyp;
+  ops->nvdotprod         = N_VDotProd_ParHyp;
+  ops->nvmaxnorm         = N_VMaxNorm_ParHyp;
+  ops->nvwrmsnormmask    = N_VWrmsNormMask_ParHyp;
+  ops->nvwrmsnorm        = N_VWrmsNorm_ParHyp;
+  ops->nvmin             = N_VMin_ParHyp;
+  ops->nvwl2norm         = N_VWL2Norm_ParHyp;
+  ops->nvl1norm          = N_VL1Norm_ParHyp;
+  ops->nvcompare         = N_VCompare_ParHyp;
+  ops->nvinvtest         = N_VInvTest_ParHyp;
+  ops->nvconstrmask      = N_VConstrMask_ParHyp;
+  ops->nvminquotient     = N_VMinQuotient_ParHyp;
+
+  /* Create content */
+  content = NULL;
+  content = (N_VectorContent_ParHyp) malloc(sizeof(struct _N_VectorContent_ParHyp));
+  if (content == NULL) { free(ops); free(v); return(NULL); }
+
+  /* Attach lengths and communicator */
+  content->local_length  = local_length;
+  content->global_length = global_length;
+  content->comm          = comm;
+  content->own_parvector = FALSE;
+  content->x             = NULL;
+  
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+
+/* ---------------------------------------------------------------- 
+ * Function to create a parhyp N_Vector wrapper around user 
+ * supplie HYPRE vector.
+ */
+
+N_Vector N_VMake_ParHyp(hypre_ParVector *x)
+{
+  N_Vector v;
+  MPI_Comm comm = hypre_ParVectorComm(x);
+  HYPRE_Int global_length = hypre_ParVectorGlobalSize(x);
+  HYPRE_Int local_begin = hypre_ParVectorFirstIndex(x);
+  HYPRE_Int local_end = hypre_ParVectorLastIndex(x);
+  HYPRE_Int local_length = local_end - local_begin + 1;
+  
+  v = NULL;
+  v = N_VNewEmpty_ParHyp(comm, local_length, global_length);
+  if (v == NULL) 
+    return(NULL);
+
+  NV_OWN_PARVEC_PH(v)   = FALSE;
+  NV_HYPRE_PARVEC_PH(v) = x;
+
+  return(v);
+}
+
+
+/* ---------------------------------------------------------------- 
+ * Function to create an array of new parhyp vectors. 
+ */
+
+N_Vector *N_VCloneVectorArray_ParHyp(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VClone_ParHyp(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_ParHyp(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ---------------------------------------------------------------- 
+ * Function to create an array of new parhyp vector wrappers 
+ * without uderlying HYPRE vectors.
+ */
+
+N_Vector *N_VCloneVectorArrayEmpty_ParHyp(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VCloneEmpty_ParHyp(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_ParHyp(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ----------------------------------------------------------------
+ * Function to free an array created with N_VCloneVectorArray_ParHyp
+ */
+
+void N_VDestroyVectorArray_ParHyp(N_Vector *vs, int count)
+{
+  int j;
+
+  for (j = 0; j < count; j++) 
+    N_VDestroy_ParHyp(vs[j]);
+
+  free(vs); 
+  vs = NULL;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------
+ * Extract HYPRE vector
+ */
+
+hypre_ParVector* N_VGetVector_ParHyp(N_Vector v)
+{
+  return NV_HYPRE_PARVEC_PH(v); 
+}
+
+/* ---------------------------------------------------------------- 
+ * Function to print a parhyp vector.
+ * TODO: Consider using a HYPRE function for this.
+ */
+
+void N_VPrint_ParHyp(N_Vector x)
+{
+  long int i, N;
+  realtype *xd;
+
+  xd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+
+  for (i = 0; i < N; i++) {
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf("%Lg\n", xd[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf("%g\n", xd[i]);
+#else
+    printf("%g\n", xd[i]);
+#endif
+  }
+  printf("\n");
+
+  return;
+}
+
+/*
+ * -----------------------------------------------------------------
+ * implementation of vector operations
+ * -----------------------------------------------------------------
+ */
+
+N_Vector N_VCloneEmpty_ParHyp(N_Vector w)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_ParHyp content;
+
+  if (w == NULL) return(NULL);
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+  
+  /* Added variables for hypre_parhyp intialization */
+  int nprocs, myid;
+  MPI_Comm_size(NV_COMM_PH(w), &nprocs);
+  MPI_Comm_rank(NV_COMM_PH(w), &myid);
+  
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { free(v); return(NULL); }
+  
+  ops->nvgetvectorid     = w->ops->nvgetvectorid;
+  ops->nvclone           = w->ops->nvclone;
+  ops->nvcloneempty      = w->ops->nvcloneempty;
+  ops->nvdestroy         = w->ops->nvdestroy;
+  ops->nvspace           = w->ops->nvspace;
+  ops->nvgetarraypointer = w->ops->nvgetarraypointer;
+  ops->nvsetarraypointer = w->ops->nvsetarraypointer;
+  ops->nvlinearsum       = w->ops->nvlinearsum;
+  ops->nvconst           = w->ops->nvconst;  
+  ops->nvprod            = w->ops->nvprod;   
+  ops->nvdiv             = w->ops->nvdiv;
+  ops->nvscale           = w->ops->nvscale; 
+  ops->nvabs             = w->ops->nvabs;
+  ops->nvinv             = w->ops->nvinv;
+  ops->nvaddconst        = w->ops->nvaddconst;
+  ops->nvdotprod         = w->ops->nvdotprod;
+  ops->nvmaxnorm         = w->ops->nvmaxnorm;
+  ops->nvwrmsnormmask    = w->ops->nvwrmsnormmask;
+  ops->nvwrmsnorm        = w->ops->nvwrmsnorm;
+  ops->nvmin             = w->ops->nvmin;
+  ops->nvwl2norm         = w->ops->nvwl2norm;
+  ops->nvl1norm          = w->ops->nvl1norm;
+  ops->nvcompare         = w->ops->nvcompare;    
+  ops->nvinvtest         = w->ops->nvinvtest;
+  ops->nvconstrmask      = w->ops->nvconstrmask;
+  ops->nvminquotient     = w->ops->nvminquotient;
+
+  /* Create content */  
+  content = NULL;
+  content = (N_VectorContent_ParHyp) malloc(sizeof(struct _N_VectorContent_ParHyp));
+  if (content == NULL) { free(ops); free(v); return(NULL); }
+
+  /* Attach lengths and communicator */
+  content->local_length  = NV_LOCLENGTH_PH(w);
+  content->global_length = NV_GLOBLENGTH_PH(w);
+  content->comm          = NV_COMM_PH(w);
+  content->own_parvector = FALSE;
+  content->x             = NULL;
+  
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+/*
+ * Clone HYPRE vector wrapper.
+ * 
+ */
+N_Vector N_VClone_ParHyp(N_Vector w)
+{
+  N_Vector v;
+  hypre_ParVector *vx;
+  const hypre_ParVector *wx = NV_HYPRE_PARVEC_PH(w);
+  
+  v = NULL;
+  v = N_VCloneEmpty_ParHyp(w);
+  if (v==NULL)
+    return(NULL);
+  
+  vx = hypre_ParVectorCreate(wx->comm, wx->global_size, wx->partitioning);
+  hypre_ParVectorInitialize(vx);
+
+  hypre_ParVectorSetPartitioningOwner(vx, 0);
+  hypre_ParVectorSetDataOwner(vx, 1);
+  hypre_SeqVectorSetDataOwner(hypre_ParVectorLocalVector(vx), 1);
+  
+  NV_HYPRE_PARVEC_PH(v) = vx;
+  NV_OWN_PARVEC_PH(v) = TRUE;
+  
+  return(v);
+}
+
+void N_VDestroy_ParHyp(N_Vector v)
+{
+  if ((NV_OWN_PARVEC_PH(v) == TRUE)) {
+    hypre_ParVectorDestroy(NV_HYPRE_PARVEC_PH(v));
+  }
+  
+  free(v->content); v->content = NULL;
+  free(v->ops); v->ops = NULL;
+  free(v); v = NULL;
+
+  return;
+}
+
+
+void N_VSpace_ParHyp(N_Vector v, long int *lrw, long int *liw)
+{
+  MPI_Comm comm;
+  int npes;
+
+  comm = NV_COMM_PH(v);
+  MPI_Comm_size(comm, &npes);
+  
+  *lrw = NV_GLOBLENGTH_PH(v);
+  *liw = 2*npes;
+
+  return;
+}
+
+
+/*
+ * This function is disabled in ParHyp implementation and returns NULL. 
+ * The user should extract HYPRE vector using N_VGetVector_ParHyp and 
+ * then use HYPRE functions to get pointer to raw data of the local HYPRE 
+ * vector.
+ */
+realtype *N_VGetArrayPointer_ParHyp(N_Vector v)
+{
+  return NULL; /* ((realtype *) NV_DATA_PH(v)); */
+}
+
+
+/*
+ * This method is not implemented for HYPRE vector wrapper.
+ * TODO: Put error handler in the function body.
+ */
+void N_VSetArrayPointer_ParHyp(realtype *v_data, N_Vector v)
+{
+  /* Not implemented for Hypre vector */
+}
+
+/*
+ * Computes z[i] = a*x[i] + b*y[i]
+ * 
+ */
+void N_VLinearSum_ParHyp(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype c, *xd, *yd, *zd;
+  N_Vector v1, v2;
+  booleantype test;
+
+  xd = yd = zd = NULL;
+
+  if ((b == ONE) && (z == y)) {    /* BLAS usage: axpy y <- ax+y */
+    HYPRE_Complex   alpha=a;
+    HYPRE_ParVectorAxpy( alpha, (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(x),
+                                (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(y));
+    return;
+  }
+
+  if ((a == ONE) && (z == x)) {    /* BLAS usage: axpy x <- by+x */
+    HYPRE_Complex   beta=b;
+    HYPRE_ParVectorAxpy( beta, (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(y),
+                               (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(x));
+    return;
+  }
+
+  /* Case: a == b == 1.0 */
+
+  if ((a == ONE) && (b == ONE)) {
+    VSum_ParHyp(x, y, z);
+    return;
+  }
+
+  /* Cases: (1) a == 1.0, b = -1.0, (2) a == -1.0, b == 1.0 */
+
+  if ((test = ((a == ONE) && (b == -ONE))) || ((a == -ONE) && (b == ONE))) {
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VDiff_ParHyp(v2, v1, z);
+    return;
+  }
+
+  /* Cases: (1) a == 1.0, b == other or 0.0, (2) a == other or 0.0, b == 1.0 */
+  /* if a or b is 0.0, then user should have called N_VScale */
+
+  if ((test = (a == ONE)) || (b == ONE)) {
+    c = test ? b : a;
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VLin1_ParHyp(c, v1, v2, z);
+    return;
+  }
+
+  /* Cases: (1) a == -1.0, b != 1.0, (2) a != 1.0, b == -1.0 */
+
+  if ((test = (a == -ONE)) || (b == -ONE)) {
+    c = test ? b : a;
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VLin2_ParHyp(c, v1, v2, z);
+    return;
+  }
+
+  /* Case: a == b */
+  /* catches case both a and b are 0.0 - user should have called N_VConst */
+
+  if (a == b) {
+    VScaleSum_ParHyp(a, x, y, z);
+    return;
+  }
+
+  /* Case: a == -b */
+
+  if (a == -b) {
+    VScaleDiff_ParHyp(a, x, y, z);
+    return;
+  }
+
+  /* Do all cases not handled above:
+     (1) a == other, b == 0.0 - user should have called N_VScale
+     (2) a == 0.0, b == other - user should have called N_VScale
+     (3) a,b == other, a !=b, a != -b */
+  
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = (a*xd[i])+(b*yd[i]);
+
+  return;
+}
+
+void N_VConst_ParHyp(realtype c, N_Vector z)
+{
+  HYPRE_Complex value = c;
+  HYPRE_ParVectorSetConstantValues( (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(z), value);
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise product z[i] = x[i]*y[i]
+ */
+
+void N_VProd_ParHyp(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]*yd[i];
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise division z[i] = x[i]/y[i]
+ */
+
+void N_VDiv_ParHyp(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]/yd[i];
+
+  return;
+}
+
+
+void N_VScale_ParHyp(realtype c, N_Vector x, N_Vector z)
+{
+  HYPRE_Complex value = c;
+  
+  if (x != z) {
+     HYPRE_ParVectorCopy((HYPRE_ParVector) NV_HYPRE_PARVEC_PH(x), (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(z));
+  }
+  HYPRE_ParVectorScale(value, (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(z));
+  
+  return;
+}
+
+
+void N_VAbs_ParHyp(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = SUNRabs(xd[i]);
+
+  return;
+}
+
+void N_VInv_ParHyp(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = ONE/xd[i];
+
+  return;
+}
+
+void N_VAddConst_ParHyp(N_Vector x, realtype b, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  zd = NV_DATA_PH(z);
+  
+  for (i = 0; i < N; i++) 
+     zd[i] = xd[i] + b;
+
+  return;
+}
+
+realtype N_VDotProd_ParHyp(N_Vector x, N_Vector y)
+{
+
+  HYPRE_Real gsum;
+  HYPRE_ParVectorInnerProd( (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(x),
+                            (HYPRE_ParVector) NV_HYPRE_PARVEC_PH(y), &gsum);
+
+  return(gsum);
+}
+
+realtype N_VMaxNorm_ParHyp(N_Vector x)
+{
+  long int i, N;
+  realtype max, *xd, gmax;
+  MPI_Comm comm;
+
+  xd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  comm = NV_COMM_PH(x);
+
+  max = ZERO;
+
+  for (i = 0; i < N; i++) {
+    if (SUNRabs(xd[i]) > max) max = SUNRabs(xd[i]);
+  }
+   
+  gmax = VAllReduce_ParHyp(max, 2, comm);
+
+  return(gmax);
+}
+
+realtype N_VWrmsNorm_ParHyp(N_Vector x, N_Vector w)
+{
+  long int i, N, N_global;
+  realtype sum, prodi, *xd, *wd, gsum;
+  MPI_Comm comm;
+
+  sum = ZERO;
+  xd = wd = NULL;
+
+  N        = NV_LOCLENGTH_PH(x);
+  N_global = NV_GLOBLENGTH_PH(x);
+  xd       = NV_DATA_PH(x);
+  wd       = NV_DATA_PH(w);
+  comm     = NV_COMM_PH(x);
+
+  for (i = 0; i < N; i++) {
+    prodi = xd[i]*wd[i];
+    sum += SUNSQR(prodi);
+  }
+
+  gsum = VAllReduce_ParHyp(sum, 1, comm);
+
+  return(SUNRsqrt(gsum/N_global));
+}
+
+realtype N_VWrmsNormMask_ParHyp(N_Vector x, N_Vector w, N_Vector id)
+{
+  long int i, N, N_global;
+  realtype sum, prodi, *xd, *wd, *idd, gsum;
+  MPI_Comm comm;
+
+  sum = ZERO;
+  xd = wd = idd = NULL;
+
+  N        = NV_LOCLENGTH_PH(x);
+  N_global = NV_GLOBLENGTH_PH(x);
+  xd       = NV_DATA_PH(x);
+  wd       = NV_DATA_PH(w);
+  idd      = NV_DATA_PH(id);
+  comm = NV_COMM_PH(x);
+
+  for (i = 0; i < N; i++) {
+    if (idd[i] > ZERO) {
+      prodi = xd[i]*wd[i];
+      sum += SUNSQR(prodi);
+    }
+  }
+
+  gsum = VAllReduce_ParHyp(sum, 1, comm);
+
+  return(SUNRsqrt(gsum/N_global));
+}
+
+realtype N_VMin_ParHyp(N_Vector x)
+{
+  long int i, N;
+  realtype min, *xd, gmin;
+  MPI_Comm comm;
+
+  xd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  comm = NV_COMM_PH(x);
+
+  min = BIG_REAL;
+
+  if (N > 0) {
+
+    xd = NV_DATA_PH(x);
+
+    min = xd[0];
+
+    for (i = 1; i < N; i++) {
+      if (xd[i] < min) 
+        min = xd[i];
+    }
+
+  }
+
+  gmin = VAllReduce_ParHyp(min, 3, comm);
+
+  return(gmin);
+}
+
+realtype N_VWL2Norm_ParHyp(N_Vector x, N_Vector w)
+{
+  long int i, N;
+  realtype sum, prodi, *xd, *wd, gsum;
+  MPI_Comm comm;
+
+  sum = ZERO;
+  xd = wd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  wd = NV_DATA_PH(w);
+  comm = NV_COMM_PH(x);
+
+  for (i = 0; i < N; i++) {
+    prodi = xd[i]*wd[i];
+    sum += SUNSQR(prodi);
+  }
+
+  gsum = VAllReduce_ParHyp(sum, 1, comm);
+
+  return(SUNRsqrt(gsum));
+}
+
+realtype N_VL1Norm_ParHyp(N_Vector x)
+{
+  long int i, N;
+  realtype sum, gsum, *xd;
+  MPI_Comm comm;
+
+  sum = ZERO;
+  xd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  comm = NV_COMM_PH(x);
+
+  for (i = 0; i<N; i++) 
+    sum += SUNRabs(xd[i]);
+
+  gsum = VAllReduce_ParHyp(sum, 1, comm);
+
+  return(gsum);
+}
+
+void N_VCompare_ParHyp(realtype c, N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd;
+
+  xd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++) {
+    zd[i] = (SUNRabs(xd[i]) >= c) ? ONE : ZERO;
+  }
+
+  return;
+}
+
+booleantype N_VInvTest_ParHyp(N_Vector x, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *zd, val, gval;
+  MPI_Comm comm;
+
+  xd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  zd = NV_DATA_PH(z);
+  comm = NV_COMM_PH(x);
+
+  val = ONE;
+  for (i = 0; i < N; i++) {
+    if (xd[i] == ZERO) 
+      val = ZERO;
+    else
+      zd[i] = ONE/xd[i];
+  }
+
+  gval = VAllReduce_ParHyp(val, 3, comm);
+
+  if (gval == ZERO)
+    return(FALSE);
+  else
+    return(TRUE);
+}
+
+booleantype N_VConstrMask_ParHyp(N_Vector c, N_Vector x, N_Vector m)
+{
+  long int i, N;
+  realtype temp;
+  realtype *cd, *xd, *md;
+  MPI_Comm comm;
+
+  cd = xd = md = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  cd = NV_DATA_PH(c);
+  md = NV_DATA_PH(m);
+  comm = NV_COMM_PH(x);
+
+  temp = ONE;
+
+  for (i = 0; i < N; i++) {
+    md[i] = ZERO;
+    if (cd[i] == ZERO) continue;
+    if (cd[i] > ONEPT5 || cd[i] < -ONEPT5) {
+      if (xd[i]*cd[i] <= ZERO) { 
+        temp = ZERO; 
+        md[i] = ONE;
+      }
+      continue;
+    }
+    if (cd[i] > HALF || cd[i] < -HALF) {
+      if (xd[i]*cd[i] < ZERO ) { 
+        temp = ZERO; 
+        md[i] = ONE;
+      }
+    }
+  }
+
+  temp = VAllReduce_ParHyp(temp, 3, comm);
+
+  if (temp == ONE) 
+    return(TRUE);
+  else 
+    return(FALSE);
+}
+
+realtype N_VMinQuotient_ParHyp(N_Vector num, N_Vector denom)
+{
+  booleantype notEvenOnce;
+  long int i, N;
+  realtype *nd, *dd, min;
+  MPI_Comm comm;
+
+  nd = dd = NULL;
+
+  N  = NV_LOCLENGTH_PH(num);
+  nd = NV_DATA_PH(num);
+  dd = NV_DATA_PH(denom);
+  comm = NV_COMM_PH(num);
+
+  notEvenOnce = TRUE;
+  min = BIG_REAL;
+
+  for (i = 0; i < N; i++) {
+    if (dd[i] == ZERO) continue;
+    else {
+      if (!notEvenOnce) min = SUNMIN(min, nd[i]/dd[i]);
+      else {
+        min = nd[i]/dd[i];
+        notEvenOnce = FALSE;
+      }
+    }
+  }
+
+  return(VAllReduce_ParHyp(min, 3, comm));
+}
+
+/*
+ * -----------------------------------------------------------------
+ * private functions
+ * -----------------------------------------------------------------
+ */
+
+static realtype VAllReduce_ParHyp(realtype d, int op, MPI_Comm comm)
+{
+  /* 
+   * This function does a global reduction.  The operation is
+   *   sum if op = 1,
+   *   max if op = 2,
+   *   min if op = 3.
+   * The operation is over all processors in the communicator 
+   */
+
+  realtype out;
+
+  switch (op) {
+   case 1: MPI_Allreduce(&d, &out, 1, PVEC_REAL_MPI_TYPE, MPI_SUM, comm);
+           break;
+
+   case 2: MPI_Allreduce(&d, &out, 1, PVEC_REAL_MPI_TYPE, MPI_MAX, comm);
+           break;
+
+   case 3: MPI_Allreduce(&d, &out, 1, PVEC_REAL_MPI_TYPE, MPI_MIN, comm);
+           break;
+
+   default: break;
+  }
+
+  return(out);
+}
+
+
+static void VSum_ParHyp(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]+yd[i];
+
+  return;
+}
+
+static void VDiff_ParHyp(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = xd[i]-yd[i];
+
+  return;
+}
+
+
+static void VScaleSum_ParHyp(realtype c, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = c*(xd[i]+yd[i]);
+
+  return;
+}
+
+static void VScaleDiff_ParHyp(realtype c, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = c*(xd[i]-yd[i]);
+
+  return;
+}
+
+static void VLin1_ParHyp(realtype a, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = (a*xd[i])+yd[i];
+
+  return;
+}
+
+static void VLin2_ParHyp(realtype a, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int i, N;
+  realtype *xd, *yd, *zd;
+
+  xd = yd = zd = NULL;
+
+  N  = NV_LOCLENGTH_PH(x);
+  xd = NV_DATA_PH(x);
+  yd = NV_DATA_PH(y);
+  zd = NV_DATA_PH(z);
+
+  for (i = 0; i < N; i++)
+    zd[i] = (a*xd[i])-yd[i];
+
+  return;
+}
+
diff --git a/src/nvec_petsc/CMakeLists.txt b/src/nvec_petsc/CMakeLists.txt
new file mode 100644
index 0000000..a98867c
--- /dev/null
+++ b/src/nvec_petsc/CMakeLists.txt
@@ -0,0 +1,77 @@
+# ---------------------------------------------------------------
+# $Revision:  $
+# $Date:  $
+# ---------------------------------------------------------------
+# Programmer:  Radu Serban @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the petsc NVECTOR library
+
+INSTALL(CODE "MESSAGE(\"\nInstall NVECTOR_PETSC\n\")")
+
+IF(MPI_MPICC)
+  # use MPI_MPICC as the compiler
+  SET(CMAKE_C_COMPILER ${MPI_MPICC})
+ELSE(MPI_MPICC)
+  # add MPI_INCLUDE_PATH to include directories
+  INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+ENDIF(MPI_MPICC)
+
+# Add variable nvecpetsc_SOURCES with the sources for the NVECPARHYP lib
+SET(nvecpetsc_SOURCES nvector_petsc.c)
+
+# Add variable shared_SOURCES with the common SUNDIALS sources which will
+# also be included in the NVECPARHYP library
+SET(shared_SOURCES sundials_math.c)
+ADD_PREFIX(${sundials_SOURCE_DIR}/src/sundials/ shared_SOURCES)
+
+# Add variable nvecpetsc_HEADERS with the exported NVECPARHYP header files
+SET(nvecpetsc_HEADERS nvector_petsc.h)
+ADD_PREFIX(${sundials_SOURCE_DIR}/include/nvector/ nvecpetsc_HEADERS)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(.)
+INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIR})
+
+# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY 
+ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+
+# Rules for building and installing the static library:
+#  - Add the build target for the NVECPARHYP library
+#  - Set the library name and make sure it is not deleted
+#  - Install the NVECPARHYP library
+IF(BUILD_STATIC_LIBS)
+  ADD_LIBRARY(sundials_nvecpetsc_static STATIC ${nvecpetsc_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecpetsc_static
+    PROPERTIES OUTPUT_NAME sundials_nvecpetsc CLEAN_DIRECT_OUTPUT 1)
+  INSTALL(TARGETS sundials_nvecpetsc_static DESTINATION lib)
+ENDIF(BUILD_STATIC_LIBS)
+
+# Rules for building and installing the shared library:
+#  - Add the build target for the NVECPARHYP library
+#  - Set the library name and make sure it is not deleted
+#  - Set VERSION and SOVERSION for shared libraries
+#  - Install the NVECPARHYP library
+IF(BUILD_SHARED_LIBS)
+  ADD_LIBRARY(sundials_nvecpetsc_shared SHARED ${nvecpetsc_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecpetsc_shared
+    PROPERTIES OUTPUT_NAME sundials_nvecpetsc CLEAN_DIRECT_OUTPUT 1)
+  SET_TARGET_PROPERTIES(sundials_nvecpetsc_shared 
+    PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION})
+  INSTALL(TARGETS sundials_nvecpetsc_shared DESTINATION lib)
+ENDIF(BUILD_SHARED_LIBS)
+
+# Install the NVECPARHYP header files
+INSTALL(FILES ${nvecpetsc_HEADERS} DESTINATION include/nvector)
+
+#
+MESSAGE(STATUS "Added NVECTOR_PETSC module")
diff --git a/src/nvec_petsc/README b/src/nvec_petsc/README
new file mode 100644
index 0000000..36f5f8a
--- /dev/null
+++ b/src/nvec_petsc/README
@@ -0,0 +1,45 @@
+                     NVECTOR_PARALLEL
+                 released as part of SUNDIALS
+    SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
+                   Release 2.7.0, September 2016
+
+
+NVECTOR_PETSC is an NVECTOR wrapper around the PETSC vector.  
+
+NVECTOR_PETSC defines the content field of an N_Vector to be a 
+structure containing the global and local lengths of the vector, a 
+pointer to the PETSC vector, an MPI communicator, and a boolean 
+flag indicating ownership of the wrapped PETSC vector.
+
+NVECTOR_PETSC defines implementations of all vector operations defined
+by the generic NVECTOR module in the table of operations, except for 
+N_VSetArrayPointer and N_VGetArrayPointer, because accessing raw vector
+data should be handled by PETSC functions.  As such, this vector is not 
+available for use with SUNDIALS Fortran interfaces. When access to raw 
+vector data is needed, one should extract the PETSC vector first, and 
+then use PETSC methods to access the data. Usage examples of NVECTOR_PETSC
+are provided in example programs for IDA.
+
+
+A. Documentation
+----------------
+
+The NVECTOR_PETSC implementation is fully described in the user documentation
+for any of the SUNDIALS solvers. A PDF file for the user guide for a particular
+solver is available in the solver's subdirectory under doc/.
+
+
+B. Installation
+---------------
+
+For basic installation instructions see /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see any of the user guides.
+
+
+
+C. Releases
+-----------
+
+v. 2.7.0 - Sep. 2016
+
+
diff --git a/src/nvec_petsc/nvector_petsc.c b/src/nvec_petsc/nvector_petsc.c
new file mode 100644
index 0000000..1ab06da
--- /dev/null
+++ b/src/nvec_petsc/nvector_petsc.c
@@ -0,0 +1,900 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4918 $
+ * $Date: 2016-09-19 09:07:29 -0700 (Mon, 19 Sep 2016) $
+ * -----------------------------------------------------------------
+ * Programmer(s): Slaven Peles @ LLNL
+ * 
+ * Based on N_Vector_Parallel by Scott D. Cohen, Alan C. Hindmarsh, 
+ * Radu Serban, and Aaron Collier @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for a PETSc implementation
+ * of the NVECTOR package.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <nvector/nvector_petsc.h>
+#include <sundials/sundials_math.h>
+
+#define ZERO   RCONST(0.0)
+#define HALF   RCONST(0.5)
+#define ONE    RCONST(1.0)
+#define ONEPT5 RCONST(1.5)
+
+
+
+/* Error Message */
+
+
+#define BAD_N1 "N_VNewEmpty_Petsc -- Sum of local vector lengths differs from "
+#define BAD_N2 "input global length. \n\n"
+#define BAD_N   BAD_N1 BAD_N2
+
+/*
+ * -----------------------------------------------------------------
+ * Simplifying macros NV_CONTENT_PTC, NV_OWN_DATA_PTC, 
+ *                    NV_LOCLENGTH_PTC, NV_GLOBLENGTH_PTC,
+ *                    NV_COMM_PTC
+ * -----------------------------------------------------------------
+ * In the descriptions below, the following user declarations
+ * are assumed:
+ *
+ * N_Vector v;
+ * long int v_len, s_len, i;
+ *
+ * (1) NV_CONTENT_PTC
+ *
+ *     This routines gives access to the contents of the PETSc 
+ *     vector wrapper N_Vector.
+ *
+ *     The assignment v_cont = NV_CONTENT_PTC(v) sets v_cont to be
+ *     a pointer to the N_Vector (PETSc wrapper) content structure.
+ *
+ * (2) NV_PVEC_PTC, NV_OWN_DATA_PTC, NV_LOCLENGTH_PTC, NV_GLOBLENGTH_PTC,
+ *     and NV_COMM_PTC
+ *
+ *     These routines give access to the individual parts of
+ *     the content structure of a parallel N_Vector.
+ *
+ *     NV_PVEC_PTC(v) returns pointer to the PETSc vector. 
+ *
+ *     The assignment v_llen = NV_LOCLENGTH_PTC(v) sets v_llen to
+ *     be the length of the local part of the vector v. The call
+ *     NV_LOCLENGTH_PTC(v) = llen_v sets the local length
+ *     of v to be llen_v.
+ *
+ *     The assignment v_glen = NV_GLOBLENGTH_PTC(v) sets v_glen to
+ *     be the global length of the vector v. The call
+ *     NV_GLOBLENGTH_PTC(v) = glen_v sets the global length of v to
+ *     be glen_v.
+ *
+ *     The assignment v_comm = NV_COMM_PTC(v) sets v_comm to be the
+ *     MPI communicator of the vector v. The assignment
+ *     NV_COMM_PTC(v) = comm_v sets the MPI communicator of v to be
+ *     comm_v.
+ *
+ * -----------------------------------------------------------------
+ */
+
+#define NV_CONTENT_PTC(v)    ( (N_VectorContent_Petsc)(v->content) )
+
+#define NV_LOCLENGTH_PTC(v)  ( NV_CONTENT_PTC(v)->local_length )
+
+#define NV_GLOBLENGTH_PTC(v) ( NV_CONTENT_PTC(v)->global_length )
+
+#define NV_OWN_DATA_PTC(v)   ( NV_CONTENT_PTC(v)->own_data )
+
+#define NV_PVEC_PTC(v)       ( NV_CONTENT_PTC(v)->pvec )
+
+#define NV_COMM_PTC(v)       ( NV_CONTENT_PTC(v)->comm )
+
+
+/* Private function prototypes */
+
+/* Reduction operations add/max/min over the processor group */
+static realtype VAllReduce_Petsc(realtype d, int op, MPI_Comm comm);
+
+/*
+ * -----------------------------------------------------------------
+ * exported functions
+ * -----------------------------------------------------------------
+ */
+
+/* ----------------------------------------------------------------
+ * Returns vector type ID. Used to identify vector implementation 
+ * from abstract N_Vector interface.
+ */
+N_Vector_ID N_VGetVectorID_Petsc(N_Vector v)
+{
+  return SUNDIALS_NVEC_PETSC;
+}
+
+
+/* ----------------------------------------------------------------
+ * Function to create a new parallel vector with empty data array
+ */
+
+N_Vector N_VNewEmpty_Petsc(MPI_Comm comm, 
+                           long int local_length,
+                           long int global_length)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_Petsc content;
+  long int n, Nsum;
+  PetscErrorCode ierr;
+
+  /* Compute global length as sum of local lengths */
+  n = local_length;
+  ierr = MPI_Allreduce(&n, &Nsum, 1, PVEC_INTEGER_MPI_TYPE, MPI_SUM, comm);
+  CHKERRABORT(comm,ierr);
+  if (Nsum != global_length) {
+    printf(BAD_N);
+    return(NULL);
+  } 
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+  
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { free(v); return(NULL); }
+
+  ops->nvgetvectorid     = N_VGetVectorID_Petsc;
+  ops->nvclone           = N_VClone_Petsc;
+  ops->nvcloneempty      = N_VCloneEmpty_Petsc;
+  ops->nvdestroy         = N_VDestroy_Petsc;
+  ops->nvspace           = N_VSpace_Petsc;
+  ops->nvgetarraypointer = N_VGetArrayPointer_Petsc;
+  ops->nvsetarraypointer = N_VSetArrayPointer_Petsc;
+  ops->nvlinearsum       = N_VLinearSum_Petsc;
+  ops->nvconst           = N_VConst_Petsc;
+  ops->nvprod            = N_VProd_Petsc;
+  ops->nvdiv             = N_VDiv_Petsc;
+  ops->nvscale           = N_VScale_Petsc;
+  ops->nvabs             = N_VAbs_Petsc;
+  ops->nvinv             = N_VInv_Petsc;
+  ops->nvaddconst        = N_VAddConst_Petsc;
+  ops->nvdotprod         = N_VDotProd_Petsc;
+  ops->nvmaxnorm         = N_VMaxNorm_Petsc;
+  ops->nvwrmsnormmask    = N_VWrmsNormMask_Petsc;
+  ops->nvwrmsnorm        = N_VWrmsNorm_Petsc;
+  ops->nvmin             = N_VMin_Petsc;
+  ops->nvwl2norm         = N_VWL2Norm_Petsc;
+  ops->nvl1norm          = N_VL1Norm_Petsc;
+  ops->nvcompare         = N_VCompare_Petsc;
+  ops->nvinvtest         = N_VInvTest_Petsc;
+  ops->nvconstrmask      = N_VConstrMask_Petsc;
+  ops->nvminquotient     = N_VMinQuotient_Petsc;
+
+  /* Create content */
+  content = NULL;
+  content = (N_VectorContent_Petsc) malloc(sizeof(struct _N_VectorContent_Petsc));
+  if (content == NULL) { 
+    free(ops); 
+    free(v); 
+    return(NULL); 
+  }
+
+  /* Attach lengths and communicator */
+  content->local_length  = local_length;
+  content->global_length = global_length;
+  content->comm          = comm;
+  content->own_data      = FALSE;
+  content->pvec          = NULL;
+
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+
+
+/* ---------------------------------------------------------------- 
+ * Function to create a parallel N_Vector with user data component
+ * This function is NOT implemented for PETSc wrapper!
+ */
+
+N_Vector N_VMake_Petsc(Vec *pvec)
+{
+  N_Vector v = NULL;
+  MPI_Comm comm;
+  PetscInt local_length;
+  PetscInt global_length;
+
+  VecGetLocalSize(*pvec, &local_length);
+  VecGetSize(*pvec, &global_length);
+  PetscObjectGetComm((PetscObject) (*pvec), &comm);
+  
+  v = N_VNewEmpty_Petsc(comm, local_length, global_length);
+  if (v == NULL) 
+     return(NULL);
+
+  /* Attach data */
+  NV_OWN_DATA_PTC(v) = FALSE;
+  NV_PVEC_PTC(v)     = pvec;
+
+  return(v);
+}
+
+/* ---------------------------------------------------------------- 
+ * Function to create an array of new parallel vectors. 
+ */
+
+N_Vector *N_VCloneVectorArray_Petsc(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VClone_Petsc(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_Petsc(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ---------------------------------------------------------------- 
+ * Function to create an array of new parallel vectors with empty
+ * (NULL) data array.
+ */
+
+N_Vector *N_VCloneVectorArrayEmpty_Petsc(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VCloneEmpty_Petsc(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_Petsc(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ----------------------------------------------------------------
+ * Function to free an array created with N_VCloneVectorArray_Petsc
+ */
+
+void N_VDestroyVectorArray_Petsc(N_Vector *vs, int count)
+{
+  int j;
+
+  for (j = 0; j < count; j++) N_VDestroy_Petsc(vs[j]);
+
+  free(vs); 
+  vs = NULL;
+
+  return;
+}
+
+/* ---------------------------------------------------------------- 
+ * Function to extract PETSc vector 
+ */
+
+Vec *N_VGetVector_Petsc(N_Vector v)
+{
+  return NV_PVEC_PTC(v);
+}
+
+/* ---------------------------------------------------------------- 
+ * Function to print a parallel vector 
+ */
+
+void N_VPrint_Petsc(N_Vector x)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  MPI_Comm comm = NV_COMM_PTC(x);
+  
+  VecView(*xv, PETSC_VIEWER_STDOUT_(comm));
+
+  return;
+}
+
+/*
+ * -----------------------------------------------------------------
+ * implementation of vector operations
+ * -----------------------------------------------------------------
+ */
+
+N_Vector N_VCloneEmpty_Petsc(N_Vector w)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_Petsc content;
+
+  if (w == NULL) return(NULL);
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+  
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { 
+    free(v); 
+    return(NULL); 
+  }
+  
+  ops->nvgetvectorid     = w->ops->nvgetvectorid;
+  ops->nvclone           = w->ops->nvclone;
+  ops->nvcloneempty      = w->ops->nvcloneempty;
+  ops->nvdestroy         = w->ops->nvdestroy;
+  ops->nvspace           = w->ops->nvspace;
+  ops->nvgetarraypointer = w->ops->nvgetarraypointer;
+  ops->nvsetarraypointer = w->ops->nvsetarraypointer;
+  ops->nvlinearsum       = w->ops->nvlinearsum;
+  ops->nvconst           = w->ops->nvconst;  
+  ops->nvprod            = w->ops->nvprod;   
+  ops->nvdiv             = w->ops->nvdiv;
+  ops->nvscale           = w->ops->nvscale; 
+  ops->nvabs             = w->ops->nvabs;
+  ops->nvinv             = w->ops->nvinv;
+  ops->nvaddconst        = w->ops->nvaddconst;
+  ops->nvdotprod         = w->ops->nvdotprod;
+  ops->nvmaxnorm         = w->ops->nvmaxnorm;
+  ops->nvwrmsnormmask    = w->ops->nvwrmsnormmask;
+  ops->nvwrmsnorm        = w->ops->nvwrmsnorm;
+  ops->nvmin             = w->ops->nvmin;
+  ops->nvwl2norm         = w->ops->nvwl2norm;
+  ops->nvl1norm          = w->ops->nvl1norm;
+  ops->nvcompare         = w->ops->nvcompare;    
+  ops->nvinvtest         = w->ops->nvinvtest;
+  ops->nvconstrmask      = w->ops->nvconstrmask;
+  ops->nvminquotient     = w->ops->nvminquotient;
+
+  /* Create content */  
+  content = NULL;
+  content = (N_VectorContent_Petsc) malloc(sizeof(struct _N_VectorContent_Petsc));
+  if (content == NULL) { 
+    free(ops); 
+    free(v); 
+    return(NULL); 
+  }
+
+  /* Attach lengths and communicator */
+  content->local_length  = NV_LOCLENGTH_PTC(w);
+  content->global_length = NV_GLOBLENGTH_PTC(w);
+  content->comm          = NV_COMM_PTC(w);
+  content->own_data      = FALSE;
+  content->pvec          = NULL;
+
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+N_Vector N_VClone_Petsc(N_Vector w)
+{
+  N_Vector v     = NULL;
+  Vec *pvec      = NULL;
+  Vec *wvec      = NV_PVEC_PTC(w);
+  
+  /* PetscErrorCode ierr; */
+  
+  v = N_VCloneEmpty_Petsc(w);
+  if (v == NULL) 
+    return(NULL);
+
+  /* Create data */
+
+  /* Allocate empty PETSc vector */
+  pvec = (Vec*) malloc(sizeof(Vec));
+  if(pvec == NULL) {
+    N_VDestroy_Petsc(v); 
+    return(NULL);
+  }
+    
+  /* ierr = */ 
+  VecDuplicate(*wvec, pvec);
+  if(pvec == NULL) {
+    N_VDestroy_Petsc(v); 
+    return(NULL);
+  }
+    
+  /* Attach data */
+  NV_OWN_DATA_PTC(v) = TRUE;
+  NV_PVEC_PTC(v)     = pvec;
+
+  return(v);
+}
+
+void N_VDestroy_Petsc(N_Vector v)
+{
+  if (NV_OWN_DATA_PTC(v) == TRUE) {
+    VecDestroy((NV_PVEC_PTC(v)));
+    NV_PVEC_PTC(v) = NULL;
+  }
+  
+  free(v->content); 
+  v->content = NULL;
+  free(v->ops); 
+  v->ops = NULL;
+  free(v); 
+  v = NULL;
+
+  return;
+}
+
+void N_VSpace_Petsc(N_Vector v, long int *lrw, long int *liw)
+{
+  MPI_Comm comm;
+  int npes;
+
+  comm = NV_COMM_PTC(v);
+  MPI_Comm_size(comm, &npes);
+  
+  *lrw = NV_GLOBLENGTH_PTC(v);
+  *liw = 2*npes;
+
+  return;
+}
+
+/*
+ * Not implemented for PETSc wrapper.
+ */
+realtype *N_VGetArrayPointer_Petsc(N_Vector v)
+{
+  return NULL;
+}
+
+/*
+ * Not implemented for PETSc wrapper.
+ */
+void N_VSetArrayPointer_Petsc(realtype *v_data, N_Vector v)
+{
+  return;
+}
+
+void N_VLinearSum_Petsc(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *yv = NV_PVEC_PTC(y);
+  Vec *zv = NV_PVEC_PTC(z);
+  
+  if (x == y) {
+    N_VScale_Petsc(a + b, x, z); /* z <~ ax+bx */
+    return;
+  }
+
+  if (z == y) {
+    if (b == ONE) { 
+      VecAXPY(*yv, a, *xv);   /* BLAS usage: axpy  y <- ax+y */
+      return;
+    }
+    VecAXPBY(*yv, a, b, *xv); /* BLAS usage: axpby y <- ax+by */
+    return;
+  }
+
+  if (z == x) {
+    if (a == ONE) { 
+      VecAXPY(*xv, b, *yv);   /* BLAS usage: axpy  x <- by+x */
+      return;
+    }
+    VecAXPBY(*xv, b, a, *yv); /* BLAS usage: axpby x <- by+ax */
+    return;
+  }
+
+
+  /* Do all cases not handled above:
+     (1) a == other, b == 0.0 - user should have called N_VScale
+     (2) a == 0.0, b == other - user should have called N_VScale
+     (3) a,b == other, a !=b, a != -b */
+  
+  VecAXPBYPCZ(*zv, a, b, 0.0, *xv, *yv); // PETSc, probably not optimal 
+
+  return;
+}
+
+void N_VConst_Petsc(realtype c, N_Vector z)
+{
+  Vec *zv      = NV_PVEC_PTC(z);
+
+  VecSet(*zv, c);
+  
+  return;
+}
+
+void N_VProd_Petsc(N_Vector x, N_Vector y, N_Vector z)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *yv = NV_PVEC_PTC(y);
+  Vec *zv = NV_PVEC_PTC(z);
+  
+  VecPointwiseMult(*zv, *xv, *yv);
+  
+  return;
+}
+
+void N_VDiv_Petsc(N_Vector x, N_Vector y, N_Vector z)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *yv = NV_PVEC_PTC(y);
+  Vec *zv = NV_PVEC_PTC(z);
+
+  VecPointwiseDivide(*zv, *xv, *yv); /* z = x/y */
+
+  return;
+}
+
+void N_VScale_Petsc(realtype c, N_Vector x, N_Vector z)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *zv = NV_PVEC_PTC(z);
+
+  if (z == x) {       /* BLAS usage: scale x <- cx */
+    VecScale(*xv, c);
+    return;
+  }
+  
+  VecAXPBY(*zv, c, 0.0, *xv); 
+
+  return;
+}
+
+void N_VAbs_Petsc(N_Vector x, N_Vector z)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *zv = NV_PVEC_PTC(z);
+
+  if(z != x)
+    VecCopy(*xv, *zv); /* copy x~>z */
+  VecAbs(*zv); 
+  
+  return;
+}
+
+void N_VInv_Petsc(N_Vector x, N_Vector z)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *zv = NV_PVEC_PTC(z);
+
+  if(z != x)
+    VecCopy(*xv, *zv); /* copy x~>z */
+  VecReciprocal(*zv);
+
+  return;
+}
+
+void N_VAddConst_Petsc(N_Vector x, realtype b, N_Vector z)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *zv = NV_PVEC_PTC(z);
+
+  if(z != x)
+    VecCopy(*xv, *zv); /* copy x~>z */
+  VecShift(*zv, b);
+
+  return;
+}
+
+realtype N_VDotProd_Petsc(N_Vector x, N_Vector y)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *yv = NV_PVEC_PTC(y);
+  PetscScalar dotprod;
+  
+  VecDot(*xv, *yv, &dotprod);
+  
+  return dotprod;
+}
+
+realtype N_VMaxNorm_Petsc(N_Vector x)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  PetscReal norm;
+  
+  VecNorm(*xv, NORM_INFINITY, &norm);
+  
+  return norm;
+}
+
+realtype N_VWrmsNorm_Petsc(N_Vector x, N_Vector w)
+{
+  long int i;
+  long int N        = NV_LOCLENGTH_PTC(x);
+  long int N_global = NV_GLOBLENGTH_PTC(x);
+  MPI_Comm comm     = NV_COMM_PTC(x);
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *wv = NV_PVEC_PTC(w);
+  PetscScalar *xd;
+  PetscScalar *wd;
+  PetscReal sum = ZERO;
+  realtype global_sum;
+  
+  VecGetArray(*xv, &xd);
+  VecGetArray(*wv, &wd);
+  for (i = 0; i < N; i++) {
+    sum += PetscSqr(PetscAbsScalar(xd[i] * wd[i]));
+  }
+  VecRestoreArray(*xv, &xd);
+  VecRestoreArray(*wv, &wd);
+  
+  global_sum = VAllReduce_Petsc(sum, 1, comm);
+  return (SUNRsqrt(global_sum/N_global)); 
+}
+
+realtype N_VWrmsNormMask_Petsc(N_Vector x, N_Vector w, N_Vector id)
+{
+  long int i;
+  long int N        = NV_LOCLENGTH_PTC(x);
+  long int N_global = NV_GLOBLENGTH_PTC(x);
+  MPI_Comm comm     = NV_COMM_PTC(x);
+  
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *wv = NV_PVEC_PTC(w);
+  Vec *idv = NV_PVEC_PTC(id);
+  PetscScalar *xd;
+  PetscScalar *wd;
+  PetscScalar *idd;
+  PetscReal sum = ZERO;
+  realtype global_sum;
+  
+  VecGetArray(*xv, &xd);
+  VecGetArray(*wv, &wd);
+  VecGetArray(*idv, &idd);
+  for (i = 0; i < N; i++) {
+    PetscReal tag = (PetscReal) idd[i];
+    if (tag > ZERO) {
+      sum += PetscSqr(PetscAbsScalar(xd[i] * wd[i]));
+    }
+  }
+  VecRestoreArray(*xv, &xd);
+  VecRestoreArray(*wv, &wd);
+  VecRestoreArray(*idv, &idd);
+
+  global_sum = VAllReduce_Petsc(sum, 1, comm);
+  return (SUNRsqrt(global_sum/N_global)); 
+}
+
+realtype N_VMin_Petsc(N_Vector x)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  PetscReal minval;
+  PetscInt i;
+  
+  VecMin(*xv, &i, &minval);
+  
+  return minval;
+}
+
+realtype N_VWL2Norm_Petsc(N_Vector x, N_Vector w)
+{
+  long int i;
+  long int N        = NV_LOCLENGTH_PTC(x);
+  MPI_Comm comm     = NV_COMM_PTC(x);
+
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *wv = NV_PVEC_PTC(w);
+  PetscScalar *xd;
+  PetscScalar *wd;
+  PetscReal sum = ZERO;
+  realtype global_sum;
+  
+  VecGetArray(*xv, &xd);
+  VecGetArray(*wv, &wd);
+  for (i = 0; i < N; i++) {
+    sum += PetscSqr(PetscAbsScalar(xd[i] * wd[i]));
+  }
+  VecRestoreArray(*xv, &xd);
+  VecRestoreArray(*wv, &wd);
+
+  global_sum = VAllReduce_Petsc(sum, 1, comm);
+  return (SUNRsqrt(global_sum)); 
+}
+
+realtype N_VL1Norm_Petsc(N_Vector x)
+{
+  Vec *xv = NV_PVEC_PTC(x);
+  PetscReal norm;
+  
+  VecNorm(*xv, NORM_1, &norm);
+  
+  return norm;
+}
+
+void N_VCompare_Petsc(realtype c, N_Vector x, N_Vector z)
+{
+  long int i;
+  long int N = NV_LOCLENGTH_PTC(x);
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *zv = NV_PVEC_PTC(z);
+  PetscReal cpet = c; // <~ realtype should typedef to PETScReal
+  PetscScalar *xdata;
+  PetscScalar *zdata;
+
+  VecGetArray(*xv, &xdata);
+  VecGetArray(*zv, &zdata);
+  for (i = 0; i < N; i++) {
+    zdata[i] = PetscAbsScalar(xdata[i]) >= cpet ? ONE : ZERO;
+  }
+  VecRestoreArray(*xv, &xdata);
+  VecRestoreArray(*zv, &zdata);
+
+  return;
+}
+
+booleantype N_VInvTest_Petsc(N_Vector x, N_Vector z)
+{
+  long int i;
+  long int N = NV_LOCLENGTH_PTC(x);
+  MPI_Comm comm = NV_COMM_PTC(x);
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *zv = NV_PVEC_PTC(z);
+  PetscScalar *xd;
+  PetscScalar *zd;
+  PetscReal val = ONE;
+  
+  VecGetArray(*xv, &xd);
+  VecGetArray(*zv, &zd);
+  for (i = 0; i < N; i++) {
+    if (xd[i] == ZERO) 
+      val = ZERO;
+    else
+      zd[i] = ONE/xd[i];
+  }
+  VecRestoreArray(*xv, &xd);
+  VecRestoreArray(*zv, &zd);
+
+  val = VAllReduce_Petsc(val, 3, comm);
+
+  if (val == ZERO)
+    return(FALSE);
+  else
+    return(TRUE);
+}
+
+booleantype N_VConstrMask_Petsc(N_Vector c, N_Vector x, N_Vector m)
+{
+  long int i;
+  long int N = NV_LOCLENGTH_PTC(x);
+  MPI_Comm comm = NV_COMM_PTC(x);
+  realtype minval = ONE;
+  Vec *xv = NV_PVEC_PTC(x);
+  Vec *cv = NV_PVEC_PTC(c);
+  Vec *mv = NV_PVEC_PTC(m);
+  PetscScalar *xd;
+  PetscScalar *cd;
+  PetscScalar *md;
+
+  VecGetArray(*xv, &xd);
+  VecGetArray(*cv, &cd);
+  VecGetArray(*mv, &md);
+  for (i = 0; i < N; i++) {
+    PetscReal cc = (PetscReal) cd[i]; /* <~ Drop imaginary parts if any. */
+    PetscReal xx = (PetscReal) xd[i]; /* <~ Constraints defined on Re{x} */
+    md[i] = ZERO;
+    if (cc == ZERO) continue;
+    if (cc > ONEPT5 || cc < -ONEPT5) {
+      if (xx*cc <= ZERO) { minval = ZERO; md[i] = ONE; }
+      continue;
+    }
+    if (cc > HALF || cc < -HALF) {
+      if (xx*cc < ZERO ) { minval = ZERO; md[i] = ONE; }
+    }
+  }
+  VecRestoreArray(*xv, &xd);
+  VecRestoreArray(*cv, &cd);
+  VecRestoreArray(*mv, &md);
+
+  minval = VAllReduce_Petsc(minval, 3, comm);
+
+  if (minval == ONE) 
+    return(TRUE);
+  else
+    return(FALSE);
+}
+
+realtype N_VMinQuotient_Petsc(N_Vector num, N_Vector denom)
+{
+  booleantype notEvenOnce = TRUE;
+  long int i; 
+  long int N    = NV_LOCLENGTH_PTC(num);
+  MPI_Comm comm = NV_COMM_PTC(num);
+
+  Vec *nv = NV_PVEC_PTC(num);
+  Vec *dv = NV_PVEC_PTC(denom);
+  PetscScalar *nd;
+  PetscScalar *dd;
+  PetscReal minval = BIG_REAL;
+
+  VecGetArray(*nv, &nd);
+  VecGetArray(*dv, &dd);
+  for (i = 0; i < N; i++) {
+    PetscReal nr = (PetscReal) nd[i];
+    PetscReal dr = (PetscReal) dd[i];
+    if (dr == ZERO) 
+      continue;
+    else {
+      if (!notEvenOnce) 
+        minval = SUNMIN(minval, nr/dr);
+      else {
+        minval = nr/dr;
+        notEvenOnce = FALSE;
+      }
+    }
+  }
+  VecRestoreArray(*nv, &nd);
+  VecRestoreArray(*dv, &dd);
+
+  return(VAllReduce_Petsc(minval, 3, comm));
+}
+
+/*
+ * -----------------------------------------------------------------
+ * private functions
+ * -----------------------------------------------------------------
+ */
+
+static realtype VAllReduce_Petsc(realtype d, int op, MPI_Comm comm)
+{
+  /* 
+   * This function does a global reduction.  The operation is
+   *   sum if op = 1,
+   *   max if op = 2,
+   *   min if op = 3.
+   * The operation is over all processors in the communicator 
+   */
+
+  PetscErrorCode ierr;
+  realtype out;
+
+  switch (op) {
+   case 1: ierr = MPI_Allreduce(&d, &out, 1, PVEC_REAL_MPI_TYPE, MPI_SUM, comm);
+           break;
+
+   case 2: ierr = MPI_Allreduce(&d, &out, 1, PVEC_REAL_MPI_TYPE, MPI_MAX, comm);
+           break;
+
+   case 3: ierr = MPI_Allreduce(&d, &out, 1, PVEC_REAL_MPI_TYPE, MPI_MIN, comm);
+           break;
+
+   default: break;
+  }
+  CHKERRABORT(comm, ierr);
+
+  return(out);
+}
+
diff --git a/src/nvec_pthreads/CMakeLists.txt b/src/nvec_pthreads/CMakeLists.txt
new file mode 100644
index 0000000..b711d3a
--- /dev/null
+++ b/src/nvec_pthreads/CMakeLists.txt
@@ -0,0 +1,87 @@
+# ---------------------------------------------------------------
+# $Revision: 4075 $
+# $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
+# ---------------------------------------------------------------
+# Programmer:  Steve Smith @ LLNL
+# ---------------------------------------------------------------
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+# Produced at the Lawrence Livermore National Laboratory.
+# All rights reserved.
+# For details, see the LICENSE file.
+# LLNS Copyright End
+# ---------------------------------------------------------------
+# CMakeLists.txt file for the pthreads NVECTOR library
+
+INSTALL(CODE "MESSAGE(\"\nInstall NVECTOR_PTHREADS\n\")")
+
+# Add variable nvecpthreads_SOURCES with the sources for the NVECPTHREADS lib
+SET(nvecpthreads_SOURCES nvector_pthreads.c)
+
+# Add variable shared_SOURCES with the common SUNDIALS sources which will
+# also be included in the NVECPTHREADS library
+SET(shared_SOURCES sundials_math.c)
+ADD_PREFIX(${sundials_SOURCE_DIR}/src/sundials/ shared_SOURCES)
+
+# Add variable nvecpthreads_HEADERS with the exported NVECPTHREADS header files
+SET(nvecpthreads_HEADERS nvector_pthreads.h)
+ADD_PREFIX(${sundials_SOURCE_DIR}/include/nvector/ nvecpthreads_HEADERS)
+
+# Add source directory to include directories
+INCLUDE_DIRECTORIES(.)
+
+# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY 
+ADD_DEFINITIONS(-DBUILD_SUNDIALS_LIBRARY)
+
+# Rules for building and installing the static library:
+#  - Add the build target for the NVECPTHREADS library
+#  - Set the library name and make sure it is not deleted
+#  - Install the NVECPTHREADS library
+IF(BUILD_STATIC_LIBS)
+  ADD_LIBRARY(sundials_nvecpthreads_static STATIC ${nvecpthreads_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecpthreads_static
+    PROPERTIES OUTPUT_NAME sundials_nvecpthreads CLEAN_DIRECT_OUTPUT 1)
+  INSTALL(TARGETS sundials_nvecpthreads_static DESTINATION lib)
+ENDIF(BUILD_STATIC_LIBS)
+
+# Rules for building and installing the shared library:
+#  - Add the build target for the NVECPTHREADS library
+#  - Set the library name and make sure it is not deleted
+#  - Set VERSION and SOVERSION for shared libraries
+#  - Install the NVECPTHREADS library
+IF(BUILD_SHARED_LIBS)
+  ADD_LIBRARY(sundials_nvecpthreads_shared SHARED ${nvecpthreads_SOURCES} ${shared_SOURCES})
+  SET_TARGET_PROPERTIES(sundials_nvecpthreads_shared
+    PROPERTIES OUTPUT_NAME sundials_nvecpthreads CLEAN_DIRECT_OUTPUT 1)
+  SET_TARGET_PROPERTIES(sundials_nvecpthreads_shared
+    PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION})
+  INSTALL(TARGETS sundials_nvecpthreads_shared DESTINATION lib)
+ENDIF(BUILD_SHARED_LIBS)
+
+# Install the NVECPTHREADS header files
+INSTALL(FILES ${nvecpthreads_HEADERS} DESTINATION include/nvector)
+
+# If FCMIX is enabled, build and install the FNVECPTHREADS library
+IF(FCMIX_ENABLE AND F77_FOUND)
+  SET(fnvecpthreads_SOURCES fnvector_pthreads.c)
+  IF(BUILD_STATIC_LIBS)
+    ADD_LIBRARY(sundials_fnvecpthreads_static STATIC ${fnvecpthreads_SOURCES})
+    SET_TARGET_PROPERTIES(sundials_fnvecpthreads_static
+      PROPERTIES OUTPUT_NAME sundials_fnvecpthreads CLEAN_DIRECT_OUTPUT 1)
+    INSTALL(TARGETS sundials_fnvecpthreads_static DESTINATION lib)
+  ENDIF(BUILD_STATIC_LIBS)
+  IF(BUILD_SHARED_LIBS)
+    ADD_LIBRARY(sundials_fnvecpthreads_shared ${fnvecpthreads_SOURCES})
+    SET_TARGET_PROPERTIES(sundials_fnvecpthreads_shared
+      PROPERTIES OUTPUT_NAME sundials_fnvecpthreads CLEAN_DIRECT_OUTPUT 1)
+    SET_TARGET_PROPERTIES(sundials_fnvecpthreads_shared 
+      PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION})
+    INSTALL(TARGETS sundials_fnvecpthreads_shared DESTINATION lib)
+  ENDIF(BUILD_SHARED_LIBS)
+ENDIF(FCMIX_ENABLE AND F77_FOUND)
+
+#
+MESSAGE(STATUS "Added NVECTOR_PTHREADS module")
diff --git a/src/nvec_pthreads/README b/src/nvec_pthreads/README
new file mode 100644
index 0000000..23e8ca1
--- /dev/null
+++ b/src/nvec_pthreads/README
@@ -0,0 +1,47 @@
+                     NVECTOR_PTHREADS
+                 released as part of SUNDIALS
+    SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
+                   Release 2.7.0, September 2016
+
+
+Pthreads implementation of the NVECTOR module for SUNDIALS. 
+
+NVECTOR_PTHREADS defines the content field of N_Vector to be a structure 
+containing the length of the vector, a pointer to the beginning of a 
+contiguous data array, and a boolean flag indicating ownership of the 
+data array.
+
+NVECTOR_PTHREADS defines five macros to provide access to the content of 
+a Pthreads N_Vector, several constructors for variables of type N_Vector,
+a constructor for an array of variables of type N_Vector, and destructors
+for N_Vector and N_Vector array.
+
+NVECTOR_PTHREADS provides implementations for all vector operations defined
+by the generic NVECTOR module in the table of operations.
+
+
+A. Documentation
+----------------
+
+The Pthreads NVECTOR implementation follows the serial implemenation
+fully described in the user documentation for any of the SUNDIALS
+solvers [1-5]. A PDF file for the user guide for a particular solver
+is available in the solver's subdirectory under doc/.
+
+
+B. Installation
+---------------
+
+For basic installation instructions see /sundials/INSTALL_GUIDE.pdf. 
+For complete installation instructions see any of the user guides.
+
+
+C. Releases
+-----------
+
+v. 2.7.0 - Sep. 2015
+v. 2.6.2 - Aug. 2015
+v. 2.6.1 - Mar. 2015
+v. 2.6.0 - Mar. 2015
+
+
diff --git a/src/nvec_pthreads/fnvector_pthreads.c b/src/nvec_pthreads/fnvector_pthreads.c
new file mode 100644
index 0000000..cfdf938
--- /dev/null
+++ b/src/nvec_pthreads/fnvector_pthreads.c
@@ -0,0 +1,159 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4388 $
+ * $Date: 2015-02-25 15:50:00 -0800 (Wed, 25 Feb 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Steven Smith @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This file (companion of nvector_pthreads.h) contains the
+ * implementation needed for the Fortran initialization of pthreads
+ * vector operations.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "fnvector_pthreads.h"
+
+/* Define global vector variables */
+
+N_Vector F2C_CVODE_vec;
+N_Vector F2C_CVODE_vecQ;
+N_Vector *F2C_CVODE_vecS;
+N_Vector F2C_CVODE_vecB;
+N_Vector F2C_CVODE_vecQB;
+
+N_Vector F2C_IDA_vec;
+N_Vector F2C_IDA_vecQ;
+N_Vector *F2C_IDA_vecS;
+N_Vector F2C_IDA_vecB;
+N_Vector F2C_IDA_vecQB;
+
+N_Vector F2C_KINSOL_vec;
+
+N_Vector F2C_ARKODE_vec;
+
+/* Fortran callable interfaces */
+
+void FNV_INITPTS(int *code, long int *N, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vec = NULL;
+    F2C_CVODE_vec = N_VNewEmpty_Pthreads(*N, *num_threads);
+    if (F2C_CVODE_vec == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vec = NULL;
+    F2C_IDA_vec = N_VNewEmpty_Pthreads(*N, *num_threads);
+    if (F2C_IDA_vec == NULL) *ier = -1;
+    break;
+  case FCMIX_KINSOL:
+    F2C_KINSOL_vec = NULL;
+    F2C_KINSOL_vec = N_VNewEmpty_Pthreads(*N, *num_threads);
+    if (F2C_KINSOL_vec == NULL) *ier = -1;
+    break;
+  case FCMIX_ARKODE:
+    F2C_ARKODE_vec = NULL;
+    F2C_ARKODE_vec = N_VNewEmpty_Pthreads(*N, *num_threads);
+    if (F2C_ARKODE_vec == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITPTS_Q(int *code, long int *Nq, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecQ = NULL;
+    F2C_CVODE_vecQ = N_VNewEmpty_Pthreads(*Nq, *num_threads);
+    if (F2C_CVODE_vecQ == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecQ = NULL;
+    F2C_IDA_vecQ = N_VNewEmpty_Pthreads(*Nq, *num_threads);
+    if (F2C_IDA_vecQ == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITPTS_B(int *code, long int *NB, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecB = NULL;
+    F2C_CVODE_vecB = N_VNewEmpty_Pthreads(*NB, *num_threads);
+    if (F2C_CVODE_vecB == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecB = NULL;
+    F2C_IDA_vecB = N_VNewEmpty_Pthreads(*NB, *num_threads);
+    if (F2C_IDA_vecB == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITPTS_QB(int *code, long int *NqB, int *num_threads, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecQB = NULL;
+    F2C_CVODE_vecQB = N_VNewEmpty_Pthreads(*NqB, *num_threads);
+    if (F2C_CVODE_vecQB == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecQB = NULL;
+    F2C_IDA_vecQB = N_VNewEmpty_Pthreads(*NqB, *num_threads);
+    if (F2C_IDA_vecQB == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+void FNV_INITPTS_S(int *code, int *Ns, int *ier)
+{
+  *ier = 0;
+
+  switch(*code) {
+  case FCMIX_CVODE:
+    F2C_CVODE_vecS = NULL;
+    F2C_CVODE_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_Pthreads(*Ns, F2C_CVODE_vec);
+    if (F2C_CVODE_vecS == NULL) *ier = -1;
+    break;
+  case FCMIX_IDA:
+    F2C_IDA_vecS = NULL;
+    F2C_IDA_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_Pthreads(*Ns, F2C_IDA_vec);
+    if (F2C_IDA_vecS == NULL) *ier = -1;
+    break;
+  default:
+    *ier = -1;
+  }
+}
+
+
diff --git a/src/nvec_pthreads/fnvector_pthreads.h b/src/nvec_pthreads/fnvector_pthreads.h
new file mode 100644
index 0000000..52bf706
--- /dev/null
+++ b/src/nvec_pthreads/fnvector_pthreads.h
@@ -0,0 +1,95 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4388 $
+ * $Date: 2015-02-25 15:50:00 -0800 (Wed, 25 Feb 2015) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): Steven Smith @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This file (companion of nvector_pthreads.h) contains the
+ * definitions needed for the initialization of pthreads
+ * vector operations in Fortran.
+ * -----------------------------------------------------------------
+ */
+
+#ifndef _FNVECTOR_PTHREADS_H
+#define _FNVECTOR_PTHREADS_H
+
+#include <nvector/nvector_pthreads.h>
+#include <sundials/sundials_fnvector.h>
+
+#ifdef __cplusplus  /* wrapper to enable C++ usage */
+extern "C" {
+#endif
+
+#if defined(SUNDIALS_F77_FUNC)
+#define FNV_INITPTS    SUNDIALS_F77_FUNC(fnvinitpts, FNVINITPTS)
+#else
+#define FNV_INITPTS    fnvinitpts_
+#endif
+
+#if defined(SUNDIALS_F77_FUNC_)
+
+#define FNV_INITPTS_Q  SUNDIALS_F77_FUNC_(fnvinitpts_q, FNVINITPTS_Q)
+#define FNV_INITPTS_S  SUNDIALS_F77_FUNC_(fnvinitpts_s, FNVINITPTS_S)
+#define FNV_INITPTS_B  SUNDIALS_F77_FUNC_(fnvinitpts_b, FNVINITPTS_B)
+#define FNV_INITPTS_QB SUNDIALS_F77_FUNC_(fnvinitpts_qb, FNVINITPTS_QB)
+
+#else
+
+#define FNV_INITPTS_Q  fnvinitpts_q_
+#define FNV_INITPTS_S  fnvinitpts_s_
+#define FNV_INITPTS_B  fnvinitpts_b_
+#define FNV_INITPTS_QB fnvinitpts_qb_
+
+#endif
+
+/* Declarations of global variables */
+
+extern N_Vector F2C_CVODE_vec;
+extern N_Vector F2C_CVODE_vecQ;
+extern N_Vector *F2C_CVODE_vecS;
+extern N_Vector F2C_CVODE_vecB;
+extern N_Vector F2C_CVODE_vecQB;
+
+extern N_Vector F2C_IDA_vec;
+extern N_Vector F2C_IDA_vecQ;
+extern N_Vector *F2C_IDA_vecS;
+extern N_Vector F2C_IDA_vecB;
+extern N_Vector F2C_IDA_vecQB;
+
+extern N_Vector F2C_KINSOL_vec;
+
+extern N_Vector F2C_ARKODE_vec;
+
+/* 
+ * Prototypes of exported functions 
+ *
+ * FNV_INITPTS    - initializes pthreads vector operations for main problem
+ * FNV_INITPTS_Q  - initializes pthreads vector operations for quadratures
+ * FNV_INITPTS_S  - initializes pthreads vector operations for sensitivities
+ * FNV_INITPTS_B  - initializes pthreads vector operations for adjoint problem
+ * FNV_INITPTS_QB - initializes pthreads vector operations for adjoint quadratures
+ *
+ */
+
+void FNV_INITPTS(int *code, long int *neq, int *num_threads, int *ier);
+void FNV_INITPTS_Q(int *code, long int *Nq, int *num_threads, int *ier);
+void FNV_INITPTS_S(int *code, int *Ns, int *ier);
+void FNV_INITPTS_B(int *code, long int *NB, int *num_threads, int *ier);
+void FNV_INITPTS_QB(int *code, long int *NqB, int *num_threads, int *ier);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/nvec_pthreads/nvector_pthreads.c b/src/nvec_pthreads/nvector_pthreads.c
new file mode 100644
index 0000000..a2f6898
--- /dev/null
+++ b/src/nvec_pthreads/nvector_pthreads.c
@@ -0,0 +1,3204 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4869 $
+ * $Date: 2016-08-19 10:34:20 -0700 (Fri, 19 Aug 2016) $
+ * ----------------------------------------------------------------- 
+ * Programmer(s): David J. Gardner @ LLNL
+ * ----------------------------------------------------------------- 
+ * Acknowledgements: This NVECTOR module is based on the NVECTOR 
+ *                   Serial module by Scott D. Cohen, Alan C. 
+ *                   Hindmarsh, Radu Serban, and Aaron Collier 
+ *                   @ LLNL
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for a POSIX Threads (Pthreads)
+ * implementation of the NVECTOR package using a LOCAL array of 
+ * structures to pass data to threads.
+ * -----------------------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <nvector/nvector_pthreads.h>
+#include <sundials/sundials_math.h>
+#include <math.h> /* define NAN */
+
+#define ZERO   RCONST(0.0)
+#define HALF   RCONST(0.5)
+#define ONE    RCONST(1.0)
+#define ONEPT5 RCONST(1.5)
+
+/* Private function prototypes */
+/* z=x */
+static void VCopy_Pthreads(N_Vector x, N_Vector z);
+/* z=x+y */
+static void VSum_Pthreads(N_Vector x, N_Vector y, N_Vector z);
+/* z=x-y */
+static void VDiff_Pthreads(N_Vector x, N_Vector y, N_Vector z);
+/* z=-x */
+static void VNeg_Pthreads(N_Vector x, N_Vector z);
+/* z=c(x+y) */
+static void VScaleSum_Pthreads(realtype c, N_Vector x, N_Vector y, N_Vector z);
+/* z=c(x-y) */
+static void VScaleDiff_Pthreads(realtype c, N_Vector x, N_Vector y, N_Vector z); 
+/* z=ax+y */
+static void VLin1_Pthreads(realtype a, N_Vector x, N_Vector y, N_Vector z);
+/* z=ax-y */
+static void VLin2_Pthreads(realtype a, N_Vector x, N_Vector y, N_Vector z);
+/* y <- ax+y */
+static void Vaxpy_Pthreads(realtype a, N_Vector x, N_Vector y);
+/* x <- ax */
+static void VScaleBy_Pthreads(realtype a, N_Vector x);
+
+/* Pthread companion function prototypes */
+static void *N_VLinearSum_PT(void *thread_data);
+static void *N_VConst_PT(void *thread_data);
+static void *N_VProd_PT(void *thread_data);
+static void *N_VDiv_PT(void *thread_data);
+static void *N_VScale_PT(void *thread_data);
+static void *N_VAbs_PT(void *thread_data);
+static void *N_VInv_PT(void *thread_data);
+static void *N_VAddConst_PT(void *thread_data);
+static void *N_VCompare_PT(void *thread_data);
+static void *VCopy_PT(void *thread_data);
+static void *VSum_PT(void *thread_data);
+static void *VDiff_PT(void *thread_data);
+static void *VNeg_PT(void *thread_data);
+static void *VScaleSum_PT(void *thread_data);
+static void *VScaleDiff_PT(void *thread_data);
+static void *VLin1_PT(void *thread_data);
+static void *VLin2_PT(void *thread_data);
+static void *VScaleBy_PT(void *thread_data);
+static void *Vaxpy_PT(void *thread_data);
+static void *N_VDotProd_PT(void *thread_data);
+static void *N_VMaxNorm_PT(void *thread_data);
+static void *N_VWrmsNorm_PT(void *thread_data);
+static void *N_VMin_PT(void *thread_data);
+static void *N_VWL2Norm_PT(void *thread_data);
+static void *N_VL1Norm_PT(void *thread_data);
+static void *N_VInvTest_PT(void *thread_data);
+static void *N_VWrmsNormMask_PT(void *thread_data);
+static void *N_VConstrMask_PT(void *thread_data);
+static void *N_VMinQuotient_PT(void *thread_data);
+
+/* Function to determine loop values for threads */
+static void N_VSplitLoop(int myid, int *nthreads, long int *N, 
+			 long int *start, long int *end);
+
+/* Function to initialize thread data */
+static void N_VInitThreadData(Pthreads_Data *thread_data);
+
+/*
+ * -----------------------------------------------------------------
+ * exported functions
+ * -----------------------------------------------------------------
+ */
+
+/* ----------------------------------------------------------------
+ * Returns vector type ID. Used to identify vector implementation 
+ * from abstract N_Vector interface.
+ */
+N_Vector_ID N_VGetVectorID_Pthreads(N_Vector v)
+{
+  return SUNDIALS_NVEC_PTHREADS;
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create a new empty vector 
+ */
+
+N_Vector N_VNewEmpty_Pthreads(long int length, int num_threads)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_Pthreads content;
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+  
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { free(v); return(NULL); }
+
+  ops->nvgetvectorid     = N_VGetVectorID_Pthreads;
+  ops->nvclone           = N_VClone_Pthreads;
+  ops->nvcloneempty      = N_VCloneEmpty_Pthreads;
+  ops->nvdestroy         = N_VDestroy_Pthreads;
+  ops->nvspace           = N_VSpace_Pthreads;
+  ops->nvgetarraypointer = N_VGetArrayPointer_Pthreads;
+  ops->nvsetarraypointer = N_VSetArrayPointer_Pthreads;
+  ops->nvlinearsum       = N_VLinearSum_Pthreads;
+  ops->nvconst           = N_VConst_Pthreads;
+  ops->nvprod            = N_VProd_Pthreads;
+  ops->nvdiv             = N_VDiv_Pthreads;
+  ops->nvscale           = N_VScale_Pthreads;
+  ops->nvabs             = N_VAbs_Pthreads;
+  ops->nvinv             = N_VInv_Pthreads;
+  ops->nvaddconst        = N_VAddConst_Pthreads;
+  ops->nvdotprod         = N_VDotProd_Pthreads;
+  ops->nvmaxnorm         = N_VMaxNorm_Pthreads;
+  ops->nvwrmsnormmask    = N_VWrmsNormMask_Pthreads;
+  ops->nvwrmsnorm        = N_VWrmsNorm_Pthreads;
+  ops->nvmin             = N_VMin_Pthreads;
+  ops->nvwl2norm         = N_VWL2Norm_Pthreads;
+  ops->nvl1norm          = N_VL1Norm_Pthreads;
+  ops->nvcompare         = N_VCompare_Pthreads;
+  ops->nvinvtest         = N_VInvTest_Pthreads;
+  ops->nvconstrmask      = N_VConstrMask_Pthreads;
+  ops->nvminquotient     = N_VMinQuotient_Pthreads;
+
+  /* Create content */
+  content = NULL;
+  content = (N_VectorContent_Pthreads) malloc(sizeof(struct _N_VectorContent_Pthreads));
+  if (content == NULL) { free(ops); free(v); return(NULL); }
+
+  content->length      = length;
+  content->num_threads = num_threads;
+  content->own_data    = FALSE;
+  content->data        = NULL;
+
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create a new vector 
+ */
+
+N_Vector N_VNew_Pthreads(long int length, int num_threads)
+{
+  N_Vector v;
+  realtype *data;
+
+  v = NULL;
+  v = N_VNewEmpty_Pthreads(length, num_threads);
+  if (v == NULL) return(NULL);
+
+  /* Create data */
+  if (length > 0) {
+
+    /* Allocate memory */
+    data = NULL;
+    data = (realtype *) malloc(length * sizeof(realtype));
+    if(data == NULL) { N_VDestroy_Pthreads(v); return(NULL); }
+
+    /* Attach data */
+    NV_OWN_DATA_PT(v) = TRUE;
+    NV_DATA_PT(v)     = data;
+
+  }
+
+  return(v);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create a vector with user data component 
+ */
+
+N_Vector N_VMake_Pthreads(long int length, int num_threads, realtype *v_data)
+{
+  N_Vector v;
+
+  v = NULL;
+  v = N_VNewEmpty_Pthreads(length, num_threads);
+  if (v == NULL) return(NULL);
+
+  if (length > 0) {
+    /* Attach data */
+    NV_OWN_DATA_PT(v) = FALSE;
+    NV_DATA_PT(v)     = v_data;
+  }
+
+  return(v);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create an array of new vectors. 
+ */
+
+N_Vector *N_VCloneVectorArray_Pthreads(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VClone_Pthreads(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_Pthreads(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to create an array of new vectors with NULL data array. 
+ */
+
+N_Vector *N_VCloneVectorArrayEmpty_Pthreads(int count, N_Vector w)
+{
+  N_Vector *vs;
+  int j;
+
+  if (count <= 0) return(NULL);
+
+  vs = NULL;
+  vs = (N_Vector *) malloc(count * sizeof(N_Vector));
+  if(vs == NULL) return(NULL);
+
+  for (j = 0; j < count; j++) {
+    vs[j] = NULL;
+    vs[j] = N_VCloneEmpty_Pthreads(w);
+    if (vs[j] == NULL) {
+      N_VDestroyVectorArray_Pthreads(vs, j-1);
+      return(NULL);
+    }
+  }
+
+  return(vs);
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to free an array created with N_VCloneVectorArray_Pthreads
+ */
+
+void N_VDestroyVectorArray_Pthreads(N_Vector *vs, int count)
+{
+  int j;
+
+  for (j = 0; j < count; j++) N_VDestroy_Pthreads(vs[j]);
+
+  free(vs); vs = NULL;
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Function to return number of vector elements
+ */
+long int N_VGetLength_Pthreads(N_Vector v)
+{
+  return NV_LENGTH_PT(v);
+}
+
+ 
+/* ----------------------------------------------------------------------------
+ * Function to print a vector 
+ */
+ 
+void N_VPrint_Pthreads(N_Vector x)
+{
+  long int i, N;
+  realtype *xd;
+
+  xd = NULL;
+
+  N  = NV_LENGTH_PT(x);
+  xd = NV_DATA_PT(x);
+
+  for (i = 0; i < N; i++) {
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+    printf("%11.8Lg\n", xd[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+    printf("%11.8g\n", xd[i]);
+#else
+    printf("%11.8g\n", xd[i]);
+#endif
+  }
+  printf("\n");
+
+  return;
+}
+
+/*
+ * -----------------------------------------------------------------
+ * implementation of vector operations
+ * -----------------------------------------------------------------
+ */
+
+/* ----------------------------------------------------------------------------
+ * Create new vector from existing vector without attaching data
+ */
+
+N_Vector N_VCloneEmpty_Pthreads(N_Vector w)
+{
+  N_Vector v;
+  N_Vector_Ops ops;
+  N_VectorContent_Pthreads content;
+
+  if (w == NULL) return(NULL);
+
+  /* Create vector */
+  v = NULL;
+  v = (N_Vector) malloc(sizeof *v);
+  if (v == NULL) return(NULL);
+
+  /* Create vector operation structure */
+  ops = NULL;
+  ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
+  if (ops == NULL) { free(v); return(NULL); }
+  
+  ops->nvgetvectorid     = w->ops->nvgetvectorid;
+  ops->nvclone           = w->ops->nvclone;
+  ops->nvcloneempty      = w->ops->nvcloneempty;
+  ops->nvdestroy         = w->ops->nvdestroy;
+  ops->nvspace           = w->ops->nvspace;
+  ops->nvgetarraypointer = w->ops->nvgetarraypointer;
+  ops->nvsetarraypointer = w->ops->nvsetarraypointer;
+  ops->nvlinearsum       = w->ops->nvlinearsum;
+  ops->nvconst           = w->ops->nvconst;  
+  ops->nvprod            = w->ops->nvprod;   
+  ops->nvdiv             = w->ops->nvdiv;
+  ops->nvscale           = w->ops->nvscale; 
+  ops->nvabs             = w->ops->nvabs;
+  ops->nvinv             = w->ops->nvinv;
+  ops->nvaddconst        = w->ops->nvaddconst;
+  ops->nvdotprod         = w->ops->nvdotprod;
+  ops->nvmaxnorm         = w->ops->nvmaxnorm;
+  ops->nvwrmsnormmask    = w->ops->nvwrmsnormmask;
+  ops->nvwrmsnorm        = w->ops->nvwrmsnorm;
+  ops->nvmin             = w->ops->nvmin;
+  ops->nvwl2norm         = w->ops->nvwl2norm;
+  ops->nvl1norm          = w->ops->nvl1norm;
+  ops->nvcompare         = w->ops->nvcompare;    
+  ops->nvinvtest         = w->ops->nvinvtest;
+  ops->nvconstrmask      = w->ops->nvconstrmask;
+  ops->nvminquotient     = w->ops->nvminquotient;
+
+  /* Create content */
+  content = NULL;
+  content = (N_VectorContent_Pthreads) malloc(sizeof(struct _N_VectorContent_Pthreads));
+  if (content == NULL) { free(ops); free(v); return(NULL); }
+
+  content->length      = NV_LENGTH_PT(w);
+  content->num_threads = NV_NUM_THREADS_PT(w);
+  content->own_data    = FALSE;
+  content->data        = NULL;
+
+  /* Attach content and ops */
+  v->content = content;
+  v->ops     = ops;
+
+  return(v);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Create new vector from existing vector and attach data
+ */
+
+N_Vector N_VClone_Pthreads(N_Vector w)
+{
+  N_Vector v;
+  realtype *data;
+  long int length;
+
+  v = NULL;
+  v = N_VCloneEmpty_Pthreads(w);
+  if (v == NULL) return(NULL);
+
+  length = NV_LENGTH_PT(w);
+
+  /* Create data */
+  if (length > 0) {
+
+    /* Allocate memory */
+    data = NULL;
+    data = (realtype *) malloc(length * sizeof(realtype));
+    if(data == NULL) { N_VDestroy_Pthreads(v); return(NULL); }
+
+    /* Attach data */
+    NV_OWN_DATA_PT(v) = TRUE;
+    NV_DATA_PT(v)     = data;
+
+  }
+
+  return(v);
+}
+
+/* ----------------------------------------------------------------------------
+ * Destroy vector and free vector memory
+ */
+
+void N_VDestroy_Pthreads(N_Vector v)
+{
+  if (NV_OWN_DATA_PT(v) == TRUE) {
+    free(NV_DATA_PT(v));
+    NV_DATA_PT(v) = NULL;
+  }
+  free(v->content); v->content = NULL;
+  free(v->ops); v->ops = NULL;
+  free(v); v = NULL;
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Get storage requirement for vector
+ */
+
+void N_VSpace_Pthreads(N_Vector v, long int *lrw, long int *liw)
+{
+  *lrw = NV_LENGTH_PT(v);
+  *liw = 1;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Get vector data pointer
+ */
+
+realtype *N_VGetArrayPointer_Pthreads(N_Vector v)
+{
+  return((realtype *) NV_DATA_PT(v));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Set vector data pointer
+ */
+
+void N_VSetArrayPointer_Pthreads(realtype *v_data, N_Vector v)
+{
+  if (NV_LENGTH_PT(v) > 0) NV_DATA_PT(v) = v_data;
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute linear combination z[i] = a*x[i]+b*y[i]
+ */
+
+void N_VLinearSum_Pthreads(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
+{
+  realtype c;
+  N_Vector v1, v2;
+  booleantype test;
+
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+
+  pthread_attr_t attr;
+
+  if ((b == ONE) && (z == y)) {    /* BLAS usage: axpy y <- ax+y */
+    Vaxpy_Pthreads(a,x,y);
+    return;
+  }
+
+  if ((a == ONE) && (z == x)) {    /* BLAS usage: axpy x <- by+x */
+    Vaxpy_Pthreads(b,y,x);
+    return;
+  }
+
+  /* Case: a == b == 1.0 */
+
+  if ((a == ONE) && (b == ONE)) {
+    VSum_Pthreads(x, y, z);
+    return;
+  }
+
+  /* Cases: (1) a == 1.0, b = -1.0, (2) a == -1.0, b == 1.0 */
+
+  if ((test = ((a == ONE) && (b == -ONE))) || ((a == -ONE) && (b == ONE))) {
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VDiff_Pthreads(v2, v1, z);
+    return;
+  }
+
+  /* Cases: (1) a == 1.0, b == other or 0.0, (2) a == other or 0.0, b == 1.0 */
+  /* if a or b is 0.0, then user should have called N_VScale */
+
+  if ((test = (a == ONE)) || (b == ONE)) {
+    c  = test ? b : a;
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VLin1_Pthreads(c, v1, v2, z);
+    return;
+  }
+
+  /* Cases: (1) a == -1.0, b != 1.0, (2) a != 1.0, b == -1.0 */
+
+  if ((test = (a == -ONE)) || (b == -ONE)) {
+    c = test ? b : a;
+    v1 = test ? y : x;
+    v2 = test ? x : y;
+    VLin2_Pthreads(c, v1, v2, z);
+    return;
+  }
+
+  /* Case: a == b */
+  /* catches case both a and b are 0.0 - user should have called N_VConst */
+
+  if (a == b) {
+    VScaleSum_Pthreads(a, x, y, z);
+    return;
+  }
+
+  /* Case: a == -b */
+
+  if (a == -b) {
+    VScaleDiff_Pthreads(a, x, y, z);
+    return;
+  }
+
+  /* Do all cases not handled above:
+     (1) a == other, b == 0.0 - user should have called N_VScale
+     (2) a == 0.0, b == other - user should have called N_VScale
+     (3) a,b == other, a !=b, a != -b */
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = a;
+    thread_data[i].c2 = b;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VLinearSum_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VLinearSum
+ */
+
+static void *N_VLinearSum_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype a, b;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  a  = my_data->c1;  
+  b  = my_data->c2; 
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+  
+  /* compute linear sum */
+  for (i = start; i < end; i++){
+    zd[i] = (a*xd[i])+(b*yd[i]);
+  }
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Assigns constant value to all vector elements, z[i] = c
+ */
+
+void N_VConst_Pthreads(realtype c, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+
+  pthread_attr_t attr;
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(z);
+  nthreads     = NV_NUM_THREADS_PT(z);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+    
+    /* pack thread data */
+    thread_data[i].c1 = c;
+    thread_data[i].v1 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VConst_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VConst
+ */
+
+static void *N_VConst_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype c;
+  realtype *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  c  = my_data->c1;  
+  zd = my_data->v1;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* assign constant values */
+  for (i = start; i < end; i++)
+    zd[i] = c;
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise product z[i] = x[i]*y[i]
+ */
+
+void N_VProd_Pthreads(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VProd_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and exit */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VProd
+ */
+
+static void *N_VProd_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute componentwise product */
+  for (i = start; i < end; i++)
+    zd[i] = xd[i]*yd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise division z[i] = x[i]/y[i]
+ */
+
+void N_VDiv_Pthreads(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VDiv_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VDiv
+ */
+
+static void *N_VDiv_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute componentwise division */
+  for (i = start; i < end; i++)
+    zd[i] = xd[i]/yd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaler multiplication z[i] = c*x[i]
+ */
+
+void N_VScale_Pthreads(realtype c, N_Vector x, N_Vector z)
+{
+  if (z == x) {  /* BLAS usage: scale x <- cx */
+    VScaleBy_Pthreads(c, x);
+    return;
+  }
+
+  if (c == ONE) {
+    VCopy_Pthreads(x, z);
+  } 
+  else if (c == -ONE) {
+    VNeg_Pthreads(x, z);
+  } 
+  else {      
+      long int      N;
+      int           i, nthreads;
+      pthread_t     *threads;
+      Pthreads_Data *thread_data;
+      pthread_attr_t attr;
+
+      /* allocate threads and thread data structs */     
+      N            = NV_LENGTH_PT(x);
+      nthreads     = NV_NUM_THREADS_PT(x);
+      threads      = malloc(nthreads*sizeof(pthread_t));
+      thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+      
+      /* set thread attributes */
+      pthread_attr_init(&attr);
+      pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+            
+      for (i=0; i<nthreads; i++) {
+	/* initialize thread data */
+	N_VInitThreadData(&thread_data[i]);    
+
+	/* compute start and end loop index for thread */
+	N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+	
+	/* pack thread data */
+	thread_data[i].c1 = c;
+	thread_data[i].v1 = NV_DATA_PT(x);
+	thread_data[i].v2 = NV_DATA_PT(z); 
+	
+	/* create threads and call pthread companion function */
+	pthread_create(&threads[i], &attr, N_VScale_PT, (void *) &thread_data[i]);
+      }
+      
+      /* wait for all threads to finish */ 
+      for (i=0; i<nthreads; i++) {
+	pthread_join(threads[i], NULL);
+      }
+      
+      /* clean up */
+      pthread_attr_destroy(&attr);
+      free(threads);
+      free(thread_data);
+  }
+  
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VScale
+ */
+
+static void *N_VScale_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype c;
+  realtype *xd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  c  = my_data->c1;  
+  xd = my_data->v1;
+  zd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute scaler multiplication */
+  for (i = start; i < end; i++)
+    zd[i] = c*xd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute absolute value of vector components z[i] = SUNRabs(x[i])
+ */
+
+void N_VAbs_Pthreads(N_Vector x, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VAbs_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VAbs
+ */
+
+static void *N_VAbs_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  zd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute absolute value of components */
+  for (i = start; i < end; i++)
+    zd[i] = SUNRabs(xd[i]);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise inverse z[i] = 1 / x[i]
+ */
+
+void N_VInv_Pthreads(N_Vector x, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VInv_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VInv
+ */
+
+static void *N_VInv_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  zd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute componentwise inverse */
+  for (i = start; i < end; i++)
+    zd[i] = ONE/xd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise addition of a scaler to a vector z[i] = x[i] + b
+ */
+
+void N_VAddConst_Pthreads(N_Vector x, realtype b, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = b;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VAddConst_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VAddConst
+ */
+
+static void *N_VAddConst_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype b;
+  realtype *xd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  b  = my_data->c1; 
+  xd = my_data->v1;
+  zd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute componentwise constant addition */
+  for (i = start; i < end; i++)
+    zd[i] = xd[i] + b;
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes the dot product of two vectors, a = sum(x[i]*y[i])
+ */
+
+realtype N_VDotProd_Pthreads(N_Vector x, N_Vector y)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      sum = ZERO;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].global_val   = ∑
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VDotProd_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+  
+  return(sum);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VDotProd
+ */
+
+static void *N_VDotProd_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *yd;
+  realtype local_sum, *global_sum;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  yd = my_data->v2;
+  
+  global_sum   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute dot product */
+  local_sum = ZERO;
+  for (i = start; i < end; i++)
+    local_sum += xd[i] * yd[i];
+  
+  /* update global sum */
+  pthread_mutex_lock(global_mutex);
+  *global_sum += local_sum;
+  pthread_mutex_unlock(global_mutex);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes max norm of the vector 
+ */
+
+realtype N_VMaxNorm_Pthreads(N_Vector x)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      max = ZERO;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].global_val   = &max;
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VMaxNorm_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+  
+  return(max);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VMaxNorm
+ */
+
+static void *N_VMaxNorm_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd;
+  realtype local_max, *global_max;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  
+  global_max   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* find local max */
+  local_max = ZERO;
+  for (i = start; i < end; i++)
+    if (SUNRabs(xd[i]) > local_max) local_max = SUNRabs(xd[i]);
+
+  /* update global max */
+  pthread_mutex_lock(global_mutex);
+  if (local_max > *global_max) {
+    *global_max = local_max;
+  }
+  pthread_mutex_unlock(global_mutex);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes weighted root mean square norm of a vector 
+ */
+
+realtype N_VWrmsNorm_Pthreads(N_Vector x, N_Vector w)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      sum = ZERO;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(w);
+    thread_data[i].global_val   = ∑
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VWrmsNorm_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+  
+  return(SUNRsqrt(sum/N));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VWrmsNorm
+ */
+
+static void *N_VWrmsNorm_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *wd;
+  realtype local_sum, *global_sum;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  wd = my_data->v2;
+  
+  global_sum   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute wrms norm */
+  local_sum = ZERO;
+  for (i = start; i < end; i++)
+    local_sum += SUNSQR(xd[i] * wd[i]);
+
+  /* update global sum */
+  pthread_mutex_lock(global_mutex);
+  *global_sum += local_sum;
+  pthread_mutex_unlock(global_mutex);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes weighted root mean square norm of a masked vector 
+ */
+
+realtype N_VWrmsNormMask_Pthreads(N_Vector x, N_Vector w, N_Vector id)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      sum = ZERO;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(w);
+    thread_data[i].v3 = NV_DATA_PT(id);
+    thread_data[i].global_val   = ∑
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VWrmsNormMask_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+  
+  return(SUNRsqrt(sum/N));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VWrmsNormMask
+ */
+
+static void *N_VWrmsNormMask_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *wd, *idd;
+  realtype local_sum, *global_sum;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd  = my_data->v1;
+  wd  = my_data->v2;
+  idd = my_data->v3;
+  
+  global_sum   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute wrms norm with mask */
+  local_sum = ZERO;
+  for (i = start; i < end; i++) {
+    if (idd[i] > ZERO)
+      local_sum += SUNSQR(xd[i]*wd[i]);
+  }
+
+  /* update global sum */
+  pthread_mutex_lock(global_mutex);
+  *global_sum += local_sum;
+  pthread_mutex_unlock(global_mutex);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Finds the minimun component of a vector 
+ */
+
+realtype N_VMin_Pthreads(N_Vector x)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      min;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* initialize global min */
+  min = NV_Ith_PT(x,0);
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].global_val   = &min;
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VMin_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+  
+  return(min);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VMin
+ */
+
+static void *N_VMin_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd;
+  realtype local_min, *global_min;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  
+  global_min   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* find local min */
+  local_min = *global_min;
+  for (i = start; i < end; i++) {
+    if (xd[i] < local_min) 
+      local_min = xd[i];
+  }
+
+  /* update global min */
+  pthread_mutex_lock(global_mutex);
+  if (local_min < *global_min)
+    *global_min = local_min;
+  pthread_mutex_unlock(global_mutex);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes weighted L2 norm of a vector
+ */
+
+realtype N_VWL2Norm_Pthreads(N_Vector x, N_Vector w)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      sum = ZERO;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(w);
+    thread_data[i].global_val   = ∑
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VWL2Norm_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+    
+  return(SUNRsqrt(sum));
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VWL2Norm
+ */
+
+static void *N_VWL2Norm_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *wd;
+  realtype local_sum, *global_sum;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  wd = my_data->v2;
+  
+  global_sum   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute WL2 norm */
+  local_sum = ZERO;
+  for (i = start; i < end; i++)
+    local_sum += SUNSQR(xd[i]*wd[i]);
+
+  /* update global sum */
+  pthread_mutex_lock(global_mutex);
+  *global_sum += local_sum;
+  pthread_mutex_unlock(global_mutex);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Computes L1 norm of a vector
+ */
+
+realtype N_VL1Norm_Pthreads(N_Vector x)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      sum = ZERO;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].global_val   = ∑
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VL1Norm_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+  
+  return(sum);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VL1Norm
+ */
+
+static void *N_VL1Norm_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd;
+  realtype local_sum, *global_sum;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  
+  global_sum   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute L1 norm */
+  local_sum = ZERO;
+  for (i = start; i < end; i++)
+    local_sum += SUNRabs(xd[i]);
+
+  /* update global sum */
+  pthread_mutex_lock(global_mutex);
+  *global_sum += local_sum;
+  pthread_mutex_unlock(global_mutex);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compare vector component values to a scaler   
+ */
+
+void N_VCompare_Pthreads(realtype c, N_Vector x, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1  = c;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(z);
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VCompare_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VCompare
+ */
+
+static void *N_VCompare_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype c;
+  realtype *xd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  c  = my_data->c1;  
+  xd = my_data->v1;
+  zd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compare component to scaler */
+  for (i = start; i < end; i++)
+    zd[i] = (SUNRabs(xd[i]) >= c) ? ONE : ZERO;
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute componentwise inverse z[i] = ONE/x[i] and check if x[i] == ZERO
+ */
+
+booleantype N_VInvTest_Pthreads(N_Vector x, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      val = ZERO;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(z);
+    thread_data[i].global_val = &val;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VInvTest_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  if (val > ZERO)
+    return (FALSE);
+  else
+    return (TRUE);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VInvTest
+ */
+
+static void *N_VInvTest_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *zd;
+  realtype local_val, *global_val;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  zd = my_data->v2;
+  
+  global_val = my_data->global_val;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute inverse with check for divide by ZERO */
+  local_val = ZERO;
+  for (i = start; i < end; i++) {
+    if (xd[i] == ZERO) 
+      local_val = ONE;
+    else
+      zd[i] = ONE/xd[i];
+  }
+
+  /* update global val */
+  if (local_val > ZERO) {
+    *global_val = local_val;
+  }
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute constraint mask of a vector 
+ */
+
+booleantype N_VConstrMask_Pthreads(N_Vector c, N_Vector x, N_Vector m)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      val = ZERO;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(c);
+    thread_data[i].v2 = NV_DATA_PT(x);
+    thread_data[i].v3 = NV_DATA_PT(m);
+    thread_data[i].global_val = &val;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VConstrMask_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  if (val > ZERO)
+    return(FALSE);
+  else 
+    return(TRUE);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VConstrMask
+ */
+
+static void *N_VConstrMask_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *cd, *xd, *md;
+  realtype local_val, *global_val;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  cd = my_data->v1;
+  xd = my_data->v2;
+  md = my_data->v3;
+  
+  global_val = my_data->global_val;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute constraint mask */
+  local_val = ZERO;
+  for (i = start; i < end; i++) {
+    md[i] = ZERO;
+    
+    /* c[i] = 0, do nothing */
+    if (cd[i] == ZERO) 
+      continue;
+
+    /* c[i] = +/- 2, check x[i] > or < 0 */
+    if (cd[i] > ONEPT5 || cd[i] < -ONEPT5) {
+      if (xd[i]*cd[i] <= ZERO) {
+	local_val = ONE; 
+	md[i] = ONE;
+      }
+      continue;
+    }
+
+    /* c[i] = +/- 1, check x[i] >= or <= 0 */
+    if (cd[i] > HALF || cd[i] < -HALF) {
+      if (xd[i]*cd[i] < ZERO) {
+	local_val = ONE; 
+	md[i] = ONE;
+      }
+    }
+  }
+
+  /* update global val */
+  if (local_val > ZERO) {
+    *global_val = local_val;
+  }
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute minimum componentwise quotient 
+ */
+
+realtype N_VMinQuotient_Pthreads(N_Vector num, N_Vector denom)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  realtype      min = BIG_REAL;
+  pthread_attr_t attr;
+  pthread_mutex_t global_mutex;  
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(num);
+  nthreads     = NV_NUM_THREADS_PT(num);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  /* lock for reduction */
+  pthread_mutex_init(&global_mutex, NULL);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(num);
+    thread_data[i].v2 = NV_DATA_PT(denom);
+    thread_data[i].global_val   = &min;
+    thread_data[i].global_mutex = &global_mutex;
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, N_VMinQuotient_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  pthread_mutex_destroy(&global_mutex);
+  free(threads);
+  free(thread_data);
+
+  return(min);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to N_VConstrMask
+ */
+
+static void *N_VMinQuotient_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *nd, *dd;
+  realtype local_min, *global_min;
+  Pthreads_Data *my_data;
+  pthread_mutex_t *global_mutex;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  nd = my_data->v1;
+  dd = my_data->v2;
+  
+  global_min   = my_data->global_val;
+  global_mutex = my_data->global_mutex;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute minimum quotient */
+  local_min = BIG_REAL;
+  for (i = start; i < end; i++) {
+    if (dd[i] == ZERO)
+      continue;
+    local_min = SUNMIN(local_min, nd[i]/dd[i]);
+  }
+
+  /* update global min */
+  pthread_mutex_lock(global_mutex);
+  if (local_min < *global_min)
+    *global_min = local_min;
+  pthread_mutex_unlock(global_mutex);
+ 
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/*
+ * -----------------------------------------------------------------
+ * private functions
+ * -----------------------------------------------------------------
+ */
+
+
+/* ----------------------------------------------------------------------------
+ * Copy vector components into second vector   
+ */
+
+static void VCopy_Pthreads(N_Vector x, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VCopy_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VCopy
+ */
+
+static void *VCopy_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  zd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* copy vector components */
+  for (i = start; i < end; i++)
+    zd[i] = xd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector sum    
+ */
+
+static void VSum_Pthreads(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VSum_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VSum
+ */
+
+static void *VSum_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute vector sum */
+  for (i = start; i < end; i++)
+    zd[i] = xd[i] + yd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector difference   
+ */
+
+static void VDiff_Pthreads(N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VDiff_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VDiff
+ */
+
+static void *VDiff_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute vector difference */
+  for (i = start; i < end; i++)
+    zd[i] = xd[i] - yd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute the negative of a vector   
+ */
+
+static void VNeg_Pthreads(N_Vector x, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(z);
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VNeg_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VNeg
+ */
+
+static void *VNeg_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype *xd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  xd = my_data->v1;
+  zd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute negative of vector */
+  for (i = start; i < end; i++)
+    zd[i] = -xd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaled vector sum    
+ */
+
+static void VScaleSum_Pthreads(realtype c, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = c;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VScaleSum_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VScaleSum
+ */
+
+static void *VScaleSum_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype c;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  c  = my_data->c1;  
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute scaled vector sum */
+  for (i = start; i < end; i++)
+    zd[i] = c*(xd[i] + yd[i]);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaled vector difference
+ */
+
+static void VScaleDiff_Pthreads(realtype c, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = c;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VScaleDiff_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VScaleDiff
+ */
+
+static void *VScaleDiff_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype c;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  c  = my_data->c1;  
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute scaled vector difference */
+  for (i = start; i < end; i++)
+    zd[i] = c*(xd[i] - yd[i]);
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector sum z[i] = a*x[i]+y[i]    
+ */
+
+static void VLin1_Pthreads(realtype a, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = a;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VLin1_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VLin1
+ */
+
+static void *VLin1_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype a;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  a  = my_data->c1;  
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute vector sum */
+  for (i = start; i < end; i++)
+    zd[i] = (a*xd[i]) + yd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute vector difference z[i] = a*x[i]-y[i]    
+ */
+
+static void VLin2_Pthreads(realtype a, N_Vector x, N_Vector y, N_Vector z)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = a;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+    thread_data[i].v3 = NV_DATA_PT(z); 
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VLin2_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VLin2
+ */
+
+static void *VLin2_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype a;
+  realtype *xd, *yd, *zd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  a  = my_data->c1;  
+  xd = my_data->v1;
+  yd = my_data->v2;
+  zd = my_data->v3;
+
+  start = my_data->start;
+  end   = my_data->end;
+  
+  /* compute vector difference */
+  for (i = start; i < end; i++)
+    zd[i] = (a*xd[i]) - yd[i];
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute special cases of linear sum
+ */
+
+static void Vaxpy_Pthreads(realtype a, N_Vector x, N_Vector y)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = a;
+    thread_data[i].v1 = NV_DATA_PT(x);
+    thread_data[i].v2 = NV_DATA_PT(y);
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, Vaxpy_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to Vaxpy
+ */
+
+static void *Vaxpy_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype a;
+  realtype *xd, *yd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  a  = my_data->c1;  
+  xd = my_data->v1;
+  yd = my_data->v2;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute axpy */
+  if (a == ONE) {
+    for (i = start; i < end; i++)
+      yd[i] += xd[i];
+
+    /* exit */
+    pthread_exit(NULL);
+  }
+
+  if (a == -ONE) {
+    for (i = start; i < end; i++)
+      yd[i] -= xd[i];
+   
+    /* exit */
+    pthread_exit(NULL);
+  }    
+
+  for (i = start; i < end; i++)
+    yd[i] += a*xd[i];
+
+  /* return */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Compute scaled vector    
+ */
+
+static void VScaleBy_Pthreads(realtype a, N_Vector x)
+{
+  long int      N;
+  int           i, nthreads;
+  pthread_t     *threads;
+  Pthreads_Data *thread_data;
+  pthread_attr_t attr;
+
+  /* allocate threads and thread data structs */ 
+  N            = NV_LENGTH_PT(x);
+  nthreads     = NV_NUM_THREADS_PT(x);
+  threads      = malloc(nthreads*sizeof(pthread_t));
+  thread_data  = (Pthreads_Data *) malloc(nthreads*sizeof(struct _Pthreads_Data));
+
+  /* set thread attributes */
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+  for (i=0; i<nthreads; i++) {
+    /* initialize thread data */
+    N_VInitThreadData(&thread_data[i]);    
+
+    /* compute start and end loop index for thread */
+    N_VSplitLoop(i, &nthreads, &N, &thread_data[i].start, &thread_data[i].end);
+
+    /* pack thread data */
+    thread_data[i].c1 = a;
+    thread_data[i].v1 = NV_DATA_PT(x);
+
+    /* create threads and call pthread companion function */
+    pthread_create(&threads[i], &attr, VScaleBy_PT, (void *) &thread_data[i]);
+  }
+
+  /* wait for all threads to finish */ 
+  for (i=0; i<nthreads; i++) {
+    pthread_join(threads[i], NULL);
+  }
+
+  /* clean up and return */
+  pthread_attr_destroy(&attr);
+  free(threads);
+  free(thread_data);
+
+  return;
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Pthread companion function to VScaleBy
+ */
+
+static void *VScaleBy_PT(void *thread_data)
+{
+  long int i, start, end;
+  realtype a;
+  realtype *xd;
+  Pthreads_Data *my_data;
+
+  /* extract thread data */
+  my_data = (Pthreads_Data *) thread_data;
+
+  a  = my_data->c1;  
+  xd = my_data->v1;
+
+  start = my_data->start;
+  end   = my_data->end;
+
+  /* compute scaled vector */
+  for (i = start; i < end; i++)
+    xd[i] *= a;
+
+  /* exit */
+  pthread_exit(NULL);
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Determine loop indices for a thread
+ */
+
+static void N_VSplitLoop(int myid, int *nthreads, long int *N, 
+			 long int *start, long int *end)
+{
+  long int q, r; /* quotient and remainder */
+
+  /* work per thread and leftover work */
+  q = *N / *nthreads;
+  r = *N % *nthreads;
+  
+  /* assign work */
+  if (myid < r) {
+    *start = myid * q + myid;
+    *end   = *start + q + 1;
+  }
+  else {
+    *start = myid * q + r;
+    *end   = *start + q; 
+  }
+}
+
+
+/* ----------------------------------------------------------------------------
+ * Initialize values of local thread data struct
+ */
+
+static void N_VInitThreadData(Pthreads_Data *thread_data)
+{
+  thread_data->start = -1;
+  thread_data->end   = -1; 
+
+#if __STDC_VERSION__ >= 199901L
+  thread_data->c1 = NAN;
+  thread_data->c2 = NAN;
+#else
+  thread_data->c1 = ZERO;
+  thread_data->c2 = ZERO;
+#endif
+
+  thread_data->v1 = NULL;
+  thread_data->v2 = NULL;
+  thread_data->v3 = NULL;
+  thread_data->global_val = NULL;
+  thread_data->global_mutex = NULL;
+}
diff --git a/src/nvec_ser/CMakeLists.txt b/src/nvec_ser/CMakeLists.txt
index 9c97be5..de9fb12 100644
--- a/src/nvec_ser/CMakeLists.txt
+++ b/src/nvec_ser/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.3 $
-# $Date: 2009/02/17 02:58:48 $
+# $Revision: 4075 $
+# $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the serial NVECTOR library
 
diff --git a/src/nvec_ser/Makefile.in b/src/nvec_ser/Makefile.in
deleted file mode 100644
index fe8a6dc..0000000
--- a/src/nvec_ser/Makefile.in
+++ /dev/null
@@ -1,125 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.8 $
-# $Date: 2007/01/29 17:36:28 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for serial NVECTOR module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
- at SET_MAKE@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-
-INSTALL        = @INSTALL@
-INSTALL_LIB    = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-FCMIX_ENABLED = @FCMIX_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-LIB_REVISION = 0:2:0
-
-NVECSER_LIB       = libsundials_nvecserial.la
-NVECSER_LIB_FILES = nvector_serial.lo
-
-FNVECSER_LIB       = libsundials_fnvecserial.la
-FNVECSER_LIB_FILES = fnvector_serial.lo
-
-SHARED_LIB_FILES = $(top_builddir)/src/sundials/sundials_math.lo
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-all: $(NVECSER_LIB) $(FNVECSER_LIB)
-
-$(NVECSER_LIB): shared $(NVECSER_LIB_FILES)
-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) -o $(NVECSER_LIB) $(NVECSER_LIB_FILES) $(SHARED_LIB_FILES) -rpath $(libdir) $(LDFLAGS) $(LIBS) -version-info $(LIB_REVISION)
-
-$(FNVECSER_LIB): $(FNVECSER_LIB_FILES)
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                                                                                                                                       \
-	   echo "${LIBTOOL} --mode=link ${CC} ${CFLAGS} -o ${FNVECSER_LIB} ${FNVECSER_LIB_FILES} ${SHARED_LIB_FILES} -rpath ${libdir} $(LDFLAGS) ${LIBS} -version-info ${LIB_REVISION}" ; \
-	   ${LIBTOOL} --mode=link ${CC} ${CFLAGS} -o ${FNVECSER_LIB} ${FNVECSER_LIB_FILES} ${SHARED_LIB_FILES} -rpath ${libdir} $(LDFLAGS) ${LIBS} -version-info ${LIB_REVISION} ;        \
-	fi
-
-install: $(NVECSER_LIB) $(FNVECSER_LIB)
-	$(mkinstalldirs) $(includedir)/nvector
-	$(mkinstalldirs) $(libdir)
-	$(LIBTOOL) --mode=install $(INSTALL_LIB) $(NVECSER_LIB) $(libdir)
-	$(INSTALL_HEADER) $(top_srcdir)/include/nvector/nvector_serial.h $(includedir)/nvector/
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                                    \
-	   echo "${LIBTOOL} --mode=install ${INSTALL_LIB} ${FNVECSER_LIB} ${libdir}" ; \
-	   ${LIBTOOL} --mode=install ${INSTALL_LIB} ${FNVECSER_LIB} ${libdir} ;        \
-	 fi
-
-uninstall:
-	$(LIBTOOL) --mode=uninstall rm -f $(libdir)/$(NVECSER_LIB)
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                             \
-	   echo "${LIBTOOL} --mode=uninstall rm -f ${libdir}/${FNVECSER_LIB}" ; \
-	   ${LIBTOOL} --mode=uninstall rm -f ${libdir}/${FNVECSER_LIB} ;        \
-	 fi
-	rm -f $(includedir)/nvector/nvector_serial.h
-	$(rminstalldirs) ${includedir}/nvector
-
-shared:
-	@cd ${top_builddir}/src/sundials ; \
-	 ${MAKE} ;                         \
-	 cd ${abs_builddir}
-
-clean:
-	$(LIBTOOL) --mode=clean rm -f $(NVECSER_LIB)
-	rm -f $(NVECSER_LIB_FILES)
-	rm -f nvector_serial.o
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then               \
-	   echo "${LIBTOOL} --mode=clean rm -f ${FNVECSER_LIB}" ; \
-	   ${LIBTOOL} --mode=clean rm -f ${FNVECSER_LIB} ;        \
-	   echo "rm -f ${FNVECSER_LIB_FILES}" ;                   \
-	   rm -f ${FNVECSER_LIB_FILES} ;                          \
-	   echo "rm -f fnvector_serial.o" ;                       \
-	   rm -f fnvector_serial.o ;                              \
-	 fi
-
-distclean: clean
-	rm -f Makefile
-
-nvector_serial.lo: $(srcdir)/nvector_serial.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/nvector_serial.c
-fnvector_serial.lo: $(srcdir)/fnvector_serial.c
-	@if test "X${FCMIX_ENABLED}" = "Xyes"; then                                                                  \
-	   echo "${LIBTOOL} --mode=compile ${CC} ${CPPFLAGS} $(INCLUDES) ${CFLAGS} -c ${srcdir}/fnvector_serial.c" ; \
-	   ${LIBTOOL} --mode=compile ${CC} ${CPPFLAGS} $(INCLUDES) ${CFLAGS} -c ${srcdir}/fnvector_serial.c ;        \
-	 fi
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/nvec_ser/README b/src/nvec_ser/README
index ab838a6..433ccfa 100644
--- a/src/nvec_ser/README
+++ b/src/nvec_ser/README
@@ -1,5 +1,7 @@
                      NVECTOR_SERIAL
-               Release 2.5.0, March 2012
+                 released as part of SUNDIALS
+    SUite of Nonlinear and DIfferential/ALgebraic equation Solvers
+                   Release 2.7.0, September 2016
 
 
 Serial implementation of the NVECTOR module for SUNDIALS. 
@@ -29,33 +31,16 @@ particular solver is available in the solver's subdirectory under doc/.
 B. Installation
 ---------------
 
-For basic installation instructions see /sundials/INSTALL_NOTES. 
+For basic installation instructions see /sundials/INSTALL_GUIDE.pdf. 
 For complete installation instructions see any of the user guides.
 
 
-C. References
--------------
-
-[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODE v2.7.0," 
-    LLNL technical report UCRL-MA-208108, December 2011.
-
-[2] A. C. Hindmarsh and R. Serban, "User Documentation for CVODES v2.7.0," 
-    LLNL technical report UCRL-MA-208111, December 2011.
-
-[3] A. C. Hindmarsh and R. Serban, "User Documentation for IDA v2.7.0," 
-    LLNL technical report UCRL-MA-208112, December 2011.
-
-[4] R. Serban and C. Petra,  "User Documentation for IDAS v1.1.0," 
-    LLNL technical report UCRL-SM-234051, December 2011.
-
-[5] A. M. Collier, A. C. Hindmarsh, R. Serban,and C. S. Woodward, "User 
-    Documentation for KINSOL v2.7.0," LLNL technical report UCRL-MA-208116, 
-    December 2011.
-
-
 D. Releases
 -----------
-
+v. 2.7.0 - Sep. 2016
+v. 2.6.2 - Aug. 2015
+v. 2.6.1 - Mar. 2015
+v. 2.6.0 - Mar. 2015
 v. 2.5.0 - Mar. 2012
 v. 2.4.0 - May  2009
 v. 2.3.0 - Nov. 2006
@@ -68,72 +53,3 @@ v. 2.0   - Dec. 2004
 v. 1.0   - Jul. 2002 (first SUNDIALS release)
 
 
-E. Revision History
--------------------
-
-v. 2.4.0 (May 2009) ---> v. 2.5.0 (Mar. 2012)
----------------------------------------------
-
-- Bug fix:
-   - consistently updated to using SUNDIALS_F77_FUNC in fcmix header files.
-
-v. 2.3.0 (Nov. 2006) ---> v. 2.4.0 (May 2009)
----------------------------------------------
-
-- none
-
-
-v. 2.2.0 (Mar. 2006) ---> v. 2.3.0 (Nov. 2006)
-----------------------------------------------
-
-- Changes related to the build system
-   - reorganized source tree. Header files in ${srcdir}/include/nvector; 
-     sources in ${srcdir}/src/nvec_ser
-   - exported header files in ${includedir}/sundials
-
-
-v. 2.1.1 (May 2005) ---> v. 2.2.0 (Mar. 2006)
----------------------------------------------
-
-- none
-
-v. 2.1.0 (Apr. 2005) ---> v. 2.1.1 (May 2005)
----------------------------------------------
-
-- Changes to data structures
-   - added N_VCloneEmpty to global vector operations table
-
-v. 2.0.2 (Mar. 2005) ---> v. 2.1.0 (Apr. 2005)
-----------------------------------------------
-
-- none
-
-v. 2.0.1 (Jan. 2005) ---> v. 2.0.2 (Mar. 2005)
-----------------------------------------------
-
-- Changes related to the build system
-   - fixed autoconf-related bug to allow configuration with the PGI Fortran compiler
-   - modified to use customized detection of the Fortran name mangling scheme 
-     (autoconf's AC_F77_WRAPPERS routine is problematic on some platforms)
-   - added --with-mpi-flags as a configure option to allow user to specify
-     MPI-specific flags
-   - updated Makefiles for Fortran examples to avoid C++ compiler errors (now use
-     CC and MPICC to link)
-
-v. 2.0 (Dec. 2004) ---> v. 2.0.1 (Jan. 2005)
---------------------------------------------
-
-- Changes related to the build system
-   - changed order of compiler directives in header files to avoid compilation
-     errors when using a C++ compiler.
-
-v. 1.0 (Jul. 2002) ---> v. 2.0 (Dec. 2004)
-------------------------------------------
-
-- Revised to correspond to new generic NVECTOR module
-  (see sundials/shared/README).
-- Extended the list of user-callable functions provided by NVECTOR_SERIAL
-  outside the table of vector operations.
-- Revised the F/C interface to use underscore flags for name mapping
-  and to use precision flag from configure.
-- Revised F/C routine NVECTOR names for uniformity.
diff --git a/src/nvec_ser/fnvector_serial.c b/src/nvec_ser/fnvector_serial.c
index 8f83c80..bc6d949 100644
--- a/src/nvec_ser/fnvector_serial.c
+++ b/src/nvec_ser/fnvector_serial.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/07/05 15:32:37 $
+ * $Revision: 4075 $
+ * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file (companion of nvector_serial.h) contains the
  * implementation needed for the Fortran initialization of serial
@@ -37,6 +42,8 @@ N_Vector F2C_IDA_vecQB;
 
 N_Vector F2C_KINSOL_vec;
 
+N_Vector F2C_ARKODE_vec;
+
 /* Fortran callable interfaces */
 
 void FNV_INITS(int *code, long int *N, int *ier)
@@ -59,6 +66,11 @@ void FNV_INITS(int *code, long int *N, int *ier)
     F2C_KINSOL_vec = N_VNewEmpty_Serial(*N);
     if (F2C_KINSOL_vec == NULL) *ier = -1;
     break;
+  case FCMIX_ARKODE:
+    F2C_ARKODE_vec = NULL;
+    F2C_ARKODE_vec = N_VNewEmpty_Serial(*N);
+    if (F2C_ARKODE_vec == NULL) *ier = -1;
+    break;
   default:
     *ier = -1;
   }
diff --git a/src/nvec_ser/fnvector_serial.h b/src/nvec_ser/fnvector_serial.h
index 4f49b21..98e883e 100644
--- a/src/nvec_ser/fnvector_serial.h
+++ b/src/nvec_ser/fnvector_serial.h
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/15 19:40:08 $
+ * $Revision: 4378 $
+ * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This file (companion of nvector_serial.h) contains the
  * definitions needed for the initialization of serial
@@ -19,13 +24,13 @@
 #ifndef _FNVECTOR_SERIAL_H
 #define _FNVECTOR_SERIAL_H
 
+#include <nvector/nvector_serial.h>
+#include <sundials/sundials_fnvector.h>
+
 #ifdef __cplusplus  /* wrapper to enable C++ usage */
 extern "C" {
 #endif
 
-#include <nvector/nvector_serial.h>  
-#include <sundials/sundials_fnvector.h>
-
 #if defined(SUNDIALS_F77_FUNC)
 #define FNV_INITS    SUNDIALS_F77_FUNC(fnvinits, FNVINITS)
 #else
@@ -64,6 +69,8 @@ extern N_Vector F2C_IDA_vecQB;
 
 extern N_Vector F2C_KINSOL_vec;
 
+extern N_Vector F2C_ARKODE_vec;
+
 /* 
  * Prototypes of exported functions 
  *
diff --git a/src/nvec_ser/nvector_serial.c b/src/nvec_ser/nvector_serial.c
index c890253..8992480 100644
--- a/src/nvec_ser/nvector_serial.c
+++ b/src/nvec_ser/nvector_serial.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/07/05 15:32:37 $
+ * $Revision: 4867 $
+ * $Date: 2016-08-19 10:05:14 -0700 (Fri, 19 Aug 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
  *                and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a serial implementation
  * of the NVECTOR package.
@@ -55,6 +60,15 @@ static void VScaleBy_Serial(realtype a, N_Vector x);
  * -----------------------------------------------------------------
  */
 
+/* ----------------------------------------------------------------
+ * Returns vector type ID. Used to identify vector implementation 
+ * from abstract N_Vector interface.
+ */
+N_Vector_ID N_VGetVectorID_Serial(N_Vector v)
+{
+  return SUNDIALS_NVEC_SERIAL;
+}
+
 /* ----------------------------------------------------------------------------
  * Function to create a new empty serial vector 
  */
@@ -75,6 +89,7 @@ N_Vector N_VNewEmpty_Serial(long int length)
   ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
   if (ops == NULL) { free(v); return(NULL); }
 
+  ops->nvgetvectorid     = N_VGetVectorID_Serial;
   ops->nvclone           = N_VClone_Serial;
   ops->nvcloneempty      = N_VCloneEmpty_Serial;
   ops->nvdestroy         = N_VDestroy_Serial;
@@ -238,6 +253,15 @@ void N_VDestroyVectorArray_Serial(N_Vector *vs, int count)
 }
 
 /* ----------------------------------------------------------------------------
+ * Function to return number of vector elements
+ */
+long int N_VGetLength_Serial(N_Vector v)
+{
+  return NV_LENGTH_S(v);
+}
+
+ 
+/* ----------------------------------------------------------------------------
  * Function to print the a serial vector 
  */
  
@@ -253,9 +277,9 @@ void N_VPrint_Serial(N_Vector x)
 
   for (i = 0; i < N; i++) {
 #if defined(SUNDIALS_EXTENDED_PRECISION)
-    printf("%11.8Lg\n", xd[i]);
+    printf("%35.32Lg\n", xd[i]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-    printf("%11.8lg\n", xd[i]);
+    printf("%19.16g\n", xd[i]);
 #else
     printf("%11.8g\n", xd[i]);
 #endif
@@ -289,6 +313,7 @@ N_Vector N_VCloneEmpty_Serial(N_Vector w)
   ops = (N_Vector_Ops) malloc(sizeof(struct _generic_N_Vector_Ops));
   if (ops == NULL) { free(v); return(NULL); }
   
+  ops->nvgetvectorid     = w->ops->nvgetvectorid;
   ops->nvclone           = w->ops->nvclone;
   ops->nvcloneempty      = w->ops->nvcloneempty;
   ops->nvdestroy         = w->ops->nvdestroy;
@@ -570,7 +595,7 @@ void N_VAbs_Serial(N_Vector x, N_Vector z)
   zd = NV_DATA_S(z);
 
   for (i = 0; i < N; i++)
-    zd[i] = ABS(xd[i]);
+    zd[i] = SUNRabs(xd[i]);
 
   return;
 }
@@ -639,7 +664,7 @@ realtype N_VMaxNorm_Serial(N_Vector x)
   xd = NV_DATA_S(x);
 
   for (i = 0; i < N; i++) {
-    if (ABS(xd[i]) > max) max = ABS(xd[i]);
+    if (SUNRabs(xd[i]) > max) max = SUNRabs(xd[i]);
   }
 
   return(max);
@@ -659,10 +684,10 @@ realtype N_VWrmsNorm_Serial(N_Vector x, N_Vector w)
 
   for (i = 0; i < N; i++) {
     prodi = xd[i]*wd[i];
-    sum += SQR(prodi);
+    sum += SUNSQR(prodi);
   }
 
-  return(RSqrt(sum/N));
+  return(SUNRsqrt(sum/N));
 }
 
 realtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id)
@@ -681,11 +706,11 @@ realtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id)
   for (i = 0; i < N; i++) {
     if (idd[i] > ZERO) {
       prodi = xd[i]*wd[i];
-      sum += SQR(prodi);
+      sum += SUNSQR(prodi);
     }
   }
 
-  return(RSqrt(sum / N));
+  return(SUNRsqrt(sum / N));
 }
 
 realtype N_VMin_Serial(N_Vector x)
@@ -721,10 +746,10 @@ realtype N_VWL2Norm_Serial(N_Vector x, N_Vector w)
 
   for (i = 0; i < N; i++) {
     prodi = xd[i]*wd[i];
-    sum += SQR(prodi);
+    sum += SUNSQR(prodi);
   }
 
-  return(RSqrt(sum));
+  return(SUNRsqrt(sum));
 }
 
 realtype N_VL1Norm_Serial(N_Vector x)
@@ -739,7 +764,7 @@ realtype N_VL1Norm_Serial(N_Vector x)
   xd = NV_DATA_S(x);
   
   for (i = 0; i<N; i++)  
-    sum += ABS(xd[i]);
+    sum += SUNRabs(xd[i]);
 
   return(sum);
 }
@@ -756,7 +781,7 @@ void N_VCompare_Serial(realtype c, N_Vector x, N_Vector z)
   zd = NV_DATA_S(z);
 
   for (i = 0; i < N; i++) {
-    zd[i] = (ABS(xd[i]) >= c) ? ONE : ZERO;
+    zd[i] = (SUNRabs(xd[i]) >= c) ? ONE : ZERO;
   }
 
   return;
@@ -766,6 +791,7 @@ booleantype N_VInvTest_Serial(N_Vector x, N_Vector z)
 {
   long int i, N;
   realtype *xd, *zd;
+  booleantype no_zero_found;
 
   xd = zd = NULL;
 
@@ -773,12 +799,15 @@ booleantype N_VInvTest_Serial(N_Vector x, N_Vector z)
   xd = NV_DATA_S(x);
   zd = NV_DATA_S(z);
 
+  no_zero_found = TRUE;
   for (i = 0; i < N; i++) {
-    if (xd[i] == ZERO) return(FALSE);
-    zd[i] = ONE/xd[i];
+    if (xd[i] == ZERO) 
+      no_zero_found = FALSE;
+    else
+      zd[i] = ONE/xd[i];
   }
 
-  return(TRUE);
+  return no_zero_found;
 }
 
 booleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m)
@@ -829,7 +858,7 @@ realtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom)
   for (i = 0; i < N; i++) {
     if (dd[i] == ZERO) continue;
     else {
-      if (!notEvenOnce) min = MIN(min, nd[i]/dd[i]);
+      if (!notEvenOnce) min = SUNMIN(min, nd[i]/dd[i]);
       else {
 	min = nd[i]/dd[i];
         notEvenOnce = FALSE;
diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt
index 459dcdf..b01b65f 100644
--- a/src/sundials/CMakeLists.txt
+++ b/src/sundials/CMakeLists.txt
@@ -1,13 +1,18 @@
 # ---------------------------------------------------------------
-# $Revision: 1.4 $
-# $Date: 2009/02/17 02:52:53 $
+# $Revision: 4075 $
+# $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
 # ---------------------------------------------------------------
 # Programmer:  Radu Serban @ LLNL
 # ---------------------------------------------------------------
-# Copyright (c) 2007, The Regents of the University of California.
+# LLNS Copyright Start
+# Copyright (c) 2014, Lawrence Livermore National Security
+# This work was performed under the auspices of the U.S. Department 
+# of Energy by Lawrence Livermore National Laboratory in part under 
+# Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
 # Produced at the Lawrence Livermore National Laboratory.
 # All rights reserved.
 # For details, see the LICENSE file.
+# LLNS Copyright End
 # ---------------------------------------------------------------
 # CMakeLists.txt file for the generic SUNDIALS modules
 
@@ -25,7 +30,10 @@ SET(sundials_HEADERS
   sundials_math.h
   sundials_nvector.h
   sundials_fnvector.h
+  sundials_pcg.h
+  sundials_sparse.h
   sundials_spbcgs.h
+  sundials_spfgmr.h
   sundials_spgmr.h
   sundials_sptfqmr.h
   sundials_types.h
diff --git a/src/sundials/LICENSE b/src/sundials/LICENSE
new file mode 100644
index 0000000..3c9772d
--- /dev/null
+++ b/src/sundials/LICENSE
@@ -0,0 +1,67 @@
+Copyright (c) 2002-2015, Lawrence Livermore National Security. 
+Produced at the Lawrence Livermore National Laboratory.
+Written by S.D. Cohen, A.C. Hindmarsh, D.R. Reynolds, R. Serban, 
+           D. Shumaker, A.G. Taylor, and C.S. Woodward.
+LLNL-CODE-667205    (ARKODE)
+UCRL-CODE-155951    (CVODE)
+UCRL-CODE-155950    (CVODES)
+UCRL-CODE-155952    (IDA)
+UCRL-CODE-237203    (IDAS)
+LLNL-CODE-155953    (KINSOL)
+All rights reserved. 
+
+This file is part of SUNDIALS.  For details, 
+see http://computation.llnl.gov/casc/sundials/main.html
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the disclaimer below.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the disclaimer (as noted below)
+in the documentation and/or other materials provided with the
+distribution.
+
+3. Neither the name of the LLNS/LLNL nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
+LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF 
+ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Additional BSD Notice
+---------------------
+1. This notice is required to be provided under our contract with
+the U.S. Department of Energy (DOE). This work was produced at
+Lawrence Livermore National Laboratory under Contract 
+No. DE-AC52-07NA27344 with the DOE.
+
+2. Neither the United States Government nor Lawrence Livermore 
+National Security, LLC nor any of their employees, makes any warranty, 
+express or implied, or assumes any liability or responsibility for the
+accuracy, completeness, or usefulness of any information, apparatus,
+product, or process disclosed, or represents that its use would not
+infringe privately-owned rights.
+
+3. Also, reference herein to any specific commercial products, process, 
+or services by trade name, trademark, manufacturer or otherwise does 
+not necessarily constitute or imply its endorsement, recommendation, 
+or favoring by the United States Government or Lawrence Livermore 
+National Security, LLC. The views and opinions of authors expressed 
+herein do not necessarily state or reflect those of the United States 
+Government or Lawrence Livermore National Security, LLC, and shall 
+not be used for advertising or product endorsement purposes.
+
diff --git a/src/sundials/Makefile.in b/src/sundials/Makefile.in
deleted file mode 100644
index f750ba1..0000000
--- a/src/sundials/Makefile.in
+++ /dev/null
@@ -1,137 +0,0 @@
-# -----------------------------------------------------------------
-# $Revision: 1.12 $
-# $Date: 2009/02/17 02:52:53 $
-# -----------------------------------------------------------------
-# Programmer(s): Radu Serban and Aaron Collier @ LLNL
-# -----------------------------------------------------------------
-# Copyright (c) 2002, The Regents of the University of California.
-# Produced at the Lawrence Livermore National Laboratory.
-# All rights reserved.
-# For details, see the LICENSE file.
-# -----------------------------------------------------------------
-# Makefile for SHARED module
-#
-# @configure_input@
-# -----------------------------------------------------------------
-
-SHELL = @SHELL@
-
-srcdir       = @srcdir@
-builddir     = @builddir@
-abs_builddir = @abs_builddir@
-top_builddir = @top_builddir@
-prefix       = @prefix@
-exec_prefix  = @exec_prefix@
-includedir   = @includedir@
-libdir       = @libdir@
-bindir       = @bindir@
-
-INSTALL        = @INSTALL@
-INSTALL_PROG   = @INSTALL_PROGRAM@
-INSTALL_HEADER = @INSTALL_DATA@
-
-LIBTOOL      = @LIBTOOL@
-LIBTOOL_DEPS = @LIBTOOL_DEPS@
-
-CPP      = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CC       = @CC@
-CFLAGS   = @CFLAGS@
-LDFLAGS  = @LDFLAGS@
-LIBS     = @LIBS@
-
-LAPACK_ENABLED = @LAPACK_ENABLED@
-
-top_srcdir = $(srcdir)/../..
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include
-
-SHARED_SRC_FILES = sundials_direct.c sundials_band.c sundials_dense.c sundials_iterative.c sundials_math.c sundials_nvector.c sundials_spgmr.c sundials_spbcgs.c sundials_sptfqmr.c
-
-SHARED_OBJ_FILES = $(SHARED_SRC_FILES:.c=.o)
-
-SHARED_LIB_FILES = $(SHARED_SRC_FILES:.c=.lo)
-
-mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
-rminstalldirs = $(SHELL) $(top_srcdir)/config/rminstalldirs
-
-# ----------------------------------------------------------------------------------------------------------------------
-
-
-all:
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  make lib_with_bl;                          \
-	else                                         \
-	  make lib_without_bl;                       \
-	fi
-
-lib_without_bl: $(SHARED_LIB_FILES)
-
-lib_with_bl: $(SHARED_LIB_FILES)
-
-install:
-	$(mkinstalldirs)  $(includedir)/sundials
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_direct.h     $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_band.h       $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_dense.h      $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_iterative.h  $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_spgmr.h      $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_spbcgs.h     $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_sptfqmr.h    $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_math.h       $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_types.h      $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_nvector.h    $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_fnvector.h   $(includedir)/sundials/
-	$(INSTALL_HEADER) $(top_builddir)/include/sundials/sundials_config.h   $(includedir)/sundials/
-	@if test "X${LAPACK_ENABLED}" = "Xyes"; then \
-	  $(INSTALL_HEADER) $(top_srcdir)/include/sundials/sundials_lapack.h     $(includedir)/sundials/ ; \
-	fi
-
-uninstall:
-	rm -f $(includedir)/sundials/sundials_direct.h
-	rm -f $(includedir)/sundials/sundials_band.h
-	rm -f $(includedir)/sundials/sundials_dense.h
-	rm -f $(includedir)/sundials/sundials_lapack.h
-	rm -f $(includedir)/sundials/sundials_iterative.h
-	rm -f $(includedir)/sundials/sundials_spgmr.h
-	rm -f $(includedir)/sundials/sundials_spbcgs.h
-	rm -f $(includedir)/sundials/sundials_sptfqmr.h
-	rm -f $(includedir)/sundials/sundials_math.h
-	rm -f $(includedir)/sundials/sundials_types.h
-	rm -f $(includedir)/sundials/sundials_nvector.h
-	rm -f $(includedir)/sundials/sundials_fnvector.h
-	rm -f $(includedir)/sundials/sundials_config.h
-	$(rminstalldirs) $(includedir)/sundials
-
-clean:
-	rm -f $(SHARED_LIB_FILES)
-	rm -f $(SHARED_OBJ_FILES)
-	rm -rf .libs
-
-distclean: clean
-	rm -f $(top_builddir)/include/sundials/sundials_config.h
-	rm -f Makefile
-
-sundials_direct.lo: $(srcdir)/sundials_direct.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_direct.c
-sundials_band.lo: $(srcdir)/sundials_band.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_band.c
-sundials_dense.lo: $(srcdir)/sundials_dense.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_dense.c
-sundials_iterative.lo: $(srcdir)/sundials_iterative.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_iterative.c
-sundials_spgmr.lo: $(srcdir)/sundials_spgmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_spgmr.c
-sundials_spbcgs.lo: $(srcdir)/sundials_spbcgs.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_spbcgs.c
-sundials_sptfqmr.lo: $(srcdir)/sundials_sptfqmr.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_sptfqmr.c
-sundials_math.lo: $(srcdir)/sundials_math.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_math.c
-sundials_nvector.lo: $(srcdir)/sundials_nvector.c
-	$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) -c $(srcdir)/sundials_nvector.c
-
-libtool: $(top_builddir)/$(LIBTOOL_DEPS)
-	@cd ${top_builddir} ;                 \
-	 ${SHELL} ./config.status --recheck ; \
-	 cd ${abs_builddir}
diff --git a/src/sundials/README b/src/sundials/README
index 0b6bd8c..6fcb40a 100644
--- a/src/sundials/README
+++ b/src/sundials/README
@@ -1,25 +1,25 @@
                           SUNDIALS 
                         Shared Module
-                 Release 2.5.0, March 2012
+                 Release 2.7.0, Sep 2016
 
 
 The family of solvers referred to as SUNDIALS consists of solvers 
-CVODE (ODE), CVODES (ODE with sensitivity analysis capabilities),
-IDA (DAE), IDAS (DAE with sensitivity analysis capabilities), and
-KINSOL (for nonlinear algebraic systems).
+ARKODE (ODE), CVODE (ODE), CVODES (ODE with sensitivity analysis 
+capabilities), IDA (DAE), IDAS (DAE with sensitivity analysis 
+capabilities), and KINSOL (for nonlinear algebraic systems).
 
 The various solvers of this family share many subordinate modules contained
 in this module:
 - generic NVECTOR module
-- generic linear solver modules (band, dense, lapack, spgmr, bcg, tfqmr)
+- generic linear solver modules (band, dense, lapack, sparse, pcg, spfgmr, spgmr, spbcg, sptfqmr)
 - definitions of SUNDIALS types (realtype, booleantype)
-- common math functions (RpowerI, RPowerR, RSqrt, RAbs,...)
+- common math functions (RpowerI, SUNRpowerR, SUNRsqrt, SUNRabs,...)
 
 
 A. Documentation
 ----------------
 All shared submodules are fully described in the user documentation for any of 
-the SUNDIALS solvers [1-5]. A PDF file for the user guide for a particular solver
+the SUNDIALS solvers [1-6]. A PDF file for the user guide for a particular solver
 is available in the solver's subdirectory under doc/.
 
 
@@ -33,26 +33,33 @@ For complete installation instructions see any of the user guides.
 C. References
 -------------
 
-[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODE v2.7.0," 
-    LLNL technical report UCRL-MA-208108, December 2011.
+[1] A. C. Hindmarsh and R. Serban, "User Documentation for CVODE v2.8.2," 
+    LLNL technical report UCRL-MA-208108, Aug 2015.
 
-[2] A. C. Hindmarsh and R. Serban, "User Documentation for CVODES v2.7.0," 
-    LLNL technical report UCRL-MA-208111, December 2011.
+[2] A. C. Hindmarsh and R. Serban, "User Documentation for CVODES v2.8.2," 
+    LLNL technical report UCRL-MA-208111, Aug 2015.
 
-[3] A. C. Hindmarsh and R. Serban, "User Documentation for IDA v2.7.0," 
-    LLNL technical report UCRL-MA-208112, December 2011.
+[3] A. C. Hindmarsh, R. Serban,and A. Collier, "User Documentation for IDA v2.8.2," 
+    LLNL technical report UCRL-MA-208112, Aug 2015.
 
-[4] R. Serban and C. Petra,  "User Documentation for IDAS v1.1.0," 
-    LLNL technical report UCRL-SM-234051, December 2011.
+[4] R. Serban, C. Petra, and A. C. Hindmarsh  "User Documentation for IDAS v1.2.2," 
+    LLNL technical report UCRL-SM-234051, Aug 2015.
 
 [5] A. M. Collier, A. C. Hindmarsh, R. Serban,and C. S. Woodward, "User 
-    Documentation for KINSOL v2.7.0," LLNL technical report UCRL-MA-208116, 
-    December 2011.
+    Documentation for KINSOL v2.8.2," LLNL technical report UCRL-MA-208116, 
+    Aug 2015.
+
+[6] D. R. Reynolds, "User Documentation for ARKode v1.0.2," LLNL technical report
+    LLNL-SM-668082, Aug 2015.
 
 
 D. Releases
 -----------
 
+v. 2.7.0 - Sep. 2016
+v. 2.6.2 - Aug. 2015
+v. 2.6.1 - Mar. 2015
+v. 2.6.0 - Mar. 2015
 v. 2.5.0 - Mar. 2012
 v. 2.4.0 - May  2009
 v. 2.3.0 - Nov. 2006
@@ -66,150 +73,3 @@ v. 1.0   - Jul. 2002 (first SUNDIALS release)
 v. 0.0   - Mar. 2002
 
 
-E. Revision History
--------------------
-
-v. 2.4.0 (May 2009) ---> v. 2.5.0 (Mar. 2012)
----------------------------------------------
-
-- Changes to user interface
-   - One significant design change was made with this release: The problem
-     size and its relatives, bandwidth parameters, related internal indices,
-     pivot arrays, and the optional output lsflag, have all been
-     changed from type int to type long int, except for the
-     problem size and bandwidths in user calls to routines specifying
-     BLAS/LAPACK routines for the dense/band linear solvers.  The function
-     NewIntArray is replaced by a pair NewIntArray/NewLintArray,
-     for int and long int arrays, respectively.
-
-v. 2.3.0 (Nov. 2006) ---> v. 2.4.0 (May 2009)
----------------------------------------------
-
-- New features
-   - added a new generic linear solver module based on Blas + Lapack
-     for both dense and banded matrices.
-
-- Changes to user interface
-   - common functionality for all direct linear solvers (dense, band, and
-     the new Lapack solver) has been collected into the DLS (Direct Linear
-     Solver) module, implemented in the files sundials_direct.h and
-     sundials_direct.c (similar to the SPILS module for the iterative linear 
-     solvers).
-   - in order to include the new Lapack-based linear solver, all dimensions
-     for the above linear solvers (problem sizes, bandwidths,... including 
-     the underlying matrix data types) are now of type 'int' (and not 'long int').
-
-
-v. 2.2.0 (Mar. 2006) ---> v. 2.3.0 (Nov. 2006)
-----------------------------------------------
-
-- Changes to the user interface
-   - modified sundials_dense and sundials_smalldense to work with 
-     rectangular m by n matrices (m <= n). 
-
-- Changes related to the build system
-   - reorganized source tree
-   - exported header files are installed in solver-specific subdirectories
-     of ${includedir}
-   - sundialsTB is distributed only as part of the SUNDIALS tarball
-
-v. 2.1.1 (May 2005) ---> v. 2.2.0 (Mar. 2006)
----------------------------------------------
-
-- New features
-   - added SPBCG (scaled preconditioned Bi-CGStab) linear solver module
-   - added SPTFQMR (scaled preconditioned TFQMR) linear solver module
-
-- Changes related to the build system
-   - updated configure script and Makefiles for Fortran examples to avoid C++
-     compiler errors (now use CC and MPICC to link only if necessary)
-   - SUNDIALS shared header files are installed under a 'sundials' subdirectory
-     of the install include directory
-   - the shared object files are now linked into each SUNDIALS library rather
-     than into a separate libsundials_shared library
-
-- Changes to the user interface
-   - added prefix 'sundials_' to all shared header files
-
-v. 2.1.0 (Apr. 2005) ---> v. 2.1.1 (May.2005)
----------------------------------------------
-
-- Changes to data structures
-   - added N_VCloneEmpty to global vector operations table
-
-v. 2.0.2 (Mar. 2005) ---> v. 2.1.0 (Apr. 2005)
-----------------------------------------------
-
-- none
-
-v. 2.0.1 (Jan. 2005) ---> v. 2.0.2 (Mar. 2005)
-----------------------------------------------
-
-- Changes related to the build system
-   - fixed autoconf-related bug to allow configuration with the PGI Fortran compiler
-   - modified to use customized detection of the Fortran name mangling scheme 
-     (autoconf's AC_F77_WRAPPERS routine is problematic on some platforms)
-   - added --with-mpi-flags as a configure option to allow user to specify
-     MPI-specific flags
-   - updated Makefiles for Fortran examples to avoid C++ compiler errors (now use
-     CC and MPICC to link)
-
-v. 2.0 (Dec. 2004) ---> v. 2.0.1 (Jan. 2005)
---------------------------------------------
-
-- Changes related to the build system
-   - changed order of compiler directives in header files to avoid compilation
-     errors when using a C++ compiler.
-
-v. 1.0 (Jul. 2002) ---> v. 2.0 (Dec. 2004)
-------------------------------------------
-
-- Changes to the generic NVECTOR module
-   - removed machEnv, redefined table of vector operations (now contained
-     in the N_Vector structure itself).
-   - all SUNDIALS functions create new N_Vector variables through cloning, using
-     an N_Vector passed by the user as a template.
-   - a particular NVECTOR implementation is supposed to provide user-callable 
-     constructor and destructor functions.
-   - removed from structure of vector operations the following functions:
-     N_VNew, N_VNew_S, N_VFree, N_VFree_S, N_VMake, N_VDispose, N_VGetData,
-     N_VSetData, N_VConstrProdPos, and N_VOneMask.
-   - added in structure of vector operations the following functions:
-     N_VClone, N_VDestroy, N_VSpace, N_VGetArrayPointer, N_VSetArrayPointer,
-     and N_VWrmsNormMask.
-   - Note that nvec_ser and nvec_par are now separate modules outside the 
-     shared SUNDIALS module.
-
-- Changes to the generic linear solvers
-   - in SPGMR, added a dummy N_Vector argument to be used as a template
-     for cloning.
-   - in SPGMR, removed N (problem dimension) from argument list of SpgmrMalloc.
-   - iterative.{c,h} replace iterativ.{c,h}
-   - modified constant names in iterative.h (preconditioner types are prefixed
-     with 'PREC_').
-   - changed numerical values for MODIFIED_GS (from 0 to 1) and CLASSICAL_GS
-     (from 1 to 2).
-
-- Changes to sundialsmath submodule
-   - replaced internal routine for estimation of unit roundoff with definition
-     of unit roundoff from float.h
-   - modified functions to call appropriate math routines given the precision 
-     level specified by the user.
-
-- Changes to sundialstypes submodule
-   - removed type 'integertype'.
-   - added definitions for 'BIG_REAL', 'SMALL_REAL', and 'UNIT_ROUNDOFF' using
-     values from float.h based on the precision.
-   - changed definition of macro RCONST to depend on precision.
-
-v 0.0 (Mar. 2002) ---> v. 1.0 (Jul. 2002)
------------------------------------------
-
-20020321  Defined and implemented generic NVECTOR module, and separate serial/
-          parallel NVECTOR modules, including serial/parallel F/C interfaces.
-          Modified dense and band backsolve routines to take real* type for
-          RHS and solution vector.
-20020329  Named the DenseMat, BandMat, and SpgmrMemRec structures.
-20020626  Changed type names to realtype, integertype, booleantype.
-          Renamed llnltypes and llnlmath files.
-
diff --git a/src/sundials/sundials_band.c b/src/sundials/sundials_band.c
index b9286ab..7349eb7 100644
--- a/src/sundials/sundials_band.c
+++ b/src/sundials/sundials_band.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:46:56 $
+ * $Revision: 4272 $
+ * $Date: 2014-12-02 11:19:41 -0800 (Tue, 02 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Alan C. Hindmarsh and Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a generic BAND linear
  * solver package.
@@ -52,6 +57,11 @@ void BandScale(realtype c, DlsMat A)
   bandScale(c, A->cols, A->M, A->mu, A->ml, A->s_mu);
 }
 
+void BandMatvec(DlsMat A, realtype *x, realtype *y)
+{
+  bandMatvec(A->cols, x, y, A->M, A->mu, A->ml, A->s_mu);
+}
+
 /*
  * -----------------------------------------------------
  * Functions working on realtype**
@@ -85,16 +95,16 @@ long int bandGBTRF(realtype **a, long int n, long int mu, long int ml, long int
     col_k     = a[k];
     diag_k    = col_k + smu;
     sub_diag_k = diag_k + 1;
-    last_row_k = MIN(n-1,k+ml);
+    last_row_k = SUNMIN(n-1,k+ml);
 
     /* find l = pivot row number */
 
     l=k;
-    max = ABS(*diag_k);
+    max = SUNRabs(*diag_k);
     for (i=k+1, kptr=sub_diag_k; i <= last_row_k; i++, kptr++) { 
-      if (ABS(*kptr) > max) {
+      if (SUNRabs(*kptr) > max) {
 	l=i;
-	max = ABS(*kptr);
+	max = SUNRabs(*kptr);
       }
     }
     storage_l = ROW(l, k, smu);
@@ -116,18 +126,18 @@ long int bandGBTRF(realtype **a, long int n, long int mu, long int ml, long int
     /* column k by -1.0 / a(k,k). After the above swap, */
     /* a(k,k) holds the pivot element. This scaling     */
     /* stores the pivot row multipliers -a(i,k)/a(k,k)  */
-    /* in a(i,k), i=k+1, ..., MIN(n-1,k+ml).            */
+    /* in a(i,k), i=k+1, ..., SUNMIN(n-1,k+ml).            */
     
     mult = -ONE / (*diag_k);
     for (i=k+1, kptr = sub_diag_k; i <= last_row_k; i++, kptr++)
       (*kptr) *= mult;
 
-    /* row_i = row_i - [a(i,k)/a(k,k)] row_k, i=k+1, ..., MIN(n-1,k+ml) */
+    /* row_i = row_i - [a(i,k)/a(k,k)] row_k, i=k+1, ..., SUNMIN(n-1,k+ml) */
     /* row k is the pivot row after swapping with row l.                */
     /* The computation is done one column at a time,                    */
-    /* column j=k+1, ..., MIN(k+smu,n-1).                               */
+    /* column j=k+1, ..., SUNMIN(k+smu,n-1).                               */
     
-    last_col_k = MIN(k+smu,n-1);
+    last_col_k = SUNMIN(k+smu,n-1);
     for (j=k+1; j <= last_col_k; j++) {
       
       col_j = a[j];
@@ -179,7 +189,7 @@ void bandGBTRS(realtype **a, long int n, long int smu, long int ml, long int *p,
       b[k] = mult;
     }
     diag_k = a[k]+smu;
-    last_row_k = MIN(n-1,k+ml);
+    last_row_k = SUNMIN(n-1,k+ml);
     for (i=k+1; i <= last_row_k; i++)
       b[i] += mult * diag_k[i-k];
   }
@@ -188,7 +198,7 @@ void bandGBTRS(realtype **a, long int n, long int smu, long int ml, long int *p,
   
   for (k=n-1; k >= 0; k--) {
     diag_k = a[k]+smu;
-    first_row_k = MAX(0,k-smu);
+    first_row_k = SUNMAX(0,k-smu);
     b[k] /= (*diag_k);
     mult = -b[k];
     for (i=first_row_k; i <= k-1; i++)
@@ -233,3 +243,22 @@ void bandAddIdentity(realtype **a, long int n, long int smu)
   for(j=0; j < n; j++)
     a[j][smu] += ONE;
 }
+
+void bandMatvec(realtype **a, realtype *x, realtype *y, long int n, 
+		long int mu, long int ml, long int smu)
+{
+  long int i, j, is, ie;
+  realtype *col_j;
+
+  for (i=0; i<n; i++)
+    y[i] = 0.0;
+
+  for(j=0; j<n; j++) {
+    col_j = a[j]+smu-mu;
+    is = (0 > j-mu) ? 0 : j-mu;
+    ie = (n-1 < j+ml) ? n-1 : j+ml;
+    for (i=is; i<=ie; i++)
+      y[i] += col_j[i-j+mu]*x[j];
+  }
+}
+
diff --git a/src/sundials/sundials_dense.c b/src/sundials/sundials_dense.c
index 4fa3bb0..1a15a46 100644
--- a/src/sundials/sundials_dense.c
+++ b/src/sundials/sundials_dense.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.7 $
- * $Date: 2010/12/01 22:46:56 $
+ * $Revision: 4272 $
+ * $Date: 2014-12-02 11:19:41 -0800 (Tue, 02 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a generic package of dense
  * matrix operations.
@@ -72,6 +77,11 @@ void DenseScale(realtype c, DlsMat A)
   denseScale(c, A->cols, A->M, A->N);
 }
 
+void DenseMatvec(DlsMat A, realtype *x, realtype *y)
+{
+  denseMatvec(A->cols, x, y, A->M, A->N);
+}
+
 long int denseGETRF(realtype **a, long int m, long int n, long int *p)
 {
   long int i, j, k, l;
@@ -86,7 +96,7 @@ long int denseGETRF(realtype **a, long int m, long int n, long int *p)
     /* find l = pivot row number */
     l=k;
     for (i=k+1; i < m; i++)
-      if (ABS(col_k[i]) > ABS(col_k[l])) l=i;
+      if (SUNRabs(col_k[i]) > SUNRabs(col_k[l])) l=i;
     p[k] = l;
 
     /* check for zero pivot element */
@@ -193,7 +203,7 @@ long int densePOTRF(realtype **a, long int m)
 
     a_diag = a_col_j[j];
     if (a_diag <= ZERO) return(j+1);
-    a_diag = RSqrt(a_diag);
+    a_diag = SUNRsqrt(a_diag);
 
     for(i=j; i<m; i++) a_col_j[i] /= a_diag;
     
@@ -270,7 +280,7 @@ int denseGEQRF(realtype **a, long int m, long int n, realtype *beta, realtype *v
     }
 
     if(s != ZERO) {
-      mu = RSqrt(ajj*ajj+s);
+      mu = SUNRsqrt(ajj*ajj+s);
       v1 = (ajj <= ZERO) ? ajj-mu : -s/(ajj+mu);
       v1_2 = v1*v1;
       beta[j] = TWO * v1_2 / (s + v1_2);
@@ -371,3 +381,20 @@ void denseAddIdentity(realtype **a, long int n)
   
   for (i=0; i < n; i++) a[i][i] += ONE;
 }
+
+void denseMatvec(realtype **a, realtype *x, realtype *y, long int m, long int n)
+{
+  long int i, j;
+  realtype *col_j;
+
+  for (i=0; i<m; i++) {
+    y[i] = 0.0;
+  }
+
+  for (j=0; j<n; j++) {
+    col_j = a[j];
+    for (i=0; i<m; i++)
+      y[i] += col_j[i]*x[j];
+  }
+}
+
diff --git a/src/sundials/sundials_direct.c b/src/sundials/sundials_direct.c
index 67a6000..0fabca6 100644
--- a/src/sundials/sundials_direct.c
+++ b/src/sundials/sundials_direct.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.4 $
- * $Date: 2010/12/01 22:46:56 $
+ * $Revision: 4272 $
+ * $Date: 2014-12-02 11:19:41 -0800 (Tue, 02 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer: Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for operations to be used by a
  * generic direct linear solver.
@@ -314,7 +319,7 @@ void PrintMat(DlsMat A)
 #if defined(SUNDIALS_EXTENDED_PRECISION)
         printf("%12Lg  ", DENSE_ELEM(A,i,j));
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-        printf("%12lg  ", DENSE_ELEM(A,i,j));
+        printf("%12g  ", DENSE_ELEM(A,i,j));
 #else
         printf("%12g  ", DENSE_ELEM(A,i,j));
 #endif
@@ -330,14 +335,14 @@ void PrintMat(DlsMat A)
     a = A->cols;
     printf("\n");
     for (i=0; i < A->N; i++) {
-      start = MAX(0,i-A->ml);
-      finish = MIN(A->N-1,i+A->mu);
+      start = SUNMAX(0,i-A->ml);
+      finish = SUNMIN(A->N-1,i+A->mu);
       for (j=0; j < start; j++) printf("%12s  ","");
       for (j=start; j <= finish; j++) {
 #if defined(SUNDIALS_EXTENDED_PRECISION)
         printf("%12Lg  ", a[j][i-j+A->s_mu]);
 #elif defined(SUNDIALS_DOUBLE_PRECISION)
-        printf("%12lg  ", a[j][i-j+A->s_mu]);
+        printf("%12g  ", a[j][i-j+A->s_mu]);
 #else
         printf("%12g  ", a[j][i-j+A->s_mu]);
 #endif
diff --git a/src/sundials/sundials_iterative.c b/src/sundials/sundials_iterative.c
index 41ccc17..3d36106 100644
--- a/src/sundials/sundials_iterative.c
+++ b/src/sundials/sundials_iterative.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/07/05 15:32:38 $
+ * $Revision: 4272 $
+ * $Date: 2014-12-02 11:19:41 -0800 (Tue, 02 Dec 2014) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the iterative.h header
  * file. It contains the implementation of functions that may be
@@ -42,9 +47,9 @@ int ModifiedGS(N_Vector *v, realtype **h, int k, int p,
   int  i, k_minus_1, i0;
   realtype new_norm_2, new_product, vk_norm, temp;
   
-  vk_norm = RSqrt(N_VDotProd(v[k],v[k]));
+  vk_norm = SUNRsqrt(N_VDotProd(v[k],v[k]));
   k_minus_1 = k - 1;
-  i0 = MAX(k-p, 0);
+  i0 = SUNMAX(k-p, 0);
   
   /* Perform modified Gram-Schmidt */
   
@@ -55,7 +60,7 @@ int ModifiedGS(N_Vector *v, realtype **h, int k, int p,
 
   /* Compute the norm of the new vector at v[k] */
 
-  *new_vk_norm = RSqrt(N_VDotProd(v[k], v[k]));
+  *new_vk_norm = SUNRsqrt(N_VDotProd(v[k], v[k]));
 
   /* If the norm of the new vector at v[k] is less than
      FACTOR (== 1000) times unit roundoff times the norm of the
@@ -74,12 +79,12 @@ int ModifiedGS(N_Vector *v, realtype **h, int k, int p,
     if ((temp + new_product) == temp) continue;
     h[i][k_minus_1] += new_product;
     N_VLinearSum(ONE, v[k],-new_product, v[i], v[k]);
-    new_norm_2 += SQR(new_product);
+    new_norm_2 += SUNSQR(new_product);
   }
 
   if (new_norm_2 != ZERO) {
-    new_product = SQR(*new_vk_norm) - new_norm_2;
-    *new_vk_norm = (new_product > ZERO) ? RSqrt(new_product) : ZERO;
+    new_product = SUNSQR(*new_vk_norm) - new_norm_2;
+    *new_vk_norm = (new_product > ZERO) ? SUNRsqrt(new_product) : ZERO;
   }
 
   return(0);
@@ -104,9 +109,9 @@ int ClassicalGS(N_Vector *v, realtype **h, int k, int p,
   
   /* Perform Classical Gram-Schmidt */
 
-  vk_norm = RSqrt(N_VDotProd(v[k], v[k]));
+  vk_norm = SUNRsqrt(N_VDotProd(v[k], v[k]));
 
-  i0 = MAX(k-p, 0);
+  i0 = SUNMAX(k-p, 0);
   for (i=i0; i < k; i++) {
     h[i][k_minus_1] = N_VDotProd(v[i], v[k]);
   }
@@ -117,7 +122,7 @@ int ClassicalGS(N_Vector *v, realtype **h, int k, int p,
 
   /* Compute the norm of the new vector at v[k] */
 
-  *new_vk_norm = RSqrt(N_VDotProd(v[k], v[k]));
+  *new_vk_norm = SUNRsqrt(N_VDotProd(v[k], v[k]));
 
   /* Reorthogonalize if necessary */
 
@@ -137,7 +142,7 @@ int ClassicalGS(N_Vector *v, realtype **h, int k, int p,
     }
     N_VLinearSum(ONE, v[k], -ONE, temp, v[k]);
 
-    *new_vk_norm = RSqrt(N_VDotProd(v[k],v[k]));
+    *new_vk_norm = SUNRsqrt(N_VDotProd(v[k],v[k]));
   }
 
   return(0);
@@ -185,13 +190,13 @@ int QRfact(int n, realtype **h, realtype *q, int job)
       if( temp2 == ZERO) {
 	c = ONE;
 	s = ZERO;
-      } else if (ABS(temp2) >= ABS(temp1)) {
+      } else if (SUNRabs(temp2) >= SUNRabs(temp1)) {
 	temp3 = temp1/temp2;
-	s = -ONE/RSqrt(ONE+SQR(temp3));
+	s = -ONE/SUNRsqrt(ONE+SUNSQR(temp3));
 	c = -s*temp3;
       } else {
 	temp3 = temp2/temp1;
-	c = ONE/RSqrt(ONE+SQR(temp3));
+	c = ONE/SUNRsqrt(ONE+SUNSQR(temp3));
 	s = -c*temp3;
       }
       q[q_ptr] = c;
@@ -228,13 +233,13 @@ int QRfact(int n, realtype **h, realtype *q, int job)
     if (temp2 == ZERO) {
       c = ONE;
       s = ZERO;
-    } else if (ABS(temp2) >= ABS(temp1)) {
+    } else if (SUNRabs(temp2) >= SUNRabs(temp1)) {
       temp3 = temp1/temp2;
-      s = -ONE/RSqrt(ONE+SQR(temp3));
+      s = -ONE/SUNRsqrt(ONE+SUNSQR(temp3));
       c = -s*temp3;
     } else {
       temp3 = temp2/temp1;
-      c = ONE/RSqrt(ONE+SQR(temp3));
+      c = ONE/SUNRsqrt(ONE+SUNSQR(temp3));
       s = -c*temp3;
     }
     q_ptr = 2*n_minus_1;
diff --git a/src/sundials/sundials_math.c b/src/sundials/sundials_math.c
index 8bc9d59..0e9a1de 100644
--- a/src/sundials/sundials_math.c
+++ b/src/sundials/sundials_math.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.1 $
- * $Date: 2006/07/05 15:32:38 $
+ * $Revision: 4272 $
+ * $Date: 2014-12-02 11:19:41 -0800 (Tue, 02 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a simple C-language math
  * library.
@@ -25,7 +30,7 @@
 #define ZERO RCONST(0.0)
 #define ONE  RCONST(1.0)
 
-realtype RPowerI(realtype base, int exponent)
+realtype SUNRpowerI(realtype base, int exponent)
 {
   int i, expt;
   realtype prod;
@@ -37,7 +42,7 @@ realtype RPowerI(realtype base, int exponent)
   return(prod);
 }
 
-realtype RPowerR(realtype base, realtype exponent)
+realtype SUNRpowerR(realtype base, realtype exponent)
 {
   if (base <= ZERO) return(ZERO);
 
@@ -52,7 +57,7 @@ realtype RPowerR(realtype base, realtype exponent)
 #endif
 }
 
-realtype RSqrt(realtype x)
+realtype SUNRsqrt(realtype x)
 {
   if (x <= ZERO) return(ZERO);
 
@@ -67,7 +72,7 @@ realtype RSqrt(realtype x)
 #endif
 }
 
-realtype RAbs(realtype x)
+realtype SUNRabs(realtype x)
 {
 #if defined(SUNDIALS_USE_GENERIC_MATH)
   return((realtype) fabs((double) x));
@@ -80,7 +85,7 @@ realtype RAbs(realtype x)
 #endif
 }
 
-realtype RExp(realtype x)
+realtype SUNRexp(realtype x)
 {
 #if defined(SUNDIALS_USE_GENERIC_MATH)
   return((realtype) exp((double) x));
diff --git a/src/sundials/sundials_nvector.c b/src/sundials/sundials_nvector.c
index e8e1b83..75208d5 100644
--- a/src/sundials/sundials_nvector.c
+++ b/src/sundials/sundials_nvector.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2007/04/06 20:33:30 $
+ * $Revision: 4790 $
+ * $Date: 2016-06-29 14:47:05 -0700 (Wed, 29 Jun 2016) $
  * ----------------------------------------------------------------- 
  * Programmer(s): Radu Serban and Aaron Collier @ LLNL                               
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for a generic NVECTOR package.
  * It contains the implementation of the N_Vector operations listed
@@ -26,6 +31,13 @@
  * -----------------------------------------------------------------
  */
 
+N_Vector_ID N_VGetVectorID(N_Vector w)
+{
+  N_Vector_ID id;
+  id = w->ops->nvgetvectorid(w);
+  return(id);
+}
+
 N_Vector N_VClone(N_Vector w)
 {
   N_Vector v = NULL;
diff --git a/src/sundials/sundials_pcg.c b/src/sundials/sundials_pcg.c
new file mode 100644
index 0000000..1840c14
--- /dev/null
+++ b/src/sundials/sundials_pcg.c
@@ -0,0 +1,213 @@
+/*---------------------------------------------------------------
+ Programmer(s): Daniel R. Reynolds @ SMU
+ ----------------------------------------------------------------
+ Copyright (c) 2013, Southern Methodist University.
+ All rights reserved.
+ For details, see the LICENSE file.
+ ----------------------------------------------------------------
+ This is the implementation file for the preconditioned conjugate 
+ gradient solver in SUNDIALS.
+ --------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <sundials/sundials_pcg.h>
+#include <sundials/sundials_math.h>
+
+
+/*---------------------------------------------------------------
+ private constants
+ --------------------------------------------------------------*/
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+
+/*---------------------------------------------------------------
+ Function : PcgMalloc
+ --------------------------------------------------------------*/
+PcgMem PcgMalloc(int l_max, N_Vector vec_tmpl)
+{
+  PcgMem mem;
+  N_Vector r, p, z, Ap;
+
+  /* Check the input parameters */
+  if (l_max <= 0) return(NULL);
+
+  /* Create temporary arrays */
+  r = N_VClone(vec_tmpl);
+  if (r == NULL) {
+    return(NULL);
+  }
+
+  p = N_VClone(vec_tmpl);
+  if (p == NULL) {
+    N_VDestroy(r);
+    return(NULL);
+  }
+
+  z = N_VClone(vec_tmpl);
+  if (z == NULL) {
+    N_VDestroy(r);
+    N_VDestroy(p);
+    return(NULL);
+  }
+
+  Ap = N_VClone(vec_tmpl);
+  if (Ap == NULL) {
+    N_VDestroy(r);
+    N_VDestroy(p);
+    N_VDestroy(z);
+    return(NULL);
+  }
+
+  /* Get memory for an PcgMemRec containing PCG vectors */
+  mem = NULL;
+  mem = (PcgMem) malloc(sizeof(PcgMemRec));
+  if (mem == NULL) {
+    N_VDestroy(r);
+    N_VDestroy(p);
+    N_VDestroy(z);
+    N_VDestroy(Ap);
+    return(NULL);
+  }
+
+  /* Set the structure fields */
+  mem->l_max = l_max;
+  mem->r     = r;
+  mem->p     = p;
+  mem->z     = z;
+  mem->Ap    = Ap;
+
+  /* Return the pointer to PCG memory */
+  return(mem);
+}
+
+
+/*---------------------------------------------------------------
+ Function : PcgSolve
+ --------------------------------------------------------------*/
+int PcgSolve(PcgMem mem, void *A_data, N_Vector x, N_Vector b,
+	     int pretype, realtype delta, void *P_data,
+	     N_Vector w, ATimesFn atimes, PSolveFn psolve,
+	     realtype *res_norm, int *nli, int *nps)
+{
+  realtype alpha, beta, r0_norm, rho, rz, rz_old;
+  N_Vector r, p, z, Ap;
+  booleantype UsePrec, converged;
+  int l, l_max, ier;
+
+  if (mem == NULL)  return(PCG_MEM_NULL);
+
+  /* Make local copies of mem variables */
+  l_max  = mem->l_max;
+  r      = mem->r;
+  p      = mem->p;
+  z      = mem->z;
+  Ap     = mem->Ap;
+
+  /* Initialize counters and converged flag */
+  *nli = *nps = 0;
+  converged = FALSE;
+
+  /* Set preconditioning flag */
+  UsePrec = ((pretype == PREC_BOTH) || (pretype == PREC_LEFT) || (pretype == PREC_RIGHT));
+
+  /* Set r to initial residual r_0 = b - A*x_0 */
+  if (N_VDotProd(x, x) == ZERO)  N_VScale(ONE, b, r);
+  else {
+    ier = atimes(A_data, x, r);
+    if (ier != 0)
+      return((ier < 0) ? PCG_ATIMES_FAIL_UNREC : PCG_ATIMES_FAIL_REC);
+    N_VLinearSum(ONE, b, -ONE, r, r);
+  }
+
+  /* Set rho to L2 norm of r, and return if small */
+  *res_norm = r0_norm = rho = N_VWrmsNorm(r,w);
+  if (rho <= delta) return(PCG_SUCCESS);
+
+  /* Apply preconditioner and b-scaling to r = r_0 */
+  if (UsePrec) {
+    ier = psolve(P_data, r, z, PREC_LEFT);   /* z = P^{-1}r */
+    (*nps)++;
+    if (ier != 0) return((ier < 0) ? PCG_PSOLVE_FAIL_UNREC : PCG_PSOLVE_FAIL_REC);
+  }
+  else N_VScale(ONE, r, z);
+
+  /* Initialize rz to <r,z> */
+  rz = N_VDotProd(r, z);
+
+  /* Copy z to p */
+  N_VScale(ONE, z, p);
+
+  /* Begin main iteration loop */
+  for(l=0; l<l_max; l++) {
+
+    /* increment counter */
+    (*nli)++;
+
+    /* Generate Ap = A*p */
+    ier = atimes(A_data, p, Ap );
+    if (ier != 0)
+      return((ier < 0) ? PCG_ATIMES_FAIL_UNREC : PCG_ATIMES_FAIL_REC);
+
+    /* Calculate alpha = <r,z> / <Ap,p> */
+    alpha = rz / N_VDotProd(Ap, p);
+
+    /* Update x = x + alpha*p */
+    N_VLinearSum(ONE, x, alpha, p, x);
+
+    /* Update r = r - alpha*Ap */
+    N_VLinearSum(ONE, r, -alpha, Ap, r);
+
+    /* Set rho and check convergence */
+    *res_norm = rho = N_VWrmsNorm(r, w);
+    if (rho <= delta) {
+      converged = TRUE;
+      break;
+    }
+
+    /* Apply preconditioner:  z = P^{-1}*r */
+    if (UsePrec) {
+      ier = psolve(P_data, r, z, PREC_LEFT);
+      (*nps)++;
+      if (ier != 0) return((ier < 0) ? PCG_PSOLVE_FAIL_UNREC : PCG_PSOLVE_FAIL_REC);
+    }
+    else N_VScale(ONE, r, z);
+
+    /* update rz */
+    rz_old = rz;
+    rz = N_VDotProd(r, z);
+    
+    /* Calculate beta = <r,z> / <r_old,z_old> */
+    beta = rz / rz_old;
+
+    /* Update p = z + beta*p */
+    N_VLinearSum(ONE, z, beta, p, p);
+
+  }
+
+  /* Main loop finished, return with result */
+  if (converged == TRUE)  return(PCG_SUCCESS);
+  if (rho < r0_norm)      return(PCG_RES_REDUCED);
+  return(PCG_CONV_FAIL);
+}
+
+
+/*---------------------------------------------------------------
+ Function : PcgFree
+ --------------------------------------------------------------*/
+void PcgFree(PcgMem mem)
+{
+  if (mem == NULL) return;
+
+  N_VDestroy(mem->r);
+  N_VDestroy(mem->p);
+  N_VDestroy(mem->z);
+  N_VDestroy(mem->Ap);
+
+  free(mem); mem = NULL;
+}
+
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/sundials/sundials_sparse.c b/src/sundials/sundials_sparse.c
new file mode 100644
index 0000000..a63f505
--- /dev/null
+++ b/src/sundials/sundials_sparse.c
@@ -0,0 +1,870 @@
+/*
+ * -----------------------------------------------------------------
+ * $Revision: 4761 $
+ * $Date: 2016-05-18 20:00:35 -0700 (Wed, 18 May 2016) $
+ * -----------------------------------------------------------------
+ * Programmers: Carol Woodward, Slaven Peles @ LLNL
+ *              Daniel R. Reynolds @ SMU
+ * -----------------------------------------------------------------
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
+ * Produced at the Lawrence Livermore National Laboratory.
+ * All rights reserved.
+ * For details, see the LICENSE file.
+ * LLNS Copyright End
+ * -----------------------------------------------------------------
+ * This is the implementation file for operations on the SUNDIALS
+ * sparse matrix structure.
+ * -----------------------------------------------------------------
+ */ 
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sundials/sundials_sparse.h>
+#include <sundials/sundials_math.h>
+
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/*
+ * ==================================================================
+ * Private function prototypes (functions working on SlsMat)
+ * ==================================================================
+ */
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseMatvecCSC
+ * -----------------------------------------------------------------
+ * This function computes the matrix-vector product, y=A*x, where A
+ * is a CSC sparse matrix of dimension MxN, x is a realtype array of 
+ * length N, and y is a realtype array of length M. Upon successful
+ * completion, the return value is zero; otherwise 1 is returned.
+ * -----------------------------------------------------------------
+ */
+
+static int SparseMatvecCSC(const SlsMat A, const realtype *x, realtype *y);
+
+/*
+ * -----------------------------------------------------------------
+ * Functions: SparseMatvecCSR
+ * -----------------------------------------------------------------
+ * This function computes the matrix-vector product, y=A*x, where A
+ * is a CSR sparse matrix of dimension MxN, x is a realtype array of 
+ * length N, and y is a realtype array of length M. Upon successful
+ * completion, the return value is zero; otherwise 1 is returned.
+ * -----------------------------------------------------------------
+ */
+
+static int SparseMatvecCSR(const SlsMat A, const realtype *x, realtype *y);
+
+
+
+/*
+ * ==================================================================
+ * Implementation of sparse matrix methods (functions on SlsMat)
+ * ==================================================================
+ */
+
+/* 
+ * Default Constructor
+ * 
+ * Creates a new (empty) sparse matrix of a desired size and nonzero density.
+ * Returns NULL if a memory allocation error occurred.
+ * 
+ */
+SlsMat SparseNewMat(int M, int N, int NNZ, int sparsetype)
+{
+  SlsMat A;
+
+  if ( (M <= 0) || (N <= 0) ) return(NULL);
+
+  A = NULL;
+  A = (SlsMat) malloc(sizeof(struct _SlsMat));
+  if (A==NULL) return (NULL);
+  
+  A->sparsetype = sparsetype;
+  
+  switch(A->sparsetype){
+    case CSC_MAT:
+      A->NP = N;
+      A->rowvals = &(A->indexvals);
+      A->colptrs = &(A->indexptrs);
+      /* CSR indices */
+      A->colvals = NULL;
+      A->rowptrs = NULL;
+      break;
+    case CSR_MAT:
+      A->NP = M;
+      A->colvals = &(A->indexvals);
+      A->rowptrs = &(A->indexptrs);
+      /* CSC indices */
+      A->rowvals = NULL;
+      A->colptrs = NULL;
+      break;
+    default:
+      free(A); 
+      A = NULL;
+      return(NULL);
+  }
+
+  A->data = (realtype *) malloc(NNZ * sizeof(realtype));
+  if (A->data == NULL) {
+    free(A); A = NULL;
+    return(NULL);
+  }
+  
+  A->indexvals = (int *) malloc(NNZ * sizeof(int));
+  if (A->indexvals == NULL) {
+    free(A->data); A->data = NULL;
+    free(A); A = NULL;
+    return(NULL);
+  }
+  A->indexptrs = (int *) malloc((A->NP + 1) * sizeof(int));
+  if (A->indexptrs == NULL) {
+    free(A->indexvals);
+    free(A->data); A->data = NULL;
+    free(A); A = NULL;
+    return(NULL);
+  }
+
+  A->M = M;
+  A->N = N;
+  A->NNZ = NNZ;
+  /* A->colptrs[N] = NNZ; */
+  A->indexptrs[A->NP] = 0;
+
+  return(A);
+}
+
+/** 
+ * Constructor
+ * 
+ * Creates a new sparse matrix out of an existing dense or band matrix.  
+ * Returns NULL if a memory allocation error occurred.
+ * 
+ */
+SlsMat SparseFromDenseMat(const DlsMat Ad, int sparsetype)
+{
+  int i, j, nnz;
+  int M, N;
+  realtype dtmp;
+  SlsMat As = NULL;
+  
+  switch(sparsetype) {
+    case CSC_MAT:
+      /* CSC is transpose of CSR */
+      M = Ad->N;
+      N = Ad->M;
+      break;
+    case CSR_MAT:
+      M = Ad->M;
+      N = Ad->N;
+      break;
+    default:
+      /* Sparse matrix type not recognized */
+      return NULL;
+  }
+
+  /* proceed according to A's type (dense/band) */
+  if (Ad->type == SUNDIALS_DENSE) {
+
+    /* determine total number of nonzeros */
+    nnz = 0;
+    for (j=0; j<Ad->N; j++)
+      for (i=0; i<Ad->M; i++)
+        nnz += (DENSE_ELEM(Ad,i,j) != 0.0);
+
+    /* allocate sparse matrix */
+    As = SparseNewMat(Ad->M, Ad->N, nnz, sparsetype);
+    if (As == NULL)  return NULL;
+
+    /* copy nonzeros from A into As */
+    nnz = 0;
+    for (i=0; i<M; i++) {
+      (As->indexptrs)[i] = nnz;
+      for (j=0; j<N; j++) {
+        /* CSR = row major looping; CSC = column major looping */
+        dtmp = (sparsetype == CSR_MAT) ? DENSE_ELEM(Ad,i,j) : DENSE_ELEM(Ad,j,i);
+        if ( dtmp != ZERO ) { 
+          (As->indexvals)[nnz] = j;
+          As->data[nnz++] = dtmp;
+        }
+      }
+    }
+    (As->indexptrs)[M] = nnz;
+
+  } else { /* SUNDIALS_BAND */
+
+    /* determine total number of nonzeros */
+    nnz = 0;
+    for (j=0; j<Ad->N; j++)
+      for (i=j-(Ad->mu); i<j+(Ad->ml); i++)
+        nnz += (BAND_ELEM(Ad,i,j) != 0.0);
+
+    /* allocate sparse matrix */
+    As = SparseNewMat(Ad->M, Ad->N, nnz, sparsetype);
+    if (As == NULL)  return NULL;
+
+    /* copy nonzeros from A into As */
+    nnz = 0;
+    for (i=0; i<M; i++) {
+      (As->indexptrs)[i] = nnz;
+      for (j=i-(Ad->mu); j<i+(Ad->ml); j++) {
+        /* CSR = row major looping; CSC = column major looping */
+        dtmp = (sparsetype == CSR_MAT) ? BAND_ELEM(Ad,i,j) : BAND_ELEM(Ad,j,i);
+        if ( dtmp != 0.0 ) { 
+          (As->indexvals)[nnz] = j;
+          As->data[nnz++] = dtmp;
+        }
+      }
+    }
+    (As->indexptrs)[M] = nnz;
+
+  }
+
+  return(As);
+}
+
+
+/**
+ * 
+ * Destructor
+ * 
+ * Frees memory and deletes the structure for an existing sparse matrix.
+ * 
+ */
+int SparseDestroyMat(SlsMat A)
+{
+  if (A->data) {
+    free(A->data);  
+    A->data = NULL;
+  }
+  if (A->indexvals) {
+    free(A->indexvals);
+    A->indexvals = NULL;
+    A->rowvals   = NULL;
+    A->colvals   = NULL;
+  }
+  if (A->indexptrs) {
+    free(A->indexptrs);
+    A->indexptrs = NULL;
+    A->colptrs   = NULL;
+    A->rowptrs   = NULL;
+  }
+  free(A); 
+  A = NULL;
+  
+  return 0;
+}
+
+
+/** 
+ * Sets all sparse matrix entries to zero.
+ */
+int SparseSetMatToZero(SlsMat A)
+{
+  int i;
+
+  for (i=0; i<A->NNZ; i++) {
+    A->data[i] = ZERO;
+    A->indexvals[i] = 0;
+  }
+
+  for (i=0; i<A->NP; i++) {
+    A->indexptrs[i] = 0;
+  }
+  /* A->colptrs[A->N] = A->NNZ; */
+  A->indexptrs[A->NP] = 0;
+  
+  return 0;
+}
+
+
+/** 
+ * Copies the sparse matrix A into sparse matrix B.  
+ * 
+ * It is assumed that A and B have the same dimensions, but we account 
+ * for the situation in which B has fewer nonzeros than A.
+ *  
+ */
+int SparseCopyMat(const SlsMat A, SlsMat B)
+{
+  int i;
+  int A_nz = A->indexptrs[A->NP];
+  
+  if(A->M != B->M || A->N != B->N) {
+    /* fprintf(stderr, "Error: Copying sparse matrices of different size!\n"); */
+    return (-1);
+  }
+    
+  
+  /* ensure B is of the same type as A */
+  B->sparsetype = A->sparsetype;
+
+  /* ensure that B is allocated with at least as 
+     much memory as we have nonzeros in A */
+  if (B->NNZ < A_nz) {
+    B->indexvals = realloc(B->indexvals, A_nz*sizeof(int));
+    B->data = realloc(B->data, A_nz*sizeof(realtype));
+    B->NNZ = A_nz;
+  }
+
+  /* zero out B so that copy works correctly */
+  SparseSetMatToZero(B);
+
+  /* copy the data and row indices over */
+  for (i=0; i<A_nz; i++){
+    B->data[i] = A->data[i];
+    B->indexvals[i] = A->indexvals[i];
+  }
+
+  /* copy the column pointers over */
+  for (i=0; i<A->NP; i++) {
+    B->indexptrs[i] = A->indexptrs[i];
+  }
+  B->indexptrs[A->NP] = A_nz;
+  
+  return 0;
+}
+
+
+/** 
+ * Scales a sparse matrix A by the coefficient b.
+ */
+int SparseScaleMat(realtype b, SlsMat A)
+{
+  int i;
+
+  for (i=0; i<A->indexptrs[A->NP]; i++){
+    A->data[i] = b * (A->data[i]);
+  }
+  return 0;
+}
+
+
+
+
+/** 
+ * Adds 1 to every diagonal entry of A.  
+ * 
+ * Works for general [rectangular] matrices and handles potentially increased 
+ * size if A does not currently contain a value on the diagonal.
+ * 
+ * The function was developed originally for CSC matrices. To make it work for 
+ * CSR, one simply need to transpose it, i.e. transpose M and N in the 
+ * implementation.  
+ * 
+ */
+int SparseAddIdentityMat(SlsMat A)
+{
+  int j, i, p, nz, newmat, found;
+  int *w, *Ap, *Ai, *Cp, *Ci;
+  realtype *x, *Ax, *Cx;
+  SlsMat C;
+  int M;
+  int N;
+
+  /* determine if A already contains values on the diagonal (hence 
+     memory allocation necessary)*/
+  newmat=0;
+  for (j=0; j < SUNMIN(A->N,A->M); j++) {
+    /* scan column (row if CSR) of A, searching for diagonal value */
+    found = 0;
+    for (i=A->indexptrs[j]; i<A->indexptrs[j+1]; i++) {
+      if (A->indexvals[i] == j) {
+        found = 1;
+        break;
+      }
+    }
+    /* if no diagonal found, signal new matrix */
+    if (!found) {
+      newmat=1;
+      break;
+    }
+  }
+
+  /* perform operation */
+
+  /*   case 1: A already contains a diagonal */
+  if (!newmat) {
+
+    /* iterate through columns, adding 1.0 to diagonal */
+    for (j=0; j < SUNMIN(A->N,A->M); j++)
+      for (i=A->indexptrs[j]; i<A->indexptrs[j+1]; i++)
+        if (A->indexvals[i] == j) 
+          A->data[i] += ONE;
+
+  /*   case 2: A does not already contain a diagonal */
+  } else {
+    
+    if (A->sparsetype == CSC_MAT) {
+      M = A->M;
+      N = A->N;
+    }
+    else if (A->sparsetype == CSR_MAT) {
+      M = A->N;
+      N = A->M;
+    }
+    else
+      return (-1);
+  
+    /* create work arrays for row indices and nonzero column values */
+    w = (int *) malloc(A->M * sizeof(int));
+    x = (realtype *) malloc(A->M * sizeof(realtype));
+
+    /* create new matrix for sum (overestimate nnz as sum of each) */
+    C = SparseNewMat(A->M, A->N, (A->indexptrs)[A->NP] + SUNMIN(A->M, A->N), A->sparsetype);
+
+    /* access data from CSR structures (return if failure) */
+    Cp = Ci = Ap = Ai = NULL;
+    Cx = Ax = NULL;
+    if (C->indexptrs)  Cp = C->indexptrs;
+    else  return (-1);
+    if (C->indexvals)  Ci = C->indexvals;
+    else  return (-1);
+    if (C->data)       Cx = C->data;
+    else  return (-1);
+    if (A->indexptrs)  Ap = A->indexptrs;
+    else  return (-1);
+    if (A->indexvals)  Ai = A->indexvals;
+    else  return (-1);
+    if (A->data)       Ax = A->data;
+    else  return (-1);
+
+    /* initialize total nonzero count */
+    nz = 0;
+
+    /* iterate through columns (rows for CSR) */
+    for (j=0; j<N; j++) {
+
+      /* set current column (row) pointer to current # nonzeros */
+      Cp[j] = nz;
+
+      /* clear out temporary arrays for this column (row) */
+      for (i=0; i<M; i++) {
+        w[i] = 0;
+        x[i] = 0.0;
+      }
+
+      /* iterate down column (along row) of A, collecting nonzeros */
+      for (p=Ap[j]; p<Ap[j+1]; p++) {
+        w[Ai[p]] += 1;       /* indicate that row is filled */
+        x[Ai[p]] = Ax[p];    /* collect value */
+      }
+
+      /* add identity to this column (row) */
+      if (j < M) {
+        w[j] += 1;     /* indicate that row is filled */
+        x[j] += ONE;   /* update value */
+      }
+
+      /* fill entries of C with this column's (row's) data */
+      for (i=0; i<M; i++) {
+        if ( w[i] > 0 ) { 
+          Ci[nz] = i;  
+          Cx[nz++] = x[i];
+        }
+      }
+    }
+
+    /* indicate end of data */
+    Cp[N] = nz;
+
+    /* update A's structure with C's values; nullify C's pointers */
+    A->NNZ = C->NNZ;
+
+    if (A->data)
+      free(A->data);  
+    A->data = C->data;
+    C->data = NULL;
+
+    if (A->indexvals)
+      free(A->indexvals);
+    A->indexvals = C->indexvals;
+    C->indexvals = NULL;
+
+    if (A->indexptrs)
+      free(A->indexptrs);
+    A->indexptrs = C->indexptrs;
+    C->indexptrs = NULL;
+
+    /* clean up */
+    SparseDestroyMat(C); 
+    free(w);
+    free(x);
+
+    /* reallocate the new matrix to remove extra space */
+    SparseReallocMat(A);
+  }
+  return 0;
+}
+
+
+/** 
+ * Add two sparse matrices: A = A+B.  
+ * 
+ * Handles potentially increased size if matrices have different sparsity patterns.  
+ * Returns 0 if successful, and 1 if unsuccessful (in which case A is left unchanged).
+ * 
+ * The function was developed originally for CSC matrices. To make it work for 
+ * CSR, one simply need to transpose it, i.e. transpose M and N in the 
+ * implementation.  
+ * 
+ */
+int SparseAddMat(SlsMat A, const SlsMat B)
+{
+  int j, i, p, nz, newmat;
+  int *w, *Ap, *Ai, *Bp, *Bi, *Cp, *Ci;
+  realtype *x, *Ax, *Bx, *Cx;
+  SlsMat C;
+  int M;
+  int N;
+
+  /* ensure that matrix dimensions agree */
+  if ((A->M != B->M) || (A->N != B->N)) {
+    /* fprintf(stderr, "Error: Adding sparse matrices of different size!\n"); */
+    return(-1);
+  }
+  
+  /* if A is CSR matrix, transpose M and N */
+  if (A->sparsetype == CSC_MAT) {
+    M = A->M;
+    N = A->N;
+  }
+  else if (A->sparsetype == CSR_MAT) {
+    M = A->N;
+    N = A->M;
+  }
+  else
+    return(-1);
+  
+  /* create work arrays for row indices and nonzero column values */
+  w = (int *) malloc(M * sizeof(int));
+  x = (realtype *) malloc(M * sizeof(realtype));
+
+  /* determine if A already contains the sparsity pattern of B */
+  newmat=0;
+  for (j=0; j<N; j++) {
+
+    /* clear work array */
+    for (i=0; i<M; i++)  w[i] = 0;
+
+    /* scan column of A, incrementing w by one */
+    for (i=A->indexptrs[j]; i<A->indexptrs[j+1]; i++)
+      w[A->indexvals[i]] += 1;
+
+    /* scan column of B, decrementing w by one */
+    for (i=B->indexptrs[j]; i<B->indexptrs[j+1]; i++)
+      w[B->indexvals[i]] -= 1;
+
+    /* if any entry of w is negative, A doesn't contain B's sparsity */
+    for (i=0; i<M; i++)
+      if (w[i] < 0) {
+        newmat = 1;
+        break;
+      }
+    if (newmat) break;
+
+  }
+
+  /* perform operation */
+
+  /*   case 1: A already contains sparsity pattern of B */
+  if (!newmat) {
+
+    /* iterate through columns, adding matrices */
+    for (j=0; j<N; j++) {
+
+      /* clear work array */
+      for (i=0; i<M; i++)
+        x[i] = ZERO;
+
+      /* scan column of B, updating work array */
+      for (i = B->indexptrs[j]; i < B->indexptrs[j+1]; i++)
+        x[B->indexvals[i]] = B->data[i];
+
+      /* scan column of A, updating entries appropriately array */
+      for (i = A->indexptrs[j]; i < A->indexptrs[j+1]; i++)
+        A->data[i] += x[A->indexvals[i]];
+
+    }
+
+  /*   case 2: A does not already contain B's sparsity */
+  } else {
+
+    /* create new matrix for sum (overestimate nnz as sum of each) */
+    C = SparseNewMat(M, N, (A->indexptrs[N])+(B->indexptrs[N]), A->sparsetype);
+
+    /* access data from CSR structures (return if failure) */
+    Cp = Ci = Ap = Ai = Bp = Bi = NULL;
+    Cx = Ax = Bx = NULL;
+    if (C->indexptrs)  Cp = C->indexptrs;
+    else  return(-1);
+    if (C->indexvals)  Ci = C->indexvals;
+    else  return(-1);
+    if (C->data)       Cx = C->data;
+    else  return(-1);
+    if (A->indexptrs)  Ap = (A->indexptrs);
+    else  return(-1);
+    if (A->indexvals)  Ai = (A->indexvals);
+    else  return(-1);
+    if (A->data)       Ax = A->data;
+    else  return(-1);
+    if (B->indexptrs)  Bp = B->indexptrs;
+    else  return(-1);
+    if (B->indexvals)  Bi = B->indexvals;
+    else  return(-1);
+    if (B->data)       Bx = B->data;
+    else  return(-1);
+
+    /* initialize total nonzero count */
+    nz = 0;
+
+    /* iterate through columns */
+    for (j=0; j<N; j++) {
+
+      /* set current column pointer to current # nonzeros */
+      Cp[j] = nz;
+
+      /* clear out temporary arrays for this column */
+      for (i=0; i<M; i++) {
+        w[i] = 0;
+        x[i] = 0.0;
+      }
+
+      /* iterate down column of A, collecting nonzeros */
+      for (p=Ap[j]; p<Ap[j+1]; p++) {
+        w[Ai[p]] += 1;       /* indicate that row is filled */
+        x[Ai[p]] = Ax[p];    /* collect value */
+      }
+
+      /* iterate down column of B, collecting nonzeros */
+      for (p=Bp[j]; p<Bp[j+1]; p++) {
+        w[Bi[p]] += 1;       /* indicate that row is filled */
+        x[Bi[p]] += Bx[p];   /* collect value */
+      }
+
+      /* fill entries of C with this column's data */
+      for (i=0; i<M; i++) {
+        if ( w[i] > 0 ) { 
+          Ci[nz] = i;  
+          Cx[nz++] = x[i];
+        }
+      }
+    }
+
+    /* indicate end of data */
+    Cp[N] = nz;
+
+    /* update A's structure with C's values; nullify C's pointers */
+    A->NNZ = C->NNZ;
+
+    free(A->data);  
+    A->data = C->data;
+    C->data = NULL;
+
+    free(A->indexvals);
+    A->indexvals = C->indexvals;
+    C->indexvals = NULL;
+
+    free(A->indexptrs);
+    A->indexptrs = C->indexptrs;
+    C->indexptrs = NULL;
+
+    /* clean up */
+    SparseDestroyMat(C); 
+
+    /* reallocate the new matrix to remove extra space */
+    SparseReallocMat(A);
+
+  }
+
+  /* clean up */
+  free(w);
+  free(x);
+
+  /* return success */
+  return(0);
+}
+
+
+/** 
+ * Resizes the memory allocated for a given sparse matrix, shortening 
+ * it down to the number of actual nonzero entries.
+ */
+int SparseReallocMat(SlsMat A)
+{
+  int nzmax; 
+
+  nzmax = A->indexptrs[A->NP];
+  A->indexvals = realloc(A->indexvals, nzmax*sizeof(int));
+  A->data = realloc(A->data, nzmax*sizeof(realtype));
+  A->NNZ = nzmax;
+  
+  return 0;
+}
+
+
+/** 
+ * Computes y=A*x, where A is a sparse matrix of dimension MxN, x is a 
+ * realtype array of length N, and y is a realtype array of length M. 
+ * 
+ * Returns 0 if successful, -1 if unsuccessful (failed memory access).
+ */
+int SparseMatvec(const SlsMat A, const realtype *x, realtype *y)
+{
+  if(A->sparsetype == CSC_MAT)
+    return SparseMatvecCSC(A, x, y);
+  else if (A->sparsetype == CSR_MAT)
+    return SparseMatvecCSR(A, x, y);
+  else
+    return(-1);
+}
+
+
+/** 
+ * Prints the nonzero entries of a sparse matrix to screen.
+ */
+void SparsePrintMat(const SlsMat A, FILE* outfile)
+{
+  int i,j, NNZ;
+  char *matrixtype;
+  char *indexname;
+
+  NNZ = A->NNZ;
+
+  switch(A->sparsetype) {
+    case CSC_MAT:
+      indexname = (char*) "col";
+      matrixtype = (char*) "CSC";
+      break;
+    case CSR_MAT:
+      indexname = (char*) "row";
+      matrixtype = (char*) "CSR";
+      break;
+    default:
+      /* Sparse matrix type not recognized */
+      return;
+  }
+
+
+  fprintf(outfile, "\n");
+  
+  fprintf(outfile, "%d by %d %s matrix, NNZ: %d \n", A->M, A->N, matrixtype, NNZ);
+  for (j=0; j < A->NP; j++) {
+    fprintf(outfile, "%s %d : locations %d to %d\n", indexname, j, (A->indexptrs)[j], (A->indexptrs)[j+1]-1);
+    fprintf(outfile, "  ");
+    for (i = (A->indexptrs)[j]; i < (A->indexptrs)[j+1]; i++) {
+#if defined(SUNDIALS_EXTENDED_PRECISION)
+      fprintf(outfile, "%d: %Lg   ", A->indexvals[i], A->data[i]);
+#elif defined(SUNDIALS_DOUBLE_PRECISION)
+      fprintf(outfile, "%d: %g   ", A->indexvals[i], A->data[i]);
+#else
+      fprintf(outfile, "%d: %g   ", A->indexvals[i], A->data[i]);
+#endif
+    }
+    fprintf(outfile, "\n");
+  }
+  fprintf(outfile, "\n");
+    
+}
+
+
+
+/*
+ * ==================================================================
+ * Private function definitions
+ * ==================================================================
+ */
+
+
+
+/** 
+ * Computes y=A*x, where A is a CSC matrix of dimension MxN, x is a 
+ * realtype array of length N, and y is a realtype array of length M. 
+ * 
+ * Returns 0 if successful, -1 if unsuccessful (failed memory access).
+ */
+int SparseMatvecCSC(const SlsMat A, const realtype *x, realtype *y)
+{
+  int j, i;
+  int *Ap, *Ai;
+  realtype *Ax;
+
+  /* access data from CSR structure (return if failure) */
+  if (*A->colptrs)  Ap = A->indexptrs;
+  else  return(-1);
+  if (*A->rowvals)  Ai = A->indexvals;
+  else  return(-1);
+  if (A->data)      Ax = A->data;
+  else  return(-1);
+
+  /* ensure that vectors are non-NULL */
+  if ((x == NULL) || (y == NULL))
+    return(-1);
+
+  /* initialize result */
+  for (i=0; i<A->M; i++)
+    y[i] = 0.0;
+
+  /* iterate through matrix columns */
+  for (j=0; j<A->N; j++) {
+
+    /* iterate down column of A, performing product */
+    for (i=Ap[j]; i<Ap[j+1]; i++)
+      y[Ai[i]] += Ax[i]*x[j];
+
+  }
+
+  /* return success */
+  return(0);
+}
+
+
+/** 
+ * Computes y=A*x, where A is a CSR matrix of dimension MxN, x is a 
+ * realtype array of length N, and y is a realtype array of length M. 
+ * 
+ * Returns 0 if successful, -1 if unsuccessful (failed memory access).
+ */
+int SparseMatvecCSR(const SlsMat A, const realtype *x, realtype *y)
+{
+  int j, i;
+  int *Ap, *Aj;
+  realtype *Ax;
+
+  /* access data from CSR structure (return if failure) */
+  if (*A->rowptrs)  Ap = A->indexptrs;
+  else  return(-1);
+  if (*A->colvals)  Aj = A->indexvals;
+  else  return(-1);
+  if (A->data)      Ax = A->data;
+  else  return(-1);
+
+  /* ensure that vectors are non-NULL */
+  if ((x == NULL) || (y == NULL))
+    return(-1);
+
+  /* initialize result */
+  for (i=0; i<A->M; i++)
+    y[i] = 0.0;
+
+  /* iterate through matrix rows */
+  for (i=0; i<A->M; ++i) {
+
+    /* iterate along row of A, performing product */
+    for (j=Ap[i]; j<Ap[i+1]; ++j)
+      y[i] += Ax[j]*x[Aj[j]];
+
+  }
+
+  /* return success */
+  return(0);
+}
+
+
diff --git a/src/sundials/sundials_spbcgs.c b/src/sundials/sundials_spbcgs.c
index b73bf26..bbec881 100644
--- a/src/sundials/sundials_spbcgs.c
+++ b/src/sundials/sundials_spbcgs.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2007/04/06 20:33:30 $
+ * $Revision: 4507 $
+ * $Date: 2015-06-24 08:47:04 -0700 (Wed, 24 Jun 2015) $
  * -----------------------------------------------------------------
  * Programmer(s): Peter Brown and Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2004, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the scaled, preconditioned
  * Bi-CGSTAB (SPBCG) iterative linear solver.
@@ -203,7 +208,7 @@ int SpbcgSolve(SpbcgMem mem, void *A_data, N_Vector x, N_Vector b,
   /* Set r_norm to L2 norm of r_star = sb P1_inv r_0, and
      return if small */
 
-  *res_norm = r_norm = rho = RSqrt(beta_denom);
+  *res_norm = r_norm = rho = SUNRsqrt(beta_denom);
   if (r_norm <= delta) return(SPBCG_SUCCESS);
 
   /* Copy r_star to r and p */
@@ -256,7 +261,7 @@ int SpbcgSolve(SpbcgMem mem, void *A_data, N_Vector x, N_Vector b,
 
     /* Calculate alpha = <r,r_star>/<Ap,r_star> */
 
-    alpha = ((N_VDotProd(r, r_star) / N_VDotProd(Ap, r_star)));
+    alpha = ((beta_denom / N_VDotProd(Ap, r_star)));
 
     /* Update q = r - alpha*Ap = r - alpha*(sb P1_inv A P2_inv sx_inv p) */
 
@@ -316,7 +321,7 @@ int SpbcgSolve(SpbcgMem mem, void *A_data, N_Vector x, N_Vector b,
 
     /* Set rho = norm(r) and check convergence */
 
-    *res_norm = rho = RSqrt(N_VDotProd(r, r));
+    *res_norm = rho = SUNRsqrt(N_VDotProd(r, r));
     if (rho <= delta) {
       converged = TRUE;
       break;
diff --git a/src/sundials/sundials_spfgmr.c b/src/sundials/sundials_spfgmr.c
new file mode 100644
index 0000000..3edf7fd
--- /dev/null
+++ b/src/sundials/sundials_spfgmr.c
@@ -0,0 +1,364 @@
+/*----------------------------------------------------------------
+ Programmer(s): Daniel R. Reynolds and Hilari C. Tiedeman @ SMU
+ -----------------------------------------------------------------
+ Copyright (c) 2011, Southern Methodist University.
+ All rights reserved.
+ For details, see the LICENSE file.
+ -------------------------------------------------------------------
+ This is the implementation file for the scaled preconditioned
+ FGMRES (SPFGMR) iterative linear solver.
+ ---------------------------------------------------------------*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <sundials/sundials_spfgmr.h>
+#include <sundials/sundials_math.h>
+
+/*----------------------------------------------------------------
+ private constants
+ ---------------------------------------------------------------*/
+#define ZERO RCONST(0.0)
+#define ONE  RCONST(1.0)
+
+/*----------------------------------------------------------------
+ Function : SpfgmrMalloc
+ ---------------------------------------------------------------*/
+SpfgmrMem SpfgmrMalloc(int l_max, N_Vector vec_tmpl)
+{
+  SpfgmrMem mem;
+  N_Vector *V, *Z, xcor, vtemp;
+  realtype **Hes, *givens, *yg;
+  int k, i;
+ 
+  /* Check the input parameters. */
+  if (l_max <= 0) return(NULL);
+
+  /* Get memory for the Krylov basis vectors V[0], ..., V[l_max]. */
+  V = N_VCloneVectorArray(l_max+1, vec_tmpl);
+  if (V == NULL) return(NULL);
+
+  /* Get memory for the preconditioned basis vectors Z[0], ..., Z[l_max]. */
+  Z = N_VCloneVectorArray(l_max+1, vec_tmpl);
+  if (Z == NULL) {
+    N_VDestroyVectorArray(V, l_max+1);
+    return(NULL);
+  }
+
+  /* Get memory for the Hessenberg matrix Hes. */
+  Hes = NULL;
+  Hes = (realtype **) malloc((l_max+1)*sizeof(realtype *)); 
+  if (Hes == NULL) {
+    N_VDestroyVectorArray(V, l_max+1);
+    N_VDestroyVectorArray(Z, l_max+1);
+    return(NULL);
+  }
+  for (k=0; k<=l_max; k++) {
+    Hes[k] = NULL;
+    Hes[k] = (realtype *) malloc(l_max*sizeof(realtype));
+    if (Hes[k] == NULL) {
+      for (i=0; i<k; i++) {free(Hes[i]); Hes[i] = NULL;}
+      free(Hes); Hes = NULL;
+      N_VDestroyVectorArray(V, l_max+1);
+      N_VDestroyVectorArray(Z, l_max+1);
+      return(NULL);
+    }
+  }
+  
+  /* Get memory for Givens rotation components. */
+  givens = NULL;
+  givens = (realtype *) malloc(2*l_max*sizeof(realtype));
+  if (givens == NULL) {
+    for (i=0; i<=l_max; i++) {free(Hes[i]); Hes[i] = NULL;}
+    free(Hes); Hes = NULL;
+    N_VDestroyVectorArray(V, l_max+1);
+    N_VDestroyVectorArray(Z, l_max+1);
+    return(NULL);
+  }
+
+  /* Get memory to hold the correction to z_tilde. */
+  xcor = N_VClone(vec_tmpl);
+  if (xcor == NULL) {
+    free(givens); givens = NULL;
+    for (i=0; i<=l_max; i++) {free(Hes[i]); Hes[i] = NULL;}
+    free(Hes); Hes = NULL;
+    N_VDestroyVectorArray(V, l_max+1);
+    N_VDestroyVectorArray(Z, l_max+1);
+    return(NULL);
+  }
+
+  /* Get memory to hold SPFGMR y and g vectors. */
+  yg = NULL;
+  yg = (realtype *) malloc((l_max+1)*sizeof(realtype));
+  if (yg == NULL) {
+    N_VDestroy(xcor);
+    free(givens); givens = NULL;
+    for (i=0; i<=l_max; i++) {free(Hes[i]); Hes[i] = NULL;}
+    free(Hes); Hes = NULL;
+    N_VDestroyVectorArray(V, l_max+1);
+    N_VDestroyVectorArray(Z, l_max+1);
+    return(NULL);
+  }
+
+  /* Get an array to hold a temporary vector. */
+  vtemp = N_VClone(vec_tmpl);
+  if (vtemp == NULL) {
+    free(yg); yg = NULL;
+    N_VDestroy(xcor);
+    free(givens); givens = NULL;
+    for (i=0; i<=l_max; i++) {free(Hes[i]); Hes[i] = NULL;}
+    free(Hes); Hes = NULL;
+    N_VDestroyVectorArray(V, l_max+1);
+    N_VDestroyVectorArray(Z, l_max+1);
+    return(NULL);
+  }
+
+  /* Get memory for an SpfgmrMemRec containing SPFGMR matrices and vectors. */
+  mem = NULL;
+  mem = (SpfgmrMem) malloc(sizeof(SpfgmrMemRec));
+  if (mem == NULL) {
+    N_VDestroy(vtemp);
+    free(yg); yg = NULL;
+    N_VDestroy(xcor);
+    free(givens); givens = NULL;
+    for (i=0; i<=l_max; i++) {free(Hes[i]); Hes[i] = NULL;}
+    free(Hes); Hes = NULL;
+    N_VDestroyVectorArray(V, l_max+1);
+    N_VDestroyVectorArray(Z, l_max+1);
+    return(NULL); 
+  }
+
+  /* Set the fields of mem. */
+  mem->l_max = l_max;
+  mem->V = V;
+  mem->Z = Z;
+  mem->Hes = Hes;
+  mem->givens = givens;
+  mem->xcor = xcor;
+  mem->yg = yg;
+  mem->vtemp = vtemp;
+
+  /* Return the pointer to SPFGMR memory. */
+  return(mem);
+}
+
+/*----------------------------------------------------------------
+ Function : SpfgmrSolve
+ ---------------------------------------------------------------*/
+int SpfgmrSolve(SpfgmrMem mem, void *A_data, N_Vector x, 
+		N_Vector b, int pretype, int gstype, realtype delta, 
+		int max_restarts, int maxit, void *P_data, 
+		N_Vector s1, N_Vector s2, ATimesFn atimes, 
+		PSolveFn psolve, realtype *res_norm, int *nli, int *nps)
+{
+  N_Vector *V, *Z, xcor, vtemp;
+  realtype **Hes, *givens, *yg;
+  realtype beta, rotation_product, r_norm, s_product, rho;
+  booleantype preOnRight, scale1, scale2, converged;
+  int i, j, k, l, l_max, krydim, ier, ntries;
+
+  if (mem == NULL) return(SPFGMR_MEM_NULL);
+
+  /* Initialize some variables */
+  krydim = 0;
+
+  /* Make local copies of mem variables. */
+  l_max  = mem->l_max;
+  V      = mem->V;
+  Z      = mem->Z;
+  Hes    = mem->Hes;
+  givens = mem->givens;
+  xcor   = mem->xcor;
+  yg     = mem->yg;
+  vtemp  = mem->vtemp;
+
+  *nli = *nps = 0;    /* Initialize counters */
+  converged = FALSE;  /* Initialize converged flag */
+
+  /* If maxit is greater than l_max, then set maxit=l_max */
+  if (maxit > l_max)  maxit = l_max;
+
+  /* Check for legal value of max_restarts */
+  if (max_restarts < 0)  max_restarts = 0;
+
+  /* Set preconditioning flag (enabling any preconditioner implies right 
+     preconditioning, since FGMRES does not support left preconditioning) */
+  preOnRight = ((pretype == PREC_RIGHT) || (pretype == PREC_BOTH) || (pretype == PREC_LEFT));
+
+  /* Set scaling flags */
+  scale1 = (s1 != NULL);
+  scale2 = (s2 != NULL);
+
+  /* Set vtemp to initial (unscaled) residual r_0 = b - A*x_0. */
+  if (N_VDotProd(x, x) == ZERO) {
+    N_VScale(ONE, b, vtemp);
+  } else {
+    ier = atimes(A_data, x, vtemp);
+    if (ier != 0)
+      return((ier < 0) ? SPFGMR_ATIMES_FAIL_UNREC : SPFGMR_ATIMES_FAIL_REC);
+    N_VLinearSum(ONE, b, -ONE, vtemp, vtemp);
+  }
+
+  /* Apply left scaling to vtemp = r_0 to fill V[0]. */
+  if (scale1) {
+    N_VProd(s1, vtemp, V[0]);   
+  } else {
+    N_VScale(ONE, vtemp, V[0]);
+  }
+
+  /* Set r_norm = beta to L2 norm of V[0] = s1 r_0, and return if small */
+  *res_norm = r_norm = beta = SUNRsqrt(N_VDotProd(V[0], V[0]));
+  if (r_norm <= delta)
+    return(SPFGMR_SUCCESS);
+
+  /* Initialize rho to avoid compiler warning message */
+  rho = beta;
+
+  /* Set xcor = 0. */
+  N_VConst(ZERO, xcor);
+
+  /* Begin outer iterations: up to (max_restarts + 1) attempts. */
+  for (ntries=0; ntries<=max_restarts; ntries++) {
+    
+    /* Initialize the Hessenberg matrix Hes and Givens rotation
+       product.  Normalize the initial vector V[0].             */
+    for (i=0; i<=l_max; i++)
+      for (j=0; j<l_max; j++)
+        Hes[i][j] = ZERO;
+    rotation_product = ONE;
+    N_VScale(ONE/r_norm, V[0], V[0]);
+    
+    /* Inner loop: generate Krylov sequence and Arnoldi basis. */
+    for (l=0; l<maxit; l++) {
+      
+      (*nli)++;
+      
+      krydim = l + 1;
+      
+      /* Generate A-tilde V[l], where A-tilde = s1 A P_inv s2_inv. */
+
+      /*   Apply right scaling: vtemp = s2_inv V[l]. */
+      if (scale2) N_VDiv(V[l], s2, vtemp);
+      else N_VScale(ONE, V[l], vtemp);
+      
+      /*   Apply right preconditioner: vtemp = Z[l] = P_inv s2_inv V[l]. */ 
+      if (preOnRight) {
+        N_VScale(ONE, vtemp, V[l+1]);
+        ier = psolve(P_data, V[l+1], vtemp, PREC_RIGHT);
+        (*nps)++;
+        if (ier != 0)
+          return((ier < 0) ? SPFGMR_PSOLVE_FAIL_UNREC : SPFGMR_PSOLVE_FAIL_REC);
+      }
+      N_VScale(ONE, vtemp, Z[l]);
+      
+      /*   Apply A: V[l+1] = A P_inv s2_inv V[l]. */
+      ier = atimes(A_data, vtemp, V[l+1]);
+      if (ier != 0)
+        return((ier < 0) ? SPFGMR_ATIMES_FAIL_UNREC : SPFGMR_ATIMES_FAIL_REC);
+
+      /*   Apply left scaling: V[l+1] = s1 A P_inv s2_inv V[l]. */
+      if (scale1)  N_VProd(s1, V[l+1], V[l+1]);
+      
+      /* Orthogonalize V[l+1] against previous V[i]: V[l+1] = w_tilde. */
+      if (gstype == CLASSICAL_GS) {
+        if (ClassicalGS(V, Hes, l+1, l_max, &(Hes[l+1][l]),
+                        vtemp, yg) != 0)
+          return(SPFGMR_GS_FAIL);
+      } else {
+        if (ModifiedGS(V, Hes, l+1, l_max, &(Hes[l+1][l])) != 0) 
+          return(SPFGMR_GS_FAIL);
+      }
+      
+      /* Update the QR factorization of Hes. */
+      if(QRfact(krydim, Hes, givens, l) != 0 )
+        return(SPFGMR_QRFACT_FAIL);
+      
+      /* Update residual norm estimate; break if convergence test passes. */
+      rotation_product *= givens[2*l+1];
+      *res_norm = rho = SUNRabs(rotation_product*r_norm);
+      if (rho <= delta) { converged = TRUE; break; }
+      
+      /* Normalize V[l+1] with norm value from the Gram-Schmidt routine. */
+      N_VScale(ONE/Hes[l+1][l], V[l+1], V[l+1]);
+    }
+    
+    /* Inner loop is done.  Compute the new correction vector xcor. */
+    
+    /*   Construct g, then solve for y. */
+    yg[0] = r_norm;
+    for (i=1; i<=krydim; i++)  yg[i]=ZERO;
+    if (QRsol(krydim, Hes, givens, yg) != 0)
+      return(SPFGMR_QRSOL_FAIL);
+    
+    /*   Add correction vector Z_l y to xcor. */
+    for (k=0; k<krydim; k++)
+      N_VLinearSum(yg[k], Z[k], ONE, xcor, xcor);
+    
+    /* If converged, construct the final solution vector x and return. */
+    if (converged) {
+      N_VLinearSum(ONE, x, ONE, xcor, x);
+      return(SPFGMR_SUCCESS);
+    }
+    
+    /* Not yet converged; if allowed, prepare for restart. */
+    if (ntries == max_restarts) break;
+    
+    /* Construct last column of Q in yg. */
+    s_product = ONE;
+    for (i=krydim; i>0; i--) {
+      yg[i] = s_product*givens[2*i-2];
+      s_product *= givens[2*i-1];
+    }
+    yg[0] = s_product;
+    
+    /* Scale r_norm and yg. */
+    r_norm *= s_product;
+    for (i=0; i<=krydim; i++)
+      yg[i] *= r_norm;
+    r_norm = SUNRabs(r_norm);
+    
+    /* Multiply yg by V_(krydim+1) to get last residual vector; restart. */
+    N_VScale(yg[0], V[0], V[0]);
+    for (k=1; k<=krydim; k++)
+      N_VLinearSum(yg[k], V[k], ONE, V[0], V[0]);
+    
+  }
+  
+  /* Failed to converge, even after allowed restarts.
+     If the residual norm was reduced below its initial value, compute
+     and return x anyway.  Otherwise return failure flag. */
+  if (rho < beta) {
+    N_VLinearSum(ONE, x, ONE, xcor, x);
+    return(SPFGMR_RES_REDUCED);
+  }
+
+  return(SPFGMR_CONV_FAIL); 
+}
+
+/*----------------------------------------------------------------
+ Function : SpfgmrFree
+ ---------------------------------------------------------------*/
+void SpfgmrFree(SpfgmrMem mem)
+{
+  int i;
+
+  if (mem == NULL) return;
+
+  for (i=0; i<=mem->l_max; i++) {
+    free(mem->Hes[i]); 
+    mem->Hes[i] = NULL;
+  }
+  free(mem->Hes); mem->Hes = NULL;
+  free(mem->givens); mem->givens = NULL; 
+  free(mem->yg); mem->yg = NULL;
+
+  N_VDestroyVectorArray(mem->V, mem->l_max+1);
+  N_VDestroyVectorArray(mem->Z, mem->l_max+1);
+  N_VDestroy(mem->xcor);
+  N_VDestroy(mem->vtemp);
+
+  free(mem); mem = NULL;
+}
+
+
+/*===============================================================
+   EOF
+===============================================================*/
diff --git a/src/sundials/sundials_spgmr.c b/src/sundials/sundials_spgmr.c
index 7efd187..d32718b 100644
--- a/src/sundials/sundials_spgmr.c
+++ b/src/sundials/sundials_spgmr.c
@@ -1,15 +1,20 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2007/04/06 20:33:30 $
+ * $Revision: 4294 $
+ * $Date: 2014-12-15 13:18:40 -0800 (Mon, 15 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh and
  *                Radu Serban @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2002, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the scaled preconditioned
  * GMRES (SPGMR) iterative linear solver.
@@ -230,7 +235,7 @@ int SpgmrSolve(SpgmrMem mem, void *A_data, N_Vector x, N_Vector b,
   /* Set r_norm = beta to L2 norm of V[0] = s1 P1_inv r_0, and
      return if small.  */
 
-  *res_norm = r_norm = beta = RSqrt(N_VDotProd(V[0], V[0])); 
+  *res_norm = r_norm = beta = SUNRsqrt(N_VDotProd(V[0], V[0])); 
   if (r_norm <= delta)
     return(SPGMR_SUCCESS);
 
@@ -327,7 +332,7 @@ int SpgmrSolve(SpgmrMem mem, void *A_data, N_Vector x, N_Vector b,
       /*  Update residual norm estimate; break if convergence test passes. */
       
       rotation_product *= givens[2*l+1];
-      *res_norm = rho = ABS(rotation_product*r_norm);
+      *res_norm = rho = SUNRabs(rotation_product*r_norm);
       
       if (rho <= delta) { converged = TRUE; break; }
       
@@ -390,7 +395,7 @@ int SpgmrSolve(SpgmrMem mem, void *A_data, N_Vector x, N_Vector b,
     r_norm *= s_product;
     for (i = 0; i <= krydim; i++)
       yg[i] *= r_norm;
-    r_norm = ABS(r_norm);
+    r_norm = SUNRabs(r_norm);
     
     /* Multiply yg by V_(krydim+1) to get last residual vector; restart. */
     N_VScale(yg[0], V[0], V[0]);
@@ -436,19 +441,15 @@ int SpgmrSolve(SpgmrMem mem, void *A_data, N_Vector x, N_Vector b,
 void SpgmrFree(SpgmrMem mem)
 {
   int i, l_max;
-  realtype **Hes, *givens, *yg;
   
   if (mem == NULL) return;
 
   l_max  = mem->l_max;
-  Hes    = mem->Hes;
-  givens = mem->givens;
-  yg     = mem->yg;
 
-  for (i = 0; i <= l_max; i++) {free(Hes[i]); Hes[i] = NULL;}
-  free(Hes); Hes = NULL;
-  free(mem->givens); givens = NULL; 
-  free(mem->yg); yg = NULL;
+  for (i = 0; i <= l_max; i++) {free(mem->Hes[i]);}
+  free(mem->Hes);
+  free(mem->givens);
+  free(mem->yg);
 
   N_VDestroyVectorArray(mem->V, l_max+1);
   N_VDestroy(mem->xcor);
diff --git a/src/sundials/sundials_sptfqmr.c b/src/sundials/sundials_sptfqmr.c
index 626ca00..2aa360f 100644
--- a/src/sundials/sundials_sptfqmr.c
+++ b/src/sundials/sundials_sptfqmr.c
@@ -1,14 +1,19 @@
 /*
  * -----------------------------------------------------------------
- * $Revision: 1.2 $
- * $Date: 2007/04/06 20:33:30 $
+ * $Revision: 4272 $
+ * $Date: 2014-12-02 11:19:41 -0800 (Tue, 02 Dec 2014) $
  * -----------------------------------------------------------------
  * Programmer(s): Aaron Collier @ LLNL
  * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
+ * LLNS Copyright Start
+ * Copyright (c) 2014, Lawrence Livermore National Security
+ * This work was performed under the auspices of the U.S. Department 
+ * of Energy by Lawrence Livermore National Laboratory in part under 
+ * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  * Produced at the Lawrence Livermore National Laboratory.
  * All rights reserved.
  * For details, see the LICENSE file.
+ * LLNS Copyright End
  * -----------------------------------------------------------------
  * This is the implementation file for the scaled preconditioned
  * Transpose-Free Quasi-Minimal Residual (SPTFQMR) linear solver.
@@ -254,7 +259,7 @@ int SptfqmrSolve(SptfqmrMem mem, void *A_data, N_Vector x, N_Vector b,
 
   /* Compute norm of initial residual (r_0) to see if we really need
      to do anything */
-  *res_norm = r_init_norm = RSqrt(rho[0]);
+  *res_norm = r_init_norm = SUNRsqrt(rho[0]);
   if (r_init_norm <= delta) return(SPTFQMR_SUCCESS);
 
   /* Set v_ = A*r_0 (preconditioned and scaled) */
@@ -334,33 +339,33 @@ int SptfqmrSolve(SptfqmrMem mem, void *A_data, N_Vector x, N_Vector b,
        *       if the inner loop is executed twice
        */
       if (m == 0) {
-	temp_val = RSqrt(N_VDotProd(r_[1], r_[1]));
-	omega = RSqrt(RSqrt(N_VDotProd(r_[0], r_[0]))*temp_val);
-	N_VLinearSum(ONE, u_, SQR(v_bar)*eta/alpha, d_, d_);
+	temp_val = SUNRsqrt(N_VDotProd(r_[1], r_[1]));
+	omega = SUNRsqrt(SUNRsqrt(N_VDotProd(r_[0], r_[0]))*temp_val);
+	N_VLinearSum(ONE, u_, SUNSQR(v_bar)*eta/alpha, d_, d_);
       }
       else {
 	omega = temp_val;
-	N_VLinearSum(ONE, q_, SQR(v_bar)*eta/alpha, d_, d_);
+	N_VLinearSum(ONE, q_, SUNSQR(v_bar)*eta/alpha, d_, d_);
       }
 
       /* v_bar = omega/tau */
       v_bar = omega/tau;
 
       /* c = (1+v_bar^2)^(-1/2) */
-      c = ONE / RSqrt(ONE+SQR(v_bar));
+      c = ONE / SUNRsqrt(ONE+SUNSQR(v_bar));
 
       /* tau = tau*v_bar*c */
       tau = tau*v_bar*c;
 
       /* eta = c^2*alpha */
-      eta = SQR(c)*alpha;
+      eta = SUNSQR(c)*alpha;
 
       /* x = x+eta*d_ */
       N_VLinearSum(ONE, x, eta, d_, x);
 
       /* Check for convergence... */
       /* NOTE: just use approximation to norm of residual, if possible */
-      *res_norm = r_curr_norm = tau*RSqrt(m+1);
+      *res_norm = r_curr_norm = tau*SUNRsqrt(m+1);
 
       /* Exit inner loop if iteration has converged based upon approximation
 	 to norm of current residual */
@@ -416,7 +421,7 @@ int SptfqmrSolve(SptfqmrMem mem, void *A_data, N_Vector x, N_Vector b,
 	  if (scale_b) N_VProd(sb, vtemp3, vtemp3);
 	}
 	N_VLinearSum(ONE, vtemp3, -ONE, vtemp2, vtemp1);
-	*res_norm = r_curr_norm = RSqrt(N_VDotProd(vtemp1, vtemp1));
+	*res_norm = r_curr_norm = SUNRsqrt(N_VDotProd(vtemp1, vtemp1));
 
 	/* Exit inner loop if inequality condition is satisfied 
 	   (meaning exit if we have converged) */
@@ -442,7 +447,7 @@ int SptfqmrSolve(SptfqmrMem mem, void *A_data, N_Vector x, N_Vector b,
     N_VLinearSum(ONE, r_[1], beta, q_, u_);
 
     /* p_ = u_+beta*(q_+beta*p_) */
-    N_VLinearSum(beta, q_, SQR(beta), p_, p_);
+    N_VLinearSum(beta, q_, SUNSQR(beta), p_, p_);
     N_VLinearSum(ONE, u_, ONE, p_, p_);
 
     /* v_ = A*p_ */
diff --git a/sundialsTB/Contents.m b/sundialsTB/Contents.m
deleted file mode 100644
index 6076ead..0000000
--- a/sundialsTB/Contents.m
+++ /dev/null
@@ -1,6 +0,0 @@
-% sundialsTB v.2.4.0 - Matlab interfaces to SUNDIALS solvers
-%
-% sundialsTB provides interfaces to the CVODES, IDAS, and KINSOL
-%   solvers in SUNDIALS.
-%
-% See also cvodes, idas, kinsol, nvector, putils
diff --git a/sundialsTB/LICENSE b/sundialsTB/LICENSE
deleted file mode 100644
index 9993068..0000000
--- a/sundialsTB/LICENSE
+++ /dev/null
@@ -1,60 +0,0 @@
-Copyright (c) 2005, The Regents of the University of California. 
-Produced at the Lawrence Livermore National Laboratory.
-Written by Radu Serban, radu at llnl.gov
- 
-UCRL-CODE-155978
-All rights reserved. 
-
-This file is part of sundialsTB.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the disclaimer below.
-
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the disclaimer (as noted below)
-in the documentation and/or other materials provided with the
-distribution.
-
-3. Neither the name of the UC/LLNL nor the names of its contributors
-may be used to endorse or promote products derived from this software
-without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-REGENTS OF THE UNIVERSITY OF CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Additional BSD Notice
----------------------
-1. This notice is required to be provided under our contract with
-the U.S. Department of Energy (DOE). This work was produced at the
-University of California, Lawrence Livermore National Laboratory
-under Contract No. W-7405-ENG-48 with the DOE.
-
-2. Neither the United States Government nor the University of
-California nor any of their employees, makes any warranty, express
-or implied, or assumes any liability or responsibility for the
-accuracy, completeness, or usefulness of any information, apparatus,
-product, or process disclosed, or represents that its use would not
-infringe privately-owned rights.
-
-3. Also, reference herein to any specific commercial products,
-process, or services by trade name, trademark, manufacturer or
-otherwise does not necessarily constitute or imply its endorsement,
-recommendation, or favoring by the United States Government or the
-University of California. The views and opinions of authors expressed
-herein do not necessarily state or reflect those of the United States
-Government or the University of California, and shall not be used for
-advertising or product endorsement purposes.
diff --git a/sundialsTB/README b/sundialsTB/README
deleted file mode 100644
index 19b3fda..0000000
--- a/sundialsTB/README
+++ /dev/null
@@ -1,219 +0,0 @@
-                         sundialsTB
-                A MATLAB interface to SUNDIALS
-                   Release 2.5.0, March 2012
-
-                        Radu Serban
-         Center for Applied Scientific Computing, LLNL
-
-
-sundialsTB provides a MATLAB interface to the following SUNDIALS solvers:
-  CVODES: a variable-order, variable-step ODE solver with sensitivity 
-          analysis capabilities
-  IDAS:   a variable-order, variable-sttp DAE and implicit ODE solver
-  KINSOL: a nonlinear system solver
-
-The core of each MATLAB interface in sundialsTB is a single mex file 
-which interfaces to the various user-callable functions for that solver. 
-However, this mex file should not be called directly, but rather through 
-the user-callable functions provided for each MATLAB interface.
-
-The distribution file also contains a user guide, as well as several examples. 
-
-sundialsTB v. 2.5.0 requires SUNDIALS v 2.5.0 and, optionally (for parallel 
-support), MPITB with LAM 7.1.1 for MPI-2 features.
-
-SUNDIALS: http://www.llnl.gov/CASC/sundials
-MPITB:    http://atc.ugr.es/javier-bin/mpitb_eng
-LAM:      http://www.lam-mpi.org/
-
-
-A. Documentation
-----------------
-
-/sundialsTB/doc contains a PDF file for the sundialsTB User Guide.
-
-
-B. Installation
----------------
-
-B.1. Compilation and installation of sundialsTB
-
-As of version 2.3.0, sundialsTB is distributed only with the complete SUNDIALS 
-package and, on *nix systems (or under cygwin in Windows), the Matlab toolbox 
-can be configured, built, and installed using the main SUNDIALS configure script. 
-For details see the SUNDIALS file INSTALL_NOTES. 
-
-For systems that do not support configure scripts (or if the configure script 
-fails to configure sundialsTB), we provide a Matlab script (install_STB.m) which 
-can be used to build and install sundialsTB from within Matlab. In the sequel, 
-we assume that the SUNDIALS package was unpacked under the directory 'srcdir'. 
-The sundialsTB files are therefore in 'srcdir'/sundialsTB. 
-
-To facilitate the compilation of sundialsTB on platforms that do not have
-a make system, we rely on Matlab's mex command. Compilation of sundialsTB
-is done by running from under Matlab the install_STB.m script which is
-present in the sundialsTB top directory.
-
-1. Launch matlab in sundialsTB:
-     % cd 'srcdir'/sundialsTB
-     % matlab
-
-2. Run the install_STB matlab script.
-
-     Note that parallel support will be compiled into the MEX files only if
-     ALL of the following conditions are met:
-     - $LAMHOME is defined
-     - $MPITB_ROOT is defined
-     - 'srcdir'/src/nvec_par exists 
-
-     After the MEX files are generated, you will be asked if you wish to install 
-     the sundialsTB toolbox. If you answer yes, you will be then asked for the
-     installation directory (called in the sequel 'instdir'). 
-     To install sundialsTB for all Matlab users (not usual), assuming Matlab is 
-     installed under /usr/local/matlab7, specify
-        'instdir' = /usr/local/matlab7/toolbox
-     To install sundialsTB for just one user (usual configuration), install      
-     sundialsTB under a directory of your choice (typically under your 'matlab'
-     working directory). In other words, specify
-        'instdir' = /home/user/matlab
-
-
-B.2. Configuring Matlab's startup
-
-After a successful installation, a sundialsTB.m startup script is generated
-in 'instdir'/sundialsTB. This file must be called by Matlab at initialization.
-
-If sundialsTB was installed for all Matlab users (not usual), add the sundialsTB 
-startup to the system-wide startup file (by linking or copying):
-
-     % cd /usr/local/matlab7/toolbox/local
-     % ln -s ../sundialsTB/startup_STB.m .
-
-     and add these lines to your original local startup.m
-
-     % SUNDIALS Toolbox startup M-file, if it exists.
-     if exist('startup_STB','file')
-        startup_STB
-     end
-
-If sundialsTB was installed for just one user (usual configuration) and
-assuming you do not need to keep any previously existing startup.m, link 
-or copy the startup_STB.m script to your working 'matlab' directory:
-
-     % cd ~/matlab
-     % ln -s sundialsTB/startup_STB.m startup.m
-
-If you already have a startup.m, use the method described above, first linking 
-(or copying) startup_STB.m to the destination subdir and then editing 
-~/matlab/startup.m to run startup_STB.m
-
-B.3. Testing the installation
-
-If everything went fine, you should now be able to try one of the CVODES, IDAS,
-or KINSOL examples (in matlab, type 'help cvodes', 'help idas', or 'help kinsol' 
-to see a list of all examples available). For example, cd to the CVODES serial 
-example directory:
-     % cd 'instdir'/sundialsTB/cvode/examples_ser
-and then launch matlab and execute cvdx.
-
-
-C. References
--------------
-
-[1] R. Serban, "sundialsTB, a MATLAB Interface to SUNDIALS", 
-    LLNL technical report UCRL-SM-212121, May 2005.
-
-[2] A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, 
-    D. E. Shumaker, and C. S. Woodward, "SUNDIALS, Suite of Nonlinear and 
-    Differential/Algebraic Equation Solvers," ACM Trans. Math. Softw., 
-    31(3), pp. 363-396, 2005.
-
-
-D. Releases
------------
-
-v. 2.5.0 - Mar. 2012
-v. 2.4.0 - May  2009
-v. 2.3.0 - Nov. 2006
-v. 2.2.0 - Mar. 2006
-v. 2.1.1 - May. 2005 (first sundialsTB release)
-
-E. Revision History
--------------------
-
-v. 2.4.0 (May 2009) ---> v. 2.5.0 (Mar. 2012)
----------------------------------------------------------
-
-- Minor bug fixes:
-  - in kimOpts.c, fixed lines setting etachoice.
-  - in cvm.c and idm.c, fixed size of rootsfound array; added lines to free
-    rootsfound and ckpnt arrays when done using each.
-  - in all .c files, changed mxCreateScalarDouble to mxCreateDoubleScalar.
-  - in all .c files, changed problem sizes, bandwidths, etc. from type int
-    to type long int.
-
-
-- Minor fixes to documentation
-
-v. 2.3.0 (Nov. 2006) ---> v. 2.4.0 (May 2009)
----------------------------------------------------------
-
-- New features
-  - Updated IDAS monitoring functionality.
-  - Added functionality to reinitialize adjoint module.
-  - Added functions to allow changing optional inputs during integration.
-  - Added option to disable error message output.
-
-- Bug fixes
-  - Minor fixes to installation files.
-  - Bug fix in argument order in IDAS dense and band Jacobian interfaces.
-  - Fixed bug in CVODES reinitialization.
-  - Fixed a bug in initialization of backward quadratures in IDAS.
-
-- Changes to user interface
-  - Updated interfaces to linear solvers corresponding to DLS/SPILS split.
-  - Added several missing wrapper functions.
-  - Changed CVODES API to require LMM and ITER.
-  - Added return flags to all interface functions.
-
--Other
-  - Added CVODES examples showing integration over a discontinuity.
-  - Added two KINSOL examples.
-  - Relocated user function type files to function_types subdirectories.
-  - Reorganized IDAS files to expose Sensitivity Analysis abilities.
-
-v. 2.2.0 (Mar. 2006) ---> v. 2.3.0 (Nov. 2006)
----------------------------------------------------------
-
-- New features
-  - added IDAS module, a MEX interface to the SUNDIALS IDA integrator.
-  - startup_STB.m is automatically created from a template.
-
-- Bug fixes
-  - install_STB.m was modified to be more robust w.r.t. file naming 
-    conventions omn different platforms.
-
-- Changes to user interface
-  - updated to reflect changes to the SUNDIALS libraries in v.2.3.0
-
-v. 2.1.1 (May. 2005) ---> v. 2.2.0 (Mar. 2006)
----------------------------------------------------------
-
-- New features
-  - modified installation procedure to use a Matlab script
-  - added sample Matlab startup file
-  - expanded CVodeMonitor
-  - added interface to KINSOL's performance monitoring function
-    ('Verbose' option to KINSetOptions)
-
-- Bug fixes
-  - fixed bug in interface to quadrature integration which was causing
-    a segmentatin violation when monitoring was turned on.
-
-- Changes to user interface
-  - updated to reflect changes to the SUNDIALS libraries in v.2.2.0
-  - changed the interface for sensitivity analysis (both forward and
-    adjoint) to follow more closely the CVODES calling sequence
-  - optional inputs for forward sensitivity analysis are now provided
-    through a separate function, CVodeSetFSAOptions
-  - removed NVM mex interface
\ No newline at end of file
diff --git a/sundialsTB/cvodes/CVode.m b/sundialsTB/cvodes/CVode.m
deleted file mode 100644
index 777e5bd..0000000
--- a/sundialsTB/cvodes/CVode.m
+++ /dev/null
@@ -1,55 +0,0 @@
-function [varargout] = CVode(tout, itask)
-%CVode integrates the ODE.
-%
-%   Usage: [STATUS, T, Y] = CVode ( TOUT, ITASK ) 
-%          [STATUS, T, Y, YS] = CVode ( TOUT, ITASK )
-%          [STATUS, T, Y, YQ] = CVode  (TOUT, ITASK )
-%          [STATUS, T, Y, YQ, YS] = CVode ( TOUT, ITASK )
-%
-%   If ITASK is 'Normal', then the solver integrates from its current internal 
-%   T value to a point at or beyond TOUT, then interpolates to T = TOUT and returns 
-%   Y(TOUT). If ITASK is 'OneStep', then the solver takes one internal time step 
-%   and returns in Y the solution at the new internal time. In this case, TOUT 
-%   is used only during the first call to CVode to determine the direction of 
-%   integration and the rough scale of the problem. In either case, the time 
-%   reached by the solver is returned in T.
-%
-%   If quadratures were computed (see CVodeQuadInit), CVode will return their
-%   values at T in the vector YQ.
-%
-%   If sensitivity calculations were enabled (see CVodeSensInit), CVode will 
-%   return their values at T in the matrix YS. Each row in the matrix YS
-%   represents the sensitivity vector with respect to one of the problem parameters.
-%
-%   In ITASK =' Normal' mode, to obtain solutions at specific times T0,T1,...,TFINAL
-%   (all increasing or all decreasing) use TOUT = [T0 T1  ... TFINAL]. In this case
-%   the output arguments Y and YQ are matrices, each column representing the solution
-%   vector at the corresponding time returned in the vector T. If computed, the 
-%   sensitivities are eturned in the 3-dimensional array YS, with YS(:,:,I) representing
-%   the sensitivity vectors at the time T(I).
-%
-%   On return, STATUS is one of the following:
-%     0: successful CVode return.
-%     1: CVode succeded and returned at tstop.
-%     2: CVode succeeded and found one or more roots.
-%    -1: an error occurred (see printed message).
-%
-%   See also CVodeSetOptions, CVodeGetStats
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.7 $Date: 2011/06/01 22:06:42 $
-
-mode = 20;
-
-if nargin ~= 2
-  error('Wrong number of input arguments');
-end
-
-if nargout < 3 || nargout > 5
-  error('Wrong number of output arguments');
-end
-
-varargout = cell (nargout, 1);
-
-[varargout{:}] = cvm(mode,tout,itask);
diff --git a/sundialsTB/cvodes/CVodeAdjInit.m b/sundialsTB/cvodes/CVodeAdjInit.m
deleted file mode 100644
index 06f0045..0000000
--- a/sundialsTB/cvodes/CVodeAdjInit.m
+++ /dev/null
@@ -1,23 +0,0 @@
-function status = CVodeAdjInit(steps, interp)
-%CVodeAdjInit allocates and initializes memory for ASA with CVODES.
-%
-%   Usage: CVodeAdjInit(STEPS, INTEPR) 
-%
-%   STEPS    specifies the (maximum) number of integration steps between two 
-%            consecutive check points.
-%   INTERP   Specifies the type of interpolation used for estimating the forward 
-%            solution during the backward integration phase. INTERP should be
-%            'Hermite', indicating cubic Hermite interpolation, or 'Polynomial',
-%            indicating variable order polynomial interpolation.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:17 $
-
-mode = 4;
-
-if nargin ~= 2
-  error('Wrong number of input arguments');
-end
-
-status = cvm(mode,steps,interp);
diff --git a/sundialsTB/cvodes/CVodeAdjReInit.m b/sundialsTB/cvodes/CVodeAdjReInit.m
deleted file mode 100644
index 1f72dce..0000000
--- a/sundialsTB/cvodes/CVodeAdjReInit.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function status = CVodeAdjReInit()
-%CVodeAdjReInit re-initializes memory for ASA with CVODES.
-%
-%   Usage: CVodeAdjReInit
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:17 $
-
-mode = 14;
-
-status = cvm(mode);
diff --git a/sundialsTB/cvodes/CVodeB.m b/sundialsTB/cvodes/CVodeB.m
deleted file mode 100644
index 9bea87b..0000000
--- a/sundialsTB/cvodes/CVodeB.m
+++ /dev/null
@@ -1,49 +0,0 @@
-function [varargout] = CVodeB(tout,itask)
-%CVodeB integrates all backwards ODEs currently defined.
-%
-%   Usage:  [STATUS, T, YB] = CVodeB ( TOUT, ITASK ) 
-%           [STATUS, T, YB, YQB] = CVodeB ( TOUT, ITASK )
-%
-%   If ITASK is 'Normal', then the solver integrates from its current internal 
-%   T value to a point at or beyond TOUT, then interpolates to T = TOUT and returns 
-%   YB(TOUT). If ITASK is 'OneStep', then the solver takes one internal time step 
-%   and returns in YB the solution at the new internal time. In this case, TOUT 
-%   is used only during the first call to CVodeB to determine the direction of 
-%   integration and the rough scale of the problem. In either case, the time 
-%   reached by the solver is returned in T. 
-%
-%   If quadratures were computed (see CVodeQuadInitB), CVodeB will return their
-%   values at T in the vector YQB.
-%
-%   In ITASK =' Normal' mode, to obtain solutions at specific times T0,T1,...,TFINAL
-%   (all increasing or all decreasing) use TOUT = [T0 T1  ... TFINAL]. In this case
-%   the output arguments YB and YQB are matrices, each column representing the solution
-%   vector at the corresponding time returned in the vector T.
-%
-%   If more than one backward problem was defined, the return arguments are cell
-%   arrays, with T{IDXB}, YB{IDXB}, and YQB{IDXB} corresponding to the backward
-%   problem with index IDXB (as returned by CVodeInitB).
-%
-%   On return, STATUS is one of the following:
-%     0: successful CVodeB return.
-%     1: CVodeB succeded and return at a tstop value (internally set).
-%    -1: an error occurred (see printed message).
-%
-%   See also CVodeSetOptions, CVodeGetStatsB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.7 $Date: 2011/06/01 22:30:55 $
-
-mode = 21;
-
-if nargin ~= 2
-  error('Wrong number of input arguments');
-end
-
-if nargout < 3 || nargout > 4
-  error('Wrong number of output arguments');
-end
-
-varargout = cell (nargout, 1);
-[varargout{:}] = cvm(mode,tout,itask);
diff --git a/sundialsTB/cvodes/CVodeFree.m b/sundialsTB/cvodes/CVodeFree.m
deleted file mode 100644
index 7648eca..0000000
--- a/sundialsTB/cvodes/CVodeFree.m
+++ /dev/null
@@ -1,11 +0,0 @@
-function CVodeFree()
-%CVodeFree deallocates memory for the CVODES solver.
-%
-%   Usage:  CVodeFree
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2007/05/11 18:51:31 $
-
-mode = 40;
-cvm(mode);
diff --git a/sundialsTB/cvodes/CVodeGet.m b/sundialsTB/cvodes/CVodeGet.m
deleted file mode 100644
index a83e88f..0000000
--- a/sundialsTB/cvodes/CVodeGet.m
+++ /dev/null
@@ -1,36 +0,0 @@
-function [output, status] = CVodeGet(key, varargin)
-%CVodeGet extracts data from the CVODES solver memory.
-%
-%   Usage: RET = CVodeGet ( KEY [, P1 [, P2] ... ]) 
-%
-%   CVodeGet returns internal CVODES information based on KEY. For some values
-%   of KEY, additional arguments may be required and/or more than one output is
-%   returned.
-%
-%   KEY is a string and should be one of:
-%    o DerivSolution - Returns a vector containing the K-th order derivative
-%       of the solution at time T. The time T and order K must be passed through 
-%       the input arguments P1 and P2, respectively:
-%       DKY = CVodeGet('DerivSolution', T, K)
-%    o ErrorWeights - Returns a vector containing the current error weights.
-%       EWT = CVodeGet('ErrorWeights')
-%    o CheckPointsInfo - Returns an array of structures with check point information.
-%       CK = CVodeGet('CheckPointInfo)
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.6 $Date: 2007/12/05 21:58:17 $
-
-mode = 32;
-
-if strcmp(key, 'DerivSolution')
-  t = varargin{1};
-  k = varargin{2};
-  [output, status] = cvm(mode, 1, t, k);
-elseif strcmp(key, 'ErrorWeights')
-  [output, status] = cvm(mode, 2);
-elseif strcmp(key, 'CheckPointsInfo')
-  [output, status] = cvm(mode, 4);
-else
-  error('CVodeGet:: Unrecognized key');
-end
\ No newline at end of file
diff --git a/sundialsTB/cvodes/CVodeGetStats.m b/sundialsTB/cvodes/CVodeGetStats.m
deleted file mode 100644
index 9ef850b..0000000
--- a/sundialsTB/cvodes/CVodeGetStats.m
+++ /dev/null
@@ -1,86 +0,0 @@
-function [si, status] = CVodeGetStats()
-%CVodeGetStats returns run statistics for the CVODES solver.
-%
-%   Usage: STATS = CVodeGetStats
-%
-%Fields in the structure STATS
-%
-%o nst      - number of integration steps
-%o nfe      - number of right-hand side function evaluations
-%o nsetups  - number of linear solver setup calls
-%o netf     - number of error test failures
-%o nni      - number of nonlinear solver iterations
-%o ncfn     - number of convergence test failures
-%o qlast    - last method order used
-%o qcur     - current method order
-%o h0used   - actual initial step size used
-%o hlast    - last step size used
-%o hcur     - current step size
-%o tcur     - current time reached by the integrator
-%o RootInfo - strucutre with rootfinding information
-%o QuadInfo - structure with quadrature integration statistics
-%o LSInfo   - structure with linear solver statistics
-%o FSAInfo  - structure with forward sensitivity solver statistics
-%
-%If rootfinding was requested, the structure RootInfo has the following fields
-%
-%o nge   - number of calls to the rootfinding function
-%o roots - array of integers (a value of 1 in the i-th component means that the
-%          i-th rootfinding function has a root (upon a return with status=2 from
-%          CVode).
-%
-%If quadratures were present, the structure QuadInfo has the following fields
-%
-%o nfQe  - number of quadrature integrand function evaluations
-%o netfQ - number of error test failures for quadrature variables
-%
-%The structure LSinfo has different fields, depending on the linear solver used.
-%
-%  Fields in LSinfo for the 'Dense' linear solver
-%
-%o name - 'Dense'
-%o njeD - number of Jacobian evaluations
-%o nfeD - number of right-hand side function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'Diag' linear solver
-%
-%o name  - 'Diag'
-%o nfeDI - number of right-hand side function evaluations for difference-quotient
-%          Jacobian approximation
-%
-%  Fields in LSinfo for the 'Band' linear solver
-%
-%o name - 'Band'
-%o njeB - number of Jacobian evaluations
-%o nfeB - number of right-hand side function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'GMRES' and 'BiCGStab' linear solvers
-%
-%o name  - 'GMRES' or 'BiCGStab'
-%o nli   - number of linear solver iterations
-%o npe   - number of preconditioner setups
-%o nps   - number of preconditioner solve function calls
-%o ncfl  - number of linear system convergence test failures
-%o njeSG - number of Jacobian-vector product evaluations
-%o nfeSG - number of right-hand side function evaluations for difference-quotient
-%          Jacobian-vector product approximation
-%
-%If forward sensitivities were computed, the structure FSAInfo has the 
-%following fields
-%
-%o nfSe      - number of sensitivity right-hand side evaluations
-%o nfeS      - number of right-hand side evaluations for difference-quotient
-%              sensitivity right-hand side approximation
-%o nsetupsS  - number of linear solver setups triggered by sensitivity variables
-%o netfS     - number of error test failures for sensitivity variables
-%o nniS      - number of nonlinear solver iterations for sensitivity variables
-%o ncfnS     - number of convergence test failures due to sensitivity variables
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.5 $Date: 2007/12/05 21:58:17 $
-
-mode = 30;
-[si, status] = cvm(mode);
diff --git a/sundialsTB/cvodes/CVodeGetStatsB.m b/sundialsTB/cvodes/CVodeGetStatsB.m
deleted file mode 100644
index 7b28595..0000000
--- a/sundialsTB/cvodes/CVodeGetStatsB.m
+++ /dev/null
@@ -1,76 +0,0 @@
-function [si, status] = CVodeGetStatsB(idxB)
-%CVodeGetStatsB returns run statistics for the backward CVODES solver.
-%
-%   Usage: STATS = CVodeGetStatsB( IDXB ) 
-%
-%   IDXB     is the index of the backward problem, returned by
-%            CVodeInitB.
-%
-%Fields in the structure STATS
-%
-%o nst - number of integration steps
-%o nfe - number of right-hand side function evaluations
-%o nsetups - number of linear solver setup calls
-%o netf - number of error test failures
-%o nni - number of nonlinear solver iterations
-%o ncfn - number of convergence test failures
-%o qlast - last method order used
-%o qcur - current method order
-%o h0used - actual initial step size used
-%o hlast - last step size used
-%o hcur - current step size
-%o tcur - current time reached by the integrator
-%o QuadInfo - structure with quadrature integration statistics
-%o LSInfo - structure with linear solver statistics
-%
-%The structure LSinfo has different fields, depending on the linear solver used.
-%
-%If quadratures were present, the structure QuadInfo has the following fields
-%
-%o nfQe - number of quadrature integrand function evaluations
-%o netfQ - number of error test failures for quadrature variables
-%
-%  Fields in LSinfo for the 'Dense' linear solver
-%
-%o name - 'Dense'
-%o njeD - number of Jacobian evaluations
-%o nfeD - number of right-hand side function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'Diag' linear solver
-%
-%o name - 'Diag'
-%o nfeDI - number of right-hand side function evaluations for difference-quotient
-%          Jacobian approximation
-%
-%  Fields in LSinfo for the 'Band' linear solver
-%
-%o name - 'Band'
-%o njeB - number of Jacobian evaluations
-%o nfeB - number of right-hand side function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'GMRES' and 'BiCGStab' linear solvers
-%
-%o name - 'GMRES' or 'BiCGStab'
-%o nli - number of linear solver iterations
-%o npe - number of preconditioner setups
-%o nps - number of preconditioner solve function calls
-%o ncfl - number of linear system convergence test failures
-%o njeSG - number of Jacobian-vector product evaluations
-%o nfeSG -  number of right-hand side function evaluations for difference-quotient
-%          Jacobian-vector product approximation
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.5 $Date: 2007/12/05 21:58:17 $
-
-mode = 31;
-
-if nargin ~= 1
-  error('Wrong number of input arguments');
-end
-
-idxB = idxB-1;
-[si, status] = cvm(mode, idxB);
-
diff --git a/sundialsTB/cvodes/CVodeInit.m b/sundialsTB/cvodes/CVodeInit.m
deleted file mode 100644
index 88128af..0000000
--- a/sundialsTB/cvodes/CVodeInit.m
+++ /dev/null
@@ -1,42 +0,0 @@
-function status = CVodeInit(fct, lmm, nls, t0, y0, options)
-%CVodeInit allocates and initializes memory for CVODES.
-%
-%   Usage: CVodeInit ( ODEFUN, LMM, NLS, T0, Y0 [, OPTIONS ] ) 
-%
-%   ODEFUN   is a function defining the ODE right-hand side: y' = f(t,y).
-%            This function must return a vector containing the current 
-%            value of the righ-hand side.
-%   LMM      is the Linear Multistep Method ('Adams' or 'BDF')
-%   NLS      is the type of nonlinear solver used ('Functional' or 'Newton')
-%   T0       is the initial value of t.
-%   Y0       is the initial condition vector y(t0).  
-%   OPTIONS  is an (optional) set of integration options, created with
-%            the CVodeSetOptions function. 
-%
-%   See also: CVodeSetOptions, CVRhsFn 
-% 
-%   NOTES:
-%    1) The 'Functional' nonlinear solver is best suited for non-stiff
-%       problems, in conjunction with the 'Adams' linear multistep method,
-%       while 'Newton' is better suited for stiff problems, using the 'BDF'
-%       method.
-%    2) When using the 'Newton' nonlinear solver, a linear solver is also
-%       required. The default one is 'Dense', indicating the use of direct
-%       dense linear algebra (LU factorization). A different linear solver
-%       can be specified through the option 'LinearSolver' to CVodeSetOptions.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2007/12/05 21:58:17 $
-
-mode = 1;
-
-if nargin < 5
-  error('Too few input arguments');
-end
-
-if nargin < 6
-  options = [];
-end
-
-status = cvm(mode, fct, lmm, nls, t0, y0, options);
diff --git a/sundialsTB/cvodes/CVodeInitB.m b/sundialsTB/cvodes/CVodeInitB.m
deleted file mode 100644
index 59110db..0000000
--- a/sundialsTB/cvodes/CVodeInitB.m
+++ /dev/null
@@ -1,37 +0,0 @@
-function [idxB, status] = CVodeInitB(fctB, lmmB, nlsB, tB0, yB0, optionsB)
-%CVodeInitB allocates and initializes backward memory for CVODES.
-%
-%   Usage:   IDXB = CVodeInitB ( FCTB, LMMB, NLSB, TB0, YB0 [, OPTIONSB] )
-%
-%   FCTB     is a function defining the adjoint ODE right-hand side.
-%            This function must return a vector containing the current 
-%            value of the adjoint ODE righ-hand side.
-%   LMMB     is the Linear Multistep Method ('Adams' or 'BDF')
-%   NLSB     is the type of nonlinear solver used ('Functional' or 'Newton')
-%   TB0      is the final value of t.
-%   YB0      is the final condition vector yB(tB0).  
-%   OPTIONSB is an (optional) set of integration options, created with
-%            the CVodeSetOptions function. 
-%
-%   CVodeInitB returns the index IDXB associated with this backward
-%   problem. This index must be passed as an argument to any subsequent
-%   functions related to this backward problem.
-%
-%   See also: CVodeSetOptions, CVodeInit, CVRhsFnB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 5;
-
-if nargin < 5
-  error('Too few input arguments');
-end
-
-if nargin < 6
-  optionsB = [];
-end
-
-[idxB, status] = cvm(mode, fctB, lmmB, nlsB, tB0, yB0, optionsB);
-idxB = idxB+1;
diff --git a/sundialsTB/cvodes/CVodeMonitor.m b/sundialsTB/cvodes/CVodeMonitor.m
deleted file mode 100644
index edef5bf..0000000
--- a/sundialsTB/cvodes/CVodeMonitor.m
+++ /dev/null
@@ -1,796 +0,0 @@
-function [new_data] = CVodeMonitor(call, T, Y, YQ, YS, data)
-%CVodeMonitor is the default CVODES monitoring function.
-%   To use it, set the Monitor property in CVodeSetOptions to
-%   'CVodeMonitor' or to @CVodeMonitor and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to CVodeSetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see CVodeGetStats)
-%     o mode [ {'graphical'} | 'text' | 'both' ] 
-%         In graphical mode, plot the evolutions of the above quantities.
-%         In text mode, print a table.
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o sensi [ true | {false} ]
-%         If true and if FSA is enabled, plot sensitivity components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also CVodeSetOptions, CVMonitorFn
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to CVodeSetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.6 $Date: 2007/08/21 17:42:38 $
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.grph
-      if data.stats | data.cntr
-        data.hfg = figure;
-      end
-%     Number of subplots in figure hfg
-      if data.stats
-        data.npg = data.npg + 2;
-      end
-      if data.cntr
-        data.npg = data.npg + 1;
-      end
-    end
-    
-    if data.text
-      if data.cntr | data.stats
-        data.hft = figure;
-      end
-    end
-
-    if data.sol | data.sensi
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y and YS for additional initializations
-  
-  if data.first
-
-    if isempty(YS)
-      data.sensi = false;
-    end
-    
-    if data.sol | data.sensi
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-      if data.sensi
-        data.Ns = size(YS,2);
-        data.ys = zeros(data.N, data.Ns, data.updt);
-        data.nps = data.nps + data.Ns;
-      end
-      
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  Ns   = data.Ns;
-  y    = data.y;
-  ys   = data.ys;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = CVodeGetStats;
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-  if data.sensi
-    for k = 1:Ns
-      for j = 1:N
-        ys(j,k,n) = YS(data.select(j),k);
-      end
-    end
-  end
-  
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if (data.stats | data.cntr) & data.text
-      text_init(n, hft, data.stats, data.cntr, ...
-                t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol | data.sensi
-      sol_init(n, hfs, nps, data.sol, data.sensi,  ...
-               N, Ns, t, y, ys);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if (data.stats | data.cntr) & data.text
-      text_update(n, hft, data.stats, data.cntr, ...
-                  t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, data.sensi, N, Ns, t, y, ys);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr) & data.grph
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol | data.sensi
-      sol_final(hfs, nps, data.sol, data.sensi, N, Ns);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.ys   = ys;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'mode')
-  data.mode = 'graphical';
-end
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'sensi')
-  data.sensi = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-data.grph = true;
-data.text = true;
-if strcmp(data.mode,'graphical')
-  data.text = false;
-end
-if strcmp(data.mode,'text')
-  data.grph = false;
-end
-
-if ~data.sol & ~data.sensi
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.Ns = 0;
-data.y = 0;
-data.ys = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-fig_name = 'CVODES run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hfg);
-set(hfg,'Name',fig_name);
-set(hfg,'color',[1 1 1]);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '\rightarrow   t   \rightarrow';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') abs(h(1:n))];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') q(1:n)];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-% Attention: Children are loaded in reverse order!
-  xd = [get(hc(1),'XData') t(1:n)];
-  yd = [get(hc(1),'YData') ncfn(1:n)];
-  set(hc(1), 'XData', xd, 'YData', yd);
-  yd = [get(hc(2),'YData') netf(1:n)];
-  set(hc(2), 'XData', xd, 'YData', yd);
-  yd = [get(hc(3),'YData') nni(1:n)];
-  set(hc(3), 'XData', xd, 'YData', yd);
-  yd = [get(hc(4),'YData') nfe(1:n)];
-  set(hc(4), 'XData', xd, 'YData', yd);
-  yd = [get(hc(5),'YData') nst(1:n)];
-  set(hc(5), 'XData', xd, 'YData', yd);
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = text_init(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-fig_name = 'CVODES run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hft);
-set(hft,'Name',fig_name);
-set(hft,'color',[1 1 1]);
-set(hft,'MenuBar','none');
-set(hft,'Resize','off');
-
-% Create text box
-
-margins=[10 10 50 50]; % left, right, top, bottom
-pos=get(hft,'position');
-tbpos=[margins(1) margins(4) pos(3)-margins(1)-margins(2) ...
-       pos(4)-margins(3)-margins(4)];
-tbpos(tbpos<1)=1;
-
-htb=uicontrol(hft,'style','listbox','position',tbpos,'tag','textbox');
-set(htb,'BackgroundColor',[1 1 1]);
-set(htb,'SelectionHighlight','off');
-set(htb,'FontName','courier');
-
-% Create table head
-
-tpos = [tbpos(1) tbpos(2)+tbpos(4)+10 tbpos(3) 20];
-ht=uicontrol(hft,'style','text','position',tpos,'tag','text');
-set(ht,'BackgroundColor',[1 1 1]);
-set(ht,'HorizontalAlignment','left');
-set(ht,'FontName','courier');
-newline = '   time         step      order  |    nst   nfe   nni  netf  ncfn';
-set(ht,'String',newline);
-
-% Create OK button
-  
-bsize=[60,28];
-badjustpos=[0,25];
-bpos=[pos(3)/2-bsize(1)/2+badjustpos(1) -bsize(2)/2+badjustpos(2)...
-      bsize(1) bsize(2)];
-bpos=round(bpos);
-bpos(bpos<1)=1;
-hb=uicontrol(hft,'style','pushbutton','position',bpos,...
-             'string','Close','tag','okaybutton');
-set(hb,'callback','close');
-
-% Save handles
-
-handles=guihandles(hft);
-guidata(hft,handles);
-
-for i = 1:n
-  newline = '';
-  if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = text_update(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-figure(hft);
-
-handles=guidata(hft);
-
-for i = 1:n
-   if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-fig_name = 'CVODES solution';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-
-figure(hfs);
-set(hfs,'Name',fig_name);
-set(hfs,'color',[1 1 1]);
-
-% Time label
-
-tlab = '\rightarrow   t   \rightarrow';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-    hold on;
-      
-    ys_crt = ys(:,is,1:n);
-    for i = 1:N
-      hp = plot(t(1:n),ys_crt(i,1:n),'-');
-      ic = 1+(i-1)*floor(ncols/N);
-      set(hp,'Color',map(ic,:));
-    end
-    box on;
-    grid on;
-    xlabel(tlab);
-    str = sprintf('s_{%d}',is); ylabel(str);
-    str = sprintf('Sensitivity %d',is); title(str);
-    
-  end
-  
-end
-
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') t(1:n)];
-% Attention: Children are loaded in reverse order!
-  for i = 1:N
-    yd = [get(hc(i),'YData') y(N-i+1,1:n)];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-  
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    ys_crt = ys(:,is,:);
-    
-    hc = get(gca,'Children');
-    xd = [get(hc(1),'XData') t(1:n)];
-%   Attention: Children are loaded in reverse order!
-    for i = 1:N
-      yd = [get(hc(i),'YData') ys_crt(N-i+1,1:n)];
-      set(hc(i), 'XData', xd, 'YData', yd);
-    end
-    
-  end
-  
-end
-
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, sensi, N, Ns)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    hc = get(gca,'Children');
-    xd = get(hc(1),'XData');
-    set(gca,'XLim',sort([xd(1) xd(end)]));
-
-    ylim = get(gca,'YLim');
-    addon = 0.1*abs(ylim(2)-ylim(1));
-    ylim(1) = ylim(1) + sign(ylim(1))*addon;
-    ylim(2) = ylim(2) + sign(ylim(2))*addon;
-    set(gca,'YLim',ylim);
-  
-    for i = 1:N
-      cstring{i} = sprintf('s%d_{%d}',is,i);
-    end
-    legend(cstring);
-    
-  end
-  
-end
-
-drawnow
diff --git a/sundialsTB/cvodes/CVodeMonitorB.m b/sundialsTB/cvodes/CVodeMonitorB.m
deleted file mode 100644
index 075eacc..0000000
--- a/sundialsTB/cvodes/CVodeMonitorB.m
+++ /dev/null
@@ -1,697 +0,0 @@
-function [new_data] = CVodeMonitorB(call, idxB, T, Y, YQ, data)
-%CVodeMonitorB is the default CVODES monitoring function for backward problems.
-%   To use it, set the Monitor property in CVodeSetOptions to
-%   'CVodeMonitorB' or to @CVodeMonitorB and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to CVodeSetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see CVodeGetStats)
-%     o mode [ {'graphical'} | 'text' | 'both' ] 
-%         In graphical mode, plot the evolutions of the above quantities.
-%         In text mode, print a table.
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also CVodeSetOptions, CVMonitorFnB
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to CVodeSetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/05/11 18:51:32 $
-
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.grph
-      if data.stats | data.cntr
-        data.hfg = figure;
-      end
-%     Number of subplots in figure hfg
-      if data.stats
-        data.npg = data.npg + 2;
-      end
-      if data.cntr
-        data.npg = data.npg + 1;
-      end
-    end
-    
-    if data.text
-      if data.cntr | data.stats
-        data.hft = figure;
-      end
-    end
-
-    if data.sol
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y for additional initializations
-  
-  if data.first
-
-    if data.sol
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  y    = data.y;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = CVodeGetStatsB(idxB);
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if (data.stats | data.cntr) & data.text
-      text_init(n, hft, data.stats, data.cntr, ...
-                t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol
-      sol_init(n, hfs, nps, data.sol, ...
-               N, t, y);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if (data.stats | data.cntr) & data.text
-      text_update(n, hft, data.stats, data.cntr, ...
-                  t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, N, t, y);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr) & data.grph
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol
-      sol_final(hfs, nps, data.sol, N);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'mode')
-  data.mode = 'graphical';
-end
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-data.grph = true;
-data.text = true;
-if strcmp(data.mode,'graphical')
-  data.text = false;
-end
-if strcmp(data.mode,'text')
-  data.grph = false;
-end
-
-if ~data.sol
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.y = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-fig_name = 'CVODES run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hfg);
-set(hfg,'Name',fig_name);
-set(hfg,'color',[1 1 1]);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '\leftarrow   t   \leftarrow';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') abs(h(1:n))];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') q(1:n)];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-% Attention: Children are loaded in reverse order!
-  xd = [get(hc(1),'XData') t(1:n)];
-  yd = [get(hc(1),'YData') ncfn(1:n)];
-  set(hc(1), 'XData', xd, 'YData', yd);
-  yd = [get(hc(2),'YData') netf(1:n)];
-  set(hc(2), 'XData', xd, 'YData', yd);
-  yd = [get(hc(3),'YData') nni(1:n)];
-  set(hc(3), 'XData', xd, 'YData', yd);
-  yd = [get(hc(4),'YData') nfe(1:n)];
-  set(hc(4), 'XData', xd, 'YData', yd);
-  yd = [get(hc(5),'YData') nst(1:n)];
-  set(hc(5), 'XData', xd, 'YData', yd);
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = text_init(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-fig_name = 'CVODES run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hft);
-set(hft,'Name',fig_name);
-set(hft,'color',[1 1 1]);
-set(hft,'MenuBar','none');
-set(hft,'Resize','off');
-
-% Create text box
-
-margins=[10 10 50 50]; % left, right, top, bottom
-pos=get(hft,'position');
-tbpos=[margins(1) margins(4) pos(3)-margins(1)-margins(2) ...
-       pos(4)-margins(3)-margins(4)];
-tbpos(tbpos<1)=1;
-
-htb=uicontrol(hft,'style','listbox','position',tbpos,'tag','textbox');
-set(htb,'BackgroundColor',[1 1 1]);
-set(htb,'SelectionHighlight','off');
-set(htb,'FontName','courier');
-
-% Create table head
-
-tpos = [tbpos(1) tbpos(2)+tbpos(4)+10 tbpos(3) 20];
-ht=uicontrol(hft,'style','text','position',tpos,'tag','text');
-set(ht,'BackgroundColor',[1 1 1]);
-set(ht,'HorizontalAlignment','left');
-set(ht,'FontName','courier');
-newline = '   time         step      order  |    nst   nfe   nni  netf  ncfn';
-set(ht,'String',newline);
-
-% Create OK button
-  
-bsize=[60,28];
-badjustpos=[0,25];
-bpos=[pos(3)/2-bsize(1)/2+badjustpos(1) -bsize(2)/2+badjustpos(2)...
-      bsize(1) bsize(2)];
-bpos=round(bpos);
-bpos(bpos<1)=1;
-hb=uicontrol(hft,'style','pushbutton','position',bpos,...
-             'string','Close','tag','okaybutton');
-set(hb,'callback','close');
-
-% Save handles
-
-handles=guihandles(hft);
-guidata(hft,handles);
-
-for i = 1:n
-  newline = '';
-  if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = text_update(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-figure(hft);
-
-handles=guidata(hft);
-
-for i = 1:n
-   if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, N, t, y)
-
-fig_name = 'CVODES solution';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-
-figure(hfs);
-set(hfs,'Name',fig_name);
-set(hfs,'color',[1 1 1]);
-
-% Time label
-
-tlab = '\leftarrow   t   \leftarrow';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, N, t, y)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') t(1:n)];
-% Attention: Children are loaded in reverse order!
-  for i = 1:N
-    yd = [get(hc(i),'YData') y(N-i+1,1:n)];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, N)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-drawnow
diff --git a/sundialsTB/cvodes/CVodeMonitorB_octave.m b/sundialsTB/cvodes/CVodeMonitorB_octave.m
deleted file mode 100644
index 66a0e2c..0000000
--- a/sundialsTB/cvodes/CVodeMonitorB_octave.m
+++ /dev/null
@@ -1,545 +0,0 @@
-function [new_data] = CVodeMonitorB(call, idxB, T, Y, YQ, data)
-%CVodeMonitorB is the default CVODES monitoring function for backward problems.
-%   To use it, set the Monitor property in CVodeSetOptions to
-%   'CVodeMonitorB' or to @CVodeMonitorB and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to CVodeSetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see CVodeGetStats)
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also CVodeSetOptions, CVMonitorFnB
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to CVodeSetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/08/21 17:42:38 $
-
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.stats | data.cntr
-      data.hfg = figure;
-    end
-%   Number of subplots in figure hfg
-    if data.stats
-      data.npg = data.npg + 2;
-    end
-    if data.cntr
-      data.npg = data.npg + 1;
-    end
-    
-    if data.sol
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y for additional initializations
-  
-  if data.first
-
-    if data.sol
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  y    = data.y;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = CVodeGetStatsB(idxB);
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr)
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol
-      sol_init(n, hfs, nps, data.sol, ...
-               N, t, y);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr)
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, N, t, y);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr)
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol
-      sol_final(hfs, nps, data.sol, N);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-if ~data.sol
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.y = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '<-   t   <-';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; abs(h(1:n)')];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; q(1:n)'];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  
-  pl = pl+1;
-
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-
-  yd = [get(hc(5),'YData') ; ncfn(1:n)'];
-  set(hc(5), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(4),'YData') ; netf(1:n)'];
-  set(hc(4), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(3),'YData') ; nni(1:n)'];
-  set(hc(3), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(2),'YData') ; nfe(1:n)'];
-  set(hc(2), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(1),'YData') ; nst(1:n)'];
-  set(hc(1), 'XData', xd, 'YData', yd);
-
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, N, t, y)
-
-figure(hfs);
-
-% Time label
-
-tlab = '<-   t   <-';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, N, t, y)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-
-  for i = 1:N
-    yd = [get(hc(i),'YData') ; y(i,1:n)'];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, N)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-drawnow
diff --git a/sundialsTB/cvodes/CVodeMonitor_octave.m b/sundialsTB/cvodes/CVodeMonitor_octave.m
deleted file mode 100644
index c960ea0..0000000
--- a/sundialsTB/cvodes/CVodeMonitor_octave.m
+++ /dev/null
@@ -1,637 +0,0 @@
-function [new_data] = CVodeMonitor(call, T, Y, YQ, YS, data)
-%CVodeMonitor is the default CVODES monitoring function.
-%   To use it, set the Monitor property in CVodeSetOptions to
-%   'CVodeMonitor' or to @CVodeMonitor and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to CVodeSetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see CVodeGetStats)
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o sensi [ true | {false} ]
-%         If true and if FSA is enabled, plot sensitivity components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also CVodeSetOptions, CVMonitorFn
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to CVodeSetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/08/21 17:42:38 $
-
-% NOTES:
-%   - Unlike Matlab, Octave loads children in the normal order
-%   - Unlike Matlab, Octave stores 'XData' and 'YData' as column vectors
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.stats | data.cntr
-      data.hfg = figure;
-    end
-%   Number of subplots in figure hfg
-    if data.stats
-      data.npg = data.npg + 2;
-    end
-    if data.cntr
-      data.npg = data.npg + 1;
-    end
-    
-    if data.sol | data.sensi
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y and YS for additional initializations
-  
-  if data.first
-
-    if isempty(YS)
-      data.sensi = false;
-    end
-    
-    if data.sol | data.sensi
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-      if data.sensi
-        data.Ns = size(YS,2);
-        data.ys = zeros(data.N, data.Ns, data.updt);
-        data.nps = data.nps + data.Ns;
-      end
-      
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  Ns   = data.Ns;
-  y    = data.y;
-  ys   = data.ys;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = CVodeGetStats;
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-  if data.sensi
-    for k = 1:Ns
-      for j = 1:N
-        ys(j,k,n) = YS(data.select(j),k);
-      end
-    end
-  end
-  
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr)
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol | data.sensi
-      sol_init(n, hfs, nps, data.sol, data.sensi, ...
-               N, Ns, t, y, ys);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr)
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, data.sensi, N, Ns, t, y, ys);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr)
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol | data.sensi
-      sol_final(hfs, nps, data.sol, data.sensi, N, Ns);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.ys   = ys;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'sensi')
-  data.sensi = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-if ~data.sol & ~data.sensi
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.Ns = 0;
-data.y = 0;
-data.ys = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '->   t   ->';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; abs(h(1:n)')];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; q(1:n)'];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-  yd = [get(hc(1),'YData') ; ncfn(1:n)'];
-  set(hc(1), 'XData', xd, 'YData', yd);
-  yd = [get(hc(2),'YData') ; netf(1:n)'];
-  set(hc(2), 'XData', xd, 'YData', yd);
-  yd = [get(hc(3),'YData') ; nni(1:n)'];
-  set(hc(3), 'XData', xd, 'YData', yd);
-  yd = [get(hc(4),'YData') ; nfe(1:n)'];
-  set(hc(4), 'XData', xd, 'YData', yd);
-  yd = [get(hc(5),'YData') ; nst(1:n)'];
-  set(hc(5), 'XData', xd, 'YData', yd);
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-figure(hfs);
-
-% Time label
-
-tlab = '->   t   ->';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-    hold on;
-      
-    ys_crt = ys(:,is,1:n);
-    for i = 1:N
-      hp = plot(t(1:n),ys_crt(i,1:n),'-');
-      ic = 1+(i-1)*floor(ncols/N);
-      set(hp,'Color',map(ic,:));
-    end
-    box on;
-    grid on;
-    xlabel(tlab);
-    str = sprintf('s_{%d}',is); ylabel(str);
-    str = sprintf('Sensitivity %d',is); title(str);
-    
-  end
-  
-end
-
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-  for i = 1:N
-    yd = [get(hc(i),'YData') ; y(i,1:n)'];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-  
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    ys_crt = ys(:,is,:);
-    
-    hc = get(gca,'Children');
-    xd = [get(hc(1),'XData') ; t(1:n)'];
-    for i = 1:N
-      yd = [get(hc(i),'YData') ; ys_crt(i,1:n)'];
-      set(hc(i), 'XData', xd, 'YData', yd);
-    end
-    
-  end
-  
-end
-
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, sensi, N, Ns)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    hc = get(gca,'Children');
-    xd = get(hc(1),'XData');
-    set(gca,'XLim',sort([xd(1) xd(end)]));
-
-    ylim = get(gca,'YLim');
-    addon = 0.1*abs(ylim(2)-ylim(1));
-    ylim(1) = ylim(1) + sign(ylim(1))*addon;
-    ylim(2) = ylim(2) + sign(ylim(2))*addon;
-    set(gca,'YLim',ylim);
-  
-    for i = 1:N
-      cstring{i} = sprintf('s%d_{%d}',is,i);
-    end
-    legend(cstring);
-    
-  end
-  
-end
-
-drawnow
diff --git a/sundialsTB/cvodes/CVodeQuadInit.m b/sundialsTB/cvodes/CVodeQuadInit.m
deleted file mode 100644
index 810e522..0000000
--- a/sundialsTB/cvodes/CVodeQuadInit.m
+++ /dev/null
@@ -1,28 +0,0 @@
-function status = CVodeQuadInit(fctQ, yQ0, options)
-%CVodeQuadInit allocates and initializes memory for quadrature integration.
-%
-%   Usage: CVodeQuadInit ( QFUN, YQ0 [, OPTIONS ] ) 
-%
-%   QFUN     is a function defining the righ-hand sides of the quadrature
-%            ODEs yQ' = fQ(t,y).
-%   YQ0      is the initial conditions vector yQ(t0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the CVodeSetQuadOptions function. 
-%
-%   See also: CVodeSetQuadOptions, CVQuadRhsFn 
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 2;
-
-if nargin < 2
-  error('Too few input arguments');
-end
-
-if nargin < 3
-  options = [];
-end
-
-status = cvm(mode, fctQ, yQ0, options);
diff --git a/sundialsTB/cvodes/CVodeQuadInitB.m b/sundialsTB/cvodes/CVodeQuadInitB.m
deleted file mode 100644
index 992d725..0000000
--- a/sundialsTB/cvodes/CVodeQuadInitB.m
+++ /dev/null
@@ -1,32 +0,0 @@
-function status = CVodeQuadInitB(idxB, fctQB, yQB0, optionsB)
-%CVodeQuadInitB allocates and initializes memory for backward quadrature integration.
-%
-%   Usage: CVodeQuadInitB ( IDXB, QBFUN, YQB0 [, OPTIONS ] ) 
-%
-%   IDXB     is the index of the backward problem, returned by
-%            CVodeInitB.
-%   QBFUN    is a function defining the righ-hand sides of the
-%            backward ODEs yQB' = fQB(t,y,yB).
-%   YQB0     is the final conditions vector yQB(tB0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the CVodeSetQuadOptions function. 
-%
-%   See also: CVodeInitB, CVodeSetQuadOptions, CVQuadRhsFnB 
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 6;
-
-if nargin < 3
-  error('Too few input arguments');
-end
-
-if nargin < 4
-  optionsB = [];
-end
-
-idxB = idxB-1;
-status = cvm(mode, idxB, fctQB, yQB0, optionsB);
diff --git a/sundialsTB/cvodes/CVodeQuadReInit.m b/sundialsTB/cvodes/CVodeQuadReInit.m
deleted file mode 100644
index eef6173..0000000
--- a/sundialsTB/cvodes/CVodeQuadReInit.m
+++ /dev/null
@@ -1,28 +0,0 @@
-function status = CVodeQuadReInit(yQ0, options)
-%CVodeQuadReInit reinitializes CVODES's quadrature-related memory
-%   assuming it has already been allocated in prior calls to CVodeInit 
-%   and CVodeQuadInit.
-%
-%   Usage: CVodeQuadReInit ( YQ0 [, OPTIONS ] ) 
-%
-%   YQ0      Initial conditions for quadrature variables yQ(t0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the CVodeSetQuadOptions function. 
-%
-%   See also: CVodeSetQuadOptions, CVodeQuadInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 12;
-
-if nargin < 1
-  error('Too few input arguments');
-end
-
-if nargin < 2
-  options = [];
-end
-  
-status = cvm(mode, yQ0, options);
diff --git a/sundialsTB/cvodes/CVodeQuadReInitB.m b/sundialsTB/cvodes/CVodeQuadReInitB.m
deleted file mode 100644
index 5e821d0..0000000
--- a/sundialsTB/cvodes/CVodeQuadReInitB.m
+++ /dev/null
@@ -1,30 +0,0 @@
-function status = CVodeQuadReInitB(idxB, yQB0, optionsB)
-%CVodeQuadReInitB reinitializes memory for backward quadrature integration.
-%
-%   Usage: CVodeQuadReInitB ( IDXB, YS0 [, OPTIONS ] ) 
-%
-%   IDXB     is the index of the backward problem, returned by
-%            CVodeInitB.
-%   YQB0     is the final conditions vector yQB(tB0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the CVodeSetQuadOptions function. 
-%
-%   See also: CVodeSetQuadOptions, CVodeReInitB, CVodeQuadInitB
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 16;
-
-if nargin < 2
-  error('Too few input arguments');
-end
-
-if nargin < 3
-  optionsB = [];
-end
-  
-idxB = idxB-1;
-status = cvm(mode, idxB, yQB0, optionsB);
diff --git a/sundialsTB/cvodes/CVodeQuadSetOptions.m b/sundialsTB/cvodes/CVodeQuadSetOptions.m
deleted file mode 100644
index 2e506c0..0000000
--- a/sundialsTB/cvodes/CVodeQuadSetOptions.m
+++ /dev/null
@@ -1,64 +0,0 @@
-function options = CVodeQuadSetOptions(varargin)
-%CVodeQuadSetOptions creates an options structure for quadrature integration with CVODES.
-%
-%   Usage: OPTIONS = CVodeQuadSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...)
-%          OPTIONS = CVodeQuadSetOptions(OLDOPTIONS,'NAME1',VALUE1,...)
-%
-%   OPTIONS = CVodeQuadSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...) creates 
-%   a CVODES options structure OPTIONS in which the named properties have 
-%   the specified values. Any unspecified properties have default values. 
-%   It is sufficient to type only the leading characters that uniquely 
-%   identify the property. Case is ignored for property names. 
-%   
-%   OPTIONS = CVodeQuadSetOptions(OLDOPTIONS,'NAME1',VALUE1,...) alters an 
-%   existing options structure OLDOPTIONS.
-%   
-%   CVodeQuadSetOptions with no input arguments displays all property names 
-%   and their possible values.
-%   
-%CVodeQuadSetOptions properties
-%(See also the CVODES User Guide)
-%
-%ErrControl - Error control strategy for quadrature variables [ {false} | true ]
-%   Specifies whether quadrature variables are included in the error test.
-%RelTol - Relative tolerance for quadrature variables [ scalar {1e-4} ]
-%   Specifies the relative tolerance for quadrature variables. This parameter is
-%   used only if ErrControl = true.
-%AbsTol - Absolute tolerance for quadrature variables [ scalar or vector {1e-6} ]
-%   Specifies the absolute tolerance for quadrature variables. This parameter is
-%   used only if ErrControl = true.
-%
-%SensDependent - Backward problem depending on sensitivities [ {false} | true ]
-%   Specifies whether the backward problem quadrature right-hand side depends
-%   on forward sensitivites. If TRUE, the right-hand side function provided for
-%   this backward problem must have the appropriate type (see CVQuadRhsFnB).
-%
-%
-%   See also
-%        CVodeQuadInit, CVodeQuadReInit.
-%        CVodeQuadInitB, CVodeQuadReInitB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/08/21 17:42:38 $
-
-% If called without input and output arguments, print out the possible keywords
-
-if (nargin == 0) && (nargout == 0)
-  fprintf('      ErrControl: [ {false} | true ]\n');
-  fprintf('          RelTol: [ positive scalar {1e-4} ]\n');
-  fprintf('          AbsTol: [ positive scalar or vector {1e-6} ]\n');
-  fprintf('\n');
-  fprintf('   SensDependent: [ {false} | true ]\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'ErrControl'
-    'RelTol'
-    'AbsTol'
-    'SensDependent'
-    };
-
-options = cvm_options(KeyNames,varargin{:});
diff --git a/sundialsTB/cvodes/CVodeReInit.m b/sundialsTB/cvodes/CVodeReInit.m
deleted file mode 100644
index 330dbad..0000000
--- a/sundialsTB/cvodes/CVodeReInit.m
+++ /dev/null
@@ -1,32 +0,0 @@
-function status = CVodeReInit(t0, y0, options)
-%CVodeReInit reinitializes memory for CVODES
-%   where a prior call to CVodeInit has been made with the same
-%   problem size N. CVodeReInit performs the same input checking
-%   and initializations that CVodeInit does, but it does no 
-%   memory allocation, assuming that the existing internal memory 
-%   is sufficient for the new problem.
-%
-%   Usage: CVodeReInit ( T0, Y0 [, OPTIONS ] ) 
-%
-%   T0       is the initial value of t.
-%   Y0       is the initial condition vector y(t0).  
-%   OPTIONS  is an (optional) set of integration options, created with
-%            the CVodeSetOptions function. 
-%
-%   See also: CVodeSetOptions, CVodeInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2007/12/05 21:58:18 $
-
-mode = 11;
-
-if nargin < 2
-  error('Too few input arguments');
-end
-
-if nargin < 3
-  options = [];
-end
-
-status = cvm(mode, t0, y0, options);
diff --git a/sundialsTB/cvodes/CVodeReInitB.m b/sundialsTB/cvodes/CVodeReInitB.m
deleted file mode 100644
index 293d75a..0000000
--- a/sundialsTB/cvodes/CVodeReInitB.m
+++ /dev/null
@@ -1,36 +0,0 @@
-function status = CVodeReInitB(idxB, tB0, yB0, optionsB)
-%CVodeReInitB re-initializes backward memory for CVODES.
-%   where a prior call to CVodeInitB has been made with the same
-%   problem size NB. CVodeReInitB performs the same input checking
-%   and initializations that CVodeInitB does, but it does no 
-%   memory allocation, assuming that the existing internal memory 
-%   is sufficient for the new problem.
-%
-%   Usage:   CVodeReInitB ( IDXB, TB0, YB0 [, OPTIONSB] )
-%
-%   IDXB     is the index of the backward problem, returned by
-%            CVodeInitB.
-%   TB0      is the final value of t.
-%   YB0      is the final condition vector yB(tB0).  
-%   OPTIONSB is an (optional) set of integration options, created with
-%            the CVodeSetOptions function. 
-%
-%   See also: CVodeSetOptions, CVodeInitB
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2007/12/05 21:58:18 $
-
-mode = 15;
-
-if nargin < 3
-  error('Too few input arguments');
-end
-
-if nargin < 4
-  optionsB = [];
-end
-
-idxB = idxB-1;
-status = cvm(mode,idxB,tB0,yB0,optionsB);
diff --git a/sundialsTB/cvodes/CVodeSensInit.m b/sundialsTB/cvodes/CVodeSensInit.m
deleted file mode 100644
index d5424ba..0000000
--- a/sundialsTB/cvodes/CVodeSensInit.m
+++ /dev/null
@@ -1,33 +0,0 @@
-function status = CVodeSensInit(Ns,fctS,yS0,options)
-%CVodeSensInit allocates and initializes memory for FSA with CVODES.
-%
-%   Usage: CVodeSensInit ( NS, SFUN, YS0 [, OPTIONS ] ) 
-%
-%   NS       is the number of parameters with respect to which sensitivities
-%            are desired
-%   SFUN     is a function defining the righ-hand sides of the sensitivity
-%            ODEs yS' = fS(t,y,yS).
-%   YS0      Initial conditions for sensitivity variables.
-%            YS0 must be a matrix with N rows and Ns columns, where N is the problem
-%            dimension and Ns the number of sensitivity systems.
-%   OPTIONS  is an (optional) set of FSA options, created with
-%            the CVodeSetFSAOptions function. 
-%
-%   See also CVodeSensSetOptions, CVodeInit, CVSensRhsFn
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 3;
-
-if nargin < 3
-  error('Too few input arguments');
-end
-
-if nargin < 4
-  options = [];
-end
-
-status = cvm(mode, Ns, fctS, yS0, options);
diff --git a/sundialsTB/cvodes/CVodeSensReInit.m b/sundialsTB/cvodes/CVodeSensReInit.m
deleted file mode 100644
index 549cd5f..0000000
--- a/sundialsTB/cvodes/CVodeSensReInit.m
+++ /dev/null
@@ -1,32 +0,0 @@
-function status = CVodeSensReInit(yS0, options)
-%CVodeSensReInit reinitializes CVODES's FSA-related memory
-%   assuming it has already been allocated in prior calls to CVodeInit 
-%   and CVodeSensInit.
-%   The number of sensitivities Ns is assumed to be unchanged since the 
-%   previous call to CVodeSensInit.
-%
-%   Usage: CVodeSensReInit ( YS0 [, OPTIONS ] ) 
-%
-%   YS0      Initial conditions for sensitivity variables.
-%            YS0 must be a matrix with N rows and Ns columns, where N is the problem
-%            dimension and Ns the number of sensitivity systems.
-%   OPTIONS  is an (optional) set of FSA options, created with
-%            the CVodeSensSetOptions function. 
-%
-%   See also: CVodeSensSetOptions, CVodeReInit, CVodeSensInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2007/12/05 21:58:18 $
-
-mode = 13;
-
-if nargin < 1
-  error('Too few input arguments');
-end
-
-if nargin < 2
-  options = [];
-end
-
-status = cvm(mode, yS0, options);
diff --git a/sundialsTB/cvodes/CVodeSensSetOptions.m b/sundialsTB/cvodes/CVodeSensSetOptions.m
deleted file mode 100644
index 613e828..0000000
--- a/sundialsTB/cvodes/CVodeSensSetOptions.m
+++ /dev/null
@@ -1,112 +0,0 @@
-function options = CVodeSensSetOptions(varargin)
-%CVodeSensSetOptions creates an options structure for FSA with CVODES.
-%
-%   Usage: OPTIONS = CVodeSensSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...)
-%          OPTIONS = CVodeSensSetOptions(OLDOPTIONS,'NAME1',VALUE1,...)
-%
-%   OPTIONS = CVodeSensSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...) creates 
-%   a CVODES options structure OPTIONS in which the named properties have 
-%   the specified values. Any unspecified properties have default values. 
-%   It is sufficient to type only the leading characters that uniquely 
-%   identify the property. Case is ignored for property names. 
-%   
-%   OPTIONS = CVodeSensSetOptions(OLDOPTIONS,'NAME1',VALUE1,...) alters an 
-%   existing options structure OLDOPTIONS.
-%   
-%   CVodeSensSetOptions with no input arguments displays all property names 
-%   and their possible values.
-%   
-%CVodeSensSetOptions properties
-%(See also the CVODES User Guide)
-%
-%method - FSA solution method [ 'Simultaneous' | {'Staggered'} ]
-%   Specifies the FSA method for treating the nonlinear system solution for
-%   sensitivity variables. In the simultaneous case, the nonlinear systems 
-%   for states and all sensitivities are solved simultaneously. In the 
-%   Staggered case, the nonlinear system for states is solved first and then
-%   the nonlinear systems for all sensitivities are solved at the same time. 
-%ParamField - Problem parameters  [ string ]
-%   Specifies the name of the field in the user data structure (specified through
-%   the 'UserData' field with CVodeSetOptions) in which the nominal values of the problem 
-%   parameters are stored. This property is used only if  CVODES will use difference
-%   quotient approximations to the sensitivity right-hand sides (see CVSensRhsFn).
-%ParamList - Parameters with respect to which FSA is performed [ integer vector ]
-%   Specifies a list of Ns parameters with respect to which sensitivities are to
-%   be computed. This property is used only if CVODES will use difference-quotient
-%   approximations to the sensitivity right-hand sides. Its length must be Ns, 
-%   consistent with the number of columns of yS0 (see CVodeSensInit).
-%ParamScales - Order of magnitude for problem parameters [ vector ]
-%   Provides order of magnitude information for the parameters with respect to
-%   which sensitivities are computed. This information is used if CVODES 
-%   approximates the sensitivity right-hand sides or if CVODES estimates integration
-%   tolerances for the sensitivity variables (see RelTol and AbsTol).
-%RelTol - Relative tolerance for sensitivity variables [ positive scalar ]
-%   Specifies the scalar relative tolerance for the sensitivity variables. 
-%   See also AbsTol.
-%AbsTol - Absolute tolerance for sensitivity variables [ row-vector or matrix ]
-%   Specifies the absolute tolerance for sensitivity variables. AbsTol must be
-%   either a row vector of dimension Ns, in which case each of its components is
-%   used as a scalar absolute tolerance for the coresponding sensitivity vector,
-%   or a N x Ns matrix, in which case each of its columns is used as a vector
-%   of absolute tolerances for the corresponding sensitivity vector.
-%   By default, CVODES estimates the integration tolerances for sensitivity 
-%   variables, based on those for the states and on the order of magnitude 
-%   information for the problem parameters specified through ParamScales.
-%ErrControl - Error control strategy for sensitivity variables [ false | {true} ]
-%   Specifies whether sensitivity variables are included in the error control test.
-%   Note that sensitivity variables are always included in the nonlinear system
-%   convergence test.
-%DQtype - Type of DQ approx. of the sensi. RHS [{Centered} | Forward ]
-%   Specifies whether to use centered (second-order) or forward (first-order)
-%   difference quotient approximations of the sensitivity eqation right-hand 
-%   sides. This property is used only if a user-defined sensitivity right-hand 
-%   side function was not provided.
-%DQparam - Cut-off parameter for the DQ approx. of the sensi. RHS [ scalar | {0.0} ]
-%   Specifies the value which controls the selection of the difference-quotient 
-%   scheme used in evaluating the sensitivity right-hand sides (switch between 
-%   simultaneous or separate evaluations of the two components in the sensitivity 
-%   right-hand side). The default value 0.0 indicates the use of simultaenous approximation
-%   exclusively (centered or forward, depending on the value of DQtype.
-%   For DQparam >= 1, CVODES uses a simultaneous approximation if the estimated
-%   DQ perturbations for states and parameters are within a factor of DQparam, 
-%   and separate approximations otherwise. Note that a value DQparam < 1
-%   will inhibit switching! This property is used only if a user-defined sensitivity 
-%   right-hand side function was not provided. 
-%
-%   See also
-%        CVodeSensInit, CVodeSensReInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/08/21 17:42:38 $
-
-% If called without input and output arguments, print out the possible keywords
-
-if (nargin == 0) & (nargout == 0)
-  fprintf('          method: [ Simultaneous | {Staggered} ]\n');
-  fprintf('      ParamField: [ string ]\n');
-  fprintf('       ParamList: [ integer vector ]\n');
-  fprintf('     ParamScales: [ vector ]\n');
-  fprintf('          RelTol: [ positive scalar ]\n');
-  fprintf('          AbsTol: [ row-vector or matrix ]\n');
-  fprintf('      ErrControl: [ false | {true} ]\n');
-  fprintf('          DQtype: [ {Centered} | {Forward} ]\n');
-  fprintf('         DQparam: [ scalar | {0.0} ]\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'method'
-    'ParamField'
-    'ParamList'
-    'ParamScales'
-    'RelTol'
-    'AbsTol'
-    'ErrControl'
-    'DQtype'
-    'DQparam'
-        };
-
-options = cvm_options(KeyNames,varargin{:});
-
diff --git a/sundialsTB/cvodes/CVodeSensToggleOff.m b/sundialsTB/cvodes/CVodeSensToggleOff.m
deleted file mode 100644
index 658ff48..0000000
--- a/sundialsTB/cvodes/CVodeSensToggleOff.m
+++ /dev/null
@@ -1,16 +0,0 @@
-function status = CVodeSensToggleOff()
-% CVodeSensToggleOff deactivates sensitivity calculations.
-%   It does NOT deallocate sensitivity-related memory so that 
-%   sensitivity computations can be later toggled ON (through
-%   CVodeSensReInit).
-%
-%   Usage: CVodeSensToggleOff
-%
-%   See also: CVodeSensInit, CVodeSensReInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 18;
-status = cvm(mode);
diff --git a/sundialsTB/cvodes/CVodeSet.m b/sundialsTB/cvodes/CVodeSet.m
deleted file mode 100644
index 50ff082..0000000
--- a/sundialsTB/cvodes/CVodeSet.m
+++ /dev/null
@@ -1,52 +0,0 @@
-function status = CVodeSet(varargin)
-%CVodeSet changes optional input values during the integration.
-%
-%   Usage: CVodeSet('NAME1',VALUE1,'NAME2',VALUE2,...)
-%
-%   CVodeSet can be used to change some of the optional inputs during
-%   the integration, i.e., without need for a solver reinitialization.
-%   The property names accepted by CVodeSet are a subset of those valid
-%   for CVodeSetOptions. Any unspecified properties are left unchanged.
-%
-%   CVodeSet with no input arguments displays all property names. 
-%
-%CVodeSet properties
-%(See also the CVODES User Guide)
-%
-%UserData - problem data passed unmodified to all user functions.
-%  Set VALUE to be the new user data.  
-%RelTol - Relative tolerance
-%  Set VALUE to the new relative tolerance
-%AbsTol - absolute tolerance
-%  Set VALUE to be either the new scalar absolute tolerance or
-%  a vector of absolute tolerances, one for each solution component.
-%StopTime - Stopping time
-%  Set VALUE to be a new value for the independent variable past which
-%  the solution is not to proceed. 
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-if (nargin == 0)
-  fprintf('        UserData\n');
-  fprintf('\n');
-  fprintf('          RelTol\n');
-  fprintf('          AbsTol\n');
-  fprintf('        StopTime\n');  
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'UserData'
-    'RelTol'
-    'AbsTol'
-    'StopTime'
-           };
-
-options = cvm_options(KeyNames,varargin{:});
-
-mode = 33;
-
-status = cvm(mode, options);
diff --git a/sundialsTB/cvodes/CVodeSetB.m b/sundialsTB/cvodes/CVodeSetB.m
deleted file mode 100644
index cae4ad8..0000000
--- a/sundialsTB/cvodes/CVodeSetB.m
+++ /dev/null
@@ -1,48 +0,0 @@
-function status = CVodeSetB(idxB, varargin)
-%CVodeSetB changes optional input values during the integration.
-%
-%   Usage: CVodeSetB( IDXB, 'NAME1',VALUE1,'NAME2',VALUE2,... )
-%
-%   CVodeSetB can be used to change some of the optional inputs for
-%   the backward problem identified by IDXB during the backward
-%   integration, i.e., without need for a solver reinitialization.
-%   The property names accepted by CVodeSet are a subset of those valid
-%   for CVodeSetOptions. Any unspecified properties are left unchanged.
-%   
-%   CVodeSetB with no input arguments displays all property names.
-%
-%CVodeSetB properties
-%(See also the CVODES User Guide)
-%
-%UserData - problem data passed unmodified to all user functions.
-%  Set VALUE to be the new user data.  
-%RelTol - Relative tolerance
-%  Set VALUE to the new relative tolerance
-%AbsTol - absolute tolerance
-%  Set VALUE to be either the new scalar absolute tolerance or
-%  a vector of absolute tolerances, one for each solution component.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-if (nargin == 0)
-  fprintf('        UserData\n');
-  fprintf('\n');
-  fprintf('          RelTol\n');
-  fprintf('          AbsTol\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'UserData'
-    'RelTol'
-    'AbsTol'
-           };
-
-options = cvm_options(KeyNames,varargin{:});
-
-mode = 34;
-
-status = cvm(mode, idxB, options);
diff --git a/sundialsTB/cvodes/CVodeSetOptions.m b/sundialsTB/cvodes/CVodeSetOptions.m
deleted file mode 100644
index e2f87a7..0000000
--- a/sundialsTB/cvodes/CVodeSetOptions.m
+++ /dev/null
@@ -1,300 +0,0 @@
-function options = CVodeSetOptions(varargin)
-%CVodeSetOptions creates an options structure for CVODES.
-%
-%   Usage: OPTIONS = CVodeSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...)
-%          OPTIONS = CVodeSetOptions(OLDOPTIONS,'NAME1',VALUE1,...)
-%
-%   OPTIONS = CVodeSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...) creates 
-%   a CVODES options structure OPTIONS in which the named properties have 
-%   the specified values. Any unspecified properties have default values. 
-%   It is sufficient to type only the leading characters that uniquely 
-%   identify the property. Case is ignored for property names. 
-%   
-%   OPTIONS = CVodeSetOptions(OLDOPTIONS,'NAME1',VALUE1,...) alters an 
-%   existing options structure OLDOPTIONS.
-%   
-%   CVodeSetOptions with no input arguments displays all property names 
-%   and their possible values.
-%   
-%CVodeSetOptions properties
-%(See also the CVODES User Guide)
-%
-%UserData - User data passed unmodified to all functions [ empty ]
-%   If UserData is not empty, all user provided functions will be
-%   passed the problem data as their last input argument. For example,
-%   the RHS function must be defined as YD = ODEFUN(T,Y,DATA).
-%
-%LMM - Linear Multistep Method [ 'Adams' | {'BDF'} ]
-%   This property specifies whether the Adams method is to be used instead
-%   of the default Backward Differentiation Formulas (BDF) method.
-%   The Adams method is recommended for non-stiff problems, while BDF is
-%   recommended for stiff problems.
-%NonlinearSolver - Type of nonlinear solver used [ Functional | {Newton} ]
-%   The 'Functional' nonlinear solver is best suited for non-stiff
-%   problems, in conjunction with the 'Adams' linear multistep method,
-%   while 'Newton' is better suited for stiff problems, using the 'BDF' 
-%   method.
-%RelTol - Relative tolerance [ positive scalar | {1e-4} ]
-%   RelTol defaults to 1e-4 and is applied to all components of the solution
-%   vector. See AbsTol.
-%AbsTol - Absolute tolerance [ positive scalar or vector | {1e-6} ]
-%   The relative and absolute tolerances define a vector of error weights
-%   with components
-%     ewt(i) = 1/(RelTol*|y(i)| + AbsTol)    if AbsTol is a scalar
-%     ewt(i) = 1/(RelTol*|y(i)| + AbsTol(i)) if AbsTol is a vector
-%   This vector is used in all error and convergence tests, which
-%   use a weighted RMS norm on all error-like vectors v:
-%     WRMSnorm(v) = sqrt( (1/N) sum(i=1..N) (v(i)*ewt(i))^2 ),
-%   where N is the problem dimension.
-%MaxNumSteps - Maximum number of steps [positive integer | {500}]
-%   CVode will return with an error after taking MaxNumSteps internal steps
-%   in its attempt to reach the next output time.
-%InitialStep - Suggested initial stepsize [ positive scalar ]
-%   By default, CVode estimates an initial stepsize h0 at the initial time 
-%   t0 as the solution of
-%     WRMSnorm(h0^2 ydd / 2) = 1
-%   where ydd is an estimated second derivative of y(t0).
-%MaxStep - Maximum stepsize [ positive scalar | {inf} ]
-%   Defines an upper bound on the integration step size.
-%MinStep - Minimum stepsize [ positive scalar | {0.0} ]
-%   Defines a lower bound on the integration step size.
-%MaxOrder - Maximum method order [ 1-12 for Adams, 1-5 for BDF | {5} ]
-%   Defines an upper bound on the linear multistep method order.
-%StopTime - Stopping time [ scalar ]
-%   Defines a value for the independent variable past which the solution 
-%   is not to proceed. 
-%RootsFn - Rootfinding function [ function ]
-%   To detect events (roots of functions), set this property to the event 
-%   function. See CVRootFn.
-%NumRoots - Number of root functions [ integer | {0} ]
-%   Set NumRoots to the number of functions for which roots are monitored.
-%   If NumRoots is 0, rootfinding is disabled.
-%StabilityLimDet - Stability limit detection algorithm [ {false} | true ]
-%   Flag used to turn on or off the stability limit detection algorithm 
-%   within CVODES. This property can be used only with the BDF method. 
-%   In this case, if the order is 3 or greater and if the stability limit 
-%   is detected, the method order is reduced.
-%
-%LinearSolver - Linear solver type [{Dense}|Diag|Band|GMRES|BiCGStab|TFQMR]
-%   Specifies the type of linear solver to be used for the Newton nonlinear 
-%   solver (see NonlinearSolver). Valid choices are: Dense (direct, dense 
-%   Jacobian), Band (direct, banded Jacobian), Diag (direct, diagonal Jacobian), 
-%   GMRES (iterative, scaled preconditioned GMRES), BiCGStab (iterative, scaled 
-%   preconditioned stabilized BiCG), TFQMR (iterative, scaled transpose-free QMR).
-%   The GMRES, BiCGStab, and TFQMR are matrix-free linear solvers.
-%JacobianFn - Jacobian function [ function ]
-%   This propeerty is overloaded. Set this value to a function that returns 
-%   Jacobian information consistent with the linear solver used (see Linsolver). 
-%   If not specified, CVODES uses difference quotient approximations. 
-%   For the Dense linear solver, JacobianFn must be of type CVDenseJacFn and 
-%   must return a dense Jacobian matrix. For the Band linear solver, JacobianFn 
-%   must be of type CVBandJacFn and must return a banded Jacobian matrix. 
-%   For the iterative linear solvers, GMRES, BiCGStab, and TFQMR, JacobianFn must 
-%   be of type CVJacTimesVecFn and must return a Jacobian-vector product. This 
-%   property is not used for the Diag linear solver.
-%   If these options are for a backward problem, the corresponding funciton types
-%   are CVDenseJacFnB for the Dense linear solver, CVBandJacFnB for he band linear
-%   solver, and CVJacTimesVecFnB for the iterative linear solvers.
-%KrylovMaxDim - Maximum number of Krylov subspace vectors [ integer | {5} ]
-%   Specifies the maximum number of vectors in the Krylov subspace. This property 
-%   is used only if an iterative linear solver, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver).
-%GramSchmidtType - Gram-Schmidt orthogonalization [ Classical | {Modified} ]
-%   Specifies the type of Gram-Schmidt orthogonalization (classical or modified).
-%   This property is used only if the GMRES linear solver is used (see LinSolver).
-%PrecType - Preconditioner type [ Left | Right | Both | {None} ]
-%   Specifies the type of user preconditioning to be done if an iterative linear
-%   solver, GMRES, BiCGStab, or TFQMR is used (see LinSolver). PrecType must be 
-%   one of the following: 'None', 'Left', 'Right', or 'Both', corresponding to no 
-%   preconditioning, left preconditioning only, right preconditioning only, and 
-%   both left and right preconditioning, respectively.
-%PrecModule - Preconditioner module [ BandPre | BBDPre | {UserDefined} ]
-%   If PrecModule = 'UserDefined', then the user must provide at least a 
-%   preconditioner solve function (see PrecSolveFn)
-%   CVODES provides the following two general-purpose preconditioner modules:
-%     BandPre provide a band matrix preconditioner based on difference quotients
-%   of the ODE right-hand side function. The user must specify the lower and
-%   upper half-bandwidths through the properties LowerBwidth and UpperBwidth,
-%   respectively. 
-%     BBDPre can be only used with parallel vectors. It provide a preconditioner 
-%   matrix that is block-diagonal with banded blocks. The blocking corresponds
-%   to the distribution of the dependent variable vector y among the processors. 
-%   Each preconditioner block is generated from the Jacobian of the local part 
-%   (on the current processor) of a given function g(t,y) approximating
-%   f(t,y) (see GlocalFn). The blocks are generated by a difference quotient 
-%   scheme on each processor independently. This scheme utilizes an assumed 
-%   banded structure with given half-bandwidths, mldq and mudq (specified through 
-%   LowerBwidthDQ and UpperBwidthDQ, respectively). However, the banded Jacobian 
-%   block kept by the scheme has half-bandwiths ml and mu (specified through 
-%   LowerBwidth and UpperBwidth), which may be smaller.
-%PrecSetupFn - Preconditioner setup function [ function ]
-%   If PrecType is not 'None', PrecSetupFn specifies an optional function which,
-%   together with PrecSolve, defines left and right preconditioner matrices
-%   (either of which can be trivial), such that the product P1*P2 is an 
-%   aproximation to the Newton matrix. PrecSetupFn must be of type CVPrecSetupFn
-%   or CVPrecSetupFnB for forward and backward problems, respectively.
-%PrecSolveFn - Preconditioner solve function [ function ]
-%   If PrecType is not 'None', PrecSolveFn specifies a required function which 
-%   must solve a linear system Pz = r, for given r. PrecSolveFn must be of type
-%   CVPrecSolveFn or CVPrecSolveFnB for forward and backward problems, respectively.
-%GlocalFn - Local right-hand side approximation funciton for BBDPre [ function ]
-%   If PrecModule is BBDPre, GlocalFn specifies a required function that
-%   evaluates a local approximation to the ODE right-hand side. GlocalFn must
-%   be of type CVGlocFn or CVGlocFnB for forward and backward problems, respectively.
-%GcommFn - Inter-process communication function for BBDPre [ function ]
-%   If PrecModule is BBDPre, GcommFn specifies an optional function
-%   to perform any inter-process communication required for the evaluation of
-%   GlocalFn. GcommFn must be of type CVGcommFn or CVGcommFnB  for forward and
-%   backward problems, respectively.
-%LowerBwidth - Jacobian/preconditioner lower bandwidth [ integer | {0} ]
-%   This property is overloaded. If the Band linear solver is used (see LinSolver),
-%   it specifies the lower half-bandwidth of the band Jacobian approximation. 
-%   If one of the three iterative linear solvers, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver) and if the BBDPre preconditioner module in CVODES is used 
-%   (see PrecModule), it specifies the lower half-bandwidth of the retained 
-%   banded approximation of the local Jacobian block. If the BandPre preconditioner 
-%   module (see PrecModule) is used, it specifies the lower half-bandwidth of 
-%   the band preconditioner matrix. LowerBwidth defaults to 0 (no sub-diagonals).
-%UpperBwidth - Jacobian/preconditioner upper bandwidth [ integer | {0} ]
-%   This property is overloaded. If the Band linear solver is used (see LinSolver),
-%   it specifies the upper half-bandwidth of the band Jacobian approximation. 
-%   If one of the three iterative linear solvers, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver) and if the BBDPre preconditioner module in CVODES is used 
-%   (see PrecModule), it specifies the upper half-bandwidth of the retained 
-%   banded approximation of the local Jacobian block. If the BandPre 
-%   preconditioner module (see PrecModule) is used, it specifies the upper 
-%   half-bandwidth of the band preconditioner matrix. UpperBwidth defaults to 
-%   0 (no super-diagonals).
-%LowerBwidthDQ - BBDPre preconditioner DQ lower bandwidth [ integer | {0} ]
-%   Specifies the lower half-bandwidth used in the difference-quotient Jacobian
-%   approximation for the BBDPre preconditioner (see PrecModule).
-%UpperBwidthDQ - BBDPre preconditioner DQ upper bandwidth [ integer | {0} ]
-%   Specifies the upper half-bandwidth used in the difference-quotient Jacobian
-%   approximation for the BBDPre preconditioner (see PrecModule).
-%
-%MonitorFn - User-provied monitoring function [ function ]
-%   Specifies a function that is called after each successful integration step.
-%   This function must have type CVMonitorFn or CVMonitorFnB, depending on
-%   whether these options are for a forward or a backward problem, respectively.
-%   Sample monitoring functions CVodeMonitor and CvodeMonitorB are provided
-%   with CVODES.
-%MonitorData - User-provied data for the monitoring function [ struct ]
-%   Specifies a data structure that is passed to the MonitorFn function every
-%   time it is called. 
-%
-%SensDependent - Backward problem depending on sensitivities [ {false} | true ]
-%   Specifies whether the backward problem right-hand side depends on 
-%   forward sensitivites. If TRUE, the right-hand side function provided for
-%   this backward problem must have the appropriate type (see CVRhsFnB).
-%
-%ErrorMessages - Post error/warning messages [ {true} | false ]
-%   Note that any errors in CVodeInit will result in a Matlab error, thus
-%   stoping execution. Only subsequent calls to CVODES functions will respect
-%   the value specified for 'ErrorMessages'.
-%
-%NOTES:
-%
-%   The properties listed above that can only be used for forward problems
-%   are: StopTime, RootsFn, and NumRoots.
-%
-%   The property SensDependent is relevant only for backward problems.
-%
-%
-%   See also
-%        CVodeInit, CVodeReInit, CVodeInitB, CVodeReInitB
-%        CVRhsFn, CVRootFn,
-%        CVDenseJacFn, CVBandJacFn, CVJacTimesVecFn
-%        CVPrecSetupFn, CVPrecSolveFn
-%        CVGlocalFn, CVGcommFn
-%        CVMonitorFn
-%        CVRhsFnB,
-%        CVDenseJacFnB, CVBandJacFnB, CVJacTimesVecFnB
-%        CVPrecSetupFnB, CVPrecSolveFnB
-%        CVGlocalFnB, CVGcommFnB
-%        CVMonitorFnB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.9 $Date: 2007/12/05 21:58:18 $
-
-% If called without input and output arguments, print out the possible keywords
-
-if (nargin == 0) && (nargout == 0)
-  fprintf('        UserData: [ empty ]\n');
-  fprintf('\n');
-  fprintf('             LMM: [ Adams | {BDF} ]\n');
-  fprintf(' NonlinearSolver: [ Functional | {Newton} ]\n');
-  fprintf('          RelTol: [ positive scalar | {1e-4} ]\n');
-  fprintf('          AbsTol: [ positive scalar or vector | {1e-6} ]\n');
-  fprintf('     MaxNumSteps: [ positive integer | {500} ]\n');
-  fprintf('     InitialStep: [ positive scalar ]\n');
-  fprintf('         MaxStep: [ positive scalar | {inf} ]\n');
-  fprintf('         MinStep: [ positive scalar | {0.0} ]\n');
-  fprintf('        MaxOrder: [ 1-12 for Adams, 1-5 for BDF | {5} ]\n');
-  fprintf('        StopTime: [ scalar ]\n');
-  fprintf('         RootsFn: [ function ]\n');
-  fprintf('        NumRoots: [ integer | {0} ]\n');
-  fprintf(' StabilityLimDet: [ {false} | true ]\n');
-  fprintf('\n');
-  fprintf('    LinearSolver: [ {Dense} | Diag | Band | GMRES | BiCGStab | TFQMR ]\n');
-  fprintf('      JacobianFn: [ function ]\n');
-  fprintf('    KrylovMaxDim: [ integer | {5} ]\n');
-  fprintf(' GramSchmidtType: [ Classical | {Modified} ]\n');
-  fprintf('        PrecType: [ Left | Right | Both | {None} ]\n');
-  fprintf('      PrecModule: [ BandPre | BBDPre | {UserDefined} ]\n');
-  fprintf('     PrecSetupFn: [ function ]\n');
-  fprintf('     PrecSolveFn: [ function ]\n');
-  fprintf('        GlocalFn: [ function ]\n');
-  fprintf('         GcommFn: [ function ]\n');
-  fprintf('     LowerBwidth: [ integer | {0} ]\n');
-  fprintf('     UpperBwidth: [ integer | {0} ]\n');
-  fprintf('   LowerBwidthDQ: [ integer | {0} ]\n');
-  fprintf('   UpperBwidthDQ: [ integer | {0} ]\n');
-  fprintf('\n');
-  fprintf('       MonitorFn: [ function ]\n');
-  fprintf('     MonitorData: [ struct ]\n');
-  fprintf('\n');
-  fprintf('   SensDependent: [ {false} | true ]\n');
-  fprintf('\n');
-  fprintf('   ErrorMessages: [ false | {true} ]\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'UserData'
-    'LMM'
-    'NonlinearSolver'
-    'RelTol'
-    'AbsTol'
-    'MaxNumSteps'
-    'InitialStep'
-    'MaxStep'
-    'MinStep'
-    'MaxOrder'
-    'StopTime'
-    'RootsFn'
-    'NumRoots'
-    'StabilityLimDet'
-    'LinearSolver'
-    'JacobianFn'
-    'PrecType'
-    'PrecModule'
-    'PrecSetupFn'
-    'PrecSolveFn'
-    'KrylovMaxDim'
-    'GramSchmidtType'
-    'GlocalFn'
-    'GcommFn'
-    'LowerBwidth'
-    'UpperBwidth'
-    'LowerBwidthDQ'
-    'UpperBwidthDQ'
-    'MonitorFn'
-    'MonitorData'
-    'SensDependent'
-    'ErrorMessages'
-           };
-
-options = cvm_options(KeyNames,varargin{:});
-
diff --git a/sundialsTB/cvodes/Contents.m b/sundialsTB/cvodes/Contents.m
deleted file mode 100644
index c82947a..0000000
--- a/sundialsTB/cvodes/Contents.m
+++ /dev/null
@@ -1,115 +0,0 @@
-% CVODES, an ODE integrator with sensitivity analysis capabilities
-%
-% The Matlab interface to the SUNDIALS solver CVODES provides access
-% to all functionality of the underlying solver, including IVP simulation
-% and sensitvity analysis (both forward and adjoint).
-%
-% The interface consists of several user-callable functions. In addition,
-% the user must provide several required and optional user-supplied 
-% functions which define the problem to be solved. The user-callable 
-% functions and the types of user-supplied functions are listed below.
-% For completness, some functions appear more than once.
-%
-% Functions for ODE integration
-%
-%  CVodeSetOptions     - create an options structure for an ODE problem.
-%  CVodeQuadSetOptions - create an options structure for quadrature integration.
-%  CVodeInit           - allocate and initialize memory for CVODES.
-%  CVodeQuadInit       - allocate and initialize memory for quadrature integration.
-%  CVodeReInit         - reinitialize memory for CVODES.
-%  CVodeQuadReInit     - reinitialize memory for quadrature integration.
-%  CVode               - integrate the ODE problem.
-%  CVodeGetStats       - return statistics for the CVODES solver.
-%  CVodeGet            - extract data from CVODES memory.
-%  CVodeFree           - deallocate memory for the CVODES solver.
-%
-% Functions for forward sensitivity analysis
-%
-%  CVodeSetOptions     - create an options structure for an ODE problem.
-%  CVodeQuadSetOptions - create an options structure for quadrature integration.
-%  CVodeSensSetOptions - create an options structure for FSA.
-%  CVodeInit           - allocate and initialize memory for CVODES.
-%  CVodeQuadInit       - allocate and initialize memory for quadrature integration.
-%  CVodeSensInit       - allocate and initialize memory for FSA.
-%  CVodeReInit         - reinitialize memory for CVODES.
-%  CVodeQuadReInit     - reinitialize memory for quadrature integration.
-%  CVodeSensReInit     - reinitialize memory for FSA.
-%  CVodeSensToggleOff  - temporarily deactivates FSA.
-%  CVode               - integrate the ODE problem.
-%  CVodeGetStats       - return statistics for the CVODES solver.
-%  CVodeGet            - extract data from CVODES memory.
-%  CVodeFree           - deallocate memory for the CVODES solver.
-%
-% Functions for adjoint sensitivity analysis
-%
-%  CVodeSetOptions     - create an options structure for an ODE problem.
-%  CVodeQuadSetOptions - create an options structure for quadrature integration.
-%  CVodeInit           - allocate and initialize memory for the forward problem.
-%  CVodeQuadInit       - allocate and initialize memory for forward quadrature integration.
-%  CVodeQuadReInit     - reinitialize memory for forward quadrature integration.
-%  CVodeReInit         - reinitialize memory for the forward problem.
-%  CVodeAdjInit        - allocate and initialize memory for ASA.
-%  CVodeInitB          - allocate and initialize a backward problem.
-%  CVodeAdjReInit      - reinitialize memory for ASA.
-%  CVodeReInitB        - reinitialize a backward problem.
-%  CVode               - integrate the forward ODE problem.
-%  CVodeB              - integrate the backward problems.
-%  CVodeGetStats       - return statistics for the integration of the forward problem.
-%  CVodeGetStatsB      - return statistics for the integration of a backward problem.
-%  CVodeGet            - extract data from CVODES memory.
-%  CVodeFree           - deallocate memory for the CVODES solver.
-%
-% User-supplied function types for forward problems
-%
-%   CVRhsFn            -  RHS function
-%   CVRootFn           -  root-finding function 
-%   CVQuadRhsFn        -  quadrature RHS function
-%   CVSensRhsFn        -  sensitivity RHS function
-%   CVDenseJacFn       -  dense Jacobian function
-%   CVBandJacFn        -  banded Jacobian function
-%   CVJacTimesVecFn    -  Jacobian times vector function
-%   CVPrecSetupFn      -  preconditioner setup function
-%   CVPrecSolveFn      -  preconditioner solve function
-%   CVGlocalFn         -  RHS approximation function (BBDPre)
-%   CVGcomFn           -  communication function (BBDPre)
-%   CVMonitorFn        -  monitoring function
-%
-% User-supplied function types for backward problems
-%
-%   CVRhsFnB           -  RHS function
-%   CVQuadRhsFnB       -  quadrature RHS function
-%   CVDenseJacFnB      -  dense Jacobian function
-%   CVBandJacFnB       -  banded Jacobian function
-%   CVJacTimesVecFnB   -  Jacobian times vector function
-%   CVPrecSetupFnB     -  preconditioner setup function
-%   CVPrecSolveFnB     -  preconditioner solve function
-%   CVGlocalFnB        -  RHS approximation function (BBDPre)
-%   CVGcomFnB          -  communication function (BBDPre)
-%   CVMonitorFnB       -  monitoring function
-%
-% Serial examples provided with the toolbox
-%
-%   mcvsRoberts_dns      -  chemical kinetics problem 
-%   mcvsRoberts_FSA_dns  -  FSA for the robertson problem
-%   mcvsRoberts_ASAi_dns -  ASA for the robertson problem
-%   mcvsAdvDiff_bnd      -  advection-diffusion PDE
-%   mcvsDiurnal_kry      -  2D, 2-species, time dependent PDE
-%   mcvsPleiades_non     -  nonstiff celestial mechanics problem
-%   mcvsVanDPol_dns      -  Van der Pol problem
-%   mcvsPollut_FSA_dns   -  FSA for pollution chemical kinetics
-%   mcvsOzone_FSA_dns    -  FSA for ozone chemical kinetics
-%   mcvsDiscRHS_dns      -  integration over RHS discontinuities
-%   mcvsDiscSOL_dns      -  integration over solution discontinuities
-%   mcvsHessian_FSA_ASA  -  illustration for computing Hessian information
-%                           (forward-over-adjoint approach)
-%
-% Parallel examples provided with the toolbox
-%
-%   mcvsDecoupl_non_p     - diagonal ODE example
-%   mcvsAdvDiff_FSA_non_p - FSA for 1D adv-diff problem (Adams, Functional)
-%   mcvsAtmDisp_kry_bbd_p - 3D adv-diff with distributed source problem
-%                           (BDF, Newton, GMRES, BBDPre preconditioner)
-% Use the mpirun function to run any of the parallel examples
-%
-% See also nvector, putils
-
diff --git a/sundialsTB/cvodes/cvm/Contents.m b/sundialsTB/cvodes/cvm/Contents.m
deleted file mode 100644
index b53c72b..0000000
--- a/sundialsTB/cvodes/cvm/Contents.m
+++ /dev/null
@@ -1,3 +0,0 @@
-% MEX binding of CVODES functions
-%
-%-- Radu Serban @ LLNL -- April 2005
diff --git a/sundialsTB/cvodes/cvm/cvm_bjac.m b/sundialsTB/cvodes/cvm/cvm_bjac.m
deleted file mode 100644
index 669572a..0000000
--- a/sundialsTB/cvodes/cvm/cvm_bjac.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [J, flag, new_data] = cvm_bjac(t, y, fy, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [J, flag] = feval(fct,t,y,fy);
-  new_data = [];
-else
-  [J, flag, new_data] = feval(fct,t,y,fy,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_bjacB.m b/sundialsTB/cvodes/cvm/cvm_bjacB.m
deleted file mode 100644
index 1644c4b..0000000
--- a/sundialsTB/cvodes/cvm/cvm_bjacB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [JB, flag, new_data] = cvm_bjacB(t, y, yB, fyB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [JB, flag] = feval(fct,t,y,yB,fyB);
-  new_data = [];
-else
-  [JB, flag, new_data] = feval(fct,t,y,yB,fyB,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_djac.m b/sundialsTB/cvodes/cvm/cvm_djac.m
deleted file mode 100644
index 211d527..0000000
--- a/sundialsTB/cvodes/cvm/cvm_djac.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [J, flag, new_data] = cvm_djac(t, y, fy, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [J, flag] = feval(fct,t,y,fy);
-  new_data = [];
-else
-  [J, flag, new_data] = feval(fct,t,y,fy,data);
-end
-
diff --git a/sundialsTB/cvodes/cvm/cvm_djacB.m b/sundialsTB/cvodes/cvm/cvm_djacB.m
deleted file mode 100644
index fe47177..0000000
--- a/sundialsTB/cvodes/cvm/cvm_djacB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [JB, flag, new_data] = cvm_djacB(t, y, yB, fyB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [JB, flag] = feval(fct,t,y,yB,fyB);
-  new_data = [];
-else
-  [JB, flag, new_data] = feval(fct,t,y,yB,fyB,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_gcom.m b/sundialsTB/cvodes/cvm/cvm_gcom.m
deleted file mode 100644
index 2730647..0000000
--- a/sundialsTB/cvodes/cvm/cvm_gcom.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [flag, new_data] = cvm_gcom(t, y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,t,y);
-  new_data = [];
-else
-  [flag, new_data] = feval(fct,t,y,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_gcomB.m b/sundialsTB/cvodes/cvm/cvm_gcomB.m
deleted file mode 100644
index 83f02e1..0000000
--- a/sundialsTB/cvodes/cvm/cvm_gcomB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [flag, new_data] = cvm_gcomB(t, y, yB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,t,y,yB);
-  new_data = [];
-else
-  [flag, new_data] = feval(fct,t,y,yB,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_gloc.m b/sundialsTB/cvodes/cvm/cvm_gloc.m
deleted file mode 100644
index f1b3b77..0000000
--- a/sundialsTB/cvodes/cvm/cvm_gloc.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [fl, flag, new_data] = cvm_gloc(t, y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [fl, flag] = feval(fct,t,y);
-  new_data = [];
-else
-  [fl, flag, new_data] = feval(fct,t,y,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_glocB.m b/sundialsTB/cvodes/cvm/cvm_glocB.m
deleted file mode 100644
index c563ba5..0000000
--- a/sundialsTB/cvodes/cvm/cvm_glocB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [flB, flag, new_data] = cvm_glocB(t, y, yB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [flB, flag] = feval(fct,t,y,yB);
-  new_data = [];
-else
-  [flB, flag, new_data] = feval(fct,t,y,yB,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_jtv.m b/sundialsTB/cvodes/cvm/cvm_jtv.m
deleted file mode 100644
index 2567da9..0000000
--- a/sundialsTB/cvodes/cvm/cvm_jtv.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [Jv, flag, new_data] = cvm_jtv(t, y, fy, v, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [Jv, flag] = feval(fct,t,y,fy,v);
-  new_data = [];
-else
-  [Jv, flag, new_data] = feval(fct,t,y,fy,v,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_jtvB.m b/sundialsTB/cvodes/cvm/cvm_jtvB.m
deleted file mode 100644
index 3b5b922..0000000
--- a/sundialsTB/cvodes/cvm/cvm_jtvB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [JvB, flag, new_data] = cvm_jtvB(t, y, yB, fyB, vB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [JvB, flag] = feval(fct,t,y,yB,fyB,vB);
-  new_data =[];
-else
-  [JvB, flag, new_data] = feval(fct,t,y,yB,fyB,vB,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_monitor.m b/sundialsTB/cvodes/cvm/cvm_monitor.m
deleted file mode 100644
index 26655c5..0000000
--- a/sundialsTB/cvodes/cvm/cvm_monitor.m
+++ /dev/null
@@ -1,17 +0,0 @@
-function new_mondata = cvm_monitor(call, t, y, yQ, Ns, yS, fct, mondata)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-N = length(y);
-
-yS = reshape(yS,N,Ns);
-
-if isempty(mondata)
-  feval(fct, call, t, y, yQ, yS);
-  new_mondata = [];
-else
-  new_mondata = feval(fct, call, t, y, yQ, yS, mondata);
-end
-
diff --git a/sundialsTB/cvodes/cvm/cvm_monitorB.m b/sundialsTB/cvodes/cvm/cvm_monitorB.m
deleted file mode 100644
index 53908c8..0000000
--- a/sundialsTB/cvodes/cvm/cvm_monitorB.m
+++ /dev/null
@@ -1,15 +0,0 @@
-function [new_mondata] = cvm_monitorB(call, idxB, t, y, yQ, fct, mondata)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-N = length(y);
-
-idxB = idxB+1;
-if isempty(mondata)
-  feval(fct, call, idxB, t, y, yQ);
-  new_mondata = [];
-else
-  new_mondata = feval(fct, call, idxB, t, y, yQ, mondata);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_options.m b/sundialsTB/cvodes/cvm/cvm_options.m
deleted file mode 100644
index 1a0f2bc..0000000
--- a/sundialsTB/cvodes/cvm/cvm_options.m
+++ /dev/null
@@ -1,66 +0,0 @@
-function options = cvm_options(KeyNames, varargin)
-
-m = length(KeyNames);
-
-% Initialize the output options structure
-
-options = [];
-for i = 1:m
-  options.(KeyNames{i}) = [];
-end
-
-% If the first argument is an options structure, read its non-empty fields
-% and update options. Store in j the start of key-value pairs.
-
-arg = varargin{1};
-
-if isa(arg,'struct')
-  for i = 1:m
-    if isfield(arg,KeyNames{i})
-      options.(KeyNames{i}) = arg.(KeyNames{i});
-    end
-  end
-  j = 2;
-else
-  j = 1;  
-end
-
-% The remaining input arguments must be key-value pairs
-
-if rem(nargin-j,2) ~= 0
-  error('Arguments must be key-value pairs.');
-end
-
-% Process each key-value pair
-
-np = (nargin-j)/2;
-
-keynames = lower(KeyNames);
-
-for i = 1:np
-  
-  % Get the key
-  key = varargin{j};
-  
-  % key must be a string 
-  if ~isstr(key)
-    error(sprintf('Argument %d is not a string property name.', j));
-  end
-  
-  % Get the index in keynames that exactly matches the current key
-  % (modulo the case)
-  ik = strmatch(lower(key), keynames, 'exact');
-  if isempty(ik)
-    error(sprintf('Unrecognized property "%s"', key));
-  end
-
-  % Get the value
-  val = varargin{j+1};
-
-  % Set the proper field in options
-  options.(KeyNames{ik}) = val;
-  
-  % move to next pair  
-  j = j+2;
-  
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_pset.m b/sundialsTB/cvodes/cvm/cvm_pset.m
deleted file mode 100644
index b4dfe80..0000000
--- a/sundialsTB/cvodes/cvm/cvm_pset.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [jcur, flag, new_data] = cvm_pset(t, y, fy, jok, gm, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [jcur, flag] = feval(fct,t,y,fy,jok,gm);
-  new_data = [];
-else
-  [jcur, flag, new_data] = feval(fct,t,y,fy,jok,gm,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_psetB.m b/sundialsTB/cvodes/cvm/cvm_psetB.m
deleted file mode 100644
index e356b53..0000000
--- a/sundialsTB/cvodes/cvm/cvm_psetB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [jcurB, flag, new_data] = cvm_psetB(t, y, yB, fyB, jokB, gmB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [jcurB, flag] = feval(fct,t,y,yB,fyB,jokB,gmB);
-  new_data = [];
-else
-  [jcurB, flag, new_data] = feval(fct,t,y,yB,fyB,jokB,gmB,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_psol.m b/sundialsTB/cvodes/cvm/cvm_psol.m
deleted file mode 100644
index 52fee12..0000000
--- a/sundialsTB/cvodes/cvm/cvm_psol.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [z, flag, new_data] = cvm_psol(t, y, fy, r, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [z, flag] = feval(fct,t,y,fy,r);
-  new_data = [];
-else
-  [z, flag, new_data] = feval(fct,t,y,fy,r,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_psolB.m b/sundialsTB/cvodes/cvm/cvm_psolB.m
deleted file mode 100644
index ba21ec9..0000000
--- a/sundialsTB/cvodes/cvm/cvm_psolB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [zB, flag, new_data] = cvm_psolB(t, y, yB, fyB, rB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [zB, flag] = feval(fct,t,y,yB,fyB,rB);
-  new_data = [];
-else
-  [zB, flag, new_data] = feval(fct,t,y,yB,fyB,rB,data);
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_rhs.m b/sundialsTB/cvodes/cvm/cvm_rhs.m
deleted file mode 100644
index a38928d..0000000
--- a/sundialsTB/cvodes/cvm/cvm_rhs.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [yd, flag, new_data] = cvm_rhs(t, y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [yd, flag] = feval(fct,t,y);
-  new_data = [];
-else
-  [yd, flag, new_data] = feval(fct,t,y,data);
-end
-
diff --git a/sundialsTB/cvodes/cvm/cvm_rhsB.m b/sundialsTB/cvodes/cvm/cvm_rhsB.m
deleted file mode 100644
index 0447c48..0000000
--- a/sundialsTB/cvodes/cvm/cvm_rhsB.m
+++ /dev/null
@@ -1,48 +0,0 @@
-function [yBd, flag, new_data] = cvm_rhsB(type, varargin)
- 
-%
-% Wrapper around the actual user-provided Matlab function
-%
- 
-switch type
-   
- case 0
- 
-  % Not dependent on yS
-   
-  t    = varargin{1};
-  y    = varargin{2};
-  yB   = varargin{3};
-  fct  = varargin{4};
-  data = varargin{5};
-   
-  if isempty(data)
-    [yBd, flag] = feval(fct,t,y,yB);
-    new_data = [];
-  else
-    [yBd, flag, new_data] = feval(fct,t,y,yB,data);
-  end
- 
- case 1
-   
-  % Dependent on yS
-   
-  t    = varargin{1};
-  y    = varargin{2};
-  Ns   = varargin{3};
-  yS   = varargin{4};
-  yB   = varargin{5};
-  fct  = varargin{6};
-  data = varargin{7};
-   
-  N = length(y);
-  yS = reshape(yS,N,Ns);
-  
-  if isempty(data)
-    [yBd, flag] = feval(fct,t,y,yS,yB);
-    new_data = [];
-  else
-    [yBd, flag, new_data] = feval(fct,t,y,yS,yB,data);
-  end
- 
-end
diff --git a/sundialsTB/cvodes/cvm/cvm_rhsQ.m b/sundialsTB/cvodes/cvm/cvm_rhsQ.m
deleted file mode 100644
index 9975c50..0000000
--- a/sundialsTB/cvodes/cvm/cvm_rhsQ.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [qd, flag, new_data] = cvm_rhsQ(t, y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [qd, flag] = feval(fct,t,y);
-  new_data =[];
-else
-  [qd, flag, new_data] = feval(fct,t,y,data);
-end
-
diff --git a/sundialsTB/cvodes/cvm/cvm_rhsQB.m b/sundialsTB/cvodes/cvm/cvm_rhsQB.m
deleted file mode 100644
index c109a10..0000000
--- a/sundialsTB/cvodes/cvm/cvm_rhsQB.m
+++ /dev/null
@@ -1,49 +0,0 @@
-function [qBd, flag, new_data] = cvm_rhsQB(type, varargin)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-switch type
-  
- case 0
- 
-  % Not dependent on yS
-
-  t    = varargin{1};
-  y    = varargin{2};
-  yB   = varargin{3};
-  fct  = varargin{4};
-  data = varargin{5};
-  
-  if isempty(data)
-    [qBd, flag] = feval(fct,t,y,yB);
-    new_data = [];
-  else
-    [qBd, flag, new_data] = feval(fct,t,y,yB,data);
-  end
-
- case 1
- 
-  % Dependent on yS
-
-  t    = varargin{1};
-  y    = varargin{2};
-  Ns   = varargin{3};
-  yS   = varargin{4};
-  yB   = varargin{5};
-  fct  = varargin{6};
-  data = varargin{7};
-  
-  N = length(y);
-  yS = reshape(yS,N,Ns);
-  
-  if isempty(data)
-    [qBd, flag] = feval(fct,t,y,yS,yB);
-    new_data = [];
-  else
-    [qBd, flag, new_data] = feval(fct,t,y,yS,yB,data);
-  end
-
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/cvodes/cvm/cvm_rhsS.m b/sundialsTB/cvodes/cvm/cvm_rhsS.m
deleted file mode 100644
index f90f33b..0000000
--- a/sundialsTB/cvodes/cvm/cvm_rhsS.m
+++ /dev/null
@@ -1,17 +0,0 @@
-function [ySd, flag, new_data] = cvm_rhsS(t, y, yd, Ns, yS, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-N = length(y);
-yS = reshape(yS,N,Ns);
-
-if isempty(data)
-  [ySd, flag] = feval(fct,t,y,yd,yS);
-  new_data = [];
-else
-  [ySd, flag, new_data] = feval(fct,t,y,yd,yS,data);
-end
-
-ySd = reshape(ySd,N*Ns,1);
\ No newline at end of file
diff --git a/sundialsTB/cvodes/cvm/cvm_root.m b/sundialsTB/cvodes/cvm/cvm_root.m
deleted file mode 100644
index 820d9b3..0000000
--- a/sundialsTB/cvodes/cvm/cvm_root.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [g, flag, new_data] = cvm_root(t, y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [g, flag] = feval(fct,t,y);
-  new_data = [];
-else
-  [g, flag, new_data] = feval(fct,t,y,data);
-end
-
diff --git a/sundialsTB/cvodes/cvm/src/cvm.c b/sundialsTB/cvodes/cvm/src/cvm.c
deleted file mode 100644
index aa7f8c7..0000000
--- a/sundialsTB/cvodes/cvm/src/cvm.c
+++ /dev/null
@@ -1,3662 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.26 $
- * $Date: 2012/03/07 21:48:00 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/cvodes/LICENSE.
- * -----------------------------------------------------------------
- * MEX implementation for CVODES Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include "cvm.h"
-#include "nvm.h"
-
-/*
- * ---------------------------------------------------------------------------------
- * Global interface data variable
- * ---------------------------------------------------------------------------------
- */
-
-cvmInterfaceData cvmData = NULL;
-
-/*
- * ---------------------------------------------------------------------------------
- * Static function prototypes
- * ---------------------------------------------------------------------------------
- */
-
-static void cvmInitCVODESdata();
-static void cvmPersistCVODESdata();
-static void cvmFinalCVODESdata();
-
-static void cvmInitPbData(cvmPbData pb);
-static void cvmPersistPbData(cvmPbData pb);
-static void cvmFinalPbData(cvmPbData pb);
-
-
-static int CVM_Initialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int CVM_QuadInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int CVM_SensInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int CVM_AdjInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int CVM_InitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int CVM_QuadInitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int CVM_SensToggleOff(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int CVM_Solve(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int CVM_SolveB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int cvmSolveB_one(mxArray *plhs[], int NtoutB, double *toutB, int itaskB);
-static int cvmSolveB_more(mxArray *plhs[], int NtoutB, double *toutB, int itaskB,
-                          booleantype any_quadrB, booleantype any_monB);
-
-
-static int CVM_Stats(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int CVM_StatsB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-
-static int CVM_Set(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int CVM_SetB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int CVM_Get(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-
-static int CVM_Free(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-/*
- * ---------------------------------------------------------------------------------
- * Main entry point
- * ---------------------------------------------------------------------------------
- */
-
-void mexFunction(int nlhs, mxArray *plhs[],
-                 int nrhs, const mxArray *prhs[] )
-{
-  int mode;
-  /* 
-     Modes:
-     
-     1 - initialize CVODES solver
-     2 - initialize quadratures
-     3 - initialize forward sensitivity calculations
-     4 - initialize adjoint sensitivity calculations
-     5 - initialize backward solver
-     6 - initialize backward quadratures
-
-    11 - reinitialize CVODES solver
-    12 - reinitialize quadratures
-    13 - reinitialize forward sensitivity calculations
-    14 - reinitialize adjoint sensitivity calculations
-    15 - reinitialize backward solver
-    16 - reinitialize backward quadratures
-
-    18 - toggle FSA off
-
-    20 - solve problem
-    21 - solve backward problem
-
-    30 - get integrator stats
-    31 - get backward integrator stats
-    32 - extract data from cvode_mem
-
-    33 - set one optional input at a time
-    34 - set one optional input at a time for backward problems
-
-    40 - finalize
-  */
-
-  mode = (int)mxGetScalar(prhs[0]);
-
-  mexUnlock();
-
-
-  if ( (mode != 1) && (cvmData == NULL) ) {
-    mexErrMsgTxt("CVODES - Illegal attempt to call before CVodeInit.");
-  }
-
-
-  switch(mode) {
-
-    /* Initialization functions */
-
-  case 1:
-    if (cvmData != NULL) {
-      CVM_Free(nlhs, plhs, nrhs-1, &prhs[1]);
-      cvmFinalCVODESdata();
-    }
-    cvmInitCVODESdata();
-    CVM_Initialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 2:
-    CVM_QuadInitialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 3:
-    CVM_SensInitialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 4:
-    CVM_AdjInitialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 5:
-    CVM_InitializationB(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 6:
-    CVM_QuadInitializationB(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Re-initialization functions */
-
-  case 11:
-    CVM_Initialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 12:
-    CVM_QuadInitialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 13:
-    CVM_SensInitialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 14:
-    CVM_AdjInitialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 15:
-    CVM_InitializationB(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 16:
-    CVM_QuadInitializationB(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Sensitivity toggle function */
-
-  case 18:
-    CVM_SensToggleOff(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-    
-    /* Solve functions */
-
-  case 20:
-    CVM_Solve(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 21:
-    CVM_SolveB(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Optional output extraction functions */
-
-  case 30:
-    CVM_Stats(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 31:
-    CVM_StatsB(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 32:
-    CVM_Get(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 33:
-    CVM_Set(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 34:
-    CVM_SetB(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Memory deallocation function */
-
-  case 40:
-    CVM_Free(nlhs, plhs, nrhs-1, &prhs[1]);
-    cvmFinalCVODESdata();
-    return;
-
-  }
-
-  /* Unless this was the CVodeFree call,
-   * make data persistent and lock the MEX file */
-  if (mode != 40) {
-    cvmPersistCVODESdata();
-    mexLock();
-  }
-
-  return;
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Private functions
- * ---------------------------------------------------------------------------------
- */
-
-static void cvmInitCVODESdata()
-{
-  /* Allocate space for global CVODES data structure */
-
-  cvmData = (cvmInterfaceData) mxMalloc(sizeof(struct cvmInterfaceData_));
-
-  /* Initialize global CVODES data */
-
-  cvmData->cvode_mem = NULL;
-
-  cvmData->fwdPb     = NULL;
-  cvmData->bckPb     = NULL;
-
-  cvmData->NbckPb    = 0;
-
-  cvmData->Nd        = 0;
-  cvmData->Nc        = 0;
-  cvmData->asa       = FALSE;
-
-  cvmData->errMsg    = TRUE;
-
-  return;
-}
-
-
-static void cvmInitPbData(cvmPbData pb)
-{
-  mxArray *empty;
-
-  pb->n  = 0;
-  pb->nq = 0;
-  pb->ng = 0;
-  pb->ns = 0;
-
-  pb->Y  = NULL;
-  pb->YQ = NULL;
-  pb->YS = NULL;
-
-  pb->Quadr  = FALSE;
-  pb->Fsa    = FALSE;
-  pb->Mon    = FALSE;
-
-  pb->LS = LS_DENSE;
-  pb->PM = PM_NONE;
-
-  empty = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  pb->RHSfct   = mxDuplicateArray(empty);
-  pb->Gfct     = mxDuplicateArray(empty);
-  pb->QUADfct  = mxDuplicateArray(empty);
-  pb->SRHSfct  = mxDuplicateArray(empty);
-  pb->JACfct   = mxDuplicateArray(empty);
-  pb->PSETfct  = mxDuplicateArray(empty);
-  pb->PSOLfct  = mxDuplicateArray(empty);
-  pb->GLOCfct  = mxDuplicateArray(empty);
-  pb->GCOMfct  = mxDuplicateArray(empty);
-
-  pb->MONfct   = mxDuplicateArray(empty);
-  pb->MONdata  = mxDuplicateArray(empty);
-
-  pb->mtlb_data = mxDuplicateArray(empty);
-
-  pb->fwd = cvmData->fwdPb;
-
-  pb->index = 0;
-  pb->next  = NULL;
-
-  mxDestroyArray(empty);
-}
-
-
-static void cvmPersistCVODESdata()
-{
-  cvmPbData tmpPb;
-
-  /* Make global memory persistent */
-
-  if (cvmData->fwdPb != NULL) {
-    cvmPersistPbData(cvmData->fwdPb);
-    mexMakeMemoryPersistent(cvmData->fwdPb);
-  }
-
-  tmpPb = cvmData->bckPb;
-  while(tmpPb != NULL) {
-    cvmPersistPbData(tmpPb);
-    mexMakeMemoryPersistent(tmpPb);
-    tmpPb = tmpPb->next;
-  }
-  
-  mexMakeMemoryPersistent(cvmData);
-
-  return;
-}
-
-
-static void cvmPersistPbData(cvmPbData pb)
-{
-  mexMakeArrayPersistent(pb->mtlb_data);
-
-  mexMakeArrayPersistent(pb->RHSfct);
-  mexMakeArrayPersistent(pb->Gfct);
-  mexMakeArrayPersistent(pb->QUADfct);
-  mexMakeArrayPersistent(pb->SRHSfct);
-  mexMakeArrayPersistent(pb->JACfct);
-  mexMakeArrayPersistent(pb->PSETfct);
-  mexMakeArrayPersistent(pb->PSOLfct);
-  mexMakeArrayPersistent(pb->GLOCfct);
-  mexMakeArrayPersistent(pb->GCOMfct);
-
-  mexMakeArrayPersistent(pb->MONfct);
-  mexMakeArrayPersistent(pb->MONdata);
-}
-
-static void cvmFinalCVODESdata()
-{  
-  cvmPbData tmpPb;
-
-  if (cvmData == NULL) return;
-
-  if (cvmData->fwdPb != NULL) {
-    cvmFinalPbData(cvmData->fwdPb);
-    mxFree(cvmData->fwdPb);
-    cvmData->fwdPb = NULL;
-  }
-
-  while(cvmData->bckPb != NULL) {
-    tmpPb = cvmData->bckPb->next;
-    mxFree(cvmData->bckPb);
-    cvmData->bckPb = tmpPb;
-  }
-
-  mxFree(cvmData);
-  cvmData = NULL;
-
-  return;
-}
-
-
-static void cvmFinalPbData(cvmPbData pb)
-{
-  if (pb->Y != NULL) N_VDestroy(pb->Y);
-  if (pb->YQ != NULL) N_VDestroy(pb->YQ);
-  if (pb->YS != NULL) N_VDestroyVectorArray(pb->YS, pb->ns);
-
-  mxDestroyArray(pb->mtlb_data);
-
-  mxDestroyArray(pb->RHSfct);
-  mxDestroyArray(pb->Gfct);
-  mxDestroyArray(pb->QUADfct);
-  mxDestroyArray(pb->SRHSfct);
-  mxDestroyArray(pb->JACfct);
-  mxDestroyArray(pb->PSETfct);
-  mxDestroyArray(pb->PSOLfct);
-  mxDestroyArray(pb->GLOCfct);
-  mxDestroyArray(pb->GCOMfct);
-
-  mxDestroyArray(pb->MONfct);
-  mxDestroyArray(pb->MONdata);
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Error handler function.
- *
- * This function is both passed as the CVODES error handler and used throughout
- * the Matlab interface.
- *
- * If called directly by one of the interface functions, error_code = -999 to
- * indicate an error and err_code = +999 to indicate a warning. Otherwise,
- * err_code is set by the calling CVODES function.
- *
- * NOTE: mexErrMsgTxt will end the execution of the MEX file. Therefore we do
- *       not have to intercept any of the CVODES error return flags.
- *       The only return flags we intercept are those from CVode() and CVodeB()
- *       which are passed back to the user (only positive values will make it). 
- * ---------------------------------------------------------------------------------
- */
-
-void cvmErrHandler(int error_code, 
-                   const char *module, const char *function, 
-                   char *msg, void *eh_data)
-{
-  char err_msg[256];
-
-  if (!(cvmData->errMsg)) return;
-
-  if (error_code > 0) {
-    sprintf(err_msg,"Warning in ==> %s\n%s",function,msg);
-    mexWarnMsgTxt(err_msg);    
-  } else if (error_code < 0) {
-    /*mexUnlock();
-      cvmFinalCVODESdata();*/
-    sprintf(err_msg,"Error using ==> %s\n%s",function,msg);
-    mexErrMsgTxt(err_msg);
-  }
-
-  return;
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define cvode_mem   (cvmData->cvode_mem)
-
-#define asa         (cvmData->asa)
-#define Nd          (cvmData->Nd) 
-#define Nc          (cvmData->Nc) 
-#define NbckPb      (cvmData->NbckPb)
-
-#define fsa         (fwdPb->Fsa)
-#define quadr       (fwdPb->Quadr)
-#define mon         (fwdPb->Mon)
-#define rootSet     (fwdPb->RootSet)
-#define tstopSet    (fwdPb->TstopSet)
-
-#define y           (fwdPb->Y) 
-#define yQ          (fwdPb->YQ) 
-#define yS          (fwdPb->YS) 
-#define N           (fwdPb->n) 
-#define Nq          (fwdPb->nq) 
-#define Ng          (fwdPb->ng) 
-#define Ns          (fwdPb->ns) 
-#define ls          (fwdPb->LS) 
-#define pm          (fwdPb->PM)
-
-#define mtlb_data     (fwdPb->mtlb_data)
-
-#define mtlb_RHSfct   (fwdPb->RHSfct)
-#define mtlb_QUADfct  (fwdPb->QUADfct)
-#define mtlb_JACfct   (fwdPb->JACfct)
-#define mtlb_PSETfct  (fwdPb->PSETfct)
-#define mtlb_PSOLfct  (fwdPb->PSOLfct)
-#define mtlb_GLOCfct  (fwdPb->GLOCfct)
-#define mtlb_GCOMfct  (fwdPb->GCOMfct)
-#define mtlb_Gfct     (fwdPb->Gfct)
-#define mtlb_SRHSfct  (fwdPb->SRHSfct)
-
-#define mtlb_MONfct   (fwdPb->MONfct)
-#define mtlb_MONdata  (fwdPb->MONdata)
-
-
-
-#define indexB      (bckPb->index)
-
-#define quadrB      (bckPb->Quadr)
-#define monB        (bckPb->Mon)
-
-#define yB          (bckPb->Y) 
-#define yQB         (bckPb->YQ) 
-#define NB          (bckPb->n) 
-#define NqB         (bckPb->nq) 
-#define lsB         (bckPb->LS) 
-#define pmB         (bckPb->PM) 
-
-#define mtlb_dataB    (bckPb->mtlb_data)
-
-#define mtlb_RHSfctB  (bckPb->RHSfct)
-#define mtlb_QUADfctB (bckPb->QUADfct)
-#define mtlb_JACfctB  (bckPb->JACfct)
-#define mtlb_PSETfctB (bckPb->PSETfct)
-#define mtlb_PSOLfctB (bckPb->PSOLfct)
-#define mtlb_GLOCfctB (bckPb->GLOCfct)
-#define mtlb_GCOMfctB (bckPb->GCOMfct)
-
-#define mtlb_MONfctB  (bckPb->MONfct)
-#define mtlb_MONdataB (bckPb->MONdata)
-
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Exported procedures
- * ---------------------------------------------------------------------------------
- */
-
-/* CVM_Initialization
- *
- * action = 0   -> CVodeCreate + CVodeInit
- * prhs contains:
- *   fct 
- *   lmm
- *   iter
- *   t0
- *   y0
- *   options
- *   data
- *
- * action = 1   -> CVodeReInit
- * prhs contains:
- *   t0
- *   y0
- *   options
- *
- */
-
-static int CVM_Initialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-
-  const mxArray *options;
-
-  double t0, *y0;
-
-  int lmm, iter, maxord;
-
-  long int mxsteps;
-
-  int itol;
-  realtype reltol, Sabstol, *Vabstol;
-  N_Vector NV_abstol;
-
-  double hin, hmax, hmin;
-
-  double tstop;
-
-  booleantype sld;
-
-  booleantype errmsg;
-
-  booleantype rhs_s; /* ignored */
-
-  long int mupper, mlower;
-  int ptype, gstype, maxl;
-  long int mudq, mldq;
-  double dqrely;
-
-  char *bufval;
-  int buflen, status;
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* SOLVER INITIALIZATION */
-
-    /* Create and initialize a new problem */
-
-    fwdPb = (cvmPbData) mxMalloc(sizeof(struct cvmPbData_));
-    cvmInitPbData(fwdPb);
-
-    cvmData->fwdPb = fwdPb;
-
-    /* Initialize appropriate vector module */
-
-    InitVectors();
-
-    /* Extract user-provided RHS function */
-
-    mxDestroyArray(mtlb_RHSfct);
-    mtlb_RHSfct = mxDuplicateArray(prhs[0]);
-
-    /* Extract lmm */
-
-    buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(prhs[1], bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeInit",
-                    "Cannot parse LMM input argument.", NULL);
-      goto error_return;
-    }
-    if(!strcmp(bufval,"Adams"))    {
-      lmm = CV_ADAMS;
-    } else if(!strcmp(bufval,"BDF")) {
-      lmm = CV_BDF;
-    } else {
-      cvmErrHandler(-999, "CVODES", "CVodeInit",
-                    "LMM has an illegal value.", NULL);
-      goto error_return;
-    }
-    mxFree(bufval);
-
-    /* Extract iter */
-
-    buflen = mxGetM(prhs[2]) * mxGetN(prhs[2]) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(prhs[2], bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeInit",
-                    "Cannot parse NLS input argument.", NULL);
-      goto error_return;
-    }
-    if(!strcmp(bufval,"Functional"))  {
-      iter = CV_FUNCTIONAL;
-    } else if(!strcmp(bufval,"Newton")) {
-      iter = CV_NEWTON;
-    } else {
-      cvmErrHandler(-999, "CVODES", "CVodeInit",
-                    "NLS has an illegal value.", NULL);
-      goto error_return;
-    }
-    mxFree(bufval);
-
-    /* Extract initial time */
-
-    t0 = (double)mxGetScalar(prhs[3]);
-
-    /* Extract initial conditions */
-
-    y0 = mxGetPr(prhs[4]);
-    N = mxGetM(prhs[4]);
-
-    /* Create the solution N_Vector */
-
-    y = NewVector(N);
-
-    /* Load initial conditions */
-
-    PutData(y, y0, N);
-
-    /* Extract options structure */
-    
-    options = prhs[5];
-
-    break;
-
-  case 1:    /* SOLVER RE-INITIALIZATION */
-
-    fwdPb = cvmData->fwdPb;
-
-    /* If monitoring was enabled, finalize it now. */
-
-    if (mon) mxW_CVodeMonitor(2, 0.0, NULL, NULL, NULL, fwdPb);
-
-    /* Extract initial time */
-
-    t0 = (double)mxGetScalar(prhs[0]);
-
-    /* Extract initial conditions */
-
-    y0 = mxGetPr(prhs[1]);
-
-    if (mxGetM(prhs[1]) != N) {
-      cvmErrHandler(-999, "CVODES", "CVodeReInit",
-                    "Size of y0 changed from CVodeInit call.", NULL);
-      goto error_return;
-    }
-
-    /* Load initial conditions */
-
-    PutData(y, y0, N);
-
-    /* Extract options structure */
-    
-    options = prhs[2];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_IntgrOptions(options, fwdPb, TRUE, lmm,
-                            &maxord, &sld, &errmsg, &mxsteps,
-                            &itol, &reltol, &Sabstol, &Vabstol,
-                            &hin, &hmax, &hmin, &tstop, &rhs_s);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate CVODES functions
-   *
-   * If action = 0
-   *    Create CVODES object and allocate memory
-   *    Attach error handler function
-   *    Redirect output
-   * If action = 1
-   *    Reinitialize solver
-   * ----------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:
-
-    /* Create CVODES object */
-    cvode_mem = CVodeCreate(lmm, iter);
-    if (cvode_mem == NULL) goto error_return;
-
-    /* Attach the global CVODES data as 'user-data' */
-    status = CVodeSetUserData(cvode_mem, fwdPb);
-    if (status != CV_SUCCESS) goto error_return;
-
-    /* Attach error handler function */
-    status = CVodeSetErrHandlerFn(cvode_mem, cvmErrHandler, NULL);
-    if (status != CV_SUCCESS) goto error_return;
-
-    /* Call CVodeInit */
-    status = CVodeInit(cvode_mem, mxW_CVodeRhs, t0, y);
-    if (status != CV_SUCCESS) goto error_return;
-
-    /* Redirect output */
-    status = CVodeSetErrFile(cvode_mem, stdout);
-    if (status != CV_SUCCESS) goto error_return;
-
-    break;
-
-  case 1:
-
-    /* Reinitialize solver */
-    status = CVodeReInit(cvode_mem, t0, y);
-    if (status != CV_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances
-   * ----------------------------------------
-   */
-
-  switch (itol) {
-    case CV_SS:
-      status = CVodeSStolerances(cvode_mem, reltol, Sabstol);
-      if (status != CV_SUCCESS) goto error_return;
-      break;
-    case CV_SV:
-      NV_abstol = N_VClone(y);
-      PutData(NV_abstol, Vabstol, N);
-      status = CVodeSVtolerances(cvode_mem, reltol, NV_abstol);
-      if (status != CV_SUCCESS) goto error_return;
-      N_VDestroy(NV_abstol);
-      break;
-    }
-  
-  /*
-   * --------------------------------
-   * Set various optional inputs
-   * --------------------------------
-   */
-
-  /* set maxorder (default is consistent with LMM) */
-  status = CVodeSetMaxOrd(cvode_mem, maxord);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* set initial step size (the default value of 0.0 is ignored by CVODES) */
-  status = CVodeSetInitStep(cvode_mem, hin);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* set max step (default is infinity) */
-  status = CVodeSetMaxStep(cvode_mem, hmax);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* set min step (default is 0) */
-  status = CVodeSetMinStep(cvode_mem, hmin);
-  if (status != CV_SUCCESS) goto error_return;
- 
-  /* set number of max steps */
-  status = CVodeSetMaxNumSteps(cvode_mem, mxsteps);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* set tstop? */
-  if (tstopSet) {
-    status = CVodeSetStopTime(cvode_mem, tstop);
-    if (status != CV_SUCCESS) goto error_return;
-  }
-
-  /* set stability limit detection (default is FALSE) */
-  status = CVodeSetStabLimDet(cvode_mem, sld);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* Rootfinding? */
-  if ( !mxIsEmpty(mtlb_Gfct) && (Ng > 0) ) {
-    status = CVodeRootInit(cvode_mem, Ng, mxW_CVodeGfct);
-    if (status != CV_SUCCESS) goto error_return;
-    rootSet = TRUE;
-  } else {
-    rootSet = FALSE;
-  }
-
-  /*
-   * ----------------------------------------
-   * Need a linear solver?
-   * ----------------------------------------
-   */
-
-  if (iter == CV_NEWTON) {
-
-    status = get_LinSolvOptions(options, fwdPb, TRUE,
-                                &mupper, &mlower,
-                                &mudq, &mldq, &dqrely,
-                                &ptype, &gstype, &maxl);
-    if (status != 0) goto error_return;
-
-    switch (ls) {
-
-    case LS_DENSE:
-
-      status = CVDense(cvode_mem, N);
-      if (status != CV_SUCCESS) goto error_return;
-      if (!mxIsEmpty(mtlb_JACfct)) {
-        status = CVDlsSetDenseJacFn(cvode_mem, mxW_CVodeDenseJac);
-        if (status != CV_SUCCESS) goto error_return;
-      }
-
-      break;
-
-    case LS_DIAG:
-
-      status = CVDiag(cvode_mem);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    case LS_BAND:
-
-      status = CVBand(cvode_mem, N, mupper, mlower);
-      if (status != CV_SUCCESS) goto error_return;
-      if (!mxIsEmpty(mtlb_JACfct)) {
-        status = CVDlsSetBandJacFn(cvode_mem, mxW_CVodeBandJac);
-        if (status != CV_SUCCESS) goto error_return;
-      }
-
-      break;
-
-    case LS_SPGMR:
-
-      status = CVSpgmr(cvode_mem, ptype, maxl);
-      if (status != CV_SUCCESS) goto error_return;
-      status = CVSpilsSetGSType(cvode_mem, gstype);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    case LS_SPBCG:
-
-      status = CVSpbcg(cvode_mem, ptype, maxl);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    case LS_SPTFQMR:
-
-      status = CVSptfqmr(cvode_mem, ptype, maxl);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    }
-
-
-    /* Jacobian * vector and preconditioner for SPILS linear solvers */
-
-    if ( (ls==LS_SPGMR) || (ls==LS_SPBCG) || (ls==LS_SPTFQMR) ) {
-
-      if (!mxIsEmpty(mtlb_JACfct)) {
-        status = CVSpilsSetJacTimesVecFn(cvode_mem, mxW_CVodeSpilsJac);
-        if (status != CV_SUCCESS) goto error_return;
-      }
-
-      switch (pm) {
-
-      case PM_NONE:
-
-        if (!mxIsEmpty(mtlb_PSOLfct)) {
-
-          if (!mxIsEmpty(mtlb_PSETfct)) status = CVSpilsSetPreconditioner(cvode_mem, mxW_CVodeSpilsPset, mxW_CVodeSpilsPsol);
-          else                          status = CVSpilsSetPreconditioner(cvode_mem, NULL, mxW_CVodeSpilsPsol);
-          if (status != CV_SUCCESS) goto error_return;
-
-        }
-
-        break;
-
-      case PM_BANDPRE:
-
-        status = CVBandPrecInit(cvode_mem, N, mupper, mlower);
-        if (status != CV_SUCCESS) goto error_return;
-
-        break;
-
-      case PM_BBDPRE:
-
-        if (!mxIsEmpty(mtlb_GCOMfct)) status = CVBBDPrecInit(cvode_mem, N, mudq, mldq, mupper, mlower, dqrely, mxW_CVodeBBDgloc, mxW_CVodeBBDgcom);
-        else                          status = CVBBDPrecInit(cvode_mem, N, mudq, mldq, mupper, mlower, dqrely, mxW_CVodeBBDgloc, NULL);
-        if (status != CV_SUCCESS) goto error_return;
-
-        break;
-      }
-
-    }
-
-  } else {
-
-    ls = LS_NONE;
-
-  }
-
-  /* Do we monitor? */
-  
-  if (mon) mxW_CVodeMonitor(0, t0, NULL, NULL, NULL, fwdPb);
-
-  /* Set errMsg field in global data 
-   * (all error messages from here on will respect this) */
-
-  cvmData->errMsg = errmsg;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-/* CVM_QuadInitialization
- *
- * action = 0   -> CVodeQuadInit
- * prhs contains:
- *   fQ
- *   y0
- *   options
- *
- * action = 1   -> CVodeQuadReInit
- * prhs contains:
- *   y0
- *   options
- *
- */
-
-static int CVM_QuadInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-
-  const mxArray *options;
-
-  double *yQ0;
-
-  booleantype rhs_s; /* ignored */
-
-  booleantype errconQ;
-  int itolQ;
-  realtype reltolQ, SabstolQ, *VabstolQ;
-  N_Vector NV_abstolQ;
-
-  int status;
-
-  fwdPb = cvmData->fwdPb;
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* QUADRATURE INITIALIZATION */
-
-    /* Extract user-provided quadrature RHS function */
-
-    mxDestroyArray(mtlb_QUADfct);
-    mtlb_QUADfct = mxDuplicateArray(prhs[0]);
-  
-    /* Extract quadrature initial conditions */
-
-    yQ0 = mxGetPr(prhs[1]);
-    Nq = mxGetM(prhs[1]);
-
-    /* Create the quadrature N_Vector */
-
-    yQ = NewVector(Nq);
-
-    /* Load quadrature initial conditions */
-    
-    PutData(yQ, yQ0, Nq);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[2];
-
-    break;
-
-  case 1:     /* QUADRATURE RE-INITIALIZATION */
-
-    /* Extract quadrature initial conditions */
-
-    yQ0 = mxGetPr(prhs[0]);
-
-    if (mxGetM(prhs[0]) != Nq) {
-      cvmErrHandler(-999, "CVODES", "CVodeQuadReInit",
-                    "Size of yQ0 changed from CVodeQuadInit call.", NULL);
-      goto error_return;
-    }
-
-    /* Load quadrature initial conditions */
-    
-    PutData(yQ, yQ0, Nq);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[1];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_QuadOptions(options, fwdPb, TRUE,
-                           Nq, &rhs_s,
-                           &errconQ, 
-                           &itolQ, &reltolQ, &SabstolQ, &VabstolQ);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate CVODES functions
-   *
-   * If action = 0
-   *    Initialize quadratures
-   * If action = 1
-   *    Reinitialize quadratures
-   * ----------------------------------------
-   */
-
-  switch (action) {
-  case 0:
-    status = CVodeQuadInit(cvode_mem, mxW_CVodeQUADfct, yQ);
-    if (status != CV_SUCCESS) goto error_return;
-    break;
-  case 1:
-    status = CVodeQuadReInit(cvode_mem, yQ);
-    if (status != CV_SUCCESS) goto error_return;
-    break;
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances for quadrature variables
-   * ----------------------------------------
-   */
-
-  status = CVodeSetQuadErrCon(cvode_mem, errconQ);
-  if (status != CV_SUCCESS) goto error_return;
-
-  if (errconQ) {
-    
-    switch (itolQ) {
-    case CV_SS:
-      status = CVodeQuadSStolerances(cvode_mem, reltolQ, SabstolQ);
-      if (status != CV_SUCCESS) goto error_return;
-      break;
-    case CV_SV:
-      NV_abstolQ = N_VClone(yQ);
-      PutData(NV_abstolQ, VabstolQ, Nq);
-      status = CVodeQuadSVtolerances(cvode_mem, reltolQ, NV_abstolQ);
-      if (status != CV_SUCCESS) goto error_return;
-      N_VDestroy(NV_abstolQ);
-      break;
-    }
-    
-  }
-
-  /* Quadratures will be integrated */
-
-  quadr = TRUE;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-/* CVM_SensInitialization
- *
- * action = 0 -> CVodeSensInit
- * prhs contains:
- *   Ns
- *   fS
- *   yS0
- *   options
- * action = 1 -> CVodeSensReInit
- *   yS0
- *   options
- *
- */
-
-static int CVM_SensInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-
-  const mxArray *options;
-
-  booleantype fS_DQ;
-  CVSensRhsFn rhsS;
-
-  double *yS0;
-
-  int ism;
-
-  mxArray *pfield;
-  char *pfield_name;
-
-  booleantype errconS;
-  int itolS;
-  realtype reltolS;
-  realtype *SabstolS, *VabstolS;
-  N_Vector *NV_abstolS;
-
-  int *plist, dqtype;
-  double *p, *pbar, rho;
-
-  int is, status;
-
-  p = NULL;
-  plist = NULL;
-  pbar = NULL;
-
-  fwdPb = cvmData->fwdPb;
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* FSA INITIALIZATION */
-
-    /* Extract number of sensitivities */
-
-    Ns = (int)mxGetScalar(prhs[0]);
-
-    /* Extract user-provided sensitivity RHS function */
-
-    if ( mxIsEmpty(prhs[1]) ) {
-      rhsS = NULL;
-      fS_DQ = TRUE;
-    } else {
-      mxDestroyArray(mtlb_SRHSfct);
-      mtlb_SRHSfct = mxDuplicateArray(prhs[1]);
-      rhsS = mxW_CVodeSensRhs;
-      fS_DQ = FALSE;
-    }
-
-    /* Extract sensitivity initial condition */
-
-    yS0 = mxGetPr(prhs[2]);
-
-    /* Create the sensitivity N_Vectors */
-
-    yS = N_VCloneVectorArray(Ns, y);
-
-    /* Load sensitivity initial conditions */
-
-    for (is=0;is<Ns;is++)
-      PutData(yS[is], &yS0[is*N], N);
-
-    /* Extract FSA options structure */
-
-    options = prhs[3];
-
-    break;
-
-  case 1:     /* FSA RE-INITIALIZATION */
-
-    /* Extract sensitivity initial condition */
-
-    yS0 = mxGetPr(prhs[0]);
-
-    if ( (mxGetM(prhs[0]) != N) || (mxGetN(prhs[0]) != Ns) )  {
-      cvmErrHandler(-999, "CVODES", "CVodeSensReInit",
-                    "Size of yS0 changed from CVodeSensInit call.", NULL);
-      goto error_return;
-    }
-
-    /* Load sensitivity initial conditions */
-
-    for (is=0;is<Ns;is++)
-      PutData(yS[is], &yS0[is*N], N);
-
-    /* Extract qFSA options structure */
-
-    options = prhs[1];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_FSAOptions(options, fwdPb, 
-                          &ism,
-                          &pfield_name, &plist, &pbar,
-                          &dqtype, &rho,
-                          &errconS, &itolS, &reltolS, &SabstolS, &VabstolS);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate CVODES functions
-   *
-   * If action = 0
-   *    Check if required inputs are available
-   *    Initialize FSA
-   * If action = 1
-   *    Reinitialize FSA
-   * ----------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:
-
-    /* Test required inputs */
-    if ( fS_DQ && (pfield_name == NULL) ) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit",
-                    "pfield required but was not provided.", NULL);
-      goto error_return;
-    }
-
-    status = CVodeSensInit(cvode_mem, Ns, ism, rhsS, yS);
-    if (status != CV_SUCCESS) goto error_return;
-
-    break;
-
-  case 1:
-
-    status = CVodeSensReInit(cvode_mem, ism, yS);
-    if (status != CV_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances for sensitivity variables
-   * ----------------------------------------
-   */
-
-  switch (itolS) {
-  case CV_SS:
-    status = CVodeSensSStolerances(cvode_mem, reltolS, SabstolS);
-    if (status != CV_SUCCESS) goto error_return;
-    break;
-  case CV_SV:
-    NV_abstolS = N_VCloneVectorArray(Ns, y);
-    for (is=0;is<Ns;is++)
-      PutData(NV_abstolS[is], &VabstolS[is*N], N);
-    status = CVodeSensSVtolerances(cvode_mem, reltolS, NV_abstolS);
-    if (status != CV_SUCCESS) goto error_return;
-    N_VDestroyVectorArray(NV_abstolS, Ns);
-    break;
-  case CV_EE:
-    status = CVodeSensEEtolerances(cvode_mem);
-    if (status != CV_SUCCESS) goto error_return;
-    break;
-  }
-
-  /*
-   * --------------------------------
-   * Set various optional inputs
-   * --------------------------------
-   */
-
-  if (pfield_name != NULL) {
-    pfield = mxGetField(mtlb_data,0,pfield_name);
-    if (pfield == NULL) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit",
-                    "illegal pfield input.", NULL);
-      goto error_return;
-    }
-    p = mxGetPr(pfield);
-  }
-  
-  status = CVodeSetSensParams(cvode_mem, p, pbar, plist);
-  if (status != CV_SUCCESS) goto error_return;
-
-  status = CVodeSetSensDQMethod(cvode_mem, dqtype, rho);
-  if (status != CV_SUCCESS) goto error_return;
-
-  status = CVodeSetSensErrCon(cvode_mem, errconS);
-  if (status != CV_SUCCESS) goto error_return;
-
-  fsa = TRUE;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-/*
- * CVM_SensToggleOff
- *
- * deactivates FSA
- */
-
-static int CVM_SensToggleOff(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-  int status;
-
-  fwdPb = cvmData->fwdPb;
-
-  status = CVodeSensToggleOff(cvode_mem);
-  if (status != CV_SUCCESS) {
-    status = -1;
-    plhs[0] = mxCreateDoubleScalar((double)status);
-    return(-1);
-  }
-
-  fsa = FALSE;
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-}
-
-
-/* CVM_AdjInitialization
- *
- * prhs contains:
- *   Nd - number of interpolatin data points (i.e. steps between check points)
- *   interp - type of interpolation
- *
- */
-
-static int CVM_AdjInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  int interp;
-
-  int buflen, status;
-  char *bufval;
-
-  switch (action) {
-
-  case 0:
-
-    /* Number of steps */
-
-    Nd = (int)mxGetScalar(prhs[0]);
-
-    /* Interpolation method */
-
-    buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(prhs[1], bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeAdjInit", 
-                    "Could not parse InterpType.", NULL);
-      goto error_return;
-    }
-    if(!strcmp(bufval,"Hermite")) {
-      interp = CV_HERMITE;
-    } else if(!strcmp(bufval,"Polynomial")) {
-      interp = CV_POLYNOMIAL;
-    } else {
-      cvmErrHandler(-999, "CVODES", "CVodeAdjInit",
-                    "Interp. type has an illegal value.", NULL);
-      goto error_return;
-    }
-
-    status = CVodeAdjInit(cvode_mem, Nd, interp);
-    if (status != CV_SUCCESS) goto error_return;
-
-    break;
-
-  case 1:
-
-    status = CVodeAdjReInit(cvode_mem);
-    if (status != CV_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  asa = TRUE;
-  
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-
-/* CVM_InitializationB
- *
- * action = 0   -> CVodeCreateB + CVodeInitB
- * prhs contains:
- *   fctB
- *   lmmB
- *   iterB
- *   tF
- *   yB0
- *   options
- * plhs contains:
- *   indexB
- *
- * action = 1   -> CVodeReInitB
- * prhs contains:
- *   indexB
- *   tF
- *   yB0
- *   options
- *
- */
-
-static int CVM_InitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData bckPb;
-
-  const mxArray *options;
-
-  int idxB;
-
-  double tB0, *yB0;
-
-  int lmmB, iterB, maxordB;
-  long int mxstepsB;
-
-  int itolB;
-  realtype reltolB, SabstolB, *VabstolB;
-  N_Vector NV_abstolB;
-
-  double hinB, hmaxB, hminB;
-
-  double tstopB;            /* ignored */
-  booleantype sldB;         /* ignored */
-  booleantype errmsgB;      /* ignored */
-
-  booleantype rhs_s;
-
-  long int mupperB, mlowerB;
-  int ptypeB, gstypeB, maxlB;
-  long int mudqB, mldqB;
-  double dqrelyB;
-
-  booleantype found_bck;
-
-  char *bufval;
-  int buflen;
-
-  int status;
-  int i_status;
-
-  /* Set output containing status */
-
-  i_status = (action == 0) ? 1 : 0;
-
-  /* 
-   * -----------------------------
-   * Finalize Forward monitoring
-   * -----------------------------
-   */
-
-  if (cvmData->fwdPb->Mon) {
-    mxW_CVodeMonitor(2, 0.0, NULL, NULL, NULL, cvmData->fwdPb);
-    cvmData->fwdPb->Mon = FALSE;
-  }
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* BACKWARD SOLVER INITIALIZATION */
-
-    /* Create and initialize a new problem */
-
-    bckPb = (cvmPbData) mxMalloc(sizeof(struct cvmPbData_));
-    cvmInitPbData(bckPb);
-
-    bckPb->next = cvmData->bckPb;
-    cvmData->bckPb = bckPb;
-
-    /* Extract user-provided RHS function */
-
-    mxDestroyArray(mtlb_RHSfctB);
-    mtlb_RHSfctB = mxDuplicateArray(prhs[0]);
-
-    /* Extract lmmB */
-
-    buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(prhs[1], bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeInitB",
-                    "Cannot parse LMM input argument.", NULL);
-      goto error_return;
-    }
-    if(!strcmp(bufval,"Adams")) {
-      lmmB = CV_ADAMS;
-    } else if(!strcmp(bufval,"BDF")) {
-      lmmB = CV_BDF;
-    } else {
-      cvmErrHandler(-999, "CVODES", "CVodeInitB",
-                    "LMM has an illegal value.", NULL);
-      goto error_return;
-    }
-    mxFree(bufval);
-
-    /* Extract iterB */
-
-    buflen = mxGetM(prhs[2]) * mxGetN(prhs[2]) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(prhs[2], bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeInitB",
-                    "Cannot parse NLS input argument.", NULL);
-      goto error_return;
-    }
-    if(!strcmp(bufval,"Functional")) {
-      iterB = CV_FUNCTIONAL;
-    } else if(!strcmp(bufval,"Newton")) {
-      iterB = CV_NEWTON;
-    } else {
-      cvmErrHandler(-999, "CVODES", "CVodeInitB",
-                    "NLS has an illegal value.", NULL);
-      goto error_return;
-    }
-    mxFree(bufval);
-
-    /* Extract final time */
-
-    tB0 = (double)mxGetScalar(prhs[3]);
-
-    /* Extract final conditions */
-
-    yB0 = mxGetPr(prhs[4]);
-    NB = mxGetM(prhs[4]);
-
-    /* Create the solution N_Vector */
-
-    yB = NewVector(NB);
-
-    /* Load final conditions */
-
-    PutData(yB, yB0, NB);
-
-    /* Extract options structure */
-    
-    options = prhs[5];
-
-    break;
-
-  case 1:     /* BACKWARD SOLVER RE-INITIALIZATION */
-
-    /* Extract index of current backward problem */
-    
-    idxB = (int)mxGetScalar(prhs[0]);
-
-    /* Find current backward problem */
-
-    found_bck = FALSE;
-    bckPb = cvmData->bckPb;
-    while (bckPb != NULL) {
-      if (indexB == idxB) {
-        found_bck = TRUE;
-        break;
-      }
-      bckPb = bckPb->next;
-    }
-
-    if (!found_bck) {
-      cvmErrHandler(-999, "CVODES", "CVodeReInitB",
-                    "idxB has an illegal value.", NULL);
-      goto error_return;
-    }
-
-    /* If backward monitoring was enabled, finalize it now. */
-
-    if (monB) mxW_CVodeMonitorB(2, indexB, 0.0, NULL, NULL, bckPb);
-
-    /* Extract final time */
-
-    tB0 = (double)mxGetScalar(prhs[1]);
-
-    /* Extract final conditions */
-
-    yB0 = mxGetPr(prhs[2]);
-
-    if (mxGetM(prhs[2]) != NB) {
-      cvmErrHandler(-999, "CVODES", "CVodeReInitB",
-                    "Size of yB0 changed from CVodeInitB call.", NULL);
-      goto error_return;
-    }
-    
-    /* Load final conditions */
-
-    PutData(yB, yB0, NB);
-
-    /* Extract options structure */
-    
-    options = prhs[3];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_IntgrOptions(options, bckPb, FALSE, lmmB,
-                            &maxordB, &sldB, &errmsgB, &mxstepsB,
-                            &itolB, &reltolB, &SabstolB, &VabstolB,
-                            &hinB, &hmaxB, &hminB, &tstopB, &rhs_s);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate CVODES functions
-   *
-   * If action = 0
-   *    Create CVODES object and allocate memory
-   *    Initialize and allocate memory
-   * If action = 1
-   *    Reinitialize solver
-   * ----------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:
-
-    status = CVodeCreateB(cvode_mem, lmmB, iterB, &idxB);
-    if (status != CV_SUCCESS) goto error_return;
-
-    status = CVodeSetUserDataB(cvode_mem, idxB, bckPb);
-    if (status != CV_SUCCESS) goto error_return;
-
-    if (rhs_s) {
-      status = CVodeInitBS(cvode_mem, idxB, mxW_CVodeRhsBS, tB0, yB);
-    } else {
-      status = CVodeInitB(cvode_mem, idxB, mxW_CVodeRhsB, tB0, yB);
-    }
-    if (status != CV_SUCCESS) goto error_return;
-
-    /* Load idxB in the 1st output (status is 2nd one for this action) */
-
-    plhs[0] = mxCreateDoubleScalar((double)idxB);
-
-    indexB = idxB;
-
-    NbckPb++;
-
-    break;
-
-  case 1:
-
-    status = CVodeReInitB(cvode_mem, idxB, tB0, yB);
-    if (status != CV_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances
-   * ----------------------------------------
-   */
-
-  switch (itolB) {
-  case CV_SS:
-    status = CVodeSStolerancesB(cvode_mem, idxB, reltolB, SabstolB);
-    if (status != CV_SUCCESS) goto error_return;
-    break;
-  case CV_SV:
-    NV_abstolB = N_VClone(yB);
-    PutData(NV_abstolB, VabstolB, NB);
-    status = CVodeSVtolerancesB(cvode_mem, idxB, reltolB, NV_abstolB);
-    if (status != CV_SUCCESS) goto error_return;
-    N_VDestroy(NV_abstolB);
-    break;
-  }
-
-  /*
-   * --------------------------------
-   * Set various optional inputs
-   * --------------------------------
-   */
-
-  /* set maxorder (default is consistent with LMM) */
-  status = CVodeSetMaxOrdB(cvode_mem, idxB, maxordB);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* set initial step size (the default value of 0.0 is ignored by CVODES) */
-  status = CVodeSetInitStepB(cvode_mem, idxB, hinB);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* set max step (default is infinity) */
-  status = CVodeSetMaxStepB(cvode_mem, idxB, hmaxB);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /* set min step (default is 0) */
-  status = CVodeSetMinStepB(cvode_mem, idxB, hminB);
-  if (status != CV_SUCCESS) goto error_return;
- 
-  /* set number of max steps */
-  status = CVodeSetMaxNumStepsB(cvode_mem, idxB, mxstepsB);
-  if (status != CV_SUCCESS) goto error_return;
-
-  /*
-   * ----------------------------------------
-   * Need a linear solver?
-   * ----------------------------------------
-   */
-
-  if (iterB == CV_NEWTON) {
-
-    status = get_LinSolvOptions(options, bckPb, FALSE,
-                                &mupperB, &mlowerB,
-                                &mudqB, &mldqB, &dqrelyB,
-                                &ptypeB, &gstypeB, &maxlB);
-    if (status != 0) goto error_return;
-
-    switch(lsB) {
-
-    case LS_DENSE:
-
-      status = CVDenseB(cvode_mem, idxB, NB);
-      if (status != CV_SUCCESS) goto error_return;
-      if (!mxIsEmpty(mtlb_JACfctB)) {
-        status = CVDlsSetDenseJacFnB(cvode_mem, idxB, mxW_CVodeDenseJacB);
-        if (status != CV_SUCCESS) goto error_return;
-      }
-
-      break;
-
-    case LS_DIAG:
-
-      status = CVDiagB(cvode_mem, idxB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    case LS_BAND:
-
-      status = CVBandB(cvode_mem, idxB, NB, mupperB, mlowerB);
-      if (status != CV_SUCCESS) goto error_return;
-      if (!mxIsEmpty(mtlb_JACfctB)) {
-        status = CVDlsSetBandJacFnB(cvode_mem, idxB, mxW_CVodeBandJacB);
-        if (status != CV_SUCCESS) goto error_return;
-      }
-
-      break;
-
-    case LS_SPGMR:
-      
-      status = CVSpgmrB(cvode_mem, idxB, ptypeB, maxlB);
-      if (status != CV_SUCCESS) goto error_return;
-      status = CVSpilsSetGSTypeB(cvode_mem, idxB, gstypeB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    case LS_SPBCG:
-
-      status = CVSpbcgB(cvode_mem, idxB, ptypeB, maxlB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    case LS_SPTFQMR:
-
-      status = CVSptfqmrB(cvode_mem, idxB, ptypeB, maxlB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      break;
-
-    }
-
-    /* Jacobian * vector and preconditioner for SPILS linear solvers */
-
-    if ( (lsB==LS_SPGMR) || (lsB==LS_SPBCG) || (lsB==LS_SPTFQMR) ) {
-
-      if (!mxIsEmpty(mtlb_JACfctB)) {
-        status = CVSpilsSetJacTimesVecFnB(cvode_mem, idxB, mxW_CVodeSpilsJacB);
-        if (status != CV_SUCCESS) goto error_return;
-      }
-
-      switch (pmB) {
-
-      case PM_NONE:
-
-        if (!mxIsEmpty(mtlb_PSOLfctB)) {
-          if (!mxIsEmpty(mtlb_PSETfctB)) status = CVSpilsSetPreconditionerB(cvode_mem, idxB, mxW_CVodeSpilsPsetB, mxW_CVodeSpilsPsolB);
-          else                           status = CVSpilsSetPreconditionerB(cvode_mem, idxB, NULL, mxW_CVodeSpilsPsolB);
-        }
-        if (status != CV_SUCCESS) goto error_return;
-
-        break;
-
-      case PM_BANDPRE:
-
-        status = CVBandPrecInitB(cvode_mem, idxB, NB, mupperB, mlowerB);
-        if (status != CV_SUCCESS) goto error_return;
-
-        break;
-
-      case PM_BBDPRE:
-
-        if (!mxIsEmpty(mtlb_GCOMfctB)) status = CVBBDPrecInitB(cvode_mem, idxB, NB, mudqB, mldqB, mupperB, mlowerB, dqrelyB, mxW_CVodeBBDglocB, mxW_CVodeBBDgcomB);
-        else                           status = CVBBDPrecInitB(cvode_mem, idxB, NB, mudqB, mldqB, mupperB, mlowerB, dqrelyB, mxW_CVodeBBDglocB, NULL);
-        if (status != CV_SUCCESS) goto error_return;
-
-        break;
-
-      }
-
-    }
-
-  } else {
-
-    lsB = LS_NONE;
-
-  }
-
-  /* Do we monitor? */
-
-  if (monB) mxW_CVodeMonitorB(0, idxB, tB0, NULL, NULL, bckPb);
-
-  /* Successful return */
-
-  status = 0;
-  plhs[i_status] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[i_status] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-
-/* CVM_QuadInitializationB
- *
- * action = 0   -> CVodeQuadInitB
- * prhs contains:
- *   idxB
- *   fQB
- *   yQB0
- *   options
- *
- * action = 1   -> CVodeQuadReInitB
- *   idxB
- *   yQB0
- *   options
- *
- */
-
-static int CVM_QuadInitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData bckPb;
-
-  const mxArray *options;
-
-  int idxB;
-
-  double *yQB0;
-
-  booleantype rhs_s;
-  
-  booleantype errconQB;
-  int itolQB;
-  realtype reltolQB, SabstolQB, *VabstolQB;
-  N_Vector NV_abstolQB;
-
-  booleantype found_bck;
-
-  int status;
-
-  /* Extract index of current backward problem */
-    
-  idxB = (int)mxGetScalar(prhs[0]);
-
-  /* Find current backward problem */
-
-  found_bck = FALSE;
-  bckPb = cvmData->bckPb;
-  while (bckPb != NULL) {
-    if (indexB == idxB) {
-      found_bck = TRUE;
-      break;
-    }
-    bckPb = bckPb->next;
-  }
-
-  if (!found_bck) {
-    cvmErrHandler(-999, "CVODES", "CVodeQuadInitB/CVodeQuadReInitB",
-                  "idxB has an illegal value.", NULL);
-    goto error_return;
-  }
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* BACKWARD QUADRATURE INITIALIZATION */
-
-    /* Extract user-provided quadrature RHS function */
-
-    mxDestroyArray(mtlb_QUADfctB);
-    mtlb_QUADfctB = mxDuplicateArray(prhs[1]);
-
-    /* Extract quadrature final conditions */
-
-    yQB0 = mxGetPr(prhs[2]);
-    NqB = mxGetM(prhs[2]);
-
-    /* Create the backward quadrature N_Vector */
-
-    yQB = NewVector(NqB);
-
-    /* Load quadrature final conditions */
-
-    PutData(yQB, yQB0, NqB);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[3];
-
-    break;
-
-  case 1:     /* BACKWARD QUADRATURE RE-INITIALIZATION */
-
-
-    /* Extract quadrature final conditions */
-
-    yQB0 = mxGetPr(prhs[1]);
-
-    if (mxGetM(prhs[1]) != NqB) cvmErrHandler(-999, "CVODES", "CVodeQuadReInitB",
-                                              "Size of yQB0 changed from CVodeQuadInitB call.", NULL);
-
-    /* Load quadrature final conditions */
-
-    PutData(yQB, yQB0, NqB);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[2];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_QuadOptions(options, bckPb, FALSE,
-                           NqB, &rhs_s,
-                           &errconQB, 
-                           &itolQB, &reltolQB, &SabstolQB, &VabstolQB);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate CVODES functions
-   *
-   * If action = 0
-   *    Initialize backward quadratures
-   * If action = 1
-   *    Reinitialize backward quadratures
-   * ----------------------------------------
-   */
-
-  switch (action) {
-  case 0:
-    if (rhs_s) status = CVodeQuadInitBS(cvode_mem, idxB, mxW_CVodeQUADfctBS, yQB);
-    else       status = CVodeQuadInitB(cvode_mem, idxB, mxW_CVodeQUADfctB, yQB);
-    if (status != CV_SUCCESS) goto error_return;
-    break;
-  case 1:
-    status = CVodeQuadReInitB(cvode_mem, idxB, yQB);
-    if (status != CV_SUCCESS) goto error_return;
-    break;
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances for quadrature variables
-   * ----------------------------------------
-   */
-  
-  status = CVodeSetQuadErrConB(cvode_mem, idxB, errconQB);
-  if (status != CV_SUCCESS) goto error_return;
-
-  if (errconQB) {
-
-    switch (itolQB) {
-    case CV_SS:
-      status = CVodeQuadSStolerancesB(cvode_mem, idxB, reltolQB, SabstolQB);
-      if (status != CV_SUCCESS) goto error_return;
-      break;
-    case CV_SV:
-      NV_abstolQB = N_VClone(yQB);
-      PutData(NV_abstolQB, VabstolQB, NqB);
-      status = CVodeQuadSVtolerancesB(cvode_mem, idxB, reltolQB, NV_abstolQB);
-      if (status != CV_SUCCESS) goto error_return;
-      N_VDestroy(NV_abstolQB);
-      break;
-    }
-    
-  }
-
-  quadrB = TRUE;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-
-/*
- * CVM_Solve  - Main solution function
- *
- */
-
-static int CVM_Solve(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-
-  int buflen;
-  char *bufval;
-
-  int nlhs_bad, dims[3];
-
-  int status, cv_status;
-  int itask, is, Ntout, itout, s_idx;
-  double *tout, tret, h;
-  double *tdata, *ydata, *yQdata, *ySdata;
-  long int nst;
-
-  fwdPb = cvmData->fwdPb;
-
-
-  /* Set index of output corresponding to FSA */
-
-  if (fsa) {
-    s_idx = quadr ? 4 : 3;
-  }
-
-
-  /*
-   * ----------------------------------------------------------------
-   * Verify if number of output arguments agrees with current options
-   * ----------------------------------------------------------------
-   */
-
-  nlhs_bad = 0;
-
-  if (nlhs < 3) nlhs_bad = -1;
-  if (nlhs > 5) nlhs_bad = 1;
-  if ( (nlhs == 3) && (quadr || fsa) ) nlhs_bad = -1;
-  if ( (nlhs == 4) && (quadr && fsa) ) nlhs_bad = -1;
-  if ( (nlhs == 5) && (!quadr || !fsa) ) nlhs_bad = 1;
-
-  if (nlhs_bad < 0) {
-    cvmErrHandler(-999, "CVODES", "CVode",
-                  "Too few output arguments.", NULL);
-    goto error_return;
-  }
-
-  if (nlhs_bad > 0) {
-    cvmErrHandler(-999, "CVODES", "CVode",
-                  "Too many output arguments.", NULL);
-    goto error_return;
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Extract input arguments
-   * ----------------------------------------------------------------
-   */
-
-  /* Extract tout */
-
-  Ntout = mxGetM(prhs[0]) * mxGetN(prhs[0]);
-  tout = mxGetPr(prhs[0]);
-
-  /* If rootfinding or tstop are enabled, we do not allow multiple output times */
-
-  if (rootSet && (Ntout>1)) {
-    cvmErrHandler(-999, "CVODES", "CVode",
-                  "More than one tout value prohibited with rootfinding enabled.", NULL);
-    goto error_return;
-  }
-
-  if (tstopSet && (Ntout>1)) {
-    cvmErrHandler(-999, "CVODES", "CVode",
-                  "More than one tout value prohibited with tstop enabled.", NULL);
-    goto error_return;
-  }
-
-  /* Extract itask */
-
-  buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-  bufval = mxCalloc(buflen, sizeof(char));
-  status = mxGetString(prhs[1], bufval, buflen);
-  if(!strcmp(bufval,"Normal")) {
-    itask = CV_NORMAL;
-  } else if(!strcmp(bufval,"OneStep")) {
-    itask = CV_ONE_STEP;
-  } else {
-    cvmErrHandler(-999, "CVODES", "CVode",
-                  "Illegal value for itask.", NULL); 
-    goto error_return;
-  }
-
-  if (itask == CV_ONE_STEP) {
-
-    /* If itask==CV_ONE_STEP, we do not allow multiple output times and we do not monitor */
-
-    if (Ntout > 1) {
-      cvmErrHandler(-999, "CVODES", "CVode",
-                    "More than one tout value prohibited in ONE_STEP mode.", NULL); 
-      goto error_return;
-    }
-
-    if (mon) {
-      cvmErrHandler(+999, "CVODES", "CVode",
-                    "Monitoring disabled in ONE_STEP mode.", NULL);
-      mon = FALSE;
-    }
-
-  } else {
-
-    /* Check if tout values are legal */
-
-    status = CVodeGetCurrentTime(cvode_mem, &tret);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVodeGetNumSteps(cvode_mem, &nst);
-    if (status != CV_SUCCESS) goto error_return;
-
-    /* h is used throughout this function as integration direction only */
-    if (nst == 0) {
-      h = tout[0] - tret;
-    } else {
-      status = CVodeGetLastStep(cvode_mem, &h);
-      if (status != CV_SUCCESS) goto error_return;
-      if ( (tout[0] - tret + h)*h < 0.0 ) {
-        cvmErrHandler(-999, "CVODES", "CVode",
-                      "Illegal value of tout.", NULL);
-        goto error_return;
-      }
-    }
-    
-    for (itout=1; itout<Ntout; itout++) 
-      if ( (tout[itout] - tout[itout-1])*h < 0.0 ) {
-        cvmErrHandler(-999, "CVODES", "CVode",
-                      "tout values are not monotonic.", NULL);
-        goto error_return;
-      }
-
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Prepare the output arrays
-   * ----------------------------------------------------------------
-   */
-
-  /* Return time(s) */
-
-  plhs[1] = mxCreateDoubleMatrix(1,Ntout,mxREAL);
-  tdata = mxGetPr(plhs[1]);
-
-  /* Solution vector(s) */
-
-  plhs[2] = mxCreateDoubleMatrix(N,Ntout,mxREAL);
-  ydata = mxGetPr(plhs[2]);
-
-  /* Quadrature vector(s) */
-
-  if (quadr) {
-    plhs[3] = mxCreateDoubleMatrix(Nq,Ntout,mxREAL);
-    yQdata = mxGetPr(plhs[3]);
-  }
-
-  /* Sensitivity vectors */
-
-  if (fsa) {
-    dims[0] = N;
-    dims[1] = Ns;
-    dims[2] = Ntout;
-    plhs[s_idx] = mxCreateNumericArray(3, dims, mxDOUBLE_CLASS, mxREAL);
-    ySdata = mxGetPr(plhs[s_idx]);
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Call the CVODES main solver function
-   * ----------------------------------------------------------------
-   */
- 
-  if (!mon) {
-
-    /* No monitoring. itask can be either CV_ONE_STEP or CV_NORMAL */
-
-    for (itout=0; itout<Ntout; itout++) {
-
-      if (!asa) cv_status = CVode(cvode_mem, tout[itout], y, &tret, itask);
-      else      cv_status = CVodeF(cvode_mem, tout[itout], y, &tret, itask, &Nc);
-      if (cv_status < 0) goto error_return;
-
-      tdata[itout] = tret;
-
-      GetData(y, &ydata[itout*N], N);
-
-      if (quadr) {
-        status = CVodeGetQuad(cvode_mem, &tret, yQ);
-        if (status != CV_SUCCESS) goto error_return;
-        GetData(yQ, &yQdata[itout*Nq], Nq);
-      }
-
-      if (fsa) {
-        status = CVodeGetSens(cvode_mem, &tret, yS);
-        if (status != CV_SUCCESS) goto error_return;
-        for (is=0; is<Ns; is++)
-          GetData(yS[is], &ySdata[itout*Ns*N+is*N], N);
-      }
-
-    }
-
-  } else {
-
-    /* Monitoring. itask = CV_NORMAL */
-
-    for (itout=0; itout<Ntout; itout++) {
-      
-      /* In ONE_STEP mode, CVODE reads tout only at the first step.
-       * We must therefore check here whether we need to take additional steps,
-       * or simply return interpolated solution at tout. */
-
-      status = CVodeGetNumSteps(cvode_mem, &nst);
-      if (status != CV_SUCCESS) goto error_return;
-      status = CVodeGetCurrentTime(cvode_mem, &tret);
-      if (status != CV_SUCCESS) goto error_return;
-
-      if ( (nst>0) && ((tret - tout[itout])*h >= 0.0) ) {
-
-        /* No need to take an additional step */
-        cv_status = CV_SUCCESS;
-
-      } else {
-
-        /* Take additional steps */
-        while(1) {
-
-          if (!asa) cv_status = CVode(cvode_mem, tout[itout], y, &tret, CV_ONE_STEP);
-          else      cv_status = CVodeF(cvode_mem, tout[itout], y, &tret, CV_ONE_STEP, &Nc);
-          if (cv_status < 0) goto error_return;
-
-          /* Call the monitoring function */
-          if (quadr) {
-            status = CVodeGetQuad(cvode_mem, &tret, yQ);
-            if (status != CV_SUCCESS) goto error_return;
-          }
-          if (fsa) {
-            status = CVodeGetSens(cvode_mem, &tret, yS);
-            if (status != CV_SUCCESS) goto error_return;
-          }
-          mxW_CVodeMonitor(1, tret, y, yQ, yS, fwdPb);
-
-          /* If a root was found or tstop was reached, break out of while loop */
-          if (cv_status == CV_TSTOP_RETURN || cv_status == CV_ROOT_RETURN) break;
-
-          /* If current tout was reached break out of while loop */
-          if ( (tret - tout[itout])*h >= 0.0 )  break;
-
-        }
-
-      }
-      
-      /* On a tstop or root return, return solution at tret.
-       * Otherwise (cv_status=CV_SUCCESS), return solution at tout[itout]. */
-
-      if (cv_status == CV_TSTOP_RETURN || cv_status == CV_ROOT_RETURN) {
-
-        if (quadr) {
-          status = CVodeGetQuad(cvode_mem, &tret, yQ);
-          if (status != CV_SUCCESS) goto error_return;
-        }
-
-        if (fsa) {
-          status = CVodeGetSens(cvode_mem, &tret, yS);
-          if (status != CV_SUCCESS) goto error_return;
-        }
-
-      } else {
-
-        tret = tout[itout];
-        
-        status = CVodeGetDky(cvode_mem, tret, 0, y);
-        if (status != CV_SUCCESS) goto error_return;
-
-        if (quadr) {
-          status = CVodeGetQuadDky(cvode_mem, tret, 0, yQ);
-          if (status != CV_SUCCESS) goto error_return;
-        }
-
-        if (fsa) {
-          status = CVodeGetSensDky(cvode_mem, tret, 0, yS);
-          if (status != CV_SUCCESS) goto error_return;
-        }
-
-      }
-
-      tdata[itout] = tret;
-
-      GetData(y, &ydata[itout*N], N);
-
-      if (quadr)  GetData(yQ, &yQdata[itout*Nq], Nq);
-
-      if (fsa)
-        for (is=0; is<Ns; is++)
-          GetData(yS[is], &ySdata[itout*Ns*N+is*N], N);
-
-    }
-
-  }
-
-  /* CVODE return flag (only non-negative values make it here) */
-
-  plhs[0] = mxCreateDoubleScalar((double)cv_status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadr) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  if (fsa) {
-    s_idx = quadr ? 4 : 3;
-    plhs[s_idx] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  return(-1);
-
-}
-
-
-static int CVM_SolveB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData bckPb;
-
-  int buflen;
-  char *bufval;
-
-  int nlhs_bad;
-
-  int itaskB, NtoutB;
-  double *toutB;
-
-  double tret, h;
-
-  booleantype any_quadrB, any_monB;
-
-  int status, cv_status;
-
-  /*
-   * -------------------------------------------------------
-   * Check whether quadratures and/or monitoring are enabled
-   * for at least one backward problem
-   * -------------------------------------------------------
-   */
-
-  any_quadrB = FALSE;
-  any_monB   = FALSE;
-  bckPb = cvmData->bckPb;
-  while(bckPb != NULL) {
-    if (quadrB) any_quadrB = TRUE;
-    if (monB)   any_monB   = TRUE;
-    bckPb = bckPb->next;
-  }
-  
-  /*
-   * ----------------------------------------------------------------
-   * Verify if number of output arguments agrees with current options
-   * ----------------------------------------------------------------
-   */
-
-  nlhs_bad = 0;
-
-  if (nlhs < 3) nlhs_bad = -1;
-  if (nlhs > 4) nlhs_bad = 1;
-  if ( (nlhs == 3) && any_quadrB ) nlhs_bad = -1;
-
-  if (nlhs_bad < 0) {
-    cvmErrHandler(-999, "CVODES", "CVodeB",
-                  "Too few output arguments.", NULL);
-    goto error_return;
-  }
-
-  if (nlhs_bad > 0) {
-    cvmErrHandler(-999, "CVODES", "CVodeB",
-                  "Too many output arguments.", NULL);
-    goto error_return;
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Extract input arguments
-   * ----------------------------------------------------------------
-   */
-
-  /* Extract tout */
-
-  NtoutB = mxGetM(prhs[0]) * mxGetN(prhs[0]);
-  toutB = mxGetPr(prhs[0]);
-
-  /* Check if first tout value is in the right direction */
-
-  status = CVodeGetLastStep(cvode_mem, &h);
-  if (status != CV_SUCCESS) goto error_return;
-  status = CVodeGetCurrentTime(cvode_mem, &tret);
-  if (status != CV_SUCCESS) goto error_return;
- 
-  /* The stepsize of the forward problem is used to indicate the integration direction */
-  if ( (tret - toutB[0])*h < 0.0 ) {
-    cvmErrHandler(-999, "CVODES", "CVodeB",
-                  "tout value in wrong direction.", NULL);
-    goto error_return;
-  }
-
-  /* Extract itaskB */
-
-  buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-  bufval = mxCalloc(buflen, sizeof(char));
-  status = mxGetString(prhs[1], bufval, buflen);
-  if(!strcmp(bufval,"Normal")) {
-    itaskB = CV_NORMAL;
-  } else if(!strcmp(bufval,"OneStep")) {
-    itaskB = CV_ONE_STEP;
-  } else {
-    cvmErrHandler(-999, "CVODES", "CVodeB",
-                  "Illegal value for itask.", NULL); 
-    goto error_return;
-  }
-
-  /* If itask == CV_ONE_STEP, then
-   * - we do not allow multiple output times
-   * - we disable monitoring 
-   */
-
-  if ( itaskB == CV_ONE_STEP ) {
-    
-    if (NtoutB > 1) {
-      cvmErrHandler(-999, "CVODES", "CVodeB",
-                    "More than one tout value prohibited in ONE_STEP mode.", NULL); 
-      goto error_return;
-    }
-
-    if (any_monB) {
-      cvmErrHandler(+999, "CVODES", "CVodeB",
-                    "Monitoring disabled in itask=CV_ONE_STEP", NULL);
-      bckPb = cvmData->bckPb;
-      while(bckPb != NULL) {
-        monB = FALSE;
-        bckPb = bckPb->next;
-      }
-      any_monB = FALSE;
-    }
-
-  }
-
-  /* Call the appropriate function to do all the work.
-   * Note: if we made it here, we rely on the functions cvmSolveB_one and cvmSolveB_more
-   *       to set the output arrays in plhs appropriately. */
-
-  if (NbckPb == 1) cv_status = cvmSolveB_one(plhs, NtoutB, toutB, itaskB);
-  else             cv_status = cvmSolveB_more(plhs, NtoutB, toutB, itaskB, any_quadrB, any_monB);
-
-  if (cv_status < 0) return(-1);
-  else               return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  return(-1);
-
-}
-
-
-
-static int cvmSolveB_one(mxArray *plhs[], int NtoutB, double *toutB, int itaskB)
-{
-  cvmPbData bckPb;
-  
-  void *cvode_memB;
-
-  double tretB, hB;
-  double *tdata, *ydata, *yQdata;
-  int itout;
-  long int nstB;
-
-  int status, cv_status;
-
-  bckPb = cvmData->bckPb;
-
-  cvode_memB = CVodeGetAdjCVodeBmem(cvode_mem, indexB);
-
-  /* Check if tout values are legal */
-
-  CVodeGetCurrentTime(cvode_memB, &tretB);
-  CVodeGetNumSteps(cvode_memB, &nstB);
-
-  /* hB is used throughout this function as integration direction only */
-  if (nstB == 0) {
-    hB = toutB[0] - tretB;
-  } else {
-    CVodeGetLastStep(cvode_memB, &hB);
-    if ( (toutB[0] - tretB + hB)*hB < 0.0 ) {
-      cvmErrHandler(-999, "CVODES", "CVodeB",
-                    "Illegal value of tout.", NULL);
-      goto error_return;
-    }
-  }
-
-  for (itout=1; itout<NtoutB; itout++) {
-    if ( (toutB[itout] - toutB[itout-1])*hB < 0.0 ) {
-      cvmErrHandler(-999, "CVODES", "CVodeB",
-                    "tout values are not monotonic.", NULL);
-      goto error_return;
-    }
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Prepare the output arrays
-   * ----------------------------------------------------------------
-   */
-
-  /* Return time(s) */
-
-  plhs[1] = mxCreateDoubleMatrix(1,NtoutB,mxREAL);
-  tdata = mxGetPr(plhs[1]);
-  
-  /* Solution vector(s) */
-  
-  plhs[2] = mxCreateDoubleMatrix(NB,NtoutB,mxREAL);
-  ydata = mxGetPr(plhs[2]);
-  
-  /* Quadrature vector(s) */
-  
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(NqB,NtoutB,mxREAL);
-    yQdata = mxGetPr(plhs[3]);
-  }
-  
-  /*
-   * ----------------------------------------------------------------
-   * Call the CVodeB main solver function
-   * ----------------------------------------------------------------
-   */
-
-  if (!monB) {
-
-    /* No monitoring. itaskB can be either CV_ONE_STEP or CV_NORMAL */
-
-    for (itout=0; itout<NtoutB; itout++) {
-      
-      cv_status = CVodeB(cvode_mem, toutB[itout], itaskB);
-      if (cv_status < 0) goto error_return;
-
-      status = CVodeGetB(cvode_mem, indexB, &tretB, yB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      tdata[itout] = tretB;
-      
-      GetData(yB, &ydata[itout*NB], NB);
-      
-      if (quadrB) {
-        status = CVodeGetQuadB(cvode_mem, indexB, &tretB, yQB);
-        if (status != CV_SUCCESS) goto error_return;
-        GetData(yQB, &yQdata[itout*NqB], NqB);
-      }
-      
-    }
-    
-    
-  } else {
-
-    /* Monitoring. itask = CV_NORMAL */
-
-    for (itout=0; itout<NtoutB; itout++) {
-
-      /* In ONE_STEP mode, CVODE reads tout only at the first step.
-       * We must therefore check here whether we need to take additional steps,
-       * or simply return interpolated solution at tout. */
-
-      status = CVodeGetNumSteps(cvode_memB, &nstB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      status = CVodeGetCurrentTime(cvode_memB, &tretB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      if ( (nstB>0) && ((tretB - toutB[itout])*hB >= 0.0) ) {
-
-        /* No need to take an additional step */
-        cv_status = CV_SUCCESS;
-
-      } else {
-
-        /* Take additional steps */
-        while(1) {
-        
-          cv_status = CVodeB(cvode_mem, toutB[itout], CV_ONE_STEP);
-          if (cv_status < 0) goto error_return;          
-
-          /* Call the monitoring function */          
-
-          status = CVodeGetB(cvode_mem, indexB, &tretB, yB);
-          if (status != CV_SUCCESS) goto error_return;
-
-          if (quadrB) {
-            CVodeGetQuadB(cvode_mem, indexB, &tretB, yQB);
-            if (status != CV_SUCCESS) goto error_return;
-          }
-
-          mxW_CVodeMonitorB(1, indexB, tretB, yB, yQB, bckPb);
-          
-          /* If current tout was reached break out of while loop */
-          if ( (tretB - toutB[itout])*hB >= 0.0 ) break;
-          
-        }
-
-      }
-
-      tretB = toutB[itout];
-
-      tdata[itout] = tretB;
-
-      status = CVodeGetDky(cvode_memB, tretB, 0, yB);
-      if (status != CV_SUCCESS) goto error_return;
-
-      GetData(yB, &ydata[itout*NB], NB);
-      
-      if (quadrB) {
-        status = CVodeGetQuadDky(cvode_memB, tretB, 0, yQB);
-        if (status != CV_SUCCESS) goto error_return;
-        GetData(yQB, &yQdata[itout*NqB], NqB);
-      }
-
-    }
-
-  }
-
-  /* CVodeB return flag (only non-negative values make it here) */
-
-  plhs[0] = mxCreateDoubleScalar((double)cv_status);
-  return(0);
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  return(-1);
-
-}
-
-
-static int cvmSolveB_more(mxArray *plhs[], int NtoutB, double *toutB, int itaskB,
-                          booleantype any_quadrB, booleantype any_monB)
-{
-  cvmPbData bckPb;
-  mxArray *cell;
-  void *cvode_memB;
-
-  double tretB, h, hB;
-  double **tdata, **ydata, **yQdata;
-  int itout;
-  long int nstB;
-
-  char err_msg[80];
-
-  int status, cv_status;
-
-  /* Check if tout values are legal */
-
-  CVodeGetLastStep(cvode_mem, &h);
-
-  bckPb = cvmData->bckPb;
-  while (bckPb != NULL) {
-
-    cvode_memB = CVodeGetAdjCVodeBmem(cvode_mem, indexB);
-
-    status = CVodeGetCurrentTime(cvode_memB, &tretB);
-    if (status != CV_SUCCESS) goto error_return;
-
-    status = CVodeGetNumSteps(cvode_memB, &nstB);
-    if (status != CV_SUCCESS) goto error_return;
-
-    if (nstB > 0) {
-      status = CVodeGetLastStep(cvode_memB, &hB);
-      if (status != CV_SUCCESS) goto error_return;
-      if ( (toutB[0] - tretB + hB)*hB < 0.0 ) {
-        sprintf(err_msg, "CVodeB:: illegal value of tout (pb. %d).",indexB+1);
-        cvmErrHandler(-999, "CVODES", "CVodeB", err_msg, NULL);
-        goto error_return;
-      }
-    }
-    
-    for (itout=1; itout<NtoutB; itout++) {
-      if ( (toutB[itout] - toutB[itout-1]) * h > 0.0 ) {
-        sprintf(err_msg, "CVodeB:: tout values are not monotonic (pb. %d).", indexB+1);
-        cvmErrHandler(-999, "CVODES", "CVodeB", err_msg, NULL);
-        goto error_return;
-      }
-    }
-
-    bckPb = bckPb->next;
-    
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Prepare the output arrays
-   * ----------------------------------------------------------------
-   */
-
-  plhs[1] = mxCreateCellMatrix(NbckPb,1);
-  tdata = (double **) mxMalloc(NbckPb*sizeof(double *));
-
-  plhs[2] = mxCreateCellMatrix(NbckPb,1);
-  ydata = (double **) mxMalloc(NbckPb*sizeof(double *));
-
-  if (any_quadrB) {
-    plhs[3] = mxCreateCellMatrix(NbckPb,1);
-    yQdata = (double **) mxMalloc(NbckPb*sizeof(double *));
-  }
-
-
-  bckPb = cvmData->bckPb;
-  while (bckPb != NULL) {
-
-    /* Return time(s) */
-    cell = mxCreateDoubleMatrix(1,NtoutB,mxREAL);
-    tdata[indexB] = mxGetPr(cell);
-    mxSetCell(plhs[1], indexB, cell);
-
-    /* Solution vector(s) */
-    cell = mxCreateDoubleMatrix(NB,NtoutB,mxREAL);
-    ydata[indexB] = mxGetPr(cell);
-    mxSetCell(plhs[2], indexB, cell);
-
-    /* Quadrature vector(s) */
-    if (any_quadrB) {
-      if (quadrB) {
-        cell = mxCreateDoubleMatrix(NqB,NtoutB,mxREAL);
-        yQdata[indexB] = mxGetPr(cell);
-      } else {
-        cell = mxCreateDoubleMatrix(0,0,mxREAL);
-      }
-      mxSetCell(plhs[3], indexB, cell);
-    }
-
-    bckPb = bckPb->next;
-
-  }
-
-  
-  /*
-   * ----------------------------------------------------------------
-   * Call the CVodeB main solver function
-   * ----------------------------------------------------------------
-   */
-
-  if (!any_monB) {
-
-    /* No monitoring. itaskB can be either CV_ONE_STEP or CV_NORMAL */
-
-    for (itout=0; itout<NtoutB; itout++) {
-
-      cv_status = CVodeB(cvode_mem, toutB[itout], itaskB);
-      if (cv_status < 0) goto error_return;
-
-      bckPb = cvmData->bckPb;
-      while (bckPb != NULL) {
-
-        status = CVodeGetB(cvode_mem, indexB, &tretB, yB);
-        if (status != CV_SUCCESS) goto error_return;
-
-        tdata[indexB][itout] = tretB;
-
-        GetData(yB, &ydata[indexB][itout*NB], NB);
-      
-        if (quadrB) {
-          status = CVodeGetQuadB(cvode_mem, indexB, &tretB, yQB);
-          if (status != CV_SUCCESS) goto error_return;
-          GetData(yQB, &yQdata[indexB][itout*NqB], NqB);
-        }
-
-        bckPb = bckPb->next;
-
-      }
-
-    }
-
-
-  } else {
-
-    /* Monitoring for at least one backward problem. itask = CV_NORMAL */
-
-    cvmErrHandler(-999, "CVODES", "CVodeB",
-                  "Monitoring currently prohibited with more than one backward problem defined .", NULL); 
-    goto error_return;
-
-  }
-
-  /* CVODE return flag (only non-negative values make it here) */
-
-  plhs[0] = mxCreateDoubleScalar((double)cv_status);
-  return(0);
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  return(-1);
-
-}
-
-
-static int CVM_Stats(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-
-  const char *fnames_intgr[]={
-    "nst",
-    "nfe",
-    "nge",
-    "nsetups",
-    "netf",
-    "nni",
-    "ncfn",
-    "qlast",
-    "qcur",
-    "h0used",
-    "hlast",
-    "hcur",
-    "tcur",
-    "RootInfo",
-    "QuadInfo",
-    "LSInfo",
-    "FSAInfo"
-  };
-  const char *fnames_root[]={
-    "nge",
-    "roots"
-  };
-  const char *fnames_dense[]={
-    "name",
-    "njeD",
-    "nfeD"
-  };
-  const char *fnames_diag[]={
-    "name",
-    "nfeDI"
-  };
-  const char *fnames_band[]={
-    "name",
-    "njeB",
-    "nfeB"
-  };
-  const char *fnames_spils[]={
-    "name",
-    "nli",
-    "npe",
-    "nps",
-    "ncfl",
-    "njeSG",
-    "nfeSG"
-  };
-  const char *fnames_quad[]={
-    "nfQe",
-    "netfQ"
-  };
-  const char *fnames_sens[]={
-    "nfSe",
-    "nfeS",
-    "nsetupsS",
-    "netfS",
-    "nniS",
-    "ncfnS",
-  };
-
-  long int nst, nfe, nsetups, nni, ncfn, netf, nge;
-  int qlast, qcur;
-  double h0used, hlast, hcur, tcur;
-  int *rootsfound;
-
-  long int njeD, nfeD;
-  long int nfeDI;
-  long int njeB, nfeB;
-  long int nli, npe, nps, ncfl, njeSG, nfeSG;
-
-  long int nfQe, netfQ;
-
-  long int nfSe, nfeS, netfS, nsetupsS;
-  long int nniS, ncfnS;
-
-  int i, status;
-  mxArray *mxS_root, *mxS_ls, *mxS_quad, *mxS_fsa;
-  mxArray *mxS_rootsfound;
-  double *tmp;
-  int nfields;
-  
-
-  if (cvmData == NULL) return(0);
-
-  fwdPb = cvmData->fwdPb;
-
-  status = CVodeGetIntegratorStats(cvode_mem, &nst, &nfe, &nsetups, 
-                                   &netf, &qlast, &qcur, &h0used, &hlast, &hcur, &tcur);
-  if (status != CV_SUCCESS) goto error_return;
-
-  status = CVodeGetNonlinSolvStats(cvode_mem, &nni, &ncfn);
-  if (status != CV_SUCCESS) goto error_return;
-
-  nfields = sizeof(fnames_intgr)/sizeof(*fnames_intgr);
-  plhs[0] = mxCreateStructMatrix(1, 1, nfields, fnames_intgr);
- 
-  mxSetField(plhs[0], 0, "nst",     mxCreateDoubleScalar((double)nst));
-  mxSetField(plhs[0], 0, "nfe",     mxCreateDoubleScalar((double)nfe));
-  mxSetField(plhs[0], 0, "nsetups", mxCreateDoubleScalar((double)nsetups));
-  mxSetField(plhs[0], 0, "netf",    mxCreateDoubleScalar((double)netf));
-  mxSetField(plhs[0], 0, "nni",     mxCreateDoubleScalar((double)nni));
-  mxSetField(plhs[0], 0, "ncfn",    mxCreateDoubleScalar((double)ncfn));
-  mxSetField(plhs[0], 0, "qlast",   mxCreateDoubleScalar((double)qlast));
-  mxSetField(plhs[0], 0, "qcur",    mxCreateDoubleScalar((double)qcur));
-  mxSetField(plhs[0], 0, "h0used",  mxCreateDoubleScalar(h0used));
-  mxSetField(plhs[0], 0, "hlast",   mxCreateDoubleScalar(hlast));
-  mxSetField(plhs[0], 0, "hcur",    mxCreateDoubleScalar(hcur));
-  mxSetField(plhs[0], 0, "tcur",    mxCreateDoubleScalar(tcur));
-
-
-  /* Root Finding Statistics */
-
-  if (Ng > 0) {
-
-    status = CVodeGetNumGEvals(cvode_mem, &nge);
-    if (status != CV_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_root)/sizeof(*fnames_root);
-    mxS_root = mxCreateStructMatrix(1, 1, nfields, fnames_root);
-
-    mxSetField(mxS_root, 0, "nge", mxCreateDoubleScalar((double)nge));
-
-    rootsfound = (int *) malloc(Ng*sizeof(int));
-    status = CVodeGetRootInfo(cvode_mem, rootsfound);
-    if (status != CV_SUCCESS) goto error_return;
-    mxS_rootsfound = mxCreateDoubleMatrix(Ng,1,mxREAL);
-    tmp = mxGetPr(mxS_rootsfound);
-    for (i=0;i<Ng;i++)
-      tmp[i] = (double)rootsfound[i];
-    mxSetField(mxS_root, 0, "roots", mxS_rootsfound);
-    free(rootsfound);
-
-  } else {
-
-    mxS_root = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "RootInfo", mxS_root);
-
-  /* Quadrature Statistics */
-
-  if (quadr) {
-
-    status = CVodeGetQuadStats(cvode_mem, &nfQe, &netfQ);
-    if (status != CV_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_quad)/sizeof(*fnames_quad);
-    mxS_quad = mxCreateStructMatrix(1, 1, nfields, fnames_quad);
-
-    mxSetField(mxS_quad, 0, "nfQe",  mxCreateDoubleScalar((double)nfQe));
-    mxSetField(mxS_quad, 0, "netfQ", mxCreateDoubleScalar((double)netfQ));
-
-  } else {
-
-    mxS_quad = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "QuadInfo", mxS_quad);
-
-  /* Linear Solver Statistics */
-
-  switch(ls){
-
-  case LS_NONE:
-
-    mxS_ls = mxCreateDoubleMatrix(0,0,mxREAL);
-    break;
-
-  case LS_DENSE:
-    
-    status = CVDlsGetNumJacEvals(cvode_mem, &njeD);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVDlsGetNumRhsEvals(cvode_mem, &nfeD);
-    if (status != CV_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_dense)/sizeof(*fnames_dense);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_dense);
-    
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Dense"));
-    mxSetField(mxS_ls, 0, "njeD", mxCreateDoubleScalar((double)njeD));
-    mxSetField(mxS_ls, 0, "nfeD", mxCreateDoubleScalar((double)nfeD));
-    
-    break;
-
-  case LS_DIAG:
-
-    status = CVDiagGetNumRhsEvals(cvode_mem, &nfeDI);
-    if (status != CV_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_diag)/sizeof(*fnames_diag);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_diag);
- 
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Diag"));
-    mxSetField(mxS_ls, 0, "nfeDI", mxCreateDoubleScalar((double)nfeDI));
-      
-    break;
-
-  case LS_BAND:
-      
-    status = CVDlsGetNumJacEvals(cvode_mem, &njeB);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVDlsGetNumRhsEvals(cvode_mem, &nfeB);
-    if (status != CV_SUCCESS) goto error_return;
-  
-    nfields = sizeof(fnames_band)/sizeof(*fnames_band);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_band);
- 
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Band"));
-    mxSetField(mxS_ls, 0, "njeB", mxCreateDoubleScalar((double)njeB));
-    mxSetField(mxS_ls, 0, "nfeB", mxCreateDoubleScalar((double)nfeB));
-      
-    break;
-
-  case LS_SPGMR:
-  case LS_SPBCG:
-  case LS_SPTFQMR:
-
-    status = CVSpilsGetNumLinIters(cvode_mem, &nli);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumPrecEvals(cvode_mem, &npe);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumPrecSolves(cvode_mem, &nps);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumConvFails(cvode_mem, &ncfl);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumJtimesEvals(cvode_mem, &njeSG);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumRhsEvals(cvode_mem, &nfeSG);
-    if (status != CV_SUCCESS) goto error_return;
-    
-    nfields = sizeof(fnames_spils)/sizeof(*fnames_spils);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_spils);
-    
-    if (ls == LS_SPGMR)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("GMRES"));
-    else if (ls == LS_SPBCG)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("BiCGStab"));
-    else
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("TFQMR"));
-
-    mxSetField(mxS_ls, 0, "nli",   mxCreateDoubleScalar((double)nli));
-    mxSetField(mxS_ls, 0, "npe",   mxCreateDoubleScalar((double)npe));
-    mxSetField(mxS_ls, 0, "nps",   mxCreateDoubleScalar((double)nps));
-    mxSetField(mxS_ls, 0, "ncfl",  mxCreateDoubleScalar((double)ncfl));
-    mxSetField(mxS_ls, 0, "njeSG", mxCreateDoubleScalar((double)njeSG));
-    mxSetField(mxS_ls, 0, "nfeSG", mxCreateDoubleScalar((double)nfeSG));
-    
-    break;
-    
-  }
-
-  mxSetField(plhs[0], 0, "LSInfo", mxS_ls);
-
-  /* Forward Sensitivity Statistics */
-
-  if (fsa) {
-
-    status = CVodeGetSensStats(cvode_mem, &nfSe, &nfeS, &netfS, &nsetupsS); 
-    if (status != CV_SUCCESS) goto error_return;
-
-    status = CVodeGetSensNonlinSolvStats(cvode_mem, &nniS, &ncfnS);
-    if (status != CV_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_sens)/sizeof(*fnames_sens);
-    mxS_fsa = mxCreateStructMatrix(1, 1, nfields, fnames_sens);
-    
-    mxSetField(mxS_fsa, 0, "nfSe",     mxCreateDoubleScalar((double)nfSe));
-    mxSetField(mxS_fsa, 0, "nfeS",     mxCreateDoubleScalar((double)nfeS));
-    mxSetField(mxS_fsa, 0, "nsetupsS", mxCreateDoubleScalar((double)nsetupsS));
-    mxSetField(mxS_fsa, 0, "netfS",    mxCreateDoubleScalar((double)netfS));
-    mxSetField(mxS_fsa, 0, "nniS",     mxCreateDoubleScalar((double)nniS));
-    mxSetField(mxS_fsa, 0, "ncfnS",    mxCreateDoubleScalar((double)ncfnS));
-    
-  } else {
-
-    mxS_fsa = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "FSAInfo", mxS_fsa);
-
-  /* Successful return */
-
-  status = 0;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int CVM_StatsB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData bckPb;
-  int idxB;
-
-  const char *fnames_intgr[]={
-    "nst",
-    "nfe",
-    "nge",
-    "nsetups",
-    "netf",
-    "nni",
-    "ncfn",
-    "qlast",
-    "qcur",
-    "h0used",
-    "hlast",
-    "hcur",
-    "tcur",
-    "QuadInfo",
-    "LSInfo",
-  };
-  const char *fnames_dense[]={
-    "name",
-    "njeD",
-    "nfeD"
-  };
-  const char *fnames_diag[]={
-    "name",
-    "nfeDI"
-  };
-  const char *fnames_band[]={
-    "name",
-    "njeB",
-    "nfeB"
-  };
-  const char *fnames_spils[]={
-    "name",
-    "nli",
-    "npe",
-    "nps",
-    "ncfl",
-    "njeSG",
-    "nfeSG"
-  };
-  const char *fnames_quad[]={
-    "nfQe",
-    "netfQ"
-  };
-
-  void *cvode_memB;
-
-  long int nst, nfe, nsetups, nni, ncfn, netf;
-  int qlast, qcur;
-  double h0used, hlast, hcur, tcur;
-
-  long int njeD, nfeD;
-  long int nfeDI;
-  long int njeB, nfeB;
-  long int nli, npe, nps, ncfl, njeSG, nfeSG;
-
-  long int nfQe, netfQ;
-
-  mxArray *mxS_ls, *mxS_quad;
-  int nfields;
-
-  booleantype found_bck;
-
-  int status;
-
-  /* Extract index of current backward problem */
-    
-  idxB = (int)mxGetScalar(prhs[0]);
-
-  /* Find current backward problem */
-
-  found_bck = FALSE;
-  bckPb = cvmData->bckPb;
-  while (bckPb != NULL) {
-    if (indexB == idxB) {
-      found_bck = TRUE;
-      break;
-    }
-    bckPb = bckPb->next;
-  }
-
-  if (!found_bck) cvmErrHandler(-999, "CVODES", "CVodeGetStatsB",
-                                "idxB has an illegal value.", NULL);
-
-  cvode_memB = CVodeGetAdjCVodeBmem(cvode_mem, indexB);
-
-  status = CVodeGetIntegratorStats(cvode_memB, &nst, &nfe, &nsetups, 
-                                 &netf, &qlast, &qcur, &h0used, &hlast, &hcur, &tcur);
-  if (status != CV_SUCCESS) goto error_return;
-
-  status = CVodeGetNonlinSolvStats(cvode_memB, &nni, &ncfn);
-  if (status != CV_SUCCESS) goto error_return;
-
-  nfields = sizeof(fnames_intgr)/sizeof(*fnames_intgr);
-  plhs[0] = mxCreateStructMatrix(1, 1, nfields, fnames_intgr);
-
-  mxSetField(plhs[0], 0, "nst",     mxCreateDoubleScalar((double)nst));
-  mxSetField(plhs[0], 0, "nfe",     mxCreateDoubleScalar((double)nfe));
-  mxSetField(plhs[0], 0, "nsetups", mxCreateDoubleScalar((double)nsetups));
-  mxSetField(plhs[0], 0, "netf",    mxCreateDoubleScalar((double)netf));
-  mxSetField(plhs[0], 0, "nni",     mxCreateDoubleScalar((double)nni));
-  mxSetField(plhs[0], 0, "ncfn",    mxCreateDoubleScalar((double)ncfn));
-  mxSetField(plhs[0], 0, "qlast",   mxCreateDoubleScalar((double)qlast));
-  mxSetField(plhs[0], 0, "qcur",    mxCreateDoubleScalar((double)qcur));
-  mxSetField(plhs[0], 0, "h0used",  mxCreateDoubleScalar(h0used));
-  mxSetField(plhs[0], 0, "hlast",   mxCreateDoubleScalar(hlast));
-  mxSetField(plhs[0], 0, "hcur",    mxCreateDoubleScalar(hcur));
-  mxSetField(plhs[0], 0, "tcur",    mxCreateDoubleScalar(tcur));
-
-
-  /* Quadrature Statistics */
-
-  if (quadrB) {
-
-    status = CVodeGetQuadStats(cvode_memB, &nfQe, &netfQ);
-    if (status != CV_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_quad)/sizeof(*fnames_quad);
-    mxS_quad = mxCreateStructMatrix(1, 1, nfields, fnames_quad);
-
-    mxSetField(mxS_quad, 0, "nfQe",  mxCreateDoubleScalar((double)nfQe));
-    mxSetField(mxS_quad, 0, "netfQ", mxCreateDoubleScalar((double)netfQ));
-
-  } else {
-
-    mxS_quad = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "QuadInfo", mxS_quad);
-
-  /* Linear Solver Statistics */
-
-  switch(lsB){
-
-  case LS_NONE:
-
-    mxS_ls = mxCreateDoubleMatrix(0,0,mxREAL);
-    break;
-
-  case LS_DENSE:
-    
-    status = CVDlsGetNumJacEvals(cvode_memB, &njeD);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVDlsGetNumRhsEvals(cvode_memB, &nfeD);
-    if (status != CV_SUCCESS) goto error_return;
-    
-    nfields = sizeof(fnames_dense)/sizeof(*fnames_dense);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_dense);
-
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Dense"));
-    mxSetField(mxS_ls, 0, "njeD", mxCreateDoubleScalar((double)njeD));
-    mxSetField(mxS_ls, 0, "nfeD", mxCreateDoubleScalar((double)nfeD));
-    
-    break;
-
-  case LS_DIAG:
-
-    status = CVDiagGetNumRhsEvals(cvode_memB, &nfeDI);
-    if (status != CV_SUCCESS) goto error_return;
-      
-    nfields = sizeof(fnames_diag)/sizeof(*fnames_diag);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_diag);
- 
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Diag"));
-    mxSetField(mxS_ls, 0, "nfeDI", mxCreateDoubleScalar((double)nfeDI));
-      
-    break;
-
-  case LS_BAND:
-      
-    status = CVDlsGetNumJacEvals(cvode_memB, &njeB);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVDlsGetNumRhsEvals(cvode_memB, &nfeB);
-    if (status != CV_SUCCESS) goto error_return;
-      
-    nfields = sizeof(fnames_band)/sizeof(*fnames_band);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_band);
- 
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Band"));
-    mxSetField(mxS_ls, 0, "njeB", mxCreateDoubleScalar((double)njeB));
-    mxSetField(mxS_ls, 0, "nfeB", mxCreateDoubleScalar((double)nfeB));
-      
-    break;
-
-  case LS_SPGMR:
-  case LS_SPBCG:
-  case LS_SPTFQMR:
-
-    status = CVSpilsGetNumLinIters(cvode_memB, &nli);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumPrecEvals(cvode_memB, &npe);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumPrecSolves(cvode_memB, &nps);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumConvFails(cvode_memB, &ncfl);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumJtimesEvals(cvode_memB, &njeSG);
-    if (status != CV_SUCCESS) goto error_return;
-    status = CVSpilsGetNumRhsEvals(cvode_memB, &nfeSG);
-    if (status != CV_SUCCESS) goto error_return;
-    
-    nfields = sizeof(fnames_spils)/sizeof(*fnames_spils);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_spils);
- 
-    if (lsB == LS_SPGMR)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("GMRES"));
-    else if (lsB == LS_SPBCG)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("BiCGStab"));
-    else
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("TFQMR"));
-
-    mxSetField(mxS_ls, 0, "nli",   mxCreateDoubleScalar((double)nli));
-    mxSetField(mxS_ls, 0, "npe",   mxCreateDoubleScalar((double)npe));
-    mxSetField(mxS_ls, 0, "nps",   mxCreateDoubleScalar((double)nps));
-    mxSetField(mxS_ls, 0, "ncfl",  mxCreateDoubleScalar((double)ncfl));
-    mxSetField(mxS_ls, 0, "njeSG", mxCreateDoubleScalar((double)njeSG));
-    mxSetField(mxS_ls, 0, "nfeSG", mxCreateDoubleScalar((double)nfeSG));
-    
-    break;
-  }
-
-  mxSetField(plhs[0], 0, "LSInfo", mxS_ls);
-
-  /* Successful return */
-
-  status = 0;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-
-static int CVM_Set(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-
-  const mxArray *options;
-  mxArray *opt;
-
-  double tstop;
-
-  int status;
-
-  fwdPb = cvmData->fwdPb;
-  options = prhs[0];
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* User data */
-
-  opt = mxGetField(options,0,"UserData");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_data);
-    mtlb_data = mxDuplicateArray(opt);
-  }
-
-  /* Stopping time */
-
-  opt = mxGetField(options,0,"StopTime");
-  if ( !mxIsEmpty(opt) ) {
-    tstop = (double)mxGetScalar(opt);
-    status = CVodeSetStopTime(cvode_mem, tstop);
-    if (status != CV_SUCCESS) goto error_return;
-  }
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int CVM_SetB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  return(0);
-}
-
-static int CVM_Get(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb;
-
-  double t;
-  N_Vector ewt;
-  double *this, *next;
-  int key, k, i, nfields;
-
-  CVadjCheckPointRec *ckpnt;
-  const char *fnames_ckpnt[]={
-    "t0",
-    "t1",
-    "nstep",
-    "order",
-    "step"
-  };
-
-  int status;
-
-
-  fwdPb = cvmData->fwdPb;
-
-  key = (int) (*mxGetPr(prhs[0]));
-
-  switch (key) {
-  case 1:    /* DerivSolution */
-
-    t = *mxGetPr(prhs[1]);
-    k = (int) (*mxGetPr(prhs[2]));
-
-    plhs[0] = mxCreateDoubleMatrix(N,1,mxREAL);
-    status = CVodeGetDky(cvode_mem, t, k, y);
-    if (status != CV_SUCCESS) goto error_return;
-    GetData(y, mxGetPr(plhs[0]), N);
-
-    break;
-
-  case 2:    /* ErrorWeights */
-
-    ewt = N_VClone(y);
-
-    plhs[0] = mxCreateDoubleMatrix(N,1,mxREAL);
-    status = CVodeGetErrWeights(cvode_mem, ewt);
-    if (status != CV_SUCCESS) goto error_return;
-    GetData(ewt, mxGetPr(plhs[0]), N);
-
-    N_VDestroy(ewt);
-
-    break;
-
-  case 3:    /* not used */
-
-    break;
-
-  case 4:    /* CheckPointsInfo */
-
-    ckpnt = (CVadjCheckPointRec *) malloc ( (Nc+1)*sizeof(CVadjCheckPointRec));
-    status = CVodeGetAdjCheckPointsInfo(cvode_mem, ckpnt);
-    if (status != CV_SUCCESS) {
-      free(ckpnt);
-      goto error_return;
-    }
-    nfields = sizeof(fnames_ckpnt)/sizeof(*fnames_ckpnt);
-    plhs[0] = mxCreateStructMatrix(Nc+1, 1, nfields, fnames_ckpnt);
-    for (i=0; i<=Nc; i++) {
-      this = (double *)(ckpnt[Nc-i].my_addr);
-      next = (double *)(ckpnt[Nc-i].next_addr);
-      mxSetField(plhs[0], i, "t0",    mxCreateDoubleScalar((double)(ckpnt[Nc-i].t0)));
-      mxSetField(plhs[0], i, "t1",    mxCreateDoubleScalar((double)(ckpnt[Nc-i].t1)));
-      mxSetField(plhs[0], i, "nstep", mxCreateDoubleScalar((double)(ckpnt[Nc-i].nstep)));
-      mxSetField(plhs[0], i, "order", mxCreateDoubleScalar((double)(ckpnt[Nc-i].order)));
-      mxSetField(plhs[0], i, "step",  mxCreateDoubleScalar((double)(ckpnt[Nc-i].step)));
-    }
-    free(ckpnt);
-    break;
-
-  }
-
-  /* Successful return */
-
-  status = 0;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int CVM_Free(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  cvmPbData fwdPb, bckPb;
-
-  if (cvmData == NULL) return(0);
-
-  fwdPb = cvmData->fwdPb;
-  if (mon) mxW_CVodeMonitor(2, 0.0, NULL, NULL, NULL, fwdPb);
-
-  bckPb = cvmData->bckPb;
-  while (bckPb != NULL) {
-    if (monB) mxW_CVodeMonitorB(2, indexB, 0.0, NULL, NULL, bckPb);   
-    bckPb = bckPb->next;
-  }
-
-  CVodeFree(&cvode_mem);
-
-  return(0);
-}
-
-
diff --git a/sundialsTB/cvodes/cvm/src/cvm.h b/sundialsTB/cvodes/cvm/src/cvm.h
deleted file mode 100644
index d247edb..0000000
--- a/sundialsTB/cvodes/cvm/src/cvm.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.14 $
- * $Date: 2012/03/07 21:44:21 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/cvodes/LICENSE.
- * -----------------------------------------------------------------
- * Header file for the CVODES Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#ifndef _CVM_H
-#define _CVM_H
-
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
-#include <string.h>
-#include <stdlib.h>
-#include "mex.h"
-#include <cvodes/cvodes.h>
-#include <cvodes/cvodes_dense.h>
-#include <cvodes/cvodes_diag.h>
-#include <cvodes/cvodes_band.h>
-#include <cvodes/cvodes_spgmr.h>
-#include <cvodes/cvodes_spbcgs.h>
-#include <cvodes/cvodes_sptfqmr.h>
-#include <cvodes/cvodes_bandpre.h>
-#include <cvodes/cvodes_bbdpre.h>
-
-/*
- * ---------------------------------------------------------------------------------
- * Constants
- * ---------------------------------------------------------------------------------
- */
-
-/* Tolerance types */
-
-enum {CV_SS, CV_SV, CV_EE};
-
-/* Linear solver types */
-
-enum {LS_NONE, LS_DENSE, LS_DIAG, LS_BAND, LS_SPGMR, LS_SPBCG, LS_SPTFQMR};
-
-/* Preconditioner modules */
-
-enum {PM_NONE, PM_BANDPRE, PM_BBDPRE};
-
-/*
- * ---------------------------------------------------------------------------------
- * Types for global data structures
- * ---------------------------------------------------------------------------------
- */
-
-
-typedef struct cvmPbData_ {
-
-
-  long int n;        /* problem dimension */
-  N_Vector Y;        /* solution vector */
-
-  booleantype Quadr; /* integrate quadratures? */
-  long int nq;       /* number of quadratures */
-  N_Vector YQ;       /* quadratures vector */
-
-  booleantype Fsa;   /* integrate sensitivities? */
-  int ns;            /* number of sensitivities */
-  N_Vector *YS;      /* sensitivity vectors */
-
-  booleantype RootSet;  /* rootfinding active? */
-  int ng;               /* number of root functions */
-
-  booleantype TstopSet; /* tstop active? */
-
-  int LS;            /* linear solver type */
-  int PM;            /* preconditioner module */
-
-  booleantype Mon;   /* monitoring? */
-
-  /* Matlab functions and data associated with this problem */
-
-  mxArray *RHSfct;
-  mxArray *QUADfct;
-
-  mxArray *JACfct;
-
-  mxArray *PSETfct;
-  mxArray *PSOLfct;
-
-  mxArray *GLOCfct;
-  mxArray *GCOMfct;
-    
-  mxArray *Gfct;
-    
-  mxArray *SRHSfct;
-
-  mxArray *MONfct;
-  mxArray *MONdata;
-
-  /* Pointer to the global Matlab user data */
-
-  mxArray *mtlb_data;
-
-  /* Information for backward problems only */
-
-  struct cvmPbData_ *fwd;
-  int index;               /* index of this problem */
-  struct cvmPbData_ *next; /* pointer to next problem in linked list */
-
-} *cvmPbData;
-
-
-typedef struct cvmInterfaceData_ {
-
-  void *cvode_mem;       /* CVODES solver memory */
-
-  booleantype asa;       /* Perform ASA? */
-  int Nd;                /* number of data points */
-  int Nc;                /* number of check points */
-
-  struct cvmPbData_ *fwdPb;
-  struct cvmPbData_ *bckPb;
-
-  int NbckPb;            /* Number of backward problems in the linked list bckPb */
-
-  booleantype errMsg;    /* post error/warning messages? */
-
-} *cvmInterfaceData;
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Error handler function
- * ---------------------------------------------------------------------------------
- */
-
-void cvmErrHandler(int error_code, 
-                   const char *module, const char *function, 
-                   char *msg, void *eh_data);
-
-/*
- * ---------------------------------------------------------------------------------
- * Wrapper functions
- * ---------------------------------------------------------------------------------
- */
-
-int mxW_CVodeRhs(realtype t, N_Vector y, N_Vector yd, void *user_data);
-
-int mxW_CVodeGfct(realtype t, N_Vector y, double *g, void *user_data);
-
-int mxW_CVodeQUADfct(realtype t, N_Vector y, N_Vector yQd, void *user_data);
-
-
-int mxW_CVodeSensRhs1(int Ns, realtype t,
-                      N_Vector y, N_Vector ydot,
-                      int iS, N_Vector yS, N_Vector ySdot,
-                      void *user_data,
-                      N_Vector tmp1, N_Vector tmp2);
-int mxW_CVodeSensRhs(int Ns, realtype t,
-                     N_Vector y, N_Vector ydot,
-                     N_Vector *yS, N_Vector *ySdot,
-                     void *user_data,
-                     N_Vector tmp1, N_Vector tmp2);
-
-
-int mxW_CVodeDenseJac(long int N, realtype t,
-                      N_Vector y, N_Vector fy, 
-                      DlsMat J, void *user_data,
-                      N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
-int mxW_CVodeBandJac(long int N, long int mupper, long int mlower, realtype t,
-                     N_Vector y, N_Vector fy, 
-                     DlsMat J, void *user_data,
-                     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
-int mxW_CVodeSpilsJac(N_Vector v, N_Vector Jv, realtype t,
-                      N_Vector y, N_Vector fy,
-                      void *user_data, N_Vector tmp);
-int mxW_CVodeSpilsPset(realtype t, N_Vector y, N_Vector fy,
-                       booleantype jok, booleantype *jcurPtr,
-                       realtype gamma, void *user_data,
-                       N_Vector tmp1, N_Vector tmp2,
-                       N_Vector tmp3);
-int mxW_CVodeSpilsPsol(realtype t, N_Vector y, N_Vector fy,
-                       N_Vector r, N_Vector z,
-                       realtype gamma, realtype delta,
-                       int lr, void *user_data, N_Vector tmp);
-
-  
-int mxW_CVodeBBDgloc(long int Nlocal, realtype t, N_Vector y, N_Vector g, void *user_data);
-int mxW_CVodeBBDgcom(long int Nlocal, realtype t, N_Vector y, void *user_data);
-
-void mxW_CVodeMonitor(int call, double t, 
-                      N_Vector y, N_Vector yQ, N_Vector *yS,
-                      cvmPbData fwdPb);
-
-
-int mxW_CVodeRhsB(realtype t, N_Vector y,
-                  N_Vector yB, N_Vector yBdot, void *user_dataB);
-int mxW_CVodeRhsBS(realtype t, N_Vector y,  N_Vector *yS,
-                   N_Vector yB, N_Vector yBd, void *user_dataB);
-
-int mxW_CVodeQUADfctB(realtype t, N_Vector y, 
-                      N_Vector yB, N_Vector qBdot, void *user_dataB);
-int mxW_CVodeQUADfctBS(realtype t, N_Vector y,  N_Vector *yS,
-                       N_Vector yB, N_Vector yQBd, void *user_dataB);
-
-int mxW_CVodeDenseJacB(long int nB, realtype t,
-                       N_Vector y, N_Vector yB, N_Vector fyB,
-                       DlsMat JB, void *user_dataB, 
-                       N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
-int mxW_CVodeBandJacB(long int nB, long int mupperB, long int mlowerB, realtype t,
-                      N_Vector y, N_Vector yB, N_Vector fyB,
-                      DlsMat JB, void *user_dataB, 
-                      N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
-int mxW_CVodeSpilsJacB(N_Vector vB, N_Vector JvB, realtype t,
-                       N_Vector y, N_Vector yB, N_Vector fyB,
-                       void *user_dataB, N_Vector tmpB);
-int mxW_CVodeSpilsPsetB(realtype t, N_Vector y,
-                        N_Vector yB, N_Vector fyB,
-                        booleantype jokB,
-                        booleantype *jcurPtrB, realtype gammaB,
-                        void *user_dataB,
-                        N_Vector tmp1B, N_Vector tmp2B,
-                        N_Vector tmp3B);
-int mxW_CVodeSpilsPsolB(realtype t, N_Vector y,
-                        N_Vector yB, N_Vector fyB,
-                        N_Vector rB, N_Vector zB,
-                        realtype gammaB, realtype deltaB,
-                        int lrB, void *user_dataB, N_Vector tmpB);
-  
-int mxW_CVodeBBDglocB(long int NlocalB, realtype t, N_Vector y, 
-                      N_Vector yB, N_Vector gB, void *user_dataB);
-
-int mxW_CVodeBBDgcomB(long int NlocalB, realtype t, N_Vector y, 
-                      N_Vector yB, void *user_dataB);
-
-
-void mxW_CVodeMonitorB(int call, int idxB, double tB,
-                       N_Vector yB, N_Vector yQB,
-                       cvmPbData bckPb);
-
-/*
- * ---------------------------------------------------------------------------------
- * Option handling functions
- * ---------------------------------------------------------------------------------
- */
-
-int get_IntgrOptions(const mxArray *options, cvmPbData thisPb, booleantype fwd, int lmm,
-                     int *maxord, booleantype *sld, booleantype *errmsg,
-                     long int *mxsteps,
-                     int *itol, realtype *reltol, double *Sabstol, double **Vabstol,
-                     double *hin, double *hmax, double *hmin, 
-                     double *tstop, booleantype *rhs_s);
-
-int get_LinSolvOptions(const mxArray *options, cvmPbData thisPb, booleantype fwd,
-                       long int *mupper, long int *mlower,
-                       long int *mudq, long int *mldq, double *dqrely,
-                       int *ptype, int *gstype, int *maxl);
-
-int get_QuadOptions(const mxArray *options, cvmPbData thisPb, booleantype fwd,
-                    long int Nq, booleantype *rhs_s,
-                    booleantype *errconQ,
-                    int *itolQ, double *reltolQ, double *SabstolQ, double **VabstolQ);
-
-int get_FSAOptions(const mxArray *options, cvmPbData thisPb,
-                   int *ism,
-                   char **pfield_name, int **plist, double **pbar,
-                   int *dqtype, double *rho,
-                   booleantype *errconS, int *itolS, double *reltolS, 
-                   double **SabstolS, double **VabstolS);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/sundialsTB/cvodes/cvm/src/cvmOpts.c b/sundialsTB/cvodes/cvm/src/cvmOpts.c
deleted file mode 100644
index dd5be2e..0000000
--- a/sundialsTB/cvodes/cvm/src/cvmOpts.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.13 $
- * $Date: 2012/03/07 21:44:21 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/cvodes/LICENSE.
- * -----------------------------------------------------------------
- * Option parsing functions for the CVODES Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#include <string.h>
-#include "cvm.h"
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define N             (thisPb->n) 
-#define Ns            (thisPb->ns) 
-#define Ng            (thisPb->ng) 
-#define ls            (thisPb->LS) 
-#define pm            (thisPb->PM) 
-
-#define mtlb_data     (thisPb->mtlb_data)
-
-#define mtlb_JACfct   (thisPb->JACfct)
-#define mtlb_PSETfct  (thisPb->PSETfct)
-#define mtlb_PSOLfct  (thisPb->PSOLfct)
-#define mtlb_GLOCfct  (thisPb->GLOCfct)
-#define mtlb_GCOMfct  (thisPb->GCOMfct)
-#define mtlb_Gfct     (thisPb->Gfct)
-
-#define mon           (thisPb->Mon)
-#define tstopSet      (thisPb->TstopSet)
-
-#define mtlb_MONfct   (thisPb->MONfct)
-#define mtlb_MONdata  (thisPb->MONdata)
-
-/*
- * ---------------------------------------------------------------------------------
- * Option handling functions
- * ---------------------------------------------------------------------------------
- */
-
-int get_IntgrOptions(const mxArray *options, cvmPbData thisPb, booleantype fwd, int lmm,
-                     int *maxord, booleantype *sld, booleantype *errmsg,
-                     long int *mxsteps,
-                     int *itol, realtype *reltol, double *Sabstol, double **Vabstol,
-                     double *hin, double *hmax, double *hmin, double *tstop,
-                     booleantype *rhs_s)
-{
-  mxArray *opt;
-  int q;
-  long int i, m, n;
-  double *tmp;
-  char *fctName;
-  char *fwd_fctName = "CVodeInit/CVodeReInit";
-  char *bck_fctName = "CVodeInitB/CVodeReInitB";
-
-  if (fwd) fctName = fwd_fctName;
-  else     fctName = bck_fctName;
-  
-  /* Set default values */
-  
-  *maxord = (lmm == CV_ADAMS) ? 12 : 5;
-  
-  *sld = FALSE;
-
-  *mxsteps = 0;
-
-  *itol = CV_SS;
-  *reltol = 1.0e-3;
-  *Sabstol = 1.0e-6;
-  *Vabstol = NULL;
-
-  *hin = 0.0;
-  *hmax = 0.0;
-  *hmin = 0.0;
-
-  *rhs_s = FALSE;
-
-  Ng = 0;
-  tstopSet = FALSE;
-  mon = FALSE;
-
-  *errmsg = TRUE;
-
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* User data */
-
-  opt = mxGetField(options,0,"UserData");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_data);
-    mtlb_data = mxDuplicateArray(opt);
-  }
-  
-  /* Tolerances */
-
-  opt = mxGetField(options,0,"RelTol");
-  if ( !mxIsEmpty(opt) ) {
-    *reltol = *mxGetPr(opt);
-    if (*reltol < 0.0 ) {
-      cvmErrHandler(-999, "CVODES", fctName, "RelTol is negative.", NULL);
-      return(-1);
-    }
-  }
-    
-  opt = mxGetField(options,0,"AbsTol");
-  if ( !mxIsEmpty(opt) ) {
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      cvmErrHandler(-999, "CVODES", fctName, "AbsTol is not a scalar or a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    tmp = mxGetPr(opt);
-    if (n == 1) {
-      *itol = CV_SS;
-      *Sabstol = *tmp;
-      if (*Sabstol < 0.0) {
-        cvmErrHandler(-999, "CVODES", fctName, "AbsTol is negative.", NULL);
-      return(-1);
-      }
-    } else if (n == N) {
-      *itol = CV_SV;
-      *Vabstol = (double *) malloc(N*sizeof(double));
-      for(i=0;i<N;i++) {
-        (*Vabstol)[i] = tmp[i];
-        if (tmp[i] < 0.0) {
-          cvmErrHandler(-999, "CVODES", fctName, "AbsTol has a negative component.", NULL);
-          return(-1);
-        }
-      }
-    } else {
-      cvmErrHandler(-999, "CVODES", fctName, "AbsTol does not contain N elements.", NULL);
-      return(-1);
-    }
-  }
-
-  /* Maximum number of steps */
-
-  opt = mxGetField(options,0,"MaxNumSteps");
-  if ( !mxIsEmpty(opt) ) {
-    *mxsteps = (int)*mxGetPr(opt);
-    if (*mxsteps < 0) {
-      cvmErrHandler(-999, "CVODES", fctName, "MaxNumSteps is negative.", NULL);
-      return(-1);
-    }
-  }
-
-  /* Maximum order */
-
-  opt = mxGetField(options,0,"MaxOrder");
-  if ( !mxIsEmpty(opt) ) {
-    q = (int)*mxGetPr(opt);
-    if (q <= 0) {
-      cvmErrHandler(-999, "CVODES", fctName, "MaxOrder must be positive.", NULL);
-      return(-1);
-    }
-    if (q > *maxord) {
-      cvmErrHandler(-999, "CVODES", fctName, "MaxOrder is too large for the Method specified.", NULL);
-      return(-1);
-    }
-    *maxord = q;
-  }
-
-  /* Initial step size */
-
-  opt = mxGetField(options,0,"InitialStep");
-  if ( !mxIsEmpty(opt) ) {
-    *hin = *mxGetPr(opt);
-  }
-
-  /* Maximum step size */
-
-  opt = mxGetField(options,0,"MaxStep");
-  if ( !mxIsEmpty(opt) ) {
-    tmp = mxGetPr(opt);
-    if (*tmp < 0.0) {
-      cvmErrHandler(-999, "CVODES", fctName, "MaxStep is negative.", NULL);
-      return(-1);
-    }
-    if ( mxIsInf(*tmp) ) *hmax = 0.0;
-    else                 *hmax = *tmp;
-  }
-
-  /* Minimum step size */
-
-  opt = mxGetField(options,0,"MinStep");
-  if ( !mxIsEmpty(opt) ) {
-    *hmin = *mxGetPr(opt);
-    if (*hmin < 0.0) {
-      cvmErrHandler(-999, "CVODES", fctName, "MinStep is negative.", NULL);
-      return(-1);
-    }
-  }
-
-  /* Stability Limit Detection */
-
-  opt = mxGetField(options,0,"StabilityLimDet");
-  if ( !mxIsEmpty(opt) ) {
-    if (!mxIsLogical(opt)) {
-      cvmErrHandler(-999, "CVODES", fctName, "StabilityLimDet is not a logical scalar.", NULL);
-      return(-1);
-    }
-    if (mxIsLogicalScalarTrue(opt)) *sld = TRUE;
-    else                            *sld = FALSE;
-  }
-
-  /* Monitor? */
-
-  opt = mxGetField(options,0,"MonitorFn");
-  if ( !mxIsEmpty(opt) ) {
-    mon = TRUE;
-    mxDestroyArray(mtlb_MONfct);
-    mtlb_MONfct = mxDuplicateArray(opt);
-    opt = mxGetField(options,0,"MonitorData");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_MONdata);
-      mtlb_MONdata  = mxDuplicateArray(opt);
-    }
-  }
-
-  /* The remaining options are interpreted either for 
-   * forward problems only or backward problems only */
-
-  if (fwd) {   /* FORWARD PROBLEM ONLY */
-
-    /* Disable error/warning messages? */
-
-    opt = mxGetField(options,0,"ErrorMessages");
-    if ( !mxIsEmpty(opt) ) {
-      if (!mxIsLogical(opt)) {
-        cvmErrHandler(-999, "CVODES", fctName, "ErrorMessages is not a logical scalar.", NULL);
-        return(-1);
-      }
-      if (mxIsLogicalScalarTrue(opt)) *errmsg = TRUE;
-      else                            *errmsg = FALSE;
-    }
-
-    /* Stopping time */
-    opt = mxGetField(options,0,"StopTime");
-    if ( !mxIsEmpty(opt) ) {
-      *tstop = *mxGetPr(opt);
-      tstopSet = TRUE;
-    }
-
-    /* Number of root functions */
-    opt = mxGetField(options,0,"NumRoots");
-    if ( !mxIsEmpty(opt) ) {
-
-      Ng = (int)*mxGetPr(opt);
-      if (Ng < 0) {
-        cvmErrHandler(-999, "CVODES", fctName, "NumRoots is negative.", NULL);
-        return(-1);
-      }
-      if (Ng > 0) {
-        /* Roots function */
-        opt = mxGetField(options,0,"RootsFn");
-        if ( !mxIsEmpty(opt) ) {
-          mxDestroyArray(mtlb_Gfct);
-          mtlb_Gfct = mxDuplicateArray(opt);
-        } else {
-          cvmErrHandler(-999, "CVODES", fctName, "RootsFn required for NumRoots > 0", NULL);
-          return(-1);
-        }
-      }
-      
-    }
-
-  } else {   /* BACKWARD PROBLEM ONLY */
-
-    /* Dependency on forward sensitivities */
-
-    opt = mxGetField(options,0,"SensDependent");
-    if ( !mxIsEmpty(opt) ) {
-      if (!mxIsLogical(opt)) {
-        cvmErrHandler(-999, "CVODES", fctName, "SensDependent is not a logical scalar.", NULL);
-        return(-1);
-      }
-      if (mxIsLogicalScalarTrue(opt)) *rhs_s = TRUE;
-      else                            *rhs_s = FALSE;
-    }
-
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-}
-
-
-int get_LinSolvOptions(const mxArray *options, cvmPbData thisPb, booleantype fwd,
-                       long int *mupper, long int *mlower,
-                       long int *mudq, long int *mldq, double *dqrely,
-                       int *ptype, int *gstype, int *maxl)
-{
-  mxArray *opt;
-  char *bufval;
-  int buflen, status;
-  char *fctName;
-  char *fwd_fctName = "CVodeInit/CVodeReInit";
-  char *bck_fctName = "CVodeInitB/CVodeReInitB";
-
-  if (fwd) fctName = fwd_fctName;
-  else     fctName = bck_fctName;
-
-  *mupper = 0;
-  *mlower = 0;
-
-  *mudq = 0;
-  *mldq = 0;
-  *dqrely = 0.0;
-
-  *ptype = PREC_NONE;
-  *gstype = MODIFIED_GS;
-  *maxl = 0;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* Linear solver type */
-
-  opt = mxGetField(options,0,"LinearSolver");
-  if ( !mxIsEmpty(opt) ) {
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", fctName, "Cannot parse LinearSolver.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"Diag"))          ls = LS_DIAG;
-    else if(!strcmp(bufval,"Band"))     ls = LS_BAND;
-    else if(!strcmp(bufval,"GMRES"))    ls = LS_SPGMR;
-    else if(!strcmp(bufval,"BiCGStab")) ls = LS_SPBCG;
-    else if(!strcmp(bufval,"TFQMR"))    ls = LS_SPTFQMR;
-    else if(!strcmp(bufval,"Dense"))    ls = LS_DENSE;
-    else {
-      cvmErrHandler(-999, "CVODES", fctName, "LinearSolver has an illegal value.", NULL);
-      return(-1);
-    }
-  }
-  
-  /* Jacobian function */
-
-  opt = mxGetField(options,0,"JacobianFn");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_JACfct);
-    mtlb_JACfct  = mxDuplicateArray(opt);
-  }
-
-  /* Band linear solver */
-
-  if (ls==LS_BAND) {
-
-    opt = mxGetField(options,0,"UpperBwidth");
-    if ( !mxIsEmpty(opt) )
-      *mupper = (long int)*mxGetPr(opt);
-    
-    opt = mxGetField(options,0,"LowerBwidth");
-    if ( !mxIsEmpty(opt) )
-      *mlower = (long int)*mxGetPr(opt);
-
-  }
-
-  /* SPGMR linear solver options */
-  
-  if (ls==LS_SPGMR) {
-
-    /* Type of Gram-Schmidt procedure */
-
-    opt = mxGetField(options,0,"GramSchmidtType");
-    if ( !mxIsEmpty(opt) ) {
-      buflen = mxGetM(opt) * mxGetN(opt) + 1;
-      bufval = mxCalloc(buflen, sizeof(char));
-      status = mxGetString(opt, bufval, buflen);
-      if(status != 0) {
-        cvmErrHandler(-999, "CVODES", fctName, "Cannot parse GramSchmidtType.", NULL);
-        return(-1);
-      }
-      if(!strcmp(bufval,"Classical"))     *gstype = CLASSICAL_GS;
-      else if(!strcmp(bufval,"Modified")) *gstype = MODIFIED_GS;
-      else {
-        cvmErrHandler(-999, "CVODES", fctName, "GramSchmidtType has an illegal value.", NULL);
-        return(-1);
-      }
-    }
-
-  }
-
-  /* SPILS linear solver options */
-
-  if ( (ls==LS_SPGMR) || (ls==LS_SPBCG) || (ls==LS_SPTFQMR) ) {
-
-    /* Max. dimension of Krylov subspace */
-
-    opt = mxGetField(options,0,"KrylovMaxDim");
-    if ( !mxIsEmpty(opt) ) {
-      *maxl = (int)*mxGetPr(opt);
-      if (*maxl < 0) {
-        cvmErrHandler(-999, "CVODES", fctName, "KrylovMaxDim is negative.", NULL);
-        return(-1);
-      }
-    }
-
-    /* Preconditioning type */
-
-    opt = mxGetField(options,0,"PrecType");
-    if ( !mxIsEmpty(opt) ) {
-      buflen = mxGetM(opt) * mxGetN(opt) + 1;
-      bufval = mxCalloc(buflen, sizeof(char));
-      status = mxGetString(opt, bufval, buflen);
-      if(status != 0) {
-        cvmErrHandler(-999, "CVODES", fctName, "Cannot parse PrecType.", NULL);
-        return(-1);
-      }
-      if(!strcmp(bufval,"Left")) *ptype = PREC_LEFT;
-      else if(!strcmp(bufval,"Right")) *ptype = PREC_RIGHT;
-      else if(!strcmp(bufval,"Both"))  *ptype = PREC_BOTH;
-      else if(!strcmp(bufval,"None"))  *ptype = PREC_NONE;
-      else {
-        cvmErrHandler(-999, "CVODES", fctName, "PrecType has an illegal value.", NULL);
-        return(-1);
-      }
-    }
-
-    /* User defined precoditioning */
-
-    opt = mxGetField(options,0,"PrecSetupFn");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_PSETfct);
-      mtlb_PSETfct  = mxDuplicateArray(opt);
-    }
-
-    opt = mxGetField(options,0,"PrecSolveFn");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_PSOLfct);
-      mtlb_PSOLfct  = mxDuplicateArray(opt);
-    }
-
-    /* Preconditioner module */
-  
-    opt = mxGetField(options,0,"PrecModule");
-    if ( !mxIsEmpty(opt) ) {
-      buflen = mxGetM(opt) * mxGetN(opt) + 1;
-      bufval = mxCalloc(buflen, sizeof(char));
-      status = mxGetString(opt, bufval, buflen);
-      if(status != 0) {
-        cvmErrHandler(-999, "CVODES", fctName, "Cannot parse PrecModule.", NULL);
-        return(-1);
-      }
-      if(!strcmp(bufval,"BandPre"))          pm = PM_BANDPRE;
-      else if(!strcmp(bufval,"BBDPre"))      pm = PM_BBDPRE;
-      else if(!strcmp(bufval,"UserDefined")) pm = PM_NONE;
-      else {
-        cvmErrHandler(-999, "CVODES", fctName, "PrecModule has an illegal value.", NULL);
-        return(-1);
-      }
-    }
-
-    if (pm != PM_NONE) {
-    
-      opt = mxGetField(options,0,"UpperBwidth");
-      if ( !mxIsEmpty(opt) )
-        *mupper = (long int)*mxGetPr(opt);
-      
-      opt = mxGetField(options,0,"LowerBwidth");
-      if ( !mxIsEmpty(opt) )
-        *mlower = (long int)*mxGetPr(opt);
-      
-    }
-
-    if (pm == PM_BBDPRE) {
-      
-      opt = mxGetField(options,0,"UpperBwidthDQ");
-      if ( !mxIsEmpty(opt) )
-        *mudq = (long int)*mxGetPr(opt);
-
-      opt = mxGetField(options,0,"LowerBwidthDQ");
-      if ( !mxIsEmpty(opt) )
-        *mldq = (long int)*mxGetPr(opt);
-
-      opt = mxGetField(options,0,"GlocalFn");
-      if ( !mxIsEmpty(opt) ) {
-        mxDestroyArray(mtlb_GLOCfct);
-        mtlb_GLOCfct  = mxDuplicateArray(opt);
-      } else { 
-        cvmErrHandler(-999, "CVODES", fctName, "GlocalFn required for BBD preconditioner.", NULL);
-        return(-1);
-      }      
-
-      opt = mxGetField(options,0,"GcommFn");
-      if ( !mxIsEmpty(opt) ) {
-        mxDestroyArray(mtlb_GCOMfct);
-        mtlb_GCOMfct  = mxDuplicateArray(opt);
-      }
-
-    }
-
-  }
-
-  
-  /* We made it here without problems */
-
-  return(0);
-
-}
-
-
-int get_QuadOptions(const mxArray *options, cvmPbData thisPb, booleantype fwd,
-                    long int Nq, booleantype *rhs_s,
-                    booleantype *errconQ,
-                    int *itolQ, double *reltolQ, double *SabstolQ, double **VabstolQ)
-{
-  mxArray *opt;
-  long int i, m, n;
-  double *tmp;
-  char *fctName;
-  char *fwd_fctName = "CVodeQuadInit/CVodeQuadReInit";
-  char *bck_fctName = "CVodeQuadInitB/CVodeQuadReInitB";
-
-  if (fwd) fctName = fwd_fctName;
-  else     fctName = bck_fctName;
-
-  *errconQ = FALSE;
-  *itolQ = CV_SS;
-  *reltolQ = 1.0e-4;
-  *SabstolQ = 1.0e-6;
-  *VabstolQ = NULL;
-
-  *rhs_s = FALSE;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* For backward problems only, check dependency on forward sensitivities */
-
-  if (!fwd) {
-
-    opt = mxGetField(options,0,"SensDependent");
-    if ( !mxIsEmpty(opt) ) {
-      if (!mxIsLogical(opt)) {
-        cvmErrHandler(-999, "CVODES", fctName, "SensDependent is not a logical scalar.", NULL);
-        return(-1);
-      }
-      if (mxIsLogicalScalarTrue(opt)) *rhs_s = TRUE;
-      else                            *rhs_s = FALSE;
-    }
-
-  }
-
-  /* Quadrature error control and tolerances */
-
-  opt = mxGetField(options,0,"ErrControl");
-
-  if ( mxIsEmpty(opt) ) return(0);
-
-  if (!mxIsLogical(opt)) {
-    cvmErrHandler(-999, "CVODES", fctName, "ErrControl is not a logical scalar.", NULL);
-    return(-1);
-  }
-
-  if (!mxIsLogicalScalarTrue(opt)) return(0);
-  
-  /* the remining options are interpreted only if quadratures are included in error control */
-
-  *errconQ = TRUE;
-
-  opt = mxGetField(options,0,"RelTol");
-  if ( !mxIsEmpty(opt) ) {
-    *reltolQ = *mxGetPr(opt);
-    if (*reltolQ < 0.0) {
-      cvmErrHandler(-999, "CVODES", fctName, "RelTol is negative.", NULL);
-      return(-1);
-    }
-  } 
-
-  opt = mxGetField(options,0,"AbsTol");
-  if ( !mxIsEmpty(opt) ) {
-
-    m = mxGetN(opt);
-    n = mxGetM(opt);
-    if ( (n != 1) && (m != 1) ) {
-      cvmErrHandler(-999, "CVODES", fctName, "AbsTol is not a scalar or a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    tmp = mxGetPr(opt);
-
-    if (n == 1) {
-      *itolQ = CV_SS;
-      *SabstolQ = *tmp;
-      if (*SabstolQ < 0.0) {
-        cvmErrHandler(-999, "CVODES", fctName, "AbsTol is negative.", NULL);
-        return(-1);
-      }
-    } else if (n == Nq) {
-      *itolQ = CV_SV;
-      *VabstolQ = (double *)malloc(Nq*sizeof(double));
-      for(i=0;i<Nq;i++) {
-        (*VabstolQ)[i] = tmp[i];
-        if (tmp[i] < 0.0) {
-          cvmErrHandler(-999, "CVODES", fctName, "AbsTol has a negative component.", NULL);
-          return(-1);
-        }
-      }
-    } else {
-      cvmErrHandler(-999, "CVODES", fctName, "AbsTol does not contain Nq elements.", NULL);
-      return(-1);
-    }
-
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-}
-
-int get_FSAOptions(const mxArray *options, cvmPbData thisPb,
-                   int *ism,
-                   char **pfield_name, int **plist, double **pbar,
-                   int *dqtype, double *rho,
-                   booleantype *errconS, int *itolS, double *reltolS, 
-                   double **SabstolS, double **VabstolS)
-{
-  mxArray *opt;
-  char *bufval;
-  int i, is, m, n, buflen, status, this_plist;
-  double *tmp;
-
-  /* Set default values */
-
-  *ism = CV_STAGGERED;
-
-  *dqtype = CV_CENTERED;
-  *rho = 0.0;
-
-  *errconS = TRUE;
-
-  *itolS = CV_EE;
-  *SabstolS = NULL;
-  *VabstolS = NULL;
-
-  *pfield_name = NULL;
-  *plist = NULL;
-  *pbar  = NULL;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* Sensitivity method */
-
-  opt = mxGetField(options,0,"method");
-  if ( !mxIsEmpty(opt) ) {
-  
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "Could not parse method.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"Simultaneous"))   *ism = CV_SIMULTANEOUS;
-    else if(!strcmp(bufval,"Staggered")) *ism = CV_STAGGERED;
-    else {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "method has an illegal value.", NULL);
-      return(-1);
-    }
-  }
-
-
-  /* Field name in data structure for params. */
-
-  opt = mxGetField(options,0,"ParamField");
-  if ( !mxIsEmpty(opt) ) {
-
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "Could not parse ParamField.", NULL);
-      return(-1);
-    }
-    *pfield_name = mxCalloc(buflen, sizeof(char));
-    strcpy((*pfield_name), bufval);
-
-  }  
-
-  /* PLIST */
-
-  opt = mxGetField(options,0,"ParamList");
-  if ( !mxIsEmpty(opt) ) {
-
-    tmp = mxGetPr(opt);
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "ParamList is not a vector.", NULL);
-      return(-1);
-    }
-    if (m > n) n = m;
-    if ( n != Ns) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "ParamList does not contain Ns elements.", NULL);
-      return(-1);
-    }
-    *plist = (int *) malloc(Ns*sizeof(int));
-    for (is=0;is<Ns;is++) {
-      this_plist = (int) tmp[is];
-      if (this_plist <= 0) {
-        cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "ParamList must contain only positive integers.", NULL);
-        return(-1);
-      }
-      (*plist)[is] = this_plist - 1;
-    }
-
-  }
-
-  /* PBAR */
-
-  opt = mxGetField(options,0,"ParamScales");
-  if ( !mxIsEmpty(opt) ) {
-
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "ParamScales is not a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    if ( n != Ns) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "ParamScales does not contain Ns elements.", NULL);
-      return(-1);
-    }
-    tmp = mxGetPr(opt);
-    *pbar = (double *) malloc(Ns*sizeof(double));
-    for(i=0;i<Ns;i++)
-      (*pbar)[i] = tmp[i];
-
-  }
-
-  /* DQ type */
-
-  opt = mxGetField(options,0,"DQtype");
-  if ( !mxIsEmpty(opt) ) {
-
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "Cannot parse DQtype.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"Centered")) *dqtype = CV_CENTERED;
-    else if(!strcmp(bufval,"Forward")) *dqtype = CV_FORWARD;
-    else {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "DQtype has an illegal value.", NULL);
-      return(-1);
-    }
-  }
-  
-  /* DQ parameter */
-
-  opt = mxGetField(options,0,"DQparam");
-  if ( !mxIsEmpty(opt) )
-    *rho = *mxGetPr(opt);
-
-  /* Error control */
-
-  opt = mxGetField(options,0,"ErrControl");
-  if ( !mxIsEmpty(opt) ) {
-    if (!mxIsLogical(opt)) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "ErrControl is not a logical scalar.", NULL);
-      return(-1);
-    }
-    if (mxIsLogicalScalarTrue(opt)) *errconS = TRUE;
-    else                            *errconS = FALSE;
-  }
-
-  /* Tolerances */
-  
-  opt = mxGetField(options,0,"RelTol");
-  if ( !mxIsEmpty(opt) ) {
-
-    *reltolS = *mxGetPr(opt);
-    if (*reltolS < 0.0) {
-      cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "RelTol is negative.", NULL);
-      return(-1);
-    }
-    opt = mxGetField(options,0,"AbsTol");
-    if ( !mxIsEmpty(opt) ) {
-
-      m = mxGetM(opt);
-      n = mxGetN(opt);
-      if ( (m == 1) && (n == Ns) ) {
-        *itolS = CV_SS;
-        tmp = mxGetPr(opt);
-        *SabstolS = (double *) malloc(Ns*sizeof(double));
-        for (is=0; is<Ns; is++) {
-          (*SabstolS)[is] = tmp[is];
-          if ( tmp[is] < 0.0 ) {
-            cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "AbsTol has a negative component.", NULL);
-            return(-1);
-          }
-        }
-      } else if ( (m == N) && (n == Ns) ) {
-        *itolS = CV_SV;
-        tmp = mxGetPr(opt);
-        *VabstolS = (double *)malloc(Ns*N*sizeof(double));
-        for (i=0; i<Ns*N; i++) {
-          (*VabstolS)[i] = tmp[i];
-          if ( tmp[i] < 0.0 ) {
-            cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "AbsTol has a negative component.", NULL);
-            return(-1);
-          }
-        }
-      } else {
-        cvmErrHandler(-999, "CVODES", "CVodeSensInit/CVodeSensReInit", "AbsTol must be either a 1xNs vector or an NxNs matrix.", NULL);
-        return(-1);
-      }
-
-    } else {
-
-      *itolS = CV_EE;
-
-    }
-
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-
-}
diff --git a/sundialsTB/cvodes/cvm/src/cvmWrap.c b/sundialsTB/cvodes/cvm/src/cvmWrap.c
deleted file mode 100644
index 179b466..0000000
--- a/sundialsTB/cvodes/cvm/src/cvmWrap.c
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.12 $
- * $Date: 2012/03/07 21:44:21 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/cvodes/LICENSE.
- * -----------------------------------------------------------------
- * CVODES wrapper functions.
- * -----------------------------------------------------------------
- */
-
-#include "cvm.h"
-#include "nvm.h"
-
-static void UpdateUserData(mxArray *new_mtlb_data, cvmPbData pb);
-static void UpdateMonitorData(mxArray *new_mtlb_data, cvmPbData pb);
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define fsa         (fwdPb->Fsa)
-#define quadr       (fwdPb->Quadr)
-#define N           (fwdPb->n) 
-#define Nq          (fwdPb->nq) 
-#define Ng          (fwdPb->ng) 
-#define Ns          (fwdPb->ns) 
-
-#define quadrB      (bckPb->Quadr)
-#define NB          (bckPb->n) 
-#define NqB         (bckPb->nq) 
-
-/*
- * ---------------------------------------------------------------------------------
- * FORWARD PROBLEMS
- * ---------------------------------------------------------------------------------
- */
-
-int mxW_CVodeRhs(realtype t, N_Vector y, N_Vector yd, void *user_data)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[4], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */
-  mx_in[2] = fwdPb->RHSfct;                    /* matlab function handle */ 
-  mx_in[3] = fwdPb->mtlb_data;                 /* matlab user data */
-
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(3,mx_out,4,mx_in,"cvm_rhs");
-
-  PutData(yd, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_CVodeQUADfct(realtype t, N_Vector y, N_Vector yQd, void *user_data)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[4], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */
-  mx_in[2] = fwdPb->QUADfct;                   /* matlab function handle */ 
-  mx_in[3] = fwdPb->mtlb_data;                 /* matlab user data */
-
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(3,mx_out,4,mx_in,"cvm_rhsQ");
-
-  PutData(yQd, mxGetPr(mx_out[0]), Nq);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_CVodeGfct(realtype t, N_Vector y, double *g, void *user_data)
-{
-  cvmPbData fwdPb;
-  double *gdata;
-  int i, ret;
-  mxArray *mx_in[4], *mx_out[3];
-  
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */
-  mx_in[2] = fwdPb->Gfct;                      /* matlab function handle */
-  mx_in[3] = fwdPb->mtlb_data;                 /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(3,mx_out,4,mx_in,"cvm_root");
-
-  gdata = mxGetPr(mx_out[0]);
-  for (i=0;i<Ng;i++) g[i] = gdata[i];
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeDenseJac(long int Neq, realtype t,
-                      N_Vector y, N_Vector fy, 
-                      DlsMat J, void *user_data,
-                      N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
-{
-  cvmPbData fwdPb;
-  double *J_data;
-  long int i;
-  int ret;
-  mxArray *mx_in[5], *mx_out[3];
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */  
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fy */
-  mx_in[3] = fwdPb->JACfct;                     /* matlab function handle */
-  mx_in[4] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(fy, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(3,mx_out,5,mx_in,"cvm_djac");
-
-  /* Extract data */
-  J_data = mxGetPr(mx_out[0]);
-  for (i=0;i<N;i++)
-    memcpy(DENSE_COL(J,i), J_data + i*N, N*sizeof(double));
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_CVodeBandJac(long int Neq, long int mupper, long int mlower, realtype t,
-                     N_Vector y, N_Vector fy, 
-                     DlsMat J, void *user_data,
-                     N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
-{
-  cvmPbData fwdPb;
-  double *J_data;
-  long int eband, i;
-  int ret;
-  mxArray *mx_in[5], *mx_out[3];
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fy */
-  mx_in[3] = fwdPb->JACfct;                     /* matlab function handle */
-  mx_in[4] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(fy, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(3,mx_out,5,mx_in,"cvm_bjac");
-
-  /* Extract data */
-  eband =  mupper + mlower + 1;
-  J_data = mxGetPr(mx_out[0]);
-  for (i=0;i<N;i++)
-    memcpy(BAND_COL(J,i) - mupper, J_data + i*eband, eband*sizeof(double));
-
-  ret = (int)*mxGetPr(mx_out[1]);
-  
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeSpilsJac(N_Vector v, N_Vector Jv, realtype t,
-                      N_Vector y, N_Vector fy,
-                      void *user_data, N_Vector tmp)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[6], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */ 
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* vector v */
-  mx_in[4] = fwdPb->JACfct;                     /* matlab function handle */
-  mx_in[5] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(fy, mxGetPr(mx_in[2]), N);
-  GetData(v, mxGetPr(mx_in[3]), N);
-
-  mexCallMATLAB(3,mx_out,6,mx_in,"cvm_jtv");
-
-  PutData(Jv, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeSpilsPset(realtype t, N_Vector y, N_Vector fy,
-                       booleantype jok, booleantype *jcurPtr,
-                       realtype gamma, void *user_data,
-                       N_Vector tmp1, N_Vector tmp2,
-                       N_Vector tmp3)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[7], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fy */
-  mx_in[3] = mxCreateLogicalScalar(jok);        /* jok flag */
-  mx_in[4] = mxCreateDoubleScalar(gamma);       /* gamma value */
-  mx_in[5] = fwdPb->PSETfct;                    /* matlab function handle */
-  mx_in[6] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(fy, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"cvm_pset");
-
-  *jcurPtr = mxIsLogicalScalarTrue(mx_out[0]);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeSpilsPsol(realtype t, N_Vector y, N_Vector fy,
-                       N_Vector r, N_Vector z,
-                       realtype gamma, realtype delta,
-                       int lr, void *user_data, N_Vector tmp)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[6], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);          /* current t */   
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* right hand side r */
-  mx_in[4] = fwdPb->PSOLfct;                   /* matlab function handle */
-  mx_in[5] = fwdPb->mtlb_data;                 /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(fy, mxGetPr(mx_in[2]), N);
-  GetData(r, mxGetPr(mx_in[3]), N);
-
-  mexCallMATLAB(3,mx_out,6,mx_in,"cvm_psol");
-
-  PutData(z, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-/*
- * ----------------------------
- * BBD PRECONDITONER FUNCTIONS
- * ----------------------------
- */
-
-int mxW_CVodeBBDgloc(long int Nlocal, realtype t, N_Vector y,
-                     N_Vector g, void *user_data)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[4], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = fwdPb->GLOCfct;                    /* matlab function handle */
-  mx_in[3] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(3,mx_out,4,mx_in,"cvm_gloc");
-
-  PutData(g, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_CVodeBBDgcom(long int Nlocal, realtype t, N_Vector y, void *user_data)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[4], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = fwdPb->GCOMfct;                    /* matlab function handle */
-  mx_in[3] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(2,mx_out,4,mx_in,"cvm_gcom");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-}
-
-/*
- * ----------------------------
- * FORWARD SENSITVITY FUNCTIONS
- * ----------------------------
- */
-
-int mxW_CVodeSensRhs(int Nsens, realtype t,
-                     N_Vector y, N_Vector yd,
-                     N_Vector *yS, N_Vector *ySd,
-                     void *user_data,
-                     N_Vector tmp1, N_Vector tmp2)
-{
-  cvmPbData fwdPb;
-  mxArray *mx_in[7], *mx_out[3];
-  int is, ret;
-  double *tmp;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (cvmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);             /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current yd */
-  mx_in[3] = mxCreateDoubleScalar(Ns);            /* number of sensitivities */
-  mx_in[4] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yS */
-  mx_in[5] = fwdPb->SRHSfct;                      /* matlab function handle */      
-  mx_in[6] = fwdPb->mtlb_data;                    /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yd, mxGetPr(mx_in[2]), N);
-  tmp = mxGetPr(mx_in[4]);
-  for (is=0; is<Ns; is++)
-    GetData(yS[is], &tmp[is*N], N);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"cvm_rhsS");
-  
-  tmp = mxGetPr(mx_out[0]);
-
-  for(is=0;is<Ns;is++)
-    PutData(ySd[is], &tmp[is*N], N);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-/*
- * ----------------------------
- * ADJOINT SENSITVITY FUNCTIONS
- * ----------------------------
- */
-
-int mxW_CVodeRhsB(realtype t, N_Vector y, N_Vector yB, N_Vector yBd, void *user_dataB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[6], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(0.0);         /* type=0: not dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[4] = bckPb->RHSfct;                     /* matlab function handle */ 
-  mx_in[5] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[2]), N);
-  GetData(yB, mxGetPr(mx_in[3]), NB);
-
-  mexCallMATLAB(3,mx_out,6,mx_in,"cvm_rhsB");
-
-  PutData(yBd, mxGetPr(mx_out[0]), NB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeRhsBS(realtype t, N_Vector y,  N_Vector *yS,
-                   N_Vector yB, N_Vector yBd, void *user_dataB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[8], *mx_out[3];
-  int is, ret;
-  double *tmp;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(1.0);           /* type=1: dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(t);             /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current y */
-  mx_in[3] = mxCreateDoubleScalar(Ns);            /* number of sensitivities */
-  mx_in[4] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yS */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL);   /* current yB */
-  mx_in[6] = bckPb->RHSfct;                       /* matlab function handle */ 
-  mx_in[7] = bckPb->mtlb_data;                    /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[2]), N);
-
-  tmp = mxGetPr(mx_in[4]);
-  for (is=0; is<Ns; is++)
-    GetData(yS[is], &tmp[is*N], N);
-
-  GetData(yB, mxGetPr(mx_in[5]), NB);
-
-  mexCallMATLAB(3,mx_out,8,mx_in,"cvm_rhsB");
-
-  PutData(yBd, mxGetPr(mx_out[0]), NB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-
-int mxW_CVodeQUADfctB(realtype t, N_Vector y, N_Vector yB, N_Vector yQBd, void *user_dataB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[6], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(0.0);         /* type=0: not dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[4] = bckPb->QUADfct;                    /* matlab function handle */ 
-  mx_in[5] = bckPb->mtlb_data;                  /* matlab user data */
-
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[2]), N);
-  GetData(yB, mxGetPr(mx_in[3]), NB);
-
-  mexCallMATLAB(3,mx_out,6,mx_in,"cvm_rhsQB");
-
-  PutData(yQBd, mxGetPr(mx_out[0]), NqB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeQUADfctBS(realtype t, N_Vector y,  N_Vector *yS,
-                       N_Vector yB, N_Vector yQBd, void *user_dataB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[8], *mx_out[3];
-  int is, ret;
-  double *tmp;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(1.0);           /* type=1: dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(t);             /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current y */
-  mx_in[3] = mxCreateDoubleScalar(Ns);            /* number of sensitivities */
-  mx_in[4] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yS */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL);   /* current yB */
-  mx_in[6] = bckPb->QUADfct;                      /* matlab function handle */ 
-  mx_in[7] = bckPb->mtlb_data;                    /* matlab user data */
-
-  /* Call matlab wrapper */
-
-  GetData(y, mxGetPr(mx_in[2]), N);
-
-  tmp = mxGetPr(mx_in[4]);
-  for (is=0; is<Ns; is++)
-    GetData(yS[is], &tmp[is*N], N);
-
-  GetData(yB, mxGetPr(mx_in[5]), NB);
-
-  mexCallMATLAB(3,mx_out,8,mx_in,"cvm_rhsQB");
-
-  PutData(yQBd, mxGetPr(mx_out[0]), NqB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-
-
-int mxW_CVodeDenseJacB(long int NeqB, realtype t,
-                       N_Vector y, N_Vector yB, N_Vector fyB,
-                       DlsMat JB, void *user_dataB, 
-                       N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
-{
-  cvmPbData fwdPb, bckPb;
-  double *JB_data;
-  mxArray *mx_in[6], *mx_out[3];
-  int i, ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */  
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */
-  mx_in[4] = bckPb->JACfct;                     /* matlab function handle */
-  mx_in[5] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yB, mxGetPr(mx_in[2]), NB);
-  GetData(fyB, mxGetPr(mx_in[3]), NB);
-
-  mexCallMATLAB(3,mx_out,6,mx_in,"cvm_djacB");
-
-  JB_data = mxGetPr(mx_out[0]);
-  for (i=0;i<NB;i++)
-    memcpy(DENSE_COL(JB,i), JB_data + i*NB, NB*sizeof(double));
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeBandJacB(long int NeqB, long int mupperB, long int mlowerB, realtype t, 
-                       N_Vector y, N_Vector yB, N_Vector fyB,
-                       DlsMat JB, void *user_dataB, 
-                       N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
-{
-  cvmPbData fwdPb, bckPb;
-  double *JB_data;
-  mxArray *mx_in[6], *mx_out[3];
-  long int ebandB, i;
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */
-  mx_in[4] = bckPb->JACfct;                     /* matlab function handle */
-  mx_in[5] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yB, mxGetPr(mx_in[2]), NB);
-  GetData(fyB, mxGetPr(mx_in[3]), NB);
-
-  mexCallMATLAB(3,mx_out,6,mx_in,"cvm_bjacB");
-
-  ebandB =  mupperB + mlowerB + 1;
-  JB_data = mxGetPr(mx_out[0]);
-  for (i=0;i<NB;i++)
-    memcpy(BAND_COL(JB,i) - mupperB, JB_data + i*ebandB, ebandB*sizeof(double));
-    
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_CVodeSpilsJacB(N_Vector vB, N_Vector JvB, realtype t,
-                        N_Vector y, N_Vector yB, N_Vector fyB,
-                        void *user_dataB, N_Vector tmpB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[7], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */ 
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* vector vB */
-  mx_in[5] = bckPb->JACfct;                     /* matlab function handle */
-  mx_in[6] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yB, mxGetPr(mx_in[2]), NB);
-  GetData(fyB, mxGetPr(mx_in[3]), NB);
-  GetData(vB, mxGetPr(mx_in[4]), NB);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"cvm_jtvB");
-
-  PutData(JvB, mxGetPr(mx_out[0]), NB);
-  ret = (int)*mxGetPr(mx_out[1]);
-  
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-
-}
-
-
-int mxW_CVodeSpilsPsetB(realtype t, N_Vector y,
-                         N_Vector yB, N_Vector fyB,
-                         booleantype jokB,
-                         booleantype *jcurPtrB, realtype gammaB,
-                         void *user_dataB,
-                         N_Vector tmp1B, N_Vector tmp2B,
-                         N_Vector tmp3B)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[8], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */
-  mx_in[4] = mxCreateLogicalScalar(jokB);       /* jokB flag */
-  mx_in[5] = mxCreateDoubleScalar(gammaB);      /* gammaB value */
-  mx_in[6] = bckPb->PSETfct;                    /* matlab function handle */
-  mx_in[7] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yB, mxGetPr(mx_in[2]), NB);
-  GetData(fyB, mxGetPr(mx_in[3]), NB);
-
-  mexCallMATLAB(3,mx_out,8,mx_in,"cvm_psetB");
-
-  *jcurPtrB = mxIsLogicalScalarTrue(mx_out[0]);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-
-}
-
-
-int mxW_CVodeSpilsPsolB(realtype t, N_Vector y,
-                         N_Vector yB, N_Vector fyB,
-                         N_Vector rB, N_Vector zB,
-                         realtype gammaB, realtype deltaB,
-                         int lrB, void *user_dataB, N_Vector tmpB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[7], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */   
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current fyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* right hand side rB */
-  mx_in[5] = bckPb->PSOLfct;                    /* matlab function handle */
-  mx_in[6] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yB, mxGetPr(mx_in[2]), NB);
-  GetData(fyB, mxGetPr(mx_in[3]), NB);
-  GetData(rB, mxGetPr(mx_in[4]), NB);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"cvm_psolB");
-
-  PutData(zB, mxGetPr(mx_out[0]), NB);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-
-}
-
-int mxW_CVodeBBDglocB(long int NlocalB, realtype t, N_Vector y,
-                       N_Vector yB, N_Vector gB, void *user_dataB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[5], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[3] = bckPb->GLOCfct;                    /* matlab function handle */
-  mx_in[4] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yB, mxGetPr(mx_in[2]), NB);
-
-  mexCallMATLAB(3,mx_out,5,mx_in,"cvm_glocB");
-
-  PutData(gB, mxGetPr(mx_out[0]), NB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_CVodeBBDgcomB(long int NlocalB, realtype t, N_Vector y, 
-                       N_Vector yB, void *user_dataB)
-{
-  cvmPbData fwdPb, bckPb;
-  mxArray *mx_in[5], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (cvmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);           /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[2] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yB */
-  mx_in[3] = bckPb->GCOMfct;                    /* matlab function handle */
-  mx_in[4] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(y, mxGetPr(mx_in[1]), N);
-  GetData(yB, mxGetPr(mx_in[2]), NB);
-
-  mexCallMATLAB(2,mx_out,5,mx_in,"cvm_gcomB");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Wrapper around matlab monitor function
- * ---------------------------------------------------------------------------------
- */
-
-void mxW_CVodeMonitor(int call, double t, N_Vector y, N_Vector yQ, N_Vector *yS,
-                       cvmPbData fwdPb)
-{
-  mxArray *mx_in[8], *mx_out[1];
-  double *tmp;
-  int is;
-
-  mx_in[0] = mxCreateDoubleScalar(call);            /* call type (0:first, 1:interm. 2:last) */
-  mx_in[1] = mxCreateDoubleScalar(t);               /* current time */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);      /* current solution */
-  if (quadr)
-    mx_in[3] = mxCreateDoubleMatrix(Nq,1,mxREAL);   /* current quadratures */
-  else
-    mx_in[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  mx_in[4] = mxCreateDoubleScalar(Ns);              /* number of sensitivities */
-  if (fsa)
-    mx_in[5] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current sensitivities */
-  else
-    mx_in[5] = mxCreateDoubleMatrix(0,0,mxREAL);
-  mx_in[6] = fwdPb->MONfct;                         /* Matlab monitor function */
-  mx_in[7] = fwdPb->MONdata;                        /* data for monitor function */
-
-  if (call == 1) {
-
-    GetData(y, mxGetPr(mx_in[2]), N);
-
-    if (quadr)
-      GetData(yQ, mxGetPr(mx_in[3]), Nq);
-
-    if (fsa) {
-      tmp = mxGetPr(mx_in[5]);
-      for (is=0; is<Ns; is++)
-        GetData(yS[is], &tmp[is*N], N);
-    }
-
-  }
-
-  mexCallMATLAB(1,mx_out,8,mx_in,"cvm_monitor");
-
-  if (!mxIsEmpty(mx_out[0])) {
-    UpdateMonitorData(mx_out[0], fwdPb);
-  }
-
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-}
-
-void mxW_CVodeMonitorB(int call, int idxB, double tB, N_Vector yB, N_Vector yQB,
-                       cvmPbData bckPb)
-{
-  mxArray *mx_in[7], *mx_out[1];
-
-  mx_in[0] = mxCreateDoubleScalar(call);            /* 0: first, 1: interm. 2: last */
-  mx_in[1] = mxCreateDoubleScalar(idxB);            /* index of current problem */
-  mx_in[2] = mxCreateDoubleScalar(tB);              /* current time */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL);     /* current solution */
-  if (quadrB)
-    mx_in[4] = mxCreateDoubleMatrix(NqB,1,mxREAL);  /* current quadratures */
-  else
-    mx_in[4] = mxCreateDoubleMatrix(0,0,mxREAL);
-  mx_in[5] = bckPb->MONfct;
-  mx_in[6] = bckPb->MONdata;
-
-  if (call == 1) {
-    
-    GetData(yB, mxGetPr(mx_in[3]), NB);
-
-    if (quadrB)
-      GetData(yQB, mxGetPr(mx_in[4]), NqB);
-  }
-
-  mexCallMATLAB(1,mx_out,7,mx_in,"cvm_monitorB");
-
-  if (!mxIsEmpty(mx_out[0])) {
-    UpdateMonitorData(mx_out[0], bckPb);
-  }
-
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-}
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Private functions to update the user data structures
- * ---------------------------------------------------------------------------------
- */
-
-static void UpdateUserData(mxArray *new_mtlb_data, cvmPbData pb)
-{
-  mexUnlock();
-  mxDestroyArray(pb->mtlb_data);
-  pb->mtlb_data = mxDuplicateArray(new_mtlb_data);
-  mexMakeArrayPersistent(pb->mtlb_data);
-  mexLock();
-}
-
-static void UpdateMonitorData(mxArray *new_mtlb_data, cvmPbData pb)
-{
-  mexUnlock();
-  mxDestroyArray(pb->MONdata);
-  pb->MONdata = mxDuplicateArray(new_mtlb_data);
-  mexMakeArrayPersistent(pb->MONdata);
-  mexLock();
-}
-
diff --git a/sundialsTB/cvodes/examples_par/mcvsAdvDiff_FSA_non_p.m b/sundialsTB/cvodes/examples_par/mcvsAdvDiff_FSA_non_p.m
deleted file mode 100644
index d1fd9f4..0000000
--- a/sundialsTB/cvodes/examples_par/mcvsAdvDiff_FSA_non_p.m
+++ /dev/null
@@ -1,206 +0,0 @@
-function [] = mcvsAdvDiff_FSA_non_p(comm)
-%mcvsAdvDiff_FSA_non_p - CVODES forward sensitivity example
-%                        (parallel, Adams, Functional)
-%   Semi-discrete form of the advection-diffusion equation in 1-D:
-%     du/dt = q1 * d^2 u / dx^2 + q2 * du/dx
-%   on the interval 0 <= x <= 2, and the time interval 0 <= t <= 5.
-%   Homogeneous Dirichlet boundary conditions are posed, and the
-%   initial condition is:
-%     u(x,y,t=0) = x(2-x)exp(2x).
-%   The PDE is discretized on a uniform grid of size MX+2 with
-%   central differencing, and with boundary values eliminated,
-%   leaving an ODE system of size NEQ = MX.
-%
-%   Optionally, sensitivities with respect to q1 and q2 are also computed. 
-%
-%   This program solves the problem with the option for nonstiff
-%   systems: ADAMS method and functional iteration.
-%   It uses scalar relative and absolute tolerances.
-%   Output is printed at t = .5, 1.0, ..., 5.
-%
-%   See also: mpirun
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:47 $
-
-sensi = true;
-
-xmax = 2.0;
-mx = 10;
-dx = xmax/(mx+1);
-neq = mx;
-
-[status npes] = MPI_Comm_size(comm);
-[status mype] = MPI_Comm_rank(comm);
-
-nperpe = floor(neq/npes);
-nrem = neq - npes*nperpe;
-
-if mype < nrem
-  nlocal = nperpe+1;
-  my_base = mype * nlocal;
-else
-  nlocal = nperpe;
-  my_base = mype * nperpe + nrem;
-end
-
-data.comm = comm;
-data.nlocal = nlocal;
-data.npes = npes;
-data.mype = mype;
-data.dx = dx;
-data.p = [1.0 ; 0.5];
-
-t0 = 0.0;
-for i = 1:nlocal
-  iglobal = my_base + i;
-  x = iglobal * dx;
-  u0(i,1) = x *(xmax-x)*exp(2.0*x);
-end
-
-rtol = 0.0;
-atol = 1.0e-5;
-
-options = CVodeSetOptions('Reltol',rtol,'AbsTol',atol);
-CVodeInit(@rhsfn,'Adams','Functional',t0,u0,options,data);
-
-
-if sensi
-
-  Ns = 2;
-  uS0 = zeros(nlocal,Ns);
-  pbar = data.p;
-  plist = [1;2];
-
-  FSAoptions = CVodeSensSetOptions('method','Simultaneous',...
-                                   'ErrControl', 'on',...
-                                   'ParamField', 'p',...
-                                   'ParamList', plist,...
-                                   'ParamScales', pbar);
-
-  CVodeSensInit(Ns, [], uS0, FSAoptions);
-
-end
-
-
-if mype == 0
-  fprintf('============================================================\n');
-  fprintf('     T     Q       H      NST                    Max norm   \n');
-  fprintf('============================================================\n');
-end
-
-nout = 10;
-dtout = 0.5;
-tout = dtout;
-for i = 1:nout
-  if sensi
-    [status,t,u,uS] = CVode(tout,'Normal');
-    PrintOutput(mype, comm, t, u, uS);
-  else
-    [status,t,u] = CVode(tout,'Normal');
-    PrintOutput(mype, comm, t, u, []);
-  end
-  tout = tout + dtout;
-end
-
-CVodeFree;
-
-%%
-%%-------------------------------------------------------------------
-%%
-
-function [ud, flag, new_data] = rhsfn(t, u, data)
-
-% Extract needed problem constants from data
-
-dx = data.dx;
-hordc = data.p(1) / dx^2;
-horac = data.p(2) / (2.0*dx);
-
-% Extract parameters for parallel computation
-
-comm = data.comm;
-npes = data.npes;
-mype = data.mype;
-
-nlocal = length(u);
-
-% Compute related parameters
-
-mype_m1 = mype-1;
-mype_p1 = mype+1;
-last_pe = npes-1;
-
-% Local copy of state
-
-y = [0.0 ; u ; 0.0];
-
-% Pass needed data to processes before and after current one
-
-if mype ~= 0
-  MPI_Send(u(1), mype_m1, 0, comm);
-end
-if mype ~= last_pe
-  MPI_Send(u(nlocal), mype_p1, 0, comm);
-end
-
-% Receive needed data from processes before and after current one
-
-buf = 0.0;
-
-if mype ~= 0
-  MPI_Recv(buf, mype_m1, 0, comm);
-  y(1) = buf;
-else
-  y(1) = 0.0; % zero BC
-end
-
-if mype ~= last_pe
-  MPI_Recv(buf, mype_p1, 0, comm);
-  y(nlocal+2) = buf;
-else
-  y(nlocal+2) = 0.0; % zero BC
-end
-
-for i = 2:nlocal+1
-  ui = y(i);
-  ul = y(i-1);
-  ur = y(i+1);
-  
-  hdiff = hordc*(ul - 2.0*ui + ur);
-  hadv  = horac * (ur-ul);
-  
-  ud(i-1) = hdiff + hadv;
-  
-end
-
-flag = 0;
-new_data = [];
-
-
-%%
-%%-------------------------------------------------------------------
-%%
-
-function [] = PrintOutput(mype, comm, t, u, uS)
-
-umax = N_VMaxNorm(u,comm);
-
-if ~isempty(uS)
-  smax1 = N_VMaxNorm(uS(:,1),comm);
-  smax2 = N_VMaxNorm(uS(:,2),comm);
-end
-
-if mype == 0
-  si = CVodeGetStats;
-  fprintf('%8.3e %2d  %8.3e %5ld\n', t,si.qlast,si.hlast,si.nst);
-  fprintf('                                Solution       ');
-  fprintf('%12.4e \n', umax);
-  if ~isempty(uS)
-    fprintf('                                Sensitivity 1  ');
-    fprintf('%12.4e \n', smax1);
-    fprintf('                                Sensitivity 2  ');
-    fprintf('%12.4e \n', smax2);
-  end
-end
\ No newline at end of file
diff --git a/sundialsTB/cvodes/examples_par/mcvsAtmDisp_kry_bbd_p.m b/sundialsTB/cvodes/examples_par/mcvsAtmDisp_kry_bbd_p.m
deleted file mode 100644
index 02e50f8..0000000
--- a/sundialsTB/cvodes/examples_par/mcvsAtmDisp_kry_bbd_p.m
+++ /dev/null
@@ -1,521 +0,0 @@
-function [] = mcvsAtmDisp_kry_bbd_p(comm)
-%mcvsAtmDisp_kry_bbd_p - CVODES example problem
-%   (parallel, BDF, Newton, GMRES, BBDP)
-%   This example solves a 3D advection-diffusion PDE with a
-%   distributed source to simulate atmospheric dispersion.
-%   
-%   This example uses the BBDP preconditioner module in CVODES.
-%
-%   See also: mpirun
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:47 $
-
-%---------------------------------
-% Domain definition
-%  xmin - left boundary
-%  xmax - right boundary
-%  m    - number of intervals
-%  np   - number of processes
-%---------------------------------
-
-xmin(1) = 0.0; xmax(1) = 20.0; m(1) = 20; np(1) = 2;
-xmin(2) = 0.0; xmax(2) = 20.0; m(2) = 40; np(2) = 2;
-xmin(3) = 0.0; xmax(3) = 20.0; m(3) = 20; np(3) = 1;
-
-%---------------------------------
-% Get MPI id and no. of processes
-%---------------------------------
-
-[status npes] = MPI_Comm_size(comm);
-[status myId] = MPI_Comm_rank(comm);
-
-if npes ~= prod(np)
-  error('Wrong number of processes');
-end
-
-%---------------------------------
-% Set-up problem data
-%---------------------------------
-
-data = SetData(comm, npes, myId, xmin, xmax, m, np);
-
-%--------------------------------
-% Problem dimensions
-%--------------------------------
-
-nlocal = prod(data.ml);
-neq = prod(data.m);
-
-fprintf('\nPVKX example problem\n\n');
-fprintf('  Processor %d/%d\n',myId,npes);
-fprintf('  Global problem size: %d\n',neq);
-fprintf('  Local problem size:  %d\n\n',nlocal);
-
-
-%--------------------------------
-% Initial conditions
-%--------------------------------
-
-% Initial time
-t0 = 0.0;
-
-% Initial states (concentrations)
-y0 = zeros(nlocal,1);
-
-% TEST communication pattern
-fprintf('Local data structure\n');
-fprintf('  myId = %d\n',data.myId);
-fprintf('  xmin = %g %g %g\n',data.xmin);
-fprintf('  xmax = %g %g %g\n',data.xmax);
-fprintf('  dx   = %g %g %g\n',data.dx);
-fprintf('  start  = %3d %3d %3d\n',data.start);
-fprintf('  m      = %3d %3d %3d\n',data.m);
-fprintf('  ml     = %3d %3d %3d\n',data.ml);
-fprintf('  |yext| = %3d %3d %3d\n\n',size(data.yext));
-
-%--------------------------------
-% CVODES setup
-%--------------------------------
-
-% Tolerances
-options = CVodeSetOptions('RelTol',1.e-8,...
-                          'AbsTol',1.e-6);
-
-% Linear solver
-mldq = data.ml(1)+1;
-mudq = data.ml(1)+1;
-mlkeep = 2;
-mukeep = 2;
-
-options = CVodeSetOptions(options,...
-                          'LinearSolver','GMRES',...
-                          'PrecType','Left',...
-                          'PrecModule','BBDPre',...
-                          'GlocalFn', at pvkx_fl,...
-                          'LowerBwidthDQ',mldq,...
-                          'UpperBwidthDQ',mudq,...
-                          'LowerBwidth',mlkeep,...
-                          'UpperBwidth',mukeep);
-
-% Monitoring
-mondata = struct;
-if myId ==0
-  mondata.mode = 'text';
-else
-  mondata.post = false;
-end
-options = CVodeSetOptions(options,...
-                          'MonitorFn','CVodeMonitor',...
-                          'MonitorData',mondata);
-
-% Memory allocation and initialization
-CVodeInit(@rhsfn,'BDF','Newton',t0,y0,options,data);
-
-%--------------------------------
-% CVODES solution
-%--------------------------------
-
-tf = 0.01;
-
-[status,t,y] = CVode(tf,'Normal');
-
-if myId == 0
-  si = CVodeGetStats
-end
-
-
-CVodeFree;
-
-%
-% ===========================================================
-%
-
-function d = SetData(comm, npes, myId, xmin, xmax, m, np)
-
-%---------------------------------
-% MPI stuff
-%---------------------------------
-
-d.comm = comm;
-d.myId = myId;
-d.np = np;
-
-%---------------------------------
-% Domain boundaries
-%---------------------------------
-
-d.xmin = xmin;
-d.xmax = xmax;
-
-%--------------------------------------
-% Diffusion coefficient
-%--------------------------------------
-
-d.Dc = 1.0;
-
-%--------------------------------------
-% Velocity parameters: Poiseuille flow
-% across y direction, max. velocity=1
-%    v(y) = Vc*(L-y)*(L+y)
-%--------------------------------------
-
-d.L = 0.5 * ( xmax(2) - xmin(2) );
-d.Vc = 1.0/d.L^2;
-
-
-%--------------------------------------
-% Grid spacing and differential volume
-%   d.m -> number of internal points
-%--------------------------------------
-
-d.dx = (d.xmax - d.xmin) ./ m;
-d.m = m - [1 1 1];
-d.dOmega = prod(d.dx);
-
-%------------------------------------------------
-% Partitioning
-%   d.left  -> left neighbours
-%   d.right -> right neighbours
-%   d.start -> left border in global index space
-%   d.ml    -> length of subdomain
-%-----------------------------------------------
-
-npd = floor(d.m ./ np);
-
-% in x direction
-
-test = mod( myId , np(1) );
-
-d.left(1) = myId-1;
-d.right(1) = myId+1;
-d.start(1) = npd(1) * test + 1;
-d.ml(1) = npd(1);
-
-if test == 0
-  d.left(1) = myId;
-end
-
-if test == np(1)-1
-  d.right(1) = myId;
-  d.ml(1) = d.m(1) - d.start(1) + 1;
-end
-
-% in y direction
-
-test = mod( floor(myId/np(1)) , np(2) );
-
-d.left(2) = myId - np(1);
-d.right(2) = myId + np(1);
-d.start(2) = npd(2) * test + 1;
-d.ml(2) = npd(2);
-
-if test == 0
-  d.left(2) = myId;
-end
-
-if test == np(2)-1
-  d.right(2) = myId;
-  d.ml(2) = d.m(2) - d.start(2) + 1;
-end
-
-% in z direction
-
-test = mod( floor(myId/np(1)/np(2))  , np(3) );
-
-d.left(3) = myId - np(1)*np(2);
-d.right(3) = myId + np(1)*np(2);
-d.start(3) = npd(3) * test + 1;
-d.ml(3) = npd(3);
-
-if test == 0
-  d.left(3) = myId;
-end
-
-if test == np(3)-1
-  d.right(3) = myId;
-  d.ml(3) = d.m(3) - d.start(3) +1;
-end
-
-%--------------------------------------
-% Space for extended local solution 
-% 3D matrix
-%--------------------------------------
-
-d.yext = zeros([d.ml(1)+2 d.ml(2)+2 d.ml(3)+2]);
-
-%--------------------------------------
-% Source parameters: Gaussians with 
-%   - A: amplitude
-%   - S: sigma^2
-%   - X: position
-%--------------------------------------
-
-d.A1 = 1.0;
-d.S1 = 1.7^2;
-d.X1 = 4.0; d.Y1 = 8.0; d.Z1 = 8.0;
-
-d.A2 = 0.8;   
-d.S2 = 3.0^2;
-d.X2 = 16.0; d.Y2 = 12.0; d.Z2 = 12.0;
-
-d.GMIN = 1.0e-5;
-
-A1 = 1.0;   
-S1 = 1.7^2;
-X1 = [  4.0  8.0  8.0];
-
-A2 = 0.8;   
-S2 = 3.0^2;
-X2 = [ 16.0 12.0 12.0];
-
-GMIN = 1.0e-5;
-
-
-
-d.s = zeros(d.ml);
-for i = 1:d.ml(1)
-  for j = 1:d.ml(2)
-    for k = 1:d.ml(3)
-      x = d.xmin + (d.start + [i-2 j-2 k-2] ) .* d.dx;
-      s = A1 * prod( exp( -(X1-x).^2 / S1 )  ) + ...
-          A2 * prod( exp( -(X2-x).^2 / S2 )  ) ;
-      if s < GMIN
-        s = 0.0;
-      end
-      d.s(i,j,k) = s;
-    end
-  end
-end
-
-% ===========================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-
-% Do all inter-process communication
-% After this, data.yext contains all data needed for Finite Differences
-data = rhsfn_comm(y, data);
-
-% Compute right-hand side locally
-[yd, flag, new_data] = rhsfn_local(t, y, data);
-
-new_data = data;
-
-%=================================================================
-
-function [data] = rhsfn_comm(y, data)
-%rhsfn_comm loads the local extended 3D solution matrix, by:
-%   a) using the local solution in the interior of the local grid
-%   b) communicating with neighbouring processes to obtain solution
-%      on the internal boundaries
-%   c) setting 0-flux B.C. on the external boundaries.
-
-ml = data.ml;
-comm = data.comm;
-myId = data.myId;
-left = data.left;
-right = data.right;
-
-% Reshape local solution into a cube
-c = reshape(y,ml);
-
-% Load local solution into extended matrix
-data.yext(2:end-1,2:end-1,2:end-1) = c;
-
-% Internal boundaries: loop over each dimension and exchange data.
-%    The processor with lower ID always sends first.
-% External boundaries: impose homogeneous Neumann B.C.
-
-for dim = 1:3
-
-  N = prod(ml)/ml(dim);     % dimension of communication buffers
-
-% to the left
-
-  nbr = left(dim);                                 % left neighbour
-
-  bufS = reshape( get_slice(c,dim,1), N, 1);       % send buffer
-  bufR = zeros(N, 1);                              % receive buffer
-
-  if nbr == myId  % external BC
-    data.yext = set_slice(data.yext,dim,1,bufS);
-  else            % internal BC
-    if myId < nbr
-%      fprintf('  left send/recv  %d  N = %d\n',nbr,N);
-      info = MPI_Send(bufS, nbr, 0, comm);
-      if info ~= 0
-        fprintf('Send to left: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-      [info, stat] = MPI_Recv(bufR, nbr, 0, comm);
-      if info ~= 0
-        fprintf('Receive from left: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-    else
-%      fprintf('  left recv/send  %d  N = %d\n',nbr,N);
-      [info, stat] = MPI_Recv(bufR, nbr, 0, comm);      
-      if info ~= 0
-        fprintf('Receive from left: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-      info = MPI_Send(bufS, nbr, 0, comm);
-      if info ~= 0
-        fprintf('Send to left: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-    end
-    data.yext = set_slice(data.yext,dim,1,bufR);
-  end
-  
-% to the right
-
-  nbr = right(dim);                                % right neighbour
-
-  bufS = reshape( get_slice(c,dim,ml(dim)), N, 1); % send buffer
-  bufR = zeros(N, 1);                              % receive buffer
-
-  if nbr == myId  % external BC
-    data.yext = set_slice(data.yext,dim,ml(dim)+2,bufS);
-  else            % internal BC
-    if myId < nbr
-%      fprintf('  right send/recv  %d  N = %d\n',nbr,N);
-      info = MPI_Send(bufS, nbr, 0, comm);
-      if info ~= 0
-        fprintf('Send to right: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-      [info, stat] = MPI_Recv(bufR, nbr, 0, comm);
-      if info ~= 0
-        fprintf('Receive from right: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-    else
-%      fprintf('  right recv/send  %d  N = %d\n',nbr,N);
-      [info, stat] = MPI_Recv(bufR, nbr, 0, comm);      
-      if info ~= 0
-        fprintf('Receive from right: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-      info = MPI_Send(bufS, nbr, 0, comm);
-      if info ~= 0
-        fprintf('Send to right: myId %d  nbr %d  info %d',myId,nbr,info); 
-        MPI_Abort(comm, 0);
-      end
-    end
-    data.yext = set_slice(data.yext,dim,ml(dim)+2,bufR);
-  end
-  
-  
-end
-
-function b = get_slice(a, dim, indx)
-%get_slice extracts from the 3D matrix A, the 2D matrix slice B at 
-%  index INDX in the dimension DIM
-
-switch dim
- case 1
-  b = a(indx,:,:);
- case 2
-  b = a(:,indx,:);
- case 3
-  b = a(:,:,indx);
-end
-
-function a = set_slice(a, dim, indx, b)
-%set_slice loads the 2D matrix B at index INDX in the dimension DIM 
-%  into the 3D matrix A. A has 2 more components than B in each 
-%  dimension
-
-[nr, nc] = size(b);   % number of rows and columns in B
-
-switch dim
- case 1
-  nr = size(a,2)-2;
-  nc = size(a,3)-2;
-  a(indx,2:end-1,2:end-1) = reshape(b,nr,nc);
- case 2
-  nr = size(a,1)-2;
-  nc = size(a,3)-2;
-  a(2:end-1,indx,2:end-1) = reshape(b,nr,nc);
- case 3
-  nr = size(a,1)-2;
-  nc = size(a,2)-2;
-  a(2:end-1,2:end-1,indx) = reshape(b,nr,nc);
-end
-
-% ===========================================================
-
-function [yd, flag, new_data] = rhsfn_local(t, y, data)
-%rhsfn_local - local RHS computation
-
-xmin  = data.xmin;
-ml    = data.ml;
-start = data.start;
-dx    = data.dx;
-Dc    = data.Dc;
-yext  = data.yext;
-
-for i = 2:ml(1)+1
-  for j = 2:ml(2)+1
-    for k = 2:ml(3)+1
-
-      x = xmin + (start + [i-2 j-2 k-2] ) .* dx;
-      v = velocity(x, data);
-      s = source(x,data);
-
-      [c, cl, cr] = stencil(yext,i,j,k);
-
-      adv = v .* (cr-cl) ./ (2.0*dx);
-      dif = Dc * (cr - 2.0*c + cl) / dx.^2;
-    
-      yd(i-1,j-1,k-1) = s + sum(dif-adv);
-      
-    end
-  end
-end
-
-yd = reshape(yd,prod(ml),1);
-
-flag = 0;
-new_data = [];
-
-
-function [c,cl,cr] = stencil(yext,i,j,k)
-
-c = yext(i,j,k) * ones(1,3);
-cl(1) = yext(i-1,j,  k  ); cr(1) = yext(i+1,j,  k  );
-cl(2) = yext(i,  j-1,k  ); cr(2) = yext(i,  j+1,k  );
-cl(3) = yext(i,  j,  k-1); cr(3) = yext(i,  j,  k+1); 
-
-
-function v = velocity(x, data)
-
-L = data.L;
-Vc = data.Vc;
-xmin = data.xmin;
-
-y = x(2) - xmin(2) - L;
-
-v(1) = Vc * (L+y) * (L-y);
-v(2) = 0.0;
-v(3) = 0.0;
-
-
-function s = source(x, data)
-
-A1 = data.A1;  A2 = data.A2;
-S1 = data.S1;  S2 = data.S2;
-X1 = data.X1;  X2 = data.X2;
-Y1 = data.Y1;  Y2 = data.Y2;
-Z1 = data.Z1;  Z2 = data.Z2;
-
-s1 = A1 * exp(-(X1-x(1))^2/S1) * exp(-(Y1-x(2))^2/S1) * exp(-(Z1-x(3))^2/S1);
-s2 = A2 * exp(-(X2-x(1))^2/S2) * exp(-(Y2-x(2))^2/S2) * exp(-(Z2-x(3))^2/S2);
-
-s = s1 + s2;
-
-if s < data.GMIN
-  s = 0.0;
-end
diff --git a/sundialsTB/cvodes/examples_par/mcvsDecoupl_non_p.m b/sundialsTB/cvodes/examples_par/mcvsDecoupl_non_p.m
deleted file mode 100644
index 63834be..0000000
--- a/sundialsTB/cvodes/examples_par/mcvsDecoupl_non_p.m
+++ /dev/null
@@ -1,91 +0,0 @@
-function [] = mcvsDecoupl_non_p(comm)
-%mcvsDecoupl_non_p - CVODES example problem
-%   (parallel, Adams, Functional)
-%   This is a simple test for the CVODES solver. It solves a
-%   set of decoupled ODEs.
-%   
-%   See also: mpirun
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:47 $
-
-[status npes] = MPI_Comm_size(comm);
-[status mype] = MPI_Comm_rank(comm);
-
-nlocal = 20;
-neq = npes * nlocal;
-
-alpha = 10.0/neq;
-
-data.alpha = alpha;
-data.comm = comm;
-data.nlocal = nlocal;
-data.mype = mype;
-
-t0 = 0.0;
-for i = 1:nlocal
-  y0(i,1) = 1.0;
-end
-
-rtol = 1.0e-5;
-atol = 1.0e-10;
-
-fprintf('\nPVNX example problem\n\n');
-fprintf('  Processor %d/%d\n',mype,npes);
-fprintf('  Global problem size: %d\n',neq);
-fprintf('  Local problem size:  %d\n\n',nlocal);
-if mype == 0
-  fprintf('  alpha = %f\n',alpha);
-  fprintf('  rtol = %e  atol = %e\n\n',rtol,atol);
-end
-
-options = CVodeSetOptions('Reltol',rtol,'AbsTol',atol);
-
-mondata = struct;
-
-if mype == 0
-  mondata.mode = 'both';
-  mondata.sol = true;
-else
-%  mondata.post = false;
-  mondata.sol = true;
-  mondata.cntr = false;
-  mondata.stats = false;
-end
-options = CVodeSetOptions(options,...
-                          'MonitorFn','CVodeMonitor',...
-                          'MonitorData',mondata);
-
-CVodeInit(@rhsfn,'Adams','Functional',t0,y0,options,data);
-
-nout = 10;
-dtout = 0.1;
-tout = dtout;
-for i = 1:nout
-  [status,t,y] = CVode(tout,'Normal');
-  if mype == 0
-    si = CVodeGetStats;
-    fprintf('t = %f  nst = %d  nfe = %d\n',t,si.nst,si.nfe);
-  end
-  tout = tout + dtout;
-end
-
-CVodeFree;
-
-%
-%---------------------------------------------------------
-%
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-
-alpha  = data.alpha;
-nlocal = data.nlocal;
-mype   = data.mype;
-
-for i = 1:nlocal
-  yd(i) = -alpha * (mype*nlocal + i) * y(i);
-end
-
-flag = 0;
-new_data = [];
diff --git a/sundialsTB/cvodes/examples_ser/mcvsAdvDiff_bnd.m b/sundialsTB/cvodes/examples_ser/mcvsAdvDiff_bnd.m
deleted file mode 100644
index 923ba72..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsAdvDiff_bnd.m
+++ /dev/null
@@ -1,243 +0,0 @@
-function mcvsAdvDiff_bnd()
-%mcvsAdvDiff_bnd - CVODES example problem (serial, band)
-%   The following is a simple example problem with a banded Jacobian,
-%   with the program for its solution by CVODES.
-%   The problem is the semi-discrete form of the advection-diffusion
-%   equation in 2-D:
-%      du/dt = d^2 u / dx^2 + .5 du/dx + d^2 u / dy^2
-%   on the rectangle 0 <= x <= 2, 0 <= y <= 1, and the time
-%   interval 0 <= t <= 1. Homogeneous Dirichlet boundary conditions
-%   are posed, and the initial condition is
-%      u(x,y,t=0) = x(2-x)y(1-y)exp(5xy).
-%   The PDE is discretized on a uniform MX+2 by MY+2 grid with
-%   central differencing, and with boundary values eliminated,
-%   leaving an ODE system of size NEQ = MX*MY.
-%   This program solves the problem with the BDF method, Newton
-%   iteration with the CVBAND band linear solver, and a user-supplied
-%   Jacobian routine.
-%   It uses scalar relative and absolute tolerances.
-%   Output is printed at t = .1, .2, ..., 1.
-%   Run statistics (optional outputs) are printed at the end.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:47 $
-
-xmax = 2.0;
-ymax = 1.0;
-mx = 10;
-my = 5;
-
-rtol = 0.0;
-atol = 1.0e-5;
-
-t0 = 0.0;
-dtout = 0.1;
-nout = 6;
-
-dx = xmax/(mx+1);
-dy =  ymax/(my+1);
-
-% Problem data structure
-data.xmax = xmax;
-data.ymax = ymax;
-data.mx = mx;
-data.my = my;
-data.dx = dx;
-data.dy = dy;
-data.hdcoef = 1.0/dx^2;
-data.hacoef = 0.5/(2.0*dx);
-data.vdcoef = 1.0/dy^2;
-
-% Options for integration
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',rtol,...
-                          'AbsTol',atol,...
-                          'LinearSolver','Band',...
-                          'JacobianFn', at bjacfn,...
-                          'UpperBwidth',my,...
-                          'LowerBwidth',my);
-
-mondata.grph = false;
-options = CVodeSetOptions(options,...
-                          'MonitorFn', at CVodeMonitor,...
-                          'MonitorData',mondata);
-
-% Initial conditions for states
-t = t0;
-u = zeros(mx*my,1);
-for j = 1:my
-  y = j * data.dy;
-  for i = 1:mx
-    x = i * data.dx;
-    u(j + (i-1)*my) = x*(xmax-x)*y*(ymax-y)*exp(5.0*x*y);
-  end
-end
-
-% Initialize integrator
-CVodeInit(@rhsfn, 'BDF', 'Newton', t, u, options);
-
-% Initialize quadratures (with default optional inputs)
-q = 0.0;
-CVodeQuadInit(@quadfn, q);
-
-
-ff=figure;
-hold on;
-box
-
-umax = norm(u,'inf');
-uavg = quadfn(t,u,data);
-fprintf('At t = %f   max.norm(u) = %e\n',t, umax);
-
-for i = 1:nout
-
-  t_old = t;
-  uavg_old = uavg;
-
-  tout = t + dtout;
-  [status,t,u, q] = CVode(tout, 'Normal');
-
-  if status ~= 0
-    return
-  end
-  
-  uavg = quadfn(t,u,data);
-  umax = norm(u,'inf');
-  fprintf('At t = %f   max.norm(u) = %e\n',tout, umax);
-
-  figure(ff);
-  plot([t_old t],[uavg_old uavg]);
-  plot([t0 tout], [q q]/(tout-t0), 'r-');
-  plot([tout tout], [0 q]/(tout-t0), 'r-');
-  
-end
-  
-si= CVodeGetStats
-
-CVodeFree;
-
-return
-
-% ===========================================================================
-
-function [ud, flag, new_data] = rhsfn(t, u, data)
-% Right-hand side function
-
-mx = data.mx;
-my = data.my;
-hordc = data.hdcoef;
-horac = data.hacoef;
-verdc = data.vdcoef;
-
-for j = 1:my
-  for i = 1:mx
-    uij = u(j+(i-1)*my);
-    if j == 1
-      udn = 0.0;
-    else
-      udn = u(j-1+(i-1)*my);
-    end
-    if j == my
-      uup = 0.0;
-    else
-      uup = u(j+1+(i-1)*my);
-    end
-    if i == 1
-      ult = 0.0;
-    else
-      ult = u(j+(i-2)*my);
-    end
-    if i == mx
-      urt = 0.0;
-    else
-      urt = u(j+i*my);
-    end
-    
-    hdiff = hordc * (ult - 2*uij + urt);
-    hadv = horac * (urt - ult);
-    vdiff = verdc * (uup - 2*uij + udn);
-    ud(j+(i-1)*my) = hdiff + hadv + vdiff;
-  end
-end
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [qd, flag, new_data] = quadfn(t, u, data)
-% Quadrature integrand function
-
-mx = data.mx;
-my = data.my;
-dx = data.dx;
-dy = data.dy;
-xmax = data.xmax;
-ymax = data.ymax;
-
-qd1 = 0.0;
-for j = 1:my
-  for i = 1:mx
-    uij = u(j+(i-1)*my);
-    if j == 1 | j == mx
-      del_y = dy/2;
-    else
-      del_y = dy;
-    end
-    if i == 1 | i == mx
-      del_x = dx/2;
-    else
-      del_x = dx;
-    end
-    qd1 = qd1 + uij * del_x*del_y;
-  end
-end
-
-qd1 = qd1 / (xmax*ymax);
-
-qd(1) = qd1;
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [J, flag, new_data] = bjacfn(t, y, fy, data)
-% Band Jacobian function
-
-mx = data.mx;
-my = data.my;
-hordc = data.hdcoef;
-horac = data.hacoef;
-verdc = data.vdcoef;
-
-mu = my;
-ml = my;
-mband = mu + 1 + ml;
-
-for i = 1:mx
-  for j = 1:my
-     k = j + (i-1)*my;
-     J(mu+1,k) = -2.0 * (verdc + hordc);
-     if  i ~= 1
-       J(1,k) = hordc + horac;
-     end
-     if i ~= mx
-       J(mband,k) = hordc - horac;
-     end
-     if j ~= 1
-       J(mu,k) = verdc;
-     end
-     if j ~= my
-       J(mu+2,k) = verdc;
-     end
-  end
-end
-
-flag = 0;
-new_data = [];
diff --git a/sundialsTB/cvodes/examples_ser/mcvsDiscRHS_dns.m b/sundialsTB/cvodes/examples_ser/mcvsDiscRHS_dns.m
deleted file mode 100644
index fc7bda9..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsDiscRHS_dns.m
+++ /dev/null
@@ -1,150 +0,0 @@
-function mcvsDiscRHS_dns()
-%mcvsDiscRHS_dns - CVODES example with RHS discontinuity
-%  Trivial CVODES example to illustrate the proper 
-%  way to integrate over a discontinuity in the RHS: 
-%       y' = -y   ; y(0) = 1    ; t = [0,1]
-%       z' = -5*z ; z(1) = y(1) ; t = [1,2]
-%  The problem is solved twice, first by explicitly treating the 
-%  discontinuity point and secondly by letting the integrator 
-%  deal with the discontinuity.
-
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $
-
-t0 = 0.0;
-t1 = 1.0;
-t2 = 2.0;
-
-y0 = 1.0;
-
-% ---------------------------------------------------------------
-% Discontinuity in RHS: Case 1 - let CVODES deal with it.
-% ---------------------------------------------------------------
-
-data.tdisc = t1;
-
-% Initialize solver
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-3,...
-                          'AbsTol',1.e-4,...
-                          'LinearSolver','Dense');
-CVodeInit(@rhsfn1, 'BDF', 'Newton', t0, y0, options);
-
-% Integrate over the point of discontinuity
-t = t0;
-i = 1;
-tt1(1) = t0; yy1(1) = y0;
-while t < t2
-  [status, t, y] = CVode(t2,'OneStep');
-  i = i+1;
-  tt1(i) = t;
-  yy1(i) = y;
-end
-
-% Free memory
-CVodeFree;
-
-% -------------------------------------------------------------
-% Discontinuity in RHS: Case 1 - explicit treatment
-% Note that, since we set tstop at the point of discontinuity,
-% we could simply use the exact same RHS function as before. 
-% However, we chose to use a flag set in the user data (to also
-% illustrate the use of CVodeSet).
-% -------------------------------------------------------------
-
-% Initialize solver (data.flag = 1)
-
-data.flag = 1;
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-3,...
-                          'AbsTol',1.e-4,...
-                          'StopTime',t1,...
-                          'LinearSolver','Dense');
-CVodeInit(@rhsfn2, 'BDF', 'Newton', t0, y0, options);
-
-% Integrate to the point of discontinuity
-t = t0;
-i = 1;
-tt2(1) = t0; yy2(1) = y0;
-while t < t2
-  [status, t, y] = CVode(t2,'OneStep');
-  i = i+1;
-  tt2(i) = t;
-  yy2(i) = y;
-  if status == 1
-    % Once tstop is reached, flag a change in RHS
-    data.flag = 2;
-    CVodeSet('UserData',data);
-  end
-end
-
-% Free memory
-CVodeFree;
-
-
-% Plot the two solutions
-
-figure
-
-subplot(2,1,1)
-hold on
-plot(tt1,yy1);
-plot(tt2,yy2,'r');
-legend('Integrate over discontinuity','Stop at discontinuity');
-title('Discontinuity in RHS');
-xlabel('time');
-ylabel('y');
-box on
-
-subplot(2,1,2)
-hold on
-plot(tt1,yy1,'b',tt1,yy1,'b.');
-plot(tt2,yy2,'r',tt2,yy2,'r.');
-set(gca,'XLim',[0.99 1.01],'YLim',[0.36 0.37]);
-legend('Integrate over discontinuity','Stop at discontinuity');
-title('Zoom on discontinuity');
-xlabel('time');
-ylabel('y');
-grid on
-box on
-
-return
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn1(t, y, data)
-% Right-hand side function for case 1
-
-
-if t <= data.tdisc
-  yd(1) = -y(1);
-else  
-  yd(1) = -5*y(1);
-end
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-
-function [yd, flag, new_data] = rhsfn2(t, y, data)
-% Right-hand side function for case 2
-
-if data.flag == 1
-  yd(1) = -y(1);
-else  
-  yd(1) = -5*y(1);
-end
-
-flag = 0;
-new_data = [];
-
-return
-
-
diff --git a/sundialsTB/cvodes/examples_ser/mcvsDiscSOL_dns.m b/sundialsTB/cvodes/examples_ser/mcvsDiscSOL_dns.m
deleted file mode 100644
index 194af5c..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsDiscSOL_dns.m
+++ /dev/null
@@ -1,77 +0,0 @@
-function mcvsDiscSOL_dns()
-%mcvsDiscSOL_dns - CVODES example with solution discontinuity
-%  Trivial CVODES example to illustrate the use of
-%  CVodeReInit to integrate over a discontinuity in 
-%  the solution:
-%       y' = -y   ; y(0) = 1    ; t = [0,1]
-%       y' = -y   ; y(1) = 1    ; t = [1,2]
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $
-
-t0 = 0.0;
-t1 = 1.0;
-t2 = 2.0;
-
-% Initialize solver
-y = 1.0;
-options = CVodeSetOptions('RelTol',1.e-3,...
-                          'AbsTol',1.e-4,...
-                          'StopTime',t1,...
-                          'LinearSolver','Dense');
-CVodeInit(@rhsfn,'BDF','Newton',t0,y,options);
-
-% Integrate to the point of discontinuity
-t = t0;
-i = 1;
-tt(i) = t0; yy(i) = y;
-while t < t1
-  [status, t, y] = CVode(t1,'OneStep');
-  i = i+1;
-  tt(i) = t;
-  yy(i) = y;
-end
-
-% Add discontinuity and reinitialize solver
-y = 1.0;
-options = CVodeSetOptions(options,'StopTime',t2);
-CVodeReInit(t1,y,options);
-
-% Integrate from discontinuity to final time
-t = t1;
-i = i+1;
-tt(i) = t1; yy(i) = y;
-while t < t2
-  [status, t, y] = CVode(t2,'OneStep');
-  i = i+1;
-  tt(i) = t;
-  yy(i) = y;
-end
-
-% Plot solution
-figure
-plot(tt,yy)
-title('Discontinuity in solution');
-xlabel('time');
-ylabel('y');
-
-% Free memory
-CVodeFree;
-
-return
-
-% ===========================================================================
-
-function [yd, flag] = rhsfn(t, y)
-% Right-hand side function
-
-yd(1) = -y(1);
-flag = 0;
-
-return
-
-
-
-
diff --git a/sundialsTB/cvodes/examples_ser/mcvsDiurnal_kry.m b/sundialsTB/cvodes/examples_ser/mcvsDiurnal_kry.m
deleted file mode 100644
index ab28620..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsDiurnal_kry.m
+++ /dev/null
@@ -1,388 +0,0 @@
-function [x,y,u0_2, u_2] = mcvsDiurnal_kry
-%mcvsDiurnal_kry - CVODES example problem (serial, Spgmr)
-%   An ODE system is generated from the following 2-species diurnal
-%   kinetics advection-diffusion PDE system in 2 space dimensions:
-%
-%   dc(i)/dt = Kh*(d/dx)^2 c(i) + V*dc(i)/dx + (d/dy)(Kv(y)*dc(i)/dy)
-%                   + Ri(c1,c2,t)      for i = 1,2,   where
-%     R1(c1,c2,t) = -q1*c1*c3 - q2*c1*c2 + 2*q3(t)*c3 + q4(t)*c2 ,
-%     R2(c1,c2,t) =  q1*c1*c3 - q2*c1*c2 - q4(t)*c2 ,
-%     Kv(y) = Kv0*exp(y/5) ,
-%   Kh, V, Kv0, q1, q2, and c3 are constants, and q3(t) and q4(t)
-%   vary diurnally. The problem is posed on the square
-%      0 <= x <= 20,    30 <= y <= 50   (all in km),
-%   with homogeneous Neumann boundary conditions, and for time t in
-%      0 <= t <= 86400 sec (1 day).
-%   The PDE system is treated by central differences on a uniform
-%   10 x 10 mesh, with simple polynomial initial profiles.
-%   The problem is solved with CVODES, with the BDF/GMRES
-%   method (i.e. using the CVSPGMR linear solver) and the
-%   block-diagonal part of the Newton matrix as a left
-%   preconditioner. A copy of the block-diagonal part of the
-%   Jacobian is saved and conditionally reused within the Precond
-%   routine.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:47 $
-
-%------------------------
-% SET USER DATA STRUCTURE
-%------------------------
-
-ns = 2;
-
-mx = 50;
-my = 20;
-
-xmin = 0.0;  xmax = 20.0; xmid = 10.0;
-ymin = 30.0; ymax = 50.0; ymid = 40.0;
-dx = (xmax-xmin)/(mx-1);
-dy = (ymax-ymin)/(my-1);
-
-kh = 4.0e-6;
-vel = 0.001;
-kv0 = 1.0e-8;
-halfday = 4.32e4;
-
-c1s = 1.0e6;
-c2s = 1.0e12;
-
-
-data.ns = ns;
-
-%% Problem constants
-
-data.mx = mx;
-data.xmin = xmin;
-data.xmax = xmax;
-data.xmid = xmid;
-data.dx = dx;
-
-data.my = my;
-data.ymin = ymin;
-data.ymax = ymax;
-data.ymid = ymid;
-data.dy = dy;
-
-data.q1 = 1.63e-16;
-data.q2 = 4.66e-16;
-data.c3 = 3.7e16;
-data.a3 = 22.62;
-data.a4 = 7.601;
-
-data.om = pi/halfday;
-data.hdco = kh/dx^2;
-data.haco = vel/(2*dx);
-data.vdco = kv0/dy^2;
-
-%% Workspace
-
-data.P = [];
-
-%------------------------
-% SET INITIAL PROFILE
-%------------------------
-
-t0 = 0.0;
-
-for jy = 1:my
-  y(jy) = ymin + (jy - 1) * dy;
-end
-for jx = 1:mx
-  x(jx) = xmin + (jx - 1) * dx;
-end
-
-for jy = 1:my
-  cy = (0.1 * (y(jy) - ymid))^2;
-  cy = 1.0 - cy + 0.5 * cy^2;
-  for jx = 1:mx
-    cx = (0.1 * (x(jx) - xmid))^2;
-    cx = 1.0 - cx + 0.5 * cx^2;
-    u0(1,jx,jy) = c1s * cx * cy;
-    u0(2,jx,jy) = c2s * cx * cy;
-  end
-end
-
-u0_2 = squeeze(u0(2,:,:));
-
-u0 = reshape(u0,2*mx*my,1);
-
-
-%------------------------
-% SET CVODES OPTIONS
-%------------------------
-
-% Tolerances
-rtol = 1.0e-5;
-atol = 1.0e-3;
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',rtol, 'AbsTol',atol,...
-                          'LinearSolver','GMRES',...
-                          'PrecType','Left',...
-                          'PrecSetupFn', at psetfn,...
-                          'PrecSolveFn', at psolfn);
-
-%mondata = struct;
-%options = CVodeSetOptions(options,'MonitorFn', at CVodeMonitor,'MonitorData',mondata);
-
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, u0, options);
-
-%------------------------
-% SOLVE PROBLEM
-%------------------------
-
-twohr = 7200.0;
-tout = twohr;
-nout = 12;
-
-for i = 1:nout
-  [status,t,u] = CVode(tout,'Normal');
-  si = CVodeGetStats;
-  u = reshape(u,2,mx,my);
-  fprintf('status = %d   t = %.2e   nst = %d   q = %d   h = %.2e\n',...
-          status, t, si.nst, si.qlast, si.hlast);
-  fprintf('c1 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n',...
-          u(1,1,1), u(1,5,5), u(1,10,10));
-  fprintf('c2 (bot.left/middle/top rt.) = %12.3e  %12.3e  %12.3e\n',...
-          u(2,1,1), u(2,5,5), u(2,10,10));
-  tout = tout + twohr;
-end
-
-u_2 = squeeze(u(2,:,:));
-
-si = CVodeGetStats
-
-%------------------------
-% FREE MEMORY
-%------------------------
-
-CVodeFree;
-
-%------------------------
-% PLOT RESULTS
-%------------------------
-
-figure;
-
-hsurf0 = surf(y,x,u0_2);
-
-set(hsurf0,'Edgecolor','flat','EdgeAlpha',0.6);
-set(hsurf0,'FaceAlpha',0);
-
-hold on
-
-hsurf = surf(y,x,u_2);
-set(hsurf,'FaceColor','interp', 'EdgeColor','none');
-
-title('Initial and final values for species 2');
-xlabel('y');
-ylabel('x');
-colorbar
-box on
-
-return
-
-% ===========================================================================
-
-function [ud, flag, new_data] = rhsfn(t, u, data)
-% Right-hand side function
-
-mx = data.mx;
-xmin = data.xmin;
-dx = data.dx;
-
-my = data.my;
-ymin = data.ymin;
-dy = data.dy;
-
-om = data.om;
-q1 = data.q1;
-q2 = data.q2;
-c3 = data.c3;
-a3 = data.a3;
-a4 = data.a4;
-hdco = data.hdco;
-haco = data.haco;
-vdco = data.vdco;
-
-s = sin(om*t);
-if s > 0.0
-  q3 = exp(-a3/s);
-  q4 = exp(-a4/s);
-else
-  q3 = 0.0;
-  q4 = 0.0;
-end
-
-u = reshape(u, 2,mx*my);
-
-for jy = 1:my
-  ydn = ymin + (jy - 1.5)*dy;
-  yup = ydn + dy;
-  cydn = vdco * exp(0.2*ydn);
-  cyup = vdco * exp(0.2*yup);
-  i = (jy-1)*mx;
-  idn = -mx;
-  if jy == 1
-    idn = mx;
-  end
-  iup = mx;
-  if jy == my
-    iup = -mx;
-  end
-  for jx = 1:mx
-    ii = i + jx;
-    c1 = u(1,ii);
-    c2 = u(2,ii);
-    % kinetic rate terms
-    qq1 = q1 * c1 * c3;
-    qq2 = q2 * c1 * c2;
-    qq3 = q3 * c3;
-    qq4 = q4 *c2;
-    rkin1 = -qq1 - qq2 + 2.0*qq3 + qq4;
-    rkin2 = qq1 - qq2 - qq4;
-    % vertical diffusion
-    c1dn = u(1,ii+idn);
-    c2dn = u(2,ii+idn);
-    c1up = u(1,ii+iup);
-    c2up = u(2,ii+iup);
-    vertd1 = cyup*(c1up - c1) - cydn*(c1 - c1dn);
-    vertd2 = cyup*(c2up - c2) - cydn*(c2 - c2dn);
-    % horizontal diffusion and advection
-    ileft = -1;
-    if jx == 1
-      ileft = 1;
-    end
-    iright = 1;
-    if jx == mx
-      iright = -1;
-    end
-    c1lt = u(1,ii+ileft);
-    c2lt = u(2,ii+ileft);
-    c1rt = u(1,ii+iright);
-    c2rt = u(2,ii+iright);
-    hord1 = hdco * (c1rt-2.0*c1+c1lt);
-    hord2 = hdco * (c2rt-2.0*c2+c2lt);
-    horad1 = haco * (c1rt-c1lt);
-    horad2 = haco * (c2rt-c2lt);
-    % load into ud
-    ud(1,ii) = vertd1 + hord1 + horad1 + rkin1; 
-    ud(2,ii) = vertd2 + hord2 + horad2 + rkin2;
-  end
-  
-end
-
-ud = reshape(ud,2*mx*my,1);
-
-flag = 0;
-new_data = [];
-
-new_data = data;
-
-return
-
-% ===========================================================================
-
-function [jcur, flag, data] = psetfn(t,u,fu,jok,gm,data)
-% Preconditioner setup function
-
-persistent Jbd
-
-mx = data.mx;
-my = data.my;
-
-if jok
-
-  % Copy Jbd to P
-  
-  P = Jbd;
-  jcur = false;
-  
-else
-
-  % Generate Jbd from scratch and copy to P
-
-  xmin = data.xmin;
-  dx = data.dx;
-
-  ymin = data.ymin;
-  dy = data.dy;
-
-  om = data.om;
-  q1 = data.q1;
-  q2 = data.q2;
-  c3 = data.c3;
-  a3 = data.a3;
-  a4 = data.a4;
-  hdco = data.hdco;
-  haco = data.haco;
-  vdco = data.vdco;
-  
-  s = sin(om*t);
-  if s > 0.0
-    q4 = exp(-a4/s);
-  else
-    q4 = 0.0;
-  end
-
-  u = reshape(u,2,mx*my);
-  
-  for jy = 1:my
-    ydn = ymin + (jy - 1.5)*dy;
-    yup = ydn + dy;
-    cydn = vdco * exp(0.2*ydn);
-    cyup = vdco * exp(0.2*yup);
-    diag = -(cydn + cyup + 2.0*hdco);
-    i = (jy-1)*mx;
-    for jx = 1:mx
-      ii = i + jx;
-      c1 = u(1,ii);
-      c2 = u(2,ii);
-      Jbd(1,1,ii) = (-q1*c3 - q2*c2) + diag;
-      Jbd(1,2,ii) = -q2*c1 + q4;
-      Jbd(2,1,ii) = q1*c3 - q2*c2;
-      Jbd(2,2,ii) = (-q2*c1 - q4) + diag;
-    end
-  end
-  
-  P = Jbd;
-  jcur = true;
-
-end
-
-% Scale by -gamma and add identity
-P = - gm*P;
-for i = 1:mx*my
-  P(:,:,i) = eye(2) + P(:,:,i);
-end
-
-flag = 0;
-data.P = P;
-
-
-return
-
-% ===========================================================================
-
-function [z, flag, new_data] = psolfn(t,y,fy,r,data)
-% Preconditioner solve function
-
-P = data.P;
- 
-mx = data.mx;
-my = data.my;
-
-r = reshape(r,2,mx*my);
-
-for i = 1:mx*my
-  z(:,i) = P(:,:,i)^(-1)*r(:,i);
-end
-
-z = reshape(z,2*mx*my,1);
-
-flag = 0;
-new_data = [];
-
-return
\ No newline at end of file
diff --git a/sundialsTB/cvodes/examples_ser/mcvsHessian_FSA_ASA.m b/sundialsTB/cvodes/examples_ser/mcvsHessian_FSA_ASA.m
deleted file mode 100644
index a693d6b..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsHessian_FSA_ASA.m
+++ /dev/null
@@ -1,349 +0,0 @@
-function mcvsHessian_FSA_ASA
-%mcvsHessian_FSA_ASA - CVODES Hessian calculation example (FSA over ASA)
-%  The following is a simple example illustrating the use
-%  of simultaneous FSA and ASA computations in order to 
-%  evaluate the Hessian of a functional depending on the
-%  ODE solution. 
-%
-%  The forward problem consists of the following 3 equations
-%
-%    dy1/dt = - p1 * y1^2 - y3;
-%    dy2/dt = - y2;
-%    dy3/dt = - p2^2 * y2 * y3;
-%
-%  depending on the parameters p1 = 1.0 and p2 = 2.0.
-%
-%  The initial conditions are y1(0) = y2(0) = y390) = 1.0
-%
-%  The functional considered is
-%
-%           2
-%          /
-%   G(p) = |  0.5 * ( y1^2 + y2^2 + y3^2 ) dt
-%          /
-%          0
-%  
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:47 $
-
-
-
-Neq = 3;
-Np  = 2;
-
-t0 = 0.0;
-tf = 2.0;
-
-% ----------------------------------------
-% User data structure
-% ----------------------------------------
-
-data.p = [1.0 2.0];
-
-% ----------------------------------------
-% Forward CVODES options
-% ----------------------------------------
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-8,...
-                          'AbsTol',1.0e-8,...
-                          'LinearSolver','Dense');
-
-optionsQ = CVodeQuadSetOptions('ErrControl',true,...
-                               'RelTol',1.e-8,'AbsTol',1.e-8);
-
-optionsS = CVodeSensSetOptions('method','Simultaneous',...
-                               'ErrControl', true,...
-                               'ParamScales', [1.0; 2.0]);
-
-y0 = ones(Neq,1);
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, y0, options);
-
-q0 = 0.0;
-CVodeQuadInit(@rhsQfn, q0, optionsQ);
-
-s0 = zeros(Neq,Np);
-CVodeSensInit(Np, @rhsSfn, s0, optionsS);
-
-% ----------------------------------------
-% Initialize ASA
-% ----------------------------------------
-
-CVodeAdjInit(100, 'Polynomial');
-
-% ----------------------------------------
-% Forward integration
-% ----------------------------------------
-
-fprintf('\nForward integration ');
-
-[status, tret, y, q, yS] = CVode(tf,'Normal');
-s = CVodeGetStats;
-
-fprintf('(%d steps)\n', s.nst);
-fprintf('G = %12.4e\n', q);
-
-% ----------------------------------------
-% Backward CVODES options
-% ----------------------------------------
-
-optionsB = CVodeSetOptions('UserData',data,...
-                           'RelTol',1.e-8,...
-                           'AbsTol',1.e-8,...
-                           'LinearSolver','Dense',...
-                           'SensDependent', true);
-
-optionsQB = CVodeQuadSetOptions('ErrControl',true,...
-                                'RelTol',1.e-8,'AbsTol',1.e-8,...
-                                'SensDependent', true);
-
-
-yB1 = zeros(2*Neq,1);
-idxB1 = CVodeInitB(@rhsB1fn, 'BDF', 'Newton', tf, yB1, optionsB);
-
-qB1 = zeros(2*Np,1);
-CVodeQuadInitB(idxB1, @rhsQB1fn, qB1, optionsQB);
-
-
-yB2 = zeros(2*Neq,1);
-idxB2 = CVodeInitB(@rhsB2fn, 'BDF', 'Newton', tf, yB2, optionsB);
-
-qB2 = zeros(2*Np,1);
-CVodeQuadInitB(idxB2, @rhsQB2fn, qB2, optionsQB);
-
-% ----------------------------------------
-% Backward integration
-% ----------------------------------------
-
-fprintf('\nBackward integration ');
-
-[status, tretB, yB, qB] = CVodeB(t0,'Normal');
-sB1 = CVodeGetStatsB(idxB1);
-sB2 = CVodeGetStatsB(idxB2);
-
-fprintf('(%d steps pb1) (%d steps pb2)\n',sB1.nst, sB2.nst);
-
-qB1 = -qB{idxB1};
-qB2 = -qB{idxB2};
-
-fprintf('Gradient\n');
-fprintf('  %12.4e  %12.4e  (from backward pb. 1)\n',qB1(1:2));
-fprintf('  %12.4e  %12.4e  (from backward pb. 2)\n',qB2(1:2));
-
-fprintf('Hessian\n');
-fprintf('  %12.4e  %12.4e\n',qB1(3), qB2(3));
-fprintf('  %12.4e  %12.4e\n',qB1(4), qB2(4));
-
-% ----------------------------------------
-% Free memory
-% ----------------------------------------
-
-CVodeFree;
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-p1 = data.p(1);
-p2 = data.p(2);
-
-yd(1) = - p1 * y(1)^2 - y(3);
-yd(2) = - y(2);
-yd(3) = - p2^2 * y(2) * y(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [qd, flag, new_data] = rhsQfn(t, y, data)
-% Forward quadrature integrand function
-
-qd = 0.5 * ( y(1)^2 + y(2)^2 + y(3)^2 );
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [ySd, flag, new_data] = rhsSfn(t,y,yd,yS,data)
-% Sensitivity right-hand side function
-
-p1 = data.p(1);
-p2 = data.p(2);
-
-s = yS(:,1);
-
-fys1 = - 2.0*p1*y(1) * s(1) - s(3);
-fys2 = - s(2);
-fys3 = - p2*p2*y(3) * s(2) - p2*p2*y(2) * s(3);
-
-ySd(1,1) = fys1 - y(1)*y(1);
-ySd(2,1) = fys2;
-ySd(3,1) = fys3;
-
-s = yS(:,2);
-
-fys1 = - 2.0*p1*y(1) * s(1) - s(3);
-fys2 = - s(2);
-fys3 = - p2*p2*y(3) * s(2) - p2*p2*y(2) * s(3);
-
-ySd(1,2) = fys1;
-ySd(2,2) = fys2;
-ySd(3,2) = fys3 - 2.0*p2*y(2)*y(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [yBd, flag, new_data] = rhsB1fn(t, y, yS, yB, data)
-% Backward problem right-hand side function for 1st Hessian column
-
-p1 = data.p(1);
-p2 = data.p(2);
-
-y1 = y(1);
-y2 = y(2);
-y3 = y(3);
-
-s1 = yS(1,1);
-s2 = yS(2,1);
-s3 = yS(3,1);
-
-l1 = yB(1);
-l2 = yB(2);
-l3 = yB(3);
-
-m1 = yB(4);
-m2 = yB(5);
-m3 = yB(6);
-
-yBd(1) = 2.0*p1*y1 * l1     - y1;
-yBd(2) = l2 + p2*p2*y3 * l3 - y2;
-yBd(3) = l1 + p2*p2*y2 * l3 - y3;
-
-yBd(4) = 2.0*p1*y1 * m1     + l1 * 2.0*(y1 + p1*s1) - s1;
-yBd(5) = m2 + p2*p2*y3 * m3 + l3 * p2*p2*s3         - s2;
-yBd(6) = m1 + p2*p2*y2 * m3 + l3 * p2*p2*s2         - s3;
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [yBd, flag, new_data] = rhsB2fn(t, y, yS, yB, data)
-% Backward problem right-hand side function 2nd Hessian column
- 
-p1 = data.p(1);
-p2 = data.p(2);
-
-y1 = y(1);
-y2 = y(2);
-y3 = y(3);
-
-s1 = yS(1,2);
-s2 = yS(2,2);
-s3 = yS(3,2);
-
-l1 = yB(1);
-l2 = yB(2);
-l3 = yB(3);
-
-m1 = yB(4);
-m2 = yB(5);
-m3 = yB(6);
-
-yBd(1) = 2.0*p1*y1 * l1     - y1;
-yBd(2) = l2 + p2*p2*y3 * l3 - y2;
-yBd(3) = l1 + p2*p2*y2 * l3 - y3;
-
-yBd(4) = 2.0*p1*y1 * m1     + l1 * 2.0*p1*s1              - s1;
-yBd(5) = m2 + p2*p2*y3 * m3 + l3 * (2.0*p2*y3 + p2*p2*s3) - s2;
-yBd(6) = m1 + p2*p2*y2 * m3 + l3 * (2.0*p2*y3 + p2*p2*s2) - s3;
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [qBd, flag, new_data] = rhsQB1fn(t, y, yS, yB, data)
-% Backward problem quadrature integrand function for 1st Hessian column
-
-p1 = data.p(1);
-p2 = data.p(2);
-
-y1 = y(1);
-y2 = y(2);
-y3 = y(3);
-
-s1 = yS(1,1);
-s2 = yS(2,1);
-s3 = yS(3,1);
-
-l1 = yB(1);
-l2 = yB(2);
-l3 = yB(3);
-
-m1 = yB(4);
-m2 = yB(5);
-m3 = yB(6);
-
-qBd(1) = -y1*y1 * l1;
-qBd(2) = -2.0*p2*y2*y3 * l3;
-
-qBd(3) = -y1*y1 * m1        - l1 * 2.0*y1*s1;
-qBd(4) = -2.0*p2*y2*y3 * m3 - l3 * 2.0*(p2*y3*s2 + p2*y2*s3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [qBd, flag, new_data] = rhsQB2fn(t, y, yS, yB, data)
-% Backward problem quadrature integrand function for 2nd Hessian column
-
-p1 = data.p(1);
-p2 = data.p(2);
-
-y1 = y(1);
-y2 = y(2);
-y3 = y(3);
-
-s1 = yS(1,2);
-s2 = yS(2,2);
-s3 = yS(3,2);
-
-l1 = yB(1);
-l2 = yB(2);
-l3 = yB(3);
-
-m1 = yB(4);
-m2 = yB(5);
-m3 = yB(6);
-
-qBd(1) = -y1*y1 * l1;
-qBd(2) = -2.0*p2*y2*y3 * l3;
-
-qBd(3) = -y1*y1 * m1        - l1 * 2.0*y1*s1;
-qBd(4) = -2.0*p2*y2*y3 * m3 - l3 * 2.0*(p2*y3*s2 + p2*y2*s3 + y2*y3);
-
-flag = 0;
-new_data = [];
-
-return
\ No newline at end of file
diff --git a/sundialsTB/cvodes/examples_ser/mcvsOzone_FSA_dns.m b/sundialsTB/cvodes/examples_ser/mcvsOzone_FSA_dns.m
deleted file mode 100644
index f9fd544..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsOzone_FSA_dns.m
+++ /dev/null
@@ -1,143 +0,0 @@
-function mcvsOzone_FSA_dns()
-%mcvsOzone_FSA_dns - CVODES example problem (serial, dense)
-%        ozone depletion chemical mechanism (3 species)
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-
-% -------------------
-% User data structure
-% -------------------
-
-data.p = [1.63e-16 ; 4.66e-16 ; 5.00e-11 ; 2.50e-4];
-
-% ---------------------
-% CVODES initialization
-% ---------------------
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-4,...
-                          'AbsTol',1.e-8,...
-                          'LinearSolver','Dense');
-
-t0 = 0.0;
-y0 = [1.0e6 ; 1.0e12 ; 3.7e16];
-
-
-
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, y0, options);
-
-
-% ------------------
-% FSA initialization
-% ------------------
-
-Ns = 4;
-yS0 = zeros(3,Ns);
-
-FSAoptions = CVodeSensSetOptions('method','Simultaneous',...
-                                 'ErrControl', true,...
-                                 'ParamField', 'p',...
-                                 'ParamScales', data.p);
-CVodeSensInit(Ns, [], yS0, FSAoptions);
-
-% ----------------
-% Problem solution
-% ----------------
-
-time(1,1) = t0;
-sol(1,:) = y0';
-
-t = t0;
-tf = 0.25;
-it = 1;
-while t<tf
-  it = it+1;
-  [status, t, y, yS] = CVode(tf,'OneStep');
-  time(it,1) = t;
-  sol(it,:) = y';
-end
-
-si = CVodeGetStats
-
-% -------------
-% Plot solution
-% -------------
-
-figure
-hold on
-plot(time, sol(:,1),'r');
-plot(time, sol(:,2),'g');
-plot(time, sol(:,3),'b');
-set(gca,'YScale','log');
-set(gca,'XLim',[t0 tf]);
-xlabel('time')
-
-grid on
-box on
-
-% -----------
-% Free memory
-% -----------
-CVodeFree;
-
-return
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-p = data.p;
-
-yd(1) = -p(1)*y(1)*y(2) - p(2)*y(1)*y(3) + 2*p(3)*y(2) + p(4)*y(3);
-yd(2) = -p(1)*y(1)*y(2) + 2*p(2)*y(1)*y(3) + p(4)*y(3);
-yd(3) =  p(1)*y(1)*y(2) - p(2)*y(1)*y(3) - p(4)*y(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [ySd, flag, new_data] = rhsSfn(t,y,yd,yS,data)
-% Sensitivity right-hand side function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-% r1
-
-yS1 = yS(:,1);
-yS1d = zeros(3,1);
-
-yS1d(1) = -r1*yS1(1) + r2*y(3)*yS1(2) + r2*y(2)*yS1(3);
-yS1d(3) = 2*r3*y(2)*yS1(2);
-yS1d(2) = -yS1d(1)-yS1d(3);
-
-yS1d(1) = yS1d(1) - y(1);
-yS1d(2) = yS1d(2) + y(1);
-
-% r2
-
-yS2 = yS(:,2);
-yS2d = zeros(3,1);
-
-yS2d(1) = -r1*yS2(1) + r2*y(3)*yS2(2) + r2*y(2)*yS2(3);
-yS2d(3) = 2*r3*y(2)*yS2(2);
-yS2d(2) = -yS2d(1)-yS2d(3);
-
-yS2d(1) = yS2d(1) + y(2)*y(3);
-yS2d(2) = yS2d(2) - y(2)*y(3);
-
-% Return values
-
-ySd = [yS1d yS2d];
-flag = 0;
-new_data = [];
-
-return
diff --git a/sundialsTB/cvodes/examples_ser/mcvsPleiades_non.m b/sundialsTB/cvodes/examples_ser/mcvsPleiades_non.m
deleted file mode 100644
index ba138d7..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsPleiades_non.m
+++ /dev/null
@@ -1,149 +0,0 @@
-function mcvsPleiades_non()
-%mcvsPleiades_non - CVODES example problem (serial, nonstiff)
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-neq = 28;
-
-t0 = 0.0;
-tout = 3.0;
-
-y0 = zeros(neq,1);
-y0(1)  =  3.0;
-y0(2)  =  3.0;
-y0(3)  = -1.0;
-y0(4)  = -3.0;
-y0(5)  =  2.0;
-y0(6)  = -2.0;
-y0(7)  =  2.0;
-y0(8)  =  3.0;
-y0(9)  = -3.0;
-y0(10) =  2.0;
-y0(13) = -4.0;
-y0(14) =  4.0;
-y0(20) =  1.75;
-y0(21) = -1.5;
-y0(25) = -1.25;
-y0(26) =  1.0;
-
-options = CVodeSetOptions('RelTol', 1.0e-7,...
-                          'AbsTol', 1.0e-7,...
-                          'StopTime',tout,...
-                          'MaxNumSteps',2000);
-
-CVodeInit(@rhsfn, 'Adams', 'Functional', t0, y0, options);
-
-% Loop in one-step mode
-t = t0;
-i = 0;
-while t < tout
-  i = i+1;
-  [status,t,y] = CVode(tout,'OneStep');
-  time(i) = t;
-  xx(:,i) = y(1:7);
-  yy(:,i) = y(8:14);
-end
-
-% Display solver statistics
-Stats = CVodeGetStats
-
-% Free solver memory
-CVodeFree;
-
-% Plot body trajectories
-colors = ['k','b','r','g','c','y','m'];
-figure;
-for i = 1:7
-  plot(xx(i,:),yy(i,:),colors(i));
-  hold on;
-end
-legend('Body 1','Body 2','Body 3','Body 4','Body 5','Body 6','Body 7');
-title('Body Trajectories');
-xlabel('x');
-ylabel('y');
-grid on;
-axis square;
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-for i = 1:7
-  sumx = 0.0;
-  sumy = 0.0;
-  for j = 1:7
-    mj = j;
-    rij = (y(i)-y(j))^2 + (y(i+7)-y(j+7))^2;
-    rij32 = rij^(3/2);
-    if j ~= i
-      sumx = sumx + mj*(y(j)-y(i))/rij32;
-      sumy = sumy + mj*(y(j+7)-y(i+7))/rij32;
-    end
-  end
-  yd(i+14) = sumx;
-  yd(i+21) = sumy;
-end
-for i = 1:14
-  yd(i) = y(i+14);
-end
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [J, flag, new_data] = djacfn(t, y, fy, data)
-% Dense Jacobian function
-
-neq = 28;
-
-J = zeros(neq,neq);
-for i = 1:14
-  J(i,14+i)=1.0;
-end
-for i = 2:7
-  mi=i;
-  for j = 1:i-1
-    mj = j;
-    rij = (y(i)-y(j))^2+(y(i+7)-y(j+7))^2;
-    rij32 = rij^(3/2);
-    rij52 = rij^(5/2);
-    fjh = (1.0-3.0*(y(j)-y(i))^2/rij)/rij32;
-    J(i+14,j)   = mj*fjh;
-    J(j+14,i)   = mi*fjh;
-    fjh = (1.0-3.0*(y(j+7)-y(i+7))^2/rij)/rij32;
-    J(i+21,j+7) = mj*fjh;
-    J(j+21,i+7) = mi*fjh;
-    fjh = -3.0*(y(j)-y(i))*(y(j+7)-y(i+7))/rij52;
-    J(i+14,j+7) = mj*fjh;
-    J(j+14,i+7) = mi*fjh;
-    J(i+21,j)   = mj*fjh;
-    J(j+21,i)   = mi*fjh;
-  end
-end
-for i = 1:7
-  sumxx = 0.0;
-  sumxy = 0.0;
-  sumyy = 0.0;
-  for j = 1:7
-    if j ~= i
-      sumxx = sumxx + J(i+14,j);
-      sumxy = sumxy + J(i+14,j+7);
-      sumyy = sumyy + J(i+21,j+7);
-    end
-  end
-  J(i+14,i)   = -sumxx;
-  J(i+14,i+7) = -sumxy;
-  J(i+21,i)   = -sumxy;
-  J(i+21,i+7) = -sumyy;
-end
-
-flag = 0;
-new_data = [];
-
-return
\ No newline at end of file
diff --git a/sundialsTB/cvodes/examples_ser/mcvsPollut_FSA_dns.m b/sundialsTB/cvodes/examples_ser/mcvsPollut_FSA_dns.m
deleted file mode 100644
index 25c46c7..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsPollut_FSA_dns.m
+++ /dev/null
@@ -1,417 +0,0 @@
-function mcvsPollut_FSA_dns()
-%mcvsPollut_FSA_dns - Air pollution model
-%   J.G Verwer - Gauss-Seidel Iteration for Stiff ODEs from Chemical Kinetics
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-
-t0 = 0.0;
-tf = 1.0;
-
-
-Ny = 20;
-Np = 25;
-
-plist = [21;22;23;24;25];
-Ns = length(plist);
-
-% -------------------
-% User data structure
-% -------------------
-
-data.p  = [0.35    ; 0.266e2  ; 0.123e5  ; 0.86e-3  ; 0.82e-3  ; ...
-           0.15e5  ; 0.13e-3  ; 0.24e5   ; 0.165e5  ; 0.9e4    ; ...
-           0.22e-1 ; 0.12e5   ; 0.188e1  ; 0.163e5  ; 0.48e7   ; ...
-           0.35e-3 ; 0.175e-1 ; 0.1e9    ; 0.444e12 ; 0.124e4  ; ...
-           0.21e1  ; 0.578e1  ; 0.474e-1 ; 0.178e4  ; 0.312e1];
-
-data.plist = plist;
-
-% ---------------------
-% CVODES initialization
-% ---------------------
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-5,...
-                          'AbsTol',1.e-8,...
-                          'LinearSolver','Dense');
-
-y0 = [0 ; 0.2   ; 0   ; 0.04 ; 0 ; ...
-      0 ; 0.1   ; 0.3 ; 0.01 ; 0 ; ...
-      0 ; 0     ; 0   ; 0    ; 0 ; ...
-      0 ; 0.007 ; 0   ; 0    ; 0];
-
-
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, y0, options);
-
-
-% ------------------
-% FSA initialization
-% ------------------
-
-yS0 = zeros(Ny,Ns);
-
-FSAoptions = CVodeSensSetOptions('method','Simultaneous',...
-                                 'ErrControl', true,...
-                                 'ParamScales', data.p(plist));
-
-CVodeSensInit(Ns, @rhsSfn, yS0, FSAoptions);
-
-% ----------------
-% Problem solution
-% ----------------
-
-time(1,1) = t0;
-sol(1,:) = y0';
-sens(1,:,:) = yS0;
-
-t = t0;
-it = 1;
-while t<tf
-  it = it+1;
-  [status, t, y, yS] = CVode(tf,'OneStep');
-%  [status, t, y] = CVode(tf,'OneStep');
-  time(it,1) = t;
-  sol(it,:) = y';
-  sens(it,:,:) = yS;
-end
-
-si = CVodeGetStats
-
-% -------------
-% Plot solution
-% -------------
-
-figure
-hold on
-for i = 1:Ny
-  plot(time, sol(:,i))
-end
-set(gca,'XLim',[t0 tf]);
-xlabel('time')
-grid on
-box on
-
-% -----------
-% Free memory
-% -----------
-
-CVodeFree;
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-p  = data.p;
-
-p1  = p(1);  p2  = p(2);  p3  = p(3);  p4  = p(4);  p5  = p(5);
-p6  = p(6);  p7  = p(7);  p8  = p(8);  p9  = p(9);  p10 = p(10);
-p11 = p(11); p12 = p(12); p13 = p(13); p14 = p(14); p15 = p(15);
-p16 = p(16); p17 = p(17); p18 = p(18); p19 = p(19); p20 = p(20);
-p21 = p(21); p22 = p(22); p23 = p(23); p24 = p(24); p25 = p(25);
-
-y1  = y(1);  y2  = y(2);  y3  = y(3);  y4  = y(4);  y5  = y(5);
-y6  = y(6);  y7  = y(7);  y8  = y(8);  y9  = y(9);  y10 = y(10);
-y11 = y(11); y12 = y(12); y13 = y(13); y14 = y(14); y15 = y(15);
-y16 = y(16); y17 = y(17); y18 = y(18); y19 = y(19); y20 = y(20);
-
-
-r1  = p1*y1;
-r2  = p2*y2*y4;
-r3  = p3*y2*y5;
-r4  = p4*y7;
-r5  = p5*y7;
-
-r6  = p6*y6*y7;
-r7  = p7*y9;
-r8  = p8*y6*y9;
-r9  = p9*y2*y11;
-r10 = p10*y1*y11;
-
-r11 = p11*y13;
-r12 = p12*y2*y10;
-r13 = p13*y14;
-r14 = p14*y1*y6;
-r15 = p15*y3;
-
-r16 = p16*y4;
-r17 = p17*y4;
-r18 = p18*y16;
-r19 = p19*y16;
-r20 = p20*y6*y17;
-
-r21 = p21*y19;
-r22 = p22*y19;
-r23 = p23*y1*y4;
-r24 = p24*y1*y19;
-r25 = p25*y20;
-
-
-f1  = -r1-r10-r14-r23-r24+r2+r3+r9+r11+r12+r22+r25;
-f2  = -r2-r3-r9-r12+r1+r21;
-f3  = -r15+r1+r17+r19+r22;
-f4  = -r2-r16-r17-r23+r15;
-f5  = -r3+2*r4+r6+r7+r13+r20;
-
-f6  = -r6-r8-r14-r20+r3+2*r18;
-f7  = -r4-r5-r6+r13;
-f8  = r4+r5+r6+r7;
-f9  = -r7-r8;
-f10 = -r12+r7+r9;
-
-f11 = -r9-r10+r8+r11;
-f12 = r9;
-f13 = -r11+r10;
-f14 = -r13+r12;
-f15 = r14;
-
-f16 = -r18-r19+r16;
-f17 = -r20;
-f18 = r20;
-f19 = -r21-r22-r24+r23+r25;
-f20 = -r25+r24;
-
-yd = [f1  ; f2  ; f3  ; f4  ; f5  ; ...
-      f6  ; f7  ; f8  ; f9  ; f10 ; ...
-      f11 ; f12 ; f13 ; f14 ; f15 ; ...
-      f16 ; f17 ; f18 ; f19 ; f20];
-
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [ySd, flag, new_data] = rhsSfn(t,y,yd,yS,data)
-% Sensitivity right-hand side function
-
-J = Jmat(y,data);
-K = Kmat(y,data);
-
-pl = data.plist;
-
-ySd = J*yS + K(:,pl);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [J, flag, new_data] = djacfn(t, y, fy, data)
-
-J = Jmat(y, data);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function J = Jmat(y, data)
-
-p  = data.p;
-
-p1  = p(1);  p2  = p(2);  p3  = p(3);  p4  = p(4);  p5  = p(5);
-p6  = p(6);  p7  = p(7);  p8  = p(8);  p9  = p(9);  p10 = p(10);
-p11 = p(11); p12 = p(12); p13 = p(13); p14 = p(14); p15 = p(15);
-p16 = p(16); p17 = p(17); p18 = p(18); p19 = p(19); p20 = p(20);
-p21 = p(21); p22 = p(22); p23 = p(23); p24 = p(24); p25 = p(25);
-
-y1  = y(1);  y2  = y(2);  y3  = y(3);  y4  = y(4);  y5  = y(5);
-y6  = y(6);  y7  = y(7);  y8  = y(8);  y9  = y(9);  y10 = y(10);
-y11 = y(11); y12 = y(12); y13 = y(13); y14 = y(14); y15 = y(15);
-y16 = y(16); y17 = y(17); y18 = y(18); y19 = y(19); y20 = y(20);
-
-% Jacobian obtained symbolically :-)
-
-J = zeros(20, 20);
-
-J( 1,  1) = -p1-p10*y11-p14*y6-p23*y4-p24*y19;
-J( 1,  2) = p2*y4+p3*y5+p9*y11+p12*y10;
-J( 1,  4) = -p23*y1+p2*y2;
-J( 1,  5) = p3*y2;
-J( 1,  6) = -p14*y1;
-J( 1, 10) = p12*y2;
-J( 1, 11) = -p10*y1+p9*y2;
-J( 1, 13) = p11;
-J( 1, 19) = -p24*y1+p22;
-J( 1, 20) = p25;
-J( 2,  1) = p1;
-J( 2,  2) = -p2*y4-p3*y5-p9*y11-p12*y10;
-J( 2,  4) = -p2*y2;
-J( 2,  5) = -p3*y2;
-J( 2, 10) = -p12*y2;
-J( 2, 11) = -p9*y2;
-J( 2, 19) = p21;
-J( 3,  1) = p1;
-J( 3,  3) = -p15;
-J( 3,  4) = p17;
-J( 3, 16) = p19;
-J( 3, 19) = p22;
-J( 4,  1) = -p23*y4;
-J( 4,  2) = -p2*y4;
-J( 4,  3) = p15;
-J( 4,  4) = -p2*y2-p16-p17-p23*y1;
-J( 5,  2) = -p3*y5;
-J( 5,  5) = -p3*y2;
-J( 5,  6) = p6*y7+p20*y17;
-J( 5,  7) = 2*p4+p6*y6;
-J( 5,  9) = p7;
-J( 5, 14) = p13;
-J( 5, 17) = p20*y6;
-J( 6,  1) = -p14*y6;
-J( 6,  2) = p3*y5;
-J( 6,  5) = p3*y2;
-J( 6,  6) = -p6*y7-p8*y9-p14*y1-p20*y17;
-J( 6,  7) = -p6*y6;
-J( 6,  9) = -p8*y6;
-J( 6, 16) = 2*p18;
-J( 6, 17) = -p20*y6;
-J( 7,  6) = -p6*y7;
-J( 7,  7) = -p4-p5-p6*y6;
-J( 7, 14) = p13;
-J( 8,  6) = p6*y7;
-J( 8,  7) = p4+p5+p6*y6;
-J( 8,  9) = p7;
-J( 9,  6) = -p8*y9;
-J( 9,  9) = -p7-p8*y6;
-J(10,  2) = -p12*y10+p9*y11;
-J(10,  9) = p7;
-J(10, 10) = -p12*y2;
-J(10, 11) = p9*y2;
-J(11,  1) = -p10*y11;
-J(11,  2) = -p9*y11;
-J(11,  6) = p8*y9;
-J(11,  9) = p8*y6;
-J(11, 11) = -p9*y2-p10*y1;
-J(11, 13) = p11;
-J(12,  2) = p9*y11;
-J(12, 11) = p9*y2;
-J(13,  1) = p10*y11;
-J(13, 11) = p10*y1;
-J(13, 13) = -p11;
-J(14,  2) = p12*y10;
-J(14, 10) = p12*y2;
-J(14, 14) = -p13;
-J(15,  1) = p14*y6;
-J(15,  6) = p14*y1;
-J(16,  4) = p16;
-J(16, 16) = -p18-p19;
-J(17,  6) = -p20*y17;
-J(17, 17) = -p20*y6;
-J(18,  6) = p20*y17;
-J(18, 17) = p20*y6;
-J(19,  1) = -p24*y19+p23*y4;
-J(19,  4) = p23*y1;
-J(19, 19) = -p21-p22-p24*y1;
-J(19, 20) = p25;
-J(20,  1) = p24*y19;
-J(20, 19) = p24*y1;
-J(20, 20) = -p25;
-
-return
-
-% ===========================================================================
-
-function K = Kmat(y, data)
-
-p  = data.p;
-
-p1  = p(1);  p2  = p(2);  p3  = p(3);  p4  = p(4);  p5  = p(5);
-p6  = p(6);  p7  = p(7);  p8  = p(8);  p9  = p(9);  p10 = p(10);
-p11 = p(11); p12 = p(12); p13 = p(13); p14 = p(14); p15 = p(15);
-p16 = p(16); p17 = p(17); p18 = p(18); p19 = p(19); p20 = p(20);
-p21 = p(21); p22 = p(22); p23 = p(23); p24 = p(24); p25 = p(25);
-
-y1  = y(1);  y2  = y(2);  y3  = y(3);  y4  = y(4);  y5  = y(5);
-y6  = y(6);  y7  = y(7);  y8  = y(8);  y9  = y(9);  y10 = y(10);
-y11 = y(11); y12 = y(12); y13 = y(13); y14 = y(14); y15 = y(15);
-y16 = y(16); y17 = y(17); y18 = y(18); y19 = y(19); y20 = y(20);
-
-K = zeros(20, 25);
-
-K( 1,  1) = -y1;
-K( 1,  2) = y2*y4;
-K( 1,  3) = y2*y5;
-K( 1,  9) = y2*y11;
-K( 1, 10) = -y1*y11;
-K( 1, 11) = y13;
-K( 1, 12) = y2*y10;
-K( 1, 14) = -y1*y6;
-K( 1, 22) = y19;
-K( 1, 23) = -y1*y4;
-K( 1, 24) = -y1*y19;
-K( 1, 25) = y20;
-K( 2,  1) = y1;
-K( 2,  2) = -y2*y4;
-K( 2,  3) = -y2*y5;
-K( 2,  9) = -y2*y11;
-K( 2, 12) = -y2*y10;
-K( 2, 21) = y19;
-K( 3,  1) = y1;
-K( 3, 15) = -y3;
-K( 3, 17) = y4;
-K( 3, 19) = y16;
-K( 3, 22) = y19;
-K( 4,  2) = -y2*y4;
-K( 4, 15) = y3;
-K( 4, 16) = -y4;
-K( 4, 17) = -y4;
-K( 4, 23) = -y1*y4;
-K( 5,  3) = -y2*y5;
-K( 5,  4) = 2*y7;
-K( 5,  6) = y6*y7;
-K( 5,  7) = y9;
-K( 5, 13) = y14;
-K( 5, 20) = y6*y17;
-K( 6,  3) = y2*y5;
-K( 6,  6) = -y6*y7;
-K( 6,  8) = -y6*y9;
-K( 6, 14) = -y1*y6;
-K( 6, 18) = 2*y16;
-K( 6, 20) = -y6*y17;
-K( 7,  4) = -y7;
-K( 7,  5) = -y7;
-K( 7,  6) = -y6*y7;
-K( 7, 13) = y14;
-K( 8,  4) = y7;
-K( 8,  5) = y7;
-K( 8,  6) = y6*y7;
-K( 8,  7) = y9;
-K( 9,  7) = -y9;
-K( 9,  8) = -y6*y9;
-K(10,  7) = y9;
-K(10,  9) = y2*y11;
-K(10, 12) = -y2*y10;
-K(11,  8) = y6*y9;
-K(11,  9) = -y2*y11;
-K(11, 10) = -y1*y11;
-K(11, 11) = y13;
-K(12,  9) = y2*y11;
-K(13, 10) = y1*y11;
-K(13, 11) = -y13;
-K(14, 12) = y2*y10;
-K(14, 13) = -y14;
-K(15, 14) = y1*y6;
-K(16, 16) = y4;
-K(16, 18) = -y16;
-K(16, 19) = -y16;
-K(17, 20) = -y6*y17;
-K(18, 20) = y6*y17;
-K(19, 21) = -y19;
-K(19, 22) = -y19;
-K(19, 23) = y1*y4;
-K(19, 24) = -y1*y19;
-K(19, 25) = y20;
-K(20, 24) = y1*y19;
-K(20, 25) = -y20;
-
-return
\ No newline at end of file
diff --git a/sundialsTB/cvodes/examples_ser/mcvsRoberts_ASAi_dns.m b/sundialsTB/cvodes/examples_ser/mcvsRoberts_ASAi_dns.m
deleted file mode 100644
index ee6800b..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsRoberts_ASAi_dns.m
+++ /dev/null
@@ -1,286 +0,0 @@
-function mcvsRoberts_ASAi_dns()
-%mcvsRoberts_ASAi_dns - CVODES adjoint sensitivity example problem (serial, dense)
-%   The following is a simple example problem, with the coding
-%   needed for its solution by CVODES. The problem is from
-%   chemical kinetics, and consists of the following three rate
-%   equations:         
-%      dy1/dt = -p1*y1 + p2*y2*y3
-%      dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
-%      dy3/dt =  p3*(y2)^2
-%   on the interval from t = 0.0 to t = 4.e10, with initial
-%   conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
-%
-%   This program solves the problem with the BDF method,
-%   Newton iteration with the CVDENSE dense linear solver, and a
-%   user-supplied Jacobian routine. It uses a scalar relative 
-%   tolerance and a vector absolute tolerance.
-%
-%   The gradient with respect to the problem parameters p1, p2,
-%   and p3 of the following quantity:
-%     G = int_t0^t1 y3(t) dt
-%   is computed using ASA.
-% 
-%   Writing the original ODE as:
-%     dy/dt = f(y,p)
-%     y(t0) = y0(p)
-%   then the gradient with respect to the parameters p of
-%     G(p) = int_t0^t1 g(y,p) dt
-%   is obtained as:
-%     dG/dp = int_t0^t1 (g_p + lambda^T f_p ) dt + lambda^T(t0)*y0_p
-%           = -xi^T(t0) + lambda^T(t0)*y0_p
-%   where lambda and xi are solutions of:
-%     d(lambda)/dt = - (f_y)^T * lambda - (g_y)^T
-%     lambda(t1) = 0
-%   and
-%     d(xi)/dt = (g_p)^T + (f_p)^T * lambda
-%     xi(t1) = 0
-%   
-%   During the forward integration, CVODES also evaluates G as
-%     G = q(t1)
-%   where
-%     dq/dt = g(t,y,p)
-%     q(t0) = 0
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2009/04/26 23:26:45 $
-
-
-% ----------------------------------------
-% User data structure
-% ----------------------------------------
-
-data.p = [0.04; 1.0e4; 3.0e7];
-
-% ----------------------------------------
-% Forward CVODES options
-% ----------------------------------------
-
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-6,...
-                          'AbsTol',[1.e-8; 1.e-14; 1.e-6],...
-                          'LinearSolver','Dense',...
-                          'JacobianFn', at djacfn);
-
-mondata = struct;
-mondata.sol = true;
-mondata.mode = 'both';
-options = CVodeSetOptions(options,...
-                          'MonitorFn', at CVodeMonitor,...
-                          'MonitorData',mondata);
-
-t0 = 0.0;
-y0 = [1.0;0.0;0.0];
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, y0, options);
-
-
-optionsQ = CVodeQuadSetOptions('ErrControl',true,...
-                               'RelTol',1.e-6,'AbsTol',1.e-6);
-
-q0 = 0.0;
-CVodeQuadInit(@quadfn, q0, optionsQ);
-
-% ----------------------------------------
-% Initialize ASA
-% ----------------------------------------
-
-CVodeAdjInit(150, 'Hermite');
-
-% ----------------------------------------
-% Forward integration
-% ----------------------------------------
-
-fprintf('Forward integration ');
-
-tout = 4.e7;
-[status,t,y,q] = CVode(tout,'Normal');
-s = CVodeGetStats;
-fprintf('(%d steps)\n',s.nst);
-fprintf('G = %12.4e\n',q);
-
-
-fprintf('\nCheck point info\n');
-
-ck = CVodeGet('CheckPointsInfo');
-fprintf(['    t0         t1     nstep  order  step size\n']); 
-for i = 1:length(ck)
-  fprintf('%8.3e  %8.3e  %4d     %1d   %10.5e\n',...
-          ck(i).t0, ck(i).t1, ck(i).nstep, ck(i).order, ck(i).step);
-end
-fprintf('\n');
-
-% ----------------------------------------
-% Backward CVODES options
-% ----------------------------------------
-
-optionsB = CVodeSetOptions('UserData',data,...
-                           'RelTol',1.e-6,...
-                           'AbsTol',1.e-8,...
-                           'LinearSolver','Dense',...
-                           'JacobianFn', at djacBfn);
-
-mondataB = struct;
-mondataB.mode = 'both';
-optionsB = CVodeSetOptions(optionsB,...
-                           'MonitorFn','CVodeMonitorB',...
-                           'MonitorData', mondataB);
-
-tB1 = 4.e7;
-yB1 = [0.0;0.0;0.0];
-idxB = CVodeInitB(@rhsBfn, 'BDF', 'Newton', tB1, yB1, optionsB);
-
-optionsQB = CVodeQuadSetOptions('ErrControl',true,...
-                                'RelTol',1.e-6,'AbsTol',1.e-3);
-
-qB1 = [0.0;0.0;0.0];
-CVodeQuadInitB(idxB, @quadBfn, qB1, optionsQB);
-
-% ----------------------------------------
-% Backward integration
-% ----------------------------------------
-
-fprintf('Backward integration ');
-
-[status,t,yB,qB] = CVodeB(t0,'Normal');
-sB=CVodeGetStatsB(idxB);
-fprintf('(%d steps)\n',sB.nst);
-
-fprintf('tB1:        %12.4e\n',tB1);
-fprintf('dG/dp:      %12.4e  %12.4e  %12.4e\n',...
-        -qB(1)+yB(1), -qB(2)+yB(2), -qB(3)+yB(3));
-fprintf('lambda(t0): %12.4e  %12.4e  %12.4e\n',...
-        yB(1),yB(2),yB(3));
-
-% ----------------------------------------
-% Free memory
-% ----------------------------------------
-
-CVodeFree;
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-yd(1) = -r1*y(1) + r2*y(2)*y(3);
-yd(3) = r3*y(2)*y(2);
-yd(2) = -yd(1) - yd(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [qd, flag, new_data] = quadfn(t, y, data)
-% Forward quadrature integrand function
-
-qd = y(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [J, flag, new_data] = djacfn(t, y, fy, data)
-% Dense Jacobian function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-J(1,1) = -r1;
-J(1,2) = r2*y(3);
-J(1,3) = r2*y(2);
-
-J(2,1) = r1;
-J(2,2) = -r2*y(3) - 2*r3*y(2);
-J(2,3) = -r2*y(2);
-
-J(3,2) = 2*r3*y(2);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [yBd, flag, new_data] = rhsBfn(t, y, yB, data)
-% Backward problem right-hand side function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-y1 = y(1);
-y2 = y(2);
-y3 = y(3);
-
-l1 = yB(1);
-l2 = yB(2);
-l3 = yB(3);
-
-l21 = l2-l1;
-l32 = l3-l2;
-y23 = y2*y3;
-
-yBd(1) = - r1*l21;
-yBd(2) = r2*y3*l21 - 2.0*r3*y2*l32;
-yBd(3) = r2*y2*l21 - 1.0;
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [qBd, flag, new_data] = quadBfn(t, y, yB, data)
-% Backward problem quadrature integrand function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-y1 = y(1);
-y2 = y(2);
-y3 = y(3);
-
-l1 = yB(1);
-l2 = yB(2);
-l3 = yB(3);
-
-l21 = l2-l1;
-l32 = l3-l2;
-y23 = y2*y3;
-
-qBd(1) = y1*l21;
-qBd(2) = -y23*l21;
-qBd(3) = l32*y2^2;
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [JB, flag, new_data] = djacBfn(t, y, yB, fyB, data)
-% Backward problem Jacobian function
-
-J = djacfn(t,y,[],data);
-JB = -J';
-
-flag = 0;
-new_data = [];
-
-return
\ No newline at end of file
diff --git a/sundialsTB/cvodes/examples_ser/mcvsRoberts_FSA_dns.m b/sundialsTB/cvodes/examples_ser/mcvsRoberts_FSA_dns.m
deleted file mode 100644
index 7a589f4..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsRoberts_FSA_dns.m
+++ /dev/null
@@ -1,197 +0,0 @@
-function mcvsRoberts_FSA_dns()
-%mcvsRoberts_FSA_dns - CVODES forward sensitivity example (serial, dense)
-%   The following is a simple example problem, with the coding
-%   needed for its solution by CVODES. The problem is from
-%   chemical kinetics, and consists of the following three rate
-%   equations:         
-%      dy1/dt = -.04*y1 + 1.e4*y2*y3
-%      dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
-%      dy3/dt = 3.e7*(y2)^2
-%   on the interval from t = 0.0 to t = 4.e10, with initial
-%   conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
-%   While integrating the system, we also use the rootfinding
-%   feature to find the points at which y1 = 1e-4 or at which
-%   y3 = 0.01. This program solves the problem with the BDF method,
-%   Newton iteration with the CVDENSE dense linear solver, and a
-%   user-supplied Jacobian routine. It uses a scalar relative 
-%   tolerance and a vector absolute tolerance.
-%
-%   Solution sensitivities with respect to the problem parameters
-%   p1, p2, and p3 are computed using FSA. The sensitivity right-hand
-%   side is given analytically through the user routine rhsSfn.
-%   Tolerances for the sensitivity variables are estimated by
-%   CVODES using the provided parameter scale information. The
-%   sensitivity variables are included in the error test.
-%
-%   Output is printed in decades from t = .4 to t = 4.e10.
-%   Run statistics (optional outputs) are printed at the end.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-% -------------------
-% User data structure
-% -------------------
-
-data.p = [0.04; 1.0e4; 3.0e7];
-
-% ---------------------
-% CVODES initialization
-% ---------------------
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-4,...
-                          'AbsTol',[1.e-8; 1.e-14; 1.e-6],...
-                          'JacobianFn', at djacfn);
-
-mondata = struct;
-mondata.mode = 'both';
-mondata.sol = true;
-mondata.sensi = true;
-options = CVodeSetOptions(options,'MonitorFn', at CVodeMonitor,'MonitorData',mondata);
-
-t0 = 0.0;
-y0 = [1.0;0.0;0.0];
-
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, y0, options);
-
-
-% ------------------
-% FSA initialization
-% ------------------
-
-Ns = 2;
-yS0 = zeros(3,Ns);
-
-% Case 1: user-provided sensitivity RHS
-
-FSAoptions = CVodeSensSetOptions('method','Simultaneous',...
-                                 'ErrControl', true,...
-                                 'ParamScales', [0.04; 1.0e4]);
-CVodeSensInit(Ns, @rhsSfn, yS0, FSAoptions);
-
-% Case 2: internal DQ approximation
-
-%FSAoptions = CVodeSensSetOptions('method','Simultaneous',...
-%                                 'ErrControl', true,...
-%                                 'ParamField', 'p',...
-%                                 'ParamList', [1 2],...
-%                                 'ParamScales', [0.04 1.0e4]);
-%CVodeSensInit(Ns, [], yS0, FSAoptions);
-
-% ----------------
-% Problem solution
-% ----------------
-
-t1 = 0.4;
-tmult = 10.0;
-nout = 12;
-
-iout = 0;
-tout = t1;
-while 1,
-  [status, t, y, yS] = CVode(tout,'Normal');
-  fprintf('t = %0.2e\n',t);
-  fprintf('solution      = [ %14.6e  %14.6e  %14.6e ]\n', y(1), y(2), y(3));
-  fprintf('sensitivity 1 = [ %14.6e  %14.6e  %14.6e ]\n', yS(1,1), yS(2,1), yS(3,1));
-  fprintf('sensitivity 2 = [ %14.6e  %14.6e  %14.6e ]\n\n', yS(1,2), yS(2,2), yS(3,2));
-  if(status ==0)
-    iout = iout+1;
-    tout = tout*tmult;
-  end
-  if iout==nout
-    break;
-  end
-end
-
-si = CVodeGetStats
-
-% -----------
-% Free memory
-% -----------
-
-CVodeFree;
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-yd(1) = -r1*y(1) + r2*y(2)*y(3);
-yd(3) = r3*y(2)*y(2);
-yd(2) = -yd(1) - yd(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [J, flag, new_data] = djacfn(t, y, fy, data)
-% Dense Jacobian function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-J(1,1) = -r1;
-J(1,2) = r2*y(3);
-J(1,3) = r2*y(2);
-
-J(2,1) = r1;
-J(2,2) = -r2*y(3) - 2*r3*y(2);
-J(2,3) = -r2*y(2);
-
-J(3,2) = 2*r3*y(2);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [ySd, flag, new_data] = rhsSfn(t,y,yd,yS,data)
-% Sensitivity right-hand side function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-% r1
-
-yS1 = yS(:,1);
-yS1d = zeros(3,1);
-
-yS1d(1) = -r1*yS1(1) + r2*y(3)*yS1(2) + r2*y(2)*yS1(3);
-yS1d(3) = 2*r3*y(2)*yS1(2);
-yS1d(2) = -yS1d(1)-yS1d(3);
-
-yS1d(1) = yS1d(1) - y(1);
-yS1d(2) = yS1d(2) + y(1);
-
-% r2
-
-yS2 = yS(:,2);
-yS2d = zeros(3,1);
-
-yS2d(1) = -r1*yS2(1) + r2*y(3)*yS2(2) + r2*y(2)*yS2(3);
-yS2d(3) = 2*r3*y(2)*yS2(2);
-yS2d(2) = -yS2d(1)-yS2d(3);
-
-yS2d(1) = yS2d(1) + y(2)*y(3);
-yS2d(2) = yS2d(2) - y(2)*y(3);
-
-% Return values
-
-ySd = [yS1d yS2d];
-flag = 0;
-new_data = [];
-
-return
diff --git a/sundialsTB/cvodes/examples_ser/mcvsRoberts_dns.m b/sundialsTB/cvodes/examples_ser/mcvsRoberts_dns.m
deleted file mode 100644
index 15ca4bf..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsRoberts_dns.m
+++ /dev/null
@@ -1,132 +0,0 @@
-function mcvsRoberts_dns()
-%mcvsRoberts_dns - CVODES example problem (serial, dense)
-%   The following is a simple example problem, with the coding
-%   needed for its solution by CVODES. The problem is from
-%   chemical kinetics, and consists of the following three rate
-%   equations:         
-%      dy1/dt = -.04*y1 + 1.e4*y2*y3
-%      dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
-%      dy3/dt = 3.e7*(y2)^2
-%   on the interval from t = 0.0 to t = 4.e10, with initial
-%   conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
-%   While integrating the system, we also use the rootfinding
-%   feature to find the points at which y1 = 1e-4 or at which
-%   y3 = 0.01. This program solves the problem with the BDF method,
-%   Newton iteration with the CVDENSE dense linear solver, and a
-%   user-supplied Jacobian routine. It uses a scalar relative 
-%   tolerance and a vector absolute tolerance and also illustrates
-%   the rootfinding capability in CVODES.
-%
-%   Output is printed in decades from t = .4 to t = 4.e10.
-%   Run statistics (optional outputs) are printed at the end.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-data.p = [0.04; 1.0e4; 3.0e7];
-
-t0 = 0.0;
-y0 = [1.0;0.0;0.0];
-
-options = CVodeSetOptions('UserData', data,...
-                          'RelTol',1.e-8,...
-                          'AbsTol',[1.e-8; 1.e-14; 1.e-6],...
-                          'LinearSolver','Dense',...
-                          'JacobianFn', at djacfn,...
-                          'RootsFn', at rootfn, 'NumRoots',2);
-
-mondata.sol = true;
-mondata.mode = 'text';
-mondata.skip = 9;
-mondata.updt = 100;
-options = CVodeSetOptions(options,'MonitorFn', at CVodeMonitor,'MonitorData',mondata);
-
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, y0, options);
-
-t1 = 0.4;
-tmult = 10.0;
-nout = 12;
-
-iout = 0;
-tout = t1;
-while iout < nout
-
-  [status,t,y] = CVode(tout,'Normal');
-  
-% Extract statistics
-  si = CVodeGetStats;
-
-% Print output
-  fprintf('t = %0.2e   order = %1d  step = %0.2e',t, si.qlast, si.hlast);
-  if(status == 2)
-    fprintf(' ... Root found  %d   %d\n',si.RootInfo.roots(1), si.RootInfo.roots(2));
-  else
-    fprintf('\n');
-  end
-  fprintf('solution = [ %14.6e  %14.6e  %14.6e ]\n\n', y(1), y(2), y(3));
-
-% Update output time
-  if(status == 0)
-    iout = iout+1;
-    tout = tout*tmult;
-  end
-  
-end
-
-si = CVodeGetStats;
-
-CVodeFree;
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-yd(1) = -r1*y(1) + r2*y(2)*y(3);
-yd(3) = r3*y(2)*y(2);
-yd(2) = -yd(1) - yd(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [J, flag, new_data] = djacfn(t, y, fy, data)
-% Dense Jacobian function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-J(1,1) = -r1;
-J(1,2) = r2*y(3);
-J(1,3) = r2*y(2);
-
-J(2,1) = r1;
-J(2,2) = -r2*y(3) - 2*r3*y(2);
-J(2,3) = -r2*y(2);
-
-J(3,2) = 2*r3*y(2);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [g, flag, new_data] = rootfn(t,y,data)
-% Root finding function
-
-g(1) = y(1) - 0.0001;
-g(2) = y(3) - 0.01;
-
-flag = 0;
-new_data = [];
diff --git a/sundialsTB/cvodes/examples_ser/mcvsVanDPol_dns.m b/sundialsTB/cvodes/examples_ser/mcvsVanDPol_dns.m
deleted file mode 100644
index ab77d71..0000000
--- a/sundialsTB/cvodes/examples_ser/mcvsVanDPol_dns.m
+++ /dev/null
@@ -1,64 +0,0 @@
-function mcvsVanDPol_dns()
-%mcvsVanDPol_dns - CVODES example problem (serial, dense)
-%   van der Pol problem.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-
-data.mu = 100.0;
-
-t0 = 0.0;
-tf = 300.0;
-y0 = [2.0;0.0];
-
-options = CVodeSetOptions('UserData',data,...
-                          'RelTol',1.e-8,...
-                          'AbsTol',1e-6,...
-                          'JacobianFn', at djacfn);
-
-mondata.mode = 'both';
-mondata.skip = 20;
-options = CVodeSetOptions(options,'MonitorFn', at CVodeMonitor,'MonitorData',mondata);
-
-CVodeInit(@rhsfn, 'BDF', 'Newton', t0, y0, options);
-
-ntout = 50;
-dt = (tf-t0)/ntout;
-tt = linspace(t0+dt,tf,ntout-1);
-
-[status,t,y] = CVode(tt,'Normal');
-
-CVodeFree;
-
-figure;
-plot(t,y(1,:),'r',t,y(1,:),'.');
-
-% ===========================================================================
-
-function [yd, flag, new_data] = rhsfn(t, y, data)
-% Right-hand side function
-
-mu = data.mu;
-
-yd = [            y(2)
-        mu*(1-y(1)^2)*y(2)-y(1) ];
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-
-function [J, flag, new_data] = djacfn(t, y, fy, data)
-% Dense Jacobian function (if using Newton)
-
-mu = data.mu;
-
-J = [         0                  1
-      -2*mu*y(1)*y(2)-1    mu*(1-y(1)^2) ];
-
-flag = 0;
-new_data = [];
\ No newline at end of file
diff --git a/sundialsTB/cvodes/function_types/CVBandJacFn.m b/sundialsTB/cvodes/function_types/CVBandJacFn.m
deleted file mode 100644
index 10233fb..0000000
--- a/sundialsTB/cvodes/function_types/CVBandJacFn.m
+++ /dev/null
@@ -1,31 +0,0 @@
-%CVBandJacFn - type for user provided banded Jacobian function.
-%
-%   The function BJACFUN must be defined as 
-%        FUNCTION [J, FLAG] = BJACFUN(T, Y, FY)
-%   and must return a matrix J corresponding to the banded Jacobian of f(t,y).
-%   The input argument FY contains the current value of f(t,y).
-%   If a user data structure DATA was specified in CVodeInit, then
-%   BJACFUN must be defined as
-%        FUNCTION [J, FLAG, NEW_DATA] = BJACFUN(T, Y, FY, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix J,
-%   the BJACFUN function must also set NEW_DATA. Otherwise, it should 
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function BJACFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeSetOptions
-%
-%   See the CVODES user guide for more informaiton on the structure of
-%   a banded Jacobian.
-%
-%   NOTE: BJACFUN is specified through the property JacobianFn to 
-%   CVodeSetOptions and is used only if the property LinearSolver
-%   was set to 'Band'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVBandJacFnB.m b/sundialsTB/cvodes/function_types/CVBandJacFnB.m
deleted file mode 100644
index 1ea8215..0000000
--- a/sundialsTB/cvodes/function_types/CVBandJacFnB.m
+++ /dev/null
@@ -1,27 +0,0 @@
-%CVBandJacFnB - type for user provided banded Jacobian function for backward problems.
-%
-%   The function BJACFUNB must be defined either as
-%        FUNCTION [JB, FLAG] = BJACFUNB(T, Y, YB, FYB)
-%   or as
-%        FUNCTION [JB, FLAG, NEW_DATA] = BJACFUNB(T, Y, YB, FYB, DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the matrix JB, the
-%   Jacobian of fB(t,y,yB), with respect to yB. The input argument
-%   FYB contains the current value of f(t,y,yB).
-%
-%   The function BJACFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeSetOptions
-%
-%   See the CVODES user guide for more informaiton on the structure of
-%   a banded Jacobian.
-%
-%   NOTE: BJACFUNB is specified through the property JacobianFn to 
-%   CVodeSetOptions and is used only if the property LinearSolver
-%   was set to 'Band'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVDenseJacFn.m b/sundialsTB/cvodes/function_types/CVDenseJacFn.m
deleted file mode 100644
index ee30758..0000000
--- a/sundialsTB/cvodes/function_types/CVDenseJacFn.m
+++ /dev/null
@@ -1,27 +0,0 @@
-%CVDenseJacFn - type for user provided dense Jacobian function.
-%
-%   The function DJACFUN must be defined as 
-%        FUNCTION [J, FLAG] = DJACFUN(T, Y, FY)
-%   and must return a matrix J corresponding to the Jacobian of f(t,y).
-%   The input argument FY contains the current value of f(t,y).
-%   If a user data structure DATA was specified in CVodeInit, then
-%   DJACFUN must be defined as
-%        FUNCTION [J, FLAG, NEW_DATA] = DJACFUN(T, Y, FY, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix J,
-%   the DJACFUN function must also set NEW_DATA. Otherwise, it should
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function DJACFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%   See also CVodeSetOptions
-%
-%   NOTE: DJACFUN is specified through the property JacobianFn to
-%   CVodeSetOptions and is used only if the property LinearSolver
-%   was set to 'Dense'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVDenseJacFnB.m b/sundialsTB/cvodes/function_types/CVDenseJacFnB.m
deleted file mode 100644
index 0c5d133..0000000
--- a/sundialsTB/cvodes/function_types/CVDenseJacFnB.m
+++ /dev/null
@@ -1,24 +0,0 @@
-%CVDenseJacFnB - type for user provided dense Jacobian function for backward problems.
-%
-%   The function DJACFUNB must be defined either as
-%        FUNCTION [JB, FLAG] = DJACFUNB(T, Y, YB, FYB)
-%   or as
-%        FUNCTION [JB, FLAG, NEW_DATA] = DJACFUNB(T, Y, YB, FYB, DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the matrix JB, the
-%   Jacobian of fB(t,y,yB), with respect to yB. The input argument
-%   FYB contains the current value of f(t,y,yB).
-%
-%   The function DJACFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeSetOptions
-%
-%   NOTE: DJACFUNB is specified through the property JacobianFn to
-%   CVodeSetOptions and is used only if the property LinearSolver
-%   was set to 'Dense'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVGcommFn.m b/sundialsTB/cvodes/function_types/CVGcommFn.m
deleted file mode 100644
index 4ddd3b3..0000000
--- a/sundialsTB/cvodes/function_types/CVGcommFn.m
+++ /dev/null
@@ -1,34 +0,0 @@
-%CVGcommFn - type for user provided communication function (BBDPre).
-%
-%   The function GCOMFUN must be defined as 
-%        FUNCTION FLAG = GCOMFUN(T, Y)
-%   and can be used to perform all interprocess communication necessary
-%   to evaluate the approximate right-hand side function for the BBDPre
-%   preconditioner module.
-%   If a user data structure DATA was specified in CVodeInit, then
-%   GCOMFUN must be defined as
-%        FUNCTION [FLAG, NEW_DATA] = GCOMFUN(T, Y, DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then the GCOMFUN function must also 
-%   set NEW_DATA. Otherwise, it should set NEW_DATA=[] (do not set 
-%   NEW_DATA = DATA as it would lead to unnecessary copying).
-%
-%   The function GCOMFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVGlocalFn, CVodeSetOptions
-%
-%   NOTES:
-%     GCOMFUN is specified through the GcommFn property in CVodeSetOptions
-%     and is used only if the property PrecModule is set to 'BBDPre'.
-%
-%     Each call to GCOMFUN is preceded by a call to the RHS function
-%     ODEFUN with the same arguments T and Y. Thus GCOMFUN can omit
-%     any communication done by ODEFUN if relevant to the evaluation
-%     of G by GLOCFUN. If all necessary communication was done by ODEFUN,
-%     GCOMFUN need not be provided.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVGcommFnB.m b/sundialsTB/cvodes/function_types/CVGcommFnB.m
deleted file mode 100644
index 78dd01e..0000000
--- a/sundialsTB/cvodes/function_types/CVGcommFnB.m
+++ /dev/null
@@ -1,28 +0,0 @@
-%CVGcommFn - type for user provided communication function (BBDPre) for backward problems.
-%
-%   The function GCOMFUNB must be defined either as
-%        FUNCTION FLAG = GCOMFUNB(T, Y, YB)
-%   or as
-%        FUNCTION [FLAG, NEW_DATA] = GCOMFUNB(T, Y, YB, DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. 
-%
-%   The function GCOMFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVGlocalFnB, CVodeSetOptions
-%
-%   NOTES:
-%     GCOMFUNB is specified through the GcommFn property in CVodeSetOptions
-%     and is used only if the property PrecModule is set to 'BBDPre'.
-%
-%     Each call to GCOMFUNB is preceded by a call to the RHS function
-%     ODEFUNB with the same arguments T, Y, and YB. Thus GCOMFUNB can
-%     omit any communication done by ODEFUNB if relevant to the evaluation
-%     of G by GLOCFUNB. If all necessary communication was done by ODEFUNB,
-%     GCOMFUNB need not be provided.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVGlocalFn.m b/sundialsTB/cvodes/function_types/CVGlocalFn.m
deleted file mode 100644
index 26d9e4d..0000000
--- a/sundialsTB/cvodes/function_types/CVGlocalFn.m
+++ /dev/null
@@ -1,28 +0,0 @@
-%CVGlocalFn - type for user provided RHS approximation function (BBDPre).
-%
-%   The function GLOCFUN must be defined as 
-%        FUNCTION [GLOC, FLAG] = GLOCFUN(T,Y)
-%   and must return a vector GLOC corresponding to an approximation to f(t,y)
-%   which will be used in the BBDPRE preconditioner module. The case where
-%   G is mathematically identical to F is allowed.
-%   If a user data structure DATA was specified in CVodeInit, then
-%   GLOCFUN must be defined as
-%        FUNCTION [GLOC, FLAG, NEW_DATA] = GLOCFUN(T,Y,DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then, besides setting the vector G,
-%   the GLOCFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function GLOCFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVGcommFn, CVodeSetOptions
-%
-%   NOTE: GLOCFUN is specified through the GlocalFn property in CVodeSetOptions
-%   and is used only if the property PrecModule is set to 'BBDPre'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVGlocalFnB.m b/sundialsTB/cvodes/function_types/CVGlocalFnB.m
deleted file mode 100644
index c3a74ca..0000000
--- a/sundialsTB/cvodes/function_types/CVGlocalFnB.m
+++ /dev/null
@@ -1,22 +0,0 @@
-%CVGlocalFnB - type for user provided RHS approximation function (BBDPre) for backward problems.
-%
-%   The function GLOCFUNB must be defined either as
-%        FUNCTION [GLOCB, FLAG] = GLOCFUNB(T,Y,YB)
-%   or as
-%        FUNCTION [GLOCB, FLAG, NEW_DATA] = GLOCFUNB(T,Y,YB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the vector GLOCB
-%   corresponding to an approximation to fB(t,y,yB).
-%
-%   The function GLOCFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVGcommFnB, CVodeSetOptions
-%
-%   NOTE: GLOCFUNB is specified through the GlocalFn property in CVodeSetOptions
-%   and is used only if the property PrecModule is set to 'BBDPre'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVJacTimesVecFn.m b/sundialsTB/cvodes/function_types/CVJacTimesVecFn.m
deleted file mode 100644
index 94c9a1e..0000000
--- a/sundialsTB/cvodes/function_types/CVJacTimesVecFn.m
+++ /dev/null
@@ -1,28 +0,0 @@
-%CVJacTimesVecFn - type for user provided Jacobian times vector function.
-%
-%   The function JTVFUN must be defined as 
-%        FUNCTION [JV, FLAG] = JTVFUN(T,Y,FY,V)
-%   and must return a vector JV corresponding to the product of the 
-%   Jacobian of f(t,y) with the vector v.
-%   The input argument FY contains the current value of f(t,y).
-%   If a user data structure DATA was specified in CVodeInit, then
-%   JTVFUN must be defined as
-%        FUNCTION [JV, FLAG, NEW_DATA] = JTVFUN(T,Y,FY,V,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector JV,
-%   the JTVFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function JTVFUN must set FLAG=0 if successful, or FLAG~=0 if
-%   a failure occurred.
-%
-%   See also CVodeSetOptions
-%
-%   NOTE: JTVFUN is specified through the property JacobianFn to
-%   CVodeSetOptions and is used only if the property LinearSolver
-%   was set to 'GMRES', 'BiCGStab', or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVJacTimesVecFnB.m b/sundialsTB/cvodes/function_types/CVJacTimesVecFnB.m
deleted file mode 100644
index a1bd075..0000000
--- a/sundialsTB/cvodes/function_types/CVJacTimesVecFnB.m
+++ /dev/null
@@ -1,23 +0,0 @@
-%CVJacTimesVecFnB - type for user provided Jacobian times vector function for backward problems.
-%
-%   The function JTVFUNB must be defined either as
-%        FUNCTION [JVB, FLAG] = JTVFUNB(T,Y,YB,FYB,VB)
-%   or as
-%        FUNCTION [JVB, FLAG, NEW_DATA] = JTVFUNB(T,Y,YB,FYB,VB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the vector JVB, the
-%   product of the Jacobian of fB(t,y,yB) with respect to yB and a vector
-%   vB. The input argument FYB contains the current value of f(t,y,yB).
-%
-%   The function JTVFUNB must set FLAG=0 if successful, or FLAG~=0 if
-%   a failure occurred.
-%
-%   See also CVodeSetOptions
-%
-%   NOTE: JTVFUNB is specified through the property JacobianFn to
-%   CVodeSetOptions and is used only if the property LinearSolver
-%   was set to 'GMRES', 'BiCGStab', or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVMonitorFn.m b/sundialsTB/cvodes/function_types/CVMonitorFn.m
deleted file mode 100644
index aaf9b30..0000000
--- a/sundialsTB/cvodes/function_types/CVMonitorFn.m
+++ /dev/null
@@ -1,37 +0,0 @@
-%CVMonitorFn - type for user provided monitoring function for forward problems.
-%
-%   The function MONFUN must be defined as
-%       FUNCTION [] = MONFUN(CALL, T, Y, YQ, YS)
-%   It is called after every internal CVode step and can be used to
-%   monitor the progress of the solver. MONFUN is called with CALL=0
-%   from CVodeInit at which time it should initialize itself and it
-%   is called with CALL=2 from CVodeFree. Otherwise, CALL=1.
-%
-%   It receives as arguments the current time T, solution vector Y,
-%   and, if they were computed, quadrature vector YQ, and forward 
-%   sensitivity matrix YS. If YQ and/or YS were not computed they
-%   are empty here.
-%
-%   If additional data is needed inside MONFUN, it must be defined
-%   as
-%      FUNCTION NEW_MONDATA = MONFUN(CALL, T, Y, YQ, YS, MONDATA)
-%   If the local modifications to the user data structure need to be 
-%   saved (e.g. for future calls to MONFUN), then MONFUN must set
-%   NEW_MONDATA. Otherwise, it should set NEW_MONDATA=[] 
-%   (do not set NEW_MONDATA = DATA as it would lead to unnecessary copying).
-%
-%   A sample monitoring function, CVodeMonitor, is provided with CVODES.
-%
-%   See also CVodeSetOptions, CVodeMonitor
-%
-%   NOTES: 
-%   
-%   MONFUN is specified through the MonitorFn property in CVodeSetOptions. 
-%   If this property is not set, or if it is empty, MONFUN is not used.
-%   MONDATA is specified through the MonitorData property in CVodeSetOptions.
-%
-%   See CVodeMonitor for an implementation example.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/05/11 18:51:33 $
diff --git a/sundialsTB/cvodes/function_types/CVMonitorFnB.m b/sundialsTB/cvodes/function_types/CVMonitorFnB.m
deleted file mode 100644
index 8606ec7..0000000
--- a/sundialsTB/cvodes/function_types/CVMonitorFnB.m
+++ /dev/null
@@ -1,37 +0,0 @@
-%CVMonitorFnB - type of user provided monitoring function for backward problems.
-%
-%   The function MONFUNB must be defined as
-%       FUNCTION [] = MONFUNB(CALL, IDXB, T, Y, YQ)
-%   It is called after every internal CVodeB step and can be used to
-%   monitor the progress of the solver. MONFUNB is called with CALL=0
-%   from CVodeInitB at which time it should initialize itself and it
-%   is called with CALL=2 from CVodeFree. Otherwise, CALL=1.
-%
-%   It receives as arguments the index of the backward problem (as
-%   returned by CVodeInitB), the current time T, solution vector Y,
-%   and, if it was computed, the quadrature vector YQ. If quadratures
-%   were not computed for this backward problem, YQ is empty here.
-%
-%   If additional data is needed inside MONFUNB, it must be defined
-%   as
-%      FUNCTION NEW_MONDATA = MONFUNB(CALL, IDXB, T, Y, YQ, MONDATA)
-%   If the local modifications to the user data structure need to be 
-%   saved (e.g. for future calls to MONFUNB), then MONFUNB must set
-%   NEW_MONDATA. Otherwise, it should set NEW_MONDATA=[] 
-%   (do not set NEW_MONDATA = DATA as it would lead to unnecessary copying).
-%
-%   A sample monitoring function, CVodeMonitorB, is provided with CVODES.
-%
-%   See also CVodeSetOptions, CVodeMonitorB
-%
-%   NOTES: 
-%   
-%   MONFUNB is specified through the MonitorFn property in CVodeSetOptions. 
-%   If this property is not set, or if it is empty, MONFUNB is not used.
-%   MONDATA is specified through the MonitorData property in CVodeSetOptions.
-%
-%   See CVodeMonitorB for an implementation example.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/05/11 18:51:33 $
diff --git a/sundialsTB/cvodes/function_types/CVPrecSetupFn.m b/sundialsTB/cvodes/function_types/CVPrecSetupFn.m
deleted file mode 100644
index d9b6677..0000000
--- a/sundialsTB/cvodes/function_types/CVPrecSetupFn.m
+++ /dev/null
@@ -1,68 +0,0 @@
-%CVPrecSetupFn - type for user provided preconditioner setup function.
-%
-%   The user-supplied preconditioner setup function PSETFUN and
-%   the user-supplied preconditioner solve function PSOLFUN
-%   together must define left and right preconditoner matrices
-%   P1 and P2 (either of which may be trivial), such that the
-%   product P1*P2 is an approximation to the Newton matrix
-%   M = I - gamma*J.  Here J is the system Jacobian J = df/dy,
-%   and gamma is a scalar proportional to the integration step
-%   size h.  The solution of systems P z = r, with P = P1 or P2,
-%   is to be carried out by the PrecSolve function, and PSETFUN
-%   is to do any necessary setup operations.
-%
-%   The user-supplied preconditioner setup function PSETFUN
-%   is to evaluate and preprocess any Jacobian-related data
-%   needed by the preconditioner solve function PSOLFUN.
-%   This might include forming a crude approximate Jacobian,
-%   and performing an LU factorization on the resulting
-%   approximation to M.  This function will not be called in
-%   advance of every call to PSOLFUN, but instead will be called
-%   only as often as necessary to achieve convergence within the
-%   Newton iteration.  If the PSOLFUN function needs no
-%   preparation, the PSETFUN function need not be provided.
-%
-%   For greater efficiency, the PSETFUN function may save
-%   Jacobian-related data and reuse it, rather than generating it
-%   from scratch.  In this case, it should use the input flag JOK
-%   to decide whether to recompute the data, and set the output
-%   flag JCUR accordingly.
-%
-%   Each call to the PSETFUN function is preceded by a call to
-%   ODEFUN with the same (t,y) arguments.  Thus the PSETFUN
-%   function can use any auxiliary data that is computed and
-%   saved by the ODEFUN function and made accessible to PSETFUN.
-%
-%   The function PSETFUN must be defined as 
-%        FUNCTION [JCUR, FLAG] = PSETFUN(T,Y,FY,JOK,GAMMA)
-%   and must return a logical flag JCUR (true if Jacobian information
-%   was recomputed and false if saved data was reused). If PSETFUN
-%   was successful, it must return FLAG=0. For a recoverable error (in    
-%   which case the setup will be retried) it must set FLAG to a positive
-%   integer value. If an unrecoverable error occurs, it must set FLAG
-%   to a negative value, in which case the integration will be halted.
-%   The input argument FY contains the current value of f(t,y).
-%   If the input logical flag JOK is false, it means that
-%   Jacobian-related data must be recomputed from scratch. If it is true,
-%   it means that Jacobian data, if saved from the previous PSETFUN call
-%   can be reused (with the current value of GAMMA).
-%
-%   If a user data structure DATA was specified in CVodeInit, then
-%   PSETFUN must be defined as
-%        FUNCTION [JCUR, FLAG, NEW_DATA] = PSETFUN(T,Y,FY,JOK,GAMMA,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the flags JCUR
-%   and FLAG, the PSETFUN function must also set NEW_DATA. Otherwise, it 
-%   should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead
-%   to unnecessary copying).
-%
-%   See also CVPrecSolveFn, CVodeSetOptions
-%
-%   NOTE: PSETFUN is specified through the property PrecSetupFn to
-%   CVodeSetOptions and is used only if the property LinearSolver was 
-%   set to 'GMRES', 'BiCGStab', or 'TFQMR' and if the property PrecType
-%   is not 'None'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVPrecSetupFnB.m b/sundialsTB/cvodes/function_types/CVPrecSetupFnB.m
deleted file mode 100644
index aaeaa8b..0000000
--- a/sundialsTB/cvodes/function_types/CVPrecSetupFnB.m
+++ /dev/null
@@ -1,53 +0,0 @@
-%CVPrecSetupFnB - type for user provided preconditioner setup function for backward problems.
-%
-%   The user-supplied preconditioner setup function PSETFUN and
-%   the user-supplied preconditioner solve function PSOLFUN
-%   together must define left and right preconditoner matrices
-%   P1 and P2 (either of which may be trivial), such that the
-%   product P1*P2 is an approximation to the Newton matrix
-%   M = I - gamma*J.  Here J is the system Jacobian J = df/dy,
-%   and gamma is a scalar proportional to the integration step
-%   size h.  The solution of systems P z = r, with P = P1 or P2,
-%   is to be carried out by the PrecSolve function, and PSETFUN
-%   is to do any necessary setup operations.
-%
-%   The user-supplied preconditioner setup function PSETFUN
-%   is to evaluate and preprocess any Jacobian-related data
-%   needed by the preconditioner solve function PSOLFUN.
-%   This might include forming a crude approximate Jacobian,
-%   and performing an LU factorization on the resulting
-%   approximation to M.  This function will not be called in
-%   advance of every call to PSOLFUN, but instead will be called
-%   only as often as necessary to achieve convergence within the
-%   Newton iteration.  If the PSOLFUN function needs no
-%   preparation, the PSETFUN function need not be provided.
-%
-%   For greater efficiency, the PSETFUN function may save
-%   Jacobian-related data and reuse it, rather than generating it
-%   from scratch.  In this case, it should use the input flag JOK
-%   to decide whether to recompute the data, and set the output
-%   flag JCUR accordingly.
-%
-%   Each call to the PSETFUN function is preceded by a call to
-%   ODEFUN with the same (t,y) arguments.  Thus the PSETFUN
-%   function can use any auxiliary data that is computed and
-%   saved by the ODEFUN function and made accessible to PSETFUN.
-%
-%
-%   The function PSETFUNB must be defined either as
-%        FUNCTION [JCURB, FLAG] = PSETFUNB(T,Y,YB,FYB,JOK,GAMMAB)
-%   or as
-%        FUNCTION [JCURB, FLAG, NEW_DATA] = PSETFUNB(T,Y,YB,FYB,JOK,GAMMAB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the flags JCURB and FLAG.
-%
-%   See also CVPrecSolveFnB, CVodeSetOptions
-%
-%   NOTE: PSETFUNB is specified through the property PrecSetupFn to
-%   CVodeSetOptions and is used only if the property LinearSolver was 
-%   set to 'GMRES', 'BiCGStab', or 'TFQMR' and if the property PrecType
-%   is not 'None'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2012/03/20 21:08:32 $
diff --git a/sundialsTB/cvodes/function_types/CVPrecSolveFn.m b/sundialsTB/cvodes/function_types/CVPrecSolveFn.m
deleted file mode 100644
index f2285df..0000000
--- a/sundialsTB/cvodes/function_types/CVPrecSolveFn.m
+++ /dev/null
@@ -1,35 +0,0 @@
-%CVPrecSolveFn - type for user provided preconditioner solve function.
-%
-%   The user-supplied preconditioner solve function PSOLFN
-%   is to solve a linear system P z = r in which the matrix P is
-%   one of the preconditioner matrices P1 or P2, depending on the
-%   type of preconditioning chosen.
-%
-%   The function PSOLFUN must be defined as 
-%        FUNCTION [Z, FLAG] = PSOLFUN(T,Y,FY,R)
-%   and must return a vector Z containing the solution of Pz=r.
-%   If PSOLFUN was successful, it must return FLAG=0. For a recoverable 
-%   error (in which case the step will be retried) it must set FLAG to a 
-%   positive value. If an unrecoverable error occurs, it must set FLAG
-%   to a negative value, in which case the integration will be halted.
-%   The input argument FY contains the current value of f(t,y).
-%
-%   If a user data structure DATA was specified in CVodeInit, then
-%   PSOLFUN must be defined as
-%        FUNCTION [Z, FLAG, NEW_DATA] = PSOLFUN(T,Y,FY,R,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector Z and
-%   the flag FLAG, the PSOLFUN function must also set NEW_DATA. Otherwise,
-%   it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would
-%   lead to unnecessary copying).
-%
-%   See also CVPrecSetupFn, CVodeSetOptions
-%
-%   NOTE: PSOLFUN is specified through the property PrecSolveFn to 
-%   CVodeSetOptions and is used only if the property LinearSolver was
-%   set to 'GMRES', 'BiCGStab', or 'TFQMR' and if the property PrecType
-%   is not 'None'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVPrecSolveFnB.m b/sundialsTB/cvodes/function_types/CVPrecSolveFnB.m
deleted file mode 100644
index e10943c..0000000
--- a/sundialsTB/cvodes/function_types/CVPrecSolveFnB.m
+++ /dev/null
@@ -1,25 +0,0 @@
-%CVPrecSolveFnB - type for user provided preconditioner solve function for backward problems.
-%
-%   The user-supplied preconditioner solve function PSOLFN
-%   is to solve a linear system P z = r in which the matrix P is
-%   one of the preconditioner matrices P1 or P2, depending on the
-%   type of preconditioning chosen.
-%
-%   The function PSOLFUNB must be defined either as
-%        FUNCTION [ZB, FLAG] = PSOLFUNB(T,Y,YB,FYB,RB)
-%   or as
-%        FUNCTION [ZB, FLAG, NEW_DATA] = PSOLFUNB(T,Y,YB,FYB,RB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the vector ZB and the
-%   flag FLAG.
-%
-%   See also CVPrecSetupFnB, CVodeSetOptions
-%
-%   NOTE: PSOLFUNB is specified through the property PrecSolveFn to 
-%   CVodeSetOptions and is used only if the property LinearSolver was
-%   set to 'GMRES', 'BiCGStab', or 'TFQMR' and if the property PrecType
-%   is not 'None'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVQuadRhsFn.m b/sundialsTB/cvodes/function_types/CVQuadRhsFn.m
deleted file mode 100644
index cbe4071..0000000
--- a/sundialsTB/cvodes/function_types/CVQuadRhsFn.m
+++ /dev/null
@@ -1,24 +0,0 @@
-%CVQuadRhsFn - type for user provided quadrature RHS function.
-%
-%   The function ODEQFUN must be defined as 
-%        FUNCTION [YQD, FLAG] = ODEQFUN(T,Y)
-%   and must return a vector YQD corresponding to fQ(t,y), the integrand
-%   for the integral to be evaluated.
-%   If a user data structure DATA was specified in CVodeInit, then
-%   ODEQFUN must be defined as
-%        FUNCTION [YQD, FLAG, NEW_DATA] = ODEQFUN(T,Y,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector YQD,
-%   the ODEQFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function ODEQFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeQuadInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVQuadRhsFnB.m b/sundialsTB/cvodes/function_types/CVQuadRhsFnB.m
deleted file mode 100644
index 46cab29..0000000
--- a/sundialsTB/cvodes/function_types/CVQuadRhsFnB.m
+++ /dev/null
@@ -1,20 +0,0 @@
-%CVQuadRhsFnB - type for user provided quadrature RHS function for backward problems
-%
-%   The function ODEQFUNB must be defined either as
-%        FUNCTION [YQBD, FLAG] = ODEQFUNB(T,Y,YB)
-%   or as
-%        FUNCTION [YQBD, FLAG, NEW_DATA] = ODEQFUNB(T,Y,YB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the vector YQBD
-%   corresponding to fQB(t,y,yB), the integrand for the integral to be 
-%   evaluated on the backward phase.
-%
-%   The function ODEQFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeQuadInitB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVRhsFn.m b/sundialsTB/cvodes/function_types/CVRhsFn.m
deleted file mode 100644
index a4e5c37..0000000
--- a/sundialsTB/cvodes/function_types/CVRhsFn.m
+++ /dev/null
@@ -1,24 +0,0 @@
-%CVRhsFn - type for user provided RHS function
-%
-%   The function ODEFUN must be defined as 
-%        FUNCTION [YD, FLAG] = ODEFUN(T,Y)
-%   and must return a vector YD corresponding to f(t,y).
-%   If a user data structure DATA was specified in CVodeInit, then
-%   ODEFUN must be defined as
-%        FUNCTION [YD, FLAG, NEW_DATA] = ODEFUN(T,Y,DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then, besides setting the vector YD,
-%   the ODEFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function ODEFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeInit
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVRhsFnB.m b/sundialsTB/cvodes/function_types/CVRhsFnB.m
deleted file mode 100644
index bf3bd74..0000000
--- a/sundialsTB/cvodes/function_types/CVRhsFnB.m
+++ /dev/null
@@ -1,20 +0,0 @@
-%CVRhsFnB - type for user provided RHS function for backward problems.
-%
-%   The function ODEFUNB must be defined either as
-%        FUNCTION [YBD, FLAG] = ODEFUNB(T,Y,YB)
-%   or as
-%        FUNCTION [YBD, FLAG, NEW_DATA] = ODEFUNB(T,Y,YB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   CVodeInit. In either case, it must return the vector YBD
-%   corresponding to fB(t,y,yB).
-%
-%   The function ODEFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeInitB
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVRootFn.m b/sundialsTB/cvodes/function_types/CVRootFn.m
deleted file mode 100644
index 0dda7e6..0000000
--- a/sundialsTB/cvodes/function_types/CVRootFn.m
+++ /dev/null
@@ -1,26 +0,0 @@
-%CVRootFn - type for user provided root-finding function.
-%
-%   The function ROOTFUN must be defined as 
-%        FUNCTION [G, FLAG] = ROOTFUN(T,Y)
-%   and must return a vector G corresponding to g(t,y).
-%   If a user data structure DATA was specified in CVodeInit, then
-%   ROOTFUN must be defined as
-%        FUNCTION [G, FLAG, NEW_DATA] = ROOTFUN(T,Y,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector G,
-%   the ROOTFUN function must also set NEW_DATA. Otherwise, it should 
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function ROOTFUN must set FLAG=0 if successful, or FLAG~=0 if
-%   a failure occurred.
-%
-%   See also CVodeSetOptions
-%
-%   NOTE: ROOTFUN is specified through the RootsFn property in 
-%   CVodeSetOptions and is used only if the property NumRoots is a
-%   positive integer.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/cvodes/function_types/CVSensRhsFn.m b/sundialsTB/cvodes/function_types/CVSensRhsFn.m
deleted file mode 100644
index 076801e..0000000
--- a/sundialsTB/cvodes/function_types/CVSensRhsFn.m
+++ /dev/null
@@ -1,26 +0,0 @@
-%CVSensRhsFn - type for user provided sensitivity RHS function.
-%
-%   The function ODESFUN must be defined as 
-%        FUNCTION [YSD, FLAG] = ODESFUN(T,Y,YD,YS)
-%   and must return a matrix YSD corresponding to fS(t,y,yS).
-%   If a user data structure DATA was specified in CVodeInit, then
-%   ODESFUN must be defined as
-%        FUNCTION [YSD, FLAG, NEW_DATA] = ODESFUN(T,Y,YD,YS,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix YSD,
-%   the ODESFUN function must also set NEW_DATA. Otherwise, it should
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function ODESFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also CVodeSetFSAOptions
-%
-%   NOTE: ODESFUN is specified through the property FSARhsFn to 
-%         CVodeSetFSAOptions. 
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 20:44:05 $
diff --git a/sundialsTB/idas/Contents.m b/sundialsTB/idas/Contents.m
deleted file mode 100644
index 2a7c375..0000000
--- a/sundialsTB/idas/Contents.m
+++ /dev/null
@@ -1,113 +0,0 @@
-% IDAS, a DAE integrator with sensitivity analysis capabilities
-%
-% The Matlab interface to the SUNDIALS solver IDAS provides access
-% to all functionality of the underlying solver, including IVP simulation
-% and sensitvity analysis (both forward and adjoint).
-%
-% The interface consists of several user-callable functions. In addition,
-% the user must provide several required and optional user-supplied 
-% functions which define the problem to be solved. The user-callable 
-% functions and the types of user-supplied functions are listed below.
-% For completness, some functions appear more than once.
-%
-% Functions for DAE integration
-%
-%  IDASetOptions     - create an options structure for IDAS.
-%  IDASetQuadOptions - create an options structure for quadrature integration.
-%  IDAInit           - allocate and initialize memory for IDAS.
-%  IDAQuadInit       - allocate and initialize memory for quadrature integration.
-%  IDAReInit         - reinitialize memory for IDAS.
-%  IDAQuadReInit     - reinitialize memory for quadrature integration.
-%  IDACalcIC         - compute consistent initial conditions.
-%  IDASolve          - integrate the DAE problem.
-%  IDAGetStats       - return statistics for the IDAS solver.
-%  IDAGet            - extract data from IDAS memory.
-%  IDAFree           - deallocate memory for the IDAS solver.
-%
-% Functions for forward sensitivity analysis
-%
-%  IDASetOptions     - create an options structure for an DAE problem.
-%  IDAQuadSetOptions - create an options structure for quadrature integration.
-%  IDASensSetOptions - create an options structure for FSA.
-%  IDAInit           - allocate and initialize memory for IDAS.
-%  IDAQuadInit       - allocate and initialize memory for quadrature integration.
-%  IDASensInit       - allocate and initialize memory for FSA.
-%  IDAReInit         - reinitialize memory for IDAS.
-%  IDAQuadReInit     - reinitialize memory for quadrature integration.
-%  IDASensReInit     - reinitialize memory for FSA.
-%  IDASensToggleOff  - temporarily deactivates FSA.
-%  IDASetIC          - compute consistent initial conditions.
-%  IDASolve          - integrate the DAE problem.
-%  IDAGetStats       - return statistics for the IDAS solver.
-%  IDAGet            - extract data from IDAS memory.
-%  IDAFree           - deallocate memory for the IDAS solver.
-%
-% Functions for adjoint sensitivity analysis
-%
-%  IDASetOptions     - create an options structure for an DAE problem.
-%  IDAQuadSetOptions - create an options structure for quadrature integration.
-%  IDAInit           - allocate and initialize memory for the forward problem.
-%  IDAQuadInit       - allocate and initialize memory for forward quadrature integration.
-%  IDAQuadReInit     - reinitialize memory for forward quadrature integration.
-%  IDAReInit         - reinitialize memory for the forward problem.
-%  IDAAdjInit        - allocate and initialize memory for ASA.
-%  IDAInitB          - allocate and initialize a backward problem.
-%  IDAAdjReInit      - reinitialize memory for ASA.
-%  IDAReInitB        - reinitialize a backward problem.
-%  IDASetIC          - compute consistent initial conditions.
-%  IDASetICb         - compute consistent final conditions for backward problem.
-%  IDASolve          - integrate the forward DAE problem.
-%  IDASolveB         - integrate the backward problems.
-%  IDAGetStats       - return statistics for the integration of the forward problem.
-%  IDAGetStatsB      - return statistics for the integration of a backward problem.
-%  IDAGet            - extract data from IDAS memory.
-%  IDAFree           - deallocate memory for the IDAS solver.
-%
-% User-supplied function types for forward problems
-%
-%   IDAResFn            -  DAE residual function
-%   IDARootFn           -  root-finding function 
-%   IDAQuadRhsFn        -  quadrature RHS function
-%   IDASensResFn        -  sensitivity DAE residual function
-%   IDADenseJacFn       -  dense Jacobian function
-%   IDABandJacFn        -  banded Jacobian function
-%   IDAJacTimesVecFn    -  Jacobian times vector function
-%   IDAPrecSetupFn      -  preconditioner setup function
-%   IDAPrecSolveFn      -  preconditioner solve function
-%   IDAGlocalFn         -  RHS approximation function (BBDPre)
-%   IDAGcomFn           -  communication function (BBDPre)
-%   IDAMonitorFn        -  monitoring function
-%
-% User-supplied function types for backward problems
-%
-%   IDAResFnB           -  backard DAE residual function
-%   IDAQuadRhsFnB       -  quadrature RHS function
-%   IDADenseJacFnB      -  dense Jacobian function
-%   IDABandJacFnB       -  banded Jacobian function
-%   IDAJacTimesVecFnB   -  Jacobian times vector function
-%   IDAPrecSetupFnB     -  preconditioner setup function
-%   IDAPrecSolveFnB     -  preconditioner solve function
-%   IDAGlocalFnB        -  RHS approximation function (BBDPre)
-%   IDAGcomFnB          -  communication function (BBDPre)
-%   IDAMonitorFnB       -  monitoring function
-%
-% Serial examples provided with the toolbox
-%
-%   midasRoberts_dns      -  chemical kinetics problem (index-1 DAE)
-%   midasRoberts_ASAi_dns -  ASA for the robertson problem
-%   midasBruss_dns        -  2D, 2-species, time dependent PDE (index-1 DAE)
-%   midasBruss_ASA_dns    -  ASA for the brusselator example
-%   midasHeat2D_bnd       -  2D heat problem
-%   midasPendI1_dns       -  simple pendulum example (index-1 DAE)
-%   midasPendI2_dns       -  simple pendulum example (stabilized index-2 DAE)
-%   midasSlCrank_dns      -  slider-crank example (stabilized index-2 DAE)
-%   midasSlCrank_FSA_dns  -  FSA for the slider-crank example
-%   midasReInit_dns       -  integration over solution discontinuities
-%
-% Parallel examples provided with the toolbox
-%
-%    N/A
-% Use the mpirun function to run any of the parallel examples
-%
-% See also nvector, putils
-
diff --git a/sundialsTB/idas/IDAAdjInit.m b/sundialsTB/idas/IDAAdjInit.m
deleted file mode 100644
index 482069e..0000000
--- a/sundialsTB/idas/IDAAdjInit.m
+++ /dev/null
@@ -1,23 +0,0 @@
-function status = IDAAdjInit(steps, interp)
-%IDAAdjInit allocates and initializes memory for ASA with IDAS.
-%
-%   Usage: IDAAdjInit(STEPS, INTEPR) 
-%
-%   STEPS    specifies the (maximum) number of integration steps between two 
-%            consecutive check points.
-%   INTERP   Specifies the type of interpolation used for estimating the forward 
-%            solution during the backward integration phase. INTERP should be
-%            'Hermite', indicating cubic Hermite interpolation, or 'Polynomial',
-%            indicating variable order polynomial interpolation.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 4;
-
-if nargin ~= 2
-  error('Wrong number of input arguments');
-end
-
-status = idm(mode,steps,interp);
diff --git a/sundialsTB/idas/IDAAdjReInit.m b/sundialsTB/idas/IDAAdjReInit.m
deleted file mode 100644
index 294e417..0000000
--- a/sundialsTB/idas/IDAAdjReInit.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function status = IDAAdjReInit()
-%IDAAdjReInit re-initializes memory for ASA with CVODES.
-%
-%   Usage: IDAAdjReInit
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 14;
-
-status = idm(mode);
diff --git a/sundialsTB/idas/IDACalcIC.m b/sundialsTB/idas/IDACalcIC.m
deleted file mode 100644
index 573a1c5..0000000
--- a/sundialsTB/idas/IDACalcIC.m
+++ /dev/null
@@ -1,73 +0,0 @@
-function [status, varargout] = IDACalcIC(tout,icmeth)
-%IDACalcIC computes consistent initial conditions
-%
-%   Usage: STATUS = IDACalcIC ( TOUT, ICMETH )
-%          [STATUS, YY0, YP0] = IDACalcIC ( TOUT, ICMETH )
-%
-%   IDACalcIC corrects the guess for initial conditions passed
-%   to IDAInit or IDAReInit so that the algebraic constraints
-%   are satisfied. 
-%
-%   The argument TOUT is the first value of t at which a soluton will be      
-%   requested (from IDASolve). This is needed here to determine the 
-%   direction of integration and rough scale in the independent variable. 
-%
-%   If ICMETH is 'FindAlgebraic', then IDACalcIC attempts to compute 
-%   the algebraic components of y and differential components of y', 
-%   given the differential components of y.  
-%   This option requires that the vector id was set through IDASetOptions  
-%   specifying the differential and algebraic components.
-%   If ICMETH is 'FindAll', then IDACalcIC attempts to compute all  
-%   components of y, given y'.  In this case, id is not required. 
-%
-%   On return, STATUS is one of the following:
-% SUCCESS             IDACalcIC was successful.  The corrected   
-%                     initial value vectors are in y0 and yp0.
-% IDA_MEM_NULL        The argument ida_mem was NULL.             
-% IDA_ILL_INPUT       One of the input arguments was illegal.    
-%                     See printed message.                       
-% IDA_LINIT_FAIL      The linear solver's init routine failed.   
-% IDA_BAD_EWT         Some component of the error weight vector  
-%                     is zero (illegal), either for the input    
-%                     value of y0 or a corrected value.          
-% IDA_RES_FAIL        The user's residual routine returned 
-%                     a non-recoverable error flag.              
-% IDA_FIRST_RES_FAIL  The user's residual routine returned 
-%                     a recoverable error flag on the first call,
-%                     but IDACalcIC was unable to recover.       
-% IDA_LSETUP_FAIL     The linear solver's setup routine had a    
-%                     non-recoverable error.                     
-% IDA_LSOLVE_FAIL     The linear solver's solve routine had a    
-%                     non-recoverable error.                     
-% IDA_NO_RECOVERY     The user's residual routine, or the linear 
-%                     solver's setup or solve routine had a      
-%                     recoverable error, but IDACalcIC was       
-%                     unable to recover.                         
-% IDA_CONSTR_FAIL     IDACalcIC was unable to find a solution    
-%                     satisfying the inequality constraints.     
-% IDA_LINESEARCH_FAIL The Linesearch algorithm failed to find a  
-%                     solution with a step larger than steptol   
-%                     in weighted RMS norm.
-% IDA_CONV_FAIL       IDACalcIC failed to get convergence of the 
-%                     Newton iterations.  
-%
-%   If the output arguments YY0 and YP0 are present, they will
-%   contain the consistent initial conditions.
-%
-%  See also: IDASetOptions, IDAInit, IDAReInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/08/21 17:38:42 $
-
-mode = 25;
-
-if nargout == 1
-  status = idm(mode, tout, icmeth);
-elseif nargout == 3
-  [status, yy, yp] = idm(mode, tout, icmeth);
-  varargout(1) = {yy};
-  varargout(2) = {yp};
-else
-  disp('IDACalcIC:: wrong number of output arguments');
-end
diff --git a/sundialsTB/idas/IDACalcICB.m b/sundialsTB/idas/IDACalcICB.m
deleted file mode 100644
index ca26b4b..0000000
--- a/sundialsTB/idas/IDACalcICB.m
+++ /dev/null
@@ -1,23 +0,0 @@
-function [status, varargout] = IDACalcICB(tout,icmeth)
-%IDACalcICB computes consistent initial conditions for the backward phase.
-%
-%   Usage: STATUS = IDACalcICB ( TOUTB, ICMETHB )
-%          [STATUS, YY0B, YP0B] = IDACalcIC ( TOUTB, ICMETHB )
-%
-%  See also: IDASetOptions, IDAInitB, IDAReInitB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2011/05/26 00:05:36 $
-
-mode = 26;
-
-if nargout == 1
-  status = idm(mode, tout, icmeth);
-elseif nargout == 3
-  [status, yy, yp] = idm(mode, tout, icmeth);
-  varargout(1) = {yy};
-  varargout(2) = {yp};
-else
-  disp('IDACalcICB:: wrong number of output arguments');
-end
diff --git a/sundialsTB/idas/IDAFree.m b/sundialsTB/idas/IDAFree.m
deleted file mode 100644
index aee3cf4..0000000
--- a/sundialsTB/idas/IDAFree.m
+++ /dev/null
@@ -1,11 +0,0 @@
-function [] = IDAFree()
-%IDAFree deallocates memory for the IDAS solver.
-%
-%   Usage:  IDAFree
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/08/21 17:38:42 $
-
-mode = 40;
-idm(mode);
diff --git a/sundialsTB/idas/IDAGet.m b/sundialsTB/idas/IDAGet.m
deleted file mode 100644
index 50cfd26..0000000
--- a/sundialsTB/idas/IDAGet.m
+++ /dev/null
@@ -1,36 +0,0 @@
-function [output, status] = IDAGet(key, varargin)
-%IDAGet extracts data from the IDAS solver memory.
-%
-%   Usage: RET = IDAGet ( KEY [, P1 [, P2] ... ]) 
-%
-%   IDAGet returns internal IDAS information based on KEY. For some values
-%   of KEY, additional arguments may be required and/or more than one output is
-%   returned.
-%
-%   KEY is a string and should be one of:
-%    o DerivSolution - Returns a vector containing the K-th order derivative
-%       of the solution at time T. The time T and order K must be passed through 
-%       the input arguments P1 and P2, respectively:
-%       DKY = IDAGet('DerivSolution', T, K)
-%    o ErrorWeights - Returns a vector containing the current error weights.
-%       EWT = IDAGet('ErrorWeights')
-%    o CheckPointsInfo - Returns an array of structures with check point information.
-%       CK = IDAGet('CheckPointInfo)
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2007/12/05 21:58:18 $
-
-mode = 32;
-
-if strcmp(key, 'DerivSolution')
-  t = varargin{1};
-  k = varargin{2};
-  [output, status] = idm(mode,1,t,k);
-elseif strcmp(key, 'ErrorWeights')
-  [output, status] = idm(mode,2);
-elseif strcmp(key, 'CheckPointsInfo')
-  [output, status] = idm(mode,4);
-else
-  error('IDAGet:: Unrecognized key');
-end
\ No newline at end of file
diff --git a/sundialsTB/idas/IDAGetStats.m b/sundialsTB/idas/IDAGetStats.m
deleted file mode 100644
index 6892ba7..0000000
--- a/sundialsTB/idas/IDAGetStats.m
+++ /dev/null
@@ -1,80 +0,0 @@
-function [si, status] = IDAGetStats()
-%IDAGetStats returns run statistics for the IDAS solver.
-%
-%   Usage: STATS = IDAGetStats
-%
-%Fields in the structure STATS
-%
-%o nst      - number of integration steps
-%o nre      - number of residual function evaluations
-%o nsetups  - number of linear solver setup calls
-%o netf     - number of error test failures
-%o nni      - number of nonlinear solver iterations
-%o ncfn     - number of convergence test failures
-%o qlast    - last method order used
-%o qcur     - current method order
-%o h0used   - actual initial step size used
-%o hlast    - last step size used
-%o hcur     - current step size
-%o tcur     - current time reached by the integrator
-%o RootInfo - strucutre with rootfinding information
-%o QuadInfo - structure with quadrature integration statistics
-%o LSInfo   - structure with linear solver statistics
-%o FSAInfo  - structure with forward sensitivity solver statistics
-%
-%If rootfinding was requested, the structure RootInfo has the following fields
-%
-%o nge   - number of calls to the rootfinding function
-%o roots - array of integers (a value of 1 in the i-th component means that the
-%          i-th rootfinding function has a root (upon a return with status=2 from
-%          IDASolve).
-%
-%If quadratures were present, the structure QuadInfo has the following fields
-%
-%o nfQe  - number of quadrature integrand function evaluations
-%o netfQ - number of error test failures for quadrature variables
-%
-%The structure LSinfo has different fields, depending on the linear solver used.
-%
-%  Fields in LSinfo for the 'Dense' linear solver
-%
-%o name - 'Dense'
-%o njeD - number of Jacobian evaluations
-%o nreD - number of residual function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'Band' linear solver
-%
-%o name - 'Band'
-%o njeB - number of Jacobian evaluations
-%o nreB - number of residual function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'GMRES' and 'BiCGStab' linear solvers
-%
-%o name  - 'GMRES' or 'BiCGStab'
-%o nli   - number of linear solver iterations
-%o npe   - number of preconditioner setups
-%o nps   - number of preconditioner solve function calls
-%o ncfl  - number of linear system convergence test failures
-%o njeSG - number of Jacobian-vector product evaluations
-%o nreSG - number of residual function evaluations for difference-quotient
-%          Jacobian-vector product approximation
-%
-%If forward sensitivities were computed, the structure FSAInfo has the 
-%following fields
-%
-%o nrSe      - number of sensitivity residual evaluations
-%o nreS      - number of residual evaluations for difference-quotient
-%              sensitivity residual approximation
-%o nsetupsS  - number of linear solver setups triggered by sensitivity variables
-%o netfS     - number of error test failures for sensitivity variables
-%o nniS      - number of nonlinear solver iterations for sensitivity variables
-%o ncfnS     - number of convergence test failures due to sensitivity variables
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 30;
-[si, status] = idm(mode);
diff --git a/sundialsTB/idas/IDAGetStatsB.m b/sundialsTB/idas/IDAGetStatsB.m
deleted file mode 100644
index 4a9cc7c..0000000
--- a/sundialsTB/idas/IDAGetStatsB.m
+++ /dev/null
@@ -1,66 +0,0 @@
-function [si, status] = IDAGetStatsB(idxB)
-%IDAGetStatsB returns run statistics for the backward IDAS solver.
-%
-%   Usage: STATS = IDAGetStatsB(IDXB)
-%
-%   IDXB is the index of the backward problem, returned by IDAInitB.
-%
-%Fields in the structure STATS
-%
-%o nst - number of integration steps
-%o nre - number of residual function evaluations
-%o nsetups - number of linear solver setup calls
-%o netf - number of error test failures
-%o nni - number of nonlinear solver iterations
-%o ncfn - number of convergence test failures
-%o qlast - last method order used
-%o qcur - current method order
-%o h0used - actual initial step size used
-%o hlast - last step size used
-%o hcur - current step size
-%o tcur - current time reached by the integrator
-%o QuadInfo - structure with quadrature integration statistics
-%o LSInfo - structure with linear solver statistics
-%
-%The structure LSinfo has different fields, depending on the linear solver used.
-%
-%If quadratures were present, the structure QuadInfo has the following fields
-%
-%o nfQe - number of quadrature integrand function evaluations
-%o netfQ - number of error test failures for quadrature variables
-%
-%  Fields in LSinfo for the 'Dense' linear solver
-%
-%o name - 'Dense'
-%o njeD - number of Jacobian evaluations
-%o nreD - number of residual function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'Band' linear solver
-%
-%o name - 'Band'
-%o njeB - number of Jacobian evaluations
-%o nreB - number of residual function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'GMRES' and 'BiCGStab' linear solvers
-%
-%o name - 'GMRES' or 'BiCGStab'
-%o nli - number of linear solver iterations
-%o npe - number of preconditioner setups
-%o nps - number of preconditioner solve function calls
-%o ncfl - number of linear system convergence test failures
-%o njeSG - number of Jacobian-vector product evaluations
-%o nreSG -  number of residual function evaluations for difference-quotient
-%          Jacobian-vector product approximation
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2007/12/05 21:58:18 $
-
-mode = 31;
-
-if nargin ~= 1
-  error('Wrong number of input arguments');
-end
-[si, status] = idm(mode, idxB-1);
diff --git a/sundialsTB/idas/IDAInit.m b/sundialsTB/idas/IDAInit.m
deleted file mode 100644
index b90b6a1..0000000
--- a/sundialsTB/idas/IDAInit.m
+++ /dev/null
@@ -1,31 +0,0 @@
-function status = IDAInit(fct,t0,yy0,yp0,options)
-%IDAInit allocates and initializes memory for IDAS.
-%
-%   Usage: IDAInit ( DAEFUN, T0, YY0, YP0 [, OPTIONS ] ) 
-%
-%   DAEFUN   is a function defining the DAE residual: f(t,yy,yp).
-%            This function must return a vector containing the current 
-%            value of the residual.
-%   T0       is the initial value of t.
-%   YY0      is the initial condition vector y(t0).  
-%   YP0      is the initial condition vector y'(t0).  
-%   OPTIONS  is an (optional) set of integration options, created with
-%            the IDASetOptions function. 
-%
-%  See also: IDASetOptions, IDAResFn 
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:05:36 $
-
-mode = 1;
-
-if nargin < 4
-  error('Too few input arguments');
-end
-
-if nargin < 5
-  options = [];
-end
-
-status = idm(mode, fct, t0, yy0, yp0, options);
diff --git a/sundialsTB/idas/IDAInitB.m b/sundialsTB/idas/IDAInitB.m
deleted file mode 100644
index 01d6373..0000000
--- a/sundialsTB/idas/IDAInitB.m
+++ /dev/null
@@ -1,37 +0,0 @@
-function [idxB, status] = IDAInitB(fctB, tB0, yyB0, ypB0, optionsB)
-%IDAInitB allocates and initializes backward memory for CVODES.
-%
-%   Usage:   IDXB = IDAInitB ( DAEFUNB, TB0, YYB0, YPB0 [, OPTIONSB] )
-%
-%   DAEFUNB  is a function defining the adjoint DAE: F(t,y,y',yB,yB')=0
-%            This function must return a vector containing the current 
-%            value of the adjoint DAE residual.
-%   TB0      is the final value of t.
-%   YYB0     is the final condition vector yB(tB0).  
-%   YPB0     is the final condition vector yB'(tB0).  
-%   OPTIONSB is an (optional) set of integration options, created with
-%            the IDASetOptions function. 
-%
-%   IDAInitB returns the index IDXB associated with this backward
-%   problem. This index must be passed as an argument to any subsequent
-%   functions related to this backward problem.
-%
-%   See also: IDASetOptions, IDAResFnB
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 5;
-
-if nargin < 4
-  error('Too few input arguments');
-end
-
-if nargin < 5
-  optionsB = [];
-end
-
-[idxB, status] = idm(mode, fctB, tB0, yyB0, ypB0, optionsB);
-idxB = idxB+1;
diff --git a/sundialsTB/idas/IDAMonitor.m b/sundialsTB/idas/IDAMonitor.m
deleted file mode 100644
index d1908b1..0000000
--- a/sundialsTB/idas/IDAMonitor.m
+++ /dev/null
@@ -1,796 +0,0 @@
-function [new_data] = IDAMonitor(call, T, Y, YQ, YS, data)
-%IDAMonitor is the default IDAS monitoring function.
-%   To use it, set the Monitor property in IDASetOptions to
-%   'IDAMonitor' or to @IDAMonitor and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to IDASetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see IDAGetStats)
-%     o mode [ {'graphical'} | 'text' | 'both' ] 
-%         In graphical mode, plot the evolutions of the above quantities.
-%         In text mode, print a table.
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o sensi [ true | {false} ]
-%         If true and if FSA is enabled, plot sensitivity components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also IDASetOptions, IDAMonitorFn
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to IDASetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.4 $Date: 2009/04/22 04:25:06 $
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.grph
-      if data.stats | data.cntr
-        data.hfg = figure;
-      end
-%     Number of subplots in figure hfg
-      if data.stats
-        data.npg = data.npg + 2;
-      end
-      if data.cntr
-        data.npg = data.npg + 1;
-      end
-    end
-    
-    if data.text
-      if data.cntr | data.stats
-        data.hft = figure;
-      end
-    end
-
-    if data.sol | data.sensi
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y and YS for additional initializations
-  
-  if data.first
-
-    if isempty(YS)
-      data.sensi = false;
-    end
-    
-    if data.sol | data.sensi
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-      if data.sensi
-        data.Ns = size(YS,2);
-        data.ys = zeros(data.N, data.Ns, data.updt);
-        data.nps = data.nps + data.Ns;
-      end
-      
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  Ns   = data.Ns;
-  y    = data.y;
-  ys   = data.ys;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = IDAGetStats;
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-  if data.sensi
-    for k = 1:Ns
-      for j = 1:N
-        ys(j,k,n) = YS(data.select(j),k);
-      end
-    end
-  end
-  
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if (data.stats | data.cntr) & data.text
-      text_init(n, hft, data.stats, data.cntr, ...
-                t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol | data.sensi
-      sol_init(n, hfs, nps, data.sol, data.sensi,  ...
-               N, Ns, t, y, ys);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if (data.stats | data.cntr) & data.text
-      text_update(n, hft, data.stats, data.cntr, ...
-                  t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, data.sensi, N, Ns, t, y, ys);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr) & data.grph
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol | data.sensi
-      sol_final(hfs, nps, data.sol, data.sensi, N, Ns);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.ys   = ys;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'mode')
-  data.mode = 'graphical';
-end
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'sensi')
-  data.sensi = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-data.grph = true;
-data.text = true;
-if strcmp(data.mode,'graphical')
-  data.text = false;
-end
-if strcmp(data.mode,'text')
-  data.grph = false;
-end
-
-if ~data.sol & ~data.sensi
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.Ns = 0;
-data.y = 0;
-data.ys = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-fig_name = 'IDAS run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hfg);
-set(hfg,'Name',fig_name);
-set(hfg,'color',[1 1 1]);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '\rightarrow   t   \rightarrow';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') abs(h(1:n))];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') q(1:n)];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-% Attention: Children are loaded in reverse order!
-  xd = [get(hc(1),'XData') t(1:n)];
-  yd = [get(hc(1),'YData') ncfn(1:n)];
-  set(hc(1), 'XData', xd, 'YData', yd);
-  yd = [get(hc(2),'YData') netf(1:n)];
-  set(hc(2), 'XData', xd, 'YData', yd);
-  yd = [get(hc(3),'YData') nni(1:n)];
-  set(hc(3), 'XData', xd, 'YData', yd);
-  yd = [get(hc(4),'YData') nfe(1:n)];
-  set(hc(4), 'XData', xd, 'YData', yd);
-  yd = [get(hc(5),'YData') nst(1:n)];
-  set(hc(5), 'XData', xd, 'YData', yd);
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = text_init(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-fig_name = 'IDAS run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hft);
-set(hft,'Name',fig_name);
-set(hft,'color',[1 1 1]);
-set(hft,'MenuBar','none');
-set(hft,'Resize','off');
-
-% Create text box
-
-margins=[10 10 50 50]; % left, right, top, bottom
-pos=get(hft,'position');
-tbpos=[margins(1) margins(4) pos(3)-margins(1)-margins(2) ...
-       pos(4)-margins(3)-margins(4)];
-tbpos(tbpos<1)=1;
-
-htb=uicontrol(hft,'style','listbox','position',tbpos,'tag','textbox');
-set(htb,'BackgroundColor',[1 1 1]);
-set(htb,'SelectionHighlight','off');
-set(htb,'FontName','courier');
-
-% Create table head
-
-tpos = [tbpos(1) tbpos(2)+tbpos(4)+10 tbpos(3) 20];
-ht=uicontrol(hft,'style','text','position',tpos,'tag','text');
-set(ht,'BackgroundColor',[1 1 1]);
-set(ht,'HorizontalAlignment','left');
-set(ht,'FontName','courier');
-newline = '   time         step      order  |    nst   nfe   nni  netf  ncfn';
-set(ht,'String',newline);
-
-% Create OK button
-  
-bsize=[60,28];
-badjustpos=[0,25];
-bpos=[pos(3)/2-bsize(1)/2+badjustpos(1) -bsize(2)/2+badjustpos(2)...
-      bsize(1) bsize(2)];
-bpos=round(bpos);
-bpos(bpos<1)=1;
-hb=uicontrol(hft,'style','pushbutton','position',bpos,...
-             'string','Close','tag','okaybutton');
-set(hb,'callback','close');
-
-% Save handles
-
-handles=guihandles(hft);
-guidata(hft,handles);
-
-for i = 1:n
-  newline = '';
-  if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = text_update(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-figure(hft);
-
-handles=guidata(hft);
-
-for i = 1:n
-   if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-fig_name = 'IDAS solution';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-
-figure(hfs);
-set(hfs,'Name',fig_name);
-set(hfs,'color',[1 1 1]);
-
-% Time label
-
-tlab = '\rightarrow   t   \rightarrow';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-    hold on;
-      
-    ys_crt = ys(:,is,1:n);
-    for i = 1:N
-      hp = plot(t(1:n),ys_crt(i,1:n),'-');
-      ic = 1+(i-1)*floor(ncols/N);
-      set(hp,'Color',map(ic,:));
-    end
-    box on;
-    grid on;
-    xlabel(tlab);
-    str = sprintf('s_{%d}',is); ylabel(str);
-    str = sprintf('Sensitivity %d',is); title(str);
-    
-  end
-  
-end
-
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') t(1:n)];
-% Attention: Children are loaded in reverse order!
-  for i = 1:N
-    yd = [get(hc(i),'YData') y(N-i+1,1:n)];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-  
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    ys_crt = ys(:,is,:);
-    
-    hc = get(gca,'Children');
-    xd = [get(hc(1),'XData') t(1:n)];
-%   Attention: Children are loaded in reverse order!
-    for i = 1:N
-      yd = [get(hc(i),'YData') ys_crt(N-i+1,1:n)];
-      set(hc(i), 'XData', xd, 'YData', yd);
-    end
-    
-  end
-  
-end
-
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, sensi, N, Ns)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    hc = get(gca,'Children');
-    xd = get(hc(1),'XData');
-    set(gca,'XLim',sort([xd(1) xd(end)]));
-
-    ylim = get(gca,'YLim');
-    addon = 0.1*abs(ylim(2)-ylim(1));
-    ylim(1) = ylim(1) + sign(ylim(1))*addon;
-    ylim(2) = ylim(2) + sign(ylim(2))*addon;
-    set(gca,'YLim',ylim);
-  
-    for i = 1:N
-      cstring{i} = sprintf('s%d_{%d}',is,i);
-    end
-    legend(cstring);
-    
-  end
-  
-end
-
-drawnow
diff --git a/sundialsTB/idas/IDAMonitorB.m b/sundialsTB/idas/IDAMonitorB.m
deleted file mode 100644
index 776a540..0000000
--- a/sundialsTB/idas/IDAMonitorB.m
+++ /dev/null
@@ -1,697 +0,0 @@
-function [new_data] = IDAMonitorB(call, idxB, T, Y, YQ, data)
-%IDAMonitorB is the default IDAS monitoring function for backward problems.
-%   To use it, set the Monitor property in IDASetOptions to
-%   'IDAMonitorB' or to @IDAMonitorB and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to IDASetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see IDAGetStats)
-%     o mode [ {'graphical'} | 'text' | 'both' ] 
-%         In graphical mode, plot the evolutions of the above quantities.
-%         In text mode, print a table.
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also IDASetOptions, IDAMonitorFnB
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to IDASetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2009/04/22 04:25:06 $
-
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.grph
-      if data.stats | data.cntr
-        data.hfg = figure;
-      end
-%     Number of subplots in figure hfg
-      if data.stats
-        data.npg = data.npg + 2;
-      end
-      if data.cntr
-        data.npg = data.npg + 1;
-      end
-    end
-    
-    if data.text
-      if data.cntr | data.stats
-        data.hft = figure;
-      end
-    end
-
-    if data.sol
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y for additional initializations
-  
-  if data.first
-
-    if data.sol
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  y    = data.y;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = IDAGetStatsB(idxB);
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if (data.stats | data.cntr) & data.text
-      text_init(n, hft, data.stats, data.cntr, ...
-                t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol
-      sol_init(n, hfs, nps, data.sol, ...
-               N, t, y);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr) & data.grph
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if (data.stats | data.cntr) & data.text
-      text_update(n, hft, data.stats, data.cntr, ...
-                  t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, N, t, y);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr) & data.grph
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol
-      sol_final(hfs, nps, data.sol, N);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'mode')
-  data.mode = 'graphical';
-end
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-data.grph = true;
-data.text = true;
-if strcmp(data.mode,'graphical')
-  data.text = false;
-end
-if strcmp(data.mode,'text')
-  data.grph = false;
-end
-
-if ~data.sol
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.y = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-fig_name = 'IDAS run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hfg);
-set(hfg,'Name',fig_name);
-set(hfg,'color',[1 1 1]);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '\leftarrow   t   \leftarrow';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') abs(h(1:n))];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') t(1:n)];
-  yd = [get(hc,'YData') q(1:n)];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-% Attention: Children are loaded in reverse order!
-  xd = [get(hc(1),'XData') t(1:n)];
-  yd = [get(hc(1),'YData') ncfn(1:n)];
-  set(hc(1), 'XData', xd, 'YData', yd);
-  yd = [get(hc(2),'YData') netf(1:n)];
-  set(hc(2), 'XData', xd, 'YData', yd);
-  yd = [get(hc(3),'YData') nni(1:n)];
-  set(hc(3), 'XData', xd, 'YData', yd);
-  yd = [get(hc(4),'YData') nfe(1:n)];
-  set(hc(4), 'XData', xd, 'YData', yd);
-  yd = [get(hc(5),'YData') nst(1:n)];
-  set(hc(5), 'XData', xd, 'YData', yd);
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = text_init(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-fig_name = 'IDAS run statistics';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-figure(hft);
-set(hft,'Name',fig_name);
-set(hft,'color',[1 1 1]);
-set(hft,'MenuBar','none');
-set(hft,'Resize','off');
-
-% Create text box
-
-margins=[10 10 50 50]; % left, right, top, bottom
-pos=get(hft,'position');
-tbpos=[margins(1) margins(4) pos(3)-margins(1)-margins(2) ...
-       pos(4)-margins(3)-margins(4)];
-tbpos(tbpos<1)=1;
-
-htb=uicontrol(hft,'style','listbox','position',tbpos,'tag','textbox');
-set(htb,'BackgroundColor',[1 1 1]);
-set(htb,'SelectionHighlight','off');
-set(htb,'FontName','courier');
-
-% Create table head
-
-tpos = [tbpos(1) tbpos(2)+tbpos(4)+10 tbpos(3) 20];
-ht=uicontrol(hft,'style','text','position',tpos,'tag','text');
-set(ht,'BackgroundColor',[1 1 1]);
-set(ht,'HorizontalAlignment','left');
-set(ht,'FontName','courier');
-newline = '   time         step      order  |    nst   nfe   nni  netf  ncfn';
-set(ht,'String',newline);
-
-% Create OK button
-  
-bsize=[60,28];
-badjustpos=[0,25];
-bpos=[pos(3)/2-bsize(1)/2+badjustpos(1) -bsize(2)/2+badjustpos(2)...
-      bsize(1) bsize(2)];
-bpos=round(bpos);
-bpos(bpos<1)=1;
-hb=uicontrol(hft,'style','pushbutton','position',bpos,...
-             'string','Close','tag','okaybutton');
-set(hb,'callback','close');
-
-% Save handles
-
-handles=guihandles(hft);
-guidata(hft,handles);
-
-for i = 1:n
-  newline = '';
-  if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = text_update(n,hft,stats,cntr,t,h,q,nst,nfe,nni,netf,ncfn)
-
-figure(hft);
-
-handles=guidata(hft);
-
-for i = 1:n
-   if stats
-    newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
-  end
-  if cntr
-    newline = sprintf('%s %5d %5d %5d %5d %5d',...
-                      newline,nst(i),nfe(i),nni(i),netf(i),ncfn(i));
-  end
-  string = get(handles.textbox,'String');
-  string{end+1}=newline;
-  set(handles.textbox,'String',string);
-end
-
-drawnow
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, N, t, y)
-
-fig_name = 'IDAS solution';
-
-% If this is a parallel job, look for the MPI rank in the global
-% workspace and append it to the figure name
-
-global sundials_MPI_rank
-
-if ~isempty(sundials_MPI_rank)
-  fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
-end
-
-
-figure(hfs);
-set(hfs,'Name',fig_name);
-set(hfs,'color',[1 1 1]);
-
-% Time label
-
-tlab = '\leftarrow   t   \leftarrow';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, N, t, y)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') t(1:n)];
-% Attention: Children are loaded in reverse order!
-  for i = 1:N
-    yd = [get(hc(i),'YData') y(N-i+1,1:n)];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, N)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-drawnow
diff --git a/sundialsTB/idas/IDAMonitorB_octave.m b/sundialsTB/idas/IDAMonitorB_octave.m
deleted file mode 100644
index b9e3207..0000000
--- a/sundialsTB/idas/IDAMonitorB_octave.m
+++ /dev/null
@@ -1,545 +0,0 @@
-function [new_data] = IDAMonitorB(call, idxB, T, Y, YQ, data)
-%IDAMonitorB is the default IDAS monitoring function for backward problems.
-%   To use it, set the Monitor property in IDASetOptions to
-%   'IDAMonitorB' or to @IDAMonitorB and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to IDASetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see IDAGetStats)
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also IDASetOptions, IDAMonitorFnB
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to IDASetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/08/21 17:38:42 $
-
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.stats | data.cntr
-      data.hfg = figure;
-    end
-%   Number of subplots in figure hfg
-    if data.stats
-      data.npg = data.npg + 2;
-    end
-    if data.cntr
-      data.npg = data.npg + 1;
-    end
-    
-    if data.sol
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y for additional initializations
-  
-  if data.first
-
-    if data.sol
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  y    = data.y;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = IDAGetStatsB(idxB);
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr)
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol
-      sol_init(n, hfs, nps, data.sol, ...
-               N, t, y);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr)
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, N, t, y);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr)
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol
-      sol_final(hfs, nps, data.sol, N);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-if ~data.sol
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.y = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '<-   t   <-';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; abs(h(1:n)')];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; q(1:n)'];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  
-  pl = pl+1;
-
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-
-  yd = [get(hc(5),'YData') ; ncfn(1:n)'];
-  set(hc(5), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(4),'YData') ; netf(1:n)'];
-  set(hc(4), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(3),'YData') ; nni(1:n)'];
-  set(hc(3), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(2),'YData') ; nfe(1:n)'];
-  set(hc(2), 'XData', xd, 'YData', yd);
-
-  yd = [get(hc(1),'YData') ; nst(1:n)'];
-  set(hc(1), 'XData', xd, 'YData', yd);
-
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, N, t, y)
-
-figure(hfs);
-
-% Time label
-
-tlab = '<-   t   <-';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, N, t, y)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-
-  for i = 1:N
-    yd = [get(hc(i),'YData') ; y(i,1:n)'];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, N)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-drawnow
diff --git a/sundialsTB/idas/IDAMonitor_octave.m b/sundialsTB/idas/IDAMonitor_octave.m
deleted file mode 100644
index fc30315..0000000
--- a/sundialsTB/idas/IDAMonitor_octave.m
+++ /dev/null
@@ -1,637 +0,0 @@
-function [new_data] = IDAMonitor(call, T, Y, YQ, YS, data)
-%IDAMonitor is the default IDAS monitoring function.
-%   To use it, set the Monitor property in IDASetOptions to
-%   'IDAMonitor' or to @IDAMonitor and 'MonitorData' to mondata
-%   (defined as a structure).
-%  
-%   With default settings, this function plots the evolution of the step 
-%   size, method order, and various counters.
-%   
-%   Various properties can be changed from their default values by passing
-%   to IDASetOptions, through the property 'MonitorData', a structure
-%   MONDATA with any of the following fields. If a field is not defined, 
-%   the corresponding default value is used.
-%
-%   Fields in MONDATA structure:
-%     o stats [ {true} | false ]
-%         If true, report the evolution of the step size and method order.
-%     o cntr [ {true} | false ]
-%         If true, report the evolution of the following counters:
-%         nst, nfe, nni, netf, ncfn (see IDAGetStats)
-%     o sol  [ true | {false} ]
-%         If true, plot solution components.
-%     o sensi [ true | {false} ]
-%         If true and if FSA is enabled, plot sensitivity components.
-%     o select [ array of integers ]
-%         To plot only particular solution components, specify their indeces in
-%         the field select. If not defined, but sol=true, all components are plotted.
-%     o updt [ integer | {50} ]
-%         Update frequency. Data is posted in blocks of dimension n.
-%     o skip [ integer | {0} ]
-%         Number of integrations steps to skip in collecting data to post.
-%     o post [ {true} | false ]
-%         If false, disable all posting. This option is necessary to disable
-%         monitoring on some processors when running in parallel.
-%
-%   See also IDASetOptions, IDAMonitorFn
-%
-%   NOTES:
-%     1. The argument mondata is REQUIRED. Even if only the default options
-%        are desired, set mondata=struct; and pass it to IDASetOptions.
-%     2. The yQ argument is currently ignored.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/08/21 17:38:42 $
-
-% NOTES:
-%   - Unlike Matlab, Octave loads children in the normal order
-%   - Unlike Matlab, Octave stores 'XData' and 'YData' as column vectors
-
-if (nargin ~= 6) 
-  error('Monitor data not defined.');
-end
-
-new_data = [];
-
-if call == 0
-
-% Initialize unspecified fields to default values.
-  data = initialize_data(data);  
-
-% Open figure windows
-  if data.post
-
-    if data.stats | data.cntr
-      data.hfg = figure;
-    end
-%   Number of subplots in figure hfg
-    if data.stats
-      data.npg = data.npg + 2;
-    end
-    if data.cntr
-      data.npg = data.npg + 1;
-    end
-    
-    if data.sol | data.sensi
-      data.hfs = figure; 
-    end
-  
-  end
-  
-% Initialize other private data
-  data.i = 0;
-  data.n = 1;  
-  data.t = zeros(1,data.updt);
-  if data.stats
-    data.h = zeros(1,data.updt);
-    data.q = zeros(1,data.updt);
-  end
-  if data.cntr
-    data.nst = zeros(1,data.updt);
-    data.nfe = zeros(1,data.updt);
-    data.nni = zeros(1,data.updt);
-    data.netf = zeros(1,data.updt);
-    data.ncfn = zeros(1,data.updt);
-  end
-
-  data.first = true;        % the next one will be the first call = 1
-  data.initialized = false; % the graphical windows were not initalized
-  
-  new_data = data;
-  
-  return;
-
-else
-
-% If this is the first call ~= 0, 
-% use Y and YS for additional initializations
-  
-  if data.first
-
-    if isempty(YS)
-      data.sensi = false;
-    end
-    
-    if data.sol | data.sensi
-      
-      if isempty(data.select)
-      
-        data.N = length(Y);
-        data.select = [1:data.N];
-        
-      else
-        
-        data.N = length(data.select);
-        
-      end
-
-      if data.sol
-        data.y = zeros(data.N,data.updt);
-        data.nps = data.nps + 1;
-      end
-        
-      if data.sensi
-        data.Ns = size(YS,2);
-        data.ys = zeros(data.N, data.Ns, data.updt);
-        data.nps = data.nps + data.Ns;
-      end
-      
-    end
-    
-    data.first = false;
-  
-  end
-  
-% Extract variables from data
-
-  hfg  = data.hfg;
-  hft  = data.hft;
-  hfs  = data.hfs;
-  npg  = data.npg;
-  nps  = data.nps;
-  i    = data.i;
-  n    = data.n;
-  t    = data.t;
-  N    = data.N;
-  Ns   = data.Ns;
-  y    = data.y;
-  ys   = data.ys;
-  h    = data.h;
-  q    = data.q;
-  nst  = data.nst;
-  nfe  = data.nfe;
-  nni  = data.nni;
-  netf = data.netf;
-  ncfn = data.ncfn;
-  
-end
-
-
-% Load current statistics?
-
-if call == 1
-
-  if i ~= 0
-    i = i-1;
-    data.i = i;
-    new_data = data;
-    return;
-  end
-
-  si = IDAGetStats;
-
-  t(n) = si.tcur;
-  
-  if data.stats
-    h(n) = si.hlast;
-    q(n) = si.qlast;
-  end
-  
-  if data.cntr
-    nst(n) = si.nst;
-    nfe(n) = si.nfe;
-    nni(n) = si.nni;
-    netf(n) = si.netf;
-    ncfn(n) = si.ncfn;
-  end
-
-  if data.sol
-    for j = 1:N
-      y(j,n) = Y(data.select(j));
-    end
-  end
-
-  if data.sensi
-    for k = 1:Ns
-      for j = 1:N
-        ys(j,k,n) = YS(data.select(j),k);
-      end
-    end
-  end
-  
-end
-
-% Is it time to post?
-
-if data.post & (n == data.updt | call==2)
-
-  if call == 2
-    n = n-1;
-  end
-  
-  if ~data.initialized
-
-    if (data.stats | data.cntr)
-      graphical_init(n, hfg, npg, data.stats, data.cntr, ...
-                     t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-    
-    if data.sol | data.sensi
-      sol_init(n, hfs, nps, data.sol, data.sensi, ...
-               N, Ns, t, y, ys);
-    end
-    
-    data.initialized = true;
-  
-  else
-
-    if (data.stats | data.cntr)
-      graphical_update(n, hfg, npg, data.stats, data.cntr, ...
-                       t, h, q, nst, nfe, nni, netf, ncfn);
-    end
-
-    if data.sol
-      sol_update(n, hfs, nps, data.sol, data.sensi, N, Ns, t, y, ys);
-    end
-      
-  end
-
-  if call == 2
-    
-    if (data.stats | data.cntr)
-      graphical_final(hfg, npg, data.cntr, data.stats);
-    end
-    
-    if data.sol | data.sensi
-      sol_final(hfs, nps, data.sol, data.sensi, N, Ns);
-    end
-
-    return;
-  
-  end
-  
-  n = 1;
-
-else
-
-  n = n + 1;
-
-end
-
-
-% Save updated values in data
-
-data.i    = data.skip;
-data.n    = n;
-data.npg  = npg;
-data.t    = t;
-data.y    = y;
-data.ys   = ys;
-data.h    = h;
-data.q    = q;
-data.nst  = nst;
-data.nfe  = nfe;
-data.nni  = nni;
-data.netf = netf;
-data.ncfn = ncfn;
-  
-new_data = data;
-
-return;
-
-%-------------------------------------------------------------------------
-
-function data = initialize_data(data)
-
-if ~isfield(data,'updt')
-  data.updt = 50;
-end
-if ~isfield(data,'skip')
-  data.skip = 0;
-end
-if ~isfield(data,'stats')
-  data.stats = true;
-end
-if ~isfield(data,'cntr')
-  data.cntr = true;
-end
-if ~isfield(data,'sol')
-  data.sol = false;
-end
-if ~isfield(data,'sensi')
-  data.sensi = false;
-end
-if ~isfield(data,'select')
-  data.select = [];
-end
-if ~isfield(data,'post')
-  data.post = true;
-end
-
-if ~data.sol & ~data.sensi
-  data.select = [];
-end
-  
-% Other initializations
-data.npg = 0;
-data.nps = 0;
-data.hfg = 0;
-data.hft = 0;
-data.hfs = 0;
-data.h = 0;
-data.q = 0;
-data.nst = 0;
-data.nfe = 0;
-data.nni = 0;
-data.netf = 0;
-data.ncfn = 0;
-data.N = 0;
-data.Ns = 0;
-data.y = 0;
-data.ys = 0;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_init(n, hfg, npg, stats, cntr, ...
-                             t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-
-% Time label and figure title
-
-tlab = '->   t   ->';
-
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  semilogy(t(1:n),abs(h(1:n)),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('|Step size|');
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),q(1:n),'-');
-  hold on;
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Order');
-end
-  
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  plot(t(1:n),nst(1:n),'k-');
-  hold on;
-  plot(t(1:n),nfe(1:n),'b-');
-  plot(t(1:n),nni(1:n),'r-');
-  plot(t(1:n),netf(1:n),'g-');
-  plot(t(1:n),ncfn(1:n),'c-');
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('Counters');
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_update(n, hfg, npg, stats, cntr, ...
-                               t, h, q, nst, nfe, nni, netf, ncfn)
-
-figure(hfg);
-pl = 0;
-  
-% Step size and order
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; abs(h(1:n)')];
-  set(hc, 'XData', xd, 'YData', yd);
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc,'XData') ; t(1:n)'];
-  yd = [get(hc,'YData') ; q(1:n)'];
-  set(hc, 'XData', xd, 'YData', yd);
-end
-
-% Counters
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-  yd = [get(hc(1),'YData') ; ncfn(1:n)'];
-  set(hc(1), 'XData', xd, 'YData', yd);
-  yd = [get(hc(2),'YData') ; netf(1:n)'];
-  set(hc(2), 'XData', xd, 'YData', yd);
-  yd = [get(hc(3),'YData') ; nni(1:n)'];
-  set(hc(3), 'XData', xd, 'YData', yd);
-  yd = [get(hc(4),'YData') ; nfe(1:n)'];
-  set(hc(4), 'XData', xd, 'YData', yd);
-  yd = [get(hc(5),'YData') ; nst(1:n)'];
-  set(hc(5), 'XData', xd, 'YData', yd);
-end
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = graphical_final(hfg,npg,stats,cntr)
-
-figure(hfg);
-pl = 0;
-
-if stats
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc,'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  
-  pl = pl+1;
-  subplot(npg,1,pl)
-  ylim = get(gca,'YLim');
-  ylim(1) = ylim(1) - 1;
-  ylim(2) = ylim(2) + 1;
-  set(gca,'YLim',ylim);
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-end
-
-if cntr
-  pl = pl+1;
-  subplot(npg,1,pl)
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-  legend('nst','nfe','nni','netf','ncfn',2);
-end
-
-%-------------------------------------------------------------------------
-
-function [] = sol_init(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-figure(hfs);
-
-% Time label
-
-tlab = '->   t   ->';
-
-% Get number of colors in colormap
-map = colormap;
-ncols = size(map,1);
-
-% Initialize current subplot counter
-pl = 0;
-
-if sol
-
-  pl = pl+1;
-  subplot(nps,1,pl);
-  hold on;
-
-  for i = 1:N
-    hp = plot(t(1:n),y(i,1:n),'-');
-    ic = 1+(i-1)*floor(ncols/N);
-    set(hp,'Color',map(ic,:));
-  end
-  box on;
-  grid on;
-  xlabel(tlab);
-  ylabel('y');
-  title('Solution');
-
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-    hold on;
-      
-    ys_crt = ys(:,is,1:n);
-    for i = 1:N
-      hp = plot(t(1:n),ys_crt(i,1:n),'-');
-      ic = 1+(i-1)*floor(ncols/N);
-      set(hp,'Color',map(ic,:));
-    end
-    box on;
-    grid on;
-    xlabel(tlab);
-    str = sprintf('s_{%d}',is); ylabel(str);
-    str = sprintf('Sensitivity %d',is); title(str);
-    
-  end
-  
-end
-
-
-drawnow;
-
-%-------------------------------------------------------------------------
-
-function [] = sol_update(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-  
-  pl = pl+1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = [get(hc(1),'XData') ; t(1:n)'];
-  for i = 1:N
-    yd = [get(hc(i),'YData') ; y(i,1:n)'];
-    set(hc(i), 'XData', xd, 'YData', yd);
-  end
-
-end
-  
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    ys_crt = ys(:,is,:);
-    
-    hc = get(gca,'Children');
-    xd = [get(hc(1),'XData') ; t(1:n)'];
-    for i = 1:N
-      yd = [get(hc(i),'YData') ; ys_crt(i,1:n)'];
-      set(hc(i), 'XData', xd, 'YData', yd);
-    end
-    
-  end
-  
-end
-
-
-drawnow;
-
-
-%-------------------------------------------------------------------------
-
-function [] = sol_final(hfs, nps, sol, sensi, N, Ns)
-
-figure(hfs);
-
-pl = 0;
-
-if sol
-
-  pl = pl +1;
-  subplot(nps,1,pl);
-  
-  hc = get(gca,'Children');
-  xd = get(hc(1),'XData');
-  set(gca,'XLim',sort([xd(1) xd(end)]));
-
-  ylim = get(gca,'YLim');
-  addon = 0.1*abs(ylim(2)-ylim(1));
-  ylim(1) = ylim(1) + sign(ylim(1))*addon;
-  ylim(2) = ylim(2) + sign(ylim(2))*addon;
-  set(gca,'YLim',ylim);
-  
-  for i = 1:N
-    cstring{i} = sprintf('y_{%d}',i);
-  end
-  legend(cstring);
-  
-end
-
-if sensi
-  
-  for is = 1:Ns
-    
-    pl = pl+1;
-    subplot(nps,1,pl);
-
-    hc = get(gca,'Children');
-    xd = get(hc(1),'XData');
-    set(gca,'XLim',sort([xd(1) xd(end)]));
-
-    ylim = get(gca,'YLim');
-    addon = 0.1*abs(ylim(2)-ylim(1));
-    ylim(1) = ylim(1) + sign(ylim(1))*addon;
-    ylim(2) = ylim(2) + sign(ylim(2))*addon;
-    set(gca,'YLim',ylim);
-  
-    for i = 1:N
-      cstring{i} = sprintf('s%d_{%d}',is,i);
-    end
-    legend(cstring);
-    
-  end
-  
-end
-
-drawnow
diff --git a/sundialsTB/idas/IDAQuadInit.m b/sundialsTB/idas/IDAQuadInit.m
deleted file mode 100644
index 921610b..0000000
--- a/sundialsTB/idas/IDAQuadInit.m
+++ /dev/null
@@ -1,28 +0,0 @@
-function status = IDAQuadInit(fctQ, yQ0, options)
-%IDAQuadInit allocates and initializes memory for quadrature integration.
-%
-%   Usage: IDAQuadInit ( QFUN, YQ0 [, OPTIONS ] ) 
-%
-%   QFUN     is a function defining the righ-hand sides of the quadrature
-%            ODEs yQ' = fQ(t,y).
-%   YQ0      is the initial conditions vector yQ(t0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the IDASetQuadOptions function. 
-%
-%   See also: IDASetQuadOptions, IDAQuadRhsFn 
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 2;
-
-if nargin < 2
-  error('Too few input arguments');
-end
-
-if nargin < 3
-  options = [];
-end
-
-status = idm(mode, fctQ, yQ0, options);
diff --git a/sundialsTB/idas/IDAQuadInitB.m b/sundialsTB/idas/IDAQuadInitB.m
deleted file mode 100644
index 83fbbbe..0000000
--- a/sundialsTB/idas/IDAQuadInitB.m
+++ /dev/null
@@ -1,32 +0,0 @@
-function status = IDAQuadInitB(idxB, fctQB, yQB0, optionsB)
-%IDAQuadInitB allocates and initializes memory for backward quadrature integration.
-%
-%   Usage: IDAQuadInitB ( IDXB, QBFUN, YQB0 [, OPTIONS ] ) 
-%
-%   IDXB     is the index of the backward problem, returned by
-%            IDAInitB.
-%   QBFUN    is a function defining the righ-hand sides of the
-%            backward ODEs yQB' = fQB(t,y,yB).
-%   YQB0     is the final conditions vector yQB(tB0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the IDASetQuadOptions function. 
-%
-%   See also: IDAInitB, IDASetQuadOptions, IDAQuadRhsFnB 
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 6;
-
-if nargin < 3
-  error('Too few input arguments');
-end
-
-if nargin < 4
-  optionsB = [];
-end
-
-idxB = idxB-1;
-status = idm(mode, idxB, fctQB, yQB0, optionsB);
diff --git a/sundialsTB/idas/IDAQuadReInit.m b/sundialsTB/idas/IDAQuadReInit.m
deleted file mode 100644
index 14f2c5f..0000000
--- a/sundialsTB/idas/IDAQuadReInit.m
+++ /dev/null
@@ -1,28 +0,0 @@
-function status = IDAQuadReInit(yQ0, options)
-%IDAQuadReInit reinitializes IDAS's quadrature-related memory
-%   assuming it has already been allocated in prior calls to IDAInit 
-%   and IDAQuadInit.
-%
-%   Usage: IDAQuadReInit ( YQ0 [, OPTIONS ] ) 
-%
-%   YQ0      Initial conditions for quadrature variables yQ(t0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the IDASetQuadOptions function. 
-%
-%   See also: IDASetQuadOptions, IDAQuadInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 12;
-
-if nargin < 1
-  error('Too few input arguments');
-end
-
-if nargin < 2
-  options = [];
-end
-  
-status = idm(mode, yQ0, options);
diff --git a/sundialsTB/idas/IDAQuadReInitB.m b/sundialsTB/idas/IDAQuadReInitB.m
deleted file mode 100644
index b117e68..0000000
--- a/sundialsTB/idas/IDAQuadReInitB.m
+++ /dev/null
@@ -1,30 +0,0 @@
-function status = IDAQuadReInitB(idxB, yQB0, optionsB)
-%IDAQuadReInitB reinitializes memory for backward quadrature integration.
-%
-%   Usage: IDAQuadReInitB ( IDXB, YS0 [, OPTIONS ] ) 
-%
-%   IDXB     is the index of the backward problem, returned by
-%            IDAInitB.
-%   YQB0     is the final conditions vector yQB(tB0).
-%   OPTIONS  is an (optional) set of QUAD options, created with
-%            the IDASetQuadOptions function. 
-%
-%   See also: IDASetQuadOptions, IDAReInitB, IDAQuadInitB
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:18 $
-
-mode = 16;
-
-if nargin < 2
-  error('Too few input arguments');
-end
-
-if nargin < 3
-  optionsB = [];
-end
-  
-idxB = idxB-1;
-status = idm(mode, idxB, yQB0, optionsB);
diff --git a/sundialsTB/idas/IDAQuadSetOptions.m b/sundialsTB/idas/IDAQuadSetOptions.m
deleted file mode 100644
index 0e180fb..0000000
--- a/sundialsTB/idas/IDAQuadSetOptions.m
+++ /dev/null
@@ -1,63 +0,0 @@
-function options = IDAQuadSetOptions(varargin)
-%IDAQuadSetOptions creates an options structure for IDAS.
-%
-%   Usage: OPTIONS = IDAQuadSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...)
-%          OPTIONS = IDAQuadSetOptions(OLDOPTIONS,'NAME1',VALUE1,...)
-%
-%   OPTIONS = IDAQuadSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...) creates 
-%   an IDAS options structure OPTIONS in which the named properties have 
-%   the specified values. Any unspecified properties have default values. 
-%   It is sufficient to type only the leading characters that uniquely 
-%   identify the property. Case is ignored for property names. 
-%   
-%   OPTIONS = IDAQuadSetOptions(OLDOPTIONS,'NAME1',VALUE1,...) alters an 
-%   existing options structure OLDOPTIONS.
-%   
-%   IDAQuadSetOptions with no input arguments displays all property names 
-%   and their possible values.
-%   
-%IDAQuadSetOptions properties
-%(See also the IDAS User Guide)
-%
-%ErrControl - Error control strategy for quadrature variables [ on | {off} ]
-%   Specifies whether quadrature variables are included in the error test.
-%RelTol - Relative tolerance for quadrature variables [ scalar {1e-4} ]
-%   Specifies the relative tolerance for quadrature variables. This parameter is
-%   used only if QuadErrCon=on.
-%AbsTol - Absolute tolerance for quadrature variables [ scalar or vector {1e-6} ]
-%   Specifies the absolute tolerance for quadrature variables. This parameter is
-%   used only if QuadErrCon=on.
-%
-%SensDependent - Backward problem depending on sensitivities [ {false} | true ]
-%   Specifies whether the backward problem quadrature right-hand side depends
-%   on forward sensitivites. If TRUE, the right-hand side function provided for
-%   this backward problem must have the appropriate type (see IDAQuadRhsFnB).
-%
-%   See also
-%        IDAQuadInit, IDAQuadReInit.
-%        IDAQuadInitB, IDAQuadReInitB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/08/21 17:38:42 $
-
-% If called without input and output arguments, print out the possible keywords
-
-if (nargin == 0) && (nargout == 0)
-  fprintf('      ErrControl: [ {false} | true ]\n');
-  fprintf('          RelTol: [ positive scalar {1e-4} ]\n');
-  fprintf('          AbsTol: [ positive scalar or vector {1e-6} ]\n');
-  fprintf('\n');
-  fprintf('   SensDependent: [ {false} | true ]\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'ErrControl'
-    'RelTol'
-    'AbsTol'
-    'SensDependent'
-    };
-
-options = idm_options(KeyNames,varargin{:});
diff --git a/sundialsTB/idas/IDAReInit.m b/sundialsTB/idas/IDAReInit.m
deleted file mode 100644
index a405020..0000000
--- a/sundialsTB/idas/IDAReInit.m
+++ /dev/null
@@ -1,33 +0,0 @@
-function status = IDAReInit(t0,yy0,yp0,options)
-%IDAReInit reinitializes memory for IDAS.
-%   where a prior call to IDAInit has been made with the same
-%   problem size N. IDAReInit performs the same input checking
-%   and initializations that IDAInit does, but it does no 
-%   memory allocation, assuming that the existing internal memory 
-%   is sufficient for the new problem.
-%
-%   Usage: IDAReInit ( T0, YY0, YP0 [, OPTIONS ] ) 
-%
-%   T0       is the initial value of t.
-%   YY0      is the initial condition vector y(t0).  
-%   YP0      is the initial condition vector y'(t0).  
-%   OPTIONS  is an (optional) set of integration options, created with
-%            the IDASetOptions function. 
-%
-%  See also: IDASetOptions, IDAInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 11;
-
-if nargin < 3
-  error('Too few input arguments');
-end
-
-if nargin < 4
-  options = [];
-end
-
-status = idm(mode, t0, yy0, yp0, options);
diff --git a/sundialsTB/idas/IDAReInitB.m b/sundialsTB/idas/IDAReInitB.m
deleted file mode 100644
index a940159..0000000
--- a/sundialsTB/idas/IDAReInitB.m
+++ /dev/null
@@ -1,37 +0,0 @@
-function status = IDAReInitB(idxB,tB0,yyB0,ypB0,optionsB)
-%IDAReInitB allocates and initializes backward memory for IDAS.
-%   where a prior call to IDAInitB has been made with the same
-%   problem size NB. IDAReInitB performs the same input checking
-%   and initializations that IDAInitB does, but it does no 
-%   memory allocation, assuming that the existing internal memory 
-%   is sufficient for the new problem.
-%
-%   Usage:   IDAReInitB ( IDXB, TB0, YYB0, YPB0 [, OPTIONSB] )
-%
-%   IDXB     is the index of the backward problem, returned by
-%            IDAInitB.
-%   TB0      is the final value of t.
-%   YYB0     is the final condition vector yB(tB0).  
-%   YPB0     is the final condition vector yB'(tB0).
-%   OPTIONSB is an (optional) set of integration options, created with
-%            the IDASetOptions function. 
-%
-%   See also: IDASetOptions, IDAInitB
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:18 $
-
-mode = 15;
-
-if nargin < 4
-  error('Too few input arguments');
-end
-
-if nargin < 5
-  optionsB = [];
-end
-
-idxB = idxB-1;
-status = idm(mode, idxB, tB0, yyB0, ypB0, optionsB);
diff --git a/sundialsTB/idas/IDASensInit.m b/sundialsTB/idas/IDASensInit.m
deleted file mode 100644
index deff514..0000000
--- a/sundialsTB/idas/IDASensInit.m
+++ /dev/null
@@ -1,32 +0,0 @@
-function status = IDASensInit(Ns,fctS,yyS0,ypS0,options)
-%IDASensInit allocates and initializes memory for FSA with IDAS.
-%
-%   Usage: IDASensInit ( NS, SFUN, YYS0, YPS0 [, OPTIONS ] ) 
-%
-%   NS       is the number of parameters with respect to which sensitivities
-%            are desired
-%   SFUN     is a function defining the residual of the sensitivity DAEs
-%            fS(t,y,yp,yS,ypS).
-%   YYS0, YPS0   Initial conditions for sensitivity variables.
-%            YYS0 and YPS0 must be matrices with N rows and Ns columns, where N is 
-%            the problem dimension and Ns the number of sensitivity systems.
-%   OPTIONS  is an (optional) set of FSA options, created with
-%            the IDASetFSAOptions function. 
-%
-%   See also IDASensSetOptions, IDAInit, IDASensResFn
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-mode = 3;
-
-if nargin < 4
-  error('Too few input arguments');
-end
-
-if nargin < 5
-  options = [];
-end
-
-status = idm(mode, Ns, fctS, yyS0, ypS0, options);
diff --git a/sundialsTB/idas/IDASensReInit.m b/sundialsTB/idas/IDASensReInit.m
deleted file mode 100644
index b978502..0000000
--- a/sundialsTB/idas/IDASensReInit.m
+++ /dev/null
@@ -1,32 +0,0 @@
-function status = IDASensReInit(yyS0,ypS0,options)
-%IDASensReInit reinitializes IDAS's FSA-related memory
-%   assuming it has already been allocated in prior calls to IDAInit
-%   and IDASensInit.
-%   The number of sensitivities Ns is assumed to be unchanged since the 
-%   previous call to IDASensInit.
-%
-%   Usage: IDASensReInit ( YYS0, YPS0 [, OPTIONS ] ) 
-%
-%   YYS0, YPS0   Initial conditions for sensitivity variables.
-%            YYS0 and YPS0 must be matrices with N rows and Ns columns, where N is 
-%            the problem dimension and Ns the number of sensitivity systems.
-%   OPTIONS  is an (optional) set of FSA options, created with
-%            the IDASetFSAOptions function. 
-%
-%   See also: IDASensSetOptions, IDAReInit, IDASensInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:19 $
-
-mode = 13;
-
-if nargin < 2
-  error('Too few input arguments');
-end
-
-if nargin < 3
-  options = [];
-end
-
-status = idm(mode, yyS0, ypS0, options);
diff --git a/sundialsTB/idas/IDASensSetOptions.m b/sundialsTB/idas/IDASensSetOptions.m
deleted file mode 100644
index 94dddfa..0000000
--- a/sundialsTB/idas/IDASensSetOptions.m
+++ /dev/null
@@ -1,112 +0,0 @@
-function options = IDASensSetOptions(varargin)
-%IDASensSetOptions creates an options structure for FSA with IDAS.
-%
-%   Usage: OPTIONS = IDASensSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...)
-%          OPTIONS = IDASensSetOptions(OLDOPTIONS,'NAME1',VALUE1,...)
-%
-%   OPTIONS = IDASensSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...) creates 
-%   a IDAS options structure OPTIONS in which the named properties have 
-%   the specified values. Any unspecified properties have default values. 
-%   It is sufficient to type only the leading characters that uniquely 
-%   identify the property. Case is ignored for property names. 
-%   
-%   OPTIONS = IDASensSetOptions(OLDOPTIONS,'NAME1',VALUE1,...) alters an 
-%   existing options structure OLDOPTIONS.
-%   
-%   IDASensSetOptions with no input arguments displays all property names 
-%   and their possible values.
-%   
-%IDASensSetOptions properties
-%(See also the IDAS User Guide)
-%
-%method - FSA solution method [ 'Simultaneous' | {'Staggered'} ]
-%   Specifies the FSA method for treating the nonlinear system solution for
-%   sensitivity variables. In the simultaneous case, the nonlinear systems 
-%   for states and all sensitivities are solved simultaneously. In the 
-%   Staggered case, the nonlinear system for states is solved first and then
-%   the nonlinear systems for all sensitivities are solved at the same time. 
-%ParamField - Problem parameters  [ string ]
-%   Specifies the name of the field in the user data structure (specified through
-%   the 'UserData' field with IDASetOptions) in which the nominal values of the problem 
-%   parameters are stored. This property is used only if  IDAS will use difference
-%   quotient approximations to the sensitivity residuals (see IDASensResFn).
-%ParamList - Parameters with respect to which FSA is performed [ integer vector ]
-%   Specifies a list of Ns parameters with respect to which sensitivities are to
-%   be computed. This property is used only if IDAS will use difference-quotient
-%   approximations to the sensitivity residuals. Its length must be Ns, 
-%   consistent with the number of columns of yS0 (see IDASensInit).
-%ParamScales - Order of magnitude for problem parameters [ vector ]
-%   Provides order of magnitude information for the parameters with respect to
-%   which sensitivities are computed. This information is used if IDAS 
-%   approximates the sensitivity residuals or if IDAS estimates integration
-%   tolerances for the sensitivity variables (see RelTol and AbsTol).
-%RelTol - Relative tolerance for sensitivity variables [ positive scalar ]
-%   Specifies the scalar relative tolerance for the sensitivity variables. 
-%   See also AbsTol.
-%AbsTol - Absolute tolerance for sensitivity variables [ row-vector or matrix ]
-%   Specifies the absolute tolerance for sensitivity variables. AbsTol must be
-%   either a row vector of dimension Ns, in which case each of its components is
-%   used as a scalar absolute tolerance for the coresponding sensitivity vector,
-%   or a N x Ns matrix, in which case each of its columns is used as a vector
-%   of absolute tolerances for the corresponding sensitivity vector.
-%   By default, IDAS estimates the integration tolerances for sensitivity 
-%   variables, based on those for the states and on the order of magnitude 
-%   information for the problem parameters specified through ParamScales.
-%ErrControl - Error control strategy for sensitivity variables [ false | {true} ]
-%   Specifies whether sensitivity variables are included in the error control test.
-%   Note that sensitivity variables are always included in the nonlinear system
-%   convergence test.
-%DQtype - Type of DQ approx. of the sensi. RHS [{Centered} | Forward ]
-%   Specifies whether to use centered (second-order) or forward (first-order)
-%   difference quotient approximations of the sensitivity eqation residuals.
-%   This property is used only if a user-defined sensitivity residual function 
-%   was not provided.
-%DQparam - Cut-off parameter for the DQ approx. of the sensi. RES [ scalar | {0.0} ]
-%   Specifies the value which controls the selection of the difference-quotient 
-%   scheme used in evaluating the sensitivity residuals (switch between 
-%   simultaneous or separate evaluations of the two components in the sensitivity 
-%   right-hand side). The default value 0.0 indicates the use of simultaenous approximation
-%   exclusively (centered or forward, depending on the value of DQtype.
-%   For DQparam >= 1, IDAS uses a simultaneous approximation if the estimated
-%   DQ perturbations for states and parameters are within a factor of DQparam, 
-%   and separate approximations otherwise. Note that a value DQparam < 1
-%   will inhibit switching! This property is used only if a user-defined sensitivity 
-%   residual function was not provided. 
-%
-%   See also
-%        IDASensInit, IDASensReInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/08/21 17:38:43 $
-
-% If called without input and output arguments, print out the possible keywords
-
-if (nargin == 0) & (nargout == 0)
-  fprintf('          method: [ Simultaneous | {Staggered} ]\n');
-  fprintf('      ParamField: [ string ]\n');
-  fprintf('       ParamList: [ integer vector ]\n');
-  fprintf('     ParamScales: [ vector ]\n');
-  fprintf('          RelTol: [ positive scalar ]\n');
-  fprintf('          AbsTol: [ row-vector or matrix ]\n');
-  fprintf('      ErrControl: [ false | {true} ]\n');
-  fprintf('          DQtype: [ {Centered} | {Forward} ]\n');
-  fprintf('         DQparam: [ scalar | {0.0} ]\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'method'
-    'ParamField'
-    'ParamList'
-    'ParamScales'
-    'RelTol'
-    'AbsTol'
-    'ErrControl'
-    'DQtype'
-    'DQparam'
-        };
-
-options = idm_options(KeyNames,varargin{:});
-
diff --git a/sundialsTB/idas/IDASensToggleOff.m b/sundialsTB/idas/IDASensToggleOff.m
deleted file mode 100644
index 04ac508..0000000
--- a/sundialsTB/idas/IDASensToggleOff.m
+++ /dev/null
@@ -1,16 +0,0 @@
-function status = IDASensToggleOff()
-% IDASensToggleOff deactivates sensitivity calculations.
-%   It does NOT deallocate sensitivity-related memory so that 
-%   sensitivity computations can be later toggled ON (through
-%   IDASensReInit).
-%
-%   Usage: IDASensToggleOff
-%
-%   See also: IDASensInit, IDASensReInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2007/12/05 21:58:19 $
-
-mode = 18;
-status = idm(mode);
diff --git a/sundialsTB/idas/IDASet.m b/sundialsTB/idas/IDASet.m
deleted file mode 100644
index e525c61..0000000
--- a/sundialsTB/idas/IDASet.m
+++ /dev/null
@@ -1,52 +0,0 @@
-function status = IDASet(varargin)
-%IDASet changes optional input values during the integration.
-%
-%   Usage: IDASet('NAME1',VALUE1,'NAME2',VALUE2,...)
-%
-%   IDASet can be used to change some of the optional inputs during
-%   the integration, i.e., without need for a solver reinitialization.
-%   The property names accepted by IDASet are a subset of those valid
-%   for IDASetOptions. Any unspecified properties are left unchanged.
-%
-%   IDASet with no input arguments displays all property names. 
-%
-%IDASet properties
-%(See also the IDAS User Guide)
-%
-%UserData - problem data passed unmodified to all user functions.
-%  Set VALUE to be the new user data.  
-%RelTol - Relative tolerance
-%  Set VALUE to the new relative tolerance
-%AbsTol - absolute tolerance
-%  Set VALUE to be either the new scalar absolute tolerance or
-%  a vector of absolute tolerances, one for each solution component.
-%StopTime - Stopping time
-%  Set VALUE to be a new value for the independent variable past which
-%  the solution is not to proceed. 
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-if (nargin == 0)
-  fprintf('        UserData\n');
-  fprintf('\n');
-  fprintf('          RelTol\n');
-  fprintf('          AbsTol\n');
-  fprintf('        StopTime\n');  
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'UserData'
-    'RelTol'
-    'AbsTol'
-    'StopTime'
-           };
-
-options = idm_options(KeyNames,varargin{:});
-
-mode = 33;
-
-status = idm(mode, options);
diff --git a/sundialsTB/idas/IDASetB.m b/sundialsTB/idas/IDASetB.m
deleted file mode 100644
index 98152e2..0000000
--- a/sundialsTB/idas/IDASetB.m
+++ /dev/null
@@ -1,48 +0,0 @@
-function status = IDASetB(idxB, varargin)
-%IDASetB changes optional input values during the integration.
-%
-%   Usage: IDASetB( IDXB, 'NAME1',VALUE1,'NAME2',VALUE2,... )
-%
-%   IDASetB can be used to change some of the optional inputs for
-%   the backward problem identified by IDXB during the backward
-%   integration, i.e., without need for a solver reinitialization.
-%   The property names accepted by IDASet are a subset of those valid
-%   for IDASetOptions. Any unspecified properties are left unchanged.
-%   
-%   IDASetB with no input arguments displays all property names.
-%
-%IDASetB properties
-%(See also the IDAS User Guide)
-%
-%UserData - problem data passed unmodified to all user functions.
-%  Set VALUE to be the new user data.  
-%RelTol - Relative tolerance
-%  Set VALUE to the new relative tolerance
-%AbsTol - absolute tolerance
-%  Set VALUE to be either the new scalar absolute tolerance or
-%  a vector of absolute tolerances, one for each solution component.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-if (nargin == 0)
-  fprintf('        UserData\n');
-  fprintf('\n');
-  fprintf('          RelTol\n');
-  fprintf('          AbsTol\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'UserData'
-    'RelTol'
-    'AbsTol'
-           };
-
-options = idm_options(KeyNames,varargin{:});
-
-mode = 34;
-
-status = idm(mode, idxB, options);
diff --git a/sundialsTB/idas/IDASetOptions.m b/sundialsTB/idas/IDASetOptions.m
deleted file mode 100644
index e1ba816..0000000
--- a/sundialsTB/idas/IDASetOptions.m
+++ /dev/null
@@ -1,263 +0,0 @@
-function options = IDASetOptions(varargin)
-%IDASetOptions creates an options structure for IDAS.
-%
-%   Usage: OPTIONS = IDASetOptions('NAME1',VALUE1,'NAME2',VALUE2,...)
-%          OPTIONS = IDASetOptions(OLDOPTIONS,'NAME1',VALUE1,...)
-%
-%   OPTIONS = IDASetOptions('NAME1',VALUE1,'NAME2',VALUE2,...) creates 
-%   a IDAS options structure OPTIONS in which the named properties have 
-%   the specified values. Any unspecified properties have default values. 
-%   It is sufficient to type only the leading characters that uniquely 
-%   identify the property. Case is ignored for property names. 
-%   
-%   OPTIONS = IDASetOptions(OLDOPTIONS,'NAME1',VALUE1,...) alters an 
-%   existing options structure OLDOPTIONS.
-%   
-%   IDASetOptions with no input arguments displays all property names 
-%   and their possible values.
-%   
-%IDASetOptions properties
-%(See also the IDAS User Guide)
-%
-%UserData - User data passed unmodified to all functions [ empty ]
-%   If UserData is not empty, all user provided functions will be
-%   passed the problem data as their last input argument. For example,
-%   the RES function must be defined as R = DAEFUN(T,YY,TP,DATA).
-%
-%RelTol - Relative tolerance [ positive scalar | {1e-4} ]
-%   RelTol defaults to 1e-4 and is applied to all components of the solution
-%   vector. See AbsTol.
-%AbsTol - Absolute tolerance [ positive scalar or vector | {1e-6} ]
-%   The relative and absolute tolerances define a vector of error weights
-%   with components
-%     ewt(i) = 1/(RelTol*|y(i)| + AbsTol)    if AbsTol is a scalar
-%     ewt(i) = 1/(RelTol*|y(i)| + AbsTol(i)) if AbsTol is a vector
-%   This vector is used in all error and convergence tests, which
-%   use a weighted RMS norm on all error-like vectors v:
-%     WRMSnorm(v) = sqrt( (1/N) sum(i=1..N) (v(i)*ewt(i))^2 ),
-%   where N is the problem dimension.
-%MaxNumSteps - Maximum number of steps [positive integer | {500}]
-%   IDASolve will return with an error after taking MaxNumSteps internal steps
-%   in its attempt to reach the next output time.
-%InitialStep - Suggested initial stepsize [ positive scalar ]
-%   By default, IDASolve estimates an initial stepsize h0 at the initial time 
-%   t0 as the solution of
-%     WRMSnorm(h0^2 ydd / 2) = 1
-%   where ydd is an estimated second derivative of y(t0).
-%MaxStep - Maximum stepsize [ positive scalar | {inf} ]
-%   Defines an upper bound on the integration step size.
-%MaxOrder - Maximum method order [ 1-5 for BDF | {5} ]
-%   Defines an upper bound on the linear multistep method order.
-%StopTime - Stopping time [ scalar ]
-%   Defines a value for the independent variable past which the solution 
-%   is not to proceed. 
-%RootsFn - Rootfinding function [ function ]
-%   To detect events (roots of functions), set this property to the event 
-%   function. See IDARootFn.
-%NumRoots - Number of root functions [ integer | {0} ]
-%   Set NumRoots to the number of functions for which roots are monitored.
-%   If NumRoots is 0, rootfinding is disabled.
-%
-%SuppressAlgVars - Suppres algebraic vars. from error test [ on | {off} ]
-%VariableTypes - Alg./diff. variables [ vector ]
-%ConstraintTypes - Simple bound constraints [ vector ]
-%
-%LinearSolver - Linear solver type [{Dense}|Band|GMRES|BiCGStab|TFQMR]
-%   Specifies the type of linear solver to be used for the Newton nonlinear 
-%   solver. Valid choices are: Dense (direct, dense Jacobian), Band (direct, 
-%   banded Jacobian), GMRES (iterative, scaled preconditioned GMRES), 
-%   BiCGStab (iterative, scaled preconditioned stabilized BiCG), TFQMR 
-%   (iterative, scaled transpose-free QMR).
-%   The GMRES, BiCGStab, and TFQMR are matrix-free linear solvers.
-%JacobianFn - Jacobian function [ function ]
-%   This propeerty is overloaded. Set this value to a function that returns 
-%   Jacobian information consistent with the linear solver used (see Linsolver). 
-%   If not specified, IDAS uses difference quotient approximations. 
-%   For the Dense linear solver, JacobianFn must be of type IDADenseJacFn and 
-%   must return a dense Jacobian matrix. For the Band linear solver, JacobianFn 
-%   must be of type IDABandJacFn and must return a banded Jacobian matrix. 
-%   For the iterative linear solvers, GMRES, BiCGStab, and TFQMR, JacobianFn must 
-%   be of type IDAJacTimesVecFn and must return a Jacobian-vector product.
-%KrylovMaxDim - Maximum number of Krylov subspace vectors [ integer | {5} ]
-%   Specifies the maximum number of vectors in the Krylov subspace. This property 
-%   is used only if an iterative linear solver, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver).
-%GramSchmidtType - Gram-Schmidt orthogonalization [ Classical | {Modified} ]
-%   Specifies the type of Gram-Schmidt orthogonalization (classical or modified).
-%   This property is used only if the GMRES linear solver is used (see LinSolver).
-%PrecModule - Preconditioner module [ BBDPre | {UserDefined} ]
-%   If PrecModule = 'UserDefined', then the user must provide at least a 
-%   preconditioner solve function (see PrecSolveFn)
-%   IDAS provides one general-purpose preconditioner module, BBDPre, which can 
-%   be only used with parallel vectors. It provide a preconditioner matrix that 
-%   is block-diagonal with banded blocks. The blocking corresponds to the 
-%   distribution of the dependent variable vector y among the processors. 
-%   Each preconditioner block is generated from the Jacobian of the local part 
-%   (on the current processor) of a given function g(t,y,yp) approximating
-%   f(t,y,yp) (see GlocalFn). The blocks are generated by a difference quotient 
-%   scheme on each processor independently. This scheme utilizes an assumed 
-%   banded structure with given half-bandwidths, mldq and mudq (specified through 
-%   LowerBwidthDQ and UpperBwidthDQ, respectively). However, the banded Jacobian 
-%   block kept by the scheme has half-bandwiths ml and mu (specified through 
-%   LowerBwidth and UpperBwidth), which may be smaller.
-%PrecSetupFn - Preconditioner setup function [ function ]
-%   If PrecType is not 'None', PrecSetupFn specifies an optional function which,
-%   together with PrecSolve, defines the preconditioner matrix, which must be an
-%   aproximation to the Newton matrix. PrecSetupFn must be of type IDAPrecSetupFn. 
-%PrecSolveFn - Preconditioner solve function [ function ]
-%   If PrecType is not 'None', PrecSolveFn specifies a required function which 
-%   must solve a linear system Pz = r, for given r. PrecSolveFn must be of type
-%   IDAPrecSolveFn.
-%GlocalFn - Local residual approximation function for BBDPre [ function ]
-%   If PrecModule is BBDPre, GlocalFn specifies a required function that
-%   evaluates a local approximation to the DAE residual. GlocalFn must
-%   be of type IDAGlocFn.
-%GcommFn - Inter-process communication function for BBDPre [ function ]
-%   If PrecModule is BBDPre, GcommFn specifies an optional function
-%   to perform any inter-process communication required for the evaluation of
-%   GlocalFn. GcommFn must be of type IDAGcommFn.
-%LowerBwidth - Jacobian/preconditioner lower bandwidth [ integer | {0} ]
-%   This property is overloaded. If the Band linear solver is used (see LinSolver),
-%   it specifies the lower half-bandwidth of the band Jacobian approximation. 
-%   If one of the three iterative linear solvers, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver) and if the BBDPre preconditioner module in IDAS is used 
-%   (see PrecModule), it specifies the lower half-bandwidth of the retained 
-%   banded approximation of the local Jacobian block.
-%   LowerBwidth defaults to 0 (no sub-diagonals).
-%UpperBwidth - Jacobian/preconditioner upper bandwidth [ integer | {0} ]
-%   This property is overloaded. If the Band linear solver is used (see LinSolver),
-%   it specifies the upper half-bandwidth of the band Jacobian approximation. 
-%   If one of the three iterative linear solvers, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver) and if the BBDPre preconditioner module in IDAS is used 
-%   (see PrecModule), it specifies the upper half-bandwidth of the retained 
-%   banded approximation of the local Jacobian block.
-%   UpperBwidth defaults to 0 (no super-diagonals).
-%LowerBwidthDQ - BBDPre preconditioner DQ lower bandwidth [ integer | {0} ]
-%   Specifies the lower half-bandwidth used in the difference-quotient Jacobian
-%   approximation for the BBDPre preconditioner (see PrecModule).
-%UpperBwidthDQ - BBDPre preconditioner DQ upper bandwidth [ integer | {0} ]
-%   Specifies the upper half-bandwidth used in the difference-quotient Jacobian
-%   approximation for the BBDPre preconditioner (see PrecModule).
-%
-%MonitorFn - User-provied monitoring function [ function ]
-%   Specifies a function that is called after each successful integration step.
-%   This function must have type IDAMonitorFn or IDAMonitorFnB, depending on
-%   whether these options are for a forward or a backward problem, respectively.
-%   Sample monitoring functions IDAMonitor and IDAMonitorB are provided
-%   with IDAS.
-%MonitorData - User-provied data for the monitoring function [ struct ]
-%   Specifies a data structure that is passed to the MonitorFn function every time
-%   it is called. 
-%
-%SensDependent - Backward problem depending on sensitivities [ {false} | true ]
-%   Specifies whether the backward problem right-hand side depends on 
-%   forward sensitivites. If TRUE, the residual function provided for
-%   this backward problem must have the appropriate type (see IDAResFnB).
-%
-%ErrorMessages - Post error/warning messages [ {true} | false ]
-%   Note that any errors in IDAInit will result in a Matlab error, thus
-%   stoping execution. Only subsequent calls to IDAS functions will respect
-%   the value specified for 'ErrorMessages'.
-%
-%NOTES:
-%
-%   The properties listed above that can only be used for forward problems
-%   are: ConstraintTypes, StopTime, RootsFn, and NumRoots.
-%
-%   The property SensDependent is relevant only for backward problems.
-%
-%   See also
-%        IDAInit, IDAReInit, IDAInitB, IDAReInitB
-%        IDAResFn, IDARootFn
-%        IDADenseJacFn, IDABandJacFn, IDAJacTimesVecFn
-%        IDAPrecSetupFn, IDAPrecSolveFn
-%        IDAGlocalFn, IDAGcommFn
-%        IDAMonitorFn
-%        IDAResFnB
-%        IDADenseJacFnB, IDABandJacFnB, IDAJacTimesVecFnB
-%        IDAPrecSetupFnB, IDAPrecSolveFnB
-%        IDAGlocalFnB, IDAGcommFnB
-%        IDAMonitorFnB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.5 $Date: 2007/12/05 21:58:19 $
-
-
-% If called without input and output arguments, print out the possible keywords
-
-if (nargin == 0) & (nargout == 0)
-  fprintf('        UserData: [ empty ]\n');
-  fprintf('\n');
-  fprintf('          RelTol: [ positive scalar | {1e-4} ]\n');
-  fprintf('          AbsTol: [ positive scalar or vector | {1e-6} ]\n');
-  fprintf('     MaxNumSteps: [ positive integer | {500} ]\n');
-  fprintf('     InitialStep: [ positive scalar ]\n');
-  fprintf('         MaxStep: [ positive scalar | {inf} ]\n');
-  fprintf('        MaxOrder: [ 1-12 for Adams, 1-5 for BDF | {5} ]\n');
-  fprintf('        StopTime: [ scalar ]\n');
-  fprintf('         RootsFn: [ function ]\n');
-  fprintf('        NumRoots: [ integer | {0} ]\n');
-  fprintf('\n');
-  fprintf(' SuppressAlgVars: [ on | {off} ]\n');
-  fprintf('   VariableTypes: [ vector ]\n');
-  fprintf(' ConstraintTypes: [ vector ]\n');
-  fprintf('\n');
-  fprintf('    LinearSolver: [ {Dense} | Band | GMRES | BiCGStab | TFQMR ]\n');
-  fprintf('      JacobianFn: [ function ]\n');
-  fprintf('    KrylovMaxDim: [ integer | {5} ]\n');
-  fprintf(' GramSchmidtType: [ Classical | {Modified} ]\n');
-  fprintf('      PrecModule: [ BBDPre | {UserDefined} ]\n');
-  fprintf('     PrecSetupFn: [ function ]\n');
-  fprintf('     PrecSolveFn: [ function ]\n');
-  fprintf('        GlocalFn: [ function ]\n');
-  fprintf('         GcommFn: [ function ]\n');
-  fprintf('     LowerBwidth: [ integer | {0} ]\n');
-  fprintf('     UpperBwidth: [ integer | {0} ]\n');
-  fprintf('   LowerBwidthDQ: [ integer | {0} ]\n');
-  fprintf('   UpperBwidthDQ: [ integer | {0} ]\n');
-  fprintf('\n');
-  fprintf('       MonitorFn: [ function ]\n');
-  fprintf('     MonitorData: [ struct ]\n');
-  fprintf('\n');
-  fprintf('   SensDependent: [ {false} | true ]\n');
-  fprintf('\n');
-  fprintf('   ErrorMessages: [ false | {true} ]\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'UserData'
-    'RelTol'
-    'AbsTol'
-    'MaxNumSteps'
-    'InitialStep'
-    'MaxStep'
-    'MaxOrder'
-    'StopTime'
-    'RootsFn'
-    'NumRoots'
-    'VariableTypes'
-    'ConstraintTypes'
-    'SuppressAlgVars'
-    'LinearSolver'
-    'JacobianFn'
-    'PrecModule'
-    'PrecSetupFn'
-    'PrecSolveFn'
-    'KrylovMaxDim'
-    'GramSchmidtType'
-    'GlocalFn'
-    'GcommFn'
-    'LowerBwidth'
-    'UpperBwidth'
-    'LowerBwidthDQ'
-    'UpperBwidthDQ'
-    'MonitorFn'
-    'MonitorData'
-    'SensDependent'
-    'ErrorMessages'
-           };
-
-options = idm_options(KeyNames,varargin{:});
\ No newline at end of file
diff --git a/sundialsTB/idas/IDASolve.m b/sundialsTB/idas/IDASolve.m
deleted file mode 100644
index 857d52b..0000000
--- a/sundialsTB/idas/IDASolve.m
+++ /dev/null
@@ -1,56 +0,0 @@
-function [varargout] = IDASolve(tout,itask)
-%IDASolve integrates the DAE.
-%
-%   Usage: [STATUS, T, Y] = IDASolve ( TOUT, ITASK ) 
-%          [STATUS, T, Y, YQ] = IDASolve  (TOUT, ITASK )
-%          [STATUS, T, Y, YS] = IDASolve ( TOUT, ITASK )
-%          [STATUS, T, Y, YQ, YS] = IDASolve ( TOUT, ITASK )
-%
-%   If ITASK is 'Normal', then the solver integrates from its current internal 
-%   T value to a point at or beyond TOUT, then interpolates to T = TOUT and returns 
-%   Y(TOUT). If ITASK is 'OneStep', then the solver takes one internal time step 
-%   and returns in Y the solution at the new internal time. In this case, TOUT 
-%   is used only during the first call to IDASolve to determine the direction of 
-%   integration and the rough scale of the problem. In either case, the time 
-%   reached by the solver is returned in T.
-%
-%   If quadratures were computed (see IDAQuadInit), IDASolve will return their
-%   values at T in the vector YQ.
-%
-%   If sensitivity calculations were enabled (see IDASensInit), IDASolve will 
-%   return their values at T in the matrix YS. Each row in the matrix YS
-%   represents the sensitivity vector with respect to one of the problem parameters.
-%
-%   In ITASK =' Normal' mode, to obtain solutions at specific times T0,T1,...,TFINAL
-%   (all increasing or all decreasing) use TOUT = [T0 T1  ... TFINAL]. In this case
-%   the output arguments Y and YQ are matrices, each column representing the solution
-%   vector at the corresponding time returned in the vector T. If computed, the 
-%   sensitivities are eturned in the 3-dimensional array YS, with YS(:,:,I) representing
-%   the sensitivity vectors at the time T(I).
-%
-%   On return, STATUS is one of the following:
-%     0: IDASolve succeeded and no roots were found.
-%     1: IDASolve succeded and returned at tstop.
-%     2: IDASolve succeeded, and found one or more roots. 
-%    -1: An error occurred (see printed message).
-%
-%   See also IDASetOptions, IDAGetStats
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.5 $Date: 2011/06/01 22:05:01 $
-
-
-mode = 20;
-
-if nargin ~= 2
-  error('Wrong number of input arguments');
-end
-
-if nargout < 3 || nargout > 5
-  error('Wrong number of output arguments');
-end
-
-varargout = cell (nargout, 1);
-
-[varargout{:}] = idm(mode,tout,itask);
diff --git a/sundialsTB/idas/IDASolveB.m b/sundialsTB/idas/IDASolveB.m
deleted file mode 100644
index c9d6512..0000000
--- a/sundialsTB/idas/IDASolveB.m
+++ /dev/null
@@ -1,50 +0,0 @@
-function [varargout] = IDASolveB(tout,itask)
-%IDASolveB integrates the backward DAE.
-%
-%   Usage:  [STATUS, T, YB] = IDASolveB ( TOUT, ITASK ) 
-%           [STATUS, T, YB, YQB] = IDASolveB ( TOUT, ITASK )
-%
-%   If ITASK is 'Normal', then the solver integrates from its current internal 
-%   T value to a point at or beyond TOUT, then interpolates to T = TOUT and returns 
-%   YB(TOUT). If ITASK is 'OneStep', then the solver takes one internal time step 
-%   and returns in YB the solution at the new internal time. In this case, TOUT 
-%   is used only during the first call to IDASolveB to determine the direction of 
-%   integration and the rough scale of the problem. In either case, the time 
-%   reached by the solver is returned in T. 
-%
-%   If quadratures were computed (see IDAQuadInitB), IDASolveB will return their
-%   values at T in the vector YQB.
-%
-%   In ITASK =' Normal' mode, to obtain solutions at specific times T0,T1,...,TFINAL
-%   (all increasing or all decreasing) use TOUT = [T0 T1  ... TFINAL]. In this case
-%   the output arguments YB and YQB are matrices, each column representing the solution
-%   vector at the corresponding time returned in the vector T.
-%
-%   If more than one backward problem was defined, the return arguments are cell
-%   arrays, with T{IDXB}, YB{IDXB}, and YQB{IDXB} corresponding to the backward
-%   problem with index IDXB (as returned by IDAInitB).
-%
-%   On return, STATUS is one of the following:
-%     0: IDASolveB succeeded.
-%     1: IDASolveB succeded and return at a tstop value (internally set).
-%    -1: An error occurred (see printed message).
-%
-%   See also IDASetOptions, IDAGetStatsB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.5 $Date: 2011/06/01 22:05:01 $
-
-mode = 21;
-
-if nargin ~= 2
-  error('Wrong number of input arguments');
-end
-
-if nargout < 3 || nargout > 4
-  error('Wrong number of output arguments');
-end
-
-varargout = cell (nargout, 1);
-[varargout{:}] = idm(mode,tout,itask);
-
diff --git a/sundialsTB/idas/examples_ser/midasBruss_ASA_dns.m b/sundialsTB/idas/examples_ser/midasBruss_ASA_dns.m
deleted file mode 100644
index 3ef330c..0000000
--- a/sundialsTB/idas/examples_ser/midasBruss_ASA_dns.m
+++ /dev/null
@@ -1,446 +0,0 @@
-function midasBruss_ASA_dns
-%midasBruss_ASA_dns - ASA example for the Brusselator problem
-%  This example solves the forward and adjoint problems for
-%  the 2D Brusselator example.
-%
-%  See also: midasBruss_dns
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-%--------------
-% Problem data
-%--------------
-
-eps = 2.0e-3; % diffusion param
-A = 1.0;
-B = 3.4;
-
-% Spatial length 0 <= x,y, <= L
-L = 1.0;
-
-% grid size
-mx = 20;
-my = 20;
-dx = L/mx;
-dy = L/my;
-
-% coefficients in central FD
-hdif = eps/dx^2;
-vdif = eps/dy^2;
-
-% problem dimension
-nx = mx+1;
-ny = my+1;
-n = 2*nx*ny;
-
-x = linspace(0,L,nx);
-y = linspace(0,L,ny);
-
-% Load user data structure
-data.eps = eps;
-data.A = A;
-data.B = B;
-data.L = L;
-data.dx = dx;
-data.dy = dy;
-data.nx = nx;
-data.ny = ny;
-data.x = x;
-data.y = y;
-data.hdif = hdif;
-data.vdif = vdif;
-
-% ---------------------
-% Initialize integrator
-% ---------------------
-
-% Integration limits
-
-t0 = 0.0;
-tf = 1.0;
-
-% Initial conditions
-
-[u, v] = BRUSic(data);
-Y = UV2Y(u, v, data);
-Yp = zeros(n,1);
-
-% Specify algebraic variables
-
-u_id = ones(ny,nx);
-u_id(1,:) = 0;
-u_id(ny,:) = 0;
-u_id(:,1) = 0;
-u_id(:,nx) = 0;
-
-v_id = ones(ny,nx);
-v_id(1,:) = 0;
-v_id(ny,:) = 0;
-v_id(:,1) = 0;
-v_id(:,nx) = 0;
-
-id = UV2Y(u_id, v_id, data);
-
-% Optional inputs
-
-options = IDASetOptions('UserData',data,...
-                        'RelTol',1.e-5,...
-                        'AbsTol',1.e-5,...
-                        'VariableTypes',id,...
-                        'suppressAlgVars','on',...
-                        'MaxNumSteps', 1000,...
-                        'LinearSolver','Dense');
-
-% Initialize forward problem
-
-IDAInit(@BRUSres,t0,Y,Yp,options);
-
-% Compute consistent I.C.
-
-[status, Y, Yp] = IDACalcIC(tf, 'FindAlgebraic');
-
-% --------------
-% Initialize ASA
-% --------------
-
-IDAAdjInit(150, 'Hermite');
-
-% ---------------
-% Integrate to tf
-% ---------------
-
-[status, t, Y] = IDASolve(tf, 'Normal');
-
-[u,v] = Y2UV(Y, data);
-
-stats_fwd = IDAGetStats;
-
-plotSol(t,Y,data);
-
-% ---------------------------
-% Initialize backward problem
-% ---------------------------
-
-% Specify algebraic variables
-
-l_id = ones(ny,nx);
-l_id(1,:) = 0;
-l_id(ny,:) = 0;
-l_id(:,1) = 0;
-l_id(:,nx) = 0;
-
-m_id = ones(ny,nx);
-m_id(1,:) = 0;
-m_id(ny,:) = 0;
-m_id(:,1) = 0;
-m_id(:,nx) = 0;
-
-idB = UV2Y(l_id, m_id, data);
-
-% Final conditions
-
-l = ones(ny,nx);
-m = zeros(ny,nx);
-YB = UV2Y(l, m, data);
-
-lp = -2.0 * u .* v .* l + (B+1) * l;
-mp = - l .* (u.^2);
-YBp = UV2Y(lp, mp, data);
-
-% Optional inputs
-
-optionsB = IDASetOptions('UserData',data,...
-                         'RelTol',1.e-5,...
-                         'AbsTol',1.e-5,...
-                         'VariableTypes',id,...
-                         'suppressAlgVars','on',...
-                         'LinearSolver','Dense');
-
-% Initialize backward problem
-
-idxB = IDAInitB(@BRUSresB,tf,YB,YBp,optionsB);
-
-% --------------------------
-% Backward integration to t0
-% --------------------------
-
-[status, t, YB] = IDASolveB(t0,'Normal');
-
-plotSol(t,YB,data);
-
-% -----------
-% Free memory
-% -----------
-
-IDAFree;
-
-return
-
-
-
-
-
-
-% ====================================================================================
-% Initial conditions
-% ====================================================================================
-
-function [u0, v0] = BRUSic(data)
-
-dx = data.dx;
-dy = data.dy;
-nx = data.nx;
-ny = data.ny;
-L  = data.L;
-x  = data.x;
-y  = data.y;
-
-n = 2*nx*ny;
-
-[x2D , y2D] = meshgrid(x,y);
-
-u0 = 1.0 - 0.5 * cos(pi*y2D/L);
-u0(1,:) = u0(2,:);
-u0(ny,:) = u0(ny-1,:);
-u0(:,1) = u0(:,2);
-u0(:,nx) = u0(:,nx-1);
-
-v0 = 3.5 - 2.5*cos(pi*x2D/L);
-v0(1,:) = v0(2,:);
-v0(ny,:) = v0(ny-1,:);
-v0(:,1) = v0(:,2);
-v0(:,nx) = v0(:,nx-1);
-
-return
-
-
-
-
-
-% ====================================================================================
-% Residual function
-% ====================================================================================
-
-function [res, flag, new_data] = BRUSres(t,Y,Yp,data)
-
-nx = data.nx;
-ny = data.ny;
-
-A = data.A;
-B = data.B;
-
-hdif = data.hdif;
-vdif = data.vdif;
-
-% Convert Y and Yp to (u,v) and (up, vp)
-
-[u,v] = Y2UV(Y,data);
-[up,vp] = Y2UV(Yp,data);
-
-% 2D residuals
-
-ru = zeros(ny,nx);
-rv = zeros(ny,nx);
-
-% Inside the domain
-
-for iy = 2:ny-1
-
-  for ix = 2:nx-1
-    
-    uu = u(iy,ix);
-    vv = v(iy,ix);
-    
-    ru(iy,ix) = up(iy,ix) ...
-        - hdif * ( u(iy,ix+1) - 2*uu + u(iy,ix-1) ) ...
-        - vdif * ( u(iy+1,ix) - 2*uu + u(iy-1,ix) ) ...
-        - A + (B+1)*uu - uu^2 * vv;
-
-    rv(iy,ix) = vp(iy,ix) ...
-        - hdif * ( v(iy,ix+1) - 2*vv + v(iy,ix-1) ) ...
-        - vdif * ( v(iy+1,ix) - 2*vv + v(iy-1,ix) ) ...
-        - B*uu + uu^2 * vv;
-    
-  end
-  
-end
-    
-% Boundary conditions
-
-ru(1,:) = u(1,:) - u(2,:);
-ru(ny,:) = u(ny,:) - u(ny-1,:);
-ru(:,1) = u(:,1) - u(:,2);
-ru(:,nx) = u(:,nx) - u(:,nx-1);
-
-rv(1,:) = v(1,:) - v(2,:);
-rv(ny,:) = v(ny,:) - v(ny-1,:);
-rv(:,1) = v(:,1) - v(:,2);
-rv(:,nx) = v(:,nx) - v(:,nx-1);
-
-% Convert (ru,rv) to res
-
-res = UV2Y(ru,rv,data);
-
-% Return flag and pb. data
-
-flag = 0;
-new_data = [];
-
-
-
-
-% ====================================================================================
-% Backward residual function
-% ====================================================================================
-
-function [resB, flag, new_data] = BRUSresB(t, Y, Yp, YB, YBp, data)
-
-nx = data.nx;
-ny = data.ny;
-
-A = data.A;
-B = data.B;
-
-hdif = data.hdif;
-vdif = data.vdif;
-
-% Convert Y to (u,v)
-
-[u,v] = Y2UV(Y,data);
-
-% Convert YB and YBp to (l,m) and (lp,mp)
-
-[l,m] = Y2UV(YB,data);
-[lp,mp] = Y2UV(YBp,data);
-
-% 2D residuals
-
-rl = zeros(ny,nx);
-rm = zeros(ny,nx);
-
-% Inside the domain
-
-for iy = 2:ny-1
-
-  for ix = 2:nx-1
-
-    uu = u(iy,ix);
-    vv = v(iy,ix);
-    
-    ll = l(iy,ix);
-    mm = m(iy,ix);
-   
-    rl(iy,ix) = lp(iy,ix) ...
-        + hdif * ( l(iy,ix+1) - 2*ll + l(iy,ix-1) ) ...
-        + vdif * ( l(iy+1,ix) - 2*ll + l(iy-1,ix) ) ...
-        + 2*uu*vv*ll - (B+1)*ll + B*mm - 2*uu*vv*mm;
-
-    rm(iy,ix) = mp(iy,ix) ...
-        + hdif * ( m(iy,ix+1) - 2*mm + m(iy,ix-1) ) ...
-        + vdif * ( m(iy+1,ix) - 2*mm + m(iy-1,ix) ) ...
-        + ll * uu^2 - mm * uu^2;
-    
-  end
-  
-end
-
-% Boundary conditions
-
-rl(1,:) = l(1,:) - l(2,:);
-rl(ny,:) = l(ny,:) - l(ny-1,:);
-rl(:,1) = l(:,1) - l(:,2);
-rl(:,nx) = l(:,nx) - l(:,nx-1);
-
-rm(1,:) = m(1,:) - m(2,:);
-rm(ny,:) = m(ny,:) - m(ny-1,:);
-rm(:,1) = m(:,1) - m(:,2);
-rm(:,nx) = m(:,nx) - m(:,nx-1);
-
-% Convert (rl,rm) to resB
-
-resB = UV2Y(rl,rm,data);
-
-% Return flag and pb. data
-
-flag = 0;
-new_data = [];
-
-
-
-
-
-% ====================================================================================
-% 1D <-> 2D conversion functions
-% ====================================================================================
-
-function y = UV2Y(u, v, data)
-
-nx = data.nx;
-ny = data.ny;
-
-u1 = reshape(u, 1, nx*ny);
-v1 = reshape(v, 1, nx*ny);
-
-y = reshape([u1;v1], 2*nx*ny,1);
-
-return
-
-
-function [u,v] = Y2UV(y, data)
-
-nx = data.nx;
-ny = data.ny;
-
-y2 = reshape(y, 2, nx*ny);
-
-u = reshape(y2(1,:), ny, nx);
-v = reshape(y2(2,:), ny, nx);
-
-return
-
-
-
-
-% ====================================================================================
-% Plot (u,v)
-% ====================================================================================
-
-function plotSol(t,Y,data)
-
-x = data.x;
-y = data.y;
-
-[u,v] = Y2UV(Y, data);
-
-figure;
-set(gcf,'position',[600 600 650 300])
-
-subplot(1,2,1)
-surfc(x,y,u);
-shading interp
-%view(0,90)
-view(-15,35)
-axis tight
-box on
-grid off
-xlabel('x');
-ylabel('y');
-title(sprintf('u(x,y,%g)',t))
-%colorbar('horiz');
-
-subplot(1,2,2)
-surfc(x,y,v);
-shading interp
-%view(0,90)
-view(-15,35)
-axis tight
-box on
-grid off
-xlabel('x');
-ylabel('y');
-title(sprintf('v(x,y,%g)',t))
-%colorbar('horiz');
-
-return
diff --git a/sundialsTB/idas/examples_ser/midasBruss_dns.m b/sundialsTB/idas/examples_ser/midasBruss_dns.m
deleted file mode 100644
index 2148044..0000000
--- a/sundialsTB/idas/examples_ser/midasBruss_dns.m
+++ /dev/null
@@ -1,301 +0,0 @@
-function midasBruss_dns
-%midasBruss_dns Brusselator example
-%  This example solves the 2D Brusselator example on an (mx)x(my)
-%  grid of the square with side L, using the MOL with central 
-%  finite-differences for the semidiscretization in space.
-%  Homogeneous BC on all sides are incorporated as algebraic
-%  constraints.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-%--------------
-% Problem data
-%--------------
-
-eps = 2.0e-3; % diffusion param
-A = 1.0;
-B = 3.4;
-
-% Spatial length 0 <= x,y, <= L
-L = 1.0;
-
-% grid size
-mx = 20;
-my = 20;
-dx = L/mx;
-dy = L/my;
-
-% coefficients in central FD
-hdif = eps/dx^2;
-vdif = eps/dy^2;
-
-% problem dimension
-nx = mx+1;
-ny = my+1;
-n = 2*nx*ny;
-
-x = linspace(0,L,nx);
-y = linspace(0,L,ny);
-
-data.eps = eps;
-data.A = A;
-data.B = B;
-data.L = L;
-data.dx = dx;
-data.dy = dy;
-data.nx = nx;
-data.ny = ny;
-data.x = x;
-data.y = y;
-data.hdif = hdif;
-data.vdif = vdif;
-
-%-------------------
-% Initial conditions
-%-------------------
-
-[u0, v0] = BRUSic(data);
-Y0 = UV2Y(u0, v0, data);
-Yp0 = zeros(n,1);
-
-% ---------------------
-% Initialize integrator
-% ---------------------
-
-% Integration limits
-
-t0 = 0.0;
-tf = 1.0;
-
-% Specify algebraic variables
-
-u_id = ones(ny,nx);
-u_id(1,:) = 0;
-u_id(ny,:) = 0;
-u_id(:,1) = 0;
-u_id(:,nx) = 0;
-
-v_id = ones(ny,nx);
-v_id(1,:) = 0;
-v_id(ny,:) = 0;
-v_id(:,1) = 0;
-v_id(:,nx) = 0;
-
-id = UV2Y(u_id, v_id, data);
-
-options = IDASetOptions('UserData',data,...
-                        'RelTol',1.e-5,...
-                        'AbsTol',1.e-5,...
-                        'VariableTypes',id,...
-                        'suppressAlgVars','on',...
-                        'MaxNumSteps', 1000,...
-                        'LinearSolver','Dense');
-
-% Initialize IDAS
-
-IDAInit(@BRUSres,t0,Y0,Yp0,options);
-
-% Compute consistent I.C.
-
-[status, Y0, Yp0] = IDACalcIC(tf, 'FindAlgebraic');
-
-% ---------------
-% Integrate to tf
-% ---------------
-
-plotSol(t0,Y0,data);
-
-[status, t, Y] = IDASolve(tf, 'Normal');
-
-plotSol(t,Y,data);
-
-% -----------
-% Free memory
-% -----------
-
-IDAFree;
-
-
-%%save foo.mat t Y data
-
-return
-
-
-% ====================================================================================
-% Initial conditions
-% ====================================================================================
-
-function [u0, v0] = BRUSic(data)
-
-dx = data.dx;
-dy = data.dy;
-nx = data.nx;
-ny = data.ny;
-L  = data.L;
-x  = data.x;
-y  = data.y;
-
-n = 2*nx*ny;
-
-[x2D , y2D] = meshgrid(x,y);
-
-u0 = 1.0 - 0.5 * cos(pi*y2D/L);
-u0(1,:) = u0(2,:);
-u0(ny,:) = u0(ny-1,:);
-u0(:,1) = u0(:,2);
-u0(:,nx) = u0(:,nx-1);
-
-v0 = 3.5 - 2.5*cos(pi*x2D/L);
-v0(1,:) = v0(2,:);
-v0(ny,:) = v0(ny-1,:);
-v0(:,1) = v0(:,2);
-v0(:,nx) = v0(:,nx-1);
-
-return
-
-
-% ====================================================================================
-% 1D <-> 2D conversion functions
-% ====================================================================================
-
-function y = UV2Y(u, v, data)
-
-nx = data.nx;
-ny = data.ny;
-
-u1 = reshape(u, 1, nx*ny);
-v1 = reshape(v, 1, nx*ny);
-
-y = reshape([u1;v1], 2*nx*ny,1);
-
-return
-
-
-function [u,v] = Y2UV(y, data)
-
-nx = data.nx;
-ny = data.ny;
-
-y2 = reshape(y, 2, nx*ny);
-
-u = reshape(y2(1,:), ny, nx);
-v = reshape(y2(2,:), ny, nx);
-
-return
-
-% ====================================================================================
-% Residual function
-% ====================================================================================
-
-function [res, flag, new_data] = BRUSres(t,Y,Yp,data)
-
-dx = data.dx;
-dy = data.dy;
-nx = data.nx;
-ny = data.ny;
-
-eps = data.eps;
-A = data.A;
-B = data.B;
-L = data.L;
-
-hdif = data.hdif;
-vdif = data.vdif;
-
-% Convert Y and Yp to (u,v) and (up, vp)
-
-[u,v] = Y2UV(Y,data);
-[up,vp] = Y2UV(Yp,data);
-
-% 2D residuals
-
-ru = zeros(ny,nx);
-rv = zeros(ny,nx);
-
-% Inside the domain
-
-for iy = 2:ny-1
-
-  for ix = 2:nx-1
-    
-    uu = u(iy,ix);
-    vv = v(iy,ix);
-    
-    ru(iy,ix) = up(iy,ix) - ...
-        hdif * ( u(iy,ix+1) - 2*uu + u(iy,ix-1) ) - ...
-        vdif * ( u(iy+1,ix) - 2*uu + u(iy-1,ix) ) - ...
-        A + (B+1)*uu - uu^2 * vv;
-
-    rv(iy,ix) = vp(iy,ix) - ...
-        hdif * ( v(iy,ix+1) - 2*vv + v(iy,ix-1) ) - ...
-        vdif * ( v(iy+1,ix) - 2*vv + v(iy-1,ix) ) - ...
-        B*uu + uu^2 * vv;
-    
-  end
-  
-end
-    
-% Boundary conditions
-
-ru(1,:) = u(1,:) - u(2,:);
-ru(ny,:) = u(ny,:) - u(ny-1,:);
-ru(:,1) = u(:,1) - u(:,2);
-ru(:,nx) = u(:,nx) - u(:,nx-1);
-
-rv(1,:) = v(1,:) - v(2,:);
-rv(ny,:) = v(ny,:) - v(ny-1,:);
-rv(:,1) = v(:,1) - v(:,2);
-rv(:,nx) = v(:,nx) - v(:,nx-1);
-
-% Convert (ru,rv) to res
-
-res = UV2Y(ru,rv,data);
-
-% Return flag and pb. data
-
-flag = 0;
-new_data = [];
-
-% ====================================================================================
-% Plot (u,v)
-% ====================================================================================
-
-function plotSol(t,Y,data)
-
-x = data.x;
-y = data.y;
-
-[u,v] = Y2UV(Y, data);
-
-figure;
-set(gcf,'position',[600 600 650 300])
-
-subplot(1,2,1)
-surfc(x,y,u);
-shading interp
-%view(0,90)
-view(-15,35)
-axis tight
-box on
-grid off
-xlabel('x');
-ylabel('y');
-title(sprintf('u(x,y,%g)',t))
-%colorbar('horiz');
-
-subplot(1,2,2)
-surfc(x,y,v);
-shading interp
-%view(0,90)
-view(-15,35)
-axis tight
-box on
-grid off
-xlabel('x');
-ylabel('y');
-title(sprintf('v(x,y,%g)',t))
-%colorbar('horiz');
-
-return
diff --git a/sundialsTB/idas/examples_ser/midasHeat2D_bnd.m b/sundialsTB/idas/examples_ser/midasHeat2D_bnd.m
deleted file mode 100644
index 369b325..0000000
--- a/sundialsTB/idas/examples_ser/midasHeat2D_bnd.m
+++ /dev/null
@@ -1,175 +0,0 @@
-function midasHeat2D_bnd
-%midasHeat2D_bnd: 2D heat equation, serial, banded.
-%
-% This example solves a discretized 2D heat equation problem.
-% This version uses the band solver IDABand, and IDACalcIC.
-%
-% The DAE system solved is a spatial discretization of the PDE
-%          du/dt = d^2u/dx^2 + d^2u/dy^2
-% on the unit square. The boundary condition is u = 0 on all edges.
-% Initial conditions are given by u = 16 x (1 - x) y (1 - y).
-% The PDE is treated with central differences on a uniform M x M
-% grid. The values of u at the interior points satisfy ODEs, and
-% equations u = 0 at the boundaries are appended, to form a DAE
-% system of size N = M^2. Here M = 10.
-%
-% The system is solved with IDA using the banded linear system
-% solver, half-bandwidths equal to M, and default
-% difference-quotient Jacobian. For purposes of illustration,
-% IDACalcIC is called to compute correct values at the boundary,
-% given incorrect values as input initial guesses. The constraints
-% u >= 0 are posed for all components. Output is taken at
-% t = 0, .01, .02, .04, ..., 10.24. (Output at t = 0 is for
-% IDACalcIC cost statistics only.)
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-m = 20;
-N = m^2;
-data.m = m;
-data.N = N;
-data.dx = 1.0/(m-1);
-data.c = 1.0/data.dx^2;
-
-fp = figure;
-set(gcf,'position',[250 175 560 900]);
-
-[t0,yy0,yp0,id,cnstr] = ic(data); 
-
-% Plot initial guess for IC
-
-figure(fp);
-subplot(2,1,1);
-hold on
-hs1 = surf(reshape(yy0,m,m));
-shading interp
-set(hs1,'FaceAlpha',0.35);
-box on
-view(-30,30)
-
-options = IDASetOptions('UserData',data,...
-                        'RelTol',0.0,...
-                        'AbsTol',1.0e-3,...
-                        'VariableTypes',id,...
-                        'ConstraintTypes',cnstr,...
-                        'LinearSolver','Band',...
-                        'LowerBwidth',m,...
-                        'UpperBwidth',m);
-
-IDAInit(@resfun,t0,yy0,yp0,options);
-
-tout = 0.01;
-[status, yy0_mod, yp0_mod] = IDACalcIC(tout, 'FindAlgebraic');
-
-% Plot corrected IC
-
-figure(fp);
-subplot(2,1,1);
-hs1 = surf(reshape(yy0_mod,m,m));
-set(hs1,'FaceColor','none');
-
-
-% Plot solution
-
-subplot(2,1,2);
-hold on
-hs1 = surf(reshape(yy0_mod,m,m));
-shading interp
-view(-30,30)
-zlim_yy = get(gca,'ZLim');
-box on
-
-fprintf('t = %.4f    [Press any key]\n',t0);
-pause;
-
-nout = 5;
-tout = 0.01;
-
-for iout = 1:nout
-  [status,t,yy] = IDASolve(tout,'Normal');
-  tout = 2*tout;
-
-  figure(fp);
-  subplot(2,1,2);
-  set(hs1,'FaceAlpha',0.15);
-  hs1 = surf(reshape(yy,m,m));
-  shading interp
-  set(gca,'ZLim',zlim_yy);
-
-  fprintf('t = %.4f    [Press any key]\n',t);
-  pause;
-  
-end
-
-IDAFree;
-
-
-function [t,yy,yp,id,cnstr] = ic(data)
-
-m = data.m;
-N = data.N;
-dx = data.dx;
-
-id = ones(N,1);
-cnstr = ones(N,1);
-yy = zeros(N,1);
-yp = zeros(N,1);
-
-t = 0.0;
-
-% Initialize yy on all grid points. */ 
-for j=0:m-1
-  yfact = dx * j;
-  offset = m*j;
-  for i=0:m-1
-    xfact = dx * i;
-    loc = offset + i + 1;
-    yy(loc) = 16.0 * xfact * (1.0 - xfact) * yfact * (1.0 - yfact);
-  end
-end
-  
-% The residual gives the negative of ODE RHS values at 
-% interior points.
-yp = zeros(N,1);
-[yp,flag,new_data] = resfun(t,yy,yp,data);
-yp = -yp;
-
-% Finally, set values of yy, yp, and id at boundary points.
-for j=0:m-1
-  offset = m*j;
-  for i=0:m-1
-    loc = offset + i + 1;
-    if (j == 0 || j == m-1 || i == 0 || i == m-1 )
-        yy(loc) = 0.1;
-        yp(loc) = 0.0;
-        id(loc) = 0.0;
-    end
-  end
-end
-
-% ====================================================================
-
-function [rr,flag,new_data] = resfun(t,yy,yp,data)
-
-m = data.m;
-N = data.N;
-dx = data.dx;
-c = data.c;
-
-% Initialize resval to uu, to take care of boundary equations.
-rr = yy;
-  
-% Loop over interior points; set rr = yp - (central difference).
-for j = 1:m-2
-  offset = m*j;
-  for i = 1:m-2
-    loc = offset + i + 1;
-    rr(loc) = yp(loc) - c * ...
-	  (yy(loc-1) + yy(loc+1) + yy(loc-m) + yy(loc+m) - 4.0*yy(loc));
-  end
-end
-
-flag = 0;
-new_data = [];
\ No newline at end of file
diff --git a/sundialsTB/idas/examples_ser/midasPendI1_dns.m b/sundialsTB/idas/examples_ser/midasPendI1_dns.m
deleted file mode 100644
index 72dd96c..0000000
--- a/sundialsTB/idas/examples_ser/midasPendI1_dns.m
+++ /dev/null
@@ -1,183 +0,0 @@
-function midasPendI1_dns
-%midasPendI1_dns - Simple pendulum modeled as an index-1 DAE
-%  The pendulum is modeled using the x and y positions with
-%  the constraint x^2 + y^2 = L^2
-%  The index-1 DAE formulation (in first-order form) includes
-%  differential equations for the positions and velocities and
-%  the acceleration-level constraint.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-
-% x, y, vx, vy, lam
-neq = 5;
-
-t0 = 0.0;
-tf = 10.0;
-
-id = ones(neq,1);
-id(5) = 0;
-
-options = IDASetOptions('RelTol',1.e-6,...
-                        'AbsTol',1.e-6,...
-                        'VariableTypes',id,...
-                        'MaxNumSteps', 1000,...
-                        'LinearSolver','Dense',...
-                        'JacobianFn', at pend_J);
-%mondata.update = 100;
-%options = IDASetOptions(options,'MonitorFn', at IDAMonitor,'MonitorData',mondata);
-
-y0 = zeros(neq,1);
-y0(1) = 1.0;
-y0(5) = 0.1;
-yp0 = zeros(neq,1);
-fprintf('Estimated IC\n');
-disp([y0 yp0])
-
-IDAInit(@pend_f,t0,y0,yp0,options);
-
-[status, y0_mod, yp0_mod] = IDACalcIC(tf, 'FindAlgebraic');
-fprintf('Corrected IC\n');
-disp([y0_mod yp0_mod])
-
-it = 1;
-time(it) = t0;
-sol_y(it,:) = y0_mod';
-[pc(it) vc(it)] = pend_constr(t0,y0_mod);
-
-%t = t0;
-%t_start = clock;
-%while t < tf
-%  [status,t,y] = IDASolve(tf,'OneStep');
-%  it = it+1;
-%  time(it) = t;
-%  sol_y(it,:) = y';
-%  % Compute position and velocity constraint violations
-%  [pc(it) vc(it)] = pend_constr(t,y);
-%end
-%runtime = etime(clock,t_start);
-
-
-dt = 0.1;
-nt = ceil((tf-t0)/dt);
-
-t_start = clock;
-for it = 1:nt
-  tout = t0 + it*dt;
-  [status,t,y] = IDASolve(tout,'Normal');
-  time(it) = t;
-  sol_y(it,:) = y';
-% Compute position and velocity constraint violations
-  [pc(it) vc(it)] = pend_constr(t,y);
-end
-runtime = etime(clock,t_start);
-
-fprintf('Solver stats:\n');
-disp(IDAGetStats);
-fprintf('Run time: %f\n',runtime);
-
-
-figure;
-
-subplot(3,1,1)
-hold on
-plot(time,sol_y(:,1),'b');
-plot(time,sol_y(:,2),'r');
-box on
-set(gca,'XLim',[t0 tf])
-title('position');
-legend('x','y');
-
-subplot(3,1,2)
-hold on
-plot(time,sol_y(:,3),'b');
-plot(time,sol_y(:,4),'r');
-box on
-set(gca,'XLim',[t0 tf])
-title('velocity');
-legend('v_x', 'v_y');
-
-subplot(3,1,3)
-plot(time,sol_y(:,5));
-box on
-set(gca,'XLim',[t0 tf])
-title('Lagrange multiplier');
-
-figure
-
-plotyy(time, pc, time, vc);
-box on
-title('position and velocity constraint violations');
-
-figure
-
-subplot(2,1,1)
-plot(sol_y(:,1),sol_y(:,2));
-axis equal
-axis tight
-box on
-grid on
-xlabel('x');
-ylabel('y');
-title('trajectory');
-
-phi = atan2( sol_y(:,1) , sol_y(:,2) );
-phi_d = ( sol_y(:,1).*sol_y(:,4) - sol_y(:,2).*sol_y(:,3) ) ./ ( sol_y(:,1).^2 + sol_y(:,2).^2 ) ;
-subplot(2,1,2)
-plot3(time,phi, phi_d);
-xlabel('time');
-ylabel('\phi');
-zlabel('\phi^\prime');
-view(-30,15);
-set(gca,'XLim',[t0 tf])
-grid on
-box on
-title('phase plot');
-
-IDAFree;
-
-% ================================================================================
-
-function [res, flag, new_data] = pend_f(t,y,yp)
-% Residual function for a simple pendulum
-%   mass = 1.0
-%   length = 1.0
-%   damping coeff. = 0.3
-%   g = 9.81
-
-res = [
-    -yp(1) + y(3)  
-    -yp(2) + y(4)  
-    -yp(3) - 2*y(1)*y(5) - 0.3*y(3)  
-    -yp(4) + 9.81 - 2*y(2)*y(5) - 0.3*y(4)  
-    -2*y(5) + y(3)^2 - 0.3*y(1)*y(3) + y(4)^2 + y(2)*(9.81-0.3*y(4))
-	];
-
-flag = 0;
-new_data = [];
-
-% ================================================================================
-
-function [J, flag, new_data] = pend_J(t,y,yp, rr, cj)
-
-J = [
-    -cj 0 1 0 0  
-    0 -cj 0 1 0  
-    -2*y(5) 0 -cj-0.3 0 -2*y(1)  
-    0 -2*y(5) 0 -cj-0.3 -2*y(2)  
-    -0.3*y(3) 9.81-0.3*y(4) 2*y(3)-0.3*y(1) 2*y(4)-0.3*y(2) -2
-    ];
-
-flag = 0;
-new_data = [];
-
-% ================================================================================
-
-function [pc, vc] = pend_constr(t,y)
-%  Position and velocity constraints
-%
-
-pc = y(1)^2 + y(2)^2 - 1.0;
-vc = y(1)*y(3) + y(2)*y(4);
\ No newline at end of file
diff --git a/sundialsTB/idas/examples_ser/midasPendI2_dns.m b/sundialsTB/idas/examples_ser/midasPendI2_dns.m
deleted file mode 100644
index 437a07f..0000000
--- a/sundialsTB/idas/examples_ser/midasPendI2_dns.m
+++ /dev/null
@@ -1,158 +0,0 @@
-function midasPendI2_dns
-%midasPendI1_dns - Simple pendulum modeled as an index-2 DAE
-%  The pendulum is modeled using the x and y positions with
-%  the constraint x^2 + y^2 = L^2
-%  The stabilized index-2 (GGL formulation) DAE (in first-order form)
-%  includes differential equations for the positions and velocities
-%  with additional Lagrange multipliers included in the position
-%  differential equations) and the position and velocity constraints.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-% x, y, vx, vy, lam, mu
-neq = 6;
-
-t0 = 0.0;
-tf = 10.0;
-
-id = ones(neq,1);
-id(5) = 0;
-id(6) = 0;
-
-options = IDASetOptions('RelTol',1.e-6,...
-                        'AbsTol',1.e-6,...
-                        'VariableTypes',id,...
-                        'suppressAlgVars','on',...
-                        'MaxNumSteps', 1000,...
-                        'LinearSolver','Dense');
-y0 = zeros(neq,1);
-yp0 = zeros(neq,1);
-y0(1) = 1.0;
-yp0(4) = 9.81;
-fprintf('Consistent IC:\n');
-disp([y0 yp0])
-
-IDAInit(@pendGGL_f,t0,y0,yp0,options);
-
-it = 1;
-time(it) = t0;
-sol_y(it,:) = y0';
-[res, dummy1, status] = pendGGL_f(t0, y0, yp0);
-pc(it) = res(5);
-vc(it) = res(6);
-
-t = t0;
-t_start = clock;
-while t < tf
-  [status,t,y] = IDASolve(tf,'OneStep');
-  it = it+1;
-  time(it) = t;
-  sol_y(it,:) = y';
-  yp=yp0;
-  % For verification purposes only, compute position and velocity constraint violations
-  % (use dummy yp = yp0)
-  [res, dummy1, status] = pendGGL_f(t, y, yp0);
-  pc(it) = res(5);
-  vc(it) = res(6);
-  
-end
-runtime = etime(clock,t_start);
-
-fprintf('Solver stats:\n');
-disp(IDAGetStats);
-fprintf('Run time: %f\n',runtime);
-
-
-figure;
-
-subplot(3,1,1)
-hold on
-plot(time,sol_y(:,1),'b');
-plot(time,sol_y(:,2),'r');
-box on
-set(gca,'XLim',[t0 tf])
-title('position');
-legend('x','y');
-
-subplot(3,1,2)
-hold on
-plot(time,sol_y(:,3),'b');
-plot(time,sol_y(:,4),'r');
-box on
-set(gca,'XLim',[t0 tf])
-title('velocity');
-legend('v_x', 'v_y');
-
-subplot(3,1,3)
-hold on
-plot(time,sol_y(:,5),'b');
-plot(time,sol_y(:,6),'r');
-box on
-set(gca,'XLim',[t0 tf])
-title('Lagrange multipliers');
-legend('\lambda', '\mu');
-
-figure
-
-plotyy(time, pc, time, vc);
-box on
-title('position and velocity constraint violations');
-
-figure
-
-subplot(2,1,1)
-plot(sol_y(:,1),sol_y(:,2));
-axis equal
-axis tight
-box on
-grid on
-xlabel('x');
-ylabel('y');
-title('trajectory');
-
-phi = atan2( sol_y(:,1) , sol_y(:,2) );
-phi_d = ( sol_y(:,1).*sol_y(:,4) - sol_y(:,2).*sol_y(:,3) ) ./ ( sol_y(:,1).^2 + sol_y(:,2).^2 ) ;
-subplot(2,1,2)
-plot3(time,phi, phi_d);
-xlabel('time');
-ylabel('\phi');
-zlabel('\phi^\prime');
-view(-30,15);
-set(gca,'XLim',[t0 tf])
-grid on
-box on
-title('phase plot');
-
-IDAFree;
-
-
-
-function [res, flag, new_data] = pendGGL_f(t,yy,yp)
-
-g = 9.81;
-m = 1.0;
-b = 0.3;
-L = 1.0;
-
-x = yy(1);    xd = yp(1);
-y = yy(2);    yd = yp(2);
-vx = yy(3);   vxd = yp(3);
-vy = yy(4);   vyd = yp(4);
-
-lam = yy(5);
-mu = yy(6);
-
-res(1) = -xd  + (vx+2*x*mu);
-res(2) = -yd  + (vy+2*y*mu);
-res(3) = -vxd + (-b*vx+2*x*lam)/m;
-res(4) = -vyd + (m*g-b*vy+2*y*lam)/m;
-
-res(5) = x^2 + y^2 - L^2;
-res(6) = 2*x*vx + 2*y*vy;
-
-flag = 0;
-new_data = [];
-
-
diff --git a/sundialsTB/idas/examples_ser/midasReInit_dns.m b/sundialsTB/idas/examples_ser/midasReInit_dns.m
deleted file mode 100644
index cf74f15..0000000
--- a/sundialsTB/idas/examples_ser/midasReInit_dns.m
+++ /dev/null
@@ -1,108 +0,0 @@
-function [] = midasReInit_dns()
-%midasReInit_dns - Illustration of the IDAS reinitialization function
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-
-fprintf('Example for integrating over a discontinuity in states\n');
-fprintf('using the IDAS re-initialization function\n\n');  
-fprintf('Integrate over t = [ 0 1.0 ] the DAE:');
-fprintf('  y1'' + y1 - y2 = 0\n');
-fprintf('         y1 + y2 = 0\n');
-fprintf('with initial conditions:\n');
-fprintf('  y1(0) =  1.0\n');
-fprintf('  y2(0) = -1.0\n');
-fprintf('until y2(t*) = -0.5. At t*, perturb:\n');
-fprintf('  y1(t*) <- y1(t*) - 0.25\n');
-fprintf('  y2(t*) <- y2(t*) + 0.25\n');
-fprintf('and continue the integration to t = 1.0\n\n');
-
-t0 = 0.0;
-tout = 1.0;
-y0 = [1.0;-1.0];
-yp0 = [-2.0;0.0];
-
-% Set optional inputs
-options = IDASetOptions('RelTol',1.e-4,...
-                        'AbsTol',1.e-5,...
-                        'LinearSolver','Dense');
-options = IDASetOptions(options,'RootsFn', at my_rootfct, 'NumRoots',1);
-
-% Initialize solver
-IDAInit(@my_resfct,t0,y0,yp0,options);
-
-% Initialize arrays
-tt = [];
-yy1 = [];
-yy2 = [];
-
-% Integrate DAE until root is found
-t = t0;
-while t<tout
-  [status, t, y] = IDASolve(tout,'OneStep');
-  tt = [tt;t];
-  yy1 = [yy1;y(1)];
-  yy2 = [yy2;y(2)];
-  if status == 2
-    break;
-  end
-end
-
-
-fprintf('');
-
-% Get yp at current time
-yp = IDAGet('DerivSolution',t,0);
-
-% Add discontinuity in solution 
-% (must be consistent with the algebraic constraint)
-t0 = t;
-y0 = [y(1)-0.25; y(2)+0.25];
-yp0 = [yp(1)+0.25; 0.0];
-
-% Reinitialize solver
-IDAReInit(t0,y0,yp0,options);
-
-% Integrate to final time
-t = t0;
-while t<tout
-  [status, t, y] = IDASolve(tout,'OneStep');
-  tt = [tt;t];
-  yy1 = [yy1;y(1)];
-  yy2 = [yy2;y(2)];
-end
-
-% Free memory
-IDAFree;
-
-% Plot solution
-hp1 = plot(tt,yy1);
-hold on
-hp2 = plot(tt,yy2,'r');
-set(gca,'XLim',[tt(1) tt(end)]);
-plot([t0 t0],get(gca,'YLim'),'k:');
-
-legend([hp1,hp2],'y_1','y_2');
-
-%
-% ========================================================
-%
-
-function [rr, flag] = my_resfct(t, y, yp)
-
-rr(1) = yp(1) + y(1) - y(2);
-rr(2) = y(1) + y(2);
-
-flag = 0;
-
-%
-% ========================================================
-%
-
-function [g, flag] = my_rootfct(t, y, yp)
-
-g(1) = y(2) + 0.5;
-
-flag = 0;
diff --git a/sundialsTB/idas/examples_ser/midasRoberts_ASAi_dns.m b/sundialsTB/idas/examples_ser/midasRoberts_ASAi_dns.m
deleted file mode 100644
index a66707d..0000000
--- a/sundialsTB/idas/examples_ser/midasRoberts_ASAi_dns.m
+++ /dev/null
@@ -1,209 +0,0 @@
-function midasRoberts_ASAi_dns()
-%midasRoberts_ASAi_dns - IDAS ASA example problem (serial, dense)
-%   The following is a simple example problem, with the coding
-%   needed for its solution by IDAS. The problem is from
-%   chemical kinetics, and consists of the following three rate
-%   equations:         
-%      dy1/dt = -p1*y1 + p2*y2*y3
-%      dy2/dt =  p1*y1 - p2*y2*y3 - p3*(y2)^2
-%           0 = y1 + y2 + y3 - 1
-%   on the interval from t = 0.0 to t = 4.e7, with initial
-%   conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
-%   While integrating the system, we also use the rootfinding
-%   feature to find the points at which y1 = 1e-4 or at which
-%   y3 = 0.01.
-%
-%   The gradient with respect to the problem parameters p1, p2,
-%   and p3 of the following quantity:
-%     G = int_t0^t1 y3(t) dt
-%   is computed using ASA.
-%          
-%   The gradient dG/dp is obtained as:
-%     dG/dp = [ int_t0^tf y1*(l1-l2) dt ,
-%               int_t0^tf -y2*y3*(l1-l2) dt , 
-%               int_t0^tf y2^2*l2 dt          ]
-%              
-%   where l = [l1, l2, l3] is solutions of:
-%     dl1/dt = p1*l1 - p1*l2 + l3
-%     dl2/dt = -p2*y3*l1 + (p2*y3+2*p3*y2)*l2 + l3
-%          0 = -p2*y2*l1 + p2*y2*l2 + l3 + 1
-%   with final conditions
-%     l1(tf) = l2(tf) = 0.0  and l3(tf) = -1.0
-%
-%   All integrals (appearing in G and dG/dp) are computed using
-%   the quadrature integration features in IDAS.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-% Problem parameters
-% ------------------
-
-data.p = [0.04; 1.0e4; 3.0e7];
-
-% Initialize forward problem
-% --------------------------
-
-options = IDASetOptions('UserData', data,...
-                        'RelTol',1.e-4,...
-                        'AbsTol',[1.e-8; 1.e-14; 1.e-6],...
-                        'LinearSolver','Dense',...
-                        'JacobianFn', at djacfn);
-
-%mondata.sol = true;
-%mondata.updt = 100;
-%options = IDASetOptions(options,'MonitorFn', at IDAMonitor,'MonitorData',mondata);
-
-t0 = 0.0;
-y = [1.0;0.0;0.0];
-yp = [-0.04;0.04;0.0];
-IDAInit(@resfn,t0,y,yp,options);
-
-% Initialize forward quadrature (G)
-% ---------------------------------
-
-optionsQ = IDAQuadSetOptions('ErrControl',true,...
-                             'RelTol',1.e-4,'AbsTol',1.e-6);
-q = 0.0;
-IDAQuadInit(@quadfn, q, optionsQ);
-
-% Activate ASA
-% ------------
-
-IDAAdjInit(150, 'Hermite');
-
-% Forward integration
-% -------------------
-
-fprintf('Forward integration ');
-tf =  4.e7;
-[status, t, y, q] = IDASolve(tf,'Normal');
-si = IDAGetStats;
-fprintf('(%d steps)\n',si.nst);
-
-fprintf('G = %12.4e\n',q(1));
-
-% Initialize backward problem
-% ---------------------------
-
-optionsB = IDASetOptions('UserData',data,...
-                         'RelTol',1.e-6,...
-                         'AbsTol',1.e-3,...
-                         'LinearSolver','Dense');
-%mondataB = struct;
-%optionsB = IDASetOptions(optionsB,'MonitorFn', at IDAMonitorB,'MonitorData',mondataB);
-
-yB = [0.0 ; 0.0 ; -1.0];
-yBp = [ -1.0 ; -1.0 ; 0.0 ];
-idxB = IDAInitB(@resfnB,tf,yB,yBp,optionsB);
-
-% Initialize backward quadratures (dG/dp)
-% ---------------------------------------
-
-optionsQB = IDAQuadSetOptions('ErrControl',true,...
-                              'RelTol',1.e-6,'AbsTol',1.e-3);
-
-qB = [0.0;0.0;0.0];
-IDAQuadInitB(idxB, @quadfnB, qB, optionsQB);
-
-% Backward integration
-% --------------------
-
-fprintf('Backward integration ');
-[status, t, yB, qB] = IDASolveB(t0,'Normal');
-siB = IDAGetStatsB(idxB);
-fprintf('(%d steps)\n',siB.nst);
-
-fprintf('dG/dp:      %12.4e  %12.4e  %12.4e\n',...
-        -qB(1),-qB(2),-qB(3));
-fprintf('lambda(t0): %12.4e  %12.4e  %12.4e\n',...
-        yB(1),yB(2),yB(3));
-
-% Free IDAS memory
-% ----------------
-
-IDAFree;
-
-return
-
-% ===========================================================================
-function [rr, flag, new_data] = resfn(t, y, yp, data)
-% DAE residual function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-rr(1) = -r1*y(1) + r2*y(2)*y(3) - yp(1);
-rr(2) =  r1*y(1) - r2*y(2)*y(3) - r3*y(2)*y(2) - yp(2);
-rr(3) = y(1) + y(2) + y(3) - 1.0;
-
-flag = 0;
-new_data = [];
-
-% ===========================================================================
-function [J, flag, new_data] = djacfn(t, y, yp, rr, cj, data)
-% Dense Jacobian function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-J(1,1) = -r1 - cj;
-J(2,1) = r1;
-J(3,1) = 1.0;
-
-J(1,2) = r2*y(3);
-J(2,2) = -r2*y(3) - 2*r3*y(2) - cj;
-J(3,2) = 1.0;
-
-J(1,3) = r2*y(2);
-J(2,3) = -r2*y(2);
-J(3,3) = 1.0;
-
-flag = 0;
-new_data = [];
-
-% ===========================================================================
-function [qd, flag, new_data] = quadfn(t, y, yp, data)
-% Forward quadrature integrand function
-
-qd = y(3);
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-function [rrB, flag, new_data] = resfnB(t, y, yp, yB, yBp, data)
-% Adjoint residual function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-
-rrB(1) = yBp(1) - r1*(yB(1)-yB(2)) - yB(3);
-rrB(2) = yBp(2) + r2*y(3)*(yB(1)-yB(2)) - 2.0*r3*y(2)*yB(2) - yB(3);
-rrB(3) = -r2*y(2)*(yB(1)-yB(2)) + yB(3) + 1.0;
-
-flag = 0;
-new_data = [];
-
-return
-
-% ===========================================================================
-function [qBd, flag, new_data] = quadfnB(t, y, yp, yB, ypB, data)
-% Backward problem quadrature integrand function
-
-qBd(1) = y(1)*(yB(1)-yB(2));
-qBd(2) = -y(2)*y(3)*(yB(1)-yB(2));
-qBd(3) = y(2)^2*yB(2);
-
-flag = 0;
-new_data = [];
-
-return
-
diff --git a/sundialsTB/idas/examples_ser/midasRoberts_dns.m b/sundialsTB/idas/examples_ser/midasRoberts_dns.m
deleted file mode 100644
index 1e89cab..0000000
--- a/sundialsTB/idas/examples_ser/midasRoberts_dns.m
+++ /dev/null
@@ -1,120 +0,0 @@
-function midasRoberts_dns
-%midasRoberts_dns - IDAS example problem (serial, dense)
-%   The following is a simple example problem, with the coding
-%   needed for its solution by IDAS. The problem is from
-%   chemical kinetics, and consists of the following three rate
-%   equations:         
-%      dy1/dt = -.04*y1 + 1.e4*y2*y3
-%      dy2/dt = .04*y1 - 1.e4*y2*y3 - 3.e7*(y2)^2
-%           1 = y1 + y2 + y3
-%   on the interval from t = 0.0 to t = 4.e10, with initial
-%   conditions: y1 = 1.0, y2 = y3 = 0. The problem is stiff.
-%   While integrating the system, we also use the rootfinding
-%   feature to find the points at which y1 = 1e-4 or at which
-%   y3 = 0.01.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/10/26 16:30:48 $
-
-data.p = [0.04; 1.0e4; 3.0e7];
-
-t0 = 0.0;
-y0 = [1.0;0.0;0.0];
-yp0 = [-0.04;0.04;0.0];
-
-options = IDASetOptions('UserData', data,...
-                        'RelTol',1.e-4,...
-                        'AbsTol',[1.e-8; 1.e-14; 1.e-6],...
-                        'LinearSolver','Dense',...
-                        'JacobianFn', at djacfn);
-
-options = IDASetOptions(options,'RootsFn', at rootfn, 'NumRoots',2);
-
-%mondata.sol = true;
-mondata.updt = 100;
-options = IDASetOptions(options,'MonitorFn', at IDAMonitor,'MonitorData',mondata);
-
-IDAInit(@resfn,t0,y0,yp0,options);
-
-t1 = 0.4;
-tmult = 10.0;
-nout = 12;
-
-fprintf('-----------------------------------------------------------------------\n');
-fprintf('  t             y1           y2           y3');
-fprintf('      | nst  k      h\n');
-fprintf('-----------------------------------------------------------------------\n');
-
-iout = 0;
-tout = t1;
-while iout < nout
-
-  [status,t,y] = IDASolve(tout,'Normal');
-  
-% Extract statistics
-  si = IDAGetStats;
-
-% Print output
-  if(status == 2)
-    fprintf(' ... Root found  %d   %d\n',si.RootInfo.roots(1), si.RootInfo.roots(2));
-  end
-  fprintf('%10.4e %12.4e %12.4e %12.4e | %3d  %1d %12.4e\n',... 
-          t, y(1), y(2), y(3), si.nst, si.qlast, si.hlast);
-
-% Update output time
-  if(status == 0)
-    iout = iout+1;
-    tout = tout*tmult;
-  end
-  
-end
-
-si = IDAGetStats;
-
-IDAFree;
-
-function [rr, flag, new_data] = resfn(t, y, yp, data)
-% DAE residual function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-rr(1) = -r1*y(1) + r2*y(2)*y(3) - yp(1);
-rr(2) =  r1*y(1) - r2*y(2)*y(3) - r3*y(2)*y(2) - yp(2);
-rr(3) = y(1) + y(2) + y(3) - 1.0;
-
-flag = 0;
-new_data = [];
-
-function [J, flag, new_data] = djacfn(t, y, yp, rr, cj, data)
-% Dense Jacobian function
-
-r1 = data.p(1);
-r2 = data.p(2);
-r3 = data.p(3);
-
-J(1,1) = -r1 - cj;
-J(2,1) = r1;
-J(3,1) = 1.0;
-
-J(1,2) = r2*y(3);
-J(2,2) = -r2*y(3) - 2*r3*y(2) - cj;
-J(3,2) = 1.0;
-
-J(1,3) = r2*y(2);
-J(2,3) = -r2*y(2);
-J(3,3) = 1.0;
-
-flag = 0;
-new_data = [];
-
-function [g, flag, new_data] = rootfn(t,y,yp,data)
-% Root finding function
-
-g(1) = y(1) - 0.0001;
-g(2) = y(3) - 0.01;
-
-flag = 0;
-new_data = [];
diff --git a/sundialsTB/idas/examples_ser/midasSlCrank_FSA_dns.m b/sundialsTB/idas/examples_ser/midasSlCrank_FSA_dns.m
deleted file mode 100644
index ad12bab..0000000
--- a/sundialsTB/idas/examples_ser/midasSlCrank_FSA_dns.m
+++ /dev/null
@@ -1,238 +0,0 @@
-function midasSlCrank_FSA_dns
-%midasSlCrank_FSA_dns - FSA for the slider-crank example
-%
-% Sensitivities w.r.t. k and c are computed
-%
-% See also: midasSlCrank_dns
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2009/04/26 23:27:29 $
-
-
-% Problem data
-data.a = 0.5;
-data.J1 = 1.0;
-data.m2 = 1.0;
-data.J2 = 2.0;
-data.l0 = 1.0;
-data.F = 1.0;
-data.params(1) = 1.0; % spring constant
-data.params(2) = 1.0; % damper constant
-
-% Integration limits
-t0 = 0.0;
-tf = 10.0;
-
-% Specify algebraic variables
-id = ones(10,1);
-id(7:10) = 0.0;
-
-% Integration options
-options = IDASetOptions('UserData',data,...
-                        'RelTol',1.e-6,...
-                        'AbsTol',1.e-6,...
-                        'VariableTypes',id,...
-                        'suppressAlgVars','on',...
-                        'MaxNumSteps', 1000,...
-                        'LinearSolver','Dense');
-% Set consistent IC
-[yy0, yp0] = setIC(data);
-
-% Initialize IDAS
-IDAInit(@scRES,t0,yy0,yp0,options);
-
-% FSA options
-Ns = 2;
-options = IDASensSetOptions('method','Simultaneous',...
-                            'ErrControl',true,...
-                            'ParamField','params',...
-                            'ParamList',[1 2]);
-
-% Sensitivity IC
-yyS0 = zeros(10, Ns);
-ypS0 = zeros(10, Ns);
-
-% Initialize FSA
-IDASensInit(Ns, [], yyS0, ypS0, options);
-
-% Compute consistent IC 
-
-% Store inital time and IC
-it = 1;
-time(it,1) = t0;
-solution(it,:) = yy0';
-sensitivity1(it,:) = yyS0(:,1)';
-sensitivity2(it,:) = yyS0(:,2)';
-
-% Call solver in ONE_STEP mode
-t = t0;
-while t < tf
-  [status,t,y,yS] = IDASolve(tf,'OneStep');
-  it = it+1;
-  time(it,1) = t;
-  solution(it,:) = y';
-  sensitivity1(it,:) = yS(:,1)';
-  sensitivity2(it,:) = yS(:,2)';
-end
-
-fprintf('Solver stats:\n');
-disp(IDAGetStats);
-
-IDAFree;
-
-% Plot slider position and its sensitivities
-figure;
-set(gcf,'position',[475 250 1000 400]);
-
-hold on
-X = [time ; flipud(time)];
-Y1 = [solution(:,2) ; flipud(solution(:,2)+sensitivity1(:,2))];
-Y2 = [solution(:,2) ; flipud(solution(:,2)+sensitivity2(:,2))];
-
-
-hp1 = patch(X,Y1,'r');
-hp2 = patch(X,Y2,'b');
-
-%set(hp1,'EdgeColor','none','FaceAlpha',0.5);
-%set(hp2,'EdgeColor','none','FaceAlpha',0.5);
-
-set(hp1,'EdgeColor','none');
-set(hp2,'EdgeColor','none');
-
-hp = plot(time,solution(:,2),'k');
-set(hp,'LineWidth',2);
-
-set(gca,'XLim',[t0 tf]);
-
-box on
-grid on
-
-
-% ====================================================================================
-% Consistent IC
-% ====================================================================================
-
-function [yy, yp] = setIC(data)
-
-a = data.a;
-J1 = data.J1;
-m2 = data.m2;
-J2 = data.J2;
-
-q = pi/2.0;    
-p = -asin(a*sin(q));
-x = cos(p) + a*cos(q);
-
-yy = zeros(10,1);
-yp = zeros(10,1);
-
-yy(1) = q;  % crank angle 
-yy(2) = x;  % slider position
-yy(3) = p;  % conecting rod angle
-
-Q = force(yy, data);
-
-yp(4) = Q(1)/J1;  % crank angular acceleration
-yp(5) = Q(2)/m2;  % slider horizontal acceleration
-yp(6) = Q(3)/J2;  % connecting rod angular acceleration
-
-return
-
-% ====================================================================================
-% Generalized force calculation
-% ====================================================================================
-
-function Q = force(yy, data)
-
-a = data.a;
-k = data.params(1);
-c = data.params(2);
-l0 = data.l0;
-F = data.F;
-
-q = yy(1);  % crank angle 
-x = yy(2);  % slider position
-p = yy(3);  % conecting rod angle
-
-qd = yy(4); % crank angular velocity
-xd = yy(5); % slider horizontal velocity
-pd = yy(6); % conecting rod angular velocity
-
-s1 = sin(q);
-c1 = cos(q);
-s2 = sin(p);
-c2 = cos(p);
-s21 = s2*c1 - c2*s1;
-c21 = c2*c1 + s2*s1;
-
-l2 = x^2 - x*(c2+a*c1) + (1.0 + a^2)/4.0 + a*c21/2.0;
-l = sqrt(l2);
-ld = 2.0*x*xd - xd*(c2+a*c1) + x*(s2*pd+a*s1*qd) - a*s21*(pd-qd)/2.0;
-ld = ld / (2.0*l);
-
-f = k*(l-l0) + c*ld;
-fl = f/l;
-
-Q(1) = - fl * a * (s21/2.0 + x*s1) / 2.0;
-Q(2) = fl * (c2/2.0 - x + a*c1/2.0) + F;
-Q(3) = - fl * (x*s2 - a*s21/2.0) / 2.0 - F*s2;
-
-return
-
-% ====================================================================================
-% Residual function
-% ====================================================================================
-
-function [res, flag, new_data] = scRES(t,yy,yp,data)
-
-a = data.a;
-J1 = data.J1;
-m2 = data.m2;
-J2 = data.J2;
-
-q = yy(1);  % crank angle 
-x = yy(2);  % slider position
-p = yy(3);  % conecting rod angle
-
-qd = yy(4); % crank angular velocity
-xd = yy(5); % slider horizontal velocity
-pd = yy(6); % conecting rod angular velocity
-
-lam1 = yy(7); % Lagrange multiplier (cnstr)
-lam2 = yy(8); % Lagrange multiplier (cnstr)
-
-mu1 = yy(9);  % Lagrange multiplier (GGL)
-mu2 = yy(10); % Lagrange multiplier (GGL)
-
-s1 = sin(q);
-c1 = cos(q);
-s2 = sin(p);
-c2 = cos(p);
-
-% Generalized forces
-Q = force(yy, data);
-
-% Velocities (GGL modified)
-res(1) = yp(1) - qd + a*s1*mu1 - a*c1*mu2;
-res(2) = yp(2) - xd + mu1;
-res(3) = yp(3) - pd + s2*mu1 - c2*mu2; 
-
-% Dynamical equations
-res(4) = J1*yp(4) - Q(1) + a*s1*lam1 - a*c1*lam2;
-res(5) = m2*yp(5) - Q(2) + lam1;
-res(6) = J2*yp(6) - Q(3) + s2*lam1 - c2*lam2; 
-
-% Position constraints
-res(7) = x - c2 - a*c1;
-res(8) = -s2 - a*s1;
-
-% Velocity constraints
-res(9) = a*s1*qd + xd + s2*pd;
-res(10) = -a*c1*qd - c2*pd;
-
-flag = 0;
-new_data = [];
-
-return
-
diff --git a/sundialsTB/idas/examples_ser/midasSlCrank_dns.m b/sundialsTB/idas/examples_ser/midasSlCrank_dns.m
deleted file mode 100644
index e1a5ee5..0000000
--- a/sundialsTB/idas/examples_ser/midasSlCrank_dns.m
+++ /dev/null
@@ -1,481 +0,0 @@
-function midasSlCrank_dns
-%midasSlCrank_dns  Slider-crank example
-% The multibody system consists of two bodies (crank and 
-% connecting rod) with a translational-spring-damper (TSDA)
-% and a constant force acting on the connecting rod. 
-%
-% The system has a single degree of freedom. It is modeled with 3
-% generalized coordinates (crank angle, horizontal position of the
-% translational joint, and angle of the connecting rod) and 
-% therefore has 2 constraints.
-%
-% Example 6.1.8, pp. 271 in 
-% Ed. Haug - Intermediate Dynamics, Prentiss Hall, 1992
-%
-% For its solution with IDAS, the resulting index-3 DAE is reformulated
-% as a stabilized index-2 DAE (Gear-Gupta-Leimkhuler formulation) by 
-% introducing 2 additional Lagrange multipliers and appending the
-% velocity constraints.
-%
-%  |                                  |
-%  |       /\                         |       /\
-%  |      /  \                        |      /  \
-%  | a/2 /    \ 1/2                   |     /    \
-%  |    /      \                      |    /      \
-%  |   /--TSDA--\                     |   /        \
-%  |  /          \                    |  /          \
-%  | / a/2        \ 1/2               | /            \---
-%  |/              \                  |/  \ q1   q3 / \  \
-%  +-----------------------------     +----------------------------
-%                    \                |             \  |\
-%                     \               |               -|-\
-%                      \ 1            |                |  \
-%                       \             |<----- q2 ----->|   \
-%                        \                                  \
-%                         \                                  \
-%                          \ --> F                            \
-%
-% The local reference frame on the crank is positioned at the
-% revolute joint on the ground. The crank has length a, mass m1, and
-% intertia (with respect to the local frame) J1.
-% The local reference frame on the conncting rod is positioned at the
-% translational joint. The connecting rod has length 2, mass m2, and
-% inertia J2.
-% The TSDA has spring constant k, damping constant c, and free length l0.
-% A constant horizontal force F acts on the connecting rod.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2009/04/26 23:27:29 $
-
-% Problem data
-data.a = 0.5;
-data.J1 = 1.0;
-data.m2 = 1.0;
-data.J2 = 2.0;
-data.k = 1.0;
-data.c = 1.0;
-data.l0 = 1.0;
-data.F = 1.0;
-
-% Integration limits
-t0 = 0.0;
-tf = 10.0;
-
-% Specify algebraic variables
-id = ones(10,1);
-id(7:10) = 0.0;
-
-% Integration options
-options = IDASetOptions('UserData',data,...
-                        'RelTol',1.e-6,...
-                        'AbsTol',1.e-6,...
-                        'VariableTypes',id,...
-                        'suppressAlgVars','on',...
-                        'MaxNumSteps', 1000,...
-                        'LinearSolver','Dense');
-% Set consistent IC
-[yy0, yp0] = setIC(data);
-
-% Initialize IDAS
-IDAInit(@scRes,t0,yy0,yp0,options);
-
-% Store inital time and IC
-it = 1;
-time(it) = t0;
-pos(it,:) = yy0(1:3)';
-vel(it,:) = yy0(4:6)';
-acc(it,:) = yp0(4:6)';
-lam(it,:) = yy0(7:8)';
-
-% Compute constraint joint forces at initial time
-Fc(it,:) = joint_forces(yy0, yp0, data);
-
-% Call solver in ONE_STEP mode
-t = t0;
-while t < tf
-  [status,t,yy] = IDASolve(tf,'OneStep');
-  it = it+1;
-  time(it) = t;
-  pos(it,:) = yy(1:3)';
-  vel(it,:) = yy(4:6)';
-  lam(it,:) = yy(7:8)';
-  yp = IDAGet('DerivSolution',t,1);
-  acc(it,:) = yp(4:6)';
-  Fc(it,:) = joint_forces(yy, yp, data);
-end
-
-fprintf('Solver stats:\n');
-disp(IDAGetStats);
-
-% Plot solution
-figure;
-set(gcf,'position',[475 250 1000 800]);
-
-subplot(2,2,1)
-hold on
-plot(time,pos(:,1),'b');
-plot(time,pos(:,2),'r');
-plot(time,pos(:,3),'g');
-box on
-set(gca,'XLim',[t0 tf])
-title('position');
-legend('q','x','p');
-
-subplot(2,2,2)
-hold on
-plot(time,vel(:,1),'b');
-plot(time,vel(:,2),'r');
-plot(time,vel(:,3),'g');
-box on
-set(gca,'XLim',[t0 tf])
-title('velocity');
-legend('q''', 'x''', 'p''');
-
-subplot(2,2,3)
-hold on
-plot(time,acc(:,1),'b');
-plot(time,acc(:,2),'r');
-plot(time,acc(:,3),'g');
-box on
-set(gca,'XLim',[t0 tf])
-title('acceleration');
-legend('q''''', 'x''''', 'p''''');
-
-
-subplot(2,2,4)
-hold on
-plot(time,lam(:,1),'b');
-plot(time,lam(:,2),'r');
-box on
-set(gca,'XLim',[t0 tf])
-title('Lagrange multipliers (cnstr. forces)');
-legend('\lambda_1', '\lambda_2');
-
-
-% Plot joint forces
-figure;
-set(gcf,'position',[275 150 800 800]);
-
-plot(time,Fc);
-set(gca,'XLim',[t0 tf])
-title('joint forces');
-legend('vrt. force in rev. crank-ground',...
-       'hrz. force in rev. crank-ground',...
-       'vrt. force in rev. crank-rod',...
-       'hrz. force in rev. crank-rod',...
-       'vrt. force in transl.',...
-       'torque in transl.');
-
-
-IDAFree;
-
-% ====================================================================================
-% Consistent IC
-% ====================================================================================
-
-function [yy, yp] = setIC(data)
-
-a = data.a;
-J1 = data.J1;
-m2 = data.m2;
-J2 = data.J2;
-
-q = pi/2.0;    
-p = -asin(a*sin(q));
-x = cos(p) + a*cos(q);
-
-yy = zeros(10,1);
-yp = zeros(10,1);
-
-yy(1) = q;  % crank angle 
-yy(2) = x;  % slider position
-yy(3) = p;  % conecting rod angle
-
-Q = appl_forces(yy, data);
-g = gamma(yy,data);
-G = jac(yy,data);
-
-% Extended mass matrix in index-1 formulation
-
-MM = zeros(5,5);
-MM(1,1) = J1;
-MM(2,2) = m2;
-MM(3,3) = J2;
-MM(4:5,1:3) = G;
-MM(1:3,4:5) = G';
-
-% Right-hand side in index-1 formulation
-
-b = [Q;g];
-
-% Solution of MM*x = b
-
-acc = MM^(-1)*b;
-
-yp(4) = acc(1);
-yp(5) = acc(2);
-yp(6) = acc(3);
-%
-yy(7) = acc(4);
-yy(8) = acc(5);
-
-return
-
-% ====================================================================================
-% Constraint Jacobian
-% ====================================================================================
-
-function G = jac(yy,data)
-
-a = data.a;
-
-q = yy(1);  % crank angle 
-x = yy(2);  % slider position
-p = yy(3);  % conecting rod angle
-
-qd = yy(4); % crank angular velocity
-xd = yy(5); % slider horizontal velocity
-pd = yy(6); % conecting rod angular velocity
-
-s1 = sin(q);
-c1 = cos(q);
-s2 = sin(p);
-c2 = cos(p);
-
-G(1,1) = a*s1;
-G(1,2) = 1.0;
-G(1,3) = s2;
-
-G(2,1) = -a*c1;
-G(2,2) = 0.0;
-G(2,3) = -c2;
-
-return
-
-% ====================================================================================
-% Right-hand side of acceleration constraint
-% ====================================================================================
-
-function g = gamma(yy, data)
-
-a = data.a;
-
-q = yy(1);  % crank angle 
-x = yy(2);  % slider position
-p = yy(3);  % conecting rod angle
-
-qd = yy(4); % crank angular velocity
-xd = yy(5); % slider horizontal velocity
-pd = yy(6); % conecting rod angular velocity
-
-s1 = sin(q);
-c1 = cos(q);
-s2 = sin(p);
-c2 = cos(p);
-
-g(1,1) = - (a*qd^2*c1+pd^2*c2);
-g(2,1) = - (a*qd^2*s1 + pd^2*s2);
-
-return
-
-% ====================================================================================
-% Generalized applied forces calculation
-% ====================================================================================
-
-function Q = appl_forces(yy, data)
-
-a = data.a;
-k = data.k;
-c = data.c;
-l0 = data.l0;
-F = data.F;
-
-q = yy(1);  % crank angle 
-x = yy(2);  % slider position
-p = yy(3);  % conecting rod angle
-
-qd = yy(4); % crank angular velocity
-xd = yy(5); % slider horizontal velocity
-pd = yy(6); % conecting rod angular velocity
-
-s1 = sin(q);
-c1 = cos(q);
-s2 = sin(p);
-c2 = cos(p);
-s21 = s2*c1 - c2*s1;
-c21 = c2*c1 + s2*s1;
-
-l2 = x^2 - x*(c2+a*c1) + (1.0 + a^2)/4.0 + a*c21/2.0;
-l = sqrt(l2);
-ld = 2.0*x*xd - xd*(c2+a*c1) + x*(s2*pd+a*s1*qd) - a*s21*(pd-qd)/2.0;
-ld = ld / (2.0*l);
-
-f = k*(l-l0) + c*ld;
-fl = f/l;
-
-Q(1,1) = - fl * a * (s21/2.0 + x*s1) / 2.0;
-Q(2,1) = fl * (c2/2.0 - x + a*c1/2.0) + F;
-Q(3,1) = - fl * (x*s2 - a*s21/2.0) / 2.0 - F*s2;
-
-return
-
-% ====================================================================================
-% Residual function
-% ====================================================================================
-
-function [res, flag, new_data] = scRes(t,yy,yp,data)
-
-a = data.a;
-J1 = data.J1;
-m2 = data.m2;
-J2 = data.J2;
-
-q = yy(1);  % crank angle 
-x = yy(2);  % slider position
-p = yy(3);  % conecting rod angle
-
-qd = yy(4); % crank angular velocity
-xd = yy(5); % slider horizontal velocity
-pd = yy(6); % conecting rod angular velocity
-
-lam1 = yy(7); % Lagrange multiplier (cnstr)
-lam2 = yy(8); % Lagrange multiplier (cnstr)
-
-mu1 = yy(9);  % Lagrange multiplier (GGL)
-mu2 = yy(10); % Lagrange multiplier (GGL)
-
-s1 = sin(q);
-c1 = cos(q);
-s2 = sin(p);
-c2 = cos(p);
-
-% Generalized forces
-Q = appl_forces(yy, data);
-
-% Velocities (GGL modified)
-res(1) = yp(1) - qd + a*s1*mu1 - a*c1*mu2;
-res(2) = yp(2) - xd + mu1;
-res(3) = yp(3) - pd + s2*mu1 - c2*mu2; 
-
-% Dynamical equations
-res(4) = J1*yp(4) - Q(1) + a*s1*lam1 - a*c1*lam2;
-res(5) = m2*yp(5) - Q(2) + lam1;
-res(6) = J2*yp(6) - Q(3) + s2*lam1 - c2*lam2; 
-
-% Position constraints
-res(7) = x - c2 - a*c1;
-res(8) = -s2 - a*s1;
-
-% Velocity constraints
-res(9) = a*s1*qd + xd + s2*pd;
-res(10) = -a*c1*qd - c2*pd;
-
-flag = 0;
-new_data = [];
-
-return
-
-% ====================================================================================
-% Joint constraint forces
-% ====================================================================================
-
-function Fc = joint_forces(yy, yp, data)
-% Compute joint reaction forces for given positins, velocities, and
-% accelerations. This is done by including the reaction forces and torques,
-% considering the free body diagrams for the crank and connecting rod, and
-% writing the dynamical equilibrium equations.
-%
-
-a = data.a;
-k = data.k;
-c = data.c;
-l0 = data.l0;
-F = data.F;
-
-J1 = data.J1;
-m2 = data.m2;
-J2 = data.J2;
-
-q = yy(1);  % crank angle 
-x = yy(2);  % slider position
-p = yy(3);  % conecting rod angle
-
-qd = yy(4); % crank angular velocity
-xd = yy(5); % slider horizontal velocity
-pd = yy(6); % conecting rod angular velocity
-
-qdd = yp(4); % crank angular acc.
-xdd = yp(5); % slider horizontal acc.
-pdd = yp(6); % connecting rod angular acc.
-
-s1 = sin(q);
-c1 = cos(q);
-s2 = sin(p);
-c2 = cos(p);
-s21 = s2*c1 - c2*s1;
-c21 = c2*c1 + s2*s1;
-
-l2 = x^2 - x*(c2+a*c1) + (1.0 + a^2)/4.0 + a*c21/2.0;
-l = sqrt(l2);
-ld = 2.0*x*xd - xd*(c2+a*c1) + x*(s2*pd+a*s1*qd) - a*s21*(pd-qd)/2.0;
-ld = ld / (2.0*l);
-
-f = k*(l-l0) + c*ld;
-fl = f/l;
-
-% TSDA forces acting on crank and connecting rod
-
-Q1A(1) = x-0.5*c2-a/2*c1;
-Q1A(2) = -0.5*(s2+a*s1);
-Q1A(3) = -0.5*(a*x*s1+s21);
-
-Q2A(1) = -Q1A(1);
-Q2A(2) = -Q1A(2);
-Q2A(3) = -0.5*(x*s2+a*s21);
-
-Q1A = fl*Q1A';
-Q2A = fl*Q2A';
-
-QA = [-Q1A;-Q2A];
-
-% Force F acting on connecting rod
-FA = [0;0;0;F;0;-F*s2];
-
-% Dynamic forces
-MA = [0;0;J1*qdd;m2*xdd;0;J2*pdd];
-
-% Dynamic equilibrium equations:
-%  MA = QA+FA + FC
-% where the joint constraint forces are:
-%   Fc(1) = vertical force in revolute join crank-ground
-%   Fc(2) = horizontal force in revolute join crank-ground
-%   Fc(3) = vertical force in revolute joint crank-connecting rod
-%   Fc(4) = vertical force in revolute joint crank-connecting rod
-%   Fc(5) = vertical force in translational joint
-%   Fc(6) = reaction torque acting in translational joint
-% and therefore
-%   FC = A * Fc
-% where
-%   A = [
-%       0  1   0     1    0  0
-%       1  0   1     0    0  0
-%       0  0  a*c1 -1*s1  0  0
-%       0  0   0    -1    0  0
-%       0  0  -1     0    1  0
-%       0  0  -c2   -s2   0  1
-%       ];
-
-b = MA-QA-FA;
-
-Fc(4) = -b(4);
-Fc(2) = b(1) - Fc(4);
-if abs(c1) > 0.1
-  Fc(3) = ( b(3) + a*s1*Fc(4) ) / (a*c1);
-end
-Fc(1) = b(2) - Fc(3); 
-Fc(5) = b(5) + Fc(3);
-Fc(6) = b(6) + c2*Fc(3) + s2*Fc(4);
-
-return
-
diff --git a/sundialsTB/idas/function_types/IDABandJacFn.m b/sundialsTB/idas/function_types/IDABandJacFn.m
deleted file mode 100644
index 78472ae..0000000
--- a/sundialsTB/idas/function_types/IDABandJacFn.m
+++ /dev/null
@@ -1,32 +0,0 @@
-%IDABandJacFn - type for banded Jacobian function.
-%
-%   The function BJACFUN must be defined as 
-%        FUNCTION [J, FLAG] = BJACFUN(T, YY, YP, RR, CJ)
-%   and must return a matrix J corresponding to the banded Jacobian
-%   (df/dyy + cj*df/dyp).
-%   The input argument RR contains the current value of f(t,yy,yp).
-%   If a user data structure DATA was specified in IDAInit, then
-%   BJACFUN must be defined as
-%        FUNCTION [J, FLAG, NEW_DATA] = BJACFUN(T, YY, YP, RR, CJ, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix J,
-%   the BJACFUN function must also set NEW_DATA. Otherwise, it should 
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function BJACFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDASetOptions
-%
-%   See the IDAS user guide for more information on the structure of
-%   a banded Jacobian.
-%
-%   NOTE: BJACFUN is specified through the property JacobianFn to 
-%   IDASetOptions and is used only if the property LinearSolver 
-%   was set to 'Band'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDABandJacFnB.m b/sundialsTB/idas/function_types/IDABandJacFnB.m
deleted file mode 100644
index 68b49d9..0000000
--- a/sundialsTB/idas/function_types/IDABandJacFnB.m
+++ /dev/null
@@ -1,27 +0,0 @@
-%IDABandJacFnB - type for banded Jacobian function for backward problems.
-%
-%   The function BJACFUNB must be defined either as
-%        FUNCTION [JB, FLAG] = BJACFUNB(T, YY, YP, YYB, YPB, RRB, CJB)
-%   or as
-%        FUNCTION [JB,FLAG,NEW_DATA] = BJACFUNB(T,YY,YP,YYB,YPB,RRB,CJB)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. In either case, it must return the matrix JB, the
-%   Jacobian (dfB/dyyB + cjB*dfB/dypB)of fB(t,y,yB). The input argument
-%   RRB contains the current value of f(t,yy,yp,yyB,ypB).
-%
-%   The function BJACFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDASetOptions
-%
-%   See the IDAS user guide for more information on the structure of
-%   a banded Jacobian.
-%
-%   NOTE: BJACFUNB is specified through the property JacobianFn to 
-%   IDASetOptions and is used only if the property LinearSolver 
-%   was set to 'Band'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDADenseJacFn.m b/sundialsTB/idas/function_types/IDADenseJacFn.m
deleted file mode 100644
index de580ff..0000000
--- a/sundialsTB/idas/function_types/IDADenseJacFn.m
+++ /dev/null
@@ -1,29 +0,0 @@
-%IDADenseJacFn - type for dense Jacobian function.
-%
-%   The function DJACFUN must be defined as 
-%        FUNCTION [J, FLAG] = DJACFUN(T, YY, YP, RR, CJ)
-%   and must return a matrix J corresponding to the Jacobian 
-%   (df/dyy + cj*df/dyp).
-%   The input argument RR contains the current value of f(t,yy,yp).
-%   If a user data structure DATA was specified in IDAInit, then
-%   DJACFUN must be defined as
-%        FUNCTION [J, FLAG, NEW_DATA] = DJACFUN(T, YY, YP, RR, CJ, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix J,
-%   the DJACFUN function must also set NEW_DATA. Otherwise, it should
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function DJACFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDASetOptions
-%
-%   NOTE: DJACFUN is specified through the property JacobianFn to 
-%   IDASetOptions and is used only if the property LinearSolver 
-%   was set to 'Dense'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDADenseJacFnB.m b/sundialsTB/idas/function_types/IDADenseJacFnB.m
deleted file mode 100644
index 94f9da0..0000000
--- a/sundialsTB/idas/function_types/IDADenseJacFnB.m
+++ /dev/null
@@ -1,24 +0,0 @@
-%IDADenseJacFnb - type for dense Jacobian function for backward problems.
-%
-%   The function DJACFUNB must be defined either as
-%        FUNCTION [JB, FLAG] = DJACFUNB(T, YY, YP, YYB, YPB, RRB, CJB)
-%   or as
-%        FUNCTION [JB,FLAG,NEW_DATA] = DJACFUNB(T,YY,YP,YYB,YPB,RRB,CJB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. In either case, it must return the matrix JB, the
-%   Jacobian (dfB/dyyB + cjb*dfB/dypB). The input argument RRB contains 
-%   the current value of f(t,yy,yp,yyB,ypB).
-%
-%   The function DJACFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDADenseJacFn, IDASetOptions
-%
-%   NOTE: DJACFUNB is specified through the property JacobianFn to 
-%   IDASetOptions and is used only if the property LinearSolver was
-%   set to 'Dense'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAGcommFn.m b/sundialsTB/idas/function_types/IDAGcommFn.m
deleted file mode 100644
index b8e5a03..0000000
--- a/sundialsTB/idas/function_types/IDAGcommFn.m
+++ /dev/null
@@ -1,34 +0,0 @@
-%IDAGcommFn - type for communication function (BBDPre).
-%
-%   The function GCOMFUN must be defined as 
-%        FUNCTION FLAG = GCOMFUN(T, YY, YP)
-%   and can be used to perform all interprocess communication necessary
-%   to evaluate the approximate residual function for the BBDPre
-%   preconditioner module.
-%   If a user data structure DATA was specified in IDAInit, then
-%   GCOMFUN must be defined as
-%        FUNCTION [FLAG, NEW_DATA] = GCOMFUN(T, YY, YP, DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then the GCOMFUN function must also 
-%   set NEW_DATA. Otherwise, it should set NEW_DATA=[] (do not set 
-%   NEW_DATA = DATA as it would lead to unnecessary copying).
-%
-%   The function GCOMFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAGlocalFn, IDASetOptions
-%
-%   NOTES:
-%     GCOMFUN is specified through the GcommFn property in IDASetOptions 
-%     and is used only if the property PrecModule is set to 'BBDPre'.
-%
-%     Each call to GCOMFUN is preceded by a call to the residual function
-%     DAEFUN with the same arguments T, YY, and YP.
-%     Thus GCOMFUN can omit any communication done by DAEFUN if relevant 
-%     to the evaluation of G by GLOCFUN. If all necessary communication 
-%     was done by DAEFUN, GCOMFUN need not be provided.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAGcommFnB.m b/sundialsTB/idas/function_types/IDAGcommFnB.m
deleted file mode 100644
index 6e91e3e..0000000
--- a/sundialsTB/idas/function_types/IDAGcommFnB.m
+++ /dev/null
@@ -1,28 +0,0 @@
-%IDAGcommFnB - type for communication function (BBDPre) for backward problems.
-%
-%   The function GCOMFUNB must be defined either as
-%        FUNCTION FLAG = GCOMFUNB(T, YY, YP, YYB, YPB)
-%   or as
-%        FUNCTION [FLAG, NEW_DATA] = GCOMFUNB(T, YY, YP, YYB, YPB, DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. 
-%
-%   The function GCOMFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAGlocalFnB, IDAGcommFn, IDASetOptions
-%
-%   NOTES:
-%     GCOMFUNB is specified through the GcommFn property in IDASetOptions 
-%     and is used only if the property PrecModule is set to 'BBDPre'.
-%
-%     Each call to GCOMFUNB is preceded by a call to the residual function
-%     DAEFUN with the same arguments T, YY, YP and YYB and YPB.
-%     Thus GCOMFUNB can omit any communication done by DAEFUNB if relevant
-%     to the evaluation of G by GLOCFUNB. If all necessary communication 
-%     was done by DAEFUNB, GCOMFUNB need not be provided.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAGlocalFn.m b/sundialsTB/idas/function_types/IDAGlocalFn.m
deleted file mode 100644
index e511490..0000000
--- a/sundialsTB/idas/function_types/IDAGlocalFn.m
+++ /dev/null
@@ -1,29 +0,0 @@
-%IDAGlocalFn - type for RES approximation function (BBDPre).
-%
-%   The function GLOCFUN must be defined as 
-%        FUNCTION [GLOC, FLAG] = GLOCFUN(T,YY,YP)
-%   and must return a vector GLOC corresponding to an approximation to f(t,yy,yp)
-%   which will be used in the BBDPRE preconditioner module. The case where
-%   G is mathematically identical to F is allowed.
-%   If a user data structure DATA was specified in IDAInit, then
-%   GLOCFUN must be defined as
-%        FUNCTION [GLOC, FLAG, NEW_DATA] = GLOCFUN(T,YY,YP,DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then, besides setting the vector G,
-%   the GLOCFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function GLOCFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAGcommFn, IDASetOptions
-%
-%   NOTE: GLOCFUN and GLOCFUNB are specified through the GlocalFn property
-%   in IDASetOptions and are used only if the property PrecModule
-%   is set to 'BBDPre'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAGlocalFnB.m b/sundialsTB/idas/function_types/IDAGlocalFnB.m
deleted file mode 100644
index c078b2a..0000000
--- a/sundialsTB/idas/function_types/IDAGlocalFnB.m
+++ /dev/null
@@ -1,23 +0,0 @@
-%IDAGlocalFnB - type for RES approximation function (BBDPre) for backward problems.
-%
-%   The function GLOCFUNB must be defined either as
-%        FUNCTION [GLOCB, FLAG] = GLOCFUNB(T,YY,YP,YYB,YPB)
-%   or as
-%        FUNCTION [GLOCB, FLAG, NEW_DATA] = GLOCFUNB(T,YY,YP,YYB,YPB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. In either case, it must return the vector GLOCB
-%   corresponding to an approximation to fB(t,yy,yp,yyB,ypB).
-%
-%   The function GLOCFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAGcommFnB, IDAGlocalFn, IDASetOptions
-%
-%   NOTE: GLOCFUN and GLOCFUNB are specified through the GlocalFn property
-%   in IDASetOptions and are used only if the property PrecModule
-%   is set to 'BBDPre'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAJacTimesVecFn.m b/sundialsTB/idas/function_types/IDAJacTimesVecFn.m
deleted file mode 100644
index da5267c..0000000
--- a/sundialsTB/idas/function_types/IDAJacTimesVecFn.m
+++ /dev/null
@@ -1,28 +0,0 @@
-%IDAJacTimesVecFn - type for Jacobian times vector function.
-%
-%   The function JTVFUN must be defined as 
-%        FUNCTION [JV, FLAG] = JTVFUN(T,YY,YP,RR,V,CJ)
-%   and must return a vector JV corresponding to the product of the 
-%   Jacobian ( df/dyy + cj * df/dyp ) with the vector v.
-%   The input argument RR contains the current value of f(t,yy,yp).
-%   If a user data structure DATA was specified in IDAInit, then
-%   JTVFUN must be defined as
-%        FUNCTION [JV, FLAG, NEW_DATA] = JTVFUN(T,YY,YP,RR,V,CJ,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector JV,
-%   the JTVFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function JTVFUN must set FLAG=0 if successful, or FLAG~=0 if
-%   a failure occurred.
-%
-%   See also IDASetOptions
-%
-%   NOTE: JTVFUN is specified through the property JacobianFn to 
-%   IDASetOptions and is used only if the property LinearSolver 
-%   was set to 'GMRES', 'BiCGStab', or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAJacTimesVecFnB.m b/sundialsTB/idas/function_types/IDAJacTimesVecFnB.m
deleted file mode 100644
index 6406e50..0000000
--- a/sundialsTB/idas/function_types/IDAJacTimesVecFnB.m
+++ /dev/null
@@ -1,23 +0,0 @@
-%IDAJacTimesVecFn - type for Jacobian times vector function for backward problems.
-%
-%   The function JTVFUNB must be defined either as
-%        FUNCTION [JVB,FLAG] = JTVFUNB(T,YY,YP,YYB,YPB,RRB,VB,CJB)
-%   or as
-%        FUNCTION [JVB,FLAG,NEW_DATA] = JTVFUNB(T,YY,YP,YYB,YPB,RRB,VB,CJB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. In either case, it must return the vector JVB, the
-%   product of the Jacobian (dfB/dyyB + cj * dfB/dypB) and a vector
-%   vB. The input argument RRB contains the current value of f(t,yy,yp,yyB,ypB).
-%
-%   The function JTVFUNB must set FLAG=0 if successful, or FLAG~=0 if
-%   a failure occurred.
-%
-%   See also IDASetOptions
-%
-%   NOTE: JTVFUNB is specified through the property JacobianFn to IDASetOptions
-%   and is used only if the property LinearSolver was set to 'GMRES', 'BiCGStab',
-%   or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAMonitorFn.m b/sundialsTB/idas/function_types/IDAMonitorFn.m
deleted file mode 100644
index 5ffaa6a..0000000
--- a/sundialsTB/idas/function_types/IDAMonitorFn.m
+++ /dev/null
@@ -1,67 +0,0 @@
-%IDAMonitorFn - type for monitoring function.
-%
-%   The function MONFUN must be defined as
-%      FUNCTION [] = MONFUN(CALL, T, YY, YP, YQ, YYS, YPS)
-% 
-%   To enable monitoring using a given monitor function MONFUN,
-%   use IDASetOptions to set the property 'MonitorFn" to 'MONFUN' 
-%   (or to @MONFUN).
-%
-%   MONFUN is called with the following input arguments:
-%
-%   o CALL indicates the phase during the integration process at which
-%     MONFUN is called:
-%     CALL=1 : MONFUN was called at the initial time; this can be either 
-%              after IDAInit or after IDAReInit.
-%              (typically, MONFUN should perform its own initialization)
-%     CALL=2 : MONFUN was called right before a solver reinitializtion.
-%              (typically, MONFUN should decide whether to initialize
-%              itself or else to continue monitoring)
-%     CALL=3 : MONFUN was called during solver finalization.
-%              (typically, MONFUN should finalize monitoring)
-%     CALL=0 : MONFUN was called after the solver took a successful
-%              internal step.
-%              (typically, MONFUN should collect and/or display data)
-%
-%   o T is the current integration time
-%
-%   o YY and YP are vectors containing the solution and solution 
-%     derivative at time T
-%
-%   o YQ is a vector containing the quadrature variables at time T
-%
-%   o YYS and YPS are matrices containing the forward sensitivities
-%     and their derivatives, respectively, at time T.
-%
-%   If additional data is needed inside a MONFUN function, then it must 
-%   be defined as
-%      FUNCTION NEW_MONDATA = MONFUN(CALL, T, YY, YP, YQ, YYS, YPS, MONDATA)
-%
-%   In this case, the MONFUN function is passed the additional argument
-%   MONDATA, the same as that specified through the property 'MonitorData'
-%   in IDASetOptions. If the local modifications to the monitor data structure 
-%   need to be saved (e.g. for future calls to MONFUN), then MONFUN must set
-%   NEW_MONDATA. Otherwise, it should set NEW_MONDATA=[] (do not set 
-%   NEW_MONDATA = DATA as it would lead to unnecessary copying).
-%
-%   NOTES: 
-%   
-%   1. MONFUN is specified through the MonitorFn property in IDASetOptions. 
-%      If this property is not set, or if it is empty, MONFUN is not used.
-%      MONDATA is specified through the MonitorData property in IDASetOptions.
-%
-%   2. If quadrature integration is not enabled, YQ is empty. Similarly, if
-%      forward sensitivity analysis is not enabled, YYS and YPS are empty.
-%
-%   3. When CALL = 2 or 3, all arguments YY, YP, YQ, YYS, and YPS are empty.
-%      Moreover, when CALL = 3, T = 0.0
-%
-%   4. If MONFUN is used on the backward integration phase, YYS and YPS are 
-%      always empty.
-%
-%   See also IDASetOptions, IDAMonitor
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAMonitorFnB.m b/sundialsTB/idas/function_types/IDAMonitorFnB.m
deleted file mode 100644
index a740c2f..0000000
--- a/sundialsTB/idas/function_types/IDAMonitorFnB.m
+++ /dev/null
@@ -1,37 +0,0 @@
-%IDAMonitorFnB - type of monitoring function for backward problems.
-%
-%   The function MONFUNB must be defined as
-%       FUNCTION [] = MONFUNB(CALL, IDXB, T, Y, YQ)
-%   It is called after every internal IDASolveB step and can be used to
-%   monitor the progress of the solver. MONFUNB is called with CALL=0
-%   from IDAInitB at which time it should initialize itself and it
-%   is called with CALL=2 from IDAFree. Otherwise, CALL=1.
-%
-%   It receives as arguments the index of the backward problem (as
-%   returned by IDAInitB), the current time T, solution vector Y,
-%   and, if it was computed, the quadrature vector YQ. If quadratures
-%   were not computed for this backward problem, YQ is empty here.
-%
-%   If additional data is needed inside MONFUNB, it must be defined
-%   as
-%      FUNCTION NEW_MONDATA = MONFUNB(CALL, IDXB, T, Y, YQ, MONDATA)
-%   If the local modifications to the user data structure need to be 
-%   saved (e.g. for future calls to MONFUNB), then MONFUNB must set
-%   NEW_MONDATA. Otherwise, it should set NEW_MONDATA=[] 
-%   (do not set NEW_MONDATA = DATA as it would lead to unnecessary copying).
-%
-%   A sample monitoring function, IDAMonitorB, is provided with CVODES.
-%
-%   See also IDASetOptions, IDAMonitorB
-%
-%   NOTES: 
-%   
-%   MONFUNB is specified through the MonitorFn property in IDASetOptions. 
-%   If this property is not set, or if it is empty, MONFUNB is not used.
-%   MONDATA is specified through the MonitorData property in IDASetOptions.
-%
-%   See IDAMonitorB for an implementation example.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/08/21 17:38:44 $
diff --git a/sundialsTB/idas/function_types/IDAPrecSetupFn.m b/sundialsTB/idas/function_types/IDAPrecSetupFn.m
deleted file mode 100644
index 6835c2b..0000000
--- a/sundialsTB/idas/function_types/IDAPrecSetupFn.m
+++ /dev/null
@@ -1,53 +0,0 @@
-%IDAPrecSetupFn - type for preconditioner setup function.
-%
-%   The user-supplied preconditioner setup function PSETFUN and
-%   the user-supplied preconditioner solve function PSOLFUN
-%   together must define a preconditoner matrix P which is an 
-%   approximation to the Newton matrix M = J_yy - cj*J_yp.  
-%   Here J_yy = df/dyy, J_yp = df/dyp, and cj is a scalar proportional 
-%   to the integration step size h.  The solution of systems P z = r,
-%   is to be carried out by the PrecSolve function, and PSETFUN
-%   is to do any necessary setup operations.
-%
-%   The user-supplied preconditioner setup function PSETFUN
-%   is to evaluate and preprocess any Jacobian-related data
-%   needed by the preconditioner solve function PSOLFUN.
-%   This might include forming a crude approximate Jacobian,
-%   and performing an LU factorization on the resulting
-%   approximation to M.  This function will not be called in
-%   advance of every call to PSOLFUN, but instead will be called
-%   only as often as necessary to achieve convergence within the
-%   Newton iteration.  If the PSOLFUN function needs no
-%   preparation, the PSETFUN function need not be provided.
-%
-%   Each call to the PSETFUN function is preceded by a call to
-%   DAEFUN with the same (t,yy,yp) arguments.  Thus the PSETFUN
-%   function can use any auxiliary data that is computed and
-%   saved by the DAEFUN function and made accessible to PSETFUN.
-%
-%   The function PSETFUN must be defined as 
-%        FUNCTION FLAG = PSETFUN(T,YY,YP,RR,CJ)
-%   If successful, it must return FLAG=0. For a recoverable error (in    
-%   which case the setup will be retried) it must set FLAG to a positive
-%   integer value. If an unrecoverable error occurs, it must set FLAG
-%   to a negative value, in which case the integration will be halted.
-%   The input argument RR contains the current value of f(t,yy,yp).
-%
-%   If a user data structure DATA was specified in IDASetUserData, then
-%   PSETFUN must be defined as
-%        FUNCTION [FLAG,NEW_DATA] = PSETFUN(T,YY,YP,RR,CJ,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the flag
-%   FLAG, the PSETFUN function must also set NEW_DATA. Otherwise, it 
-%   should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead
-%   to unnecessary copying).
-%
-%   See also IDAPrecSolveFn, IDASetOptions
-%
-%   NOTE: PSETFUN and PSETFUNB are specified through the property
-%   PrecSetupFn to IDASetOptions and are used only if the property
-%   LinearSolver was set to 'GMRES', 'BiCGStab', or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/18 23:55:40 $
diff --git a/sundialsTB/idas/function_types/IDAPrecSetupFnB.m b/sundialsTB/idas/function_types/IDAPrecSetupFnB.m
deleted file mode 100644
index 5638589..0000000
--- a/sundialsTB/idas/function_types/IDAPrecSetupFnB.m
+++ /dev/null
@@ -1,18 +0,0 @@
-%IDAPrecSetupFnB - type for preconditioner setup function for backward problems.
-%
-%   The function PSETFUNB must be defined either as
-%        FUNCTION FLAG = PSETFUNB(T,YY,YP,YYB,YPB,RRB,CJB)
-%   or as
-%        FUNCTION [FLAG,NEW_DATA] = PSETFUNB(T,YY,YP,YYB,YPB,RRB,CJB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDASetUserData.
-%
-%   See also IDAPrecSolveFnB, IDAPrecSetupFn, IDASetOptions
-%
-%   NOTE: PSETFUN and PSETFUNB are specified through the property
-%   PrecSetupFn to IDASetOptions and are used only if the property
-%   LinearSolver was set to 'GMRES', 'BiCGStab', or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAPrecSolveFn.m b/sundialsTB/idas/function_types/IDAPrecSolveFn.m
deleted file mode 100644
index 5e2a05e..0000000
--- a/sundialsTB/idas/function_types/IDAPrecSolveFn.m
+++ /dev/null
@@ -1,33 +0,0 @@
-%IDAPrecSolveFn - type for preconditioner solve function.
-%
-%   The user-supplied preconditioner solve function PSOLFUN
-%   is to solve a linear system P z = r, where P is the
-%   preconditioner matrix.
-%
-%   The function PSOLFUN must be defined as 
-%        FUNCTION [Z, FLAG] = PSOLFUN(T,YY,YP,RR,R)
-%   and must return a vector Z containing the solution of Pz=r.
-%   If PSOLFUN was successful, it must return FLAG=0. For a recoverable 
-%   error (in which case the step will be retried) it must set FLAG to a 
-%   positive value. If an unrecoverable error occurs, it must set FLAG
-%   to a negative value, in which case the integration will be halted.
-%   The input argument RR contains the current value of f(t,yy,yp).
-%
-%   If a user data structure DATA was specified in IDAInit, then
-%   PSOLFUN must be defined as
-%        FUNCTION [Z, FLAG, NEW_DATA] = PSOLFUN(T,YY,YP,RR,R,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector Z and
-%   the flag FLAG, the PSOLFUN function must also set NEW_DATA. Otherwise,
-%   it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would
-%   lead to unnecessary copying).
-%
-%   See also IDAPrecSetupFn, IDASetOptions
-%
-%   NOTE: PSOLFUN and PSOLFUNB are specified through the property
-%   PrecSolveFn to IDASetOptions and are used only if the property
-%   LinearSolver was set to 'GMRES', 'BiCGStab', or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAPrecSolveFnB.m b/sundialsTB/idas/function_types/IDAPrecSolveFnB.m
deleted file mode 100644
index 2457bb6..0000000
--- a/sundialsTB/idas/function_types/IDAPrecSolveFnB.m
+++ /dev/null
@@ -1,23 +0,0 @@
-%IDAPrecSolveFnB - type for preconditioner solve function.
-%
-%   The user-supplied preconditioner solve function PSOLFUNB
-%   is to solve a linear system P z = r, where P is the
-%   preconditioner matrix.
-%
-%   The function PSOLFUNB must be defined either as
-%        FUNCTION [ZB,FLAG] = PSOLFUNB(T,YY,YP,YYB,YPB,RRB,RB)
-%   or as
-%        FUNCTION [ZB,FLAG,NEW_DATA] = PSOLFUNB(T,YY,YP,YYB,YPB,RRB,RB,DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. In either case, it must return the vector ZB and the
-%   flag FLAG.
-%
-%   See also IDAPrecSetupFnB, IDAPrecSolveFn, IDASetOptions
-%
-%   NOTE: PSOLFUN and PSOLFUNB are specified through the property
-%   PrecSolveFn to IDASetOptions and are used only if the property
-%   LinearSolver was set to 'GMRES', 'BiCGStab', or 'TFQMR'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAQuadRhsFn.m b/sundialsTB/idas/function_types/IDAQuadRhsFn.m
deleted file mode 100644
index 3a65318..0000000
--- a/sundialsTB/idas/function_types/IDAQuadRhsFn.m
+++ /dev/null
@@ -1,24 +0,0 @@
-%IDAQuadRhsFn - type for user provided quadrature RHS function.
-%
-%   The function QFUN must be defined as 
-%        FUNCTION [YQD, FLAG] = QFUN(T, YY, YP)
-%   and must return a vector YQD corresponding to fQ(t,yy,yp), the 
-%   integrand for the integral to be evaluated.
-%   If a user data structure DATA was specified in IDAInit, then
-%   QFUN must be defined as
-%        FUNCTION [YQD, FLAG, NEW_DATA] = QFUN(T, YY, YP, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector YQD,
-%   the QFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function QFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAQuadInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAQuadRhsFnB.m b/sundialsTB/idas/function_types/IDAQuadRhsFnB.m
deleted file mode 100644
index 11500e6..0000000
--- a/sundialsTB/idas/function_types/IDAQuadRhsFnB.m
+++ /dev/null
@@ -1,20 +0,0 @@
-%IDAQuadRhsFnB - type for quadrature RHS function for backward problems
-%
-%   The function QFUNB must be defined either as
-%        FUNCTION [YQBD, FLAG] = QFUNB(T, YY, YP, YYB, YPB)
-%   or as
-%        FUNCTION [YQBD, FLAG, NEW_DATA] = QFUNB(T, YY, YP, YYB, YPB, DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. In either case, it must return the vector YQBD
-%   corresponding to fQB(t,yy,yp,yyB,ypB), the integrand for the integral to be 
-%   evaluated on the backward phase.
-%
-%   The function QFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAQuadInitB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAResFn.m b/sundialsTB/idas/function_types/IDAResFn.m
deleted file mode 100644
index a1a705c..0000000
--- a/sundialsTB/idas/function_types/IDAResFn.m
+++ /dev/null
@@ -1,23 +0,0 @@
-%IDAResFn - type for residual function
-%
-%   The function DAEFUN must be defined as 
-%        FUNCTION [R, FLAG] = DAEFUN(T, YY, YP)
-%   and must return a vector R corresponding to f(t,yy,yp).
-%   If a user data structure DATA was specified in IDAInit, then
-%   DAEFUN must be defined as
-%        FUNCTION [R, FLAG, NEW_DATA] = DAEFUN(T, YY, YP, DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then, besides setting the vector YD,
-%   the DAEFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function DAEFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAInit
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.3 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDAResFnB.m b/sundialsTB/idas/function_types/IDAResFnB.m
deleted file mode 100644
index 62cdb46..0000000
--- a/sundialsTB/idas/function_types/IDAResFnB.m
+++ /dev/null
@@ -1,19 +0,0 @@
-%IDAResFnb - type for residual function for backward problems
-%
-%   The function DAEFUNB must be defined either as
-%        FUNCTION [RB, FLAG] = DAEFUNB(T, YY, YP, YYB, YPB)
-%   or as
-%        FUNCTION [RB, FLAG, NEW_DATA] = DAEFUNB(T, YY, YP, YYB, YPB, DATA)
-%   depending on whether a user data structure DATA was specified in
-%   IDAInit. In either case, it must return the vector RB
-%   corresponding to fB(t,yy,yp,yyB,ypB).
-%
-%   The function DAEFUNB must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDAInitB, IDARhsFn
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDARootFn.m b/sundialsTB/idas/function_types/IDARootFn.m
deleted file mode 100644
index 35ed80f..0000000
--- a/sundialsTB/idas/function_types/IDARootFn.m
+++ /dev/null
@@ -1,26 +0,0 @@
-%IDARootFn - type for user provided root-finding function.
-%
-%   The function ROOTFUN must be defined as 
-%        FUNCTION [G, FLAG] = ROOTFUN(T,YY,YP)
-%   and must return a vector G corresponding to g(t,yy,yp).
-%   If a user data structure DATA was specified in IDAInit, then
-%   ROOTFUN must be defined as
-%        FUNCTION [G, FLAG, NEW_DATA] = ROOTFUN(T,YY,YP,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector G,
-%   the ROOTFUN function must also set NEW_DATA. Otherwise, it should 
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function ROOTFUN must set FLAG=0 if successful, or FLAG~=0 if
-%   a failure occurred.
-%
-%   See also IDASetOptions
-%
-%   NOTE: ROOTFUN is specified through the RootsFn property in 
-%   IDASetOptions and is used only if the property NumRoots is a
-%   positive integer.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/function_types/IDASensResFn.m b/sundialsTB/idas/function_types/IDASensResFn.m
deleted file mode 100644
index 1e964ec..0000000
--- a/sundialsTB/idas/function_types/IDASensResFn.m
+++ /dev/null
@@ -1,26 +0,0 @@
-%IDASensRhsFn - type for user provided sensitivity RHS function.
-%
-%   The function DAESFUN must be defined as 
-%        FUNCTION [RS, FLAG] = DAESFUN(T,YY,YP,YYS,YPS)
-%   and must return a matrix RS corresponding to fS(t,yy,yp,yyS,ypS).
-%   If a user data structure DATA was specified in IDAInit, then
-%   DAESFUN must be defined as
-%        FUNCTION [RS, FLAG, NEW_DATA] = DAESFUN(T,YY,YP,YYS,YPS,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix YSD,
-%   the ODESFUN function must also set NEW_DATA. Otherwise, it should
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to 
-%   unnecessary copying).
-%
-%   The function DAESFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also IDASetFSAOptions
-%
-%   NOTE: DAESFUN is specified through the property FSAResFn to 
-%         IDASetFSAOptions.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/05/26 00:01:23 $
diff --git a/sundialsTB/idas/idm/Contents.m b/sundialsTB/idas/idm/Contents.m
deleted file mode 100644
index ab363f3..0000000
--- a/sundialsTB/idas/idm/Contents.m
+++ /dev/null
@@ -1,3 +0,0 @@
-% MEX binding of IDAS functions
-%
-%-- Radu Serban @ LLNL -- August 2007
diff --git a/sundialsTB/idas/idm/idm_bjac.m b/sundialsTB/idas/idm/idm_bjac.m
deleted file mode 100644
index 3427c36..0000000
--- a/sundialsTB/idas/idm/idm_bjac.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [J, flag, new_data] = idm_bjac(t, yy, yp, rr, cj, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [J, flag] = feval(fct,t,yy,yp,rr,cj);
-  new_data = [];
-else
-  [J, flag, new_data] = feval(fct,t,yy,yp,rr,cj,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_bjacB.m b/sundialsTB/idas/idm/idm_bjacB.m
deleted file mode 100644
index 452206d..0000000
--- a/sundialsTB/idas/idm/idm_bjacB.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [J, flag, new_data] = idm_bjacB(t, yy, yp, rr, cj, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [J, flag] = feval(fct,t,yy,yp,rr,cj);
-  new_data = [];
-else
-  [J, flag, new_data] = feval(fct,t,yy,yp,rr,cj,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_djac.m b/sundialsTB/idas/idm/idm_djac.m
deleted file mode 100644
index a68fa16..0000000
--- a/sundialsTB/idas/idm/idm_djac.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [J, flag, new_data] = idm_djac(t, yy, yp, rr, cj, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [J, flag] = feval(fct,t,yy,yp,rr,cj);
-  new_data = [];
-else
-  [J, flag, new_data] = feval(fct,t,yy,yp,rr,cj,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_djacB.m b/sundialsTB/idas/idm/idm_djacB.m
deleted file mode 100644
index 87528af..0000000
--- a/sundialsTB/idas/idm/idm_djacB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [JB, flag, new_data] = idm_djacB(t, yy, yp, yyB, ypB, rrB, cjB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [JB, flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB);
-  new_data = [];
-else
-  [JB, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB,data);
-end
diff --git a/sundialsTB/idas/idm/idm_gcom.m b/sundialsTB/idas/idm/idm_gcom.m
deleted file mode 100644
index 0a2e1e5..0000000
--- a/sundialsTB/idas/idm/idm_gcom.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [flag, new_data] = idm_gcom(t, yy, yp, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,t,yy,yp);
-  new_data = [];
-else
-  [flag, new_data] = feval(fct,t,yy,yp,data);
-end
diff --git a/sundialsTB/idas/idm/idm_gcomB.m b/sundialsTB/idas/idm/idm_gcomB.m
deleted file mode 100644
index 06ce22a..0000000
--- a/sundialsTB/idas/idm/idm_gcomB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [flag, new_data] = idm_gcomB(t, yy, yp, yyB, ypB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,t,yy,yp,yyB,ypB);
-  new_data = [];
-else
-  [flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data);
-end
diff --git a/sundialsTB/idas/idm/idm_gloc.m b/sundialsTB/idas/idm/idm_gloc.m
deleted file mode 100644
index 1879b00..0000000
--- a/sundialsTB/idas/idm/idm_gloc.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [res, flag, new_data] = idm_gloc(t, yy, yp, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [res, flag] = feval(fct,t,yy,yp);
-  new_data = [];
-else
-  [res, flag, new_data] = feval(fct,t,yy,yp,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_glocB.m b/sundialsTB/idas/idm/idm_glocB.m
deleted file mode 100644
index b32e34a..0000000
--- a/sundialsTB/idas/idm/idm_glocB.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [resB, flag, new_data] = idm_glocB(t, yy, yp, yyB, ypB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [resB, flag] = feval(fct,t,yy,yp,yyB,ypB);
-  new_data = [];
-else
-  [resB, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_jtv.m b/sundialsTB/idas/idm/idm_jtv.m
deleted file mode 100644
index ebbadd1..0000000
--- a/sundialsTB/idas/idm/idm_jtv.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [Jv, flag, new_data] = idm_jtv(t, yy, yp, rr, v, cj, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [Jv, flag] = feval(fct,t,yy,yp,rr,v,cj);
-  new_data = [];
-else
-  [Jv, flag, new_data] = feval(fct,t,yy,yp,rr,v,cj,data);
-end
diff --git a/sundialsTB/idas/idm/idm_jtvB.m b/sundialsTB/idas/idm/idm_jtvB.m
deleted file mode 100644
index 2d91c84..0000000
--- a/sundialsTB/idas/idm/idm_jtvB.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [JvB, flag, new_data] = idm_jtvB(t, yy, yp, yyB, ypB, rrB, vB, cjB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [JvB, flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,vB,cjB);
-  new_data = [];
-else
-  [JvB, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,vB,cjB,data);
-end
diff --git a/sundialsTB/idas/idm/idm_monitor.m b/sundialsTB/idas/idm/idm_monitor.m
deleted file mode 100644
index 909b151..0000000
--- a/sundialsTB/idas/idm/idm_monitor.m
+++ /dev/null
@@ -1,16 +0,0 @@
-function new_mondata = idm_monitor(call, t, yy, yQ, Ns, yyS, fct, mondata)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-N = length(yy);
-yyS = reshape(yyS, N, Ns);
-
-if isempty(mondata)
-  feval(fct, call, t, yy, yQ, yyS);
-  new_mondata = [];
-else
-  new_mondata = feval(fct, call, t, yy, yQ, yyS, mondata);
-end
-
diff --git a/sundialsTB/idas/idm/idm_monitorB.m b/sundialsTB/idas/idm/idm_monitorB.m
deleted file mode 100644
index 77019f5..0000000
--- a/sundialsTB/idas/idm/idm_monitorB.m
+++ /dev/null
@@ -1,15 +0,0 @@
-function [new_mondata] = idm_monitorB(call, idxB, t, y, yQ, fct, mondata)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-N = length(y);
-
-idxB = idxB+1;
-if isempty(mondata)
-  feval(fct, call, idxB, t, y, yQ);
-  new_mondata = [];
-else
-  new_mondata = feval(fct, call, idxB, t, y, yQ, mondata);
-end
diff --git a/sundialsTB/idas/idm/idm_options.m b/sundialsTB/idas/idm/idm_options.m
deleted file mode 100644
index f0da21c..0000000
--- a/sundialsTB/idas/idm/idm_options.m
+++ /dev/null
@@ -1,66 +0,0 @@
-function options = idm_options(KeyNames, varargin)
-
-m = length(KeyNames);
-
-% Initialize the output options structure
-
-options = [];
-for i = 1:m
-  options.(KeyNames{i}) = [];
-end
-
-% If the first argument is an options structure, read its non-empty fields
-% and update options. Store in j the start of key-value pairs.
-
-arg = varargin{1};
-
-if isa(arg,'struct')
-  for i = 1:m
-    if isfield(arg,KeyNames{i})
-      options.(KeyNames{i}) = arg.(KeyNames{i});
-    end
-  end
-  j = 2;
-else
-  j = 1;  
-end
-
-% The remaining input arguments must be key-value pairs
-
-if rem(nargin-j,2) ~= 0
-  error('Arguments must be key-value pairs.');
-end
-
-% Process each key-value pair
-
-np = (nargin-j)/2;
-
-keynames = lower(KeyNames);
-
-for i = 1:np
-  
-  % Get the key
-  key = varargin{j};
-  
-  % key must be a string 
-  if ~isstr(key)
-    error(sprintf('Argument %d is not a string property name.', j));
-  end
-  
-  % Get the index in keynames that exactly matches the current key
-  % (modulo the case)
-  ik = strmatch(lower(key), keynames, 'exact');
-  if isempty(ik)
-    error(sprintf('Unrecognized property "%s"', key));
-  end
-
-  % Get the value
-  val = varargin{j+1};
-
-  % Set the proper field in options
-  options.(KeyNames{ik}) = val;
-  
-  % move to next pair  
-  j = j+2;
-  
-end
diff --git a/sundialsTB/idas/idm/idm_pset.m b/sundialsTB/idas/idm/idm_pset.m
deleted file mode 100644
index f071900..0000000
--- a/sundialsTB/idas/idm/idm_pset.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [flag, new_data] = idm_pset(t, yy, yp, rr, cj, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,t,yy,yp,rr,cj);
-  new_data = [];
-else
-  [flag, new_data] = feval(fct,t,yy,yp,rr,cj,data);
-end
diff --git a/sundialsTB/idas/idm/idm_psetB.m b/sundialsTB/idas/idm/idm_psetB.m
deleted file mode 100644
index 9afe7b9..0000000
--- a/sundialsTB/idas/idm/idm_psetB.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [flag, new_data] = idm_psetB(t, yy, yp, yyB, ypB, rrB, cjB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,t,yy,yp,yyB,ypB,rrB,cjB);
-  new_data = [];
-else
-  [flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,cjBy,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_psol.m b/sundialsTB/idas/idm/idm_psol.m
deleted file mode 100644
index 9c67f34..0000000
--- a/sundialsTB/idas/idm/idm_psol.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [z, flag, new_data] = idm_psol(t, yy, yp, rr, r, cj, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [z, flag] = feval(fct,t,yy,yp,rr,r,cj);
-  new_data = [];
-else
-  [z, flag, new_data] = feval(fct,t,yy,yp,rr,r,cj,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_psolB.m b/sundialsTB/idas/idm/idm_psolB.m
deleted file mode 100644
index 40feaeb..0000000
--- a/sundialsTB/idas/idm/idm_psolB.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [zB, flag, new_data] = idm_psolB(t, yy, yp, yyB, ypB, rrB, rB, cjB, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [zB, flag] = feval(fct,t,yy,yp,yyB,ypB,rrB,rB,cjB);
-  new_data = [];
-else
-  [zB, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,rrB,rB,cjB,data);
-end
-
diff --git a/sundialsTB/idas/idm/idm_res.m b/sundialsTB/idas/idm/idm_res.m
deleted file mode 100644
index 1224e38..0000000
--- a/sundialsTB/idas/idm/idm_res.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [res, flag, new_data] = idm_res(t, yy, yp, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [res, flag] = feval(fct,t,yy,yp);
-  new_data = [];
-else
-  [res, flag, new_data] = feval(fct,t,yy,yp,data);
-end
diff --git a/sundialsTB/idas/idm/idm_resB.m b/sundialsTB/idas/idm/idm_resB.m
deleted file mode 100644
index b4e8b32..0000000
--- a/sundialsTB/idas/idm/idm_resB.m
+++ /dev/null
@@ -1,54 +0,0 @@
-function [resB, flag, new_data] = idm_resB(type, varargin)
- 
-%
-% Wrapper around the actual user-provided Matlab function
-%
- 
-switch type
-   
- case 0
- 
-  % Not dependent on yS
-   
-  t    = varargin{1};
-  yy   = varargin{2};
-  yp   = varargin{3};
-  yyB  = varargin{4};
-  ypB  = varargin{5};
-  fct  = varargin{6};
-  data = varargin{7};
-   
-  if isempty(data)
-    [resB, flag] = feval(fct,t,yy,yp,yyB,ypB);
-    new_data = [];
-  else
-    [resB, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data);
-  end
- 
- case 1
-   
-  % Dependent on yS
-   
-  t    = varargin{1};
-  yy   = varargin{2};
-  yp   = varargin{3};
-  Ns   = varargin{4};
-  yyS  = varargin{5};
-  ypS  = varargin{6};
-  yyB  = varargin{7};
-  ypB  = varargin{8};
-  fct  = varargin{9};
-  data = varargin{10};
-   
-  N = length(yy);
-  yyS = reshape(yyS,N,Ns);
-  ypS = reshape(ypS,N,Ns);
-  
-  if isempty(data)
-    [resB, flag] = feval(fct,t,yy,yp,yyS,ypS,yyB,ypB);
-    new_data = [];
-  else
-    [resB, flag, new_data] = feval(fct,t,yy,yp,yyS,ypS,yyB,ypB,data);
-  end
- 
-end
diff --git a/sundialsTB/idas/idm/idm_resS.m b/sundialsTB/idas/idm/idm_resS.m
deleted file mode 100644
index 7dcef47..0000000
--- a/sundialsTB/idas/idm/idm_resS.m
+++ /dev/null
@@ -1,18 +0,0 @@
-function [rrS, flag, new_data] = idm_resS(t, yy, yp, rr, Ns, yyS, ypS, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-N = length(yy);
-yyS = reshape(yyS, N, Ns);
-ypS = reshape(ypS, N, Ns);
-
-if isempty(data)
-  [rrS, flag] = feval(fct,t,yy,yp,rr,yyS,ypS);
-  new_data = [];
-else
-  [rrS, flag, new_data] = feval(fct,t,yy,yp,rr,yyS,ypS,data);
-end
-
-rrS = reshape(rrS, N*Ns, 1);
\ No newline at end of file
diff --git a/sundialsTB/idas/idm/idm_rhsQ.m b/sundialsTB/idas/idm/idm_rhsQ.m
deleted file mode 100644
index aeb35e2..0000000
--- a/sundialsTB/idas/idm/idm_rhsQ.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [qd, flag, new_data] = idm_rhsQ(t, yy, yp, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [qd, flag] = feval(fct,t,yy,yp);
-  new_data =[];
-else
-  [qd, flag, new_data] = feval(fct,t,yy,yp,data);
-end
diff --git a/sundialsTB/idas/idm/idm_rhsQB.m b/sundialsTB/idas/idm/idm_rhsQB.m
deleted file mode 100644
index cf191af..0000000
--- a/sundialsTB/idas/idm/idm_rhsQB.m
+++ /dev/null
@@ -1,55 +0,0 @@
-function [qBd, flag, new_data] = idm_rhsQB(type, varargin)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-switch type
-  
- case 0
- 
-  % Not dependent on yS
-
-  t    = varargin{1};
-  yy   = varargin{2};
-  yp   = varargin{3};
-  yyB  = varargin{4};
-  ypB  = varargin{5};
-  fct  = varargin{6};
-  data = varargin{7};
-  
-  if isempty(data)
-    [qBd, flag] = feval(fct,t,yy,yp,yyB,ypB);
-    new_data = [];
-  else
-    [qBd, flag, new_data] = feval(fct,t,yy,yp,yyB,ypB,data);
-  end
-
- case 1
- 
-  % Dependent on yS
-
-  t    = varargin{1};
-  yy   = varargin{2};
-  yp   = varargin{3};
-  Ns   = varargin{4};
-  yyS  = varargin{5};
-  ypS  = varargin{6};
-  yyB  = varargin{7};
-  ypB  = varargin{8};
-  fct  = varargin{9};
-  data = varargin{10};
-  
-  N = length(y);
-  yyS = reshape(yS,N,Ns);
-  ypS = reshape(yS,N,Ns);
-  
-  if isempty(data)
-    [qBd, flag] = feval(fct,t,yy,yp,yyS,ypS,yyB,ypB);
-    new_data = [];
-  else
-    [qBd, flag, new_data] = feval(fct,t,yy,yp,yyS,ypS,yyB,ypB,data);
-  end
-
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/idas/idm/idm_root.m b/sundialsTB/idas/idm/idm_root.m
deleted file mode 100644
index 5ebf404..0000000
--- a/sundialsTB/idas/idm/idm_root.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [g, flag, new_data] = idm_root(t, yy, yp, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [g, flag] = feval(fct,t,yy,yp);
-  new_data = [];
-else
-  [g, flag, new_data] = feval(fct,t,yy,yp,data);
-end
-
diff --git a/sundialsTB/idas/idm/src/idm.c b/sundialsTB/idas/idm/src/idm.c
deleted file mode 100644
index 5ca7faf..0000000
--- a/sundialsTB/idas/idm/src/idm.c
+++ /dev/null
@@ -1,3513 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.21 $
- * $Date: 2012/03/07 21:49:18 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/idas/LICENSE.
- * -----------------------------------------------------------------
- * MEX implementation for IDAS Matlab interface.
- * -----------------------------------------------------------------
- */
-
-
-/*
- * TO DO
- *
- *  - implement idmSolveB_more
- *  - implement IDM_CalcICB
- */
-
-
-
-#include <string.h>
-#include <stdlib.h>
-#include "idm.h"
-#include "nvm.h"
-
-/*
- * ---------------------------------------------------------------------------------
- * Global interface data variable
- * ---------------------------------------------------------------------------------
- */
-
-idmInterfaceData idmData = NULL;
-
-/*
- * ---------------------------------------------------------------------------------
- * Static function prototypes
- * ---------------------------------------------------------------------------------
- */
-
-static void idmInitIDASdata();
-static void idmPersistIDASdata();
-static void idmFinalIDASdata();
-
-static void idmInitPbData(idmPbData pb);
-static void idmPersistPbData(idmPbData pb);
-static void idmFinalPbData(idmPbData pb);
-
-
-static int IDM_Initialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_QuadInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_SensInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_AdjInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int IDM_InitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_QuadInitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int IDM_SensToggleOff(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int IDM_CalcIC(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_CalcICB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int IDM_Solve(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_SolveB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int idmSolveB_one(mxArray *plhs[], int NtoutB, double *toutB, int itaskB);
-static int idmSolveB_more(mxArray *plhs[], int NtoutB, double *toutB, int itaskB,
-                          booleantype any_quadrB, booleantype any_monB);
-
-static int IDM_Stats(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_StatsB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int IDM_Set(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int IDM_SetB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int IDM_Get(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-static int IDM_Free(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-/*
- * ---------------------------------------------------------------------------------
- * Main entry point
- * ---------------------------------------------------------------------------------
- */
-
-void mexFunction(int nlhs, mxArray *plhs[],
-                 int nrhs, const mxArray *prhs[])
-{
-  int mode;
-  /* 
-     Modes:
-     
-     1 - initialize IDAS solver
-     2 - initialize quadratures
-     3 - initialize forward sensitivity calculations
-     4 - initialize adjoint sensitivity calculations
-     5 - initialize backward solver
-     6 - initialize backward quadratures
-
-    11 - reinitialize IDAS solver
-    12 - reinitialize quadratures
-    13 - reinitialize forward sensitivity calculations
-    14 - reinitialize adjoint sensitivity calculations
-    15 - reinitialize backward solver
-    16 - reinitialize backward quadratures
-
-    18 - toggle FSA off
-
-    20 - solve problem
-    21 - solve backward problem                TODO
-
-    25 - calculate consistent IC
-    26 - calculate backward consistent IC      TODO
-
-    30 - get integrator stats
-    31 - get backward integrator stats
-    32 - extract data from ida_mem
-
-    33 - set one optional input at a time
-    34 - set one optional input at a time for backward problems
-
-    40 - finalize
-  */
-
-  mode = (int)mxGetScalar(prhs[0]);
-
-  mexUnlock();
-
-  if ( (mode != 1) && (idmData == NULL) ) {
-    mexErrMsgTxt("IDAS - Illegal attempt to call before IDAInit.");
-  }
-
-
-  switch(mode) {
-
-    /* Initialization functions */
-
-  case 1:
-    if (idmData != NULL) {
-      IDM_Free(nlhs, plhs, nrhs-1, &prhs[1]);
-      idmFinalIDASdata();
-    }
-    idmInitIDASdata();
-    IDM_Initialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 2:
-    IDM_QuadInitialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 3:
-    IDM_SensInitialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 4:
-    IDM_AdjInitialization(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 5:
-    IDM_InitializationB(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 6:
-    IDM_QuadInitializationB(0, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Re-initialization functions */
-
-  case 11:
-    IDM_Initialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 12:
-    IDM_QuadInitialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 13:
-    IDM_SensInitialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 14:
-    IDM_AdjInitialization(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 15:
-    IDM_InitializationB(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 16:
-    IDM_QuadInitializationB(1, nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Sensitivity toggle function */
-
-  case 18:
-    IDM_SensToggleOff(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-    
-    /* Solve functions */
-
-  case 20:
-    IDM_Solve(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 21:
-    IDM_SolveB(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Consistent IC calculation functions */
-
-  case 25:
-    IDM_CalcIC(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 26:
-    IDM_CalcICB(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Optional output extraction functions */
-
-  case 30:
-    IDM_Stats(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 31:
-    IDM_StatsB(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 32:
-    IDM_Get(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 33:
-    IDM_Set(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 34:
-    IDM_SetB(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-    /* Memory deallocation function */
-
-  case 40:
-    IDM_Free(nlhs, plhs, nrhs-1, &prhs[1]);
-    idmFinalIDASdata();
-    return;
-
-  }
-
-  /* Unless this was the IDAFree call,
-   * make data persistent and lock the MEX file */
-  if (mode != 40) {
-    idmPersistIDASdata();
-    mexLock();
-  }
-
-  return;
-}
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Private functions
- * ---------------------------------------------------------------------------------
- */
-
-
-static void idmInitIDASdata()
-{
-  /* Allocate space for global IDAS data structure */
-
-  idmData = (idmInterfaceData) mxMalloc(sizeof(struct idmInterfaceData_));
-
-  /* Initialize global IDAS data */
-
-  idmData->ida_mem = NULL;
-
-  idmData->fwdPb     = NULL;
-  idmData->bckPb     = NULL;
-
-  idmData->NbckPb    = 0;
-
-  idmData->Nd        = 0;
-  idmData->Nc        = 0;
-  idmData->asa       = FALSE;
-
-  idmData->errMsg    = TRUE;
-
-  return;
-}
-
-
-static void idmInitPbData(idmPbData pb)
-{
-  mxArray *empty;
-
-  pb->n  = 0;
-  pb->nq = 0;
-  pb->ng = 0;
-  pb->ns = 0;
-
-  pb->YY = NULL;
-  pb->YP = NULL;
-
-  pb->YQ = NULL;
-
-  pb->YYS = NULL;
-  pb->YPS = NULL;
-
-  pb->Quadr = FALSE;
-  pb->Fsa   = FALSE;
-  pb->Mon   = FALSE;
-
-  pb->LS = LS_DENSE;
-  pb->PM = PM_NONE;
-
-  empty = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  pb->RESfct   = mxDuplicateArray(empty);
-  pb->Gfct     = mxDuplicateArray(empty);
-  pb->QUADfct  = mxDuplicateArray(empty);
-  pb->SRESfct  = mxDuplicateArray(empty);
-  pb->JACfct   = mxDuplicateArray(empty);
-  pb->PSETfct  = mxDuplicateArray(empty);
-  pb->PSOLfct  = mxDuplicateArray(empty);
-  pb->GLOCfct  = mxDuplicateArray(empty);
-  pb->GCOMfct  = mxDuplicateArray(empty);
-
-  pb->MONfct   = mxDuplicateArray(empty);
-  pb->MONdata  = mxDuplicateArray(empty);
-
-  pb->mtlb_data = mxDuplicateArray(empty);
-
-  pb->fwd = idmData->fwdPb;
-
-  pb->index = 0;
-  pb->next  = NULL;
-
-  mxDestroyArray(empty);
-}
-
-
-static void idmPersistIDASdata()
-{
-  idmPbData tmpPb;
-
-  /* Make global memory persistent */
-
-  if (idmData->fwdPb != NULL) {
-    idmPersistPbData(idmData->fwdPb);
-    mexMakeMemoryPersistent(idmData->fwdPb);
-  }
-
-  tmpPb = idmData->bckPb;
-  while(tmpPb != NULL) {
-    idmPersistPbData(tmpPb);
-    mexMakeMemoryPersistent(tmpPb);
-    tmpPb = tmpPb->next;
-  }
-  
-  mexMakeMemoryPersistent(idmData);
-
-  return;
-}
-
-
-static void idmPersistPbData(idmPbData pb)
-{
-  mexMakeArrayPersistent(pb->mtlb_data);
-
-  mexMakeArrayPersistent(pb->RESfct);
-  mexMakeArrayPersistent(pb->Gfct);
-  mexMakeArrayPersistent(pb->QUADfct);
-  mexMakeArrayPersistent(pb->SRESfct);
-  mexMakeArrayPersistent(pb->JACfct);
-  mexMakeArrayPersistent(pb->PSETfct);
-  mexMakeArrayPersistent(pb->PSOLfct);
-  mexMakeArrayPersistent(pb->GLOCfct);
-  mexMakeArrayPersistent(pb->GCOMfct);
-
-  mexMakeArrayPersistent(pb->MONfct);
-  mexMakeArrayPersistent(pb->MONdata);
-}
-
-static void idmFinalIDASdata()
-{  
-  idmPbData tmpPb;
-
-  if (idmData == NULL) return;
-
-  if (idmData->fwdPb != NULL) {
-    idmFinalPbData(idmData->fwdPb);
-    mxFree(idmData->fwdPb);
-    idmData->fwdPb = NULL;
-  }
-
-  while(idmData->bckPb != NULL) {
-    tmpPb = idmData->bckPb->next;
-    mxFree(idmData->bckPb);
-    idmData->bckPb = tmpPb;
-  }
-
-  mxFree(idmData);
-  idmData = NULL;
-
-  return;
-}
-
-
-static void idmFinalPbData(idmPbData pb)
-{
-
-  if (pb->YY != NULL) N_VDestroy(pb->YY);
-  if (pb->YP != NULL) N_VDestroy(pb->YP);
-
-  if (pb->YQ != NULL) N_VDestroy(pb->YQ);
-
-  if (pb->YYS != NULL) N_VDestroyVectorArray(pb->YYS, pb->ns);
-  if (pb->YPS != NULL) N_VDestroyVectorArray(pb->YPS, pb->ns);
-
-  mxDestroyArray(pb->mtlb_data);
-
-  mxDestroyArray(pb->RESfct);
-  mxDestroyArray(pb->Gfct);
-  mxDestroyArray(pb->QUADfct);
-  mxDestroyArray(pb->SRESfct);
-  mxDestroyArray(pb->JACfct);
-  mxDestroyArray(pb->PSETfct);
-  mxDestroyArray(pb->PSOLfct);
-  mxDestroyArray(pb->GLOCfct);
-  mxDestroyArray(pb->GCOMfct);
-
-  mxDestroyArray(pb->MONfct);
-  mxDestroyArray(pb->MONdata);
-
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Error handler function.
- *
- * This function is both passed as the IDAS error handler and used throughout
- * the Matlab interface.
- *
- * If called directly by one of the interface functions, error_code = -999 to
- * indicate an error and err_code = +999 to indicate a warning. Otherwise,
- * err_code is set by the calling IDAS function.
- *
- * NOTE: mexErrMsgTxt will end the execution of the MEX file. Therefore we do
- *       not have to intercept any of the IDAS error return flags.
- *       The only return flags we intercept are those from IDASolve() and IDASolveB()
- *       which are passed back to the user (only positive values will make it). 
- * ---------------------------------------------------------------------------------
- */
-
-void idmErrHandler(int error_code, 
-                   const char *module, const char *function, 
-                   char *msg, void *f_data)
-{
-  char err_msg[256];
-
-  if (!(idmData->errMsg)) return;
-
-  if (error_code > 0) {
-    sprintf(err_msg,"Warning in ==> %s\n%s",function,msg);
-    mexWarnMsgTxt(err_msg);    
-  } else if (error_code < 0) {
-    sprintf(err_msg,"Error using ==> %s\n%s",function,msg);
-    mexErrMsgTxt(err_msg);
-  }
-
-  return;
-}
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define ida_mem     (idmData->ida_mem)
-
-#define asa         (idmData->asa)
-#define Nd          (idmData->Nd) 
-#define Nc          (idmData->Nc) 
-#define NbckPb      (idmData->NbckPb)
-
-#define fsa         (fwdPb->Fsa)
-#define quadr       (fwdPb->Quadr)
-#define mon         (fwdPb->Mon)
-#define rootSet     (fwdPb->RootSet)
-#define tstopSet    (fwdPb->TstopSet)
-
-#define yy          (fwdPb->YY) 
-#define yp          (fwdPb->YP) 
-#define yQ          (fwdPb->YQ) 
-#define yyS         (fwdPb->YYS) 
-#define ypS         (fwdPb->YPS) 
-#define N           (fwdPb->n) 
-#define Nq          (fwdPb->nq) 
-#define Ng          (fwdPb->ng) 
-#define Ns          (fwdPb->ns) 
-#define ls          (fwdPb->LS) 
-#define pm          (fwdPb->PM)
-
-#define mtlb_data     (fwdPb->mtlb_data)
-
-#define mtlb_RESfct   (fwdPb->RESfct)
-#define mtlb_QUADfct  (fwdPb->QUADfct)
-#define mtlb_JACfct   (fwdPb->JACfct)
-#define mtlb_PSETfct  (fwdPb->PSETfct)
-#define mtlb_PSOLfct  (fwdPb->PSOLfct)
-#define mtlb_GLOCfct  (fwdPb->GLOCfct)
-#define mtlb_GCOMfct  (fwdPb->GCOMfct)
-#define mtlb_Gfct     (fwdPb->Gfct)
-#define mtlb_SRESfct  (fwdPb->SRESfct)
-
-#define mtlb_MONfct   (fwdPb->MONfct)
-#define mtlb_MONdata  (fwdPb->MONdata)
-
-
-#define indexB      (bckPb->index)
-
-#define quadrB      (bckPb->Quadr)
-#define monB        (bckPb->Mon)
-
-#define yyB         (bckPb->YY) 
-#define ypB         (bckPb->YP) 
-#define yQB         (bckPb->YQ) 
-#define NB          (bckPb->n) 
-#define NqB         (bckPb->nq) 
-#define lsB         (bckPb->LS) 
-#define pmB         (bckPb->PM) 
-
-#define mtlb_dataB    (bckPb->mtlb_data)
-
-#define mtlb_RESfctB  (bckPb->RESfct)
-#define mtlb_QUADfctB (bckPb->QUADfct)
-#define mtlb_JACfctB  (bckPb->JACfct)
-#define mtlb_PSETfctB (bckPb->PSETfct)
-#define mtlb_PSOLfctB (bckPb->PSOLfct)
-#define mtlb_GLOCfctB (bckPb->GLOCfct)
-#define mtlb_GCOMfctB (bckPb->GCOMfct)
-
-#define mtlb_MONfctB  (bckPb->MONfct)
-#define mtlb_MONdataB (bckPb->MONdata)
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Exported procedures
- * ---------------------------------------------------------------------------------
- */
-
-/* IDM_Initialization
- *
- * action = 0   -> IDACreate + IDAInit
- * action = 1   -> IDAReInit
- *
- * prhs contains:
- *   res
- *   t0
- *   yy0
- *   yp0
- *   options
- *   data
- *
- * plhs contains:
- *   status
- *
- */
-
-static int IDM_Initialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  const mxArray *options;
-
-  double t0, *yy0, *yp0;
-
-  int maxord;
-  long int mxsteps;
-
-  int itol;
-  realtype reltol, Sabstol, *Vabstol;
-  N_Vector NV_abstol;
-
-  double hin, hmax;
-  double tstop;
-
-  booleantype suppress;
-
-  long int mupper, mlower;
-  int gstype, maxl;
-  long int mudq, mldq;
-  double dqrely;
-
-  double *id, *cnstr;
-  N_Vector NV_id, NV_cnstr;
-
-  booleantype errmsg;
-
-  booleantype res_s; /* ignored */
-
-  int status;
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* SOLVER INITIALIZATION */
-
-    /* Create and initialize a new problem */
-
-    fwdPb = (idmPbData) mxMalloc(sizeof(struct idmPbData_));
-    idmInitPbData(fwdPb);
-
-    idmData->fwdPb = fwdPb;
-
-    /* Initialize appropriate vector module */
-
-    InitVectors();
-
-    /* Extract user-provided RES function */
-
-    mxDestroyArray(mtlb_RESfct);
-    mtlb_RESfct = mxDuplicateArray(prhs[0]);
-
-    /* Extract initial time */
-
-    t0 = (double)mxGetScalar(prhs[1]);
-
-    /* Extract initial conditions */
-
-    yy0 = mxGetPr(prhs[2]);
-    yp0 = mxGetPr(prhs[3]);
-    N = mxGetM(prhs[2]);
-
-    /* Create the solution N_Vectors */
-
-    yy = NewVector(N);
-    yp = NewVector(N);
-
-    /* Load initial conditions */
-
-    PutData(yy, yy0, N);
-    PutData(yp, yp0, N);
-
-    /* Extract options structure */
-    
-    options = prhs[4];
-
-    break;
-
-  case 1:    /* SOLVER RE-INITIALIZATION */
-
-    fwdPb = idmData->fwdPb;
-
-    /* If monitoring was enabled, finalize it now. */
-
-    if (mon) mxW_IDAMonitor(2, 0.0, NULL, NULL, NULL, fwdPb);
-
-    /* Extract initial time */
-
-    t0 = (double)mxGetScalar(prhs[0]);
-
-    /* Extract initial conditions */
-
-    yy0 = mxGetPr(prhs[1]);
-
-    if (mxGetM(prhs[1]) != N) {
-      idmErrHandler(-999, "IDAS", "IDAReInit",
-                    "Size of yy0 changed from IDAInit call.", NULL);
-      goto error_return;
-    }
-
-    yp0 = mxGetPr(prhs[2]);
-
-    if (mxGetM(prhs[2]) != N) {
-      idmErrHandler(-999, "IDAS", "IDAReInit",
-                    "Size of yp0 changed from IDAInit call.", NULL);
-      goto error_return;
-    }
-
-    /* Load initial conditions */
-
-    PutData(yy, yy0, N);
-    PutData(yp, yp0, N);
-
-    /* Extract options structure */
-    
-    options = prhs[3];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_IntgrOptions(options, fwdPb, TRUE,
-                            &maxord, &mxsteps,
-                            &itol, &reltol, &Sabstol, &Vabstol,
-                            &hin, &hmax, &tstop,
-                            &suppress, &errmsg,
-                            &id, &cnstr,
-                            &res_s);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate IDAS functions
-   *
-   * If action = 0
-   *    Create IDAS object and allocate memory
-   *    Attach error handler function
-   *    Redirect output
-   * If action = 1
-   *    Reinitialize solver
-   * ----------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:
-
-    /* Create IDAS object */
-    ida_mem = IDACreate();
-    if (ida_mem == NULL) goto error_return;
-
-    /* Attach the global IDAS data as 'user-data' */
-    status = IDASetUserData(ida_mem, fwdPb);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    /* Attach error handler function */
-    status = IDASetErrHandlerFn(ida_mem, idmErrHandler, fwdPb);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    /* Call IDAInit */
-    status = IDAInit(ida_mem, mxW_IDARes, t0, yy, yp);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    /* Redirect output */
-    status = IDASetErrFile(ida_mem, stdout);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  case 1:
-
-    /* Reinitialize solver */
-    status = IDAReInit(ida_mem, t0, yy, yp);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances
-   * ----------------------------------------
-   */
-
-  switch (itol) {
-    case IDA_SS:
-      status = IDASStolerances(ida_mem, reltol, Sabstol);
-      if (status != IDA_SUCCESS) goto error_return;
-      break;
-    case IDA_SV:
-      NV_abstol = N_VClone(yy);
-      PutData(NV_abstol, Vabstol, N);
-      status = IDASVtolerances(ida_mem, reltol, NV_abstol);
-      if (status != IDA_SUCCESS) goto error_return;
-      N_VDestroy(NV_abstol);
-      break;
-    }
-
-
-  /*
-   * --------------------------------
-   * Set various optional inputs
-   * --------------------------------
-   */
-
-  /* set maxorder (default is 5) */
-  status = IDASetMaxOrd(ida_mem, maxord);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set initial step size (the default value of 0.0 is ignored by IDAS) */
-  status = IDASetInitStep(ida_mem, hin);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set max step (default is infinity) */
-  status = IDASetMaxStep(ida_mem, hmax);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set number of max steps */
-  status = IDASetMaxNumSteps(ida_mem, mxsteps);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set suppressAlg */
-  status = IDASetSuppressAlg(ida_mem, suppress);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set tstop? */
-  if (tstopSet) {
-    status = IDASetStopTime(ida_mem, tstop);
-    if (status != IDA_SUCCESS) goto error_return;  
-  }
-
-  /* Rootfinding? */
-  if ( !mxIsEmpty(mtlb_Gfct) && (Ng > 0) ) {
-    status = IDARootInit(ida_mem, Ng, mxW_IDAGfct);
-    if (status != IDA_SUCCESS) goto error_return;
-    rootSet = TRUE;
-  } else {
-    rootSet = FALSE;
-  }
-
-  /* ID vector specified? */
-  if (id != NULL) {
-    NV_id = N_VClone(yy);
-    PutData(NV_id, id, N);
-    status = IDASetId(ida_mem, NV_id);
-    if (status != IDA_SUCCESS) goto error_return;
-    N_VDestroy(NV_id);
-  }
-
-  /* Constraint vector specified? */
-  if (cnstr != NULL) {
-    NV_cnstr = N_VClone(yy);
-    PutData(NV_cnstr, cnstr, N);
-    status = IDASetConstraints(ida_mem, NV_cnstr);
-    if (status != IDA_SUCCESS) goto error_return;
-    N_VDestroy(NV_cnstr);
-  }
-
-
-  /*
-   * ----------------------------------------
-   * Linear solver
-   * ----------------------------------------
-   */
-
-  status = get_LinSolvOptions(options, fwdPb, TRUE,
-                              &mupper, &mlower,
-                              &mudq, &mldq, &dqrely,
-                              &gstype, &maxl);
-  if (status != 0) goto error_return;
-
-  switch (ls) {
-
-  case LS_DENSE:
-
-    status = IDADense(ida_mem, N);
-    if (status != IDA_SUCCESS) goto error_return;
-    if (!mxIsEmpty(mtlb_JACfct)) {
-      status = IDADlsSetDenseJacFn(ida_mem, mxW_IDADenseJac);
-      if (status != IDA_SUCCESS) goto error_return;
-    }
-
-    break;
-
-  case LS_BAND:
-
-    status = IDABand(ida_mem, N, mupper, mlower);
-    if (status != IDA_SUCCESS) goto error_return;
-    if (!mxIsEmpty(mtlb_JACfct)) {
-      status = IDADlsSetBandJacFn(ida_mem, mxW_IDABandJac);
-      if (status != IDA_SUCCESS) goto error_return;
-    }
-
-    break;
-
-  case LS_SPGMR:
-
-    status = IDASpgmr(ida_mem, maxl);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsSetGSType(ida_mem, gstype);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  case LS_SPBCG:
-
-    status = IDASpbcg(ida_mem, maxl);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  case LS_SPTFQMR:
-
-    status = IDASptfqmr(ida_mem, maxl);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-    
-  }
-
-  /* Jacobian * vector and preconditioner for SPILS linear solvers */
-
-  if ( (ls==LS_SPGMR) || (ls==LS_SPBCG) || (ls==LS_SPTFQMR) ) {
-
-    if (!mxIsEmpty(mtlb_JACfct)) {
-      status = IDASpilsSetJacTimesVecFn(ida_mem, mxW_IDASpilsJac);
-      if (status != IDA_SUCCESS) goto error_return;
-    }
-
-    switch (pm) {
-
-    case PM_NONE:
-
-      if (!mxIsEmpty(mtlb_PSOLfct)) {
-        if (!mxIsEmpty(mtlb_PSETfct)) status = IDASpilsSetPreconditioner(ida_mem, mxW_IDASpilsPset, mxW_IDASpilsPsol);
-        else                          status = IDASpilsSetPreconditioner(ida_mem, NULL, mxW_IDASpilsPsol);
-      }
-      if (status != IDA_SUCCESS) goto error_return;
-
-      break;
-
-    case PM_BBDPRE:
-
-      if (!mxIsEmpty(mtlb_GCOMfct)) status = IDABBDPrecInit(ida_mem, N, mudq, mldq, mupper, mlower, dqrely, mxW_IDABBDgloc, mxW_IDABBDgcom);
-      else                          status = IDABBDPrecInit(ida_mem, N, mudq, mldq, mupper, mlower, dqrely, mxW_IDABBDgloc, NULL);
-      if (status != IDA_SUCCESS) goto error_return;
-
-      break;
-
-    }
-
-  }
-
-  /* Do we monitor? */
-  
-  if (mon) mxW_IDAMonitor(0, t0, NULL, NULL, NULL, fwdPb);
-
-  /* Set errMsg field in global data 
-   * (all error messages from here on will respect this) */
-
-  idmData->errMsg = errmsg;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-/* IDM_QuadInitialization
- *
- * action = 0   -> IDAQuadInit
- * prhs contains:
- *   fQ
- *   y0
- *   options
- *
- * action = 1   -> IDAQuadReInit
- * prhs contains:
- *   y0
- *   options
- *
- */
-
-static int IDM_QuadInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  const mxArray *options;
-
-  double *yQ0;
-
-  booleantype rhs_s; /* ignored */
-
-  booleantype errconQ;
-  int itolQ;
-  realtype reltolQ, SabstolQ, *VabstolQ;
-  N_Vector NV_abstolQ;
-
-  int status;
-
-  fwdPb = idmData->fwdPb;
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* QUADRATURE INITIALIZATION */
-
-    /* Extract user-provided quadrature RHS function */
-
-    mxDestroyArray(mtlb_QUADfct);
-    mtlb_QUADfct = mxDuplicateArray(prhs[0]);
-  
-    /* Extract quadrature initial conditions */
-
-    yQ0 = mxGetPr(prhs[1]);
-    Nq = mxGetM(prhs[1]);
-
-    /* Create the quadrature N_Vector */
-
-    yQ = NewVector(Nq);
-
-    /* Load quadrature initial conditions */
-    
-    PutData(yQ, yQ0, Nq);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[2];
-
-    break;
-
-  case 1:     /* QUADRATURE RE-INITIALIZATION */
-
-    /* Extract quadrature initial conditions */
-
-    yQ0 = mxGetPr(prhs[0]);
-
-    if (mxGetM(prhs[0]) != Nq) {
-      idmErrHandler(-999, "IDAS", "IDAQuadReInit",
-                    "Size of yQ0 changed from IDAQuadInit call.", NULL);
-      goto error_return;
-    }
-
-    /* Load quadrature initial conditions */
-    
-    PutData(yQ, yQ0, Nq);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[1];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_QuadOptions(options, fwdPb, TRUE,
-                           Nq, &rhs_s,
-                           &errconQ, 
-                           &itolQ, &reltolQ, &SabstolQ, &VabstolQ);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate IDAS functions
-   *
-   * If action = 0
-   *    Initialize quadratures
-   * If action = 1
-   *    Reinitialize quadratures
-   * ----------------------------------------
-   */
-
-  switch (action) {
-  case 0:
-    status = IDAQuadInit(ida_mem, mxW_IDAQuadFct, yQ);
-    if (status != IDA_SUCCESS) goto error_return;
-    break;
-  case 1:
-    status = IDAQuadReInit(ida_mem, yQ);
-    if (status != IDA_SUCCESS) goto error_return;
-    break;
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances for quadrature variables
-   * ----------------------------------------
-   */
-
-  status = IDASetQuadErrCon(ida_mem, errconQ);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  if (errconQ) {
-    
-    switch (itolQ) {
-    case IDA_SS:
-      status = IDAQuadSStolerances(ida_mem, reltolQ, SabstolQ);
-      if (status != IDA_SUCCESS) goto error_return;
-      break;
-    case IDA_SV:
-      NV_abstolQ = N_VClone(yQ);
-      PutData(NV_abstolQ, VabstolQ, Nq);
-      status = IDAQuadSVtolerances(ida_mem, reltolQ, NV_abstolQ);
-      if (status != IDA_SUCCESS) goto error_return;
-      N_VDestroy(NV_abstolQ);
-      break;
-    }
-    
-  }
-
-  /* Quadratures will be integrated */
-
-  quadr = TRUE;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-
-/* IDM_SensInitialization
- * action = 0 -> IDASensInit
- * action = 1 -> IDASensReInit
- *
- * prhs contains:
- *   Ns
- *   sensi_meth
- *   yS0
- *   options
- *
- * plhs contains:
- *   status
- *
- */
-
-static int IDM_SensInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  const mxArray *options;
-
-  booleantype fS_DQ;
-  IDASensResFn resS;
-
-  double *yyS0, *ypS0;
-
-  int ism;
-
-  mxArray *pfield;
-  char *pfield_name;
-
-  booleantype errconS;
-  int itolS;
-  realtype reltolS;
-  realtype *SabstolS, *VabstolS;
-  N_Vector *NV_abstolS;
-
-  int *plist, dqtype;
-  double *p, *pbar, rho;
-
-  int is, status;
-
-  p = NULL;
-  plist = NULL;
-  pbar = NULL;
-
-  fwdPb = idmData->fwdPb;
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* FSA INITIALIZATION */
-
-    /* Extract number of sensitivities */
-
-    Ns = (int)mxGetScalar(prhs[0]);
-
-    /* Extract user-provided sensitivity residual function */
-
-    if ( mxIsEmpty(prhs[1]) ) {
-      resS = NULL;
-      fS_DQ = TRUE;
-    } else {
-      mxDestroyArray(mtlb_SRESfct);
-      mtlb_SRESfct = mxDuplicateArray(prhs[1]);
-      resS = mxW_IDASensRes;
-      fS_DQ = FALSE;
-    }
-
-    /* Extract sensitivity initial conditions */
-
-    yyS0 = mxGetPr(prhs[2]);
-    ypS0 = mxGetPr(prhs[3]);
-
-    /* Create the sensitivity N_Vectors */
-
-    yyS = N_VCloneVectorArray(Ns, yy);
-    ypS = N_VCloneVectorArray(Ns, yy);
-
-    /* Load sensitivity initial conditions */
-
-    for (is=0;is<Ns;is++) {
-      PutData(yyS[is], &yyS0[is*N], N);
-      PutData(ypS[is], &ypS0[is*N], N);
-    }
-
-    /* Extract FSA options structure */
-
-    options = prhs[4];
-
-    break;
-
-  case 1:     /* FSA RE-INITIALIZATION */
-
-    /* Extract sensitivity initial condition */
-
-    yyS0 = mxGetPr(prhs[0]);
-    ypS0 = mxGetPr(prhs[1]);
-
-    if ( (mxGetM(prhs[0]) != N) || (mxGetN(prhs[0]) != Ns) ) {
-      idmErrHandler(-999, "IDAS", "IDASensReInit",
-                    "Size of yyS0 changed from IDASensInit call.", NULL);
-      goto error_return;
-    }
-
-    if ( (mxGetM(prhs[1]) != N) || (mxGetN(prhs[1]) != Ns) ) {
-      idmErrHandler(-999, "IDAS", "IDASensReInit",
-                    "Size of ypS0 changed from IDASensInit call.", NULL);
-      goto error_return;
-    }
-
-    /* Load sensitivity initial conditions */
-
-    for (is=0;is<Ns;is++) {
-      PutData(yyS[is], &yyS0[is*N], N);
-      PutData(ypS[is], &ypS0[is*N], N);
-    }
-
-    /* Extract qFSA options structure */
-
-    options = prhs[2];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_FSAOptions(options, fwdPb, 
-                          &ism,
-                          &pfield_name, &plist, &pbar,
-                          &dqtype, &rho,
-                          &errconS, &itolS, &reltolS, &SabstolS, &VabstolS);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate IDAS functions
-   *
-   * If action = 0
-   *    Check if required inputs are available
-   *    Initialize FSA
-   * If action = 1
-   *    Reinitialize FSA
-   * ----------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:
-
-    if (fS_DQ) {
-
-      if (pfield_name == NULL) {
-        idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit",
-                      "pfield required but was not provided.", NULL);
-        goto error_return;
-      }
-
-      pfield = mxGetField(mtlb_data,0,pfield_name);
-
-      if (pfield == NULL) {
-        idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit",
-                      "illegal pfield input.", NULL);
-        goto error_return;
-      }
-
-      p = mxGetPr(pfield);
-
-    }
-
-    status = IDASensInit(ida_mem, Ns, ism, resS, yyS, ypS);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  case 1:
-
-    status = IDASensReInit(ida_mem, ism, yyS, ypS);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances for sensitivity variables
-   * ----------------------------------------
-   */
-
-  switch (itolS) {
-  case IDA_SS:
-    status = IDASensSStolerances(ida_mem, reltolS, SabstolS);
-    if (status != IDA_SUCCESS) goto error_return;
-    break;
-  case IDA_SV:
-    NV_abstolS = N_VCloneVectorArray(Ns, yy);
-    for (is=0;is<Ns;is++)
-      PutData(NV_abstolS[is], &VabstolS[is*N], N);
-    status = IDASensSVtolerances(ida_mem, reltolS, NV_abstolS);
-    if (status != IDA_SUCCESS) goto error_return;
-    N_VDestroyVectorArray(NV_abstolS, Ns);
-    break;
-  case IDA_EE:
-    status = IDASensEEtolerances(ida_mem);
-    if (status != IDA_SUCCESS) goto error_return;
-    break;
-  }
-
-  /*
-   * --------------------------------
-   * Set various optional inputs
-   * --------------------------------
-   */
-  
-  status = IDASetSensParams(ida_mem, p, pbar, plist);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  status = IDASetSensDQMethod(ida_mem, dqtype, rho);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  status = IDASetSensErrCon(ida_mem, errconS);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  fsa = TRUE;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-/*
- * IDM_SensToggleOff
- *
- * deactivates FSA
- */
-
-static int IDM_SensToggleOff(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-  int status;
-
-  fwdPb = idmData->fwdPb;
-
-  status = IDASensToggleOff(ida_mem);
-  if (status != IDA_SUCCESS) {
-    status = -1;
-    plhs[0] = mxCreateDoubleScalar((double)status);
-    return(-1);
-  }
-
-  fsa = FALSE;
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-}
-
-
-/* IDM_AdjInitialization
- *
- * prhs contains:
- *
- * plhs contains:
- *   status
- */
-
-static int IDM_AdjInitialization(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  int interp;
-
-  int buflen, status;
-  char *bufval;
-
-  switch (action) {
-
-  case 0:
-
-    /* Number of steps */
-
-    Nd = (int)mxGetScalar(prhs[0]);
-
-    /* Interpolation method */
-
-    buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(prhs[1], bufval, buflen);
-    if(status != 0) {
-      idmErrHandler(-999, "IDAS", "IDAAdjInit", 
-                    "Could not parse InterpType.", NULL);
-      goto error_return;
-    }
-
-    if(!strcmp(bufval,"Hermite")) {
-      interp = IDA_HERMITE;
-    } else if(!strcmp(bufval,"Polynomial")) {
-      interp = IDA_POLYNOMIAL;
-    } else {
-      idmErrHandler(-999, "IDAS", "IDAAdjInit",
-                    "Interp. type has an illegal value.", NULL);
-      goto error_return;
-    }
-
-    status = IDAAdjInit(ida_mem, Nd, interp);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  case 1:
-
-    status = IDAAdjReInit(ida_mem);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  asa = TRUE;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-
-/* IDM_InitializationB
- *
- * action = 0   -> IDACreateB + IDAInitB
- * action = 1   -> IDAReInitB
- *
- * prhs contains:
- *   resB
- *   tF
- *   yyB0
- *   ypB0
- *   options
- *   data
- *
- * plhs contains:
- *   status
- *
- */
-static int IDM_InitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData bckPb;
-
-  const mxArray *options;
-
-  int idxB;
-
-  double tB0, *yyB0, *ypB0;
-
-  int maxordB;
-  long int mxstepsB;
-
-  int itolB;
-  realtype reltolB, SabstolB, *VabstolB;
-  N_Vector NV_abstolB;
-
-  double hinB, hmaxB;
-  double tstopB;            /* ignored */
-  booleantype errmsgB;      /* ignored */
-
-  booleantype suppressB;
-
-  long int mupperB, mlowerB;
-  int gstypeB, maxlB;
-  long int mudqB, mldqB;
-  double dqrelyB;
-
-  double *idB, *cnstrB;
-  N_Vector NV_idB;
-
-  booleantype res_s;
-
-  booleantype found_bck;
-
-  int status;
-  int i_status;
-
-
-  /* Set output containing status */
-
-  i_status = (action == 0) ? 1 : 0;
-
-  /* 
-   * -----------------------------
-   * Finalize Forward monitoring
-   * -----------------------------
-   */
-
-  if (idmData->fwdPb->Mon) {
-    mxW_IDAMonitor(2, 0.0, NULL, NULL, NULL, idmData->fwdPb);
-    idmData->fwdPb->Mon = FALSE;
-  }
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* BACKWARD SOLVER INITIALIZATION */
-
-    /* Create and initialize a new problem */
-
-    bckPb = (idmPbData) mxMalloc(sizeof(struct idmPbData_));
-    idmInitPbData(bckPb);
-
-    bckPb->next = idmData->bckPb;
-    idmData->bckPb = bckPb;
-
-    /* Extract user-provided RHS function */
-
-    mxDestroyArray(mtlb_RESfctB);
-    mtlb_RESfctB = mxDuplicateArray(prhs[0]);
-
-    /* Extract final time */
-
-    tB0 = (double)mxGetScalar(prhs[1]);
-
-    /* Extract final conditions */
-
-    yyB0 = mxGetPr(prhs[2]);
-    ypB0 = mxGetPr(prhs[3]);
-    NB = mxGetM(prhs[2]);
-
-    /* Create the solution N_Vectors */
-
-    yyB = NewVector(NB);
-    ypB = NewVector(NB);
-
-    /* Load final conditions */
-
-    PutData(yyB, yyB0, NB);
-    PutData(ypB, ypB0, NB);
-
-    /* Extract options structure */
-    
-    options = prhs[4];
-
-    break;
-
-  case 1:     /* BACKWARD SOLVER RE-INITIALIZATION */
-
-    /* Extract index of current backward problem */
-    
-    idxB = (int)mxGetScalar(prhs[0]);
-
-    /* Find current backward problem */
-
-    found_bck = FALSE;
-    bckPb = idmData->bckPb;
-    while (bckPb != NULL) {
-      if (indexB == idxB) {
-        found_bck = TRUE;
-        break;
-      }
-      bckPb = bckPb->next;
-    }
-
-    if (!found_bck) {
-      idmErrHandler(-999, "IDAS", "IDAReInitB",
-                    "idxB has an illegal value.", NULL);
-      goto error_return;
-    }
-
-    /* If backward monitoring was enabled, finalize it now. */
-
-    if (monB) mxW_IDAMonitorB(2, indexB, 0.0, NULL, NULL, bckPb);
-
-    /* Extract final time */
-
-    tB0 = (double)mxGetScalar(prhs[1]);
-
-    /* Extract final conditions */
-
-    yyB0 = mxGetPr(prhs[2]);
-
-    if (mxGetM(prhs[2]) != NB) {
-      idmErrHandler(-999, "IDAS", "IDAReInitB",
-                    "Size of yyB0 changed from IDAInitB call.", NULL);
-      goto error_return;
-    }
-
-    yyB0 = mxGetPr(prhs[3]);
-
-    if (mxGetM(prhs[3]) != NB) {
-      idmErrHandler(-999, "IDAS", "IDAReInitB",
-                    "Size of ypB0 changed from IDAInitB call.", NULL);
-      goto error_return;
-    }
-
-    /* Load final conditions */
-
-    PutData(yyB, yyB0, NB);
-    PutData(ypB, ypB0, NB);
-
-    /* Extract options structure */
-    
-    options = prhs[4];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_IntgrOptions(options, bckPb, FALSE,
-                            &maxordB, &mxstepsB,
-                            &itolB, &reltolB, &SabstolB, &VabstolB,
-                            &hinB, &hmaxB, &tstopB,
-                            &suppressB, &errmsgB,
-                            &idB, &cnstrB,
-                            &res_s);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate IDAS functions
-   *
-   * If action = 0
-   *    Create IDAS object and allocate memory
-   *    Initialize and allocate memory
-   * If action = 1
-   *    Reinitialize solver
-   * ----------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:
-
-    status = IDACreateB(ida_mem, &idxB);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASetUserDataB(ida_mem, idxB, bckPb);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    if (res_s) status = IDAInitBS(ida_mem, idxB, mxW_IDAResBS, tB0, yyB, ypB);
-    else       status = IDAInitB(ida_mem, idxB, mxW_IDAResB, tB0, yyB, ypB);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    /* Return idxB */
-
-    plhs[0] = mxCreateDoubleScalar((double)idxB);
-
-    indexB = idxB;
-
-    NbckPb++;
-
-    break;
-
-  case 1:
-
-    status = IDAReInitB(ida_mem, idxB, tB0, yyB, ypB);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances
-   * ----------------------------------------
-   */
-
-  switch (itolB) {
-  case IDA_SS:
-    status = IDASStolerancesB(ida_mem, idxB, reltolB, SabstolB);
-    if (status != IDA_SUCCESS) goto error_return;
-    break;
-  case IDA_SV:
-    NV_abstolB = N_VClone(yyB);
-    PutData(NV_abstolB, VabstolB, NB);
-    status = IDASVtolerancesB(ida_mem, idxB, reltolB, NV_abstolB);
-    if (status != IDA_SUCCESS) goto error_return;
-    N_VDestroy(NV_abstolB);
-    break;
-  }
-
-  /*
-   * --------------------------------
-   * Set various optional inputs
-   * --------------------------------
-   */
-
-  /* set maxorder (default is consistent with LMM) */
-  status = IDASetMaxOrdB(ida_mem, idxB, maxordB);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set initial step size (the default value of 0.0 is ignored by IDAS) */
-  status = IDASetInitStepB(ida_mem, idxB, hinB);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set max step (default is infinity) */
-  status = IDASetMaxStepB(ida_mem, idxB, hmaxB);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set number of max steps */
-  status = IDASetMaxNumStepsB(ida_mem, idxB, mxstepsB);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* set suppressAlg */
-  status = IDASetSuppressAlgB(ida_mem, idxB, suppressB);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* ID vector specified? */
-  if (idB != NULL) {
-    NV_idB = N_VClone(yyB);
-    PutData(NV_idB, idB, NB);
-    status = IDASetIdB(ida_mem, idxB, NV_idB);
-    if (status != IDA_SUCCESS) goto error_return;
-    N_VDestroy(NV_idB);
-  }
-
-  /*
-   * ----------------------------------------
-   * Linear solver
-   * ----------------------------------------
-   */
-
-  status = get_LinSolvOptions(options, bckPb, FALSE,
-                              &mupperB, &mlowerB,
-                              &mudqB, &mldqB, &dqrelyB,
-                              &gstypeB, &maxlB);
-  if (status != 0) goto error_return;
-
-  switch(lsB) {
-
-  case LS_DENSE:
-
-    status = IDADenseB(ida_mem, idxB, NB);
-    if (status != IDA_SUCCESS) goto error_return;
-    if (!mxIsEmpty(mtlb_JACfctB)) {
-      status = IDADlsSetDenseJacFnB(ida_mem, idxB, mxW_IDADenseJacB);
-      if (status != IDA_SUCCESS) goto error_return;
-    }
-
-    break;
-
-  case LS_BAND:
-
-    status = IDABandB(ida_mem, idxB, NB, mupperB, mlowerB);
-    if (status != IDA_SUCCESS) goto error_return;
-    if (!mxIsEmpty(mtlb_JACfctB)) {
-      status = IDADlsSetBandJacFnB(ida_mem, idxB, mxW_IDABandJacB);
-      if (status != IDA_SUCCESS) goto error_return;
-    }
-
-    break;
-
-  case LS_SPGMR:
-
-    status = IDASpgmrB(ida_mem, idxB, maxlB);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsSetGSTypeB(ida_mem, idxB, gstypeB);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  case LS_SPBCG:
-
-    status = IDASpbcgB(ida_mem, idxB, maxlB);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  case LS_SPTFQMR:
-
-    status = IDASptfqmrB(ida_mem, idxB, maxlB);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /* Jacobian * vector and preconditioner for SPILS linear solvers */
-
-  if ( (lsB==LS_SPGMR) || (lsB==LS_SPBCG) || (lsB==LS_SPTFQMR) ) {
-
-    if (!mxIsEmpty(mtlb_JACfctB)) {
-      status =IDASpilsSetJacTimesVecFnB(ida_mem, idxB, mxW_IDASpilsJacB);
-      if (status != IDA_SUCCESS) goto error_return;
-    }
-
-    switch (pmB) {
-
-    case PM_NONE:
-
-      if (!mxIsEmpty(mtlb_PSOLfctB)) {
-        if (!mxIsEmpty(mtlb_PSETfctB)) status = IDASpilsSetPreconditionerB(ida_mem, idxB, mxW_IDASpilsPsetB, mxW_IDASpilsPsolB);
-        else                           status =IDASpilsSetPreconditionerB(ida_mem, idxB, NULL, mxW_IDASpilsPsolB);
-      }
-      if (status != IDA_SUCCESS) goto error_return;
-
-      break;
-
-    case PM_BBDPRE:
-
-      if (!mxIsEmpty(mtlb_GCOMfctB)) status = IDABBDPrecInitB(ida_mem, idxB, NB, mudqB, mldqB, mupperB, mlowerB, dqrelyB, mxW_IDABBDglocB, mxW_IDABBDgcomB);
-      else                           status = IDABBDPrecInitB(ida_mem, idxB, NB, mudqB, mldqB, mupperB, mlowerB, dqrelyB, mxW_IDABBDglocB, NULL);
-      if (status != IDA_SUCCESS) goto error_return;
-
-      break;
-
-    }
-
-  }
-
-  /* Do we monitor? */
-
-  if (monB) mxW_IDAMonitorB(0, idxB, tB0, NULL, NULL, bckPb);
-
-  /* Successful return */
-
-  status = 0;
-  plhs[i_status] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[i_status] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-/* IDM_QuadInitializationB
- *
- * action = 0   -> IDAQuadInitB
- * prhs contains:
- *   idxB
- *   fQB
- *   yQB0
- *   options
- *
- * action = 1   -> IDAQuadReInitB
- *   idxB
- *   yQB0
- *   options
- *
- */
-
-static int IDM_QuadInitializationB(int action, int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData bckPb;
-
-  const mxArray *options;
-
-  int idxB;
-
-  double *yQB0;
-
-  booleantype rhs_s;
-  
-  booleantype errconQB;
-  int itolQB;
-  realtype reltolQB, SabstolQB, *VabstolQB;
-  N_Vector NV_abstolQB;
-
-  booleantype found_bck;
-
-  int status;
-
-  /* Extract index of current backward problem */
-    
-  idxB = (int)mxGetScalar(prhs[0]);
-
-  /* Find current backward problem */
-
-  found_bck = FALSE;
-  bckPb = idmData->bckPb;
-  while (bckPb != NULL) {
-    if (indexB == idxB) {
-      found_bck = TRUE;
-      break;
-    }
-    bckPb = bckPb->next;
-  }
-
-  if (!found_bck) {
-    idmErrHandler(-999, "IDAS", "IDAQuadInitB/IDAQuadReInitB",
-                  "idxB has an illegal value.", NULL);
-    goto error_return;
-  }
-
-  /* 
-   * ------------------------------------
-   * Process inputs based on action
-   * ------------------------------------
-   */
-
-  switch (action) {
-
-  case 0:     /* BACKWARD QUADRATURE INITIALIZATION */
-
-    /* Extract user-provided quadrature RHS function */
-
-    mxDestroyArray(mtlb_QUADfctB);
-    mtlb_QUADfctB = mxDuplicateArray(prhs[1]);
-
-    /* Extract quadrature final conditions */
-
-    yQB0 = mxGetPr(prhs[2]);
-    NqB = mxGetM(prhs[2]);
-
-    /* Create the backward quadrature N_Vector */
-
-    yQB = NewVector(NqB);
-
-    /* Load quadrature final conditions */
-
-    PutData(yQB, yQB0, NqB);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[3];
-
-    break;
-
-  case 1:     /* BACKWARD QUADRATURE RE-INITIALIZATION */
-
-
-    /* Extract quadrature final conditions */
-
-    yQB0 = mxGetPr(prhs[1]);
-
-    if (mxGetM(prhs[1]) != NqB) {
-      idmErrHandler(-999, "IDAS", "IDAQuadReInitB",
-                    "Size of yQB0 changed from IDAQuadInitB call.", NULL);
-      goto error_return;
-    }
-
-    /* Load quadrature final conditions */
-
-    PutData(yQB, yQB0, NqB);
-
-    /* Extract quadrature options structure */
-
-    options = prhs[2];
-
-    break;
-
-  }
-
-  /* Process the options structure */
-
-  status = get_QuadOptions(options, bckPb, FALSE,
-                           NqB, &rhs_s,
-                           &errconQB, 
-                           &itolQB, &reltolQB, &SabstolQB, &VabstolQB);
-  if (status != 0) goto error_return;
-
-  /* 
-   * ----------------------------------------
-   * Call appropriate IDAS functions
-   *
-   * If action = 0
-   *    Initialize backward quadratures
-   * If action = 1
-   *    Reinitialize backward quadratures
-   * ----------------------------------------
-   */
-
-  switch (action) {
-  case 0:
-    if (rhs_s) status = IDAQuadInitBS(ida_mem, idxB, mxW_IDAQuadFctBS, yQB);
-    else       status = IDAQuadInitB(ida_mem, idxB, mxW_IDAQuadFctB, yQB);
-    if (status != IDA_SUCCESS) goto error_return;
-    break;
-  case 1:
-    status = IDAQuadReInitB(ida_mem, idxB, yQB);
-    if (status != IDA_SUCCESS) goto error_return;
-    break;
-  }
-
-  /*
-   * ----------------------------------------
-   * Set tolerances for quadrature variables
-   * ----------------------------------------
-   */
-  
-  status = IDASetQuadErrConB(ida_mem, idxB, errconQB);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  if (errconQB) {
-
-    switch (itolQB) {
-    case IDA_SS:
-      status = IDAQuadSStolerancesB(ida_mem, idxB, reltolQB, SabstolQB);
-      if (status != IDA_SUCCESS) goto error_return;
-      break;
-    case IDA_SV:
-      NV_abstolQB = N_VClone(yQB);
-      PutData(NV_abstolQB, VabstolQB, NqB);
-      status = IDAQuadSVtolerancesB(ida_mem, idxB, reltolQB, NV_abstolQB);
-      if (status != IDA_SUCCESS) goto error_return;
-      N_VDestroy(NV_abstolQB);
-      break;
-    }
-    
-  }
-
-  quadrB = TRUE;
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int IDM_CalcIC(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  double tout;
-  int buflen, icopt;
-  char *bufval;
-
-  int status;
-
-  fwdPb = idmData->fwdPb;
-
-  /* Extract tout */
-  tout = (double) mxGetScalar(prhs[0]);
-
-  /* Extract icopt */
-  icopt = -1;
-  buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-  bufval = mxCalloc(buflen, sizeof(char));
-  status = mxGetString(prhs[1], bufval, buflen);
-  if(!strcmp(bufval,"FindAlgebraic")) {
-    icopt = IDA_YA_YDP_INIT;
-  } else if(!strcmp(bufval,"FindAll"))  {
-    icopt = IDA_Y_INIT;
-  } else {
-    idmErrHandler(-999, "IDAS", "IDACalcIC",
-                  "icopt has an illegal value.", NULL);
-    goto error_return;
-  }  
-
-  /* Call IDACalcIC */
-  status = IDACalcIC(ida_mem, icopt, tout);
-  if (status < 0) goto error_return;
-
-  /* IDACalcIC return flag */
-  plhs[0] = mxCreateDoubleScalar((double)status);
-
-  if (nlhs == 1) return(0);
-
-  /* Extract and return corrected IC */
-  status = IDAGetConsistentIC(ida_mem, yy, yp);
-  if (status != IDA_SUCCESS) goto error_return;
-  plhs[1] = mxCreateDoubleMatrix(N,1,mxREAL);
-  GetData(yy, mxGetPr(plhs[1]), N);
-  plhs[2] = mxCreateDoubleMatrix(N,1,mxREAL);
-  GetData(yp, mxGetPr(plhs[2]), N);
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  if (nlhs > 1) {
-    plhs[1] = mxCreateDoubleScalar((double)status);
-    plhs[2] = mxCreateDoubleScalar((double)status);
-  }
-  return(-1);
-
-}
-
-static int IDM_CalcICB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  return(0);
-}
-
-static int IDM_Solve(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  int buflen;
-  char *bufval;
-
-  int nlhs_needed, dims[3];
-
-  int itask, is, Ntout, itout, s_idx;
-  double *tout, tret, h;
-  double *tdata, *yydata, *yQdata, *yySdata;
-  long int nst;
-
-  int status, ida_status;
-
-
-  fwdPb = idmData->fwdPb;
-
-  /* Set index of output corresponding to FSA */
-
-  if (fsa) {
-    s_idx = quadr ? 4 : 3;
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Verify if number of output arguments agrees with current options
-   * ----------------------------------------------------------------
-   */
-
-  nlhs_needed = 3;
-
-  if (quadr) nlhs_needed++;
-  if (fsa)   nlhs_needed++;
-
-  if (nlhs < nlhs_needed) {
-    idmErrHandler(-999, "IDAS", "IDASolve",
-                  "Too few output arguments.", NULL);
-    goto error_return;
-  }
-
-  if (nlhs > nlhs_needed) {
-    idmErrHandler(-999, "IDAS", "IDASolve",
-                  "Too many output arguments.", NULL);
-    goto error_return;
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Extract input arguments
-   * ----------------------------------------------------------------
-   */
-
-  /* Extract tout */
-
-  Ntout = mxGetM(prhs[0]) * mxGetN(prhs[0]);
-  tout = mxGetPr(prhs[0]);
-
-  /* If rootfinding or tstop are enabled, we do not allow multiple output times */
-
-  if (rootSet && (Ntout>1)) {
-    idmErrHandler(-999, "IDAS", "IDASolve",
-                  "More than one tout value prohibited with rootfinding enabled.", NULL);
-    goto error_return;
-  }
-
-  if (tstopSet && (Ntout>1)) {
-    idmErrHandler(-999, "IDAS", "IDASolve",
-                  "More than one tout value prohibited with tstop enabled.", NULL);
-    goto error_return;
-  }
-
-  /* Extract itask */
-
-  buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-  bufval = mxCalloc(buflen, sizeof(char));
-  status = mxGetString(prhs[1], bufval, buflen);
-  if(!strcmp(bufval,"Normal")) {
-    itask = IDA_NORMAL;
-  } else if(!strcmp(bufval,"OneStep")) {
-    itask = IDA_ONE_STEP;
-  } else {
-    idmErrHandler(-999, "IDAS", "IDASolve",
-                  "Illegal value for itask.", NULL); 
-    goto error_return;
-  }
-
-
-  if (itask == IDA_ONE_STEP) {
-
-    /* If itask==IDA_ONE_STEP, we do not allow multiple output times and we do not monitor */
-
-    if (Ntout>1) {
-      idmErrHandler(-999, "IDAS", "IDASolve",
-                    "More than one tout value prohibited in ONE_STEP mode.", NULL); 
-      goto error_return;
-    }
-
-    if (mon) {
-      idmErrHandler(+999, "IDAS", "IDASolve",
-                    "Monitoring disabled in ONE_STEP mode.", NULL);
-      mon = FALSE;
-    }
-
-  } else {
-
-    /* Check if tout values are legal */
-
-    status = IDAGetCurrentTime(ida_mem, &tret);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDAGetNumSteps(ida_mem, &nst);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    /* h is used throughout this function as integration direction only */
-    if (nst == 0) {
-      h = tout[0] - tret;
-    } else {
-      IDAGetLastStep(ida_mem, &h);
-      if ( (tout[0] - tret + h)*h < 0.0 ) {
-        idmErrHandler(-999, "IDAS", "IDASolve",
-                      "Illegal value of tout.", NULL);
-        goto error_return;
-      }
-    }
-    
-    for (itout=1; itout<Ntout; itout++) 
-      if ( (tout[itout] - tout[itout-1])*h < 0.0 ) {
-        idmErrHandler(-999, "IDAS", "IDASolve",
-                      "tout values are not monotonic.", NULL);
-        goto error_return;
-      }
-
-  }
-
-
-  /*
-   * ----------------------------------------------------------------
-   * Prepare the output arrays
-   * ----------------------------------------------------------------
-   */
-
-  /* Return time(s) */
-
-  plhs[1] = mxCreateDoubleMatrix(1,Ntout,mxREAL);
-  tdata = mxGetPr(plhs[1]);
-
-  /* Solution vector(s) */
-
-  plhs[2] = mxCreateDoubleMatrix(N,Ntout,mxREAL);
-  yydata = mxGetPr(plhs[2]);
-
-  /* Quadrature vector(s) */
-
-  if (quadr) {
-    plhs[3] = mxCreateDoubleMatrix(Nq,Ntout,mxREAL);
-    yQdata = mxGetPr(plhs[3]);
-  }
-
-  /* Sensitivity vectors */
-
-  if (fsa) {
-    dims[0] = N;
-    dims[1] = Ns;
-    dims[2] = Ntout;
-    plhs[s_idx] = mxCreateNumericArray(3, dims, mxDOUBLE_CLASS, mxREAL);
-    yySdata = mxGetPr(plhs[s_idx]);
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Call the IDAS main solver function
-   * ----------------------------------------------------------------
-   */
-
-  if (!mon) {
-
-    /* No monitoring. itask can be either IDA_ONE_STEP or IDA_NORMAL */
-
-    for (itout=0; itout<Ntout; itout++) {
-
-      if (!asa) ida_status = IDASolve(ida_mem, tout[itout], &tret, yy, yp, itask);
-      else      ida_status = IDASolveF(ida_mem, tout[itout], &tret, yy, yp, itask, &Nc);
-      if (ida_status < 0) goto error_return;
-
-      tdata[itout] = tret;
-
-      GetData(yy, &yydata[itout*N], N);
-
-      if (quadr) {
-        status = IDAGetQuad(ida_mem, &tret, yQ);
-        if (status != IDA_SUCCESS) goto error_return;
-        GetData(yQ, &yQdata[itout*Nq], Nq);
-      }
-
-      if (fsa) {
-        status = IDAGetSens(ida_mem, &tret, yyS);
-        if (status != IDA_SUCCESS) goto error_return;
-        for (is=0; is<Ns; is++)
-          GetData(yyS[is], &yySdata[itout*Ns*N+is*N], N);
-      }
-
-    }
-
-  } else {
-
-    /* Monitoring. itask = IDA_NORMAL */
-
-    for (itout=0; itout<Ntout; itout++) {
-      
-      /* In ONE_STEP mode, IDAS reads tout only at the first step.
-       * We must therefore check here whether we need to take additional steps,
-       * or simply return interpolated solution at tout. */
-
-      status = IDAGetNumSteps(ida_mem, &nst);
-      if (status != IDA_SUCCESS) goto error_return;
-      status = IDAGetCurrentTime(ida_mem, &tret);
-      if (status != IDA_SUCCESS) goto error_return;
-
-      if ( (nst>0) && ((tret - tout[itout])*h >= 0.0) ) {
-
-        /* No need to take an additional step */
-        ida_status = IDA_SUCCESS;
-
-      } else {
-
-        /* Take additional steps */
-        while(1) {
-
-          if (!asa) ida_status = IDASolve(ida_mem, tout[itout], &tret, yy, yp, IDA_ONE_STEP);
-          else      ida_status = IDASolveF(ida_mem, tout[itout], &tret, yy, yp, IDA_ONE_STEP, &Nc);
-          if (ida_status < 0) goto error_return;
-
-          /* Call the monitoring function */
-
-          if (quadr) {
-            status = IDAGetQuad(ida_mem, &tret, yQ);
-            if (status != IDA_SUCCESS) goto error_return;
-          }
-
-          if (fsa) {
-            status = IDAGetSens(ida_mem, &tret, yyS);
-            if (status != IDA_SUCCESS) goto error_return;
-          }
-
-          mxW_IDAMonitor(1, tret, yy, yQ, yyS, fwdPb);
-
-          /* If a root was found or tstop was reached, break out of while loop */
-          if (ida_status == IDA_TSTOP_RETURN || ida_status == IDA_ROOT_RETURN) break;
-
-          /* If current tout was reached break out of while loop */
-          if ( (tret - tout[itout])*h >= 0.0 )  break;
-
-        }
-
-      }
-      
-      /* On a tstop or root return, return solution at tret.
-       * Otherwise (ida_status=IDA_SUCCESS), return solution at tout[itout]. */
-
-      if (ida_status == IDA_TSTOP_RETURN || ida_status == IDA_ROOT_RETURN) {
-
-        if (quadr) {
-          status = IDAGetQuad(ida_mem, &tret, yQ);
-          if (status != IDA_SUCCESS) goto error_return;
-        }
-
-        if (fsa) {
-          status = IDAGetSens(ida_mem, &tret, yyS);
-          if (status != IDA_SUCCESS) goto error_return;
-        }
-
-      } else {
-
-        tret = tout[itout];
-        
-        status = IDAGetDky(ida_mem, tret, 0, yy);
-        if (status != IDA_SUCCESS) goto error_return;
-
-        if (quadr) {
-          status = IDAGetQuadDky(ida_mem, tret, 0, yQ);
-          if (status != IDA_SUCCESS) goto error_return;
-        }
-
-        if (fsa) {
-          status = IDAGetSensDky(ida_mem, tret, 0, yyS);
-          if (status != IDA_SUCCESS) goto error_return;
-        }
-
-      }
-
-      tdata[itout] = tret;
-
-      GetData(yy, &yydata[itout*N], N);
-
-      if (quadr)  {
-        GetData(yQ, &yQdata[itout*Nq], Nq);
-      }
-
-      if (fsa) {
-        for (is=0; is<Ns; is++) {
-          GetData(yyS[is], &yySdata[itout*Ns*N+is*N], N);
-        }
-      }
-
-    }
-
-  }
-
-  /* IDASolve return flag (only non-negative values make it here) */
-
-  plhs[0] = mxCreateDoubleScalar((double)ida_status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadr) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  if (fsa) {
-    s_idx = quadr ? 4 : 3;
-    plhs[s_idx] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  return(-1);
-
-}
-
-
-static int IDM_SolveB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData bckPb;
-
-  int buflen;
-  char *bufval;
-
-  int nlhs_bad;
-
-  int itaskB, NtoutB;
-  double *toutB;
-
-  double tret, h;
-
-  booleantype any_quadrB, any_monB;
-
-  int status, ida_status;
-
-  /*
-   * -------------------------------------------------------
-   * Check whether quadratures and/or monitoring are enabled
-   * for at least one backward problem
-   * -------------------------------------------------------
-   */
-
-  any_quadrB = FALSE;
-  any_monB   = FALSE;
-  bckPb = idmData->bckPb;
-  while(bckPb != NULL) {
-    if (quadrB) any_quadrB = TRUE;
-    if (monB)   any_monB   = TRUE;
-    bckPb = bckPb->next;
-  }
-  
-  /*
-   * ----------------------------------------------------------------
-   * Verify if number of output arguments agrees with current options
-   * ----------------------------------------------------------------
-   */
-
-  nlhs_bad = 0;
-
-  if (nlhs < 3) nlhs_bad = -1;
-  if (nlhs > 4) nlhs_bad = 1;
-  if ( (nlhs == 3) && any_quadrB ) nlhs_bad = -1;
-
-  if (nlhs_bad < 0) {
-    idmErrHandler(-999, "IDAS", "IDASolveB",
-                  "Too few output arguments.", NULL);
-    goto error_return;
-  }
-
-  if (nlhs_bad > 0) {
-    idmErrHandler(-999, "IDAS", "IDASolveB",
-                  "Too many output arguments.", NULL);
-    goto error_return;
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Extract input arguments
-   * ----------------------------------------------------------------
-   */
-
-  /* Extract tout */
-
-  NtoutB = mxGetM(prhs[0]) * mxGetN(prhs[0]);
-  toutB = mxGetPr(prhs[0]);
-
-  /* Check if first tout value is in the right direction */
-
-  status = IDAGetLastStep(ida_mem, &h);
-  if (status != IDA_SUCCESS) goto error_return;
-  status = IDAGetCurrentTime(ida_mem, &tret);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* The stepsize of the forward problem is used to indicate the integration direction */
-  if ( (tret - toutB[0])*h < 0.0 ) {
-    idmErrHandler(-999, "IDAS", "IDASolveB",
-                  "tout value in wrong direction.", NULL);
-    goto error_return;
-  }
-
-  /* Extract itaskB */
-
-  buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-  bufval = mxCalloc(buflen, sizeof(char));
-  status = mxGetString(prhs[1], bufval, buflen);
-  if(!strcmp(bufval,"Normal")) {
-    itaskB = IDA_NORMAL;
-  } else if(!strcmp(bufval,"OneStep")) {
-    itaskB = IDA_ONE_STEP;
-  } else {
-    idmErrHandler(-999, "IDAS", "IDASolveB",
-                     "Illegal value for itask.", NULL); 
-    goto error_return;
-  }
-
-  /* If itask == IDA_ONE_STEP, then
-   * - we do not allow multiple output times
-   * - we disable monitoring 
-   */
-
-  if ( itaskB == IDA_ONE_STEP ) {
-    
-    if (NtoutB > 1) {
-      idmErrHandler(-999, "IDAS", "IDASolveB",
-                    "More than one tout value prohibited in ONE_STEP mode.", NULL); 
-      goto error_return;
-    }
-
-    if (any_monB) {
-      idmErrHandler(+999, "IDAS", "IDASolveB",
-                    "Monitoring disabled in itask=ONE_STEP", NULL);
-      bckPb = idmData->bckPb;
-      while(bckPb != NULL) {
-        monB = FALSE;
-        bckPb = bckPb->next;
-      }
-      any_monB = FALSE;
-    }
-
-  }
-
-  /* Call the appropriate function to do all the work.
-   * Note: if we made it here, we rely on the functions idmSolveB_one and idmSolveB_more
-   *       to set the output arrays in plhs appropriately. */
-
-  if (NbckPb == 1) ida_status = idmSolveB_one(plhs, NtoutB, toutB, itaskB);
-  else             ida_status = idmSolveB_more(plhs, NtoutB, toutB, itaskB, any_quadrB, any_monB);
-
-  if (ida_status < 0) return(-1);
-  else                return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  return(-1);
-
-}
-
-static int idmSolveB_one(mxArray *plhs[], int NtoutB, double *toutB, int itaskB)
-{
-  idmPbData bckPb;
-  
-  void *ida_memB;
-
-  double tretB, hB;
-  double *tdata, *ydata, *yQdata;
-  int itout;
-  long int nstB;
-
-  int status, ida_status;
-
-  bckPb = idmData->bckPb;
-
-  ida_memB = IDAGetAdjIDABmem(ida_mem, indexB);
-
-  /* Check if tout values are legal */
-
-  status = IDAGetCurrentTime(ida_memB, &tretB);
-  if (status != IDA_SUCCESS) goto error_return;
-  status = IDAGetNumSteps(ida_memB, &nstB);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  /* hB is used throughout this function as integration direction only */
-  if (nstB == 0) {
-    hB = toutB[0] - tretB;
-  } else {
-    status = IDAGetLastStep(ida_memB, &hB);
-    if (status != IDA_SUCCESS) goto error_return;
-    if ( (toutB[0] - tretB + hB)*hB < 0.0 ) {
-      idmErrHandler(-999, "IDAS", "IDASolveB",
-                    "Illegal value of tout.", NULL);
-      goto error_return;
-    }
-  }
-
-  for (itout=1; itout<NtoutB; itout++) {
-    if ( (toutB[itout] - toutB[itout-1])*hB < 0.0 ) {
-      idmErrHandler(-999, "IDAS", "IDASolveB",
-                    "tout values are not monotonic.", NULL);
-      goto error_return;
-    }
-  }
-
-  /*
-   * ----------------------------------------------------------------
-   * Prepare the output arrays
-   * ----------------------------------------------------------------
-   */
-
-  /* Return time(s) */
-
-  plhs[1] = mxCreateDoubleMatrix(1,NtoutB,mxREAL);
-  tdata = mxGetPr(plhs[1]);
-  
-  /* Solution vector(s) */
-  
-  plhs[2] = mxCreateDoubleMatrix(NB,NtoutB,mxREAL);
-  ydata = mxGetPr(plhs[2]);
-  
-  /* Quadrature vector(s) */
-  
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(NqB,NtoutB,mxREAL);
-    yQdata = mxGetPr(plhs[3]);
-  }
-  
-  /*
-   * ----------------------------------------------------------------
-   * Call the IDASolveB main solver function
-   * ----------------------------------------------------------------
-   */
-
-  if (!monB) {
-
-    /* No monitoring. itaskB can be either IDA_ONE_STEP or IDA_NORMAL */
-
-    for (itout=0; itout<NtoutB; itout++) {
-      
-      ida_status = IDASolveB(ida_mem, toutB[itout], itaskB);
-      if (ida_status < 0) goto error_return;
-
-      status = IDAGetB(ida_mem, indexB, &tretB, yyB, ypB);
-      if (status != IDA_SUCCESS) goto error_return;
-   
-      tdata[itout] = tretB;
-      
-      GetData(yyB, &ydata[itout*NB], NB);
-      
-      if (quadrB) {
-        status = IDAGetQuadB(ida_mem, indexB, &tretB, yQB);
-
-        if (status != IDA_SUCCESS) goto error_return;
-        GetData(yQB, &yQdata[itout*NqB], NqB);
-      }
-      
-    }
-    
-    
-  } else {
-
-    /* Monitoring. itask = IDA_NORMAL */
-
-    for (itout=0; itout<NtoutB; itout++) {
-
-      /* In ONE_STEP mode, IDAS reads tout only at the first step.
-       * We must therefore check here whether we need to take additional steps,
-       * or simply return interpolated solution at tout. */
-
-      status = IDAGetNumSteps(ida_memB, &nstB);
-      if (status != IDA_SUCCESS) goto error_return;
-      status = IDAGetCurrentTime(ida_memB, &tretB);
-      if (status != IDA_SUCCESS) goto error_return;
-
-      if ( (nstB>0) && ((tretB - toutB[itout])*hB >= 0.0) ) {
-
-        /* No need to take an additional step */
-        ida_status = IDA_SUCCESS;
-
-      } else {
-
-        /* Take additional steps */
-        while(1) {
-        
-          ida_status = IDASolveB(ida_mem, toutB[itout], IDA_ONE_STEP);
-          if (ida_status < 0) goto error_return;  
-
-          /* Call the monitoring function */          
-          status = IDAGetB(ida_mem, indexB, &tretB, yyB, ypB);
-          if (status != IDA_SUCCESS) goto error_return;
-          if (quadrB) {
-            status = IDAGetQuadB(ida_mem, indexB, &tretB, yQB);
-            if (status != IDA_SUCCESS) goto error_return;
-          }
-          mxW_IDAMonitorB(1, indexB, tretB, yyB, yQB, bckPb);
-          
-          /* If current tout was reached break out of while loop */
-          if ( (tretB - toutB[itout])*hB >= 0.0 ) break;
-          
-        }
-
-      }
-
-      tretB = toutB[itout];
-
-      tdata[itout] = tretB;
-
-      status = IDAGetDky(ida_memB, tretB, 0, yyB);
-      if (status != IDA_SUCCESS) goto error_return;
-
-      GetData(yyB, &ydata[itout*NB], NB);
-      
-      if (quadrB) {
-        status = IDAGetQuadDky(ida_memB, tretB, 0, yQB);
-        if (status != IDA_SUCCESS) goto error_return;
-        GetData(yQB, &yQdata[itout*NqB], NqB);
-      }
-
-    }
-
-  }
-
-  /* IDASolve return flag (only non-negative values make it here) */
-
-  plhs[0] = mxCreateDoubleScalar((double)ida_status);
-  return(0);
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  return(-1);
-
-}
-
-
-static int idmSolveB_more(mxArray *plhs[], int NtoutB, double *toutB, int itaskB,
-                          booleantype any_quadrB, booleantype any_monB)
-{
-  idmPbData bckPb;
-  mxArray *cell;
-  int status, ida_status;
-
-  idmErrHandler(-999, "IDAS", "IDASolveB",
-                "Integration of multiple backward problems is not yet implemented.", NULL);
-  goto error_return;
-
-  plhs[0] = mxCreateDoubleScalar((double)ida_status);
-  return(0);
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  /*
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  plhs[2] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (quadrB) {
-    plhs[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  */
-  return(-1);
-
-}
-
-
-static int IDM_Stats(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  const char *fnames_intgr[]={
-    "nst",
-    "nfe",
-    "nge",
-    "nsetups",
-    "netf",
-    "nni",
-    "ncfn",
-    "qlast",
-    "qcur",
-    "h0used",
-    "hlast",
-    "hcur",
-    "tcur",
-    "RootInfo",
-    "QuadInfo",
-    "LSInfo",
-    "FSAInfo"
-  };
-  const char *fnames_root[]={
-    "nge",
-    "roots"
-  };
-  const char *fnames_dense[]={
-    "name",
-    "njeD",
-    "nfeD"
-  };
-  const char *fnames_band[]={
-    "name",
-    "njeB",
-    "nfeB"
-  };
-  const char *fnames_spils[]={
-    "name",
-    "nli",
-    "npe",
-    "nps",
-    "ncfl",
-    "njeSG",
-    "nfeSG"
-  };
-  const char *fnames_quad[]={
-    "nfQe",
-    "netfQ"
-  };
-  const char *fnames_sens[]={
-    "nrSe",
-    "nfeS",
-    "nsetupsS",
-    "netfS",
-    "nniS",
-    "ncfnS",
-  };
-
-  long int nst, nfe, nsetups, nni, ncfn, netf, nge;
-  int qlast, qcur;
-  double h0used, hlast, hcur, tcur;
-  int *rootsfound;
-
-  long int njeD, nfeD;
-  long int njeB, nfeB;
-  long int nli, npe, nps, ncfl, njeSG, nfeSG;
-
-  long int nfQe, netfQ;
-
-  long int nrSe, nfeS, netfS, nsetupsS;
-  long int nniS, ncfnS;
-
-  int i, status;
-  mxArray *mxS_root, *mxS_ls, *mxS_quad, *mxS_fsa;
-  mxArray *mxS_rootsfound;
-  double *tmp;
-  int nfields;
-
-  if (idmData == NULL) return(0);
-
-  fwdPb = idmData->fwdPb;
-
-  status = IDAGetIntegratorStats(ida_mem, &nst, &nfe, &nsetups, 
-                               &netf, &qlast, &qcur, &h0used, &hlast, &hcur, &tcur);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  status = IDAGetNonlinSolvStats(ida_mem, &nni, &ncfn);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  nfields = sizeof(fnames_intgr)/sizeof(*fnames_intgr);
-  plhs[0] = mxCreateStructMatrix(1, 1, nfields, fnames_intgr);
- 
-  mxSetField(plhs[0], 0, "nst",     mxCreateDoubleScalar((double)nst));
-  mxSetField(plhs[0], 0, "nfe",     mxCreateDoubleScalar((double)nfe));
-  mxSetField(plhs[0], 0, "nsetups", mxCreateDoubleScalar((double)nsetups));
-  mxSetField(plhs[0], 0, "netf",    mxCreateDoubleScalar((double)netf));
-  mxSetField(plhs[0], 0, "nni",     mxCreateDoubleScalar((double)nni));
-  mxSetField(plhs[0], 0, "ncfn",    mxCreateDoubleScalar((double)ncfn));
-  mxSetField(plhs[0], 0, "qlast",   mxCreateDoubleScalar((double)qlast));
-  mxSetField(plhs[0], 0, "qcur",    mxCreateDoubleScalar((double)qcur));
-  mxSetField(plhs[0], 0, "h0used",  mxCreateDoubleScalar(h0used));
-  mxSetField(plhs[0], 0, "hlast",   mxCreateDoubleScalar(hlast));
-  mxSetField(plhs[0], 0, "hcur",    mxCreateDoubleScalar(hcur));
-  mxSetField(plhs[0], 0, "tcur",    mxCreateDoubleScalar(tcur));
-
-
-  /* Root Finding Statistics */
-
-  if (Ng > 0) {
-
-    status = IDAGetNumGEvals(ida_mem, &nge);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_root)/sizeof(*fnames_root);
-    mxS_root = mxCreateStructMatrix(1, 1, nfields, fnames_root);
-
-    mxSetField(mxS_root, 0, "nge", mxCreateDoubleScalar((double)nge));
-
-    rootsfound = (int *) malloc(Ng*sizeof(int));
-    status = IDAGetRootInfo(ida_mem, rootsfound);
-    if (status != IDA_SUCCESS) goto error_return;
-    mxS_rootsfound = mxCreateDoubleMatrix(Ng,1,mxREAL);
-    tmp = mxGetPr(mxS_rootsfound);
-    for (i=0;i<Ng;i++)
-      tmp[i] = (double)rootsfound[i];
-    mxSetField(mxS_root, 0, "roots", mxS_rootsfound);
-    free(rootsfound);
-
-  } else {
-
-    mxS_root = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "RootInfo", mxS_root);
-
-  /* Quadrature Statistics */
-
-  if (quadr) {
-
-    status = IDAGetQuadStats(ida_mem, &nfQe, &netfQ);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_quad)/sizeof(*fnames_quad);
-    mxS_quad = mxCreateStructMatrix(1, 1, nfields, fnames_quad);
-
-    mxSetField(mxS_quad, 0, "nfQe",  mxCreateDoubleScalar((double)nfQe));
-    mxSetField(mxS_quad, 0, "netfQ", mxCreateDoubleScalar((double)netfQ));
-
-  } else {
-
-    mxS_quad = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "QuadInfo", mxS_quad);
-
-  /* Linear Solver Statistics */
-
-  switch(ls){
-
-  case LS_DENSE:
-    
-    status = IDADlsGetNumJacEvals(ida_mem, &njeD);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDADlsGetNumResEvals(ida_mem, &nfeD);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_dense)/sizeof(*fnames_dense);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_dense);
-    
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Dense"));
-    mxSetField(mxS_ls, 0, "njeD", mxCreateDoubleScalar((double)njeD));
-    mxSetField(mxS_ls, 0, "nfeD", mxCreateDoubleScalar((double)nfeD));
-    
-    break;
-
-  case LS_BAND:
-      
-    status = IDADlsGetNumJacEvals(ida_mem, &njeB);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDADlsGetNumResEvals(ida_mem, &nfeB);
-    if (status != IDA_SUCCESS) goto error_return;
-  
-    nfields = sizeof(fnames_band)/sizeof(*fnames_band);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_band);
- 
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Band"));
-    mxSetField(mxS_ls, 0, "njeB", mxCreateDoubleScalar((double)njeB));
-    mxSetField(mxS_ls, 0, "nfeB", mxCreateDoubleScalar((double)nfeB));
-      
-    break;
-
-  case LS_SPGMR:
-  case LS_SPBCG:
-  case LS_SPTFQMR:
-
-    status = IDASpilsGetNumLinIters(ida_mem, &nli);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumPrecEvals(ida_mem, &npe);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumPrecSolves(ida_mem, &nps);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumConvFails(ida_mem, &ncfl);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumJtimesEvals(ida_mem, &njeSG);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumResEvals(ida_mem, &nfeSG);
-    if (status != IDA_SUCCESS) goto error_return;
-    
-    nfields = sizeof(fnames_spils)/sizeof(*fnames_spils);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_spils);
-    
-    if (ls == LS_SPGMR)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("GMRES"));
-    else if (ls == LS_SPBCG)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("BiCGStab"));
-    else
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("TFQMR"));
-
-    mxSetField(mxS_ls, 0, "nli",   mxCreateDoubleScalar((double)nli));
-    mxSetField(mxS_ls, 0, "npe",   mxCreateDoubleScalar((double)npe));
-    mxSetField(mxS_ls, 0, "nps",   mxCreateDoubleScalar((double)nps));
-    mxSetField(mxS_ls, 0, "ncfl",  mxCreateDoubleScalar((double)ncfl));
-    mxSetField(mxS_ls, 0, "njeSG", mxCreateDoubleScalar((double)njeSG));
-    mxSetField(mxS_ls, 0, "nfeSG", mxCreateDoubleScalar((double)nfeSG));
-    
-    break;
-    
-  }
-
-  mxSetField(plhs[0], 0, "LSInfo", mxS_ls);
-
-  /* Forward Sensitivity Statistics */
-
-  if (fsa) {
-
-    status = IDAGetSensStats(ida_mem, &nrSe, &nfeS, &netfS, &nsetupsS); 
-    if (status != IDA_SUCCESS) goto error_return;
-
-    status = IDAGetSensNonlinSolvStats(ida_mem, &nniS, &ncfnS);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_sens)/sizeof(*fnames_sens);
-    mxS_fsa = mxCreateStructMatrix(1, 1, nfields, fnames_sens);
-    
-    mxSetField(mxS_fsa, 0, "nrSe",     mxCreateDoubleScalar((double)nrSe));
-    mxSetField(mxS_fsa, 0, "nfeS",     mxCreateDoubleScalar((double)nfeS));
-    mxSetField(mxS_fsa, 0, "nsetupsS", mxCreateDoubleScalar((double)nsetupsS));
-    mxSetField(mxS_fsa, 0, "netfS",    mxCreateDoubleScalar((double)netfS));
-    mxSetField(mxS_fsa, 0, "nniS",     mxCreateDoubleScalar((double)nniS));
-    mxSetField(mxS_fsa, 0, "ncfnS",    mxCreateDoubleScalar((double)ncfnS));
-    
-  } else {
-
-    mxS_fsa = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "FSAInfo", mxS_fsa);
-
-  /* Successful return */
-
-  status = 0;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int IDM_StatsB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData bckPb;
-  int idxB;
-
-  const char *fnames_intgr[]={
-    "nst",
-    "nfe",
-    "nge",
-    "nsetups",
-    "netf",
-    "nni",
-    "ncfn",
-    "qlast",
-    "qcur",
-    "h0used",
-    "hlast",
-    "hcur",
-    "tcur",
-    "QuadInfo",
-    "LSInfo",
-  };
-  const char *fnames_dense[]={
-    "name",
-    "njeD",
-    "nfeD"
-  };
-  const char *fnames_band[]={
-    "name",
-    "njeB",
-    "nfeB"
-  };
-  const char *fnames_spils[]={
-    "name",
-    "nli",
-    "npe",
-    "nps",
-    "ncfl",
-    "njeSG",
-    "nfeSG"
-  };
-  const char *fnames_quad[]={
-    "nfQe",
-    "netfQ"
-  };
-
-  void *ida_memB;
-
-  long int nst, nfe, nsetups, nni, ncfn, netf;
-  int qlast, qcur;
-  double h0used, hlast, hcur, tcur;
-
-  long int njeD, nfeD;
-  long int njeB, nfeB;
-  long int nli, npe, nps, ncfl, njeSG, nfeSG;
-
-  long int nfQe, netfQ;
-
-  int status;
-  mxArray *mxS_ls, *mxS_quad;
-  int nfields;
-
-  booleantype found_bck;
-  
-
-  /* Extract index of current backward problem */
-    
-  idxB = (int)mxGetScalar(prhs[0]);
-
-  /* Find current backward problem */
-
-  found_bck = FALSE;
-  bckPb = idmData->bckPb;
-  while (bckPb != NULL) {
-    if (indexB == idxB) {
-      found_bck = TRUE;
-      break;
-    }
-    bckPb = bckPb->next;
-  }
-
-  if (!found_bck) idmErrHandler(-999, "IDAS", "IDAGetStatsB",
-                                "idxB has an illegal value.", NULL);
-
-  ida_memB = IDAGetAdjIDABmem(ida_mem, indexB);
-
-  status = IDAGetIntegratorStats(ida_memB, &nst, &nfe, &nsetups, 
-                               &netf, &qlast, &qcur, &h0used, &hlast, &hcur, &tcur);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  status = IDAGetNonlinSolvStats(ida_memB, &nni, &ncfn);
-  if (status != IDA_SUCCESS) goto error_return;
-
-  nfields = sizeof(fnames_intgr)/sizeof(*fnames_intgr);
-  plhs[0] = mxCreateStructMatrix(1, 1, nfields, fnames_intgr);
-
-  mxSetField(plhs[0], 0, "nst",     mxCreateDoubleScalar((double)nst));
-  mxSetField(plhs[0], 0, "nfe",     mxCreateDoubleScalar((double)nfe));
-  mxSetField(plhs[0], 0, "nsetups", mxCreateDoubleScalar((double)nsetups));
-  mxSetField(plhs[0], 0, "netf",    mxCreateDoubleScalar((double)netf));
-  mxSetField(plhs[0], 0, "nni",     mxCreateDoubleScalar((double)nni));
-  mxSetField(plhs[0], 0, "ncfn",    mxCreateDoubleScalar((double)ncfn));
-  mxSetField(plhs[0], 0, "qlast",   mxCreateDoubleScalar((double)qlast));
-  mxSetField(plhs[0], 0, "qcur",    mxCreateDoubleScalar((double)qcur));
-  mxSetField(plhs[0], 0, "h0used",  mxCreateDoubleScalar(h0used));
-  mxSetField(plhs[0], 0, "hlast",   mxCreateDoubleScalar(hlast));
-  mxSetField(plhs[0], 0, "hcur",    mxCreateDoubleScalar(hcur));
-  mxSetField(plhs[0], 0, "tcur",    mxCreateDoubleScalar(tcur));
-
-
-  /* Quadrature Statistics */
-
-  if (quadrB) {
-
-    status = IDAGetQuadStats(ida_memB, &nfQe, &netfQ);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_quad)/sizeof(*fnames_quad);
-    mxS_quad = mxCreateStructMatrix(1, 1, nfields, fnames_quad);
-
-    mxSetField(mxS_quad, 0, "nfQe",  mxCreateDoubleScalar((double)nfQe));
-    mxSetField(mxS_quad, 0, "netfQ", mxCreateDoubleScalar((double)netfQ));
-
-  } else {
-
-    mxS_quad = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  }
-  
-  mxSetField(plhs[0], 0, "QuadInfo", mxS_quad);
-
-  /* Linear Solver Statistics */
-
-  switch(lsB){
-
-  case LS_DENSE:
-    
-    status = IDADlsGetNumJacEvals(ida_memB, &njeD);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDADlsGetNumResEvals(ida_memB, &nfeD);
-    if (status != IDA_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_dense)/sizeof(*fnames_dense);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_dense);
-
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Dense"));
-    mxSetField(mxS_ls, 0, "njeD", mxCreateDoubleScalar((double)njeD));
-    mxSetField(mxS_ls, 0, "nfeD", mxCreateDoubleScalar((double)nfeD));
-    
-    break;
-
-  case LS_BAND:
-      
-    status = IDADlsGetNumJacEvals(ida_memB, &njeB);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDADlsGetNumResEvals(ida_memB, &nfeB);
-    if (status != IDA_SUCCESS) goto error_return;
-  
-    nfields = sizeof(fnames_band)/sizeof(*fnames_band);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_band);
- 
-    mxSetField(mxS_ls, 0, "name", mxCreateString("Band"));
-    mxSetField(mxS_ls, 0, "njeB", mxCreateDoubleScalar((double)njeB));
-    mxSetField(mxS_ls, 0, "nfeB", mxCreateDoubleScalar((double)nfeB));
-      
-    break;
-
-  case LS_SPGMR:
-  case LS_SPBCG:
-  case LS_SPTFQMR:
-
-    status = IDASpilsGetNumLinIters(ida_memB, &nli);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumPrecEvals(ida_memB, &npe);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumPrecSolves(ida_memB, &nps);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumConvFails(ida_memB, &ncfl);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumJtimesEvals(ida_memB, &njeSG);
-    if (status != IDA_SUCCESS) goto error_return;
-    status = IDASpilsGetNumResEvals(ida_memB, &nfeSG);
-    if (status != IDA_SUCCESS) goto error_return;
-    
-    nfields = sizeof(fnames_spils)/sizeof(*fnames_spils);
-    mxS_ls = mxCreateStructMatrix(1, 1, nfields, fnames_spils);
- 
-    if (lsB == LS_SPGMR)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("GMRES"));
-    else if (lsB == LS_SPBCG)
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("BiCGStab"));
-    else
-      mxSetField(mxS_ls, 0, "name",  mxCreateString("TFQMR"));
-
-    mxSetField(mxS_ls, 0, "nli",   mxCreateDoubleScalar((double)nli));
-    mxSetField(mxS_ls, 0, "npe",   mxCreateDoubleScalar((double)npe));
-    mxSetField(mxS_ls, 0, "nps",   mxCreateDoubleScalar((double)nps));
-    mxSetField(mxS_ls, 0, "ncfl",  mxCreateDoubleScalar((double)ncfl));
-    mxSetField(mxS_ls, 0, "njeSG", mxCreateDoubleScalar((double)njeSG));
-    mxSetField(mxS_ls, 0, "nfeSG", mxCreateDoubleScalar((double)nfeSG));
-    
-    break;
-  }
-
-  mxSetField(plhs[0], 0, "LSInfo", mxS_ls);
-
-  /* Successful return */
-
-  status = 0;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int IDM_Set(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  const mxArray *options;
-  mxArray *opt;
-
-  double tstop;
-
-  int status;
-
-  fwdPb = idmData->fwdPb;
-  options = prhs[0];
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* User data */
-
-  opt = mxGetField(options,0,"UserData");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_data);
-    mtlb_data = mxDuplicateArray(opt);
-  }
-
-  /* Stopping time */
-
-  opt = mxGetField(options,0,"StopTime");
-  if ( !mxIsEmpty(opt) ) {
-    tstop = (double)mxGetScalar(opt);
-    status = IDASetStopTime(ida_mem, tstop);
-    if (status != IDA_SUCCESS) goto error_return;
-  }
-
-  /* Successful return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int IDM_SetB(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  return(0);
-}
-
-static int IDM_Get(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb;
-
-  double t;
-  N_Vector ewt;
-  double *this, *next;
-  int key, k, i, nfields;
-
-  IDAadjCheckPointRec *ckpnt;
-  const char *fnames_ckpnt[]={
-    "t0",
-    "t1",
-    "nstep",
-    "order",
-    "step"
-  };
-
-  int status;
-
-  fwdPb = idmData->fwdPb;
-
-  key = (int) (*mxGetPr(prhs[0]));
-
-  switch (key) {
-
-  case 1:    /* DerivSolution */
-
-    t = *mxGetPr(prhs[1]);
-    k = (int) (*mxGetPr(prhs[2]));
-
-    plhs[0] = mxCreateDoubleMatrix(N,1,mxREAL);
-    status = IDAGetDky(ida_mem, t, k, yy);
-    if (status != IDA_SUCCESS) goto error_return;
-    GetData(yy, mxGetPr(plhs[0]), N);
-
-    break;
-
-  case 2:    /* ErrorWeights */
-
-    ewt = N_VClone(yy);
-
-    plhs[0] = mxCreateDoubleMatrix(N,1,mxREAL);
-    status = IDAGetErrWeights(ida_mem, ewt);
-    if (status != IDA_SUCCESS) goto error_return;
-    GetData(ewt, mxGetPr(plhs[0]), N);
-
-    N_VDestroy(ewt);
-
-    break;
-
-  case 3:    /* not used */
-
-    break;
-
-  case 4:    /* CheckPointsInfo */
-
-    ckpnt = (IDAadjCheckPointRec *) malloc ( (Nc+1)*sizeof(IDAadjCheckPointRec));
-    status = IDAGetAdjCheckPointsInfo(ida_mem, ckpnt);
-    if (status != IDA_SUCCESS) {
-      free(ckpnt);
-      goto error_return;
-    }
-    nfields = sizeof(fnames_ckpnt)/sizeof(*fnames_ckpnt);
-    plhs[0] = mxCreateStructMatrix(Nc+1, 1, nfields, fnames_ckpnt);
-    for (i=0; i<=Nc; i++) {
-      this = (double *)(ckpnt[Nc-i].my_addr);
-      next = (double *)(ckpnt[Nc-i].next_addr);
-      mxSetField(plhs[0], i, "t0",    mxCreateDoubleScalar((double)(ckpnt[Nc-i].t0)));
-      mxSetField(plhs[0], i, "t1",    mxCreateDoubleScalar((double)(ckpnt[Nc-i].t1)));
-      mxSetField(plhs[0], i, "nstep", mxCreateDoubleScalar((double)(ckpnt[Nc-i].nstep)));
-      mxSetField(plhs[0], i, "order", mxCreateDoubleScalar((double)(ckpnt[Nc-i].order)));
-      mxSetField(plhs[0], i, "step",  mxCreateDoubleScalar((double)(ckpnt[Nc-i].step)));
-    }
-    free(ckpnt);
-    break;
-
-  }
-
-  /* Successful return */
-
-  status = 0;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(-1);
-}
-
-static int IDM_Free(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  idmPbData fwdPb, bckPb;
-
-  if (idmData == NULL) return(0);
-  
-  fwdPb = idmData->fwdPb;
-  if (mon) mxW_IDAMonitor(2, 0.0, NULL, NULL, NULL, fwdPb);
-
-  bckPb = idmData->bckPb;
-  while (bckPb != NULL) {
-    if (monB) mxW_IDAMonitorB(2, indexB, 0.0, NULL, NULL, bckPb);   
-    bckPb = bckPb->next;
-  }
-
-  IDAFree(&ida_mem);
-
-  return(0);
-}
-
diff --git a/sundialsTB/idas/idm/src/idm.h b/sundialsTB/idas/idm/src/idm.h
deleted file mode 100644
index 81933fc..0000000
--- a/sundialsTB/idas/idm/src/idm.h
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2012/03/07 21:49:18 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/idas/LICENSE.
- * -----------------------------------------------------------------
- * Header file for the IDAS Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#ifndef _IDM_H
-#define _IDM_H
-
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-  
-#include <string.h>
-#include <stdlib.h>
-#include "mex.h"
-#include <idas/idas.h>
-#include <idas/idas_dense.h>
-#include <idas/idas_band.h>
-#include <idas/idas_spgmr.h>
-#include <idas/idas_spbcgs.h>
-#include <idas/idas_sptfqmr.h>
-#include <idas/idas_bbdpre.h>
-
-/*
- * ---------------------------------------------------------------------------------
- * Constants
- * ---------------------------------------------------------------------------------
- */
-
-/* Tolerance types */
-
-enum {IDA_SS, IDA_SV, IDA_EE};
-
-/* Linear solver types */
-
-enum {LS_DENSE, LS_BAND, LS_SPGMR, LS_SPBCG, LS_SPTFQMR};
-
-/* Preconditioner modules */
-
-enum {PM_NONE, PM_BBDPRE};
-
-/*
- * ---------------------------------------------------------------------------------
- * Types for global data structures
- * ---------------------------------------------------------------------------------
- */
-
-
-typedef struct idmPbData_ {
-
-
-  long int n;        /* problem dimension */
-  N_Vector YY;       /* solution vector */
-  N_Vector YP;       /* derivative of solution vector */
-
-  booleantype Quadr; /* integrate quadratures? */
-  long int nq;       /* number of quadratures */
-  N_Vector YQ;       /* quadratures vector */
-
-  booleantype Fsa;   /* integrate sensitivities? */
-  int ns;            /* number of sensitivities */
-  N_Vector *YYS;     /* sensitivity vectors */
-  N_Vector *YPS;     /* derivatives of sensitivity vectors */
-
-  booleantype RootSet;  /* rootfinding active? */
-  int ng;               /* number of root functions */
-
-  booleantype TstopSet; /* tstop active? */
-
-  int LS;            /* linear solver type */
-  int PM;            /* preconditioner module */
-
-  booleantype Mon;   /* monitoring? */
-
-  /* Matlab functions and data associated with this problem */
-
-  mxArray *RESfct;
-  mxArray *QUADfct;
-
-  mxArray *JACfct;
-
-  mxArray *PSETfct;
-  mxArray *PSOLfct;
-
-  mxArray *GLOCfct;
-  mxArray *GCOMfct;
-    
-  mxArray *Gfct;
-    
-  mxArray *SRESfct;
-
-  mxArray *MONfct;
-  mxArray *MONdata;
-
-  /* Pointer to the global Matlab user data */
-
-  mxArray *mtlb_data;
-
-  /* Information for backward problems only */
-
-  struct idmPbData_ *fwd;
-  int index;               /* index of this problem */
-  struct idmPbData_ *next; /* pointer to next problem in linked list */
-
-} *idmPbData;
-
-
-typedef struct idmInterfaceData_ {
-
-  void *ida_mem;         /* IDAS solver memory */
-
-  booleantype asa;       /* Perform ASA? */
-  int Nd;                /* number of data points */
-  int Nc;                /* number of check points */
-
-  struct idmPbData_ *fwdPb;
-  struct idmPbData_ *bckPb;
-
-  int NbckPb;            /* Number of backward problems in the linked list bckPb */
-
-  booleantype errMsg;    /* post error/warning messages? */
-
-} *idmInterfaceData;
-
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Error handler function
- * ---------------------------------------------------------------------------------
- */
-
-void idmErrHandler(int error_code, 
-                   const char *module, const char *function, 
-                   char *msg, void *eh_data);
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Wrapper functions
- * ---------------------------------------------------------------------------------
- */
-
-int mxW_IDARes(realtype tt, N_Vector yy, N_Vector yp,
-               N_Vector rr, void *user_data);
-
-int mxW_IDAGfct(realtype t, N_Vector y, N_Vector yp,
-                realtype *gout, void *user_data);
-
-int mxW_IDAQuadFct(realtype tres, N_Vector yy, N_Vector yp,
-                   N_Vector ypQ,
-                   void *user_data);
-
-int mxW_IDASensRes(int Nsens, realtype tres, 
-                   N_Vector yy, N_Vector yp, N_Vector resval,
-                   N_Vector *yyS, N_Vector *ypS, N_Vector *resvalS,
-                   void *user_data,
-                   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
-
-int mxW_IDADenseJac(long int Neq, 
-                    realtype tt, realtype c_j, 
-                    N_Vector yy, N_Vector yp, N_Vector rr,
-                    DlsMat Jac, void *user_data, 
-                    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
-
-int mxW_IDABandJac(long int Neq, long int mupper, long int mlower, 
-                   realtype tt, realtype c_j, 
-                   N_Vector yy, N_Vector yp, N_Vector rr, 
-                   DlsMat Jac, void *user_data,
-                   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
-
-int mxW_IDASpilsJac(realtype tt,
-                    N_Vector yy, N_Vector yp, N_Vector rr,
-                    N_Vector v, N_Vector Jv,
-                    realtype c_j, void *user_data,
-                    N_Vector tmp1, N_Vector tmp2);
-int mxW_IDASpilsPset(realtype tt,
-                     N_Vector yy, N_Vector yp, N_Vector rr,
-                     realtype c_j, void *user_data,
-                     N_Vector tmp1, N_Vector tmp2,
-                     N_Vector tmp3);
-int mxW_IDASpilsPsol(realtype tt,
-                     N_Vector yy, N_Vector yp, N_Vector rr,
-                     N_Vector rvec, N_Vector zvec,
-                     realtype c_j, realtype delta, void *user_data,
-                     N_Vector tmp);
-
-int mxW_IDABBDgloc(long int Nlocal, realtype tt,
-                   N_Vector yy, N_Vector yp, N_Vector gval,
-                   void *user_data);
-int mxW_IDABBDgcom(long int Nlocal, realtype tt,
-                   N_Vector yy, N_Vector yp,
-                   void *user_data);
-
-void mxW_IDAMonitor(int call, double t, 
-                    N_Vector yy,
-                    N_Vector yQ, 
-                    N_Vector *yyS,
-                    idmPbData fwdPb);
-
-int mxW_IDAResB(realtype tt, 
-                N_Vector yy, N_Vector yp,
-                N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                void *user_dataB);
-int mxW_IDAResBS(realtype tt, 
-                 N_Vector yy, N_Vector yp,
-                 N_Vector *yyS, N_Vector *ypS,
-                 N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                 void *user_dataB);
-
-int mxW_IDAQuadFctB(realtype tt, 
-                    N_Vector yy, N_Vector yp, 
-                    N_Vector yyB, N_Vector ypB,
-                    N_Vector ypQB,
-                    void *user_dataB);
-int mxW_IDAQuadFctBS(realtype t, 
-                     N_Vector yy, N_Vector yp,
-                     N_Vector *yyS, N_Vector *ypS,
-                     N_Vector yyB, N_Vector ypB,
-                     N_Vector ypQB,
-                     void *user_dataB);
-
-int mxW_IDADenseJacB(long int NeqB, 
-                     realtype tt, realtype c_jB,
-                     N_Vector yy, N_Vector yp,
-                     N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                     DlsMat JacB, void *user_dataB, 
-                     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
-
-int mxW_IDABandJacB(long int NeqB, long int mupperB, long int mlowerB, 
-                    realtype tt, realtype c_jB, 
-                    N_Vector yy, N_Vector yp,
-                    N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                    DlsMat JacB, void *user_dataB,
-                    N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
-
-int mxW_IDASpilsJacB(realtype t,
-                     N_Vector yy, N_Vector yp,
-                     N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                     N_Vector vB, N_Vector JvB, 
-                     realtype c_jB, void *user_dataB, 
-                     N_Vector tmp1B, N_Vector tmp2B);
-int mxW_IDASpilsPsetB(realtype tt, 
-                      N_Vector yy, N_Vector yp,
-                      N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                      realtype c_jB, void *user_dataB,
-                      N_Vector tmp1B, N_Vector tmp2B, 
-                      N_Vector tmp3B);
-int mxW_IDASpilsPsolB(realtype tt, 
-                      N_Vector yy, N_Vector yp,
-                      N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                      N_Vector rvecB, N_Vector zvecB,
-                      realtype c_jB, realtype deltaB,
-                      void *user_dataB, N_Vector tmpB);
-
-int mxW_IDABBDglocB(long int NlocalB, realtype tt,
-                    N_Vector yy, N_Vector yp, 
-                    N_Vector yyB, N_Vector ypB, N_Vector gvalB,
-                    void *user_dataB);
-int mxW_IDABBDgcomB(long int NlocalB, realtype tt,
-                    N_Vector yy, N_Vector yp,
-                    N_Vector yyB, N_Vector ypB,
-                    void *user_dataB);
-
-void mxW_IDAMonitorB(int call, int idxB, double tB, 
-                     N_Vector yyB,
-                     N_Vector yQB,
-                     idmPbData bckPb);
-
-/*
- * ---------------------------------------------------------------------------------
- * Option handling functions
- * ---------------------------------------------------------------------------------
- */
-
-int get_IntgrOptions(const mxArray *options, idmPbData thisPb, booleantype fwd,
-                     int *maxord,
-                     long int *mxsteps,
-                     int *itol, realtype *reltol, double *Sabstol, double **Vabstol,
-                     double *hin, double *hmax,
-                     double *tstop,
-                     booleantype *suppress,
-                     booleantype *errmsg,
-                     double **id, double **cnstr,
-                     booleantype *res_s);
-
-int get_LinSolvOptions(const mxArray *options, idmPbData thisPb, booleantype fwd,
-                       long int *mupper, long int *mlower,
-                       long int *mudq, long int *mldq, double *dqrely,
-                       int *gstype, int *maxl);
-
-int get_QuadOptions(const mxArray *options, idmPbData thisPb, booleantype fwd,
-                    long int Nq, booleantype *rhs_s,
-                    booleantype *errconQ,
-                    int *itolQ, double *reltolQ, double *SabstolQ, double **VabstolQ);
-
-int get_FSAOptions(const mxArray *options, idmPbData thisPb,
-                   int *ism,
-                   char **pfield_name, int **plist, double **pbar,
-                   int *dqtype, double *rho,
-                   booleantype *errconS, int *itolS, double *reltolS, 
-                   double **SabstolS, double **VabstolS);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/sundialsTB/idas/idm/src/idmOpts.c b/sundialsTB/idas/idm/src/idmOpts.c
deleted file mode 100644
index 2378a23..0000000
--- a/sundialsTB/idas/idm/src/idmOpts.c
+++ /dev/null
@@ -1,875 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.11 $
- * $Date: 2012/03/07 21:49:18 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/idas/LICENSE.
- * -----------------------------------------------------------------
- * Option parsing functions for the IDAS Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#include <string.h>
-#include "idm.h"
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define N             (thisPb->n) 
-#define Ns            (thisPb->ns) 
-#define Ng            (thisPb->ng) 
-#define ls            (thisPb->LS) 
-#define pm            (thisPb->PM) 
-
-#define mtlb_data     (thisPb->mtlb_data)
-
-#define mtlb_JACfct   (thisPb->JACfct)
-#define mtlb_PSETfct  (thisPb->PSETfct)
-#define mtlb_PSOLfct  (thisPb->PSOLfct)
-#define mtlb_GLOCfct  (thisPb->GLOCfct)
-#define mtlb_GCOMfct  (thisPb->GCOMfct)
-#define mtlb_Gfct     (thisPb->Gfct)
-
-#define mon           (thisPb->Mon)
-#define tstopSet      (thisPb->TstopSet)
-
-#define mtlb_MONfct   (thisPb->MONfct)
-#define mtlb_MONdata  (thisPb->MONdata)
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Option handling functions
- * ---------------------------------------------------------------------------------
- */
-
-int get_IntgrOptions(const mxArray *options, idmPbData thisPb, booleantype fwd,
-                     int *maxord,
-                     long int *mxsteps,
-                     int *itol, realtype *reltol, double *Sabstol, double **Vabstol,
-                     double *hin, double *hmax,
-                     double *tstop,
-                     booleantype *suppress,
-                     booleantype *errmsg,
-                     double **id, double **cnstr,
-                     booleantype *res_s)
-{
-  mxArray *opt;
-  char *bufval;
-  int buflen, status, q;
-  long int i, m, n;
-  double *tmp;
-  char *fctName;
-  char *fwd_fctName = "IDAInit/IDAReInit";
-  char *bck_fctName = "IDAInitB/IDAReInitB";
-
-  if (fwd) fctName = fwd_fctName;
-  else     fctName = bck_fctName;
-
-  /* Set default values */
-
-  *maxord = 5;
-
-  *mxsteps = 0;
-
-  *itol = IDA_SS;
-  *reltol = 1.0e-3;
-  *Sabstol = 1.0e-6;
-  *Vabstol = NULL;
-
-  *hin = 0.0;
-  *hmax = 0.0;
-
-  *res_s = FALSE;
-
-  *suppress = FALSE;
-
-  *id = NULL;
-  *cnstr = NULL;
-
-  Ng = 0;
-  tstopSet = FALSE;
-  mon = FALSE;
-
-  *errmsg = TRUE;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* User data */
-
-  opt = mxGetField(options,0,"UserData");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_data);
-    mtlb_data = mxDuplicateArray(opt);
-  }
-
-  /* Tolerances */
-
-  opt = mxGetField(options,0,"RelTol");
-  if ( !mxIsEmpty(opt) ) {
-    *reltol = *mxGetPr(opt);
-    if (*reltol < 0.0 ) {
-      idmErrHandler(-999, "IDAS", fctName, "RelTol is negative.", NULL);
-      return(-1);
-    }
-  }
-
-  opt = mxGetField(options,0,"AbsTol");
-  if ( !mxIsEmpty(opt) ) {
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      idmErrHandler(-999, "IDAS", fctName, "AbsTol is not a scalar or a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    tmp = mxGetPr(opt);
-    if (n == 1) {
-      *itol = IDA_SS;
-      *Sabstol = *tmp;
-      if (*Sabstol < 0.0) {
-        idmErrHandler(-999, "IDAS", fctName, "AbsTol is negative.", NULL);
-        return(-1);
-      }
-    } else if (n == N) {
-      *itol = IDA_SV;
-      *Vabstol = (double *) malloc(N*sizeof(double));
-      for(i=0;i<N;i++) {
-        (*Vabstol)[i] = tmp[i];
-        if (tmp[i] < 0.0) {
-          idmErrHandler(-999, "IDAS", fctName, "AbsTol has a negative component.", NULL);
-          return(-1);
-        }
-      }
-    } else {
-      idmErrHandler(-999, "IDAS", fctName, "AbsTol does not contain N elements.", NULL);
-      return(-1);
-    }
-  }
-  
-  /* Maximum number of steps */
-  
-  opt = mxGetField(options,0,"MaxNumSteps");
-  if ( !mxIsEmpty(opt) ) {
-    *mxsteps = (int)*mxGetPr(opt);
-    if (*mxsteps < 0) {
-      idmErrHandler(-999, "IDAS", fctName, "MaxNumSteps is negative.", NULL);
-      return(-1);
-    }
-  }
-  
-  /* Maximum order */
-  
-  opt = mxGetField(options,0,"MaxOrder");
-  if ( !mxIsEmpty(opt) ) {
-    q = (int)*mxGetPr(opt);
-    if (q <= 0) {
-      idmErrHandler(-999, "IDAS", fctName, "MaxOrder must be positive.", NULL);
-      return(-1);
-    }
-    if (q > *maxord) {
-      idmErrHandler(-999, "IDAS", fctName, "MaxOrder is too large for BDF.", NULL);
-      return(-1);
-    }
-    *maxord = q;
-  }
-
-  /* Initial step size */
-
-  opt = mxGetField(options,0,"InitialStep");
-  if ( !mxIsEmpty(opt) ) {
-    *hin = *mxGetPr(opt);
-  }
-
-  /* Maximum step size */
-
-  opt = mxGetField(options,0,"MaxStep");
-  if ( !mxIsEmpty(opt) ) {
-    tmp = mxGetPr(opt);
-    if (*tmp < 0.0) {
-      idmErrHandler(-999, "IDAS", fctName, "MaxStep is negative.", NULL);
-      return(-1);
-    }
-    if ( mxIsInf(*tmp) )
-      *hmax = 0.0;
-    else
-      *hmax = *tmp;
-  }
-
-  /* ID vector */
-
-  opt = mxGetField(options,0,"VariableTypes");
-  if ( !mxIsEmpty(opt) ) {
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      idmErrHandler(-999, "IDAS", fctName, "VariableTypes is not a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    if (n == N) {
-      tmp = mxGetPr(opt);
-      *id = (double *)malloc(N*sizeof(double));
-      for(i=0;i<N;i++) 
-        (*id)[i] = tmp[i];
-    } else {
-      idmErrHandler(-999, "IDAS", fctName, "VariableTypes has wrong dimension." , NULL);
-      return(-1);
-    }
-  }
-
-  /* Suppress algebraic variables? */
-
-  opt = mxGetField(options,0,"SuppressAlgVars");
-  if ( !mxIsEmpty(opt) ) {
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      idmErrHandler(-999, "IDAS", fctName, "Canot parse SuppressAlgVars.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"on")) {
-      *suppress = TRUE;
-    } else if(!strcmp(bufval,"off")) {
-      *suppress = FALSE;
-    } else {
-      idmErrHandler(-999, "IDAS", fctName, "SuppressAlgVars has an illegal value.", NULL);
-      return(-1);
-    }
-  }
-
-  /* Monitor? */
-
-  opt = mxGetField(options,0,"MonitorFn");
-  if ( !mxIsEmpty(opt) ) {
-    mon = TRUE;
-    mxDestroyArray(mtlb_MONfct);
-    mtlb_MONfct = mxDuplicateArray(opt);
-    opt = mxGetField(options,0,"MonitorData");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_MONdata);
-      mtlb_MONdata  = mxDuplicateArray(opt);
-    }
-  }
-
-  /* The remaining options are interpreted either for 
-   * forward problems only or backward problems only */
-
-  if (fwd) {   /* FORWARD PROBLEM ONLY */
-
-
-    /* Disable error/warning messages? */
-    opt = mxGetField(options,0,"ErrorMessages");
-    if ( !mxIsEmpty(opt) ) {
-      if (!mxIsLogical(opt)) {
-        idmErrHandler(-999, "IDAS", fctName, "ErrorMessages is not a logical scalar.", NULL);
-        return(-1);
-      }
-      if (mxIsLogicalScalarTrue(opt)) *errmsg = TRUE;
-      else                            *errmsg = FALSE;
-    }
-    
-
-    /* Stopping time */
-    opt = mxGetField(options,0,"StopTime");
-    if ( !mxIsEmpty(opt) ) {
-      *tstop = *mxGetPr(opt);
-      tstopSet = TRUE;
-    }
-
-    /* Number of root functions */
-    opt = mxGetField(options,0,"NumRoots");
-    if ( !mxIsEmpty(opt) ) {
-
-      Ng = (int)*mxGetPr(opt);
-      if (Ng < 0) {
-        idmErrHandler(-999, "IDAS", fctName, "NumRoots is negative.", NULL);
-        return(-1);
-      }
-      if (Ng > 0) {
-        /* Roots function */
-        opt = mxGetField(options,0,"RootsFn");
-        if ( !mxIsEmpty(opt) ) {
-          mxDestroyArray(mtlb_Gfct);
-          mtlb_Gfct = mxDuplicateArray(opt);
-        } else {
-          idmErrHandler(-999, "IDAS", fctName, "RootsFn required for NumRoots > 0", NULL);
-          return(-1);
-        }
-      }
-      
-    }
-
-    /* Constraints vector */
-    opt = mxGetField(options,0,"ConstraintTypes");
-    if ( !mxIsEmpty(opt) ) {
-      m = mxGetM(opt);
-      n = mxGetN(opt);
-      if ( (n != 1) && (m != 1) ) {
-        idmErrHandler(-999, "IDAS", fctName, "ConstraintTypes is not a vector.", NULL);
-        return(-1);
-      }
-      if ( m > n ) n = m;
-      if (n == N) {
-        tmp = mxGetPr(opt);
-        *cnstr = (double *)malloc(N*sizeof(double));
-        for(i=0;i<N;i++) 
-          (*cnstr)[i] = tmp[i];
-      } else {
-        idmErrHandler(-999, "IDAS", fctName, "ConstraintTypes has wrong dimension.", NULL);
-        return(-1);
-      }
-    }
-    
-  } else {   /* BACKWARD PROBLEM ONLY */
-
-    /* Dependency on forward sensitivities */
-
-    opt = mxGetField(options,0,"SensDependent");
-    if ( !mxIsEmpty(opt) ) {
-      if (!mxIsLogical(opt)) {
-        idmErrHandler(-999, "IDAS", fctName, "SensDependent is not a logical scalar.", NULL);
-        return(-1);
-      }
-      if (mxIsLogicalScalarTrue(opt)) *res_s = TRUE;
-      else                            *res_s = FALSE;
-    }
-
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-}
-
-
-int get_LinSolvOptions(const mxArray *options, idmPbData thisPb, booleantype fwd,
-                       long int *mupper, long int *mlower,
-                       long int *mudq, long int *mldq, double *dqrely,
-                       int *gstype, int *maxl)
-{
-  mxArray *opt;
-  char *bufval;
-  int buflen, status;
-  char *fctName;
-  char *fwd_fctName = "IDAInit/IDAReInit";
-  char *bck_fctName = "IDAInitB/IDAReInitB";
-
-  if (fwd) fctName = fwd_fctName;
-  else     fctName = bck_fctName;
-
-  *mupper = 0;
-  *mlower = 0;
-
-  *mudq = 0;
-  *mldq = 0;
-  *dqrely = 0.0;
-
-  *gstype = MODIFIED_GS;
-  *maxl = 0;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* Linear solver type */
-
-  opt = mxGetField(options,0,"LinearSolver");
-  if ( !mxIsEmpty(opt) ) {
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      idmErrHandler(-999, "IDAS", fctName,
-                    "Cannot parse LinearSolver.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"Band"))          ls = LS_BAND;
-    else if(!strcmp(bufval,"GMRES"))    ls = LS_SPGMR;
-    else if(!strcmp(bufval,"BiCGStab")) ls = LS_SPBCG;
-    else if(!strcmp(bufval,"TFQMR"))    ls = LS_SPTFQMR;
-    else if(!strcmp(bufval,"Dense"))    ls = LS_DENSE;
-    else {
-      idmErrHandler(-999, "IDAS", fctName, "LinearSolver has an illegal value.", NULL);
-      return(-1);
-    }
-  }
-  
-  /* Jacobian function */
-
-  opt = mxGetField(options,0,"JacobianFn");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_JACfct);
-    mtlb_JACfct  = mxDuplicateArray(opt);
-  }
-
-  /* Band linear solver */
-
-  if (ls==LS_BAND) {
-
-    opt = mxGetField(options,0,"UpperBwidth");
-    if ( !mxIsEmpty(opt) )
-      *mupper = (long int)*mxGetPr(opt);
-    
-    opt = mxGetField(options,0,"LowerBwidth");
-    if ( !mxIsEmpty(opt) )
-      *mlower = (long int)*mxGetPr(opt);
-
-  }
-
-  /* SPGMR linear solver options */
-  
-  if (ls==LS_SPGMR) {
-
-    /* Type of Gram-Schmidt procedure */
-
-    opt = mxGetField(options,0,"GramSchmidtType");
-    if ( !mxIsEmpty(opt) ) {
-      buflen = mxGetM(opt) * mxGetN(opt) + 1;
-      bufval = mxCalloc(buflen, sizeof(char));
-      status = mxGetString(opt, bufval, buflen);
-      if(status != 0) {
-        idmErrHandler(-999, "IDAS", fctName, "Cannot parse GramSchmidtType.", NULL);
-        return(-1);
-      }
-      if(!strcmp(bufval,"Classical"))     *gstype = CLASSICAL_GS;
-      else if(!strcmp(bufval,"Modified")) *gstype = MODIFIED_GS;
-      else {
-        idmErrHandler(-999, "IDAS", fctName, "GramSchmidtType has an illegal value.", NULL);
-        return(-1);
-      }
-    }
-
-  }
-
-  /* SPILS linear solver options */
-
-  if ( (ls==LS_SPGMR) || (ls==LS_SPBCG) || (ls==LS_SPTFQMR) ) {
-
-    /* Max. dimension of Krylov subspace */
-
-    opt = mxGetField(options,0,"KrylovMaxDim");
-    if ( !mxIsEmpty(opt) ) {
-      *maxl = (int)*mxGetPr(opt);
-      if (*maxl < 0) {
-        idmErrHandler(-999, "IDAS", fctName, "KrylovMaxDim is negative.", NULL);
-        return(-1);
-      }
-    }
-
-    /* User defined precoditioning */
-
-    opt = mxGetField(options,0,"PrecSetupFn");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_PSETfct);
-      mtlb_PSETfct  = mxDuplicateArray(opt);
-    }
-
-    opt = mxGetField(options,0,"PrecSolveFn");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_PSOLfct);
-      mtlb_PSOLfct  = mxDuplicateArray(opt);
-    }
-
-    /* Preconditioner module */
-  
-    opt = mxGetField(options,0,"PrecModule");
-    if ( !mxIsEmpty(opt) ) {
-      buflen = mxGetM(opt) * mxGetN(opt) + 1;
-      bufval = mxCalloc(buflen, sizeof(char));
-      status = mxGetString(opt, bufval, buflen);
-      if(status != 0) {
-        idmErrHandler(-999, "IDAS", fctName, "Cannot parse PrecModule.", NULL);
-        return(-1);
-      }
-      if(!strcmp(bufval,"BBDPre"))           pm = PM_BBDPRE;
-      else if(!strcmp(bufval,"UserDefined")) pm = PM_NONE;
-      else {
-        idmErrHandler(-999, "IDAS", fctName, "PrecModule has an illegal value.", NULL);
-        return(-1);
-      }
-    }
-
-    if (pm == PM_BBDPRE) {
-      
-      opt = mxGetField(options,0,"UpperBwidth");
-      if ( !mxIsEmpty(opt) )
-        *mupper = (long int)*mxGetPr(opt);
-      
-      opt = mxGetField(options,0,"LowerBwidth");
-      if ( !mxIsEmpty(opt) )
-        *mlower = (long int)*mxGetPr(opt);
-
-      opt = mxGetField(options,0,"UpperBwidthDQ");
-      if ( !mxIsEmpty(opt) )
-        *mudq = (long int)*mxGetPr(opt);
-
-      opt = mxGetField(options,0,"LowerBwidthDQ");
-      if ( !mxIsEmpty(opt) )
-        *mldq = (long int)*mxGetPr(opt);
-
-      opt = mxGetField(options,0,"GlocalFn");
-      if ( !mxIsEmpty(opt) ) {
-        mxDestroyArray(mtlb_GLOCfct);
-        mtlb_GLOCfct  = mxDuplicateArray(opt);
-      } else { 
-        idmErrHandler(-999, "IDAS", fctName, "GlocalFn required for BBD preconditioner.", NULL);
-        return(-1);
-      }      
-
-      opt = mxGetField(options,0,"GcommFn");
-      if ( !mxIsEmpty(opt) ) {
-        mxDestroyArray(mtlb_GCOMfct);
-        mtlb_GCOMfct  = mxDuplicateArray(opt);
-      }
-
-    }
-
-  }
-
-  
-  /* We made it here without problems */
-
-  return(0);
-
-}
-
-
-int get_QuadOptions(const mxArray *options, idmPbData thisPb, booleantype fwd,
-                    long int Nq, booleantype *rhs_s,
-                    booleantype *errconQ,
-                    int *itolQ, double *reltolQ, double *SabstolQ, double **VabstolQ)
-{
-  mxArray *opt;
-  long int i, m, n;
-  double *tmp;
-  char *fctName;
-  char *fwd_fctName = "IDAQuadInit/IDAQuadReInit";
-  char *bck_fctName = "IDAQuadInitB/IDAQuadReInitB";
-
-  if (fwd) fctName = fwd_fctName;
-  else     fctName = bck_fctName;
-
-  *errconQ = FALSE;
-  *itolQ = IDA_SS;
-  *reltolQ = 1.0e-4;
-  *SabstolQ = 1.0e-6;
-  *VabstolQ = NULL;
-
-  *rhs_s = FALSE;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* For backward problems only, check dependency on forward sensitivities */
-
-  if (!fwd) {
-
-    opt = mxGetField(options,0,"SensDependent");
-    if ( !mxIsEmpty(opt) ) {
-      if (!mxIsLogical(opt)) {
-        idmErrHandler(-999, "IDAS", fctName, "SensDependent is not a logical scalar.", NULL);
-        return(-1);
-      }
-      if (mxIsLogicalScalarTrue(opt)) *rhs_s = TRUE;
-      else                            *rhs_s = FALSE;
-    }
-
-  }
-
-  /* Quadrature error control and tolerances */
-
-  opt = mxGetField(options,0,"ErrControl");
-  if ( mxIsEmpty(opt) ) return(0);
-
-  if (!mxIsLogical(opt)) {
-    idmErrHandler(-999, "IDAS", fctName, "ErrControl is not a logical scalar.", NULL);
-    return(-1);
-  }
-
-  if (!mxIsLogicalScalarTrue(opt)) return(0);
-  
-  *errconQ = TRUE;
-
-  opt = mxGetField(options,0,"RelTol");
-  if ( !mxIsEmpty(opt) ) {
-    *reltolQ = *mxGetPr(opt);
-    if (*reltolQ < 0.0) {
-      idmErrHandler(-999, "IDAS", fctName, "RelTol is negative.", NULL);
-      return(-1);
-    }
-  } 
-
-  opt = mxGetField(options,0,"AbsTol");
-  if ( !mxIsEmpty(opt) ) {
-
-    m = mxGetN(opt);
-    n = mxGetM(opt);
-    if ( (n != 1) && (m != 1) ) {
-      idmErrHandler(-999, "IDAS", fctName, "AbsTol is not a scalar or a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    tmp = mxGetPr(opt);
-
-    if (n == 1) {
-      *itolQ = IDA_SS;
-      *SabstolQ = *tmp;
-      if (*SabstolQ < 0.0) {
-        idmErrHandler(-999, "IDAS", fctName, "AbsTol is negative.", NULL);
-        return(-1);
-      }
-    } else if (n == Nq) {
-      *itolQ = IDA_SV;
-      *VabstolQ = (double *)malloc(Nq*sizeof(double));
-      for(i=0;i<Nq;i++) {
-        (*VabstolQ)[i] = tmp[i];
-        if (tmp[i] < 0.0) {
-          idmErrHandler(-999, "IDAS", fctName, "AbsTol has a negative component.", NULL);
-          return(-1);
-        }
-      }
-    } else {
-      idmErrHandler(-999, "IDAS", fctName, "AbsTol does not contain Nq elements.", NULL);
-      return(-1);
-    }
-
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-}
-
-int get_FSAOptions(const mxArray *options, idmPbData thisPb,
-                   int *ism,
-                   char **pfield_name, int **plist, double **pbar,
-                   int *dqtype, double *rho,
-                   booleantype *errconS, int *itolS, double *reltolS, 
-                   double **SabstolS, double **VabstolS)
-{
-  mxArray *opt;
-  char *bufval;
-  int i, is, m, n, buflen, status, this_plist;
-  double *tmp;
-
-  /* Set default values */
-
-  *ism = IDA_STAGGERED;
-
-  *dqtype = IDA_CENTERED;
-  *rho = 0.0;
-
-  *errconS = TRUE;
-
-  *itolS = IDA_EE;
-  *SabstolS = NULL;
-  *VabstolS = NULL;
-
-  *pfield_name = NULL;
-  *plist = NULL;
-  *pbar  = NULL;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* Sensitivity method */
-
-  opt = mxGetField(options,0,"method");
-  if ( !mxIsEmpty(opt) ) {
-  
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "Could not parse method.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"Simultaneous"))   *ism = IDA_SIMULTANEOUS;
-    else if(!strcmp(bufval,"Staggered")) *ism = IDA_STAGGERED;
-    else {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "Method has an illegal value.", NULL);
-      return(-1);
-    }
-
-  }
-
-  /* Field name in data structure for params. */
-
-  opt = mxGetField(options,0,"ParamField");
-  if ( !mxIsEmpty(opt) ) {
-
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "Could not parse ParamField.", NULL);
-      return(-1);
-    }
-    *pfield_name = mxCalloc(buflen, sizeof(char));
-    strcpy((*pfield_name), bufval);
-
-  }  
-
-  /* PLIST */
-
-  opt = mxGetField(options,0,"ParamList");
-  if ( !mxIsEmpty(opt) ) {
-
-    tmp = mxGetPr(opt);
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "ParamList is not a vector.", NULL);
-      return(-1);
-    }
-    if (m > n) n = m;
-    if ( n != Ns) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "ParamList does not contain Ns elements.", NULL);
-      return(-1);
-    }
-    *plist = (int *) malloc(Ns*sizeof(int));
-    for (is=0;is<Ns;is++) {
-      this_plist = (int) tmp[is];
-      if (this_plist <= 0) {
-        idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "ParamList must contain only positive integers.", NULL);
-        return(-1);
-      }
-      (*plist)[is] = this_plist - 1;
-    }
-
-  }
-
-  /* PBAR */
-
-  opt = mxGetField(options,0,"ParamScales");
-  if ( !mxIsEmpty(opt) ) {
-
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "ParamScales is not a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    if ( n != Ns) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "ParamScales does not contain Ns elements.", NULL);
-      return(-1);
-    }
-    tmp = mxGetPr(opt);
-    *pbar = (double *) malloc(Ns*sizeof(double));
-    for(i=0;i<Ns;i++)
-      (*pbar)[i] = tmp[i];
-
-  }
-
-  /* DQ type */
-
-  opt = mxGetField(options,0,"DQtype");
-  if ( !mxIsEmpty(opt) ) {
-
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "Cannot parse DQtype.", NULL);
-      return(-1);
-    }
-
-    if(!strcmp(bufval,"Centered")) *dqtype = IDA_CENTERED;
-    else if(!strcmp(bufval,"Forward")) *dqtype = IDA_FORWARD;
-    else {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "DQtype has an illegal value.", NULL);
-      return(-1);
-    }
-
-  }
-  
-  /* DQ parameter */
-
-  opt = mxGetField(options,0,"DQparam");
-  if ( !mxIsEmpty(opt) )
-    *rho = *mxGetPr(opt);
-
-  /* Error control */
-
-  opt = mxGetField(options,0,"ErrControl");
-  if ( !mxIsEmpty(opt) ) {
-    if (!mxIsLogical(opt)) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "ErrControl is not a logical scalar.", NULL);
-      return(-1);
-    }
-    if (mxIsLogicalScalarTrue(opt)) *errconS = TRUE;
-    else                            *errconS = FALSE;
-  }
-
-  /* Tolerances */
-  
-  opt = mxGetField(options,0,"RelTol");
-  if ( !mxIsEmpty(opt) ) {
-
-    *reltolS = *mxGetPr(opt);
-    if (*reltolS < 0.0) {
-      idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "RelTol is negative.", NULL);
-      return(-1);
-    }
-
-    opt = mxGetField(options,0,"AbsTol");
-    if ( !mxIsEmpty(opt) ) {
-
-      m = mxGetM(opt);
-      n = mxGetN(opt);
-      if ( (m == 1) && (n == Ns) ) {
-        *itolS = IDA_SS;
-        tmp = mxGetPr(opt);
-        *SabstolS = (double *) malloc(Ns*sizeof(double));
-        for (is=0; is<Ns; is++) {
-          (*SabstolS)[is] = tmp[is];
-          if ( tmp[is] < 0.0 ) {
-            idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "AbsTol has a negative component.", NULL);
-            return(-1);
-          }
-        }
-      } else if ( (m == N) && (n == Ns) ) {
-        *itolS = IDA_SV;
-        tmp = mxGetPr(opt);
-        *VabstolS = (double *)malloc(Ns*N*sizeof(double));
-        for (i=0; i<Ns*N; i++) {
-          (*VabstolS)[i] = tmp[i];
-          if ( tmp[i] < 0.0 ) {
-            idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "AbsTol has a negative component.", NULL);
-            return(-1);
-          }
-        }
-      } else {
-        idmErrHandler(-999, "IDAS", "IDASensInit/IDASensReInit", "AbsTol must be either a 1xNs vector or an NxNs matrix.", NULL);
-        return(-1);
-      }
-
-    } else {
-
-      *itolS = IDA_EE;
-
-    }
-
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-
-}
-
diff --git a/sundialsTB/idas/idm/src/idmWrap.c b/sundialsTB/idas/idm/src/idmWrap.c
deleted file mode 100644
index 3c1dc8b..0000000
--- a/sundialsTB/idas/idm/src/idmWrap.c
+++ /dev/null
@@ -1,1378 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.10 $
- * $Date: 2012/03/07 21:49:18 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/ida/LICENSE.
- * -----------------------------------------------------------------
- * IDA wrapper functions.
- * -----------------------------------------------------------------
- */
-
-#include "idm.h"
-#include "nvm.h"
-
-static void UpdateUserData(mxArray *new_mtlb_data, idmPbData pb);
-static void UpdateMonitorData(mxArray *new_mtlb_data, idmPbData pb);
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define fsa         (fwdPb->Fsa)
-#define quadr       (fwdPb->Quadr)
-#define N           (fwdPb->n) 
-#define Nq          (fwdPb->nq) 
-#define Ng          (fwdPb->ng) 
-#define Ns          (fwdPb->ns) 
-
-#define quadrB      (bckPb->Quadr)
-#define NB          (bckPb->n) 
-#define NqB         (bckPb->nq) 
-
-/*
- * ---------------------------------------------------------------------------------
- * Wrapper functions
- * ---------------------------------------------------------------------------------
- */
-
-int mxW_IDARes(realtype tt, N_Vector yy, N_Vector yp,
-               N_Vector rr, void *user_data)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[5], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);         /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */
-  mx_in[3] = fwdPb->RESfct;                    /* matlab function handle */ 
-  mx_in[4] = fwdPb->mtlb_data;                 /* matlab user data */
-
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(3,mx_out,5,mx_in,"idm_res");
-
-  PutData(rr, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDAQuadFct(realtype tres, N_Vector yy, N_Vector yp, N_Vector ypQ,
-                   void *user_data)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[5], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tres);       /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */
-  mx_in[3] = fwdPb->QUADfct;                   /* matlab function handle */ 
-  mx_in[4] = fwdPb->mtlb_data;                 /* matlab user data */
-
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(3,mx_out,5,mx_in,"idm_rhsQ");
-
-  PutData(ypQ, mxGetPr(mx_out[0]), Nq);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDAGfct(realtype t, N_Vector yy, N_Vector yp,
-                realtype *gout, void *user_data)
-{
-  idmPbData fwdPb;
-  double *gdata;
-  int i, ret;
-  mxArray *mx_in[5], *mx_out[3];
-  
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(t);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */
-  mx_in[3] = fwdPb->Gfct;                      /* matlab function handle */
-  mx_in[4] = fwdPb->mtlb_data;                 /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(3,mx_out,5,mx_in,"idm_root");
-
-  gdata = mxGetPr(mx_out[0]);
-  for (i=0;i<Ng;i++) gout[i] = gdata[i];
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDADenseJac(long int Neq, realtype tt, realtype c_j, 
-                    N_Vector yy, N_Vector yp, N_Vector rr,
-                    DlsMat Jac, void *user_data, 
-                    N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
-{
-  idmPbData fwdPb;
-  double *J_data;
-  int i, ret;
-  mxArray *mx_in[7], *mx_out[3];
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */  
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current rr */
-  mx_in[4] = mxCreateDoubleScalar(c_j);         /* current c_j */  
-  mx_in[5] = fwdPb->JACfct;                     /* matlab function handle */
-  mx_in[6] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(rr, mxGetPr(mx_in[3]), N);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"idm_djac");
-
-  /* Extract data */
-  J_data = mxGetPr(mx_out[0]);
-  for (i=0;i<N;i++)
-    memcpy(DENSE_COL(Jac,i), J_data + i*N, N*sizeof(double));
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDABandJac(long int Neq, long int mupper, long int mlower, 
-                   realtype tt, realtype c_j, 
-                   N_Vector yy, N_Vector yp, N_Vector rr, 
-                   DlsMat Jac, void *user_data,
-                   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
-{
-  idmPbData fwdPb;
-  double *J_data;
-  long int eband, i;
-  int ret;
-  mxArray *mx_in[7], *mx_out[3];
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current rr */
-  mx_in[4] = mxCreateDoubleScalar(c_j);         /* current c_j */
-  mx_in[5] = fwdPb->JACfct;                     /* matlab function handle */
-  mx_in[6] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(rr, mxGetPr(mx_in[3]), N);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"idm_bjac");
-
-  /* Extract data */
-  eband =  mupper + mlower + 1;
-  J_data = mxGetPr(mx_out[0]);
-  for (i=0;i<N;i++)
-    memcpy(BAND_COL(Jac,i) - mupper, J_data + i*eband, eband*sizeof(double));
-
-  ret = (int)*mxGetPr(mx_out[1]);
-  
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDASpilsJac(realtype tt,
-                    N_Vector yy, N_Vector yp, N_Vector rr,
-                    N_Vector v, N_Vector Jv,
-                    realtype c_j, void *user_data,
-                    N_Vector tmp1, N_Vector tmp2)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[8], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */ 
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current rr */
-  mx_in[4] = mxCreateDoubleMatrix(N,1,mxREAL);  /* vector v */
-  mx_in[5] = mxCreateDoubleScalar(c_j);         /* current c_j */ 
-  mx_in[6] = fwdPb->JACfct;                     /* matlab function handle */
-  mx_in[7] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(rr, mxGetPr(mx_in[3]), N);
-  GetData(v, mxGetPr(mx_in[4]), N);
-
-  mexCallMATLAB(3,mx_out,8,mx_in,"idm_jtv");
-
-  PutData(Jv, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDASpilsPset(realtype tt,
-                     N_Vector yy, N_Vector yp, N_Vector rr,
-                     realtype c_j, void *user_data,
-                     N_Vector tmp1, N_Vector tmp2,
-                     N_Vector tmp3)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[7], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current rr */
-  mx_in[4] = mxCreateLogicalScalar(c_j);        /* current c_j */
-  mx_in[5] = fwdPb->PSETfct;                    /* matlab function handle */
-  mx_in[6] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(rr, mxGetPr(mx_in[3]), N);
-
-  mexCallMATLAB(2,mx_out,7,mx_in,"idm_pset");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-}
-
-int mxW_IDASpilsPsol(realtype tt,
-                     N_Vector yy, N_Vector yp, N_Vector rr,
-                     N_Vector rvec, N_Vector zvec,
-                     realtype c_j, realtype delta, void *user_data,
-                     N_Vector tmp)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[8], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);         /* current t */   
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current rr */
-  mx_in[4] = mxCreateDoubleMatrix(N,1,mxREAL); /* right hand side r */
-  mx_in[5] = mxCreateDoubleScalar(c_j);        /* current c_j */   
-  mx_in[6] = fwdPb->PSOLfct;                   /* matlab function handle */
-  mx_in[7] = fwdPb->mtlb_data;                 /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(rr, mxGetPr(mx_in[3]), N);
-  GetData(rvec, mxGetPr(mx_in[4]), N);
-
-  mexCallMATLAB(3,mx_out,8,mx_in,"idm_psol");
-
-  PutData(zvec, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-/*
- * ----------------------------
- * BBD PRECONDITONER FUNCTIONS
- * ----------------------------
- */
-
-int mxW_IDABBDgloc(long int Nlocal, realtype tt,
-                   N_Vector yy, N_Vector yp, N_Vector gval,
-                   void *user_data)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[5], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = fwdPb->GLOCfct;                    /* matlab function handle */
-  mx_in[4] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(3,mx_out,5,mx_in,"idm_gloc");
-
-  PutData(gval, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDABBDgcom(long int Nlocal, realtype tt,
-                   N_Vector yy, N_Vector yp,
-                   void *user_data)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[5], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = fwdPb->GCOMfct;                    /* matlab function handle */
-  mx_in[4] = fwdPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-
-  mexCallMATLAB(2,mx_out,5,mx_in,"idm_gcom");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], fwdPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-}
-
-/*
- * ----------------------------
- * FORWARD SENSITVITY FUNCTIONS
- * ----------------------------
- */
-
-int mxW_IDASensRes(int Nsens, realtype tres, 
-                   N_Vector yy, N_Vector yp, N_Vector rr,
-                   N_Vector *yyS, N_Vector *ypS, N_Vector *rrS,
-                   void *user_data,
-                   N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
-{
-  idmPbData fwdPb;
-  mxArray *mx_in[9], *mx_out[3];
-  int is, ret;
-  double *tmp_yyS, *tmp_ypS, *tmp_rrS;
-
-  /* Extract global interface data from user-data */
-  fwdPb = (idmPbData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tres);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current rr */
-  mx_in[4] = mxCreateDoubleScalar(Ns);            /* number of sensitivities */
-  mx_in[5] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yyS */
-  mx_in[6] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current ypS */
-  mx_in[7] = fwdPb->SRESfct;                      /* matlab function handle */      
-  mx_in[8] = fwdPb->mtlb_data;                    /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(rr, mxGetPr(mx_in[3]), N);
-
-  tmp_yyS = mxGetPr(mx_in[5]);
-  tmp_ypS = mxGetPr(mx_in[6]);
-  for (is=0; is<Ns; is++) {
-    GetData(yyS[is], &tmp_yyS[is*N], N);
-    GetData(ypS[is], &tmp_ypS[is*N], N);
-  }
-
-  mexCallMATLAB(3,mx_out,9,mx_in,"idm_resS");
-  
-  tmp_rrS = mxGetPr(mx_out[0]);
-
-  for(is=0;is<Ns;is++)
-    PutData(rrS[is], &tmp_rrS[is*N], N);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], fwdPb);
-  }
-
-  /* Free temporary space */
-
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-/*
- * ----------------------------
- * ADJOINT SENSITVITY FUNCTIONS
- * ----------------------------
- */
-
-int mxW_IDAResB(realtype tt, 
-                N_Vector yy, N_Vector yp,
-                N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                void *user_dataB)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[8], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(0.0);         /* type=0: not dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[6] = bckPb->RESfct;                     /* matlab function handle */ 
-  mx_in[7] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[2]), N);
-  GetData(yp, mxGetPr(mx_in[3]), N);
-  GetData(yyB, mxGetPr(mx_in[4]), NB);
-  GetData(ypB, mxGetPr(mx_in[5]), NB);
-
-  mexCallMATLAB(3,mx_out,8,mx_in,"idm_resB");
-
-  PutData(rrB, mxGetPr(mx_out[0]), NB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDAResBS(realtype tt, 
-                 N_Vector yy, N_Vector yp,
-                 N_Vector *yyS, N_Vector *ypS,
-                 N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                 void *user_dataB)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[11], *mx_out[3];
-  double *tmp_yyS, *tmp_ypS;
-  int is, ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(1.0);           /* type=1: dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(tt);            /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current yy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current yp */
-  mx_in[4] = mxCreateDoubleScalar(Ns);            /* number of sensitivities */
-  mx_in[5] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yyS */
-  mx_in[6] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current ypS */
-  mx_in[7] = mxCreateDoubleMatrix(NB,1,mxREAL);   /* current yyB */
-  mx_in[8] = mxCreateDoubleMatrix(NB,1,mxREAL);   /* current ypB */
-  mx_in[9] = bckPb->RESfct;                       /* matlab function handle */ 
-  mx_in[10] = bckPb->mtlb_data;                   /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(yy, mxGetPr(mx_in[2]), N);
-  GetData(yp, mxGetPr(mx_in[3]), N);
-
-  tmp_yyS = mxGetPr(mx_in[5]);
-  tmp_ypS = mxGetPr(mx_in[6]);
-  for (is=0; is<Ns; is++) {
-    GetData(yyS[is], &tmp_yyS[is*N], N);
-    GetData(ypS[is], &tmp_ypS[is*N], N);
-  }
-
-  GetData(yyB, mxGetPr(mx_in[7]), NB);
-  GetData(ypB, mxGetPr(mx_in[8]), NB);
-
-  mexCallMATLAB(3,mx_out,11,mx_in,"idm_resB");
-
-  PutData(rrB, mxGetPr(mx_out[0]), NB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_in[7]);
-  mxDestroyArray(mx_in[8]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDAQuadFctB(realtype tt, 
-                    N_Vector yy, N_Vector yp, 
-                    N_Vector yyB, N_Vector ypB,
-                    N_Vector ypQB, void *user_dataB)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[8], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(0.0);         /* type=0: not dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[6] = bckPb->QUADfct;                    /* matlab function handle */ 
-  mx_in[7] = bckPb->mtlb_data;                  /* matlab user data */
-
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[2]), N);
-  GetData(yp, mxGetPr(mx_in[3]), N);
-  GetData(yyB, mxGetPr(mx_in[4]), NB);
-  GetData(ypB, mxGetPr(mx_in[5]), NB);
-
-  mexCallMATLAB(3,mx_out,8,mx_in,"idm_rhsQB");
-
-  PutData(ypQB, mxGetPr(mx_out[0]), NqB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDAQuadFctBS(realtype tt, 
-                     N_Vector yy, N_Vector yp, 
-                     N_Vector *yyS, N_Vector *ypS,
-                     N_Vector yyB, N_Vector ypB,
-                     N_Vector ypQB, void *user_dataB)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[11], *mx_out[3];
-  double *tmp_yyS, *tmp_ypS;
-  int is, ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(1.0);           /* type=1: dependent on yS */
-  mx_in[1] = mxCreateDoubleScalar(tt);            /* current t */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current yy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);    /* current yp */
-  mx_in[4] = mxCreateDoubleScalar(Ns);            /* number of sensitivities */
-  mx_in[5] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yyS */
-  mx_in[6] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current ypS */
-  mx_in[7] = mxCreateDoubleMatrix(NB,1,mxREAL);   /* current yyB */
-  mx_in[8] = mxCreateDoubleMatrix(NB,1,mxREAL);   /* current ypB */
-  mx_in[9] = bckPb->QUADfct;                      /* matlab function handle */ 
-  mx_in[10] = bckPb->mtlb_data;                   /* matlab user data */
-
-  /* Call matlab wrapper */
-
-  GetData(yy, mxGetPr(mx_in[2]), N);
-  GetData(yp, mxGetPr(mx_in[3]), N);
-
-  tmp_yyS = mxGetPr(mx_in[5]);
-  tmp_ypS = mxGetPr(mx_in[6]);
-  for (is=0; is<Ns; is++) {
-    GetData(yyS[is], &tmp_yyS[is*N], N);
-    GetData(ypS[is], &tmp_ypS[is*N], N);
-  }
-
-  GetData(yyB, mxGetPr(mx_in[7]), NB);
-  GetData(ypB, mxGetPr(mx_in[8]), NB);
-
-  mexCallMATLAB(3,mx_out,11,mx_in,"idm_rhsQB");
-
-  PutData(ypQB, mxGetPr(mx_out[0]), NqB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_in[7]);
-  mxDestroyArray(mx_in[8]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDADenseJacB(long int NeqB,
-                     realtype tt, realtype c_jB,
-                     N_Vector yy, N_Vector yp,
-                     N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                     DlsMat JacB, void *user_dataB, 
-                     N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
-{
-  idmPbData fwdPb, bckPb;
-  double *JB_data;
-  mxArray *mx_in[9], *mx_out[3];
-  int i, ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */  
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current rrB */
-  mx_in[6] = mxCreateDoubleScalar(c_jB);        /* current c_jB */  
-  mx_in[7] = bckPb->JACfct;                     /* matlab function handle */
-  mx_in[8] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(yyB, mxGetPr(mx_in[3]), NB);
-  GetData(ypB, mxGetPr(mx_in[4]), NB);
-  GetData(rrB, mxGetPr(mx_in[5]), NB);
-
-  mexCallMATLAB(3,mx_out,9,mx_in,"idm_djacB");
-
-  JB_data = mxGetPr(mx_out[0]);
-  for (i=0;i<NB;i++)
-    memcpy(DENSE_COL(JacB,i), JB_data + i*NB, NB*sizeof(double));
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDABandJacB(long int NeqB, long int mupperB, long int mlowerB, 
-                    realtype tt, realtype c_jB, 
-                    N_Vector yy, N_Vector yp,
-                    N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                    DlsMat JacB, void *user_dataB,
-                    N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B)
-{
-  idmPbData fwdPb, bckPb;
-  double *JB_data;
-  mxArray *mx_in[9], *mx_out[3];
-  long int ebandB, i;
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current rrB */
-  mx_in[6] = mxCreateDoubleScalar(c_jB);        /* current c_jB */
-  mx_in[7] = bckPb->JACfct;                     /* matlab function handle */
-  mx_in[8] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(yyB, mxGetPr(mx_in[3]), NB);
-  GetData(ypB, mxGetPr(mx_in[4]), NB);
-  GetData(rrB, mxGetPr(mx_in[5]), NB);
-
-  mexCallMATLAB(3,mx_out,9,mx_in,"idm_bjacB");
-
-  ebandB =  mupperB + mlowerB + 1;
-  JB_data = mxGetPr(mx_out[0]);
-  for (i=0;i<NB;i++)
-    memcpy(BAND_COL(JacB,i) - mupperB, JB_data + i*ebandB, ebandB*sizeof(double));
-    
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDASpilsJacB(realtype tt,
-                     N_Vector yy, N_Vector yp,
-                     N_Vector yyB, N_Vector ypB, N_Vector rrB,
-                     N_Vector vB, N_Vector JvB, 
-                     realtype c_jB, void *user_dataB, 
-                     N_Vector tmp1B, N_Vector tmp2B)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[10], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */ 
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current rrB */
-  mx_in[6] = mxCreateDoubleMatrix(NB,1,mxREAL); /* vector vB */
-  mx_in[7] = mxCreateDoubleScalar(c_jB);        /* current c_jB */ 
-  mx_in[8] = bckPb->JACfct;                     /* matlab function handle */
-  mx_in[9] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(yyB, mxGetPr(mx_in[3]), NB);
-  GetData(ypB, mxGetPr(mx_in[4]), NB);
-  GetData(rrB, mxGetPr(mx_in[5]), NB);
-  GetData(vB, mxGetPr(mx_in[6]), NB);
-
-  mexCallMATLAB(3,mx_out,10,mx_in,"idm_jtvB");
-
-  PutData(JvB, mxGetPr(mx_out[0]), NB);
-  ret = (int)*mxGetPr(mx_out[1]);
-  
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_in[7]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-
-}
-
-int mxW_IDASpilsPsetB(realtype tt, 
-                      N_Vector yy, N_Vector yp,
-                      N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                      realtype c_jB, void *user_dataB,
-                      N_Vector tmp1B, N_Vector tmp2B, 
-                      N_Vector tmp3B)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[9], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current rrB */
-  mx_in[6] = mxCreateDoubleScalar(c_jB);        /* current c_jB */
-  mx_in[7] = bckPb->PSETfct;                    /* matlab function handle */
-  mx_in[8] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(yyB, mxGetPr(mx_in[3]), NB);
-  GetData(ypB, mxGetPr(mx_in[4]), NB);
-  GetData(rrB, mxGetPr(mx_in[5]), NB);
-
-  mexCallMATLAB(2,mx_out,9,mx_in,"idm_psetB");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-
-}
-
-int mxW_IDASpilsPsolB(realtype tt, 
-                      N_Vector yy, N_Vector yp,
-                      N_Vector yyB, N_Vector ypB, N_Vector rrB, 
-                      N_Vector rvecB, N_Vector zvecB,
-                      realtype c_jB, realtype deltaB,
-                      void *user_dataB, N_Vector tmpB)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[10], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */   
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[5] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current rrB */
-  mx_in[6] = mxCreateDoubleMatrix(NB,1,mxREAL); /* right hand side rB */
-  mx_in[7] = mxCreateDoubleScalar(c_jB);        /* current c_jB */   
-  mx_in[8] = bckPb->PSOLfct;                    /* matlab function handle */
-  mx_in[9] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(yyB, mxGetPr(mx_in[3]), NB);
-  GetData(ypB, mxGetPr(mx_in[4]), NB);
-  GetData(rrB, mxGetPr(mx_in[5]), NB);
-  GetData(rvecB, mxGetPr(mx_in[6]), NB);
-
-  mexCallMATLAB(3,mx_out,10,mx_in,"idm_psolB");
-
-  PutData(zvecB, mxGetPr(mx_out[0]), NB);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_in[6]);
-  mxDestroyArray(mx_in[7]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-
-}
-
-int mxW_IDABBDglocB(long int NlocalB, realtype tt,
-                    N_Vector yy, N_Vector yp, 
-                    N_Vector yyB, N_Vector ypB, N_Vector gvalB,
-                    void *user_dataB)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[7], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[5] = bckPb->GLOCfct;                    /* matlab function handle */
-  mx_in[6] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(yyB, mxGetPr(mx_in[3]), NB);
-  GetData(ypB, mxGetPr(mx_in[4]), NB);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"idm_glocB");
-
-  PutData(gvalB, mxGetPr(mx_out[0]), NB);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_IDABBDgcomB(long int NlocalB, realtype tt,
-                    N_Vector yy, N_Vector yp,
-                    N_Vector yyB, N_Vector ypB,
-                    void *user_dataB)
-{
-  idmPbData fwdPb, bckPb;
-  mxArray *mx_in[7], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  bckPb = (idmPbData) user_dataB;
-  fwdPb = bckPb->fwd;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleScalar(tt);          /* current t */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yy */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yp */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current yyB */
-  mx_in[4] = mxCreateDoubleMatrix(NB,1,mxREAL); /* current ypB */
-  mx_in[5] = bckPb->GCOMfct;                    /* matlab function handle */
-  mx_in[6] = bckPb->mtlb_data;                  /* matlab user data */
-  
-  /* Call matlab wrapper */
-  GetData(yy, mxGetPr(mx_in[1]), N);
-  GetData(yp, mxGetPr(mx_in[2]), N);
-  GetData(yyB, mxGetPr(mx_in[3]), NB);
-  GetData(ypB, mxGetPr(mx_in[4]), NB);
-
-  mexCallMATLAB(2,mx_out,7,mx_in,"idm_gcomB");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], bckPb);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Wrapper around matlab monitor function
- * ---------------------------------------------------------------------------------
- */
-
-void mxW_IDAMonitor(int call, double t, 
-                    N_Vector yy,
-                    N_Vector yQ, 
-                    N_Vector *yyS,
-                    idmPbData fwdPb)
-{
-  mxArray *mx_in[8], *mx_out[1];
-  double *tmp_yyS;
-  int is;
-
-  mx_in[0] = mxCreateDoubleScalar(call);            /* call type (0:first, 1:interm. 2:last) */
-  mx_in[1] = mxCreateDoubleScalar(t);               /* current time */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);      /* current yy */
-  if (quadr) {
-    mx_in[3] = mxCreateDoubleMatrix(Nq,1,mxREAL);   /* current quadratures */
-  } else {
-    mx_in[3] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  mx_in[4] = mxCreateDoubleScalar(Ns);              /* number of sensitivities */
-  if (fsa) {
-    mx_in[5] = mxCreateDoubleMatrix(N*Ns,1,mxREAL); /* current yyS */
-  } else {
-    mx_in[5] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  mx_in[6] = fwdPb->MONfct;                         /* Matlab monitor function */
-  mx_in[7] = fwdPb->MONdata;                        /* data for monitor function */
-
-  if (call == 1) {
-
-    GetData(yy, mxGetPr(mx_in[2]), N);
-
-    if (quadr) {
-      GetData(yQ, mxGetPr(mx_in[3]), Nq);
-    }
-
-    if (fsa) {
-      tmp_yyS = mxGetPr(mx_in[5]);
-      for (is=0; is<Ns; is++) {
-        GetData(yyS[is], &tmp_yyS[is*N], N);
-      }
-    }
-
-  }
-
-  mexCallMATLAB(1,mx_out,8,mx_in,"idm_monitor");
-
-  if (!mxIsEmpty(mx_out[0])) {
-    UpdateMonitorData(mx_out[0], fwdPb);
-  }
-
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_in[5]);
-  mxDestroyArray(mx_out[0]);
-}
-
-void mxW_IDAMonitorB(int call, int idxB, double tB,
-                     N_Vector yyB,
-                     N_Vector yQB,
-                     idmPbData bckPb)
-{
-  mxArray *mx_in[7], *mx_out[1];
-
-  mx_in[0] = mxCreateDoubleScalar(call);            /* 0: first, 1: interm. 2: last */
-  mx_in[1] = mxCreateDoubleScalar(idxB);            /* index of current problem */
-  mx_in[2] = mxCreateDoubleScalar(tB);              /* current time */
-  mx_in[3] = mxCreateDoubleMatrix(NB,1,mxREAL);     /* current yyB */
-  if (quadrB) {
-    mx_in[4] = mxCreateDoubleMatrix(NqB,1,mxREAL);  /* current quadratures */
-  } else {
-    mx_in[4] = mxCreateDoubleMatrix(0,0,mxREAL);
-  }
-  mx_in[5] = bckPb->MONfct;
-  mx_in[6] = bckPb->MONdata;
-
-  if (call == 1) {
-    
-    GetData(yyB, mxGetPr(mx_in[3]), NB);
-
-    if (quadrB)
-      GetData(yQB, mxGetPr(mx_in[4]), NqB);
-  }
-
-  mexCallMATLAB(1,mx_out,7,mx_in,"idm_monitorB");
-
-  if (!mxIsEmpty(mx_out[0])) {
-    UpdateMonitorData(mx_out[0], bckPb);
-  }
-
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-}
-
-
-/*
- * ---------------------------------------------------------------------------------
- * Private functions to update the user data structures
- * ---------------------------------------------------------------------------------
- */
-
-static void UpdateUserData(mxArray *new_mtlb_data, idmPbData pb)
-{
-  mexUnlock();
-  mxDestroyArray(pb->mtlb_data);
-  pb->mtlb_data = mxDuplicateArray(new_mtlb_data);
-  mexMakeArrayPersistent(pb->mtlb_data);
-  mexLock();
-}
-
-static void UpdateMonitorData(mxArray *new_mtlb_data, idmPbData pb)
-{
-  mexUnlock();
-  mxDestroyArray(pb->MONdata);
-  pb->MONdata = mxDuplicateArray(new_mtlb_data);
-  mexMakeArrayPersistent(pb->MONdata);
-  mexLock();
-}
-
-
diff --git a/sundialsTB/install_STB.m b/sundialsTB/install_STB.m
deleted file mode 100644
index c93be4b..0000000
--- a/sundialsTB/install_STB.m
+++ /dev/null
@@ -1,1025 +0,0 @@
-function [] = install_STB
-%
-% INSTALL_STB Interactive compilation and installtion of sundialsTB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.23 $Date: 2009/04/22 03:34:01 $
-
-% MEX compiler command
-% --------------------
-
-mexcompiler = 'mex -v';
-
-% Location of sundialsTB and top of sundials source tree
-% ------------------------------------------------------
-
-stb = pwd;
-cd('..');
-sun = pwd;
-cd(stb);
-
-% Test mex
-% --------
-
-mex_ok = check_mex(mexcompiler);
-
-if ~mex_ok
-  return
-end
-
-% Should we enable parallel support?
-% ----------------------------------
-
-par = true;
-if isempty(getenv('LAMHOME'))
-    par = false;
-end
-if isempty(getenv('MPITB_ROOT'))
-    par = false;
-end
-q = fullfile(sun,'src','nvec_par');
-if ~exist(q, 'dir')
-    par = false;
-end
-
-% Figure out what modules exist and which ones will be built
-% ----------------------------------------------------------
-
-fprintf('\n\nSelect modules to be built\n');
-
-q = fullfile(sun,'src','cvodes');
-if exist(q, 'dir')
-  answ = input('    Compile CVODES interface? (y/n) ','s');
-  if answ == 'y'
-    cvm_ok = true;
-  else
-    cvm_ok = false;
-  end
-end
-
-if exist(q, 'dir')
-  answ = input('    Compile IDAS interface? (y/n) ','s');
-  if answ == 'y'
-    idm_ok = true;
-  else
-    idm_ok = false;
-  end
-end
-
-q = fullfile(sun,'src','kinsol');
-if exist(q, 'dir')
-  answ = input('    Compile KINSOL interface? (y/n) ','s');
-  if answ == 'y'
-    kim_ok = true;
-  else
-    kim_ok = false;
-  end
-end
-
-if ~cvm_ok && ~idm_ok && ~kim_ok
-  fprintf('\nOK. All done.\n');
-  return
-end
-
-% Create sundials_config.h
-% ------------------------
-
-mkdir('sundials');
-fi = fopen(fullfile('sundials','sundials_config.h'),'w');
-fprintf(fi,'#define SUNDIALS_PACKAGE_VERSION "2.4.0"\n');
-fprintf(fi,'#define SUNDIALS_DOUBLE_PRECISION 1\n');
-fprintf(fi,'#define SUNDIALS_USE_GENERIC_MATH 1\n');
-fprintf(fi,'#define SUNDIALS_EXPORT\n');
-fclose(fi);
-
-% Compile MEX file for the selected modules
-% -----------------------------------------
-
-if cvm_ok
-  compile_CVM(mexcompiler,stb,sun,par);
-end
-
-if idm_ok
-  compile_IDM(mexcompiler,stb,sun,par);
-end
-  
-if kim_ok
-  compile_KIM(mexcompiler,stb,sun,par);
-end
-
-% Remove sundials_config.h
-% ------------------------
-
-rmdir('sundials','s');
-
-% Install sundialsTB
-% ------------------
-
-fprintf('\n\nMEX files were successfully created.\n');
-answ = input('    Install toolbox? (y/n) ','s');
-if answ ~= 'y'
-  fprintf('\n\nOK. All done.\n');
-  return
-end
-
-while true
-  fprintf('\n\nSpecify the location where you wish to install the toolbox.\n');
-  fprintf('The toolbox will be installed in a subdirectory "sundialsTB".\n');
-  fprintf('Enter return to cancel the installation.\n');
-  where = input('    Installation directory: ','s');
-  if isempty(where)
-    go = 0;
-    break;
-  end
-  if exist(where,'dir')
-    go = 1;
-    break
-  end
-  fprintf('\n%s does not exist!\n', where);
-end
-
-if ~go
-  fprintf('\n\nOK. All done.\n');
-  return
-end
-
-stbi = fullfile(where,'sundialsTB');
-
-go = 1;
-if exist(stbi,'dir')
-  fprintf('\n\nDirectory %s exists!\n',stbi);
-  answ = input('    Replace? (y/n) ','s');
-  if answ == 'y'
-    rmdir(stbi,'s');
-    go = 1;
-  else
-    go = 0;
-  end
-end
-
-if ~go
-  fprintf('\n\nOK. All done.\n');
-  return
-end
-
-mkdir(where,'sundialsTB');
-mkdir(fullfile(where,'sundialsTB'),'nvector');
-if par
-  mkdir(fullfile(where,'sundialsTB'),'putils');
-end
-
-instSTB(stb, where, par);
-
-if cvm_ok
-  mkdir(fullfile(where,'sundialsTB'),'cvodes');
-  mkdir(fullfile(where,'sundialsTB','cvodes'),'cvm');
-  mkdir(fullfile(where,'sundialsTB','cvodes'),'function_types');
-  mkdir(fullfile(where,'sundialsTB','cvodes'),'examples_ser');
-  if par
-    mkdir(fullfile(where,'sundialsTB','cvodes'),'examples_par');
-  end
-  instCVM(stb, where, par);
-end
-
-if idm_ok
-  mkdir(fullfile(where,'sundialsTB'),'idas');
-  mkdir(fullfile(where,'sundialsTB','idas'),'idm');
-  mkdir(fullfile(where,'sundialsTB','idas'),'function_types');
-  mkdir(fullfile(where,'sundialsTB','idas'),'examples_ser');
-  if par
-    mkdir(fullfile(where,'sundialsTB','idas'),'examples_par');
-  end
-  instIDM(stb, where, par);
-end
-
-if kim_ok
-  mkdir(fullfile(where,'sundialsTB'),'kinsol');
-  mkdir(fullfile(where,'sundialsTB','kinsol'),'kim');
-  mkdir(fullfile(where,'sundialsTB','kinsol'),'function_types');
-  mkdir(fullfile(where,'sundialsTB','kinsol'),'examples_ser');
-  if par
-    mkdir(fullfile(where,'sundialsTB','kinsol'),'examples_par');
-  end
-  instKIM(stb, where, par);
-end
-  
-fprintf('\n\nThe sundialsTB toolbox was installed in %s\n',stbi);
-fprintf('\nA startup file, "startup_STB.m" was created in %s.\n',stbi);
-fprintf('Use it as your Matlab startup file, or, if you already have a startup.m file,\n');
-fprintf('add a call to %s\n',fullfile(stbi,'startup_STB.m'));
-fprintf('\nEnjoy!\n\n');
-
-%---------------------------------------------------------------------------------
-% Check if mex works and if the user accepts the current mexopts
-%---------------------------------------------------------------------------------
-
-function mex_ok = check_mex(mexcompiler)
-
-% Create a dummy file
-fid = fopen('foo.c', 'w');
-fprintf(fid,'#include "mex.h"\n');
-fprintf(fid,'void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[])\n');
-fprintf(fid,'{return;}\n');
-fclose(fid);
-
-% Run mexcompiler on foo.c
-mex_cmd = sprintf('%s foo.c', mexcompiler);
-eval(mex_cmd);
-
-% Remove dummy source file and resulting mex file
-delete('foo.c')
-delete(sprintf('foo.%s', mexext))
-
-fprintf('\n\nMEX files will be compiled and built using the above options\n');
-answ = input('    Proceed? (y/n) ','s');
-if answ == 'y'
-  mex_ok = true;
-else
-  fprintf('\n\nOK. All done.\n');
-  mex_ok = false;
-end
-
-return
-
-%---------------------------------------------------------------------------------
-% compilation of cvm MEX file
-%---------------------------------------------------------------------------------
-
-function [] = compile_CVM(mexcompiler,stb,sun,par)
-
-cvm_sources = {
-    fullfile(stb,'cvodes','cvm','src','cvm.c')
-    fullfile(stb,'cvodes','cvm','src','cvmWrap.c')
-    fullfile(stb,'cvodes','cvm','src','cvmOpts.c')
-              };
-if par
-    nvm_sources = {
-        fullfile(stb,'nvector','src','nvm_parallel.c')
-        fullfile(stb,'nvector','src','nvm_ops.c')
-                  };
-else
-    nvm_sources = {
-        fullfile(stb,'nvector','src','nvm_serial.c')
-        fullfile(stb,'nvector','src','nvm_ops.c')
-                  };
-end
-sources = '';
-for i=1:length(cvm_sources)
-    sources = sprintf('%s "%s"',sources,cvm_sources{i});
-end
-for i=1:length(nvm_sources)
-    sources = sprintf('%s "%s"',sources,nvm_sources{i});
-end
-
-cvm_incdir = fullfile(stb,'cvodes','cvm','src'); % for cvm.h
-nvm_incdir = fullfile(stb,'nvector','src');      % for nvm.h
-includes = sprintf('-I"%s" -I"%s" -I"%s"',stb,cvm_incdir,nvm_incdir);
-
-libraries = '';
-
-% Add CVODES sources and header files
-
-cvs_sources = {
-    fullfile(sun,'src','cvodes','cvodes_band.c')
-    fullfile(sun,'src','cvodes','cvodes_bandpre.c')
-    fullfile(sun,'src','cvodes','cvodes_bbdpre.c')
-    fullfile(sun,'src','cvodes','cvodes_direct.c')
-    fullfile(sun,'src','cvodes','cvodes_dense.c')
-    fullfile(sun,'src','cvodes','cvodes_diag.c')
-    fullfile(sun,'src','cvodes','cvodea.c')
-    fullfile(sun,'src','cvodes','cvodes.c')
-    fullfile(sun,'src','cvodes','cvodes_io.c')
-    fullfile(sun,'src','cvodes','cvodea_io.c')
-    fullfile(sun,'src','cvodes','cvodes_spils.c')
-    fullfile(sun,'src','cvodes','cvodes_spbcgs.c')
-    fullfile(sun,'src','cvodes','cvodes_spgmr.c')
-    fullfile(sun,'src','cvodes','cvodes_sptfqmr.c')
-              };
-shr_sources = {
-    fullfile(sun,'src','sundials','sundials_band.c')
-    fullfile(sun,'src','sundials','sundials_dense.c')
-    fullfile(sun,'src','sundials','sundials_iterative.c')
-    fullfile(sun,'src','sundials','sundials_nvector.c')
-    fullfile(sun,'src','sundials','sundials_direct.c')
-    fullfile(sun,'src','sundials','sundials_spbcgs.c')
-    fullfile(sun,'src','sundials','sundials_spgmr.c')
-    fullfile(sun,'src','sundials','sundials_sptfqmr.c')
-    fullfile(sun,'src','sundials','sundials_math.c')
-              };
-for i=1:length(cvs_sources)
-    sources = sprintf('%s "%s"',sources,cvs_sources{i});
-end
-for i=1:length(shr_sources)
-    sources = sprintf('%s "%s"',sources,shr_sources{i});
-end
-
-sun_incdir = fullfile(sun,'include');      % for SUNDIALS exported headers
-cvs_srcdir = fullfile(sun,'src','cvodes'); % for cvodes_impl.h
-includes = sprintf('%s -I"%s" -I"%s"',includes,sun_incdir,cvs_srcdir);
-
-% Add NVEC_SER sources and header files
-
-nvs_sources = fullfile(sun,'src','nvec_ser','nvector_serial.c');
-sources = sprintf('%s "%s"',sources, nvs_sources);
-
-if par
-  
-  % Add NVEC_PAR sources and header files
-
-  nvp_sources = fullfile(sun,'src','nvec_par','nvector_parallel.c');
-  sources = sprintf('%s "%s"',sources, nvp_sources);
-
-% Add LAM headers and libraries
-
-  lam = getenv('LAMHOME');
-  lam_incdir = fullfile(lam, 'include');
-  lam_libdir = fullfile(lam, 'lib');
-  includes = sprintf('%s -I"%s"',includes,lam_incdir);
-  libraries = sprintf('%s -L"%s" -lmpi -llam -lutil',libraries,lam_libdir);
-
-end
-
-% Create MEX file
-
-cvm_dir = fullfile(stb,'cvodes','cvm');
-cd(cvm_dir)
-mex_cmd = sprintf('%s %s %s %s', mexcompiler, includes, sources, libraries);
-disp(mex_cmd);
-eval(mex_cmd);
-
-% Move back to sundialsTB
-
-cd(stb)
-
-%---------------------------------------------------------------------------------
-% compilation of idm MEX file
-%---------------------------------------------------------------------------------
-
-function [] = compile_IDM(mexcompiler,stb,sun,par)
-
-idm_sources = {
-    fullfile(stb,'idas','idm','src','idm.c')
-    fullfile(stb,'idas','idm','src','idmWrap.c')
-    fullfile(stb,'idas','idm','src','idmOpts.c')
-              };
-if par
-    nvm_sources = {
-        fullfile(stb,'nvector','src','nvm_parallel.c')
-        fullfile(stb,'nvector','src','nvm_ops.c')
-                  };
-else
-    nvm_sources = {
-        fullfile(stb,'nvector','src','nvm_serial.c')
-        fullfile(stb,'nvector','src','nvm_ops.c')
-                  };
-end
-sources = '';
-for i=1:length(idm_sources)
-    sources = sprintf('%s "%s"',sources,idm_sources{i});
-end
-for i=1:length(nvm_sources)
-    sources = sprintf('%s "%s"',sources,nvm_sources{i});
-end
-
-idm_incdir = fullfile(stb,'idas','idm','src');   % for idm.h
-nvm_incdir = fullfile(stb,'nvector','src');      % for nvm.h
-includes = sprintf('-I"%s" -I"%s" -I"%s"',stb,idm_incdir,nvm_incdir);
-
-libraries = '';
-
-% Add IDAS sources and header files
-
-ids_sources = {
-    fullfile(sun,'src','idas','idas_band.c')
-    fullfile(sun,'src','idas','idas_bbdpre.c')
-    fullfile(sun,'src','idas','idas_dense.c')
-    fullfile(sun,'src','idas','idas_direct.c')
-    fullfile(sun,'src','idas','idaa.c')
-    fullfile(sun,'src','idas','idas.c')
-    fullfile(sun,'src','idas','idas_ic.c')
-    fullfile(sun,'src','idas','idas_io.c')
-    fullfile(sun,'src','idas','idaa_io.c')
-    fullfile(sun,'src','idas','idas_spils.c')
-    fullfile(sun,'src','idas','idas_spbcgs.c')
-    fullfile(sun,'src','idas','idas_spgmr.c')
-    fullfile(sun,'src','idas','idas_sptfqmr.c')
-              };
-shr_sources = {
-    fullfile(sun,'src','sundials','sundials_band.c')
-    fullfile(sun,'src','sundials','sundials_dense.c')
-    fullfile(sun,'src','sundials','sundials_iterative.c')
-    fullfile(sun,'src','sundials','sundials_nvector.c')
-    fullfile(sun,'src','sundials','sundials_direct.c')
-    fullfile(sun,'src','sundials','sundials_spbcgs.c')
-    fullfile(sun,'src','sundials','sundials_spgmr.c')
-    fullfile(sun,'src','sundials','sundials_sptfqmr.c')
-    fullfile(sun,'src','sundials','sundials_math.c')
-              };
-for i=1:length(ids_sources)
-    sources = sprintf('%s "%s"',sources,ids_sources{i});
-end
-for i=1:length(shr_sources)
-    sources = sprintf('%s "%s"',sources,shr_sources{i});
-end
-
-sun_incdir = fullfile(sun,'include');     % for SUNDIALS exported headers
-ids_srcdir = fullfile(sun,'src','idas');  % for idas_impl.h
-includes = sprintf('%s -I"%s" -I"%s"',includes,sun_incdir,ids_srcdir);
-
-% Add NVEC_SER sources and header files
-
-nvs_sources = fullfile(sun,'src','nvec_ser','nvector_serial.c');
-sources = sprintf('%s "%s"',sources, nvs_sources);
-
-if par
-  
-  % Add NVEC_PAR sources and header files
-
-  nvp_sources = fullfile(sun,'src','nvec_par','nvector_parallel.c');
-  sources = sprintf('%s "%s"',sources, nvp_sources);
-
-% Add LAM headers and libraries
-
-  lam = getenv('LAMHOME');
-  lam_incdir = fullfile(lam, 'include');
-  lam_libdir = fullfile(lam, 'lib');
-  includes = sprintf('%s -I"%s"',includes,lam_incdir);
-  libraries = sprintf('%s -L"%s" -lmpi -llam -lutil',libraries,lam_libdir);
-
-end
-
-% Create MEX file
-
-idm_dir = fullfile(stb,'idas','idm');
-cd(idm_dir)
-mex_cmd = sprintf('%s %s %s %s', mexcompiler, includes, sources, libraries);
-disp(mex_cmd);
-eval(mex_cmd);
-
-% Move back to sundialsTB
-
-cd(stb)
-
-
-%---------------------------------------------------------------------------------
-% compilation of KINSOL MEX file
-%---------------------------------------------------------------------------------
-
-function [] = compile_KIM(mexcompiler,stb,sun,par)
-
-kim_sources = {
-    fullfile(stb,'kinsol','kim','src','kim.c')
-    fullfile(stb,'kinsol','kim','src','kimWrap.c')
-    fullfile(stb,'kinsol','kim','src','kimOpts.c')
-              };
-if par
-    nvm_sources = {
-        fullfile(stb,'nvector','src','nvm_parallel.c')
-        fullfile(stb,'nvector','src','nvm_ops.c')
-                  };
-else
-    nvm_sources = {
-        fullfile(stb,'nvector','src','nvm_serial.c')
-        fullfile(stb,'nvector','src','nvm_ops.c')
-                  };
-end
-sources = '';
-for i=1:length(kim_sources)
-    sources = sprintf('%s "%s"',sources,kim_sources{i});
-end
-for i=1:length(nvm_sources)
-    sources = sprintf('%s "%s"',sources,nvm_sources{i});
-end
-
-kim_incdir = fullfile(stb,'kinsol','kim','src'); % for kim.h
-nvm_incdir = fullfile(stb,'nvector','src');      % for nvm.h
-includes = sprintf('-I"%s" -I"%s" -I"%s"',stb,kim_incdir,nvm_incdir);
-
-libraries = '';
-
-% Add KINSOL sources and header files
-
-kin_sources = {
-    fullfile(sun,'src','kinsol','kinsol_band.c')
-    fullfile(sun,'src','kinsol','kinsol_bbdpre.c')
-    fullfile(sun,'src','kinsol','kinsol_dense.c')
-    fullfile(sun,'src','kinsol','kinsol_direct.c')
-    fullfile(sun,'src','kinsol','kinsol.c')
-    fullfile(sun,'src','kinsol','kinsol_io.c')
-    fullfile(sun,'src','kinsol','kinsol_spils.c')
-    fullfile(sun,'src','kinsol','kinsol_spbcgs.c')
-    fullfile(sun,'src','kinsol','kinsol_spgmr.c')
-    fullfile(sun,'src','kinsol','kinsol_sptfqmr.c')
-              };
-shr_sources = {
-    fullfile(sun,'src','sundials','sundials_band.c')
-    fullfile(sun,'src','sundials','sundials_dense.c')
-    fullfile(sun,'src','sundials','sundials_iterative.c')
-    fullfile(sun,'src','sundials','sundials_nvector.c')
-    fullfile(sun,'src','sundials','sundials_direct.c')
-    fullfile(sun,'src','sundials','sundials_spbcgs.c')
-    fullfile(sun,'src','sundials','sundials_spgmr.c')
-    fullfile(sun,'src','sundials','sundials_sptfqmr.c')
-    fullfile(sun,'src','sundials','sundials_math.c')
-              };
-
-for i=1:length(kin_sources)
-    sources = sprintf('%s "%s"',sources,kin_sources{i});
-end
-for i=1:length(shr_sources)
-    sources = sprintf('%s "%s"',sources,shr_sources{i});
-end
-
-sun_incdir = fullfile(sun,'include');      % for SUNDIALS exported headers
-kin_srcdir = fullfile(sun,'src','kinsol'); % for kinsol_impl.h
-includes = sprintf('%s -I"%s" -I"%s"',includes,sun_incdir,kin_srcdir);
-
-% Add NVEC_SER sources and header files
-
-nvs_sources = fullfile(sun,'src','nvec_ser','nvector_serial.c');
-sources = sprintf('%s "%s"',sources, nvs_sources);
-
-if par
-  
-  % Add NVEC_PAR sources and header files
-
-  nvp_sources = fullfile(sun,'src','nvec_par','nvector_parallel.c');
-  sources = sprintf('%s "%s"',sources, nvp_sources);
-
-% Add LAM headers and libraries
-
-  lam = getenv('LAMHOME');
-  lam_incdir = fullfile(lam, 'include');
-  lam_libdir = fullfile(lam, 'lib');
-  includes = sprintf('%s -I"%s"',includes,lam_incdir);
-  libraries = sprintf('%s -L"%s" -lmpi -llam -lutil',libraries,lam_libdir);
-
-end
-
-% Create MEX file
-
-kim_dir = fullfile(stb, 'kinsol', 'kim');
-cd(kim_dir)
-mex_cmd = sprintf('%s %s %s %s', mexcompiler, includes, sources, libraries);
-disp(mex_cmd);
-eval(mex_cmd);
-
-% Move back to sundialsTB
-
-cd(stb)
-
-%---------------------------------------------------------------------------------
-% Installation of common sundialsTB files
-%---------------------------------------------------------------------------------
-
-function [] = instSTB(stb, where, par)
-
-stbi = fullfile(where,'sundialsTB');
-
-% Create startup_STB.m (use the template startup_STB.in)
-
-in_file = fullfile(stb,'startup_STB.in');
-fi = fopen(in_file,'r');
-out_file = fullfile(stbi,'startup_STB.m');
-fo = fopen(out_file,'w');
-while(~feof(fi))
-  l = fgets(fi);
-  i = strfind(l,'@STB_PATH@');
-  if ~isempty(i)
-    l = sprintf('  stb_path = ''%s'';\n',where);
-  end
-  fprintf(fo,'%s',l);
-end
-fclose(fo);
-fclose(fi);
-
-top_files = {
-    'LICENSE'
-    'Contents.m'
-            };
-
-nvm_files = {
-    fullfile('nvector','Contents.m')
-    fullfile('nvector','N_VDotProd.m')
-    fullfile('nvector','N_VL1Norm.m')
-    fullfile('nvector','N_VMax.m')
-    fullfile('nvector','N_VMaxNorm.m')
-    fullfile('nvector','N_VMin.m')
-    fullfile('nvector','N_VWL2Norm.m')
-    fullfile('nvector','N_VWrmsNorm.m')
-            };
-
-put_files = {
-    fullfile('putils','Contents.m')
-    fullfile('putils','mpistart.m')
-    fullfile('putils','mpirun.m')
-    fullfile('putils','mpiruns.m')    
-            };
-
-stb_files = [top_files ; nvm_files];
-if par
-  stb_files = [stb_files; put_files];
-end
-
-fprintf('\n\n');
-for i=1:length(stb_files)
-  src = fullfile(stb,stb_files{i});
-  dest = fullfile(stbi,stb_files{i});
-  fprintf('Install %s\n',dest);
-  [success,msg,msgid] = copyfile(src,dest);
-  if ~success
-    disp(msg);
-    break;
-  end
-end
-
-%---------------------------------------------------------------------------------
-% Installation of CVODES files
-%---------------------------------------------------------------------------------
-
-function [] = instCVM(stb, where, par)
-
-stbi = fullfile(where,'sundialsTB');
-
-% Copy files to installation directory
-
-cvmmex = ['cvm.' mexext];
-
-cvm_files = {
-    fullfile('cvodes','Contents.m')
-%
-    fullfile('cvodes','CVodeSetOptions.m')
-    fullfile('cvodes','CVodeQuadSetOptions.m')
-    fullfile('cvodes','CVodeSensSetOptions.m')
-    fullfile('cvodes','CVodeInit.m')
-    fullfile('cvodes','CVodeReInit.m')
-    fullfile('cvodes','CVodeQuadInit.m')
-    fullfile('cvodes','CVodeQuadReInit.m')
-    fullfile('cvodes','CVodeSensInit.m')
-    fullfile('cvodes','CVodeSensReInit.m')
-    fullfile('cvodes','CVode.m')
-    fullfile('cvodes','CVodeGet.m')
-    fullfile('cvodes','CVodeSet.m')
-    fullfile('cvodes','CVodeGetStats.m')
-%
-    fullfile('cvodes','CVodeAdjInit.m')
-    fullfile('cvodes','CVodeAdjReInit.m')
-%
-    fullfile('cvodes','CVodeInitB.m')
-    fullfile('cvodes','CVodeReInitB.m')
-    fullfile('cvodes','CVodeQuadInitB.m')
-    fullfile('cvodes','CVodeQuadReInitB.m')
-    fullfile('cvodes','CVodeSensToggleOff.m')
-    fullfile('cvodes','CVodeB.m')
-    fullfile('cvodes','CVodeSetB.m')
-    fullfile('cvodes','CVodeGetStatsB.m')
-%
-    fullfile('cvodes','CVodeFree.m')
-%
-    fullfile('cvodes','cvm','Contents.m')
-    fullfile('cvodes','cvm','cvm_options.m')
-%
-    fullfile('cvodes','cvm','cvm_rhs.m')
-    fullfile('cvodes','cvm','cvm_rhsQ.m')
-    fullfile('cvodes','cvm','cvm_rhsS.m')
-    fullfile('cvodes','cvm','cvm_root.m')
-    fullfile('cvodes','cvm','cvm_bjac.m')
-    fullfile('cvodes','cvm','cvm_djac.m')
-    fullfile('cvodes','cvm','cvm_jtv.m')
-    fullfile('cvodes','cvm','cvm_pset.m')
-    fullfile('cvodes','cvm','cvm_psol.m')
-    fullfile('cvodes','cvm','cvm_gcom.m')
-    fullfile('cvodes','cvm','cvm_gloc.m')
-    fullfile('cvodes','cvm','cvm_monitor.m')
-%
-    fullfile('cvodes','cvm','cvm_rhsB.m')
-    fullfile('cvodes','cvm','cvm_rhsQB.m')
-    fullfile('cvodes','cvm','cvm_bjacB.m')
-    fullfile('cvodes','cvm','cvm_djacB.m')
-    fullfile('cvodes','cvm','cvm_jtvB.m')
-    fullfile('cvodes','cvm','cvm_psetB.m')
-    fullfile('cvodes','cvm','cvm_psolB.m')
-    fullfile('cvodes','cvm','cvm_gcomB.m')
-    fullfile('cvodes','cvm','cvm_glocB.m')
-    fullfile('cvodes','cvm','cvm_monitorB.m')
-%
-    fullfile('cvodes','cvm',cvmmex)    
-            };
-
-cvm_ftypes = {
-    fullfile('cvodes','function_types','CVRhsFn.m')
-    fullfile('cvodes','function_types','CVQuadRhsFn.m')
-    fullfile('cvodes','function_types','CVSensRhsFn.m')
-    fullfile('cvodes','function_types','CVRootFn.m')
-    fullfile('cvodes','function_types','CVBandJacFn.m')
-    fullfile('cvodes','function_types','CVDenseJacFn.m')
-    fullfile('cvodes','function_types','CVJacTimesVecFn.m')
-    fullfile('cvodes','function_types','CVPrecSetupFn.m')
-    fullfile('cvodes','function_types','CVPrecSolveFn.m')
-    fullfile('cvodes','function_types','CVGcommFn.m')
-    fullfile('cvodes','function_types','CVGlocalFn.m')
-    fullfile('cvodes','function_types','CVMonitorFn.m')
-%
-    fullfile('cvodes','function_types','CVRhsFnB.m')
-    fullfile('cvodes','function_types','CVQuadRhsFnB.m')
-    fullfile('cvodes','function_types','CVBandJacFnB.m')
-    fullfile('cvodes','function_types','CVDenseJacFnB.m')
-    fullfile('cvodes','function_types','CVJacTimesVecFnB.m')
-    fullfile('cvodes','function_types','CVPrecSetupFnB.m')
-    fullfile('cvodes','function_types','CVPrecSolveFnB.m')
-    fullfile('cvodes','function_types','CVGcommFnB.m')
-    fullfile('cvodes','function_types','CVGlocalFnB.m')
-    fullfile('cvodes','function_types','CVMonitorFnB.m')
-             };    
-
-cvm_exs = {
-    fullfile('cvodes','examples_ser','mcvsAdvDiff_bnd.m')
-    fullfile('cvodes','examples_ser','mcvsDiscRHS_dns.m')
-    fullfile('cvodes','examples_ser','mcvsDiscSOL_dns.m')
-    fullfile('cvodes','examples_ser','mcvsDiurnal_kry.m')
-    fullfile('cvodes','examples_ser','mcvsHessian_FSA_ASA.m')
-    fullfile('cvodes','examples_ser','mcvsOzone_FSA_dns.m')
-    fullfile('cvodes','examples_ser','mcvsPleiades_non.m')
-    fullfile('cvodes','examples_ser','mcvsPollut_FSA_dns.m')
-    fullfile('cvodes','examples_ser','mcvsRoberts_ASAi_dns.m')
-    fullfile('cvodes','examples_ser','mcvsRoberts_dns.m')
-    fullfile('cvodes','examples_ser','mcvsRoberts_FSA_dns.m')
-    fullfile('cvodes','examples_ser','mcvsVanDPol_dns.m')
-          };
-
-cvm_exp = {
-    fullfile('cvodes','examples_par','mcvsAdvDiff_FSA_non_p.m')
-    fullfile('cvodes','examples_par','mcvsAtmDisp_kry_bbd_p.m')
-    fullfile('cvodes','examples_par','mcvsDecoupl_non_p.m')
-          };
-
-stb_files = [cvm_files ; cvm_ftypes ; cvm_exs];
-if par
-  stb_files = [stb_files ; cvm_exp];
-end
-
-fprintf('\n\n');
-for i=1:length(stb_files)
-  src = fullfile(stb,stb_files{i});
-  dest = fullfile(stbi,stb_files{i});
-  fprintf('Install %s\n',dest);
-  [success,msg,msgid] = copyfile(src,dest);
-  if ~success
-    disp(msg);
-    break;
-  end
-end
-
-if (exist ('OCTAVE_VERSION'))
-  cvmon = fullfile('cvodes','CVodeMonitor_octave.m');
-  cvmonB = fullfile('cvodes','CVodeMonitorB_octave.m');
-else
-  cvmon = fullfile('cvodes','CVodeMonitor.m');
-  cvmonB = fullfile('cvodes','CVodeMonitorB.m');
-end
-
-src = fullfile(stb,cvmon);
-dest = fullfile(stbi,'cvodes','CVodeMonitor.m');
-fprintf('Install %s\n',dest);
-[success,msg,msgid] = copyfile(src,dest);
-if ~success
-  disp(msg);
-end
-
-src = fullfile(stb,cvmonB);
-dest = fullfile(stbi,'cvodes','CVodeMonitorB.m');
-fprintf('Install %s\n',dest);
-[success,msg,msgid] = copyfile(src,dest);
-if ~success
-  disp(msg);
-end
-
-%---------------------------------------------------------------------------------
-% Installation of IDAS files
-%---------------------------------------------------------------------------------
-
-function [] = instIDM(stb, where, par)
-
-stbi = fullfile(where,'sundialsTB');
-
-% Copy files to installation directory
-
-idmmex = ['idm.' mexext];
-
-idm_files = {
-    fullfile('idas','Contents.m')
-%
-    fullfile('idas','IDASetOptions.m')
-    fullfile('idas','IDAQuadSetOptions.m')
-    fullfile('idas','IDASensSetOptions.m')
-    fullfile('idas','IDAInit.m')
-    fullfile('idas','IDAReInit.m')
-    fullfile('idas','IDAQuadInit.m')
-    fullfile('idas','IDAQuadReInit.m')
-    fullfile('idas','IDASensInit.m')
-    fullfile('idas','IDASensReInit.m')
-    fullfile('idas','IDASensToggleOff.m')
-    fullfile('idas','IDAAdjReInit.m')
-    fullfile('idas','IDACalcIC.m')
-    fullfile('idas','IDASolve.m')
-    fullfile('idas','IDASet.m')
-    fullfile('idas','IDAGet.m')
-    fullfile('idas','IDAGetStats.m')
-%
-    fullfile('idas','IDAAdjInit.m')
-%
-    fullfile('idas','IDAInitB.m')
-    fullfile('idas','IDAReInitB.m')
-    fullfile('idas','IDAQuadInitB.m')
-    fullfile('idas','IDAQuadReInitB.m')
-    fullfile('idas','IDACalcICB.m')
-    fullfile('idas','IDASolveB.m')
-    fullfile('idas','IDASetB.m')
-    fullfile('idas','IDAGetStatsB.m')
-%
-    fullfile('idas','IDAFree.m')
-%
-    fullfile('idas','idm','Contents.m')
-    fullfile('idas','idm','idm_options.m')
-%
-    fullfile('idas','idm','idm_res.m')
-    fullfile('idas','idm','idm_rhsQ.m')
-    fullfile('idas','idm','idm_bjac.m')
-    fullfile('idas','idm','idm_djac.m')
-    fullfile('idas','idm','idm_gcom.m')
-    fullfile('idas','idm','idm_gloc.m')
-    fullfile('idas','idm','idm_jtv.m')
-    fullfile('idas','idm','idm_pset.m')
-    fullfile('idas','idm','idm_psol.m')
-    fullfile('idas','idm','idm_root.m')
-    fullfile('idas','idm','idm_resS.m')
-    fullfile('idas','idm','idm_monitor.m')
-%
-    fullfile('idas','idm','idm_resB.m')
-    fullfile('idas','idm','idm_rhsQB.m')
-    fullfile('idas','idm','idm_bjacB.m')
-    fullfile('idas','idm','idm_djacB.m')
-    fullfile('idas','idm','idm_jtvB.m')
-    fullfile('idas','idm','idm_psetB.m')
-    fullfile('idas','idm','idm_psolB.m')
-    fullfile('idas','idm','idm_gcomB.m')
-    fullfile('idas','idm','idm_glocB.m')
-    fullfile('idas','idm','idm_monitorB.m')
-%
-    fullfile('idas','idm',idmmex)    
-            };
-
-idm_ftypes = {
-    fullfile('idas','function_types','IDABandJacFn.m')
-    fullfile('idas','function_types','IDABandJacFnB.m')
-    fullfile('idas','function_types','IDADenseJacFn.m')
-    fullfile('idas','function_types','IDADenseJacFnB.m')
-    fullfile('idas','function_types','IDAGcommFn.m')
-    fullfile('idas','function_types','IDAGcommFnB.m')
-    fullfile('idas','function_types','IDAGlocalFn.m')
-    fullfile('idas','function_types','IDAGlocalFnB.m')
-    fullfile('idas','function_types','IDAJacTimesVecFn.m')
-    fullfile('idas','function_types','IDAJacTimesVecFnB.m')
-    fullfile('idas','function_types','IDAMonitorFn.m')
-    fullfile('idas','function_types','IDAMonitorFnB.m')
-    fullfile('idas','function_types','IDAPrecSetupFn.m')
-    fullfile('idas','function_types','IDAPrecSetupFnB.m')
-    fullfile('idas','function_types','IDAPrecSolveFn.m')
-    fullfile('idas','function_types','IDAPrecSolveFnB.m')
-    fullfile('idas','function_types','IDAQuadRhsFn.m')
-    fullfile('idas','function_types','IDAQuadRhsFnB.m')
-    fullfile('idas','function_types','IDAResFn.m')
-    fullfile('idas','function_types','IDAResFnB.m')
-    fullfile('idas','function_types','IDARootFn.m')
-    fullfile('idas','function_types','IDASensResFn.m')
-             };
-
-idm_exs = {
-    fullfile('idas','examples_ser','midasBruss_ASA_dns.m')
-    fullfile('idas','examples_ser','midasBruss_dns.m')
-    fullfile('idas','examples_ser','midasHeat2D_bnd.m')
-    fullfile('idas','examples_ser','midasPendI1_dns.m')
-    fullfile('idas','examples_ser','midasPendI2_dns.m')
-    fullfile('idas','examples_ser','midasReInit_dns.m')
-    fullfile('idas','examples_ser','midasRoberts_ASAi_dns.m')
-    fullfile('idas','examples_ser','midasRoberts_dns.m')
-    fullfile('idas','examples_ser','midasSlCrank_dns.m')
-    fullfile('idas','examples_ser','midasSlCrank_FSA_dns.m')
-          };
-
-stb_files = [idm_files ; idm_ftypes ; idm_exs];
-%if par
-%  stb_files = [stb_files ; idm_exp];
-%end
-
-fprintf('\n\n');
-for i=1:length(stb_files)
-  src = fullfile(stb,stb_files{i});
-  dest = fullfile(stbi,stb_files{i});
-  fprintf('Install %s\n',dest);
-  [success,msg,msgid] = copyfile(src,dest);
-  if ~success
-    disp(msg);
-    break;
-  end
-end
-
-if (exist ('OCTAVE_VERSION'))
-  idamon = fullfile('idas','IDAMonitor_octave.m');
-  idamonB = fullfile('idas','IDAMonitorB_octave.m');
-else
-  idamon = fullfile('idas','IDAMonitor.m');
-  idamonB = fullfile('idas','IDAMonitorB.m');
-end
-
-src = fullfile(stb,idamon);
-dest = fullfile(stbi,'idas','IDAMonitor.m');
-fprintf('Install %s\n',dest);
-[success,msg,msgid] = copyfile(src,dest);
-if ~success
-  disp(msg);
-end
-
-src = fullfile(stb,idamonB);
-dest = fullfile(stbi,'idas','IDAMonitorB.m');
-fprintf('Install %s\n',dest);
-[success,msg,msgid] = copyfile(src,dest);
-if ~success
-  disp(msg);
-end
-
-
-
-%---------------------------------------------------------------------------------
-% Installation of KINSOL files
-%---------------------------------------------------------------------------------
-
-function [] = instKIM(stb, where, par)
-
-stbi = fullfile(where,'sundialsTB');
-
-% Copy files to installation directory
-
-kimmex = ['kim.' mexext];
-
-kim_files = {
-    fullfile('kinsol','Contents.m')
-    fullfile('kinsol','KINFree.m')
-    fullfile('kinsol','KINGetStats.m')
-    fullfile('kinsol','KINInit.m')
-    fullfile('kinsol','KINSetOptions.m')
-    fullfile('kinsol','KINSol.m')
-    fullfile('kinsol','kim','Contents.m')
-    fullfile('kinsol','kim','kim_bjac.m')
-    fullfile('kinsol','kim','kim_djac.m')
-    fullfile('kinsol','kim','kim_gcom.m')
-    fullfile('kinsol','kim','kim_gloc.m')
-    fullfile('kinsol','kim','kim_info.m')
-    fullfile('kinsol','kim','kim_jtv.m')
-    fullfile('kinsol','kim','kim_pset.m')
-    fullfile('kinsol','kim','kim_psol.m')
-    fullfile('kinsol','kim','kim_sys.m')
-    fullfile('kinsol','kim',kimmex)
-            };
-
-kim_ftypes = {
-    fullfile('kinsol','function_types','KINSysFn.m')
-    fullfile('kinsol','function_types','KINBandJacFn.m')
-    fullfile('kinsol','function_types','KINDenseJacFn.m')
-    fullfile('kinsol','function_types','KINJacTimesVecFn.m')
-    fullfile('kinsol','function_types','KINPrecSetupFn.m')
-    fullfile('kinsol','function_types','KINPrecSolveFn.m')
-    fullfile('kinsol','function_types','KINGcommFn.m')
-    fullfile('kinsol','function_types','KINGlocalFn.m')
-             };
-
-kim_exs = {
-    fullfile('kinsol','examples_ser','mkinDiagon_kry.m')
-    fullfile('kinsol','examples_ser','mkinTest_dns.m')
-    fullfile('kinsol','examples_ser','mkinFerTron_dns.m')
-    fullfile('kinsol','examples_ser','mkinRoboKin_dns.m')
-          };
-
-kim_exp = {
-    fullfile('kinsol','examples_par','mkinDiagon_kry_p.m') 
-          };
-
-stb_files = [kim_files ; kim_ftypes ; kim_exs];
-if par
-  stb_files = [stb_files ; kim_exp];
-end
-
-fprintf('\n\n');
-for i=1:length(stb_files)
-  src = fullfile(stb,stb_files{i});
-  dest = fullfile(stbi,stb_files{i});
-  fprintf('Install %s\n',dest);
-  [success,msg,msgid] = copyfile(src,dest);
-  if ~success
-    disp(msg);
-    break;
-  end
-end
-
-
diff --git a/sundialsTB/kinsol/Contents.m b/sundialsTB/kinsol/Contents.m
deleted file mode 100644
index 1620ffd..0000000
--- a/sundialsTB/kinsol/Contents.m
+++ /dev/null
@@ -1,28 +0,0 @@
-% KINSOL, nonlinear system solver
-%
-% Functions
-%   KINSetOptions - creates an options structure for KINSOL.
-%   KINInit       - allocates and initializes memory for KINSOL.
-%   KINSol        - solves the nonlinear problem.
-%   KINGetStats   - returns statistics for the KINSOL solver
-%   KINFree       - deallocates memory for the KINSOL solver.
-%
-% User-supplied function types   
-%   KINSysFn         -  system function
-%   KINDenseJacFn    -  dense Jacobian function
-%   KINJacTimesVecFn -  Jacobian times vector function
-%   KINPrecSetupFn   -  preconditioner setup function
-%   KINPrecSolveFn   -  preconditioner solve function
-%   KINGlocalFn      -  RHS approximation function (BBDPre)
-%   KINGcomFn        -  communication function (BBDPre)
-%
-% Serial examples
-%   mkinDiagon_kry - simple serial diagonal example
-%   mkinTest_dns   - simple 2 dimensional example
-%   mkinRoboKin    - robot kinematics problem
-%
-% Parallel examples
-%   mkinDiagon_kry_p - simple parallel diagonal example
-% Use the mpirun function to run any of the parallel examples
-%
-% See also nvector, putils
diff --git a/sundialsTB/kinsol/KINFree.m b/sundialsTB/kinsol/KINFree.m
deleted file mode 100644
index b6780bd..0000000
--- a/sundialsTB/kinsol/KINFree.m
+++ /dev/null
@@ -1,11 +0,0 @@
-function KINFree()
-%KINFree deallocates memory for the KINSOL solver.
-%
-%   Usage:  KINFree
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-mode = 6;
-kim(mode);
diff --git a/sundialsTB/kinsol/KINGetStats.m b/sundialsTB/kinsol/KINGetStats.m
deleted file mode 100644
index ffa548c..0000000
--- a/sundialsTB/kinsol/KINGetStats.m
+++ /dev/null
@@ -1,44 +0,0 @@
-function [si, status] = KINGetStats()
-%KINGetStats returns statistics for the main KINSOL solver and the linear
-%solver used.
-%
-%   Usage: STATS = KINGetStats
-%
-%Fields in the structure STATS
-%
-%o nfe    - total number evaluations of the nonlinear system function SYSFUN
-%o nni    - total number of nonlinear iterations
-%o nbcf   - total number of beta-condition failures
-%o nbops  - total number of backtrack operations (step length adjustments) 
-%           performed by the line search algorithm 
-%o fnorm  - scaled norm of the nonlinear system function f(y) evaluated at the
-%           current iterate: ||fscale*f(y)||_L2
-%o step   - scaled norm (or length) of the step used during the previous 
-%           iteration: ||uscale*p||_L2
-%o LSInfo - structure with linear solver statistics
-%
-%The structure LSinfo has different fields, depending on the linear solver used.
-%
-%  Fields in LSinfo for the 'Dense' linear solver
-%
-%o name - 'Dense'
-%o njeD - number of Jacobian evaluations
-%o nfeD - number of right-hand side function evaluations for difference-quotient
-%         Jacobian approximation
-%
-%  Fields in LSinfo for the 'GMRES' or 'BiCGStab' linear solver
-%
-%o name - 'GMRES' or 'BiCGStab'
-%o nli  - number of linear solver iterations
-%o npe  - number of preconditioner setups
-%o nps  - number of preconditioner solve function calls
-%o ncfl - number of linear system convergence test failures
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-
-mode = 3;
-[si, status] = kim(mode);
diff --git a/sundialsTB/kinsol/KINInit.m b/sundialsTB/kinsol/KINInit.m
deleted file mode 100644
index 3fa9ded..0000000
--- a/sundialsTB/kinsol/KINInit.m
+++ /dev/null
@@ -1,29 +0,0 @@
-function status = KINInit(fct, n, options)
-%KINInit allocates and initializes memory for KINSOL.
-%
-%   Usage:   KINInit ( SYSFUN, N [, OPTIONS ] );
-%
-%   SYSFUN   is a function defining the nonlinear problem f(y) = 0.
-%            This function must return a column vector FY containing the
-%            current value of the residual
-%   N        is the (local) problem dimension.
-%   OPTIONS  is an (optional) set of integration options, created with
-%            the KINSetOptions function. 
-%
-%   See also: KINSetOptions, KINSysFn 
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/12/05 21:58:19 $
-
-mode = 1;
-
-if nargin < 2
-  error('Too few input arguments');
-end
-
-if nargin < 3
-  options = [];
-end
-
-status = kim(mode, fct, n, options);
diff --git a/sundialsTB/kinsol/KINSetOptions.m b/sundialsTB/kinsol/KINSetOptions.m
deleted file mode 100644
index 29be3e2..0000000
--- a/sundialsTB/kinsol/KINSetOptions.m
+++ /dev/null
@@ -1,336 +0,0 @@
-function options = KINSetOptions(varargin)
-%KINSetOptions creates an options structure for KINSOL.
-%
-%   Usage:
-%
-%   options = KINSetOptions('NAME1',VALUE1,'NAME2',VALUE2,...) creates a KINSOL
-%   options structure options in which the named properties have the
-%   specified values. Any unspecified properties have default values. It is
-%   sufficient to type only the leading characters that uniquely identify the
-%   property. Case is ignored for property names. 
-%   
-%   options = KINSetOptions(oldoptions,'NAME1',VALUE1,...) alters an existing 
-%   options structure oldoptions.
-%   
-%   options = KINSetOptions(oldoptions,newoptions) combines an existing options 
-%   structure oldoptions with a new options structure newoptions. Any new 
-%   properties overwrite corresponding old properties. 
-%   
-%   KINSetOptions with no input arguments displays all property names and their
-%   possible values.
-%   
-%KINSetOptions properties
-%(See also the KINSOL User Guide)
-% 
-%UserData - User data passed unmodified to all functions [ empty ]
-%   If UserData is not empty, all user provided functions will be
-%   passed the problem data as their last input argument. For example,
-%   the SYS function must be defined as FY = SYSFUN(Y,DATA). 
-%
-%MaxNumIter - maximum number of nonlinear iterations [ scalar | {200} ]
-%   Specifies the maximum number of iterations that the nonlinar solver is allowed
-%   to take.
-%FuncRelErr - relative residual error [ scalar | {eps} ]
-%   Specifies the realative error in computing f(y) when used in difference
-%   quotient approximation of matrix-vector product J(y)*v.
-%FuncNormTol - residual stopping criteria [ scalar | {eps^(1/3)} ]
-%   Specifies the stopping tolerance on ||fscale*ABS(f(y))||_L-infinity
-%ScaledStepTol - step size stopping criteria [ scalar | {eps^(2/3)} ]
-%   Specifies the stopping tolerance on the maximum scaled step length:
-%                    ||    y_(k+1) - y_k   ||
-%                    || ------------------ ||_L-infinity
-%                    || |y_(k+1)| + yscale ||
-%MaxNewtonStep - maximum Newton step size [ scalar | {0.0} ]
-%   Specifies the maximum allowable value of the scaled length of the Newton step.
-%InitialSetup - initial call to linear solver setup [ false | {true} ]
-%   Specifies whether or not KINSol makes an initial call to the linear solver 
-%   setup function.
-%MaxNumSetups - [ scalar | {10} ]
-%   Specifies the maximum number of nonlinear iterations between calls to the
-%   linear solver setup function (i.e. Jacobian/preconditioner evaluation)
-%MaxNumSubSetups - [ scalar | {5} ]
-%   Specifies the maximum number of nonlinear iterations between checks by the 
-%   nonlinear residual monitoring algorithm (specifies length of subintervals).
-%   NOTE: MaxNumSetups should be a multiple of MaxNumSubSetups.
-%MaxNumBetaFails - maximum number of beta-condition failures [ scalar | {10} ]
-%   Specifies the maximum number of beta-condiiton failures in the line search
-%   algorithm.
-%EtaForm - Inexact Newton method [ Constant | Type2 | {Type1} ]
-%   Specifies the method for computing the eta coefficient used in the calculation
-%   of the linear solver convergence tolerance (used only if strategy='InexactNEwton'
-%   in the call to KINSol):
-%      lintol = (eta + eps)*||fscale*f(y)||_L2
-%   which is the used to check if the following inequality is satisfied:
-%      ||fscale*(f(y)+J(y)*p)||_L2 <= lintol
-%   Valid choices are:
-%                          | ||f(y_(k+1))||_L2 - ||f(y_k)+J(y_k)*p_k||_L2 |
-%   EtaForm='Type1'  eta = ------------------------------------------------
-%                                        ||f(y_k)||_L2
-%
-%                                  [ ||f(y_(k+1))||_L2 ]^alpha
-%   EtaForm='Type2'  eta = gamma * [ ----------------- ]
-%                                  [  ||f(y_k)||_L2    ]
-%   EtaForm='Constant'
-%Eta - constant value for eta [ scalar | {0.1} ]
-%   Specifies the constant value for eta in the case EtaForm='Constant'.
-%EtaAlpha - alpha parameter for eta [ scalar | {2.0} ]
-%   Specifies the parameter alpha in the case EtaForm='Type2'
-%EtaGamma - gamma parameter for eta [ scalar | {0.9} ]
-%   Specifies the parameter gamma in the case EtaForm='Type2'
-%MinBoundEps - lower bound on eps [ false | {true} ]
-%   Specifies whether or not the value of eps is bounded below by 0.01*FuncNormtol.
-%Constraints - solution constraints [ vector ]
-%   Specifies additional constraints on the solution components.
-%     Constraints(i) =  0 : no constrain on y(i)
-%     Constraints(i) =  1 : y(i) >= 0
-%     Constraints(i) = -1 : y(i) <= 0
-%     Constraints(i) =  2 : y(i) > 0
-%     Constraints(i) = -2 : y(i) < 0
-%   If Constraints is not specified, no constraints are applied to y.
-%
-%LinearSolver - Type of linear solver [ {Dense} | Band | GMRES | BiCGStab | TFQMR ]
-%   Specifies the type of linear solver to be used for the Newton nonlinear solver. 
-%   Valid choices are: Dense (direct, dense Jacobian), GMRES (iterative, scaled 
-%   preconditioned GMRES), BiCGStab (iterative, scaled preconditioned stabilized 
-%   BiCG), TFQMR (iterative, scaled preconditioned transpose-free QMR).
-%   The GMRES, BiCGStab, and TFQMR are matrix-free linear solvers.
-%JacobianFn - Jacobian function [ function ]
-%   This propeerty is overloaded. Set this value to a function that returns 
-%   Jacobian information consistent with the linear solver used (see Linsolver). 
-%   If not specified, KINSOL uses difference quotient approximations. 
-%   For the Dense linear solver, JacobianFn must be of type KINDenseJacFn and must 
-%   return a dense Jacobian matrix. For the iterative linear solvers, GMRES,
-%   BiCGStab, or TFQMR, JacobianFn must be of type KINJactimesVecFn and must return 
-%   a Jacobian-vector product.
-%KrylovMaxDim - Maximum number of Krylov subspace vectors [ scalar | {10} ]
-%   Specifies the maximum number of vectors in the Krylov subspace. This property 
-%   is used only if an iterative linear solver, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver).
-%MaxNumRestarts - Maximum number of GMRES restarts [ scalar | {0} ]
-%   Specifies the maximum number of times the GMRES (see LinearSolver) solver
-%   can be restarted.
-%PrecModule - Built-in preconditioner module [ BBDPre | {UserDefined} ]
-%   If the PrecModule = 'UserDefined', then the user must provide at least a 
-%   preconditioner solve function (see PrecSolveFn)
-%   KINSOL provides a built-in preconditioner module, BBDPre which can only be used
-%   with parallel vectors. It provide a preconditioner matrix that is block-diagonal 
-%   with banded blocks. The blocking corresponds to the distribution of the variable 
-%   vector among the processors. Each preconditioner block is generated from the 
-%   Jacobian of the local part (on the current processor) of a given function g(t,y) 
-%   approximating f(y) (see GlocalFn). The blocks are generated by a difference 
-%   quotient scheme on each processor independently. This scheme utilizes an assumed 
-%   banded structure with given half-bandwidths, mldq and mudq (specified through 
-%   LowerBwidthDQ and UpperBwidthDQ, respectively). However, the banded Jacobian 
-%   block kept by the scheme has half-bandwiths ml and mu (specified through 
-%   LowerBwidth and UpperBwidth), which may be smaller.
-%PrecSetupFn - Preconditioner setup function [ function ]
-%   PrecSetupFn specifies an optional function which, together with PrecSolve, 
-%   defines a right preconditioner matrix which is an aproximation
-%   to the Newton matrix. PrecSetupFn must be of type KINPrecSetupFn. 
-%PrecSolveFn - Preconditioner solve function [ function ]
-%   PrecSolveFn specifies an optional function which must solve a linear system 
-%   Pz = r, for given r. If PrecSolveFn is not defined, the no preconditioning will
-%   be used. PrecSolveFn must be of type KINPrecSolveFn.
-%GlocalFn - Local right-hand side approximation funciton for BBDPre [ function ]
-%   If PrecModule is BBDPre, GlocalFn specifies a required function that
-%   evaluates a local approximation to the system function. GlocalFn must
-%   be of type KINGlocalFn.
-%GcommFn - Inter-process communication function for BBDPre [ function ]
-%   If PrecModule is BBDPre, GcommFn specifies an optional function
-%   to perform any inter-process communication required for the evaluation of
-%   GlocalFn. GcommFn must be of type KINGcommFn.
-%LowerBwidth - Jacobian/preconditioner lower bandwidth [ scalar | {0} ]
-%   This property is overloaded. If the Band linear solver is used (see LinSolver),
-%   it specifies the lower half-bandwidth of the band Jacobian approximation. 
-%   If one of the three iterative linear solvers, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver) and if the BBDPre preconditioner module in KINSOL is used 
-%   (see PrecModule), it specifies the lower half-bandwidth of the retained 
-%   banded approximation of the local Jacobian block.
-%   LowerBwidth defaults to 0 (no sub-diagonals).
-%UpperBwidth - Jacobian/preconditioner upper bandwidth [ scalar | {0} ]
-%   This property is overloaded. If the Band linear solver is used (see LinSolver),
-%   it specifies the upper half-bandwidth of the band Jacobian approximation. 
-%   If one of the three iterative linear solvers, GMRES, BiCGStab, or TFQMR is used 
-%   (see LinSolver) and if the BBDPre preconditioner module in KINSOL is used 
-%   (see PrecModule), it specifies the upper half-bandwidth of the retained 
-%   banded approximation of the local Jacobian block. 
-%   UpperBwidth defaults to 0 (no super-diagonals).
-%LowerBwidthDQ - BBDPre preconditioner DQ lower bandwidth [ scalar | {0} ]
-%   Specifies the lower half-bandwidth used in the difference-quotient Jacobian
-%   approximation for the BBDPre preconditioner (see PrecModule).
-%UpperBwidthDQ - BBDPre preconditioner DQ upper bandwidth [ scalar | {0} ]
-%   Specifies the upper half-bandwidth used in the difference-quotient Jacobian
-%   approximation for the BBDPre preconditioner (see PrecModule).
-%
-%Verbose - verbose output [ true | {false} ]
-%   Specifies whether or not KINSOL should output additional information
-%ErrorMessages - Post error/warning messages [ false | {true} ]
-%   Note that any errors in KINInit will result in a Matlab error, thus
-%   stoping execution. Only subsequent calls to KINSOL functions will respect
-%   the value specified for 'ErrorMessages'.
-%
-%   See also
-%        KINDenseJacFn, KINJacTimesVecFn
-%        KINPrecSetupFn, KINPrecSolveFn
-%        KINGlocalFn, KINGcommFn
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.5 $Date: 2011/06/01 21:11:01 $
-
-% Based on Matlab's ODESET function
-
-% Print out possible values of properties.
-if (nargin == 0) & (nargout == 0)
-  fprintf('        UserData: [ empty ]\n');
-  fprintf('\n');
-  fprintf('      MaxNumIter: [ scalar | {200} ]\n');
-  fprintf('      FuncRelErr: [ scalar | {eps} ]\n');
-  fprintf('     FuncNormTol: [ scalar | {eps^(1/3)} ]\n');
-  fprintf('   ScaledStepTol: [ scalar | {eps^(2/3)} ]\n');
-  fprintf('   MaxNewtonStep: [ scalar | {0.0} ]\n');
-  fprintf('    InitialSetup: [ false | {true} ]\n');
-  fprintf('    MaxNumSetups: [ scalar | {10} ]\n');
-  fprintf(' MaxNumSubSetups: [ scalar | {5} ]\n');  
-  fprintf(' MaxNumBetaFails: [ scalar | {10} ]\n');
-  fprintf('         EtaForm: [ Constant | Type2 | {Type1} ]\n');
-  fprintf('             Eta: [ scalar | {0.1} ]\n');
-  fprintf('        EtaAlpha: [ scalar | {2.0} ]\n');
-  fprintf('        EtaGamma: [ scalar | {0.9} ]\n');
-  fprintf('     MinBoundEps: [ false | {true} ]\n');
-  fprintf('     Constraints: [ array of scalar ]\n');
-  fprintf('\n');
-  fprintf('    LinearSolver: [ {Dense} | Band | GMRES | BiCGStab | TFQMR ]\n');
-  fprintf('      JacobianFn: [ function ]\n');
-  fprintf('    KrylovMaxDim: [ scalar | {10} ]');
-  fprintf('  MaxNumRestarts: [ Classical | {Modified} ]\n');
-  fprintf('      PrecModule: [ BBDPre | {UserDefined} ]\n');
-  fprintf('     PrecSetupFn: [ function ]\n');
-  fprintf('     PrecSolveFn: [ function ]\n');
-  fprintf('        GlocalFn: [ function ]\n');
-  fprintf('         GcommFn: [ function ]\n');
-  fprintf('     LowerBwidth: [ scalar | {0} ]\n');
-  fprintf('     UpperBwidth: [ scalar | {0} ]\n');
-  fprintf('   LowerBwidthDQ: [ scalar | {0} ]\n');
-  fprintf('   UpperBwidthDQ: [ scalar | {0} ]\n');
-  fprintf('\n');
-  fprintf('         Verbose: [ true | {false} ]\n');
-  fprintf('   ErrorMessages: [ false | {true} ]\n');
-  fprintf('\n');
-  return;
-end
-
-KeyNames = {
-    'UserData'
-    'MaxNumIter'
-    'MaxNumSetups'
-    'MaxNumSubSetups'
-    'MaxNumBetaFails'
-    'EtaForm'
-    'Eta'
-    'EtaAlpha'
-    'EtaGamma'
-    'MaxNewtonStep'
-    'FuncRelErr'
-    'FuncNormTol'
-    'ScaledStepTol'
-    'InitialSetup'
-    'MinBoundEps'
-    'Constraints'
-    'LinearSolver'
-    'JacobianFn'
-    'PrecType'
-    'PrecModule'
-    'PrecSetupFn'
-    'PrecSolveFn'
-    'GlocalFn'
-    'GcommFn'
-    'KrylovMaxDim'
-    'MaxNumRestarts'
-    'LowerBwidthDQ'
-    'UpperBwidthDQ'
-    'LowerBwidth'
-    'UpperBwidth'
-    'Verbose'
-    'ErrorMessages'
-    };
-
-
-options = cvm_options(KeyNames,varargin{:});
-
-return;
-
-
-%
-% Actual option processing
-% ------------------------
-
-function options = kim_options(KeyNames, varargin)
-
-m = length(KeyNames);
-
-% Initialize the output options structure
-
-options = [];
-for i = 1:m
-  options.(KeyNames{i}) = [];
-end
-
-% If the first argument is an options structure, read its non-empty fields
-% and update options. Store in j the start of key-value pairs.
-
-arg = varargin{1};
-
-if isa(arg,'struct')
-  for i = 1:m
-    if isfield(arg,KeyNames{i})
-      options.(KeyNames{i}) = arg.(KeyNames{i});
-    end
-  end
-  j = 2;
-else
-  j = 1;  
-end
-
-% The remaining input arguments must be key-value pairs
-
-if rem(nargin-j,2) ~= 0
-  error('Arguments must be key-value pairs.');
-end
-
-% Process each key-value pair
-
-np = (nargin-j)/2;
-
-keynames = lower(KeyNames);
-
-for i = 1:np
-  
-  % Get the key
-  key = varargin{j};
-  
-  % key must be a string 
-  if ~isstr(key)
-    error(sprintf('Argument %d is not a string property name.', j));
-  end
-  
-  % Get the index in keynames that exactly matches the current key
-  % (modulo the case)
-  ik = strmatch(lower(key), keynames, 'exact');
-  if isempty(ik)
-    error(sprintf('Unrecognized property "%s"', key));
-  end
-
-  % Get the value
-  val = varargin{j+1};
-
-  % Set the proper field in options
-  options.(KeyNames{ik}) = val;
-  
-  % move to next pair  
-  j = j+2;
-  
-end
-
-return;
diff --git a/sundialsTB/kinsol/KINSol.m b/sundialsTB/kinsol/KINSol.m
deleted file mode 100644
index 750a893..0000000
--- a/sundialsTB/kinsol/KINSol.m
+++ /dev/null
@@ -1,47 +0,0 @@
-function [status, y] = KINSol(y0, strategy, yscale, fscale)
-%KINSol solves the nonlinear problem.
-%
-%   Usage:  [STATUS, Y] = KINSol(Y0, STRATEGY, YSCALE, FSCALE)
-%
-%   KINSol manages the computational process of computing an approximate 
-%   solution of the nonlinear system. If the initial guess (initial value 
-%   assigned to vector Y0) doesn't violate any user-defined constraints, 
-%   then KINSol attempts to solve the system f(y)=0. If an iterative linear
-%   solver was specified (see KINSetOptions), KINSol uses a nonlinear Krylov
-%   subspace projection method. The Newton-Krylov iterations are stopped
-%   if either of the following conditions is satisfied:
-%
-%       ||f(y)||_L-infinity <= 0.01*fnormtol
-%
-%       ||y[i+1] - y[i]||_L-infinity <= scsteptol
-%
-%   However, if the current iterate satisfies the second stopping
-%   criterion, it doesn't necessarily mean an approximate solution
-%   has been found since the algorithm may have stalled, or the
-%   user-specified step tolerance may be too large.
-%
-%   STRATEGY specifies the global strategy applied to the Newton step if it is
-%   unsatisfactory. Valid choices are 'None' or 'LineSearch'.
-%   YSCALE is a vector containing diagonal elements of scaling matrix for vector 
-%   Y chosen so that the components of YSCALE*Y (as a matrix multiplication) all 
-%   have about the same magnitude when Y is close to a root of f(y)
-%   FSCALE is a vector containing diagonal elements of scaling matrix for f(y) 
-%   chosen so that the components of FSCALE*f(Y) (as a matrix multiplication) 
-%   all have roughly the same magnitude when u is not too near a root of f(y)
-%
-%   On return, status is one of the following:
-%     0: KINSol succeeded
-%     1: The initial y0 already satisfies the stopping criterion given above
-%     2: Stopping tolerance on scaled step length satisfied
-%    -1: An error occurred (see printed error message)
-%
-%   See also KINSetOptions, KINGetstats
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-mode = 2;
-
-[status, y] = kim(mode, y0, strategy, yscale, fscale);
-
diff --git a/sundialsTB/kinsol/examples_par/mkinDiagon_kry_p.m b/sundialsTB/kinsol/examples_par/mkinDiagon_kry_p.m
deleted file mode 100644
index ed6a739..0000000
--- a/sundialsTB/kinsol/examples_par/mkinDiagon_kry_p.m
+++ /dev/null
@@ -1,128 +0,0 @@
-function [] = mkinDiagon_kry_p(comm)
-%mkinDiagon_kry_p - KINSOL example problem (parallel, GMRES)
-%   Simple diagonal test, using user-supplied preconditioner setup and 
-%   solve routines.
-%
-%   This example does a basic test of the solver by solving the system:
-%               f(y) = 0  for
-%               f(y) = y(i)^2 - i^2
-%
-%   No scaling is done.
-%   An approximate diagonal preconditioner is used.
-%
-%   See also: mpirun
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-[status npes] = MPI_Comm_size(comm);
-[status mype] = MPI_Comm_rank(comm);
-
-% Problem size
-
-nlocal = 32;
-neq = npes * nlocal;
-
-% Problem options
-
-fnormtol = 1.0e-5;
-scsteptol = 1.0e-4;
-maxl = 10;
-maxlrst = 2;
-msbset = 5;
-
-% User data structure
-
-data.mype = mype;       % MPI id
-data.nlocal = nlocal;   % local problem size
-data.P = [];            % workspace for preconditioner
-
-
-options = KINSetOptions('UserData', data,...
-                        'FuncNormTol', fnormtol,...
-                        'ScaledStepTol',scsteptol,...
-                        'LinearSolver','GMRES',....
-                        'KrylovMaxDim', maxl,...
-                        'MaxNumRestarts', maxlrst,...
-                        'MaxNumSetups', msbset,...
-                        'PrecSetupFn', at psetfn,...
-                        'PrecSolveFn', at psolfn);
-
-if mype==0
-  options = KINSetOptions(options,'Verbose',true);
-end
-
-KINInit(@sysfn, nlocal, options);
-
-% Initial guess and scale vector
-
-y0 = 2.0 * ([1:nlocal] + mype*nlocal);
-scale = ones(nlocal,1);
-
-% Solve problem using Inexact Newton 
-
-strategy = 'None';
-[status, y] = KINSol(y0, strategy, scale, scale);
-
-% Print solution
-
-if status < 0
-  fprintf('KINSOL failed. status = %d\n',status);
-else
-  for i = 1:4:nlocal
-    fprintf('%4d   |  %6.2f  %6.2f  %6.2f  %6.2f\n',...
-            i, y(i), y(i+1), y(i+2), y(i+3));
-  end
-end
-
-fprintf('DONE\n');
-
-
-% Free memory
-
-KINFree;
-
-% =======================================================
-
-function [fy, flag, new_data] = sysfn(y, data)
-
-nlocal = data.nlocal;
-mype = data.mype;
-baseadd = mype * nlocal;
-
-for i = 1:nlocal
-  fy(i) = y(i)^2 - (i+baseadd)^2;
-end
-
-new_data = []; % data was not modified
-flag = 0;      % success
-
-% =======================================================
-
-function [flag, new_data] = psetfn(y,yscale,fy,fscale,data)
-
-nlocal = data.nlocal;
-
-for i = 1:nlocal
-  P(i) = 0.5 / (y(i)+5.0);
-end
-
-new_data = data;
-new_data.P = P;
-
-flag = 0;
-
-% =======================================================
-
-function [x, flag, new_data] = psolfn(y,yscale,fy,fscale,v,data)
-
-nlocal = data.nlocal;
-P = data.P;
-
-for i=1:nlocal
-  x(i) = v(i) * P(i);
-end
-
-new_data = [];
-flag = 0;
diff --git a/sundialsTB/kinsol/examples_ser/mkinDiagon_kry.m b/sundialsTB/kinsol/examples_ser/mkinDiagon_kry.m
deleted file mode 100644
index 061c18c..0000000
--- a/sundialsTB/kinsol/examples_ser/mkinDiagon_kry.m
+++ /dev/null
@@ -1,104 +0,0 @@
-function mkinDiagon_kry
-%mkinDiagon_kry - KINSOL example problem (serial, GMRES)
-%   Simple diagonal test, using user-supplied preconditioner setup and 
-%   solve routines.
-%
-%   This example does a basic test of the solver by solving the system:
-%               f(y) = 0  for
-%               f(y) = y(i)^2 - i^2
-%
-%   No scaling is done.
-%   An approximate diagonal preconditioner is used.
-%
-%   See also: kindiag_sys kindag_pset kindiag_psol
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-neq = 128;
-
-strategy = 'None';
-
-fnormtol = 1.0e-5;
-scsteptol = 1.0e-4;
-maxl   = 10;
-maxrs  = 2;
-msbset = 5;
-
-data.P = [];
-
-options = KINSetOptions('UserData', data,...
-                        'Verbose',true,...
-                        'FuncNormTol', fnormtol,...
-                        'ScaledStepTol',scsteptol,...
-                        'LinearSolver','GMRES',....
-                        'KrylovMaxDim', maxl,...
-                        'MaxNumRestarts', maxrs,...
-                        'MaxNumSetups', msbset,...
-                        'PrecSetupFn', at psetfn,...
-                        'PrecSolveFn', at psolfn);
-KINInit(@sysfn, neq, options);
-
-y0 = 2.0*[1:neq]';
-scale = ones(neq,1);
-
-[status, y] = KINSol(y0, strategy, scale, scale);
-
-if status < 0
-  fprintf('KINSOL failed. status = %d\n',status);
-else
-  for i = 1:4:neq
-    fprintf('%4d   |  %6.2f  %6.2f  %6.2f  %6.2f\n',...
-            i, y(i), y(i+1), y(i+2), y(i+3));
-  end
-end
-
-stats = KINGetStats;
-ls_stats = stats.LSInfo;
-
-stats
-ls_stats
-
-KINFree;
-
-
-% ============================================================
-
-function [fy, flag, new_data] = sysfn(y, data)
-
-neq = length(y);
-for i = 1:neq
-  fy(i) = y(i)^2 - i^2;
-end
-
-new_data = [];  % data was not modified
-flag = 0;       % success
-
-% ============================================================
-
-function [flag, new_data] = psetfn(y,yscale,fy,fscale,data)
-
-neq = length(y);
-
-for i = 1:neq
-  P(i) = 0.5 / (y(i)+5.0);
-end
-
-new_data.P = P;  % updated P in data structure
-flag = 0;        % success
-
-% ============================================================
-
-function [x, flag, new_data] = psolfn(y,yscale,fy,fscale,v,data)
-
-P = data.P;
-
-neq = length(y);
-
-for i=1:neq
-  x(i) = v(i) * P(i);
-end
-
-new_data = []; % data was not modified
-flag = 0;      % success
diff --git a/sundialsTB/kinsol/examples_ser/mkinFerTron_dns.m b/sundialsTB/kinsol/examples_ser/mkinFerTron_dns.m
deleted file mode 100644
index d7762c2..0000000
--- a/sundialsTB/kinsol/examples_ser/mkinFerTron_dns.m
+++ /dev/null
@@ -1,182 +0,0 @@
-function mkinFerTron_dns
-% mkinFerTron_dns - Ferraris-Tronconi test problem
-%
-% Source: "Handbook of Test Problems in Local and Global Optimization",
-%             C.A. Floudas, P.M. Pardalos et al.
-%             Kluwer Academic Publishers, 1999.
-% Test problem 4 from Section 14.1, Chapter 14: Ferraris and Tronconi
-% 
-% This problem involves a blend of trigonometric and exponential terms.
-%    0.5 sin(x1 x2) - 0.25 x2/pi - 0.5 x1 = 0
-%    (1-0.25/pi) ( exp(2 x1)-e ) + e x2 / pi - 2 e x1 = 0
-% such that
-%    0.25 <= x1 <=1.0
-%    1.5 <= x2 <= 2 pi
-% 
-% The treatment of the bound constraints on x1 and x2 is done using
-% the additional variables
-%    l1 = x1 - x1_min >= 0
-%    L1 = x1 - x1_max <= 0
-%    l2 = x2 - x2_min >= 0
-%    L2 = x2 - x2_max >= 0
-% 
-% and using the constraint feature in KINSOL to impose
-%    l1 >= 0    l2 >= 0
-%    L1 <= 0    L2 <= 0
-% 
-% The Ferraris-Tronconi test problem has two known solutions.
-% The nonlinear system is solved by KINSOL using different 
-% combinations of globalization and Jacobian update strategies 
-% and with different initial guesses (leading to one or the other
-% of the known solutions).
-%
-% Constraints are imposed to make all components of the solution
-% positive.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/12/05 21:58:19 $
-
-
-% Initializations
-% ---------------
-
-% User data
-lb = [0.25 ; 1.5];
-ub = [1.0 ; 2*pi];
-data.lb = lb;
-data.ub = ub;
-
-% Number of problem variables
-nvar = 2;
-
-% Number of equations = number of problem vars. + number of bound variables
-neq = nvar + 2*nvar;
-
-% Function tolerance
-ftol = 1.0e-5;
-
-% Step tolerance
-stol = 1.0e-5;
-
-% Constraints
-constraints = [ 0 0 1 -1 1 -1];
-
-% Modified/exact Newton
-%   msbset = 0   -> modified Newton
-%   msbset = 1   -> exact Newton
-msbset = 0;
-
-% Initialize solver
-options = KINSetOptions('UserData', data, ...
-                        'FuncNormTol', ftol, ...
-                        'ScaledStepTol', stol, ...
-                        'Constraints', constraints, ...
-                        'MaxNumSetups', msbset, ...
-                        'LinearSolver', 'Dense');
-KINInit(@sysfn, neq, options);
-
-% Initial guess
-% -------------
-%
-% There are two known solutions for this problem
-% 
-% the following initial guess should take us to (0.29945; 2.83693)
-x1 = lb(1);
-x2 = lb(2);
-u1 = [ x1 ; x2 ; x1-lb(1) ; x1-ub(1) ; x2-lb(2) ; x2-ub(2) ];
-% while this one should take us to (0.5; 3.1415926)
-x1 = 0.5*(lb(1)+ub(1));
-x2 = 0.5*(lb(2)+ub(2));
-u2 = [ x1 ; x2 ; x1-lb(1) ; x1-ub(1) ; x2-lb(2) ; x2-ub(2) ];
-
-% No Y and F scaling
-yscale = ones(neq,1);
-fscale = ones(neq,1);
-
-% No globalization
-strategy = 'None';
-
-
-fprintf('\nFerraris and Tronconi test problem\n');
-fprintf('Tolerance parameters:\n');
-fprintf('  fnormtol  = %10.6g\n  scsteptol = %10.6g\n', ftol, stol);
-if msbset == 1
-  fprintf('Exact Newton');
-else
-  fprintf('Modified Newton');
-end
-if strcmp(strategy,'None')
-  fprintf('\n');
-else
-  fprintf(' with line search\n');
-end
-
-% Solve problem starting from the 1st initial guess
-% -------------------------------------------------
-
-fprintf('\n------------------------------------------\n');
-fprintf('\nInitial guess on lower bounds\n');
-fprintf('  [x1,x2] = %8.6g  %8.6g', u1(1), u1(2));
-
-[status, u1] = KINSol(u1, strategy, yscale, fscale);
-stats = KINGetStats;
-
-fprintf('\nsolution\n');
-fprintf('  [x1,x2] = %8.6g  %8.6g', u1(1), u1(2));
-fprintf('\nSolver statistics:\n');
-fprintf('  nni = %5d    nfe  = %5d \n', stats.nni, stats.nfe);
-fprintf('  nje = %5d    nfeD = %5d \n', stats.LSInfo.njeD, stats.LSInfo.nfeD);
-
-% Solve problem starting from the 2nd initial guess
-% -------------------------------------------------
-
-fprintf('\n------------------------------------------\n');
-fprintf('\nInitial guess in middle of feasible region\n');
-fprintf('  [x1,x2] = %8.6g  %8.6g', u2(1), u2(2));
-
-[status, u2] = KINSol(u2, strategy, yscale, fscale);
-stats = KINGetStats;
-
-fprintf('\nsolution\n');
-fprintf('  [x1,x2] = %8.6g  %8.6g', u2(1), u2(2));
-fprintf('\nSolver statistics:\n');
-fprintf('  nni = %5d    nfe  = %5d \n', stats.nni, stats.nfe);
-fprintf('  nje = %5d    nfeD = %5d \n', stats.LSInfo.njeD, stats.LSInfo.nfeD);
-
-% Free memory 
-% --------------------------------------
-
-KINFree;
-
-return
-
-
-% System function 
-% ---------------
-
-function [fu, flag, new_data] = sysfn(u, data)
-
-lb = data.lb;
-ub = data.ub;
-
-x1 = u(1);
-x2 = u(2);
-l1 = u(3);
-L1 = u(4);
-l2 = u(5);
-L2 = u(6);
-
-e = exp(1);
-
-fu(1) = 0.5 * sin(x1*x2) - 0.25 * x2 / pi - 0.5 * x1;
-fu(2) = (1.0 - 0.25/pi)*(exp(2.0*x1)-e) + e*x2/pi - 2.0*e*x1;
-fu(3) = l1 - x1 + lb(1);
-fu(4) = L1 - x1 + ub(1);
-fu(5) = l2 - x2 + lb(2);
-fu(6) = L2 - x2 + ub(2);
-
-
-flag = 0;
-new_data = [];
-return
diff --git a/sundialsTB/kinsol/examples_ser/mkinRoboKin_dns.m b/sundialsTB/kinsol/examples_ser/mkinRoboKin_dns.m
deleted file mode 100644
index a9a6f1f..0000000
--- a/sundialsTB/kinsol/examples_ser/mkinRoboKin_dns.m
+++ /dev/null
@@ -1,248 +0,0 @@
-function mkinRoboKin_dns
-% mkinRoboKin_dns - nonlinear system from robot kinematics.
-%
-% Source: "Handbook of Test Problems in Local and Global Optimization",
-%             C.A. Floudas, P.M. Pardalos et al.
-%             Kluwer Academic Publishers, 1999.
-% Test problem 6 from Section 14.1, Chapter 14
-% 
-% The nonlinear system is solved by KINSOL using the DENSE linear solver.
-%
-% Constraints are imposed to make all components of the solution be
-% within [-1,1]. This is achieved by introducing additional "bound variables",
-%    l_i = x_i + 1   and u-i = 1 - x_i, i = 1,...,nvar
-% and using the Constraints option to KINSOL to enforce l_i >=0 and u_i >= 0.
- 
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2007/12/05 21:58:19 $
-
-
-fprintf('\nRobot Kinematics Example\n');
-fprintf('8 variables; -1 <= x_i <= 1\n');
-fprintf('KINSOL problem size: 8 + 2*8 = 24 \n\n');
-
-% Number of problem variables
-nvar = 8;
-
-% Number of equations = number of problem vars. + number of bound variables
-neq = nvar + 2*nvar;
- 
-% Function tolerance
-ftol = 1.0e-5;
-
-% Step tolerance
-stol = 1.0e-5;
-
-% Constraints (all bound variables non-negative)
-constraints = [ zeros(nvar,1); ones(nvar,1) ; ones(nvar,1) ];
-
-% Force exact Newton
-msbset = 1;
-
-% Initialize solver
-options = KINSetOptions('FuncNormTol', ftol, ...
-                        'ScaledStepTol', stol, ...
-                        'Constraints', constraints, ...
-                        'MaxNumSetups', msbset, ...
-                        'LinearSolver', 'Dense', ...
-                        'JacobianFn', @sysjac);
-KINInit(@sysfn, neq, options);
-
-% Initial guess
-y = ones(neq,1);
-y(1:nvar) = 1.0/sqrt(2);
-
-fprintf('Initial guess:\n');
-PrintOutput(y);
-
-% Call KINSol to solve the problem
-yscale = ones(neq,1);
-fscale = ones(neq,1);
-strategy = 'LineSearch';
-[status, y] = KINSol(y, strategy, yscale, fscale);
-
-fprintf('\nComputed solution:\n');
-PrintOutput(y);
-
-% Print final statistics and free memory 
-stats = KINGetStats;
-ls_stats = stats.LSInfo;
-fprintf('\nSolver statistics:');
-stats
-ls_stats
-
-KINFree;
-
-return;
-
-% System function 
-% ---------------
-
-function [fy, flag] = sysfn(y)
-
-% Extract problem variables and bound variables
-
-x1 = y(1); l1 = y( 9); u1 = y(17); 
-x2 = y(2); l2 = y(10); u2 = y(18); 
-x3 = y(3); l3 = y(11); u3 = y(19); 
-x4 = y(4); l4 = y(12); u4 = y(20); 
-x5 = y(5); l5 = y(13); u5 = y(21); 
-x6 = y(6); l6 = y(14); u6 = y(22); 
-x7 = y(7); l7 = y(15); u7 = y(23); 
-x8 = y(8); l8 = y(16); u8 = y(24); 
-
-% Nonlinear equations 
-
-eq1 = - 0.1238*x1 + x7 - 0.001637*x2 - 0.9338*x4 + 0.004731*x1*x3 - 0.3578*x2*x3 - 0.3571;
-eq2 = 0.2638*x1 - x7 - 0.07745*x2 - 0.6734*x4 + 0.2238*x1*x3 + 0.7623*x2*x3 - 0.6022;
-eq3 = 0.3578*x1 + 0.004731*x2 + x6*x8;
-eq4 = - 0.7623*x1 + 0.2238*x2 + 0.3461;
-eq5 = x1*x1 + x2*x2 - 1;
-eq6 = x3*x3 + x4*x4 - 1;
-eq7 = x5*x5 + x6*x6 - 1;
-eq8 = x7*x7 + x8*x8 - 1;
-
-% Lower bounds ( l_i = 1 + x_i >= 0)
-
-lb1 = l1 - 1.0 - x1;
-lb2 = l2 - 1.0 - x2;
-lb3 = l3 - 1.0 - x3;
-lb4 = l4 - 1.0 - x4;
-lb5 = l5 - 1.0 - x5;
-lb6 = l6 - 1.0 - x6;
-lb7 = l7 - 1.0 - x7;
-lb8 = l8 - 1.0 - x8;
-
-% Upper bounds ( u_i = 1 - x_i >= 0)
-
-ub1 = u1 - 1.0 + x1;
-ub2 = u2 - 1.0 + x2;
-ub3 = u3 - 1.0 + x3;
-ub4 = u4 - 1.0 + x4;
-ub5 = u5 - 1.0 + x5;
-ub6 = u6 - 1.0 + x6;
-ub7 = u7 - 1.0 + x7;
-ub8 = u8 - 1.0 + x8;
-
-% Load residuals for the problem equations
-% and the equations encoding the constraints
-
-fy(1) = eq1; fy( 9) = lb1; fy(17) = ub1;
-fy(2) = eq2; fy(10) = lb2; fy(18) = ub2;
-fy(3) = eq3; fy(11) = lb3; fy(19) = ub3;
-fy(4) = eq4; fy(12) = lb4; fy(20) = ub4;
-fy(5) = eq5; fy(13) = lb5; fy(21) = ub5;
-fy(6) = eq6; fy(14) = lb6; fy(22) = ub6;
-fy(7) = eq7; fy(15) = lb7; fy(23) = ub7;
-fy(8) = eq8; fy(16) = lb8; fy(24) = ub8;
-
-flag = 0;
-
-return;
-
-
-% System Jacobian
-% ---------------
-
-function [J, flag] = sysjac(y, fy)
-
-% Extract problem variables
-
-x1 = y(1);
-x2 = y(2);
-x3 = y(3);
-x4 = y(4);
-x5 = y(5);
-x6 = y(6);
-x7 = y(7);
-x8 = y(8);
-
-% Nonlinear equations
-
-%  - 0.1238*x1 + x7 - 0.001637*x2 - 0.9338*x4 + 0.004731*x1*x3 - 0.3578*x2*x3 - 0.3571 
-
-J(1,1) = - 0.1238 + 0.004731*x3;
-J(1,2) = - 0.001637 - 0.3578*x3;
-J(1,3) = 0.004731*x1 - 0.3578*x2;
-J(1,4) = - 0.9338;
-J(1,7) = 1.0;
-
-% 0.2638*x1 - x7 - 0.07745*x2 - 0.6734*x4 + 0.2238*x1*x3 + 0.7623*x2*x3 - 0.6022
-
-J(2,1) = 0.2638 + 0.2238*x3;
-J(2,2) = - 0.07745 + 0.7623*x3;
-J(2,3) = 0.2238*x1 + 0.7623*x2;
-J(2,4) = - 0.6734;
-J(2,7) = -1.0;
-
-% 0.3578*x1 + 0.004731*x2 + x6*x8
-
-J(3,1) = 0.3578;
-J(3,2) = 0.004731;
-J(3,6) = x8;
-J(3,8) = x6;
-
-% - 0.7623*x1 + 0.2238*x2 + 0.3461
-
-J(4,1) = - 0.7623;
-J(4,2) = 0.2238;
-
-% x1*x1 + x2*x2 - 1
-
-J(5,1) = 2.0*x1;
-J(5,2) = 2.0*x2;
-
-% x3*x3 + x4*x4 - 1
-
-J(6,3) = 2.0*x3;
-J(6,4) = 2.0*x4;
-
-% x5*x5 + x6*x6 - 1
-
-J(7,5) = 2.0*x5;
-J(7,6) = 2.0*x6;
-
-% x7*x7 + x8*x8 - 1
-
-J(8,7) = 2.0*x7;
-J(8,8) = 2.0*x8;
-
-% Lower bounds ( l_i = 1 + x_i >= 0)
-%     l_i - 1.0 - x_i
-
-for i=1:8
-  J(8+i,i)   = -1.0;
-  J(8+i,8+i) =  1.0;
-end
-
-% Upper bounds ( u_i = 1 - x_i >= 0)
-%     u_i - 1.0 + x_i
-
-for i=1:8
-  J(16+i,i)    = 1.0;
-  J(16+i,16+i) = 1.0;
-end
-
-flag = 0;
-
-return
-
-
-
-% Print solution
-% --------------
-
-function PrintOutput(y)
-
-nvar = 8;
-
-fprintf('     l=x+1          x         u=1-x\n');
-fprintf('   ----------------------------------\n');
-
-for i = 1:nvar
-  fprintf(' %10.6g   %10.6g   %10.6g\n', y(i+nvar), y(i), y(i+2*nvar));
-end
-
-return
-
diff --git a/sundialsTB/kinsol/examples_ser/mkinTest_dns.m b/sundialsTB/kinsol/examples_ser/mkinTest_dns.m
deleted file mode 100644
index 3113aab..0000000
--- a/sundialsTB/kinsol/examples_ser/mkinTest_dns.m
+++ /dev/null
@@ -1,59 +0,0 @@
-function mkinTest_dns
-%mkinTest_dns - KINSOL example problem (serial, dense)
-%   Simple test problem for the Dense linear solver in KINSOL
-%   This example solves the system
-%       y(1)^2 + y(2)^2 = 1
-%       y(2) = y(1)^2
-%
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2007/12/05 21:58:19 $
-
-% Initialize problem
-neq = 2;
-fnormtol  = 1.0e-5;
-scsteptol = 1.0e-4;
-msbset = 1; % force exact Newton
-options = KINSetOptions('FuncNormTol', fnormtol,...
-                        'ScaledStepTol',scsteptol,...
-                        'LinearSolver','Dense',....
-                        'MaxNumSetups', msbset);
-KINInit(@sysfn, neq, options);
-
-% Solve problem
-y0 = ones(neq,1);
-scale = ones(neq,1);
-strategy = 'LineSearch';
-[status, y] = KINSol(y0, strategy, scale, scale);
-
-% Evaluate system function at solution
-[fy, flag] = sysfn(y);
-
-% Print results
-fprintf('Solution: %10.4e  %10.4e\n', y(1), y(2));
-fprintf('Residual: %10.4e  %10.4e\n', fy(1), fy(2));
-
-slv_stats = KINGetStats;
-ls_stats = slv_stats.LSInfo;
-slv_stats
-ls_stats
-
-
-% Free memory
-KINFree;
-
-return
-
-% ===================================================================
-
-function [fy, flag] = sysfn(y)
-
-fy(1) = y(1)^2 + y(2)^2 - 1.0;
-fy(2) = y(2) - y(1)^2;
-
-flag = 0;
-
-return
-
-
diff --git a/sundialsTB/kinsol/function_types/KINBandJacFn.m b/sundialsTB/kinsol/function_types/KINBandJacFn.m
deleted file mode 100644
index 0bd4e54..0000000
--- a/sundialsTB/kinsol/function_types/KINBandJacFn.m
+++ /dev/null
@@ -1,27 +0,0 @@
-%KINBandJacFn - type for user provided banded Jacobian function.
-%
-%   The function BJACFUN must be defined as 
-%        FUNCTION [J, FLAG] = BJACFUN(Y, FY)
-%   and must return a matrix J corresponding to the banded Jacobian of f(y).
-%   The input argument FY contains the current value of f(y).
-%   If a user data structure DATA was specified in KINInit, then
-%   BJACFUN must be defined as
-%        FUNCTION [J, FLAG, NEW_DATA] = BJACFUN(Y, FY, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix J and
-%   the flag FLAG, the BJACFUN function must also set NEW_DATA. Otherwise, 
-%   it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead
-%   to unnecessary copying).
-%
-%   The function BJACFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also KINSetOptions
-%
-%   NOTE: BJACFUN is specified through the property JacobianFn to KINSetOptions 
-%   and is used only if the property LinearSolver was set to 'Band'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/function_types/KINDenseJacFn.m b/sundialsTB/kinsol/function_types/KINDenseJacFn.m
deleted file mode 100644
index 74fbb41..0000000
--- a/sundialsTB/kinsol/function_types/KINDenseJacFn.m
+++ /dev/null
@@ -1,27 +0,0 @@
-%KINDenseJacFn - type for user provided dense Jacobian function.
-%
-%   The function DJACFUN must be defined as 
-%        FUNCTION [J, FLAG] = DJACFUN(Y,FY)
-%   and must return a matrix J corresponding to the Jacobian of f(y).
-%   The input argument FY contains the current value of f(y).
-%   If a user data structure DATA was specified in KINInit, then
-%   DJACFUN must be defined as
-%        FUNCTION [J, FLAG, NEW_DATA] = DJACFUN(Y,FY,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the matrix J and
-%   the flag FLAG, the DJACFUN function must also set NEW_DATA. Otherwise, 
-%   it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead
-%   to unnecessary copying).
-%
-%   The function DJACFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also KINSetOptions
-%
-%   NOTE: DJACFUN is specified through the property JacobianFn to KINSetOptions 
-%   and is used only if the property LinearSolver was set to 'Dense'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/function_types/KINGcommFn.m b/sundialsTB/kinsol/function_types/KINGcommFn.m
deleted file mode 100644
index 72ef194..0000000
--- a/sundialsTB/kinsol/function_types/KINGcommFn.m
+++ /dev/null
@@ -1,33 +0,0 @@
-%KINGcommFn - type for user provided communication function (BBDPre).
-%
-%   The function GCOMFUN must be defined as 
-%        FUNCTION FLAG = GCOMFUN(Y)
-%   and can be used to perform all interprocess communication necessary
-%   to evaluate the approximate right-hand side function for the BBDPre
-%   preconditioner module.
-%   If a user data structure DATA was specified in KINInit, then
-%   GCOMFUN must be defined as
-%        FUNCTION [FLAG, NEW_DATA] = GCOMFUN(Y, DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then the GCOMFUN function must also 
-%   set NEW_DATA. Otherwise, it should set NEW_DATA=[] (do not set 
-%   NEW_DATA = DATA as it would lead to unnecessary copying).
-%
-%   The function GCOMFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also KINGlocalFn, KINSetOptions
-%
-%   NOTES:
-%     GCOMFUN is specified through the GcommFn property in KINSetOptions 
-%     and is used only if the property PrecModule is set to 'BBDPre'.
-%
-%     Each call to GCOMFUN is preceded by a call to the system function
-%     SYSFUN with the same argument Y. Thus GCOMFUN can omit any communication 
-%     done by SYSFUN if relevant to the evaluation of G by GLOCFUN. If all 
-%     necessary communication was done by SYSFUN, GCOMFUN need not be provided.     
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/function_types/KINGlocalFn.m b/sundialsTB/kinsol/function_types/KINGlocalFn.m
deleted file mode 100644
index 4df5763..0000000
--- a/sundialsTB/kinsol/function_types/KINGlocalFn.m
+++ /dev/null
@@ -1,28 +0,0 @@
-%KINGlocalFn - type for user provided RHS approximation function (BBDPre).
-%
-%   The function GLOCFUN must be defined as 
-%        FUNCTION [G, FLAG] = GLOCFUN(Y)
-%   and must return a vector G corresponding to an approximation to f(y)
-%   which will be used in the BBDPRE preconditioner module. The case where
-%   G is mathematically identical to F is allowed.
-%   If a user data structure DATA was specified in KINInit, then
-%   GLOCFUN must be defined as
-%        FUNCTION [G, FLAG, NEW_DATA] = GLOCFUN(Y, DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then, besides setting the vector G,
-%   the GLOCFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function GLOCFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also KINGcommFn, KINSetOptions
-%
-%   NOTE: GLOCFUN is specified through the GlocalFn property in KINSetOptions 
-%   and is used only if the property PrecModule is set to 'BBDPre'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/function_types/KINJacTimesVecFn.m b/sundialsTB/kinsol/function_types/KINJacTimesVecFn.m
deleted file mode 100644
index d1dab21..0000000
--- a/sundialsTB/kinsol/function_types/KINJacTimesVecFn.m
+++ /dev/null
@@ -1,29 +0,0 @@
-%KINJacTimesVecFn - type for user provided Jacobian times vector function.
-%
-%   The function JTVFUN must be defined as 
-%        FUNCTION [JV, NEW_Y, FLAG] = JTVFUN(Y, V, NEW_Y)
-%   and must return a vector JV corresponding to the product of the 
-%   Jacobian of f(y) with the vector v. On input, NEW_Y indicates if
-%   the iterate has been updated in the interim. JV must be update
-%   or reevaluated, if appropriate, unless NEW_Y=false. This flag must
-%   be reset by the user.
-%   If a user data structure DATA was specified in KINInit, then
-%   JTVFUN must be defined as
-%        FUNCTION [JV, NEW_Y, FLAG, NEW_DATA] = JTVFUN(Y, V, NEW_Y, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector JV, and
-%   flags NEW_Y and FLAG, the JTVFUN function must also set NEW_DATA. Otherwise, 
-%   it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   If successful, FLAG should be set to 0. If an error occurs, FLAG should
-%   be set to a nonzero value.
-%
-%   See also KINSetOptions
-%
-%   NOTE: JTVFUN is specified through the property JacobianFn to KINSetOptions 
-%   and is used only if the property LinearSolver was set to 'GMRES' or 'BiCGStab'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/function_types/KINPrecSetupFn.m b/sundialsTB/kinsol/function_types/KINPrecSetupFn.m
deleted file mode 100644
index 26cc520..0000000
--- a/sundialsTB/kinsol/function_types/KINPrecSetupFn.m
+++ /dev/null
@@ -1,48 +0,0 @@
-%KINPrecSetupFn - type for user provided preconditioner setup function.
-%
-%   The user-supplied preconditioner setup subroutine should compute 
-%   the right-preconditioner matrix P used to form the scaled preconditioned 
-%   linear system:
-%
-%   (Df*J(y)*(P^-1)*(Dy^-1)) * (Dy*P*x) = Df*(-F(y))
-%
-%   where Dy and Df denote the diagonal scaling matrices whose diagonal elements 
-%   are stored in the vectors YSCALE and FSCALE, respectively.
-%
-%   The preconditioner setup routine (referenced by iterative linear
-%   solver modules via pset (type KINSpilsPrecSetupFn)) will not be
-%   called prior to every call made to the psolve function, but will
-%   instead be called only as often as necessary to achieve convergence
-%   of the Newton iteration.
-%
-%   NOTE: If the PRECSOLVE function requires no preparation, then a
-%   preconditioner setup function need not be given.
-%
-%   The function PSETFUN must be defined as 
-%        FUNCTION FLAG = PSETFUN(Y, YSCALE, FY, FSCALE)
-%   The input argument FY contains the current value of f(y), while YSCALE
-%   and FSCALE are the scaling vectors for solution and system function,
-%   respectively (as passed to KINSol)
-%
-%   If a user data structure DATA was specified in KINInit, then
-%   PSETFUN must be defined as
-%        FUNCTION [FLAG, NEW_DATA] = PSETFUN(Y, YSCALE, FY, FSCALE, DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the flag FLAG,
-%   the PSETFUN function must also set NEW_DATA. Otherwise, it should 
-%   set NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead
-%   to unnecessary copying).
-%
-%   If successful, PSETFUN must return FLAG=0. For a recoverable error (in    
-%   which case the setup will be retried) it must set FLAG to a positive
-%   integer value. If an unrecoverable error occurs, it must set FLAG
-%   to a negative value, in which case the solver will halt.
-%
-%   See also KINPrecSolveFn, KINSetOptions, KINSol
-%
-%   NOTE: PSETFUN is specified through the property PrecSetupFn to KINSetOptions 
-%   and is used only if the property LinearSolver was set to 'GMRES' or 'BiCGStab'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/function_types/KINPrecSolveFn.m b/sundialsTB/kinsol/function_types/KINPrecSolveFn.m
deleted file mode 100644
index accdf97..0000000
--- a/sundialsTB/kinsol/function_types/KINPrecSolveFn.m
+++ /dev/null
@@ -1,35 +0,0 @@
-%KINPrecSolveFn - type for user provided preconditioner solve function.
-%
-%   The user-supplied preconditioner solve function PSOLFN
-%   is to solve a linear system P z = r in which the matrix P is
-%   the preconditioner matrix (possibly set implicitely by PSETFUN)
-%
-%   The function PSOLFUN must be defined as 
-%        FUNCTION [Z, FLAG] = PSOLFUN(Y, YSCALE, FY, FSCALE, R)
-%   and must return a vector Z containing the solution of Pz=r.
-%   The input argument FY contains the current value of f(y), while YSCALE
-%   and FSCALE are the scaling vectors for solution and system function,
-%   respectively (as passed to KINSol)
-%
-%   If a user data structure DATA was specified in KINInit, then
-%   PSOLFUN must be defined as
-%        FUNCTION [Z, FLAG, NEW_DATA] = PSOLFUN(Y,YSCALE,FY,FSCALE,R,DATA)
-%   If the local modifications to the user data structure are needed in
-%   other user-provided functions then, besides setting the vector Z and
-%   the flag FLAG, the PSOLFUN function must also set NEW_DATA. Otherwise,
-%   it should set NEW_DATA=[] (do not set NEW_DATA = DATA as it would
-%   lead to unnecessary copying).
-%
-%   If successful, PSOLFUN must return FLAG=0. For a recoverable error it 
-%   must set FLAG to a positive value (in which case the solver will attempt 
-%   to correct). If an unrecoverable error occurs, it must set FLAG
-%   to a negative value, in which case the solver will halt.
-%
-%   See also KINPrecSetupFn, KINSetOptions
-%
-%   NOTE: PSOLFUN is specified through the property PrecSolveFn to KINSetOptions 
-%   and is used only if the property LinearSolver was set to 'GMRES' or 'BiCGStab'.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/function_types/KINSysFn.m b/sundialsTB/kinsol/function_types/KINSysFn.m
deleted file mode 100644
index d9788c5..0000000
--- a/sundialsTB/kinsol/function_types/KINSysFn.m
+++ /dev/null
@@ -1,25 +0,0 @@
-%KINSysFn - type for user provided system function
-%
-%   The function SYSFUN must be defined as 
-%        FUNCTION [FY, FLAG] = SYSFUN(Y)
-%   and must return a vector FY corresponding to f(y).
-%   If a user data structure DATA was specified in KINInit, then
-%   SYSFUN must be defined as
-%        FUNCTION [FY, FLAG, NEW_DATA] = SYSFUN(Y,DATA)
-%   If the local modifications to the user data structure are needed 
-%   in other user-provided functions then, besides setting the vector FY,
-%   the SYSFUN function must also set NEW_DATA. Otherwise, it should set
-%   NEW_DATA=[] (do not set NEW_DATA = DATA as it would lead to
-%   unnecessary copying).
-%
-%   The function SYSFUN must set FLAG=0 if successful, FLAG<0 if an
-%   unrecoverable failure occurred, or FLAG>0 if a recoverable error
-%   occurred.
-%
-%   See also KINInit
-%
-%   NOTE: SYSFUN is specified through the KINInit function.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2011/06/01 21:01:10 $
diff --git a/sundialsTB/kinsol/kim/Contents.m b/sundialsTB/kinsol/kim/Contents.m
deleted file mode 100644
index 18a1adb..0000000
--- a/sundialsTB/kinsol/kim/Contents.m
+++ /dev/null
@@ -1,3 +0,0 @@
-% MEX binding of KINSOL functions
-%
-%-- Radu Serban @ LLNL -- April 2005
diff --git a/sundialsTB/kinsol/kim/kim_bjac.m b/sundialsTB/kinsol/kim/kim_bjac.m
deleted file mode 100644
index a4a0bb0..0000000
--- a/sundialsTB/kinsol/kim/kim_bjac.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [ret, flag, new_data] = kim_bjac(y, fy, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [ret, flag] = feval(fct,y,fy);
-  new_data = [];
-else
-  [ret, flag, new_data] = feval(fct,y,fy,data);
-end
diff --git a/sundialsTB/kinsol/kim/kim_djac.m b/sundialsTB/kinsol/kim/kim_djac.m
deleted file mode 100644
index 077e267..0000000
--- a/sundialsTB/kinsol/kim/kim_djac.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [ret, flag, new_data] = kim_djac(y, fy, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [ret, flag] = feval(fct,y,fy);
-  new_data = [];
-else
-  [ret, flag, new_data] = feval(fct,y,fy,data);
-end
diff --git a/sundialsTB/kinsol/kim/kim_gcom.m b/sundialsTB/kinsol/kim/kim_gcom.m
deleted file mode 100644
index aea86a5..0000000
--- a/sundialsTB/kinsol/kim/kim_gcom.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [flag, new_data] = kim_gcom(y, f, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,y);
-  new_data = [];
-else
-  [flag, new_data] = feval(fct,y,data);
-end
-
diff --git a/sundialsTB/kinsol/kim/kim_gloc.m b/sundialsTB/kinsol/kim/kim_gloc.m
deleted file mode 100644
index 06f59b2..0000000
--- a/sundialsTB/kinsol/kim/kim_gloc.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [gval, flag, new_data] = kim_gloc(y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [gval, flag] = feval(fct,y);
-  new_data = [];
-else
-  [gval, flag, new_data] = feval(fct,y,data);
-end
diff --git a/sundialsTB/kinsol/kim/kim_info.m b/sundialsTB/kinsol/kim/kim_info.m
deleted file mode 100644
index 91d61a2..0000000
--- a/sundialsTB/kinsol/kim/kim_info.m
+++ /dev/null
@@ -1,81 +0,0 @@
-function varargout = kim_info(action, fin, message);
-
-switch action
-  
- case 0  % initialize 
-
-  % Create figure
-  
-  f = figure;
-
-  set(f,'resizefcn','kim_info(2,0,0)');
-  set(f,'name','KINSOL info','numbertitle','off');
-  set(f,'menubar','none','tag','figure');
-  
-  % Create text box
-   
-  tbpos=getTBPos(f);
-  h=uicontrol(f,'style','listbox','position',tbpos,'tag','textbox');
-  set(h,'BackgroundColor',[1 1 1]);
-  set(h,'SelectionHighlight','off');
-
-  % Create OK button
-  
-  bpos=getOKPos(f);
-  h=uicontrol(f,'style','pushbutton','position',bpos,'string','Close','tag','okaybutton');
-  set(h,'callback','kim_info(3,0,0)');
-
-  % Save handles
-  
-  handles=guihandles(f);
-  guidata(f,handles);
- 
-  varargout{1} = f;
- 
- case 1 % append text
-
-  f = fin;
-  new_str = message;
-
-  handles=guidata(f);
-  string = get(handles.textbox,'String');
-  string{end+1}=new_str;
-  set(handles.textbox,'String',string);
-  
- case 2 % resize
-
-  handles=guidata(gcbo);
-  tbpos=getTBPos(handles.figure);
-  bpos=getOKPos(handles.figure);
-  set(handles.okaybutton,'position',bpos);
-  set(handles.textbox,'position',tbpos);
-
- case 3 % close
-  
-  handles=guidata(gcbo);
-  close(handles.figure);
-  
-end
-
-%------------------------------------
-function tbpos=getTBPos(f)
-
-margins=[10 10 10 50]; % left, right, top, bottom
-pos=get(f,'position');
-tbpos=[margins(1) margins(4) pos(3)-margins(1)-margins(2) ...
-    pos(4)-margins(3)-margins(4)];
-tbpos(tbpos<1)=1;
-
-
-%------------------------------------
-function tbpos=getOKPos(f)
-
-bsize=[60,30];
-badjustpos=[0,25];
-
-pos=get(f,'position');
-
-tbpos=[pos(3)/2-bsize(1)/2+badjustpos(1) -bsize(2)/2+badjustpos(2)...
-    bsize(1) bsize(2)];
-tbpos=round(tbpos);
-tbpos(tbpos<1)=1;
diff --git a/sundialsTB/kinsol/kim/kim_jtv.m b/sundialsTB/kinsol/kim/kim_jtv.m
deleted file mode 100644
index 20513dd..0000000
--- a/sundialsTB/kinsol/kim/kim_jtv.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [ret, new_y, flag, new_data] = kim_jtv(y, v, new_y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [ret, new_y, flag] = feval(fct,y,v,new_y);
-  new_data = [];
-else
-  [ret, new_y, flag, new_data] = feval(fct,y,v,new_y,data);
-end
diff --git a/sundialsTB/kinsol/kim/kim_pset.m b/sundialsTB/kinsol/kim/kim_pset.m
deleted file mode 100644
index 61aca0b..0000000
--- a/sundialsTB/kinsol/kim/kim_pset.m
+++ /dev/null
@@ -1,12 +0,0 @@
-function [flag, new_data] = kim_pset(y, yscale, fy, fscale, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  flag = feval(fct,y,yscale,fy,fscale);
-  new_data =[];
-else
-  [flag, new_data] = feval(fct,y,yscale,fy,fscale,data);
-end
diff --git a/sundialsTB/kinsol/kim/kim_psol.m b/sundialsTB/kinsol/kim/kim_psol.m
deleted file mode 100644
index 17c3258..0000000
--- a/sundialsTB/kinsol/kim/kim_psol.m
+++ /dev/null
@@ -1,11 +0,0 @@
-function [ret, flag, new_data] = kim_psol(y, yscale, fy, fscale, v, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-if isempty(data)
-  [ret, flag] = feval(fct,y,yscale,fy,fscale,v);
-  new_data = [];
-else
-  [ret, flag, new_data] = feval(fct,y,yscale,fy,fscale,v,data);
-end
diff --git a/sundialsTB/kinsol/kim/kim_sys.m b/sundialsTB/kinsol/kim/kim_sys.m
deleted file mode 100644
index 4cd2825..0000000
--- a/sundialsTB/kinsol/kim/kim_sys.m
+++ /dev/null
@@ -1,13 +0,0 @@
-function [ret, flag, new_data] = kim_sys(y, fct, data)
-
-%
-% Wrapper around the actual user-provided Matlab function
-%
-
-if isempty(data)
-  [ret, flag] = feval(fct,y);
-  new_data = [];
-else
-  [ret, flag, new_data] = feval(fct,y,data);
-end
-
diff --git a/sundialsTB/kinsol/kim/src/kim.c b/sundialsTB/kinsol/kim/src/kim.c
deleted file mode 100644
index 9b1dc32..0000000
--- a/sundialsTB/kinsol/kim/src/kim.c
+++ /dev/null
@@ -1,811 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.8 $
- * $Date: 2012/03/07 21:50:32 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/cvodes/LICENSE.
- * -----------------------------------------------------------------
- * MEX implementation for KINSOL Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include "kim.h"
-#include "nvm.h"
-
-/*
- * ---------------------------------------------------------------------------------
- * Global interface data variable
- * ---------------------------------------------------------------------------------
- */
-
-kimInterfaceData kimData = NULL;
-
-/*
- * ---------------------------------------------------------------------------------
- * Static function prototypes
- * ---------------------------------------------------------------------------------
- */
-
-static void kimInitKINSOLdata();
-static void kimPersistKINSOLdata();
-static void kimFinalKINSOLdata();
-
-static int KIM_Initialization(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int KIM_Solve(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int KIM_Stats(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int KIM_Get(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int KIM_Set(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-static int KIM_Free(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
-
-/*
- * ---------------------------------------------------------------------------------
- * Main entry point
- * ---------------------------------------------------------------------------------
- */
-
-void mexFunction(int nlhs, mxArray *plhs[],
-                 int nrhs, const mxArray *prhs[] )
-{
-  int mode;
-  /* 
-     Modes:
-     
-     1 - initialize KINSOL solver
-     2 - solve problem
-     3 - get solver stats
-     4 - extract data from kin_mem
-     5 - set one optional input at a time
-     6 - finalize
-  */
-
-  mode = (int)mxGetScalar(prhs[0]);
-
-  mexUnlock();
-
-  if ( (mode != 1) && (kimData == NULL) ) {
-    mexErrMsgTxt("KINSOL - Illegal attempt to call before KINInit.");
-  }
-
-
-  switch(mode) {
-
-  case 1:
-    if (kimData != NULL) {
-      KIM_Free(nlhs, plhs, nrhs-1, &prhs[1]);
-      kimFinalKINSOLdata();
-    }
-    kimInitKINSOLdata();
-    KIM_Initialization(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 2:
-    KIM_Solve(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 3:
-    KIM_Stats(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 4:
-    KIM_Get(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 5:
-    KIM_Set(nlhs, plhs, nrhs-1, &prhs[1]);
-    break;
-
-  case 6:
-    KIM_Free(nlhs, plhs, nrhs-1, &prhs[1]);
-    kimFinalKINSOLdata();
-    break;
-
-  }
-
-  /* Unless this was the KINFree call,
-   * make data persistent and lock the MEX file */
-  if (mode != 6) {
-    kimPersistKINSOLdata();
-    mexLock();
-  }
-
-  return;
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Private functions to deal with the global data
- * ---------------------------------------------------------------------------------
- */
-
-static void kimInitKINSOLdata()
-{
-  mxArray *empty;
-
-  /* Allocate space for global KINSOL data structure */
-
-  kimData = (kimInterfaceData) mxMalloc(sizeof(struct kimInterfaceData_));
-
-  /* Initialize global KINSOL data */
-
-  kimData->kin_mem = NULL;
-
-  kimData->n  = 0;
-
-  kimData->Y  = NULL;
-
-  kimData->LS = LS_DENSE;
-  kimData->PM = PM_NONE;
-
-  kimData->errMsg = TRUE;
-
-  /* Initialize Matlab mex arrays to empty */
-
-  empty = mxCreateDoubleMatrix(0,0,mxREAL);
-
-  kimData->SYSfct   = mxDuplicateArray(empty);
-  kimData->JACfct   = mxDuplicateArray(empty);
-  kimData->PSETfct  = mxDuplicateArray(empty);
-  kimData->PSOLfct  = mxDuplicateArray(empty);
-  kimData->GLOCfct  = mxDuplicateArray(empty);
-  kimData->GCOMfct  = mxDuplicateArray(empty);
-
-  kimData->mtlb_data = mxDuplicateArray(empty);
-
-  mxDestroyArray(empty);
-
-  return;
-}
-
-static void kimPersistKINSOLdata()
-{
-  /* Make global memory persistent */
-
-  mexMakeArrayPersistent(kimData->mtlb_data);
-
-  mexMakeArrayPersistent(kimData->SYSfct);
-  mexMakeArrayPersistent(kimData->JACfct);
-  mexMakeArrayPersistent(kimData->PSETfct);
-  mexMakeArrayPersistent(kimData->PSOLfct);
-  mexMakeArrayPersistent(kimData->GLOCfct);
-  mexMakeArrayPersistent(kimData->GCOMfct);
-
-  mexMakeMemoryPersistent(kimData);
-
-  return;
-}
-
-static void kimFinalKINSOLdata()
-{  
-  if (kimData == NULL) return;
-
-  if (kimData->Y != NULL) N_VDestroy(kimData->Y);
-
-  mxDestroyArray(kimData->mtlb_data);
-
-  mxDestroyArray(kimData->SYSfct);
-  mxDestroyArray(kimData->JACfct);
-  mxDestroyArray(kimData->PSETfct);
-  mxDestroyArray(kimData->PSOLfct);
-  mxDestroyArray(kimData->GLOCfct);
-  mxDestroyArray(kimData->GCOMfct);
-
-  mxFree(kimData);
-  kimData = NULL;
-
-  return;
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Error handler function.
- *
- * This function is both passed as the KINSOL error handler and used throughout
- * the Matlab interface.
- *
- * If called directly by one of the interface functions, error_code = -999 to
- * indicate an error and err_code = +999 to indicate a warning. Otherwise,
- * err_code is set by the calling KINSOL function.
- *
- * NOTE: mexErrMsgTxt will end the execution of the MEX file. Therefore we do
- *       not have to intercept any of the KINSOL error return flags.
- *       The only return flags we intercept are those from CVode() and CVodeB()
- *       which are passed back to the user (only positive values will make it). 
- * ---------------------------------------------------------------------------------
- */
-
-void kimErrHandler(int error_code, 
-                   const char *module, const char *function, 
-                   char *msg, void *eh_data)
-{
-  char err_msg[256];
-
-  if (!(kimData->errMsg)) return;
-
-  if (error_code > 0) {
-    sprintf(err_msg,"Warning in ==> %s\n%s",function,msg);
-    mexWarnMsgTxt(err_msg);    
-  } else if (error_code < 0) {
-    /*mexUnlock();
-      kimFinalKINSOLdata();*/
-    sprintf(err_msg,"Error using ==> %s\n%s",function,msg);
-    mexErrMsgTxt(err_msg);
-  }
-
-  return;
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Info handler function
- * 
- * This function is passed as the KINSOL info handler if verbose output was
- * requested. It is a wrapper around the Matlab m-file kim_info.m which posts
- * all info messages to a separate Matlab figure.
- * ---------------------------------------------------------------------------------
- */
-
-void kimInfoHandler(const char *module, const char *function, 
-                    char *msg, void *ih_data)
-{
-  char my_msg[400];
-  mxArray *mx_in[3];
-
-  sprintf(my_msg,"[%s] %s\n  %s\n",module,function,msg);
-
-  /* action=1 -> append */
-  mx_in[0] = mxCreateDoubleScalar(1);
-  mx_in[1] = mxCreateDoubleScalar((double)kimData->fig_handle);
-  mx_in[2] = mxCreateString(my_msg);
-
-  mexCallMATLAB(0,NULL,3,mx_in,"kim_info");
-
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define kin_mem      (kimData->kin_mem)
-
-#define y            (kimData->Y)
-#define N            (kimData->n)
-#define ls           (kimData->LS)
-#define pm           (kimData->PM)
-
-#define mtlb_data    (kimData->mtlb_data)
-
-#define mtlb_SYSfct  (kimData->SYSfct)
-#define mtlb_JACfct  (kimData->JACfct)
-#define mtlb_PSETfct (kimData->PSETfct)
-#define mtlb_PSOLfct (kimData->PSOLfct)
-#define mtlb_GLOCfct (kimData->GLOCfct)
-#define mtlb_GCOMfct (kimData->GCOMfct)
-
-/*
- * ---------------------------------------------------------------------------------
- * Interface procedures
- * ---------------------------------------------------------------------------------
- */
-
-static int KIM_Initialization(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  const mxArray *options;
-  mxArray *mx_in[3], *mx_out[2];
-
-  int status;
-
-  int mxiter, msbset, msbsetsub, etachoice, mxnbcf;
-  double eta, egamma, ealpha, mxnewtstep, relfunc, fnormtol, scsteptol;
-  booleantype verbose, errmsg, noInitSetup, noMinEps;
-
-  double *constraints;
-  N_Vector NVconstraints;
-
-  int ptype;
-  long int mudq, mldq, mupper, mlower;
-  int maxl, maxrs;
-  double dqrely;
-
-  /*
-   * ------------------------------------
-   * Initialize appropriate vector module
-   * ------------------------------------
-   */
-
-  InitVectors();
-
-  /* 
-   * ----------------------------
-   * Extract stuff from arguments
-   * ----------------------------
-   */
-
-  /* Matlab user-provided function */
-
-  mxDestroyArray(mtlb_SYSfct);
-  mtlb_SYSfct = mxDuplicateArray(prhs[0]);
-  
-  /* Problem dimension */
-
-  N = (long int) mxGetScalar(prhs[1]);
-
-  /* Solver Options (may be empty) */
-
-  options = prhs[2];
-
-  /* Create the solution N_Vector */
-
-  y = NewVector(N);
-
-  /*
-   * ----------------------------- 
-   * Process the options structure 
-   * -----------------------------
-   */
-
-  status = get_SolverOptions(options,
-                             &verbose, &errmsg,
-                             &mxiter, &msbset, &msbsetsub, &etachoice, &mxnbcf,
-                             &eta, &egamma, &ealpha, &mxnewtstep, 
-                             &relfunc, &fnormtol, &scsteptol,
-                             &constraints,
-                             &noInitSetup, &noMinEps);
-  if (status != 0) goto error_return;     
-
-  /* 
-   * ------------------------------------------------------
-   * Create KINSOL object, allocate memory, and set options
-   * ------------------------------------------------------
-   */
-
-  kin_mem = KINCreate();
-  if (kin_mem == NULL) goto error_return;
-
-  /* Attach the global KINSOL data as 'user_data' */
-  status = KINSetUserData(kin_mem, kimData);
-  if (status != KIN_SUCCESS) goto error_return;
-
-  /* Attach error handler function */
-  status = KINSetErrHandlerFn(kin_mem, kimErrHandler, NULL);
-  if (status != KIN_SUCCESS) goto error_return;
-
-  /* If verbose was set to TRUE */
-  if (verbose) {
-    /* Set print level to its highest value */
-    status = KINSetPrintLevel(kin_mem,3);
-    if (status != KIN_SUCCESS) goto error_return;
-    /* Attach info handler function */
-    status = KINSetInfoHandlerFn(kin_mem, kimInfoHandler, NULL);
-    if (status != KIN_SUCCESS) goto error_return;
-    /* Initialize the output window and store the figure handle */
-    mx_in[0] = mxCreateDoubleScalar(0); /* action=0, initialize */
-    mx_in[1] = mxCreateDoubleScalar(0); /* ignored */
-    mx_in[2] = mxCreateDoubleScalar(0); /* ignored */
-    mexCallMATLAB(1,mx_out,3,mx_in,"kim_info");
-    kimData->fig_handle = (int)*mxGetPr(mx_out[0]);
-  }
-
-  /* Call KINInit */
-  status = KINInit(kin_mem, mxW_KINSys, y);
-  if (status != KIN_SUCCESS) goto error_return;
-
-  /* Redirect output */
-  status = KINSetErrFile(kin_mem, stdout);
-  if (status != KIN_SUCCESS) goto error_return;
-
-  /* Optional inputs */
-  status = KINSetNumMaxIters(kin_mem, mxiter);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetNoInitSetup(kin_mem, noInitSetup);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetNoMinEps(kin_mem, noMinEps);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetMaxSetupCalls(kin_mem, msbset);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetMaxSubSetupCalls(kin_mem, msbsetsub);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetMaxBetaFails(kin_mem, mxnbcf);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetEtaForm(kin_mem, etachoice);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetEtaConstValue(kin_mem, eta);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetEtaParams(kin_mem, egamma, ealpha);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetMaxNewtonStep(kin_mem, mxnewtstep);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetRelErrFunc(kin_mem, relfunc);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetFuncNormTol(kin_mem, fnormtol);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINSetScaledStepTol(kin_mem, scsteptol);
-  if (status != KIN_SUCCESS) goto error_return;
-
-  /* Constraints */
-  if (constraints != NULL) {
-    NVconstraints = N_VCloneEmpty(y);
-    N_VSetArrayPointer(constraints, NVconstraints);
-    status = KINSetConstraints(kin_mem, NVconstraints);
-    if (status != KIN_SUCCESS) goto error_return;
-    N_VDestroy(NVconstraints);
-  }
-
-  /*
-   * --------------------
-   * Attach linear solver
-   * --------------------
-   */
-
-  status = get_LinSolvOptions(options,
-                              &mupper, &mlower,
-                              &mudq, &mldq, &dqrely,
-                              &ptype, &maxrs, &maxl);
-  if (status != 0) goto error_return;
-
-  switch (ls) {
-
-  case LS_NONE:
-
-    kimErrHandler(-999, "KINSOL", "KINInit",
-                  "No linear solver was specified.", NULL);
-    goto error_return;
-
-  case LS_DENSE:
-
-    status = KINDense(kin_mem,  N);
-    if (status != KIN_SUCCESS) goto error_return;
-    if (!mxIsEmpty(mtlb_JACfct)) {
-      status = KINDlsSetDenseJacFn(kin_mem, mxW_KINDenseJac);
-      if (status != KIN_SUCCESS) goto error_return;
-    }
-
-    break;
-
-  case LS_BAND:
-
-    status = KINBand(kin_mem, N, mupper, mlower);
-    if (status != KIN_SUCCESS) goto error_return;
-    if (!mxIsEmpty(mtlb_JACfct)) {
-      status = KINDlsSetBandJacFn(kin_mem, mxW_KINBandJac);
-      if (status != KIN_SUCCESS) goto error_return;
-    }
-
-    break;
-
-  case LS_SPGMR:
-
-    status = KINSpgmr(kin_mem, maxl);
-    if (status != KIN_SUCCESS) goto error_return;
-    status = KINSpilsSetMaxRestarts(kin_mem, maxrs);
-    if (status != KIN_SUCCESS) goto error_return;
-
-    break;
-
-  case LS_SPBCG:
-
-    status = KINSpbcg(kin_mem, maxl);
-    if (status != KIN_SUCCESS) goto error_return;
-
-    break;
-
-  case LS_SPTFQMR:
-
-    status = KINSptfqmr(kin_mem, maxl);
-    if (status != KIN_SUCCESS) goto error_return;
-
-    break;
-
-  }
-
-  /* Jacobian * vector and preconditioner for SPILS linear solvers */
-
-  if ( (ls==LS_SPGMR) || (ls==LS_SPBCG) || (ls==LS_SPTFQMR) ) {
-
-    if (!mxIsEmpty(mtlb_JACfct)) {
-      status = KINSpilsSetJacTimesVecFn(kin_mem, mxW_KINSpilsJac);
-      if (status != KIN_SUCCESS) goto error_return;
-    }
-
-    switch (pm) {
-
-    case PM_NONE:
-
-      if (!mxIsEmpty(mtlb_PSOLfct)) {
-        
-        if (!mxIsEmpty(mtlb_PSETfct)) status = KINSpilsSetPreconditioner(kin_mem, mxW_KINSpilsPset, mxW_KINSpilsPsol);
-        else                          status = KINSpilsSetPreconditioner(kin_mem, NULL, mxW_KINSpilsPsol);
-        if (status != KIN_SUCCESS) goto error_return;
-        
-      }
-      
-      break;
-
-    case PM_BBDPRE:
-
-      if (!mxIsEmpty(mtlb_GCOMfct)) status = KINBBDPrecInit(kin_mem, N, mudq, mldq, mupper, mlower, dqrely, mxW_KINGloc, mxW_KINGcom);
-      else                          status = KINBBDPrecInit(kin_mem, N, mudq, mldq, mupper, mlower, dqrely, mxW_KINGloc, NULL);
-      if (status != KIN_SUCCESS) goto error_return;
-      
-      break;
-
-    }
-
-
-  }
-
-  /* Set errMsg field in global data 
-   * (all error messages from here on will respect this) */
-  
-  kimData->errMsg = errmsg;
-
-  /* Successfull return */
-
-  status = 0;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-  
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-static int KIM_Solve(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  double *y0, *ys, *fs;
-  N_Vector yscale = NULL, fscale = NULL;
-  int buflen, status, strategy;
-  char *bufval;
-
-  /*
-   * ----------------------------------------------------------------
-   * Extract input arguments
-   * ----------------------------------------------------------------
-   */
-
-  /* Exract y0 and load initial guess in y */
-
-  y0 = mxGetPr(prhs[0]);
-  PutData(y, y0, N);
-
-  /* Extract strategy */
-
-  buflen = mxGetM(prhs[1]) * mxGetN(prhs[1]) + 1;
-  bufval = mxCalloc(buflen, sizeof(char));
-  status = mxGetString(prhs[1], bufval, buflen);
-  if(!strcmp(bufval,"None")) {
-    strategy = KIN_NONE;
-  } else if(!strcmp(bufval,"LineSearch")) {
-    strategy = KIN_LINESEARCH;
-  } else {
-    kimErrHandler(-999, "KINSOL", "KINSol",
-                  "Illegal value for strategy.", NULL); 
-    goto error_return;
-  }
-
-  /* Extract yscale */
-
-  ys = mxGetPr(prhs[2]);
-  yscale = N_VCloneEmpty(y);
-  N_VSetArrayPointer(ys, yscale);
-
-  /* Extract fscale */
-
-  fs = mxGetPr(prhs[3]);
-  fscale = N_VCloneEmpty(y);
-  N_VSetArrayPointer(fs, fscale);
-
-  /*
-   * -------------------------
-   * Call main solver function
-   * -------------------------
-   */
-
-  status = KINSol(kin_mem, y, strategy, yscale, fscale);
-  if (status < 0) goto error_return;
-
-  /* Extract solution vector */
-  plhs[1] = mxCreateDoubleMatrix(N,1,mxREAL);
-  GetData(y, mxGetPr(plhs[1]), N);
-
-  /* Free temporary vectors */
-  N_VDestroy(yscale);
-  N_VDestroy(fscale);
-
-  /* KINSOL return flag (only non-negative values make it here) */
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  return(0);
-
- error_return:
-  status = -1;
-  plhs[0] = mxCreateDoubleScalar((double)status);
-  plhs[1] = mxCreateDoubleMatrix(0,0,mxREAL);
-  if (yscale != NULL) N_VDestroy(yscale);
-  if (fscale != NULL) N_VDestroy(fscale);
-  return(-1);
-
-}
-
-static int KIM_Stats(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  const char *fnames_solver[]={
-    "nfe",
-    "nni",
-    "nbcf",
-    "nbops",
-    "fnorm",
-    "step",
-    "LSInfo",
-  };
-  const char *fnames_dense[]={
-    "name",
-    "njeD",
-    "nfeD"
-  };
-  const char *fnames_band[]={
-    "name",
-    "njeD",
-    "nfeD"
-  };
-  const char *fnames_spils[]={
-    "name",
-    "nli",
-    "npe",
-    "nps",
-    "ncfl",
-  };
-
-  long int nfe, nni, nbcf, nbops;
-  double fnorm, step;
-
-  long int njeD, nfeD;
-  long int nli, npe, nps, ncfl;
-
-  mxArray *mx_ls;
-  int nfields;
-
-  int status;
-
-
-  if (kimData == NULL) return;
-
-  status = KINGetNumNonlinSolvIters(kin_mem, &nni);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINGetNumFuncEvals(kin_mem, &nfe);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINGetNumBetaCondFails(kin_mem, &nbcf);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINGetNumBacktrackOps(kin_mem, &nbops);
-  if (status != KIN_SUCCESS) goto error_return;
-  
-  status = KINGetFuncNorm(kin_mem, &fnorm);
-  if (status != KIN_SUCCESS) goto error_return;
-  status = KINGetStepLength(kin_mem, &step);
-  if (status != KIN_SUCCESS) goto error_return;
-
-  nfields = sizeof(fnames_solver)/sizeof(*fnames_solver);
-  plhs[0] = mxCreateStructMatrix(1, 1, nfields, fnames_solver);
- 
-  mxSetField(plhs[0], 0, "nfe",   mxCreateDoubleScalar((double)nfe));
-  mxSetField(plhs[0], 0, "nni",   mxCreateDoubleScalar((double)nni));
-  mxSetField(plhs[0], 0, "nbcf",  mxCreateDoubleScalar((double)nbcf));
-  mxSetField(plhs[0], 0, "nbops", mxCreateDoubleScalar((double)nbops));
-  mxSetField(plhs[0], 0, "fnorm", mxCreateDoubleScalar(fnorm));
-  mxSetField(plhs[0], 0, "step",  mxCreateDoubleScalar(step));
-
-  /* Linear Solver Statistics */
-
-  switch(ls){
-
-  case LS_DENSE:
-    
-    status = KINDlsGetNumJacEvals(kin_mem, &njeD);
-    if (status != KIN_SUCCESS) goto error_return;
-    status = KINDlsGetNumFuncEvals(kin_mem, &nfeD);
-    if (status != KIN_SUCCESS) goto error_return;
-
-    nfields = sizeof(fnames_dense)/sizeof(*fnames_dense);
-    mx_ls = mxCreateStructMatrix(1, 1, nfields, fnames_dense);
-
-    mxSetField(mx_ls, 0, "name", mxCreateString("Dense"));
-    mxSetField(mx_ls, 0, "njeD", mxCreateDoubleScalar((double)njeD));
-    mxSetField(mx_ls, 0, "nfeD", mxCreateDoubleScalar((double)nfeD));
-    
-    break;
-
-  case LS_BAND:
-    
-    status = KINDlsGetNumJacEvals(kin_mem, &njeD);
-    if (status != KIN_SUCCESS) goto error_return;
-    status = KINDlsGetNumFuncEvals(kin_mem, &nfeD);
-    if (status != KIN_SUCCESS) goto error_return;
-    
-    nfields = sizeof(fnames_band)/sizeof(*fnames_band);
-    mx_ls = mxCreateStructMatrix(1, 1, nfields, fnames_band);
-
-    mxSetField(mx_ls, 0, "name", mxCreateString("Band"));
-    mxSetField(mx_ls, 0, "njeD", mxCreateDoubleScalar((double)njeD));
-    mxSetField(mx_ls, 0, "nfeD", mxCreateDoubleScalar((double)nfeD));
-    
-    break;
-
-  case LS_SPGMR:
-  case LS_SPBCG:
-  case LS_SPTFQMR:
-
-    status = KINSpilsGetNumLinIters(kin_mem, &nli);
-    if (status != KIN_SUCCESS) goto error_return;
-    status = KINSpilsGetNumPrecEvals(kin_mem, &npe);
-    if (status != KIN_SUCCESS) goto error_return;
-    status = KINSpilsGetNumPrecSolves(kin_mem, &nps);
-    if (status != KIN_SUCCESS) goto error_return;
-    status = KINSpilsGetNumConvFails(kin_mem, &ncfl);
-    if (status != KIN_SUCCESS) goto error_return;
-    
-    nfields = sizeof(fnames_spils)/sizeof(*fnames_spils);
-    mx_ls = mxCreateStructMatrix(1, 1, nfields, fnames_spils);
-
-    if (ls == LS_SPGMR)
-      mxSetField(mx_ls, 0, "name",  mxCreateString("GMRES"));
-    else if (ls == LS_SPBCG)
-      mxSetField(mx_ls, 0, "name",  mxCreateString("BiCGStab"));
-    else
-      mxSetField(mx_ls, 0, "name",  mxCreateString("TFQMR"));
-
-    mxSetField(mx_ls, 0, "nli",   mxCreateDoubleScalar((double)nli));
-    mxSetField(mx_ls, 0, "npe",   mxCreateDoubleScalar((double)npe));
-    mxSetField(mx_ls, 0, "nps",   mxCreateDoubleScalar((double)nps));
-    mxSetField(mx_ls, 0, "ncfl",  mxCreateDoubleScalar((double)ncfl));
-    
-    break;
-
-  }
-
-  mxSetField(plhs[0], 0, "LSInfo", mx_ls);
-
-  /* Successfull return */
-
-  status = 0;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(0);
-
-  /* Error return */
-
- error_return:
-  status = -1;
-  plhs[1] = mxCreateDoubleScalar((double)status);
-  return(-1);
-
-}
-
-
-static int KIM_Set(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  return(0);
-}
-
-static int KIM_Get(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  return(0);
-}
-
-static int KIM_Free(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
-{
-  if (kimData == NULL) return(0);
-
-  KINFree(&kin_mem);
-
-  return;
-}
diff --git a/sundialsTB/kinsol/kim/src/kim.h b/sundialsTB/kinsol/kim/src/kim.h
deleted file mode 100644
index 9facbde..0000000
--- a/sundialsTB/kinsol/kim/src/kim.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.5 $
- * $Date: 2012/03/07 21:50:32 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/kinsol/LICENSE.
- * -----------------------------------------------------------------
- * Header file for the KINSOL Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#ifndef _KIM_H
-#define _KIM_H
-
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-  
-#include <string.h>
-#include <stdlib.h>
-#include "mex.h"
-#include <kinsol/kinsol.h>
-#include <kinsol/kinsol_dense.h>
-#include <kinsol/kinsol_band.h>
-#include <kinsol/kinsol_spgmr.h>
-#include <kinsol/kinsol_spbcgs.h>
-#include <kinsol/kinsol_sptfqmr.h>
-#include <kinsol/kinsol_bbdpre.h>
-
-/*
- * ---------------------------------------------------------------------------------
- * Constants
- * ---------------------------------------------------------------------------------
- */
-
-
-/* Linear solver types */
-
-enum {LS_NONE, LS_DENSE, LS_BAND, LS_SPGMR, LS_SPBCG, LS_SPTFQMR};
-
-/* Preconditioner modules */
-
-enum {PM_NONE, PM_BBDPRE};
-
-/*
- * ---------------------------------------------------------------------------------
- * Types for global data structures
- * ---------------------------------------------------------------------------------
- */
-
-typedef struct kimInterfaceData_ {
-
-  void *kin_mem;        /* KINSOL solver memory */
-
-  long int n;           /* problem dimension */
-
-  N_Vector Y;           /* solution vector */
-
-  int LS;               /* linear solver type */
-  int PM;               /* preconditioner module */
-
-  booleantype errMsg;   /* post error/warning messages? */
-
-  int fig_handle;       /* figure for posting info */
-
-  /* Matlab functions and data associated with this problem */
-
-  mxArray *SYSfct;
-
-  mxArray *JACfct;
-
-  mxArray *PSETfct;
-  mxArray *PSOLfct;
-
-  mxArray *GLOCfct;
-  mxArray *GCOMfct;
-
-  mxArray *mtlb_data;
-
-} *kimInterfaceData;
-
-/*
- * ---------------------------------------------------------------------------------
- * Error and info handler functions
- * ---------------------------------------------------------------------------------
- */
-
-void kimErrHandler(int error_code, 
-                   const char *module, const char *function, 
-                   char *msg, void *eh_data); 
-
-void kimInfoHandler(const char *module, const char *function, 
-                    char *msg, void *ih_data); 
-
-/*
- * ---------------------------------------------------------------------------------
- * Wrapper functions
- * ---------------------------------------------------------------------------------
- */
-
-
-int mxW_KINSys(N_Vector y, N_Vector fy, void *user_data );
-
-/* Dense direct linear solver */
-
-int mxW_KINDenseJac(long int N,
-                    N_Vector y, N_Vector fy, 
-                    DlsMat J, void *user_data,
-                    N_Vector tmp1, N_Vector tmp2);
-
-/* Band direct linear solver */
-
-int mxW_KINBandJac(long int N, long int mupper, long int mlower,
-                   N_Vector u, N_Vector fu, 
-                   DlsMat J, void *user_data,
-                   N_Vector tmp1, N_Vector tmp2);
-
-/* Scaled Preconditioned Iterative Linear Solver (SPGMR or SPBCG) */
-
-int mxW_KINSpilsJac(N_Vector v, N_Vector Jv,
-                    N_Vector y, booleantype *new_y, 
-                    void *user_data);
-int mxW_KINSpilsPset(N_Vector y, N_Vector yscale,
-                     N_Vector fy, N_Vector fscale,
-                     void *user_data, N_Vector vtemp1,
-                     N_Vector vtemp2);
-int mxW_KINSpilsPsol(N_Vector y, N_Vector yscale, 
-                     N_Vector fy, N_Vector fscale, 
-                     N_Vector v, void *user_data,
-                     N_Vector vtemp);
-
-/* BBD Preconditioner */
-
-int mxW_KINGloc(long int Nlocal, N_Vector y, N_Vector gval, void *user_data);
-int mxW_KINGcom(long int Nlocal, N_Vector y, void *user_data);
-
-/*
- * ---------------------------------------------------------------------------------
- * Option handling functions
- * ---------------------------------------------------------------------------------
- */
-
-int get_SolverOptions(const mxArray *options,
-                      booleantype *verbose, booleantype *errmsg,
-                      int *mxiter, int *msbset, int *msbsetsub,
-                      int *etachoice, int *mxnbcf,
-                      double *eta, double *egamma, double *ealpha, double *mxnewtstep, 
-                      double *relfunc, double *fnormtol, double *scsteptol,
-                      double **constraints,
-                      booleantype *noInitSetup, booleantype *noMinEps);
-
-int get_LinSolvOptions(const mxArray *options,
-                       long int *mupper, long int *mlower,
-                       long int *mudq, long int *mldq, double *dqrely,
-                       int *ptype, int *maxrs, int *maxl);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/sundialsTB/kinsol/kim/src/kimOpts.c b/sundialsTB/kinsol/kim/src/kimOpts.c
deleted file mode 100644
index 421d26d..0000000
--- a/sundialsTB/kinsol/kim/src/kimOpts.c
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2012/03/07 21:50:32 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/kinsol/LICENSE.
- * -----------------------------------------------------------------
- * Option parsing functions for the KINSOL Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#include <string.h>
-#include "kim.h"
-
-/*
- * ---------------------------------------------------------------------------------
- * Global interface data variable (defined in kim.c)
- * ---------------------------------------------------------------------------------
- */
-
-extern kimInterfaceData kimData;
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define N            (kimData->n)
-#define ls           (kimData->LS)
-#define pm           (kimData->PM)
-
-#define mtlb_data    (kimData->mtlb_data)
-
-#define mtlb_JACfct  (kimData->JACfct)
-#define mtlb_PSETfct (kimData->PSETfct)
-#define mtlb_PSOLfct (kimData->PSOLfct)
-#define mtlb_GLOCfct (kimData->GLOCfct)
-#define mtlb_GCOMfct (kimData->GCOMfct)
-
-/*
- * ---------------------------------------------------------------------------------
- * Option handling functions
- * ---------------------------------------------------------------------------------
- */
-
-int get_SolverOptions(const mxArray *options,
-                      booleantype *verbose, booleantype *errmsg,
-                      int *mxiter, int *msbset, int *msbsetsub, 
-                      int *etachoice, int *mxnbcf,
-                      double *eta, double *egamma, double *ealpha, double *mxnewtstep, 
-                      double *relfunc, double *fnormtol, double *scsteptol,
-                      double **constraints,
-                      booleantype *noInitSetup, booleantype *noMinEps)
-{
-  mxArray *opt;
-  char *bufval;
-  int buflen, status;
-  long int i, m, n;
-  double *tmp;
-
-  /* Set default values (pass 0 values. KINSOL does the rest) */
-
-  *mxiter = 0;
-  *msbset = 0;
-  *msbsetsub = 0;
-  *mxnbcf = 0;
-  *etachoice = KIN_ETACHOICE1;
-
-  *eta = 0.0;
-  *egamma = 0.0;
-  *ealpha = 0.0;
-  *mxnewtstep = 0.0;
-  *relfunc = 0.0;
-  *fnormtol = 0.0;
-  *scsteptol = 0.0;
-
-  *noInitSetup = FALSE;
-  *noMinEps = FALSE;
-
-  *constraints = NULL;
-
-  *verbose = FALSE;
-  *errmsg = TRUE;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* User data */
-
-  opt = mxGetField(options,0,"UserData");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_data);
-    mtlb_data = mxDuplicateArray(opt);
-  }
-
-  /* Integer values */
-
-  opt = mxGetField(options,0,"MaxNumIter");
-  if ( !mxIsEmpty(opt) )
-    *mxiter = (int)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"MaxNumSetups");
-  if ( !mxIsEmpty(opt) )
-    *msbset = (int)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"MaxNumSubSetups");
-  if ( !mxIsEmpty(opt) )
-    *msbsetsub = (int)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"MaxNumBetaFails");
-  if ( !mxIsEmpty(opt) )
-    *mxnbcf = (int)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"EtaForm");
-  if ( !mxIsEmpty(opt) ) {
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "Cannot parse EtaForm.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"Type1"))         *etachoice = KIN_ETACHOICE1;
-    else if(!strcmp(bufval,"Type2"))    *etachoice = KIN_ETACHOICE2;
-    else if(!strcmp(bufval,"Constant")) *etachoice = KIN_ETACONSTANT;
-    else {
-      kimErrHandler(-999, "KINSOL", "KINInit", "EtaForm has an illegal value.", NULL);
-      return(-1);
-    }
-  }
-  
-  /* Real values */
-
-  opt = mxGetField(options,0,"Eta");
-  if ( !mxIsEmpty(opt) )
-    *eta = (double)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"EtaAlpha");
-  if ( !mxIsEmpty(opt) )
-    *ealpha = (double)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"EtaGamma");
-  if ( !mxIsEmpty(opt) )
-    *egamma = (double)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"MaxNewtonStep");
-  if ( !mxIsEmpty(opt) )
-    *mxnewtstep = (double)*mxGetPr(opt);
-  
-  opt = mxGetField(options,0,"FuncRelErr");
-  if ( !mxIsEmpty(opt) )
-    *relfunc = (double)*mxGetPr(opt);
-
-  opt = mxGetField(options,0,"FuncNormTol");
-  if ( !mxIsEmpty(opt) )
-    *fnormtol = (double)*mxGetPr(opt);
-
-  opt = mxGetField(options,0,"ScaledStepTol");
-  if ( !mxIsEmpty(opt) )
-    *scsteptol = (double)*mxGetPr(opt);
-
-  /* Boolean values */
-
-  opt = mxGetField(options,0,"ErrorMessages");
-  if ( !mxIsEmpty(opt) ) {
-    if (!mxIsLogical(opt)) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "ErrorMessages is not a logical scalar.", NULL);
-      return(-1);
-    }
-    if (mxIsLogicalScalarTrue(opt)) *errmsg = TRUE;
-    else                            *errmsg = FALSE;
-  }
-
-  opt = mxGetField(options,0,"Verbose");
-  if ( !mxIsEmpty(opt) ) {
-    if (!mxIsLogical(opt)) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "Verbose is not a logical scalar.", NULL);
-      return(-1);
-    }
-    if (mxIsLogicalScalarTrue(opt)) *verbose = TRUE;
-    else                            *verbose = FALSE;
-  }
-
-  opt = mxGetField(options,0,"InitialSetup");
-  if ( !mxIsEmpty(opt) ) {
-    if (!mxIsLogical(opt)) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "InitialSetup is not a logical scalar.", NULL);
-      return(-1);
-    }
-    if (mxIsLogicalScalarTrue(opt)) *noInitSetup = FALSE;
-    else                            *noInitSetup = TRUE;
-  }
-
-
-  opt = mxGetField(options,0,"MinBoundEps");
-  if ( !mxIsEmpty(opt) ) {
-    if (!mxIsLogical(opt)) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "MinBoundEps is not a logical scalar.", NULL);
-      return(-1);
-    }
-    if (mxIsLogicalScalarTrue(opt)) *noMinEps = FALSE;
-    else                            *noMinEps = TRUE;
-  }
-
-  /* Constraints */
-
-  opt = mxGetField(options,0,"Constraints");
-  if ( !mxIsEmpty(opt) ) {
-    m = mxGetM(opt);
-    n = mxGetN(opt);
-    if ( (n != 1) && (m != 1) ) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "constraints is not a vector.", NULL);
-      return(-1);
-    }
-    if ( m > n ) n = m;
-    if ( n != N ) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "constraints has wrong number of components.", NULL);
-      return(-1);
-    }
-    tmp = mxGetPr(opt);
-    *constraints = (double *) malloc(N*sizeof(double));
-    for (i=0;i<N;i++) (*constraints)[i] = tmp[i];
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-}
-
-
-int get_LinSolvOptions(const mxArray *options,
-                       long int *mupper, long int *mlower,
-                       long int *mudq, long int *mldq, double *dqrely,
-                       int *ptype, int *maxrs, int *maxl)
-{
-  mxArray *opt;
-  char *bufval;
-  int buflen, status;
-  
-  *mupper = 0;
-  *mlower = 0;
-
-  *mudq = 0;
-  *mldq = 0;
-  *dqrely = 0.0;
-
-  *ptype = PREC_NONE;
-
-  *maxl  = 0;
-  *maxrs = 0;
-
-  ls = LS_DENSE;
-  pm = PM_NONE;
-
-  /* Return now if options was empty */
-
-  if (mxIsEmpty(options)) return(0);
-
-  /* Linear solver type */
-
-  opt = mxGetField(options,0,"LinearSolver");
-  if ( !mxIsEmpty(opt) ) {
-    buflen = mxGetM(opt) * mxGetN(opt) + 1;
-    bufval = mxCalloc(buflen, sizeof(char));
-    status = mxGetString(opt, bufval, buflen);
-    if(status != 0) {
-      kimErrHandler(-999, "KINSOL", "KINInit", "Cannot parse LinearSolver.", NULL);
-      return(-1);
-    }
-    if(!strcmp(bufval,"Band"))          ls = LS_BAND;
-    else if(!strcmp(bufval,"GMRES"))    ls = LS_SPGMR;
-    else if(!strcmp(bufval,"BiCGStab")) ls = LS_SPBCG;
-    else if(!strcmp(bufval,"TFQMR"))    ls = LS_SPTFQMR;
-    else if(!strcmp(bufval,"Dense"))    ls = LS_DENSE;
-    else {
-      kimErrHandler(-999, "KINSOL", "KINInit", "LinearSolver has an illegal value.", NULL);
-      return(-1);
-    }
-  }
-  
-  /* Jacobian function */
-
-  opt = mxGetField(options,0,"JacobianFn");
-  if ( !mxIsEmpty(opt) ) {
-    mxDestroyArray(mtlb_JACfct);
-    mtlb_JACfct  = mxDuplicateArray(opt);
-  }
-
-  /* Band linear solver */
-
-  if (ls==LS_BAND) {
-
-    opt = mxGetField(options,0,"UpperBwidth");
-    if ( !mxIsEmpty(opt) )
-      *mupper = (long int)*mxGetPr(opt);
-    
-    opt = mxGetField(options,0,"LowerBwidth");
-    if ( !mxIsEmpty(opt) )
-      *mlower = (long int)*mxGetPr(opt);
-
-  }
-  
-  /*  SPGMR linear solver options */
-
-  if (ls==LS_SPGMR) {
-
-    opt = mxGetField(options,0,"MaxNumRestarts");
-    if ( !mxIsEmpty(opt) )
-      *maxrs = (int)*mxGetPr(opt);  
-
-  }
-
-  /* SPILS linear solver options */
-
-  if ( (ls==LS_SPGMR) || (ls==LS_SPBCG) || (ls==LS_SPTFQMR) ) {
-
-    /* Max. dimension of Krylov subspace */
-
-    opt = mxGetField(options,0,"KrylovMaxDim");
-    if ( !mxIsEmpty(opt) ) {
-      *maxl = (int)*mxGetPr(opt);
-      if (*maxl < 0) {
-        kimErrHandler(-999, "KINSOL", "KINInit", "KrylovMaxDim is negative.", NULL);
-        return(-1);
-      }
-    }
-
-    /* Preconditioning type */
-
-    opt = mxGetField(options,0,"PrecType");
-    if ( !mxIsEmpty(opt) ) {
-      buflen = mxGetM(opt) * mxGetN(opt) + 1;
-      bufval = mxCalloc(buflen, sizeof(char));
-      status = mxGetString(opt, bufval, buflen);
-      if(status != 0) {
-        kimErrHandler(-999, "KINSOL", "KINInit", "Cannot parse PrecType.", NULL);
-        return(-1);
-      }
-      if(!strcmp(bufval,"Right"))     *ptype = PREC_RIGHT;
-      else if(!strcmp(bufval,"None")) *ptype = PREC_NONE;
-      else {
-        kimErrHandler(-999, "KINSOL", "KINInit", "PrecType has an illegal value.", NULL);
-        return(-1);
-      }
-    }
-
-    /* User defined precoditioning */
-
-    opt = mxGetField(options,0,"PrecSetupFn");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_PSETfct);
-      mtlb_PSETfct  = mxDuplicateArray(opt);
-    }
-  
-    opt = mxGetField(options,0,"PrecSolveFn");
-    if ( !mxIsEmpty(opt) ) {
-      mxDestroyArray(mtlb_PSOLfct);
-      mtlb_PSOLfct  = mxDuplicateArray(opt);
-    }
-    
-    /* Preconditioner module */
-  
-    opt = mxGetField(options,0,"PrecModule");
-    if ( !mxIsEmpty(opt) ) {
-      buflen = mxGetM(opt) * mxGetN(opt) + 1;
-      bufval = mxCalloc(buflen, sizeof(char));
-      status = mxGetString(opt, bufval, buflen);
-      if(status != 0) {
-        kimErrHandler(-999, "KINSOL", "KINInit", "Cannot parse PrecModule.", NULL);
-        return(-1);
-      }
-      if(!strcmp(bufval,"BBDPre"))           pm = PM_BBDPRE;
-      else if(!strcmp(bufval,"UserDefined")) pm = PM_NONE;
-      else {
-        kimErrHandler(-999, "KINSOL", "KINInit", "PrecModule has an illegal value.", NULL);
-        return(-1);
-      }
-    }
-
-    
-    if (pm == PM_BBDPRE) {
-
-      opt = mxGetField(options,0,"UpperBwidth");
-      if ( !mxIsEmpty(opt) )
-        *mupper = (long int)*mxGetPr(opt);
-    
-      opt = mxGetField(options,0,"LowerBwidth");
-      if ( !mxIsEmpty(opt) )
-        *mlower = (long int)*mxGetPr(opt);
-
-      opt = mxGetField(options,0,"UpperBwidthDQ");
-      if ( !mxIsEmpty(opt) )
-        *mudq = (long int)*mxGetPr(opt);
-
-      opt = mxGetField(options,0,"LowerBwidthDQ");
-      if ( !mxIsEmpty(opt) )
-        *mldq = (long int)*mxGetPr(opt);
-      
-      opt = mxGetField(options,0,"GlocalFn");
-      if ( !mxIsEmpty(opt) ) {
-        mxDestroyArray(mtlb_GLOCfct);
-        mtlb_GLOCfct  = mxDuplicateArray(opt);
-      }
-      else {
-        kimErrHandler(-999, "KINSOL", "KINInit", "GlocalFn required for BBD preconditioner.", NULL);
-        return(-1);
-      }      
-
-      opt = mxGetField(options,0,"GcommFn");
-      if ( !mxIsEmpty(opt) ) {
-        mxDestroyArray(mtlb_GCOMfct);
-        mtlb_GCOMfct  = mxDuplicateArray(opt);
-      }
-      
-    }
-
-  }
-
-  /* We made it here without problems */
-
-  return(0);
-
-}
-
diff --git a/sundialsTB/kinsol/kim/src/kimWrap.c b/sundialsTB/kinsol/kim/src/kimWrap.c
deleted file mode 100644
index 51d8984..0000000
--- a/sundialsTB/kinsol/kim/src/kimWrap.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.6 $
- * $Date: 2012/03/07 21:50:32 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see sundials-x.y.z/src/kinsol/LICENSE.
- * -----------------------------------------------------------------
- * KINSOL wrapper functions.
- * -----------------------------------------------------------------
- */
-
-#include "kim.h"
-#include "nvm.h"
-
-static void UpdateUserData(mxArray *new_mtlb_data, kimInterfaceData kimData);
-
-/*
- * ---------------------------------------------------------------------------------
- * Redability replacements
- * ---------------------------------------------------------------------------------
- */
-
-#define N  (kimData->n)
-#define ls (kimData->LS)
-#define pm (kimData->PM)
-
-/*
- * ---------------------------------------------------------------------------------
- * Wrapper functions
- * ---------------------------------------------------------------------------------
- */
-
-int mxW_KINSys(N_Vector y, N_Vector fy, void *user_data )
-{
-  kimInterfaceData kimData;
-  mxArray *mx_in[3], *mx_out[3];
-  int ret;
-  
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */
-  mx_in[1] = kimData->SYSfct;                  /* matlab function handle */ 
-  mx_in[2] = kimData->mtlb_data;               /* matlab user data */
-
-  /* Call matlab wrapper */
-
-  GetData(y, mxGetPr(mx_in[0]), N);
-
-  mexCallMATLAB(3,mx_out,3,mx_in,"kim_sys");
-
-  PutData(fy, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_KINDenseJac(long int Neq,
-                    N_Vector y, N_Vector fy, 
-                    DlsMat J, void *user_data,
-                    N_Vector tmp1, N_Vector tmp2)
-{
-  kimInterfaceData kimData;
-  double *J_data;
-  mxArray *mx_in[4], *mx_out[3];
-  int i, ret;
-
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fy */
-  mx_in[2] = kimData->JACfct;                   /* matlab function handle */
-  mx_in[3] = kimData->mtlb_data;                /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(y, mxGetPr(mx_in[0]), N);
-  GetData(fy, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(3,mx_out,4,mx_in,"kim_djac");
-
-  J_data = mxGetPr(mx_out[0]);
-  for (i=0;i<N;i++)  memcpy(DENSE_COL(J,i), J_data + i*N, N*sizeof(double));
-  ret = (int)*mxGetPr(mx_out[1]);
- 
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-
-int mxW_KINBandJac(long int Neq, long int mupper, long int mlower,
-                   N_Vector y, N_Vector fy, 
-                   DlsMat J, void *user_data,
-                   N_Vector tmp1, N_Vector tmp2)
-{
-  kimInterfaceData kimData;
-  double *J_data;
-  mxArray *mx_in[4], *mx_out[3];
-  long int eband, i;
-  int ret;
-
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fy */
-  mx_in[2] = kimData->JACfct;                   /* matlab function handle */
-  mx_in[3] = kimData->mtlb_data;                /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(y, mxGetPr(mx_in[0]), N);
-  GetData(fy, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(3,mx_out,4,mx_in,"kim_bjac");
-
-  eband =  mupper + mlower + 1;
-  J_data = mxGetPr(mx_out[0]);
-  for (i=0;i<N;i++) memcpy(BAND_COL(J,i) - mupper, J_data + i*eband, eband*sizeof(double));
-  ret = (int)*mxGetPr(mx_out[1]);
- 
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_KINSpilsJac(N_Vector v, N_Vector Jv,
-                     N_Vector y, booleantype *new_y, 
-                     void *user_data)
-{
-  kimInterfaceData kimData;
-  mxArray *mx_in[5], *mx_out[4];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* vector v */
-  mx_in[2] = mxCreateLogicalScalar(*new_y);     /* */
-  mx_in[3] = kimData->JACfct;                   /* matlab function handle */
-  mx_in[4] = kimData->mtlb_data;                /* matlab user data */
- 
-  /* Call matlab wrapper */
-
-  GetData(y, mxGetPr(mx_in[0]), N);
-  GetData(v, mxGetPr(mx_in[1]), N);
-
-  mexCallMATLAB(4,mx_out,5,mx_in,"kim_jtv");
-
-  PutData(Jv, mxGetPr(mx_out[0]), N);
-  *new_y = mxIsLogicalScalarTrue(mx_out[1]);
-  ret = (int)*mxGetPr(mx_out[2]);
-
-  if (!mxIsEmpty(mx_out[3])) {
-    UpdateUserData(mx_out[3], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-  mxDestroyArray(mx_out[3]);
-
-  return(ret);
-}
-
-int mxW_KINSpilsPset(N_Vector y, N_Vector yscale,
-                     N_Vector fy, N_Vector fscale,
-                     void *user_data, N_Vector vtemp1,
-                     N_Vector vtemp2)
-{
-  kimInterfaceData kimData;
-  mxArray *mx_in[6], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current yscale */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current fscale */
-  mx_in[4] = kimData->PSETfct;                  /* matlab function handle */
-  mx_in[5] = kimData->mtlb_data;                /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(y,      mxGetPr(mx_in[0]), N);
-  GetData(yscale, mxGetPr(mx_in[1]), N);
-  GetData(fy,     mxGetPr(mx_in[2]), N);
-  GetData(fscale, mxGetPr(mx_in[3]), N);
-
-  mexCallMATLAB(2,mx_out,6,mx_in,"kim_pset");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-}
-
-int mxW_KINSpilsPsol(N_Vector y, N_Vector yscale, 
-                     N_Vector fy, N_Vector fscale, 
-                     N_Vector v, void *user_data,
-                     N_Vector vtemp)
-{
-  kimInterfaceData kimData;
-  mxArray *mx_in[7], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL); /* current y */
-  mx_in[1] = mxCreateDoubleMatrix(N,1,mxREAL); /* current yscale */
-  mx_in[2] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fy */
-  mx_in[3] = mxCreateDoubleMatrix(N,1,mxREAL); /* current fscale */
-  mx_in[4] = mxCreateDoubleMatrix(N,1,mxREAL); /* right hand side */
-  mx_in[5] = kimData->PSOLfct;                 /* matlab function handle */
-  mx_in[6] = kimData->mtlb_data;               /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(y,      mxGetPr(mx_in[0]), N);
-  GetData(yscale, mxGetPr(mx_in[1]), N);
-  GetData(fy,     mxGetPr(mx_in[2]), N);
-  GetData(fscale, mxGetPr(mx_in[3]), N);
-  GetData(v,      mxGetPr(mx_in[4]), N);
-
-  mexCallMATLAB(3,mx_out,7,mx_in,"kim_psol");
-
-  PutData(v, mxGetPr(mx_out[0]), N);
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_in[1]);
-  mxDestroyArray(mx_in[2]);
-  mxDestroyArray(mx_in[3]);
-  mxDestroyArray(mx_in[4]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_KINGloc(long int Nlocal, N_Vector y, N_Vector gval, void *user_data)
-{
-  kimInterfaceData kimData;
-  mxArray *mx_in[3], *mx_out[3];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[1] = kimData->GLOCfct;                  /* matlab function handle */
-  mx_in[2] = kimData->mtlb_data;                /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(y, mxGetPr(mx_in[0]), N);
-  mexCallMATLAB(3,mx_out,3,mx_in,"kim_gloc");
-
-  PutData(gval, mxGetPr(mx_out[0]), N);
-
-  ret = (int)*mxGetPr(mx_out[1]);
-
-  if (!mxIsEmpty(mx_out[2])) {
-    UpdateUserData(mx_out[2], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-  mxDestroyArray(mx_out[2]);
-
-  return(ret);
-}
-
-int mxW_KINGcom(long int Nlocal, N_Vector y, void *user_data)
-{
-  kimInterfaceData kimData;
-  mxArray *mx_in[5], *mx_out[2];
-  int ret;
-
-  /* Extract global interface data from user-data */
-  kimData = (kimInterfaceData) user_data;
-
-  /* Inputs to the Matlab function */
-  mx_in[0] = mxCreateDoubleMatrix(N,1,mxREAL);  /* current y */
-  mx_in[1] = kimData->GCOMfct;                  /* matlab function handle */
-  mx_in[2] = kimData->mtlb_data;                /* matlab user data */
-  
-  /* Call matlab wrapper */
-
-  GetData(y, mxGetPr(mx_in[0]), N);
-  mexCallMATLAB(2,mx_out,3,mx_in,"kim_gcom");
-
-  ret = (int)*mxGetPr(mx_out[0]);
-
-  if (!mxIsEmpty(mx_out[1])) {
-    UpdateUserData(mx_out[1], kimData);
-  }
-
-  /* Free temporary space */
-  mxDestroyArray(mx_in[0]);
-  mxDestroyArray(mx_out[0]);
-  mxDestroyArray(mx_out[1]);
-
-  return(ret);
-}
-
-/*
- * ---------------------------------------------------------------------------------
- * Private function to update the user data structure
- * ---------------------------------------------------------------------------------
- */
-
-static void UpdateUserData(mxArray *new_mtlb_data, kimInterfaceData kimData)
-{
-  mexUnlock();
-  mxDestroyArray(kimData->mtlb_data);
-  kimData->mtlb_data = mxDuplicateArray(new_mtlb_data);
-  mexMakeArrayPersistent(kimData->mtlb_data);
-  mexLock();
-}
diff --git a/sundialsTB/nvector/Contents.m b/sundialsTB/nvector/Contents.m
deleted file mode 100644
index 3abbcc1..0000000
--- a/sundialsTB/nvector/Contents.m
+++ /dev/null
@@ -1,17 +0,0 @@
-% SUNDIALS NVECTOR operations
-%
-% Functions:
-%
-%   N_VMax      - returns the largest element of x
-%   N_VMaxNorm  - returns the maximum norm of x
-%   N_VMin      - returns the smallest element of x
-%   N_VDotProd  - returns the dot product of two vectors
-%   N_VWrmsNorm - returns the weighted root mean square norm of x
-%   N_VWL2Norm  - returns the weighted Euclidean L2 norm of x
-%   N_VL1Norm   - returns the L1 norm of x
-%
-% NOTE For serial vectors, all of the above operations default to
-%   the corresponding MATLAB functions. For parallel vectors, they
-%   can be used either on the local portion of the distributed vector
-%   or on the global vector (in which case they will trigger an MPI
-%   allreduce operation).
diff --git a/sundialsTB/nvector/N_VDotProd.m b/sundialsTB/nvector/N_VDotProd.m
deleted file mode 100644
index 79d6ccc..0000000
--- a/sundialsTB/nvector/N_VDotProd.m
+++ /dev/null
@@ -1,26 +0,0 @@
-function ret = N_VDotProd(x,y,comm)
-%N_VDotProd returns the dot product of two vectors
-%
-%   Usage:  RET = N_VDotProd ( X, Y [, COMM] )
-%
-%If COMM is not present, N_VDotProd returns the dot product of the
-%local portions of X and Y. Otherwise, it returns the global dot
-%product.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2006/01/06 19:00:10 $
-
-
-if nargin == 2
-  
-  ret = dot(x,y);
-  
-else
-  
-  ldot = dot(x,y);
-  gdot = 0.0;
-  MPI_Allreduce(ldot,gdot,'SUM',comm);
-  ret = gdot;
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/nvector/N_VL1Norm.m b/sundialsTB/nvector/N_VL1Norm.m
deleted file mode 100644
index a34109d..0000000
--- a/sundialsTB/nvector/N_VL1Norm.m
+++ /dev/null
@@ -1,25 +0,0 @@
-function ret = N_VL1Norm(x,comm)
-%N_VL1Norm returns the L1 norm of x
-%
-%   Usage:  RET = N_VL1Norm ( X [, COMM] )
-%
-%If COMM is not present, N_VL1Norm returns the L1 norm of 
-%the local portion of X. Otherwise, it returns the global
-%L1 norm..
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2006/01/06 19:00:10 $
-
-if nargin == 1
-  
-  ret = norm(x,1);
-  
-else
-  
-  lnrm = norm(x,1);
-  gnrm = 0.0;
-  MPI_Allreduce(lnrm,gnrm,'MAX',comm);
-  ret = gnrm;
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/nvector/N_VMax.m b/sundialsTB/nvector/N_VMax.m
deleted file mode 100644
index 4fc4625..0000000
--- a/sundialsTB/nvector/N_VMax.m
+++ /dev/null
@@ -1,25 +0,0 @@
-function ret = N_VMax(x,comm)
-%N_VMax returns the largest element of x
-%
-%   Usage:  RET = N_VMax ( X [, COMM] )
-%
-%If COMM is not present, N_VMax returns the maximum value of 
-%the local portion of X. Otherwise, it returns the global
-%maximum value.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2006/01/06 19:00:10 $
-
-if nargin == 1
-  
-  ret = max(x);
-  
-else
-  
-  lmax = max(x);
-  gmax = 0.0;
-  MPI_Allreduce(lmax,gmax,'MAX',comm);
-  ret = gmax;
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/nvector/N_VMaxNorm.m b/sundialsTB/nvector/N_VMaxNorm.m
deleted file mode 100644
index 30e01aa..0000000
--- a/sundialsTB/nvector/N_VMaxNorm.m
+++ /dev/null
@@ -1,25 +0,0 @@
-function ret = N_VMaxNorm(x, comm)
-%N_VMaxNorm returns the L-infinity norm of x
-%
-%   Usage:  RET = N_VMaxNorm ( X [, COMM] )
-%
-%If COMM is not present, N_VMaxNorm returns the L-infinity norm 
-%of the local portion of X. Otherwise, it returns the global
-%L-infinity norm..
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2006/01/06 19:00:10 $
-
-if nargin == 1
-  
-  ret = norm(x,'inf');
-  
-else
-  
-  lnrm = norm(x,'inf');
-  gnrm = 0.0;
-  MPI_Allreduce(lnrm,gnrm,'MAX',comm);
-  ret = gnrm;
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/nvector/N_VMin.m b/sundialsTB/nvector/N_VMin.m
deleted file mode 100644
index 3485a8b..0000000
--- a/sundialsTB/nvector/N_VMin.m
+++ /dev/null
@@ -1,24 +0,0 @@
-function ret = N_VMin(x,comm)
-%N_VMin returns the smallest element of x
-%   Usage:  RET = N_VMin ( X [, COMM] )
-%
-%If COMM is not present, N_VMin returns the minimum value of 
-%the local portion of X. Otherwise, it returns the global
-%minimum value.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2006/01/06 19:00:10 $
-
-if nargin == 1
-  
-  ret = min(x);
-  
-else
-  
-  lmin = min(x);
-  gmin = 0.0;
-  MPI_Allreduce(lmin,gmin,'MIN',comm);
-  ret = gmin;
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/nvector/N_VWL2Norm.m b/sundialsTB/nvector/N_VWL2Norm.m
deleted file mode 100644
index 33ae963..0000000
--- a/sundialsTB/nvector/N_VWL2Norm.m
+++ /dev/null
@@ -1,29 +0,0 @@
-function ret = N_VWL2Norm(x,w,comm)
-%N_VWL2Norm returns the weighted Euclidean L2 norm of x 
-%   with weight vector w:
-%   sqrt [(sum (i = 0 to N-1) {(x[i]*w[i])^2})]
-%
-%   Usage:  RET = N_VWL2Norm ( X, W [, COMM] )
-%
-%If COMM is not present, N_VWL2Norm returns the weighted L2
-%norm of the local portion of X. Otherwise, it returns the 
-%global weighted L2 norm..
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2006/01/06 19:00:10 $
-
-if nargin == 2
-  
-  ret = dot(x.^2,w.^2);
-  ret = sqrt(ret);
-  
-else
-  
-  lnrm = dot(x.^2,w.^2);
-  gnrm = 0.0;
-  MPI_Allreduce(lnrm,gnrm,'SUM',comm);
-  
-  ret = sqrt(gnrm);
-  
-end
\ No newline at end of file
diff --git a/sundialsTB/nvector/N_VWrmsNorm.m b/sundialsTB/nvector/N_VWrmsNorm.m
deleted file mode 100644
index b965bf2..0000000
--- a/sundialsTB/nvector/N_VWrmsNorm.m
+++ /dev/null
@@ -1,34 +0,0 @@
-function ret = N_VWrmsNorm(x,w,comm)
-%N_VWrmsNorm returns the weighted root mean square norm of x 
-%with weight vector w: 
-%   sqrt [(sum (i = 0 to N-1) {(x[i]*w[i])^2})/N]
-%
-%   Usage:  RET = N_VWrmsNorm ( X, W [, COMM] )   
-%
-%If COMM is not present, N_VWrmsNorm returns the WRMS norm
-%of the local portion of X. Otherwise, it returns the global
-%WRMS norm..
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.1 $Date: 2006/01/06 19:00:11 $
-
-if nargin == 2
-  
-  ret = dot(x.^2,w.^2);
-  ret = sqrt(ret/length(x));
-  
-else
-  
-  lnrm = dot(x.^2,w.^2);
-  gnrm = 0.0;
-  MPI_Allreduce(lnrm,gnrm,'SUM',comm);
-
-  ln = length(x);
-  gn = 0;
-  MPI_Allreduce(ln,gn,'SUM',comm);
-  
-  ret = sqrt(gnrm/gn);
-  
-end
-
diff --git a/sundialsTB/nvector/src/nvm.h b/sundialsTB/nvector/src/nvm.h
deleted file mode 100644
index 065c808..0000000
--- a/sundialsTB/nvector/src/nvm.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2012/03/07 21:41:19 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see the LICENSE file.
- * -----------------------------------------------------------------
- * Header file for the MNVECTOR Matlab interface.
- * -----------------------------------------------------------------
- */
-
-#ifndef _NVM_H
-#define _NVM_H
-
-#ifdef __cplusplus  /* wrapper to enable C++ usage */
-extern "C" {
-#endif
-
-#include <sundials/sundials_nvector.h>
-#include "mex.h"
-
-  /*
-   * ------------------
-   * Vector functions
-   * ------------------
-   */
-  
-  void InitVectors();
-  N_Vector NewVector(long int n);
-
-  void PutData(N_Vector v, double *data, long int n);
-  void GetData(N_Vector v, double *data, long int n);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/sundialsTB/nvector/src/nvm_ops.c b/sundialsTB/nvector/src/nvm_ops.c
deleted file mode 100644
index 9a303cd..0000000
--- a/sundialsTB/nvector/src/nvm_ops.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2012/03/07 21:41:19 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see the LICENSE file.
- * -----------------------------------------------------------------
- * Vector constructors for the SUNDIALS Matlab interfaces.
- * -----------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include "nvm.h"
-
-void PutData(N_Vector v, double *data, long int n)
-{
-  double *vdata;
-  long int i;
-
-  vdata = N_VGetArrayPointer(v);
-
-  for(i=0;i<n;i++) vdata[i] = data[i];
-
-  return;
-}
-
-
-void GetData(N_Vector v, double *data, long int n)
-{
-  double *vdata;
-  long int i;
-
-  vdata = N_VGetArrayPointer(v);
-
-  for(i=0;i<n;i++) data[i] = vdata[i];
-
-  return;
-}
diff --git a/sundialsTB/nvector/src/nvm_parallel.c b/sundialsTB/nvector/src/nvm_parallel.c
deleted file mode 100644
index 2d9ed5b..0000000
--- a/sundialsTB/nvector/src/nvm_parallel.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2012/03/07 21:41:19 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see the LICENSE file.
- * -----------------------------------------------------------------
- * Vector constructors for the SUNDIALS Matlab interfaces.
- * -----------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include <mpi.h>
-#include "nvm.h"
-#include <nvector/nvector_serial.h>
-#include <nvector/nvector_parallel.h>
-
-int sundials_VecType;
-MPI_Comm sundials_comm;
-
-void InitVectors()
-{
-  const mxArray *mx_comm;
-  char *str;
-
-  /* Check if the Matlab global variable sundials_MPI_comm exists
-     (mpirun and mpiruns set it) */
-
-  mx_comm = mexGetVariable("global", "sundials_MPI_comm");
-
-  if (mx_comm == NULL) {
-
-    /* If it does not exist, set vector type to 1 (serial) */
-
-    sundials_VecType = 1;
-
-  } else {
-
-    /* If it does exist, set vector type to 2 (parallel) and
-       set the MPI communicator */
-    
-    sundials_VecType = 2;
-
-    str = mxArrayToString(mx_comm);
-    if (!strcmp(str,"NULL"  ))      sundials_comm = MPI_COMM_NULL  ;
-    else if (!strcmp(str,"WORLD" )) sundials_comm = MPI_COMM_WORLD ;
-    else if (!strcmp(str,"SELF"  )) sundials_comm = MPI_COMM_SELF  ;
-    else                            sundials_comm = *(MPI_Comm*)mxGetData(mx_comm);
-    
-  }
-
-}
-
-N_Vector NewVector(long int n)
-{
-  N_Vector v;
-  long int nlocal, nglobal;
-
-  if (sundials_VecType == 1) {
-
-    v = N_VNew_Serial((long int)n);
-
-  } else {
-
-    nlocal = n;
-    MPI_Allreduce(&nlocal, &nglobal, 1, MPI_INT, MPI_SUM, sundials_comm);
-    v = N_VNew_Parallel(sundials_comm, nlocal, nglobal);
-
-  }
-
-  return(v);
-}
-
-
diff --git a/sundialsTB/nvector/src/nvm_serial.c b/sundialsTB/nvector/src/nvm_serial.c
deleted file mode 100644
index c58ef66..0000000
--- a/sundialsTB/nvector/src/nvm_serial.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * -----------------------------------------------------------------
- * $Revision: 1.3 $
- * $Date: 2012/03/07 21:41:19 $
- * -----------------------------------------------------------------
- * Programmer: Radu Serban @ LLNL
- * -----------------------------------------------------------------
- * Copyright (c) 2005, The Regents of the University of California.
- * Produced at the Lawrence Livermore National Laboratory.
- * All rights reserved.
- * For details, see the LICENSE file.
- * -----------------------------------------------------------------
- * Vector constructors for the SUNDIALS Matlab interfaces.
- * -----------------------------------------------------------------
- */
-
-#include <stdlib.h>
-#include "nvm.h"
-#include <nvector/nvector_serial.h>
-
-void InitVectors()
-{}
-
-N_Vector NewVector(long int n)
-{
-  N_Vector v;
-  v = N_VNew_Serial(n);
-  return(v);
-}
diff --git a/sundialsTB/putils/Contents.m b/sundialsTB/putils/Contents.m
deleted file mode 100644
index 2ca90c5..0000000
--- a/sundialsTB/putils/Contents.m
+++ /dev/null
@@ -1,9 +0,0 @@
-% Parallel utilities for the Matlab SUNDIALS interfaces
-%
-% Functions:
-%
-% mpirun     - runs parallel examples
-% mpiruns    - runs the parallel example on a child MATLAB process
-% mpistart   - lamboot and MPI_Init master (if required)
-
-
diff --git a/sundialsTB/putils/mpirun.m b/sundialsTB/putils/mpirun.m
deleted file mode 100644
index 2578982..0000000
--- a/sundialsTB/putils/mpirun.m
+++ /dev/null
@@ -1,67 +0,0 @@
-function [] = mpirun(fct,npe,dbg)
-%MPIRUN runs parallel examples.
-%
-%  Usage: MPIRUN ( FCT , NPE [, DBG] )
-%
-%  FCT - function to be executed on all MATLAB processes.
-%  NPE - number of processes to be used (including the master).
-%  DBG - flag for debugging [ true | {false} ]
-%        If true, spawn MATLAB child processes with a visible xterm.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2006/03/07 01:20:01 $
-
-ih = isa(fct,'function_handle');
-is = isa(fct,'char');
-if ih
-  sh = functions(fct);
-  fct_str = sh.function;
-elseif is
-  fct_str = fct;
-else
-  error('mpirun:: Unrecognized function');
-end
-
-if exist(fct_str) ~= 2
-  err_msg = sprintf('mpirun:: Function %s not in search path.',fct_str);
-  error(err_msg);
-end
-  
-nslaves = npe-1;
-mpistart(nslaves);
-
-debug = false;
-if (nargin > 2) & dbg
-  debug = true;
-end
-
-cmd_slaves = sprintf('mpiruns(''%s'')',fct_str);
-
-if debug
-  cmd = 'xterm';
-  args = {'-sb','-sl','5000','-e','matlab','-nosplash','-nojvm','-r',cmd_slaves};
-else
-  cmd = 'matlab';
-  args = {'-nosplash','-nojvm','-r',cmd_slaves};
-end
-
-[info children errs] = MPI_Comm_spawn(cmd,args,nslaves,'NULL',0,'SELF');
-
-[info NEWORLD] = MPI_Intercomm_merge(children,0);
-
-% Put the MPI communicator in the global workspace
-global sundials_MPI_comm;
-sundials_MPI_comm = NEWORLD;
-
-% Get rank of current process and put it in the global workspace
-[status mype] = MPI_Comm_rank(NEWORLD);
-global sundials_MPI_rank;
-sundials_MPI_rank = mype;
-
-% Call the user main program
-feval(fct,NEWORLD);
-
-% Clear the global MPI communicator variable
-clear sundials_MPI_comm
-
diff --git a/sundialsTB/putils/mpiruns.m b/sundialsTB/putils/mpiruns.m
deleted file mode 100644
index 321128b..0000000
--- a/sundialsTB/putils/mpiruns.m
+++ /dev/null
@@ -1,50 +0,0 @@
-function [] = mpiruns(fct)
-%MPIRUNS runs the parallel example on a child MATLAB process.
-%
-%  Usage: MPIRUNS ( FCT )
-%
-%  This function should not be called directly. It is called
-%  by mpirun on the spawned child processes.
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2005, The Regents of the University of California.
-% $Revision: 1.2 $Date: 2006/03/07 01:20:01 $
-
-clc;
-
-[dummy hostname]=system('hostname');
-fprintf('mpiruns :: child MATLAB process on %s\n',hostname);
-
-MPI_Init;
-
-MPI_Errhandler_set('WORLD','RETURN');
-
-[info parent] = MPI_Comm_get_parent;
-
-fprintf('mpiruns :: waiting to merge MPI intercommunicators ... ');
-[info NEWORLD] = MPI_Intercomm_merge(parent,1);
-fprintf('OK!\n\n');
-
-MPI_Errhandler_set(NEWORLD,'RETURN');
-
-% Put the MPI communicator in the global workspace
-global sundials_MPI_comm;
-sundials_MPI_comm = NEWORLD;
-
-% Get rank of current process and put it in the global workspace
-[status mype] = MPI_Comm_rank(NEWORLD);
-global sundials_MPI_rank;
-sundials_MPI_rank = mype;
-
-fprintf('mpiruns :: MPI rank: %d\n\n',mype);
-
-fprintf('----------------------------------------------------------------\n\n');
-
-% Call the user main program
-feval(fct,NEWORLD);
-
-% Clear the global MPI communicator variable
-clear sundials_MPI_comm
-
-% Finalize MPI on this slave
-MPI_Finalize;
\ No newline at end of file
diff --git a/sundialsTB/putils/mpistart.m b/sundialsTB/putils/mpistart.m
deleted file mode 100644
index 61b09ae..0000000
--- a/sundialsTB/putils/mpistart.m
+++ /dev/null
@@ -1,324 +0,0 @@
-function mpistart(nslaves, rpi, hosts)
-%MPISTART invokes lamboot (if required) and MPI_Init (if required).
-%
-%   Usage: MPISTART [ ( NSLAVES [, RPI [, HOSTS] ] ) ]
-%
-%   MPISTART boots LAM and initializes MPI to match a given number of slave 
-%   hosts (and rpi) from a given list of hosts. All three args optional.
-%
-%   If they are not defined, HOSTS are taken from a builtin HOSTS list
-%   (edit HOSTS at the beginning of this file to match your cluster)
-%   or from the bhost file if defined through LAMBHOST (in this order).
-%
-%   If not defined, RPI is taken from the builtin variable RPI (edit it
-%   to suit your needs) or from the LAM_MPI_SSI_rpi environment variable
-%   (in this order).
-
-% Heavily based on the LAM_Init function in MPITB.
-
-%------------------------------
-% ARGCHECK
-%------------------------------
-
-% List of hosts
-
-if nargin>2
-
-% Hosts passed as an argument...
-
-  if ~iscell(hosts)
-    error('MPISTART: 3rd arg is not a cell');
-  end        
-  for i=1:length(hosts)
-    if ~ischar(hosts{i})
-      error('MPISTART: 3rd arg is not cell-of-strings');
-    end
-  end
-
-else
-
-% Get hosts from file specified in env. var. LAMBHOST
-
-  bfile = getenv('LAMBHOST');
-  if isempty(bfile)
-    error('MPISTART: cannot find list of hosts');
-  end
-  hosts = readHosts(bfile);
-
-end
-
-% RPI
-
-if nargin>1
-
-% RPI passed as an argument
-
-  if ~ischar(rpi)
-    error('MPISTART: 2nd arg is not a string')
-  end
-% Get full rpi name, if single letter used
-  rpi = rpi_str(rpi);
-  if isempty(rpi)
-    error('MPISTART: 2nd arg is not a known RPI')
-  end
-
-else
-
-% Get RPI from env. var. LAM_MPI_SSI_rpi
-
-  RPI = getenv('LAM_MPI_SSI_rpi');
-  if isempty(RPI)
-%   If LAM_MPI_SSI_rpi not defined, use RPI='tcp'
-    RPI = 'tcp';
-  end
-  rpi = rpi_str(RPI);
-
-end
-
-% Number of slaves
-
-if nargin>0
-  if ~isreal(nslaves) || fix(nslaves)~=nslaves  || nslaves>=length(hosts)
-    error('MPISTART: 1st arg is not a valid #slaves')
-  end
-else
-  nslaves = length(hosts)-1;
-end
-
-%------------------------------
-% LAMHALT %
-%-------------------------------------------------------------
-% reasons to lamhalt:
-% - not enough nodes  (nslv+1) % NHL < NSLAVES+1
-% - localhost not      in list % weird - just lamboot (NHL=0)
-% - localhost not last in list % weird - just lamboot (NHL=0)
-%-------------------------------------------------------------
-
-% Lam Nodes Output
-[stat, LNO] = system('lamnodes');
-if ~stat                                      % already lambooted
-  
-  emptyflag = false;
-  if isempty(LNO)
-    % this shouldn't happen
-    emptyflag=true;
-    % it's MATLAB's fault I think
-    fprintf('pushing stubborn MATLAB "system" call (lamnodes): ');
-  end
-  
-  while isempty(LNO) || stat
-    fprintf('.');
-    [stat, LNO] = system('lamnodes');
-  end
-  if emptyflag
-    fprintf('\n'); 
-  end 
-
-  LF = char(10);
-  LNO = split(LNO,LF);                        % split lines in rows at \n
-  
-  [stat, NHL] = system('lamnodes|wc -l');     % Number of Hosts in Lamnodes
-        
-  emptyflag = false;                          % again,
-  if isempty(NHL)                             % this shouldn't happen
-    emptyflag=true;                           % it's MATLAB's fault I think
-    fprintf('pushing stubborn MATLAB "system" call (lamnodes|wc): ');
-  end
-  while isempty(NHL) || stat
-    fprintf('.');
-    [stat, NHL] = system('lamnodes|wc -l');
-  end
-  if emptyflag
-    fprintf('\n'); 
-  end
-  
-  NHL = str2num(NHL);
-  if NHL ~= size(LNO,1) || ~ NHL>0            % Oh my, logic error
-    NHL= 0;                                   % pretend there are no nodes
-    disp('MPISTART: internal logic error: lamboot')
-  end                                         % to force lamboot w/o lamhalt
-  if isempty(findstr(LNO(end,:),'this_node')) % master computer last in list
-    disp('MPISTART: local host is not last in nodelist, hope that''s right')
-    beforeflag=0;
-    for i=1:size(LNO,1)
-      if ~isempty(findstr(LNO(i,:),'this_node'))
-        beforeflag=1; 
-        break;                                % well, not 1st but it's there
-      end
-    end                                       % we already warned the user
-    if ~beforeflag                            % Oh my, incredible, not there
-      NHL= 0;                                 % pretend there are no nodes
-      disp('MPISTART: local host not in LAM? lamboot')
-    end
-  end                                         % to force lamboot w/o lamhalt
-
-  if NHL > 0                                  % accurately account multiprocessors
-    NCL = 0;                                  % number of CPUs in lamnodes
-    for i=1:size(LNO,1)                       % add the 2nd ":"-separated
-      fields=split(LNO(i,:),':');             % field, ie, #CPUs
-      NCL = NCL + str2num(fields(2,:));
-    end
-    if NCL<NHL                                % Oh my, logic error
-      NHL= 0;                                 % pretend there are no nodes
-      disp('MPISTART: internal logic error: lamboot')
-    else
-      % update count
-      NHL=NCL;                                
-    end                                       % can't get count from MPI, 
-  end                                         % since might be not _Init'ed
-
-  if NHL < nslaves+1                          % we have to lamboot
-
-    % but avoid getting caught
-    [infI flgI]=MPI_Initialized;              % Init?
-    [infF flgF]=MPI_Finalized;                % Finalize?
-    if infI ||  infF
-      error('MPISTART: error calling _Initialized/_Finalized?')
-    end
-    if flgI && ~flgF                          % avoid hangup due to
-      MPI_Finalize;                           % inminent lamhalt
-      clear MPI_*                             % force MPI_Init in Mast/Ping
-      disp('MPISTART: MPI already used- clearing before lamboot')
-    end                                       % by pretending "not _Init"
-    if NHL > 0                                % avoid lamhalt in weird cases
-      disp('MPISTART: halting LAM')
-      system('lamhalt');                      % won't get caught on this
-    end
-  end
-end
-
-%------------------------------
-% LAMBOOT
-%-------------------------------------------------------------
-% reasons to lamboot:          %
-% - not lambooted yet          % stat~=0
-% - lamhalted above (or weird) % NHL < NSLAVES+1 (0 _is_ <)
-%-------------------------------------------------------------
-
-if stat || NHL<nslaves+1
-
-  HNAMS=hosts{end};
-  for i=nslaves:-1:1
-    HNAMS=strvcat(hosts{i},HNAMS); 
-  end
-  HNAMS = HNAMS';                             % transpose for "for"
-
-  fid=fopen('bhost','wt');
-  for h = HNAMS
-    fprintf(fid,'%s\n',h');                   % write slaves' hostnames
-  end        
-  fclose(fid);
-  disp  ('MPISTART: booting LAM')
-
-  stat = system('lamboot -s -v bhost');
-
-  if stat                                     % again, this shouldn't happen
-    fprintf('pushing stubborn MATLAB "system" call (lamboot): ');
-    while stat
-      fprintf('.'); stat = system('lamboot -s -v bhost');
-    end
-    fprintf('\n');
-  end
-
-  system('rm -f bhost');                      % don't need bhost anymore
-end                                           % won't wipe on exit/could lamhalt
-
-%------------------------------
-% RPI CHECK
-%------------------------------
-
-[infI flgI] = MPI_Initialized;                % Init?
-[infF flgF] = MPI_Finalized;                  % Finalize?
-
-if infI || infF
-  error('MPISTART: error calling _Initialized/_Finalized?')
-end
- 
-if  flgI && ~flgF                             % Perfect, ready to start
-else                                          % something we could fix?
-  if flgI ||  flgF                            % MPI used, will break
-    clear MPI_*                               % unless we clear MPITB
-    disp('MPISTART: MPI already used- clearing')  % must start over
-  end
-                                                                                
-  MPI_Init;
-end
-
-%------------------------------
-% NSLAVES CHECK
-%------------------------------
-
-[info attr flag] = MPI_Attr_get(MPI_COMM_WORLD,MPI_UNIVERSE_SIZE);
-if info | ~flag
-  error('MPISTART: attribute MPI_UNIVERSE_SIZE does not exist?')
-end
-if attr<2
-  error('MPISTART: required 2 computers in LAM')
-end
-
-%====================================================================
-
-function hosts = readHosts(bfile)
-
-hosts = [];
-
-fid = fopen(bfile);
-if fid == -1
-  fprintf('Cannot open bhost file %s\n',bfile);
-  return;
-end
-
-i = 0;
-while ~feof(fid)
-% get a line
-  l = fgetl(fid);
-% Discard comments
-  ic = min(strfind(l,'#'));
-  if ~isempty(ic), l = l(1:ic-1); end
-% Test if there is anything left :-)
-  if isempty(l), continue; end
-% Got a new host  
-  i = i + 1;
-% Stop at first blank or tab=char(9)
-  indx = find((l==' ') | (l==char(9)));
-  if isempty(indx)
-    hosts{i} = l;
-  else
-    hosts{i} = l(1:min(indx));
-  end
-end
-
-fclose(fid);
-
-
-%====================================================================
-
-function rpi = rpi_str(c)
-%RPI_STR Full LAM SSI RPI string given initial letter(s)
-%
-%  rpi = rpi_str (c)
-%
-%  c    initial char(s) of rpi name: t,l,u,s
-%  rpi  full rpi name, one of: tcp, lamd, usysv, sysv
-%       Use '' if c doesn't match to any supported rpi
-%
- 
-flag = nargin~=1 || isempty(c) || ~ischar(c);
-if flag
-  return
-end
-                                                                                
-c=lower(c(1));
-rpis={'tcp','lamd','usysv','sysv','none'};    % 'none' is sentinel
-
-for i=1:length(rpis)
-  if rpis{i}(1)==c
-    break
-  end
-end
-
-if i<length(rpis)
-  rpi=rpis{i};                                % normal cases
-else
-  rpi='';                                     % no way, unknown rpi
-end
diff --git a/sundialsTB/startup_STB.in b/sundialsTB/startup_STB.in
deleted file mode 100644
index d839508..0000000
--- a/sundialsTB/startup_STB.in
+++ /dev/null
@@ -1,65 +0,0 @@
-function [] = startup_STB(stb)
-% STARTUP_STB  path/environment setup script for sundialsTB
-
-% Radu Serban <radu at llnl.gov>
-% Copyright (c) 2007, The Regents of the University of California.
-% $Revision: 1.7 $Date: 2007/12/05 21:58:17 $
-
-% If called without any argument, use the path specified which was
-% harcoded when startup_STB.m was created.
-
-if nargin == 0
-  stb_path = '@STB_PATH@';
-  stb = fullfile(stb_path,'sundialsTB');
-end
-  
-
-if ~exist(stb, 'dir')
-  warning('SUNDIALS Toolbox not found'); 
-  return
-end
-
-% Add top-level directory to path
-
-addpath(stb);
-
-% Add sundialsTB components to path
-
-q = fullfile(stb,'cvodes');
-if exist(q, 'dir')
-  addpath(q);
-  q = fullfile(stb,'cvodes','cvm');
-  addpath(q);
-  q = fullfile(stb,'cvodes','function_types');
-  addpath(q);
-end
-
-q = fullfile(stb,'idas');
-if exist(q, 'dir')
-  addpath(q);
-  q = fullfile(stb,'idas','idm');
-  addpath(q);
-  q = fullfile(stb,'idas','function_types');
-  addpath(q);
-end
-
-q = fullfile(stb,'kinsol');
-if exist(q, 'dir')
-  addpath(q);
-  q = fullfile(stb,'kinsol','kim');
-  addpath(q);
-  q = fullfile(stb,'kinsol','function_types');
-  addpath(q);
-end
-
-q = fullfile(stb,'nvector');
-if exist(q, 'dir')
-  addpath(q);
-end
-
-q = fullfile(stb,'putils');
-if exist(q, 'dir')
-  addpath(q);
-end
-
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sundials.git



More information about the debian-science-commits mailing list